Merge branch 'master' of gitee.com:openharmony/third_party_jsframework into master

This commit is contained in:
wenlong_12
2022-07-29 01:11:53 +00:00
committed by Gitee
4 changed files with 128 additions and 1 deletions
@@ -65,6 +65,7 @@ import { mockHilog } from './ohos_hilog'
import { mockHiSysEvent } from './ohos_hiSysEvent'
import { mockHiTraceChain } from './ohos_hiTraceChain'
import { mockHiTraceMeter } from './ohos_hiTraceMeter'
import { mockHidebug } from './ohos_hidebug'
import { mockFaultLogger } from './ohos_faultLogger'
import { mockTv } from './tv'
import { mockDtv } from './dtv'
@@ -391,6 +392,8 @@ export function mockRequireNapiFun() {
return mockHilog();
case "hiSysEvent":
return mockHiSysEvent();
case "hidebug":
return mockHidebug();
case "hiTraceChain":
return mockHiTraceChain();
case "hiTraceMeter":
@@ -33,12 +33,20 @@ export const OnContinueResult = {
REJECT: 1,
MISMATCH: 2,
}
export const WindowMode = {
WINDOW_MODE_UNDEFINED: 0,
WINDOW_MODE_FULLSCREEN: 1,
WINDOW_MODE_SPLIT_PRIMARY: 100,
WINDOW_MODE_SPLIT_SECONDARY: 101,
WINDOW_MODE_FLOATING: 102,
}
export function mockAbilityConstant() {
const AbilityConstant = {
LaunchParam,
LaunchReason,
LastExitReason,
OnContinueResult
OnContinueResult,
WindowMode
}
return AbilityConstant;
}
@@ -0,0 +1,74 @@
/*
* Copyright (c) 2022 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import { paramMock } from "../utils"
export function mockHidebug() {
const hidebug = {
getNativeHeapSize: function () {
console.warn("hidebug.getNativeHeapSize interface mocked in the Previewer. How this interface works on the" +
" Previewer may be different from that on a real device.")
return paramMock.paramNumberMock;
},
getNativeHeapAllocatedSize: function () {
console.warn("hidebug.getNativeHeapAllocatedSize interface mocked in the Previewer. How this interface works on the" +
" Previewer may be different from that on a real device.")
return paramMock.paramNumberMock;
},
getNativeHeapFreeSize: function () {
console.warn("hidebug.getNativeHeapFreeSize interface mocked in the Previewer. How this interface works on the" +
" Previewer may be different from that on a real device.")
return paramMock.paramNumberMock;
},
getPss: function () {
console.warn("hidebug.getPss interface mocked in the Previewer. How this interface works on the" +
" Previewer may be different from that on a real device.")
return paramMock.paramNumberMock;
},
getSharedDirty: function () {
console.warn("hidebug.getSharedDirty interface mocked in the Previewer. How this interface works on the" +
" Previewer may be different from that on a real device.")
return paramMock.paramNumberMock;
},
getPrivateDirty: function () {
console.warn("hidebug.getPrivateDirty interface mocked in the Previewer. How this interface works on the" +
" Previewer may be different from that on a real device.")
return paramMock.paramNumberMock;
},
getCpuUsage: function () {
console.warn("hidebug.getCpuUsage interface mocked in the Previewer. How this interface works on the" +
" Previewer may be different from that on a real device.")
return paramMock.paramNumberMock;
},
startProfiling: function (...args) {
console.warn("hidebug.startProfiling interface mocked in the Previewer. How this interface works on the" +
" Previewer may be different from that on a real device.")
},
stopProfiling: function () {
console.warn("hidebug.stopProfiling interface mocked in the Previewer. How this interface works on the" +
" Previewer may be different from that on a real device.")
},
dumpHeapData: function (...args) {
console.warn("hidebug.dumpHeapData interface mocked in the Previewer. How this interface works on the" +
" Previewer may be different from that on a real device.")
},
getServiceDump: function (...args) {
console.warn("hidebug.getServiceDump interface mocked in the Previewer. How this interface works on the" +
" Previewer may be different from that on a real device.")
return paramMock.paramStringMock;
},
}
return hidebug
}
@@ -41,6 +41,18 @@ export function mockUpdate() {
})
}
},
getNewVersionDescription: function (...args) {
console.warn("Updater.getNewVersionDescription interface mocked in the Previewer. How this interface works" +
" on the Previewer may be different from that on a real device.")
const len = args.length
if (len > 0 && typeof args[len - 1] === 'function') {
args[len - 1].call(this, paramMock.businessErrorMock, [ComponentDescription]);
} else {
return new Promise((resolve, reject) => {
resolve([ComponentDescription]);
})
}
},
getCurrentVersionInfo: function (...args) {
console.warn("Updater.getCurrentVersionInfo interface mocked in the Previewer. How this interface works" +
" on the Previewer may be different from that on a real device.")
@@ -53,6 +65,18 @@ export function mockUpdate() {
})
}
},
getCurrentVersionDescription: function (...args) {
console.warn("Updater.getCurrentVersionDescription interface mocked in the Previewer. How this interface works" +
" on the Previewer may be different from that on a real device.")
const len = args.length
if (len > 0 && typeof args[len - 1] === 'function') {
args[len - 1].call(this, paramMock.businessErrorMock, [ComponentDescription]);
} else {
return new Promise((resolve, reject) => {
resolve([ComponentDescription]);
})
}
},
getTaskInfo: function (...args) {
console.warn("Updater.getTaskInfo interface mocked in the Previewer. How this interface works on the" +
" Previewer may be different from that on a real device.")
@@ -255,6 +279,8 @@ export function mockUpdate() {
ClearOptions,
EventClassifyInfo,
UpgradeFile,
DescriptionOptions,
DescriptionFormat,
getOnlineUpdater: function (...args) {
console.warn("update.getOnlineUpdater interface mocked in the Previewer. How this interface works on the" +
" Previewer may be different from that on a real device.")
@@ -365,6 +391,7 @@ const DescriptionInfo = {
}
const VersionComponent = {
componentId: "[PC Preview] unknown componentId",
componentType: ComponentType.OTA,
upgradeAction: UpgradeAction.UPGRADE,
displayVersion: "[PC Preview] unknown displayVersion",
@@ -465,4 +492,19 @@ const EventClassifyInfo = {
const UpgradeFile = {
fileType: ComponentType,
filePath: "[PC Preview] unknown filePath"
}
const DescriptionOptions = {
format: DescriptionFormat,
language: "[PC Preview] unknown language",
}
const ComponentDescription = {
componentId: "[PC Preview] unknown componentId",
descriptionInfo: DescriptionInfo,
}
const DescriptionFormat = {
STANDARD: 0,
SIMPLIFIED : 1,
}