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

This commit is contained in:
Mupceet
2022-07-21 07:35:39 +00:00
committed by Gitee
145 changed files with 10697 additions and 3741 deletions
+1 -1
View File
@@ -289,7 +289,7 @@ ohos_static_library("jsf") {
}
if (!is_cross_platform_build) {
import("//ark/ts2abc/ts2panda/ts2abc_config.gni")
import("//arkcompiler/ets_frontend/ts2panda/ts2abc_config.gni")
ark_abc_path =
get_label_info(":ark_build", "target_out_dir") + "/strip.native.min.abc"
+4 -1
View File
@@ -37,6 +37,8 @@ const {
const frameworkBanner = `var global=this; var process={env:{}}; ` + `var setTimeout=global.setTimeout;\n`;
const frameworkBannerForJSAPIMock = `var global=globalThis;`;
const onwarn = warning => {
// Silence circular dependency warning
if (warning.code === 'CIRCULAR_DEPENDENCY') {
@@ -94,7 +96,8 @@ const configOutput = {
const configJSAPIMockOutput = {
file: path.resolve(__dirname, 'dist/jsMockSystemPlugin.js'),
format: 'umd'
format: 'umd',
banner: frameworkBannerForJSAPIMock
};
rollup.rollup(configInput).then(bundle => {
+1 -25
View File
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2021 Huawei Device Co., Ltd.
* Copyright (c) 2021-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
@@ -1355,30 +1355,6 @@ export function mockAbilityContinuationRegisterManager() {
}
}
}
export function mockAbilityDataUriUtils() {
global.systemplugin.ability.dataUriUtils = {
getId: function (...args) {
console.warn("ability.dataUriUtils.getId interface mocked in the Previewer. How this interface works" +
" on the Previewer may be different from that on a real device.")
return paramMock.paramNumberMock
},
attachId: function (...args) {
console.warn("ability.dataUriUtils.attachId interface mocked in the Previewer. How this interface works" +
" on the Previewer may be different from that on a real device.")
return paramMock.paramStringMock
},
deleteId: function (...args) {
console.warn("ability.dataUriUtils.deleteId interface mocked in the Previewer. How this interface works" +
" on the Previewer may be different from that on a real device.")
return paramMock.paramStringMock
},
updateId: function (...args) {
console.warn("ability.dataUriUtils.updateId interface mocked in the Previewer. How this interface works" +
" on the Previewer may be different from that on a real device.")
return paramMock.paramStringMock
}
}
}
export function mockAbilityAbilityAgent() {
global.systemplugin.ability.abilityAgent = {
on: function (...args) {
+61
View File
@@ -0,0 +1,61 @@
/*
* 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 { hasComplete } from "./utils"
export function mockBrightness() {
global.systemplugin.brightness = {
argsV: {
value: 80
},
argsM: {
mode: 0
},
getValue: function (...args) {
console.warn("brightness.getValue interface mocked in the Previewer. How this interface works on the Previewer" +
" may be different from that on a real device.")
args[0].success(this.argsV)
hasComplete(args[0].complete)
},
setValue: function (...args) {
console.warn("brightness.setValue interface mocked in the Previewer. How this interface works on the Previewer" +
" may be different from that on a real device.")
if (args[0].value) {
this.argsV.value = args[0].value
args[0].success()
hasComplete(args[0].complete)
}
},
getMode: function (...args) {
console.warn("brightness.getMode interface mocked in the Previewer. How this interface works on the Previewer" +
" may be different from that on a real device.")
args[0].success(this.argsM)
hasComplete(args[0].complete)
},
setMode: function (...args) {
console.warn("brightness.setMode interface mocked in the Previewer. How this interface works on the Previewer" +
" may be different from that on a real device.")
this.argsM.mode = args[0].mode
args[0].success()
hasComplete(args[0].complete)
},
setKeepScreenOn: function (...args) {
console.warn("brightness.setKeepScreenOn interface mocked in the Previewer. How this interface works on the" +
" Previewer may be different from that on a real device.")
args[0].success()
hasComplete(args[0].complete)
}
}
}
+2 -1
View File
@@ -20,13 +20,13 @@ import {
mockAbilityParticleAbility,
mockAbilityFormManager,
mockAbilityContinuationRegisterManager,
mockAbilityDataUriUtils,
mockAbilityAbilityAgent,
mockAbilityFormBindingData
} from './ability'
import { mockAppAbilityManager } from './ohos/app'
import { mockBattery } from './battery'
import { mockBrightness } from './brightness'
import { mockOhosBluetooth } from './ohos/bluetooth'
import { mockDistributedSchedule } from './distributedSchedule'
import { mockFetch } from './fetch'
@@ -63,6 +63,7 @@ export function mockSystemPlugin() {
mockSensor()
mockGeolocation()
mockBattery()
mockBrightness()
mockSystemPackage()
mockFeatureAbility()
mockOhosBluetooth()
@@ -0,0 +1,253 @@
/*
* 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 { FormBindingData } from "../ohos_application_formBindingData"
import { FormState } from "../ohos_application_formInfo"
import { paramMock } from "../../utils"
import { RemoteObjectClass } from "../ohos_rpc"
import { ResultSet, PacMapType } from "../ohos_ability_featureAbility"
const DataAbilityResult = {
uri: "[PC Preview] unknow uri",
count: "[PC Preview] unknow count",
}
export const LifecycleForm = {
onCreate: function (...args) {
console.warn("LifecycleForm.onCreate interface mocked in the Previewer. How this interface works on the Previewer may" +
" be different from that on a real device.")
return FormBindingData;
},
onCastToNormal: function (...args) {
console.warn("LifecycleForm.onCastToNormal interface mocked in the Previewer. How this interface works on the Previewer may" +
" be different from that on a real device.")
},
onUpdate: function (...args) {
console.warn("LifecycleForm.onUpdate interface mocked in the Previewer. How this interface works on the Previewer may" +
" be different from that on a real device.")
},
onVisibilityChange: function (...args) {
console.warn("LifecycleForm.onVisibilityChange interface mocked in the Previewer. How this interface works on the Previewer may" +
" be different from that on a real device.")
},
onEvent: function (...args) {
console.warn("LifecycleForm.onEvent interface mocked in the Previewer. How this interface works on the Previewer may" +
" be different from that on a real device.")
},
onDestroy: function (...args) {
console.warn("LifecycleForm.onDestroy interface mocked in the Previewer. How this interface works on the Previewer may" +
" be different from that on a real device.")
},
onAcquireFormState: function (...args) {
console.warn("LifecycleForm.onAcquireFormState interface mocked in the Previewer. How this interface works on the Previewer may" +
" be different from that on a real device.")
return FormState;
},
}
export const LifecycleApp = {
onShow: function () {
console.warn("LifecycleApp.onShow interface mocked in the Previewer. How this interface works on the Previewer may" +
" be different from that on a real device.")
},
onHide: function () {
console.warn("LifecycleApp.onHide interface mocked in the Previewer. How this interface works on the Previewer may" +
" be different from that on a real device.")
},
onDestroy: function () {
console.warn("LifecycleApp.onDestroy interface mocked in the Previewer. How this interface works on the Previewer may" +
" be different from that on a real device.")
},
onCreate: function () {
console.warn("LifecycleApp.onCreate interface mocked in the Previewer. How this interface works on the Previewer may" +
" be different from that on a real device.")
},
onWindowDisplayModeChanged: function (...args) {
console.warn("LifecycleApp.onWindowDisplayModeChanged interface mocked in the Previewer. How this interface works on the Previewer may" +
" be different from that on a real device.")
},
onStartContinuation: function () {
console.warn("LifecycleApp.onStartContinuation interface mocked in the Previewer. How this interface works on the Previewer may" +
" be different from that on a real device.")
return paramMock.paramBooleanMock;
},
onSaveData: function (...args) {
console.warn("LifecycleApp.onSaveData interface mocked in the Previewer. How this interface works on the Previewer may" +
" be different from that on a real device.")
return paramMock.paramBooleanMock;
},
onCompleteContinuation: function (...args) {
console.warn("LifecycleApp.onCompleteContinuation interface mocked in the Previewer. How this interface works on the Previewer may" +
" be different from that on a real device.")
},
onRestoreData: function (...args) {
console.warn("LifecycleApp.onRestoreData interface mocked in the Previewer. How this interface works on the Previewer may" +
" be different from that on a real device.")
},
onRemoteTerminated: function () {
console.warn("LifecycleApp.onRemoteTerminated interface mocked in the Previewer. How this interface works on the Previewer may" +
" be different from that on a real device.")
},
onSaveAbilityState: function (...args) {
console.warn("LifecycleApp.onSaveAbilityState interface mocked in the Previewer. How this interface works on the Previewer may" +
" be different from that on a real device.")
},
onRestoreAbilityState: function (...args) {
console.warn("LifecycleApp.onRestoreAbilityState interface mocked in the Previewer. How this interface works on the Previewer may" +
" be different from that on a real device.")
},
onInactive: function () {
console.warn("LifecycleApp.onInactive interface mocked in the Previewer. How this interface works on the Previewer may" +
" be different from that on a real device.")
},
onActive: function () {
console.warn("LifecycleApp.onActive interface mocked in the Previewer. How this interface works on the Previewer may" +
" be different from that on a real device.")
},
onNewWant: function (...args) {
console.warn("LifecycleApp.onNewWant interface mocked in the Previewer. How this interface works on the Previewer may" +
" be different from that on a real device.")
},
onMemoryLevel: function (...args) {
console.warn("LifecycleApp.onMemoryLevel interface mocked in the Previewer. How this interface works on the Previewer may" +
" be different from that on a real device.")
},
}
export const LifecycleService = {
onStart: function () {
console.warn("LifecycleService.onStart interface mocked in the Previewer. How this interface works on the Previewer may" +
" be different from that on a real device.")
},
onCommand: function (...args) {
console.warn("LifecycleService.onCommand interface mocked in the Previewer. How this interface works on the Previewer may" +
" be different from that on a real device.")
},
onStop: function () {
console.warn("LifecycleService.onStop interface mocked in the Previewer. How this interface works on the Previewer may" +
" be different from that on a real device.")
},
onConnect: function (...args) {
console.warn("LifecycleService.onConnect interface mocked in the Previewer. How this interface works on the Previewer may" +
" be different from that on a real device.")
return new RemoteObjectClass();
},
onDisconnect: function (...args) {
console.warn("LifecycleService.onDisconnect interface mocked in the Previewer. How this interface works on the Previewer may" +
" be different from that on a real device.")
},
onReconnect: function (...args) {
console.warn("LifecycleService.onReconnect interface mocked in the Previewer. How this interface works on the Previewer may" +
" be different from that on a real device.")
},
}
export const LifecycleData = {
update: function (...args) {
console.warn("LifecycleData.update 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 (typeof args[len - 1] === 'function') {
args[len - 1].call(this, paramMock.businessErrorMock, paramMock.paramNumberMock);
}
},
query: function (...args) {
console.warn("LifecycleData.query 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 (typeof args[len - 1] === 'function') {
args[len - 1].call(this, paramMock.businessErrorMock, ResultSet);
}
},
delete: function (...args) {
console.warn("LifecycleData.delete 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 (typeof args[len - 1] === 'function') {
args[len - 1].call(this, paramMock.businessErrorMock, paramMock.paramNumberMock);
}
},
normalizeUri: function (...args) {
console.warn("LifecycleData.normalizeUri 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 (typeof args[len - 1] === 'function') {
args[len - 1].call(this, paramMock.businessErrorMock, paramMock.paramStringMock);
}
},
batchInsert: function (...args) {
console.warn("LifecycleData.batchInsert 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 (typeof args[len - 1] === 'function') {
args[len - 1].call(this, paramMock.businessErrorMock, paramMock.paramNumberMock);
}
},
denormalizeUri: function (...args) {
console.warn("LifecycleData.denormalizeUri 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 (typeof args[len - 1] === 'function') {
args[len - 1].call(this, paramMock.businessErrorMock, paramMock.paramStringMock);
}
},
insert: function (...args) {
console.warn("LifecycleData.insert 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 (typeof args[len - 1] === 'function') {
args[len - 1].call(this, paramMock.businessErrorMock, paramMock.paramNumberMock);
}
},
openFile: function (...args) {
console.warn("LifecycleData.openFile 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 (typeof args[len - 1] === 'function') {
args[len - 1].call(this, paramMock.businessErrorMock, paramMock.paramNumberMock);
}
},
getFileTypes: function (...args) {
console.warn("LifecycleData.getFileTypes 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 (typeof args[len - 1] === 'function') {
args[len - 1].call(this, paramMock.businessErrorMock, [paramMock.paramStringMock]);
}
},
onInitialized: function (...args) {
console.warn("LifecycleData.onInitialized interface mocked in the Previewer. How this interface works on the Previewer may" +
" be different from that on a real device.")
},
getType: function (...args) {
console.warn("LifecycleData.getType 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 (typeof args[len - 1] === 'function') {
args[len - 1].call(this, paramMock.businessErrorMock, paramMock.paramStringMock);
}
},
executeBatch: function (...args) {
console.warn("LifecycleData.executeBatch 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 (typeof args[len - 1] === 'function') {
args[len - 1].call(this, paramMock.businessErrorMock, [DataAbilityResult]);
}
},
call: function (...args) {
console.warn("LifecycleData.call 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 (typeof args[len - 1] === 'function') {
args[len - 1].call(this, paramMock.businessErrorMock, PacMapType);
}
},
}
@@ -0,0 +1,20 @@
/*
* 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 { WantClass } from "../ohos_application_Want"
export const AbilityResult = {
resultCode: "[PC Preview] unknow resultCode",
want: new WantClass(),
}
@@ -0,0 +1,29 @@
/*
* 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.
*/
export const ConnectOptions = {
onConnect: function (...args) {
console.warn("ConnectOptions.onConnect interface mocked in the Previewer. How this interface works" +
" on the Previewer may be different from that on a real device.")
},
onDisconnect: function (...args) {
console.warn("ConnectOptions.onDisconnect interface mocked in the Previewer. How this interface works" +
" on the Previewer may be different from that on a real device.")
},
onFailed: function (...args) {
console.warn("ConnectOptions.onFailed interface mocked in the Previewer. How this interface works" +
" on the Previewer may be different from that on a real device.")
},
}
@@ -0,0 +1,20 @@
/*
* 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 { WantClass } from "../ohos_application_Want"
export const StartAbilityParameter = {
want: new WantClass(),
abilityStartSetting: {},
}
@@ -0,0 +1,27 @@
/*
* 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 const Want = {
deviceId: "[PC Preview] unknow deviceId",
bundleName: "[PC Preview] unknow bundleName",
abilityName: "[PC Preview] unknow abilityName",
uri: "[PC Preview] unknow uri",
type: "[PC Preview] unknow type",
flags: "[PC Preview] unknow flags",
action: "[PC Preview] unknow action",
parameters: {},
entities: [paramMock.paramStringMock]
}
@@ -0,0 +1,20 @@
/*
* 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.
*/
export const AppVersionInfo = {
appName: "[PC Preview] unknow appName",
versionCode: "[PC Preview] unknow versionCode",
versionName: "[PC Preview] unknow versionName",
}
@@ -0,0 +1,317 @@
/*
* 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"
import { ProcessInfo } from "./processInfo"
import { AppVersionInfo } from "./appVersionInfo"
import { AbilityInfo } from "../bundle/abilityInfo"
import { ApplicationInfo } from "../bundle/applicationInfo"
import { ElementName } from "../bundle/elementName"
import { HapModuleInfo } from "../bundle/hapModuleInfo"
const DisplayOrientation = {
UNSPECIFIED: "[PC preview] unknown is UNSPECIFIED",
LANDSCAPE: "[PC preview] unknown is LANDSCAPE",
PORTRAIT: "[PC preview] unknown is PORTRAIT",
FOLLOW_RECENT: "[PC preview] unknown is FOLLOW_RECENT",
LANDSCAPE_INVERTED: "[PC preview] unknown is LANDSCAPE_INVERTED",
PORTRAIT_INVERTED: "[PC preview] unknown is PORTRAIT_INVERTED",
AUTO_ROTATION: "[PC preview] unknown is AUTO_ROTATION",
AUTO_ROTATION_LANDSCAPE: "[PC preview] unknown is AUTO_ROTATION_LANDSCAPE",
AUTO_ROTATION_PORTRAIT: "[PC preview] unknown is AUTO_ROTATION_PORTRAIT",
AUTO_ROTATION_RESTRICTED: "[PC preview] unknown is AUTO_ROTATION_RESTRICTED",
AUTO_ROTATION_LANDSCAPE_RESTRICTED: "[PC preview] unknown is AUTO_ROTATION_LANDSCAPE_RESTRICTED",
AUTO_ROTATION_PORTRAIT_RESTRICTED: "[PC preview] unknown is AUTO_ROTATION_PORTRAIT_RESTRICTED",
LOCKED: "[PC preview] unknown is LOCKED",
}
export const Context = {
getOrCreateLocalDir: function (...args) {
console.warn("Context.getOrCreateLocalDir 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, paramMock.paramStringMock);
} else {
return new Promise((resolve, reject) => {
resolve(paramMock.paramStringMock);
})
}
},
verifyPermission: function (...args) {
console.warn("Context.verifyPermission 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, paramMock.paramNumberMock);
} else {
return new Promise((resolve, reject) => {
resolve(paramMock.paramNumberMock);
})
}
},
requestPermissionsFromUser: function (...args) {
console.warn("Context.requestPermissionsFromUser 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, PermissionRequestResult);
} else {
return new Promise((resolve, reject) => {
resolve(PermissionRequestResult);
})
}
},
getApplicationInfo: function (...args) {
console.warn("Context.getApplicationInfo 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, ApplicationInfo);
} else {
return new Promise((resolve, reject) => {
resolve(ApplicationInfo);
})
}
},
getBundleName: function (...args) {
console.warn("Context.getBundleName 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, paramMock.paramStringMock);
} else {
return new Promise((resolve, reject) => {
resolve(paramMock.paramStringMock);
})
}
},
getDisplayOrientation: function (...args) {
console.warn("Context.getDisplayOrientation 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, DisplayOrientation);
} else {
return new Promise((resolve, reject) => {
resolve(DisplayOrientation);
})
}
},
setDisplayOrientation: function (...args) {
console.warn("Context.setDisplayOrientation 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);
} else {
return new Promise((resolve, reject) => {
resolve();
})
}
},
setShowOnLockScreen: function (...args) {
console.warn("Context.setShowOnLockScreen 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);
} else {
return new Promise((resolve, reject) => {
resolve();
})
}
},
setWakeUpScreen: function (...args) {
console.warn("Context.setWakeUpScreen 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);
} else {
return new Promise((resolve, reject) => {
resolve();
})
}
},
getProcessInfo: function (...args) {
console.warn("Context.getProcessInfo 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, ProcessInfo);
} else {
return new Promise((resolve, reject) => {
resolve(ProcessInfo);
})
}
},
getElementName: function (...args) {
console.warn("Context.getElementName 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, ElementName);
} else {
return new Promise((resolve, reject) => {
resolve(ElementName);
})
}
},
getProcessName: function (...args) {
console.warn("Context.getProcessName 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, paramMock.paramStringMock);
} else {
return new Promise((resolve, reject) => {
resolve(paramMock.paramStringMock);
})
}
},
getCallingBundle: function (...args) {
console.warn("Context.getCallingBundle 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, paramMock.paramStringMock);
} else {
return new Promise((resolve, reject) => {
resolve(paramMock.paramStringMock);
})
}
},
getFilesDir: function (...args) {
console.warn("Context.getFilesDir 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, paramMock.paramStringMock);
} else {
return new Promise((resolve, reject) => {
resolve(paramMock.paramStringMock);
})
}
},
getCacheDir: function (...args) {
console.warn("Context.getCacheDir 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, paramMock.paramStringMock);
} else {
return new Promise((resolve, reject) => {
resolve(paramMock.paramStringMock);
})
}
},
getOrCreateDistributedDir: function (...args) {
console.warn("Context.getOrCreateDistributedDir 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, paramMock.paramStringMock);
} else {
return new Promise((resolve, reject) => {
resolve(paramMock.paramStringMock);
})
}
},
getAppType: function (...args) {
console.warn("Context.getAppType 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, paramMock.paramStringMock);
} else {
return new Promise((resolve, reject) => {
resolve(paramMock.paramStringMock);
})
}
},
getHapModuleInfo: function (...args) {
console.warn("Context.getHapModuleInfo 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, HapModuleInfo);
} else {
return new Promise((resolve, reject) => {
resolve(HapModuleInfo);
})
}
},
getAppVersionInfo: function (...args) {
console.warn("Context.getAppVersionInfo 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, AppVersionInfo);
} else {
return new Promise((resolve, reject) => {
resolve(AppVersionInfo);
})
}
},
getApplicationContext: function () {
console.warn("Context.getApplicationContext interface mocked in the Previewer." +
" How this interface works on the Previewer may be different from that on a real device.")
return Context;
},
getAbilityInfo: function (...args) {
console.warn("Context.getAbilityInfo 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, AbilityInfo);
} else {
return new Promise((resolve, reject) => {
resolve(AbilityInfo);
})
}
},
isUpdatingConfigurations: function (...args) {
console.warn("Context.isUpdatingConfigurations 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, paramMock.paramBooleanMock);
} else {
return new Promise((resolve, reject) => {
resolve(paramMock.paramBooleanMock);
})
}
},
printDrawnCompleted: function (...args) {
console.warn("Context.printDrawnCompleted 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);
} else {
return new Promise((resolve, reject) => {
resolve();
})
}
}
}
export const PermissionRequestResult = {
requestCode: "[PC Preview] unknow requestCode",
permissions: [paramMock.paramStringMock],
authResults: [paramMock.paramNumberMock],
}
export const PermissionOptions = {
pid: "[PC Preview] unknow pid",
uid: "[PC Preview] unknow uid",
}
@@ -0,0 +1,19 @@
/*
* 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.
*/
export const ProcessInfo = {
pid: "[PC Preview] unknow pid",
processName: "[PC Preview] unknow processName",
}
@@ -16,6 +16,8 @@
import { paramMock } from "../../utils"
import { MessageParcelClass } from "../ohos_rpc"
import { ContextClass } from "../ohos_application_ServiceExtAbility"
import { Configuration } from "../ohos_application_Configuration"
import { Caller } from "../ohos_application_Ability"
const ModuleInfoMock = {
moduleName: '[PC preview] unknow moduleName',
@@ -240,37 +242,10 @@ export const ExtensionContextClass = class ExtensionContext extends ContextClass
export const AbilityResultMock = {
resultCode: "[PC Preview] unknow resultCode",
}
const ConfigurationMock = {
language: '[PC preview] unknow language'
}
const PermissionRequestResultMock = {
permissions: [paramMock.paramStringMock],
authResults: [paramMock.paramNumberMock]
}
const CallerMock = {
call: function (...args) {
console.warn("AbilityContext.Caller.call interface mocked in the Previewer." +
" How this interface works on the Previewer may be different from that on a real device.")
return new Promise((resolve, reject) => {
resolve();
})
},
callWithResult: function (...args) {
console.warn("AbilityContext.Caller.callWithResult interface mocked in the Previewer." +
" How this interface works on the Previewer may be different from that on a real device.")
return new Promise((resolve, reject) => {
resolve(new MessageParcelClass());
})
},
release: function (...args) {
console.warn("AbilityContext.Caller.release interface mocked in the Previewer. How this interface works on the Previewer" +
" may be different from that on a real device.")
},
onRelease: function (...args) {
console.warn("AbilityContext.Caller.onRelease interface mocked in the Previewer. How this interface works on the Previewer" +
" may be different from that on a real device.")
},
}
export const AbilityContextClass = class AbilityContext extends ContextClass {
constructor() {
super();
@@ -278,7 +253,7 @@ export const AbilityContextClass = class AbilityContext extends ContextClass {
' the Previewer may be different from that on a real device.');
this.abilityInfo = AbilityInfoMock;
this.currentHapModuleInfo = HapModuleInfoMock;
this.config = ConfigurationMock;
this.config = Configuration;
this.startAbility = function (...args) {
console.warn("Ability.AbilityContext.startAbility interface mocked in the Previewer." +
" How this interface works on the Previewer may be different from that on a real device.")
@@ -295,7 +270,7 @@ export const AbilityContextClass = class AbilityContext extends ContextClass {
console.warn("Ability.AbilityContext.startAbilityByCall interface mocked in the Previewer." +
" How this interface works on the Previewer may be different from that on a real device.")
return new Promise((resolve, reject) => {
resolve(CallerMock);
resolve(Caller);
})
};
this.startAbilityWithAccount = function (...args) {
@@ -334,6 +309,54 @@ export const AbilityContextClass = class AbilityContext extends ContextClass {
})
}
};
this.startServiceExtensionAbility = function (...args) {
console.warn("Ability.AbilityContext.startServiceExtensionAbility 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);
} else {
return new Promise((resolve, reject) => {
resolve();
})
}
};
this.startServiceExtensionAbilityWithAccount = function (...args) {
console.warn("Ability.AbilityContext.startServiceExtensionAbilityWithAccount 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);
} else {
return new Promise((resolve, reject) => {
resolve();
})
}
};
this.stopServiceExtensionAbility = function (...args) {
console.warn("Ability.AbilityContext.stopServiceExtensionAbility 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);
} else {
return new Promise((resolve, reject) => {
resolve();
})
}
};
this.stopServiceExtensionAbilityWithAccount = function (...args) {
console.warn("Ability.AbilityContext.stopServiceExtensionAbilityWithAccount 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);
} else {
return new Promise((resolve, reject) => {
resolve();
})
}
};
this.terminateSelf = function (...args) {
console.warn("Ability.AbilityContext.terminateSelf interface mocked in the Previewer." +
" How this interface works on the Previewer may be different from that on a real device.")
@@ -392,6 +415,18 @@ export const AbilityContextClass = class AbilityContext extends ContextClass {
})
}
};
this.setMissionIcon = function (...args) {
console.warn("Ability.AbilityContext.setMissionIcon 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);
} else {
return new Promise((resolve, reject) => {
resolve();
})
}
};
this.requestPermissionsFromUser = function (...args) {
console.warn("Ability.AbilityContext.requestPermissionsFromUser interface mocked in the Previewer." +
" How this interface works on the Previewer may be different from that on a real device.")
@@ -404,6 +439,10 @@ export const AbilityContextClass = class AbilityContext extends ContextClass {
})
}
};
this.restoreWindowStage = function (...args) {
console.warn("Ability.AbilityContext.restoreWindowStage interface mocked in the Previewer. How this interface works on the Previewer" +
" may be different from that on a real device.")
};
this.isTerminating = function () {
console.warn("Ability.AbilityContext.isTerminating interface mocked in the Previewer. How this interface works on the Previewer" +
" may be different from that on a real device.")
@@ -0,0 +1,18 @@
/*
* 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.
*/
export const BaseContext = {
stageMode: "[PC Preview] unknow stageMode",
}
@@ -0,0 +1,311 @@
/*
* 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 { ApplicationInfo } from "../bundle/applicationInfo"
import { BaseContext } from "./BaseContext"
const ResourceManager = {
getString: function(...args) {
console.warn("ResourceManager.getString 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 (typeof args[len - 1] === 'function') {
args[len - 1].call(this, paramMock.businessErrorMock, paramMock.paramStringMock);
} else {
return new Promise((resolve, reject) => {
resolve(paramMock.paramStringMock);
})
}
},
getStringArray: function(...args) {
console.warn("ResourceManager.getStringArray 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 (typeof args[len - 1] === 'function') {
args[len - 1].call(this, paramMock.businessErrorMock, [paramMock.paramStringMock]);
} else {
return new Promise((resolve, reject) => {
resolve([paramMock.paramStringMock]);
})
}
},
getMedia: function(...args) {
console.warn("ResourceManager.getMedia 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 (typeof args[len - 1] === 'function') {
args[len - 1].call(this, paramMock.businessErrorMock, paramMock.paramArrayMock);
} else {
return new Promise((resolve, reject) => {
resolve(paramMock.paramArrayMock);
})
}
},
getMediaBase64: function(...args) {
console.warn("ResourceManager.getMediaBase64 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 (typeof args[len - 1] === 'function') {
args[len - 1].call(this, paramMock.businessErrorMock, paramMock.paramArrayMock);
} else {
return new Promise((resolve, reject) => {
resolve(paramMock.paramArrayMock);
})
}
},
getPluralString: function(...args) {
console.warn("ResourceManager.getPluralString 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 (typeof args[len - 1] === 'function') {
args[len - 1].call(this, paramMock.businessErrorMock, paramMock.paramStringMock);
} else {
return new Promise((resolve, reject) => {
resolve(paramMock.paramStringMock);
})
}
},
getConfiguration: function(...args) {
console.warn("ResourceManager.getConfiguration 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 (typeof args[len - 1] === 'function') {
args[len - 1].call(this, paramMock.businessErrorMock, new ConfigurationClass());
} else {
return new Promise((resolve, reject) => {
resolve(new ConfigurationClass());
})
}
},
getDeviceCapability: function(...args) {
console.warn("ResourceManager.getDeviceCapability 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 (typeof args[len - 1] === 'function') {
args[len - 1].call(this, paramMock.businessErrorMock, new DeviceCapabilityClass());
} else {
return new Promise((resolve, reject) => {
resolve(new DeviceCapabilityClass());
})
}
},
release: function() {
console.warn("ResourceManager.release interface mocked in the Previewer. " +
"How this interface works on the Previewer may be different from that on a real device.")
},
getRawFile: function(...args) {
console.warn("ResourceManager.getRawFile 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 (typeof args[len - 1] === 'function') {
args[len - 1].call(this, paramMock.businessErrorMock, paramMock.paramArrayMock);
} else {
return new Promise((resolve, reject) => {
resolve(paramMock.paramArrayMock);
})
}
},
getRawFileDescriptor: function(...args) {
console.warn("ResourceManager.getRawFileDescriptor 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 (typeof args[len - 1] === 'function') {
args[len - 1].call(this, paramMock.businessErrorMock, RawFileDescriptor);
} else {
return new Promise((resolve, reject) => {
resolve(RawFileDescriptor);
})
}
},
closeRawFileDescriptor: function(...args) {
console.warn("ResourceManager.closeRawFileDescriptor 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 (typeof args[len - 1] === 'function') {
args[len - 1].call(this, paramMock.businessErrorMock, paramMock.paramStringMock);
} else {
return new Promise((resolve, reject) => {
resolve(paramMock.paramStringMock);
})
}
},
getStringByName: function(...args) {
console.warn("ResourceManager.getStringByName 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 (typeof args[len - 1] === 'function') {
args[len - 1].call(this, paramMock.businessErrorMock, paramMock.paramStringMock);
} else {
return new Promise((resolve, reject) => {
resolve(paramMock.paramStringMock);
})
}
},
getStringArrayByName: function(...args) {
console.warn("ResourceManager.getStringArrayByName 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 (typeof args[len - 1] === 'function') {
args[len - 1].call(this, paramMock.businessErrorMock, [paramMock.paramStringMock]);
} else {
return new Promise((resolve, reject) => {
resolve([paramMock.paramStringMock]);
})
}
},
getMediaByName: function(...args) {
console.warn("ResourceManager.getMediaByName 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 (typeof args[len - 1] === 'function') {
args[len - 1].call(this, paramMock.businessErrorMock, paramMock.paramArrayMock);
} else {
return new Promise((resolve, reject) => {
resolve(paramMock.paramArrayMock);
})
}
},
getMediaBase64ByName: function(...args) {
console.warn("ResourceManager.getMediaBase64ByName 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 (typeof args[len - 1] === 'function') {
args[len - 1].call(this, paramMock.businessErrorMock, paramMock.paramArrayMock);
} else {
return new Promise((resolve, reject) => {
resolve(paramMock.paramArrayMock);
})
}
},
getPluralStringByName: function(...args) {
console.warn("ResourceManager.getPluralStringByName 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 (typeof args[len - 1] === 'function') {
args[len - 1].call(this, paramMock.businessErrorMock, paramMock.paramStringMock);
} else {
return new Promise((resolve, reject) => {
resolve(paramMock.paramStringMock);
})
}
},
getStringSync: function(...args) {
console.warn("ResourceManager.getStringSync interface mocked in the Previewer. " +
"How this interface works on the Previewer may be different from that on a real device.")
return paramMock.paramStringMock;
},
getStringByNameSync: function(...args) {
console.warn("ResourceManager.getStringByNameSync interface mocked in the Previewer. " +
"How this interface works on the Previewer may be different from that on a real device.")
return paramMock.paramStringMock;
},
getBoolean: function(...args) {
console.warn("ResourceManager.getBoolean interface mocked in the Previewer. " +
"How this interface works on the Previewer may be different from that on a real device.")
return paramMock.paramBooleanMock;
},
getBooleanByName: function(...args) {
console.warn("ResourceManager.getBooleanByName interface mocked in the Previewer. " +
"How this interface works on the Previewer may be different from that on a real device.")
return paramMock.paramBooleanMock;
},
getNumber: function(...args) {
console.warn("ResourceManager.getNumber interface mocked in the Previewer. " +
"How this interface works on the Previewer may be different from that on a real device.")
return paramMock.paramNumberMock;
},
getNumberByName: function(...args) {
console.warn("ResourceManager.getNumberByName interface mocked in the Previewer. " +
"How this interface works on the Previewer may be different from that on a real device.")
return paramMock.paramNumberMock;
}
}
const EventHubClass = class EventHub {
constructor() {
console.warn('EventHub.constructor interface mocked in the Previewer. How this interface works on' +
' the Previewer may be different from that on a real device.');
this.on = function (...args) {
console.warn("EventHub.on interface mocked in the Previewer. How this interface works on the Previewer" +
" may be different from that on a real device.")
};
this.off = function (...args) {
console.warn("EventHub.off interface mocked in the Previewer. How this interface works on the Previewer" +
" may be different from that on a real device.")
};
this.emit = function (...args) {
console.warn("EventHub.emit interface mocked in the Previewer. How this interface works on the Previewer" +
" may be different from that on a real device.")
};
}
}
export const ContextClass = class Context extends BaseContext {
constructor() {
super();
console.warn('Context.constructor interface mocked in the Previewer. How this interface works on' +
' the Previewer may be different from that on a real device.');
this.resourceManager = ResourceManager;
this.applicationInfo = ApplicationInfo;
this.cacheDir = "[PC Preview] unknow cacheDir";
this.tempDir = "[PC Preview] unknow tempDir";
this.filesDir = "[PC Preview] unknow filesDir";
this.databaseDir = "[PC Preview] unknow databaseDir";
this.storageDir = "[PC Preview] unknow storageDir";
this.bundleCodeDir = "[PC Preview] unknow bundleCodeDir";
this.distributedFilesDir = "[PC Preview] unknow distributedFilesDir";
this.eventHub = new EventHubClass();
this.createBundleContext = function (...args) {
console.warn("Context.createBundleContext interface mocked in the Previewer. How this interface works on the Previewer" +
" may be different from that on a real device.")
return new ContextClass();
};
this.createModuleContext = function (...args) {
console.warn("Context.createModuleContext interface mocked in the Previewer. How this interface works on the Previewer" +
" may be different from that on a real device.")
return new ContextClass();
};
this.getApplicationContext = function () {
console.warn("Context.getApplicationContext interface mocked in the Previewer. How this interface works on the Previewer" +
" may be different from that on a real device.")
return new ContextClass();
};
this.switchArea = function (...args) {
console.warn("Context.switchArea interface mocked in the Previewer. How this interface works on the Previewer" +
" may be different from that on a real device.")
};
}
}
export const AreaMode = {
EL1: 0,
EL2: 1
}
@@ -0,0 +1,34 @@
/*
* 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 { ExtensionContextClass } from "./abilityContext"
export const formExtensionContextClass = class formExtensionContext extends ExtensionContextClass {
constructor() {
super();
console.warn('formExtensionContext.constructor interface mocked in the Previewer. How this interface works on' +
' the Previewer may be different from that on a real device.');
this.startAbility = function (...args) {
console.warn("formExtensionContext.startAbility 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);
} else {
return new Promise((resolve, reject) => {
resolve();
})
}
};
}
}
@@ -0,0 +1,155 @@
/*
* 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"
import { AbilityClass } from "../ohos_application_Ability"
import { ContextClass } from "../ohos_application_ServiceExtAbility"
import { ShellCmdResult } from "./shellCmdResult"
export const AbilityDelegator = {
addAbilityMonitor: function (...args) {
console.warn("AbilityDelegator.addAbilityMonitor 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);
} else {
return new Promise((resolve, reject) => {
resolve();
})
}
},
removeAbilityMonitor: function (...args) {
console.warn("AbilityDelegator.removeAbilityMonitor 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);
} else {
return new Promise((resolve, reject) => {
resolve();
})
}
},
waitAbilityMonitor: function (...args) {
console.warn("AbilityDelegator.waitAbilityMonitor 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, new AbilityClass());
} else {
return new Promise((resolve, reject) => {
resolve(new AbilityClass());
})
}
},
getAppContext: function (...args) {
console.warn('AbilityDelegator.getAppContext interface mocked in the Previewer. How this interface works on the' +
' Previewer may be different from that on a real device.');
return new ContextClass();
},
getAbilityState: function (...args) {
console.warn('AbilityDelegator.getAbilityState interface mocked in the Previewer. How this interface works on the' +
' Previewer may be different from that on a real device.');
return paramMock.paramNumberMock;
},
getCurrentTopAbility: function (...args) {
console.warn("AbilityDelegator.getCurrentTopAbility 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, new AbilityClass());
} else {
return new Promise((resolve, reject) => {
resolve(new AbilityClass());
})
}
},
startAbility: function (...args) {
console.warn("AbilityDelegator.startAbility 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);
} else {
return new Promise((resolve, reject) => {
resolve();
})
}
},
doAbilityForeground: function (...args) {
console.warn("AbilityDelegator.doAbilityForeground 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, paramMock.paramBooleanMock);
} else {
return new Promise((resolve, reject) => {
resolve(paramMock.paramBooleanMock);
})
}
},
doAbilityBackground: function (...args) {
console.warn("AbilityDelegator.doAbilityBackground 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, paramMock.paramBooleanMock);
} else {
return new Promise((resolve, reject) => {
resolve(paramMock.paramBooleanMock);
})
}
},
print: function (...args) {
console.warn("AbilityDelegator.print 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);
} else {
return new Promise((resolve, reject) => {
resolve();
})
}
},
printSync: function (...args) {
console.warn('AbilityDelegator.printSync interface mocked in the Previewer. How this interface works on the' +
' Previewer may be different from that on a real device.');
},
executeShellCommand: function (...args) {
console.warn("AbilityDelegator.executeShellCommand 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, ShellCmdResult);
} else {
return new Promise((resolve, reject) => {
resolve(ShellCmdResult);
})
}
},
finishTest: function (...args) {
console.warn("AbilityDelegator.finishTest 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);
} else {
return new Promise((resolve, reject) => {
resolve();
})
}
}
}
@@ -0,0 +1,21 @@
/*
* 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.
*/
export const AbilityDelegatorArgs = {
bundleName: "[PC Preview] unknow bundleName",
parameters: {},
testCaseNames: "[PC Preview] unknow testCaseNames",
testRunnerClassName: "[PC Preview] unknow testRunnerClassName",
}
@@ -0,0 +1,45 @@
/*
* 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.
*/
export const AbilityMonitor = {
abilityName: "[PC Preview] unknow abilityName",
onAbilityCreate: function (...args) {
console.warn("AbilityMonitor.onAbilityCreate interface mocked in the Previewer." +
" How this interface works on the Previewer may be different from that on a real device.")
},
onAbilityForeground: function (...args) {
console.warn("AbilityMonitor.onAbilityForeground interface mocked in the Previewer." +
" How this interface works on the Previewer may be different from that on a real device.")
},
onAbilityBackground: function (...args) {
console.warn("AbilityMonitor.onAbilityBackground interface mocked in the Previewer." +
" How this interface works on the Previewer may be different from that on a real device.")
},
onAbilityDestroy: function (...args) {
console.warn("AbilityMonitor.onAbilityDestroy interface mocked in the Previewer." +
" How this interface works on the Previewer may be different from that on a real device.")
},
onWindowStageCreate: function (...args) {
console.warn("AbilityMonitor.onWindowStageCreate interface mocked in the Previewer." +
" How this interface works on the Previewer may be different from that on a real device.")
},
onWindowStageRestore: function (...args) {
console.warn("AbilityMonitor.onWindowStageRestore interface mocked in the Previewer." +
" How this interface works on the Previewer may be different from that on a real device.")
},
onWindowStageDestroy: function (...args) {
console.warn("AbilityMonitor.onWindowStageDestroy interface mocked in the Previewer." +
" How this interface works on the Previewer may be different from that on a real device.")
},
}
@@ -0,0 +1,19 @@
/*
* 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.
*/
export const ShellCmdResult = {
stdResult: "[PC Preview] unknow stdResult",
exitCode: "[PC Preview] unknow exitCode",
}
@@ -0,0 +1,21 @@
/*
* 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.
*/
export const PermissionDef = {
permissionName: "[PC preview] unknown permissionName",
grantMode: "[PC preview] unknown grantMode",
labelId: "[PC preview] unknown labelId",
descriptionId: "[PC preview] unknown descriptionId",
}
@@ -13,69 +13,56 @@
* limitations under the License.
*/
export const AbilityInfoMock = {
bundleName: "string",
name: "string",
label: "string",
description: "string",
icon: "string",
labelId: 1,
descriptionId: 2,
iconId: 3,
moduleName: "string",
process: "string",
targetAbility: "string",
backgroundModes: 4,
isVisible: true,
formEnabled: true,
type: "bundle.AbilityType",
subType: "bundle.AbilitySubType",
orientation: "bundle.DisplayOrientation",
launchMode: "bundle.LaunchMode",
permissions: ["1"],
deviceTypes: ["2"],
deviceCapabilities: ["3"],
readPermission: "string",
writePermission: "string",
applicationInfo: {
packageName: "[PC preview] unknown packageName",
className: "[PC preview] unknown className",
name: "[PC preview] unknown name",
labelId: 1,
iconId: 2,
sourceDir: "[PC preview] unknown sourceDir",
flags: 3,
customizeData: {
key: "[PC preview] unknown key",
value: {
CustomizeData: {
name: "[PC preview] unknown name",
value: "[PC preview] unknown value",
}
}
}
},
formEntity: 5,
minFormHeight: 6,
defaultFormHeight: 7,
minFormWidth: 8,
defaultFormWidth: 9,
uri: "string",
customizeData: {
key: "[PC preview] unknown key",
value: [
{
CustomizeData: {
name: "[PC preview] unknown name",
value: "[PC preview] unknown value",
},
},
{
CustomizeData: {
name: "[PC preview] unknown name",
value: "[PC preview] unknown value",
},
}
]
},
import { paramMock } from "../../utils"
import { AbilityType, AbilitySubType, DisplayOrientation, LaunchMode, SupportWindowMode } from "./../ohos_bundle"
import { ApplicationInfo } from "./applicationInfo"
import { CustomizeData } from "./customizeData"
import { Metadata } from "./metadata"
export const AbilityInfo = {
name: "[PC preview] unknown name",
bundleName: "[PC preview] unknown bundleName",
moduleName: "[PC preview] unknown moduleName",
process: "[PC preview] unknown process",
targetAbility: "[PC preview] unknown targetAbility",
backgroundModes: "[PC preview] unknown backgroundModes",
isVisible: "[PC preview] unknown isVisible",
formEnabled: "[PC preview] unknown formEnabled",
type: AbilityType,
subType: AbilitySubType,
orientation: DisplayOrientation,
launchMode: LaunchMode,
permissions: [paramMock.paramStringMock],
deviceTypes: [paramMock.paramStringMock],
deviceCapabilities: [paramMock.paramNumberMock],
readPermission: '[PC Preview] unknow readPermission',
writePermission: '[PC Preview] unknow writePermission',
appId: '[PC Preview] unknow appId',
label: "[PC preview] unknown label",
description: "[PC preview] unknown description",
icon: "[PC preview] unknown icon",
labelId: "[PC preview] unknown labelId",
iconId: "[PC preview] unknown iconId",
uid: '[PC Preview] unknow uid',
installTime: '[PC Preview] unknow installTime',
updateTime: '[PC Preview] unknow updateTime',
descriptionId: '[PC Preview] unknow descriptionId',
applicationInfo: ApplicationInfo,
metaData: [CustomizeData],
uri: "[PC preview] unknown uri",
metadata: [Metadata],
enabled: "[PC preview] unknown enabled",
supportWindowMode: [SupportWindowMode],
maxWindowRatio: "[PC preview] unknown maxWindowRatio",
minWindowRatio: "[PC preview] unknown minWindowRatio",
maxWindowWidth: "[PC preview] unknown maxWindowWidth",
minWindowWidth: "[PC preview] unknown minWindowWidth",
maxWindowHeight: "[PC preview] unknown maxWindowHeight",
minWindowHeight: "[PC preview] unknown minWindowHeight",
formEntity: "[PC preview] unknown formEntity",
minFormHeight: "[PC preview] unknown minFormHeight",
defaultFormHeight: "[PC preview] unknown defaultFormHeight",
minFormWidth: "[PC preview] unknown minFormWidth",
defaultFormWidth: "[PC preview] unknown defaultFormWidth",
}
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2021 Huawei Device Co., Ltd.
* Copyright (c) 2021-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
@@ -13,26 +13,44 @@
* limitations under the License.
*/
export const ApplicationInfoMock = {
packageName: "[PC preview] unknown packageName",
className: "[PC preview] unknown className",
import { paramMock } from "../../utils"
import { ModuleInfo } from './moduleInfo';
import { CustomizeData } from './customizeData';
import { Metadata } from './metadata';
import { Resource } from './../global/resource';
export const ApplicationInfo = {
name: "[PC preview] unknown name",
labelId: 1,
iconId: 2,
sourceDir: "[PC preview] unknown sourceDir",
flags: 3,
customizeData: {
key: "[PC preview] unknown key",
value: {
CustomizeData: {
name: "[PC preview] unknown name",
value: "[PC preview] unknown value",
}
}
}
description: "[PC preview] unknown description",
descriptionId: "[PC preview] unknown descriptionId",
systemApp: "[PC preview] unknown systemApp",
enabled: "[PC preview] unknown enabled",
label: "[PC preview] unknown label",
labelId: "[PC preview] unknown labelId",
icon: "[PC preview] unknown icon",
iconId: "[PC preview] unknown iconId",
process: "[PC preview] unknown process",
supportedModes: "[PC preview] unknown supportedModes",
moduleSourceDirs: [paramMock.paramNumberMock],
permissions: [paramMock.paramNumberMock],
moduleInfos: [ModuleInfo],
entryDir: "[PC preview] unknown entryDir",
codePath: "[PC preview] unknown codePath",
metaData: [CustomizeData],
metadata: [Metadata],
removable: "[PC preview] unknown removable",
accessTokenId: "[PC preview] unknown accessTokenId",
uid: "[PC preview] unknown uid",
entityType: "[PC preview] unknown entityType",
fingerprint: "[PC preview] unknown fingerprint",
iconResource: Resource,
labelResource: Resource,
descriptionResource: Resource,
appDistributionType: "[PC preview] unknown appDistributionType",
appProvisionType: "[PC preview] unknown appProvisionType",
}
export const WantMock = {
export const Want = {
deviceId: "[PC Preview] unknow deviceId",
bundleName: "[PC Preview] unknow bundleName",
abilityName: "[PC Preview] unknow abilityName",
@@ -40,39 +58,7 @@ export const WantMock = {
type: "[PC Preview] unknow type",
flag: "[PC Preview] unknow flag",
action: "[PC Preview] unknow action",
parameters: "[PC Preview] unknow parameters",
entities: "[PC Preview] unknow entities"
}
export const ShortcutInfoMock = {
id: "[PC preview] unknown id",
bundleName: "[PC preview] unknown bundleName",
hostAbility: "[PC preview] unknown hostAbility",
icon: "[PC preview] unknown icon",
label: "[PC preview] unknown label",
disableMessage: "[PC preview] unknown disableMessage",
wants: [
{
targetBundle: "[PC preview] unknown targetBundle",
targetClass: "[PC preview] unknown targetClass",
}],
isStatic: "[PC preview] unknown isStatic",
isHomeShortcut: "[PC preview] unknown isHomeShortcut",
isEnabled: "[PC preview] unknown isEnabled",
}
export const ModuleUsageRecordMock = {
bundleName: "[PC preview] unknown bundleName",
appLabelId: "[PC preview] unknown appLabelId",
name: "[PC preview] unknown name",
labelId: "[PC preview] unknown labelId",
descriptionId: "[PC preview] unknown descriptionId",
abilityName: "[PC preview] unknown abilityName",
abilityLabelId: "[PC preview] unknown abilityLabelId",
abilityDescriptionId: "[PC preview] unknown abilityDescriptionId",
abilityIconId: "[PC preview] unknown abilityIconId",
launchedCount: "[PC preview] unknown launchedCount",
lastLaunchTime: "[PC preview] unknown lastLaunchTime",
isRemoved: "[PC preview] unknown isRemoved",
installationFreeSupported: "[PC preview] unknown installationFreeSupported",
parameters: [paramMock.paramStringMock],
entities: [paramMock.paramStringMock],
moduleName: "[PC Preview] unknow moduleName",
}
@@ -13,266 +13,53 @@
* limitations under the License.
*/
export const BundleInfoMock = {
import { paramMock } from "../../utils"
import { AbilityInfo } from './abilityInfo';
import { ApplicationInfo } from './applicationInfo';
import { ExtensionAbilityInfo } from './extensionAbilityInfo';
import { HapModuleInfo } from './hapModuleInfo';
export const UsedScene = {
abilities: [paramMock.paramStringMock],
when: "[PC preview] unknown when",
}
export const ReqPermissionDetail = {
name: "[PC preview] unknown name",
reason: "[PC preview] unknown reason",
reasonId: "[PC preview] unknown reasonId",
usedScene: UsedScene,
}
export const BundleInfo = {
name: "[PC preview] unknown name",
type: "[PC preview] unknown type",
appId: "[PC preview] unknown appId",
uid: "[PC preview] unknown uid",
installTime: "[PC preview] unknown installTime",
updateTime: "[PC preview] unknown updateTime",
appInfo: {
packageName: "[PC preview] unknown packageName",
className: "[PC preview] unknown className",
name: "[PC preview] unknown name",
labelId: "[PC preview] unknown labelId",
iconId: "[PC preview] unknown iconId",
sourceDir: "[PC preview] unknown sourceDir",
flags: "[PC preview] unknown flags",
customizeData: {
key: "[PC preview] unknown key",
value: {
CustomizeData: {
name: "[PC preview] unknown name",
value: "[PC preview] unknown value",
}
}
}
},
abilityInfo: [
{
name: "[PC preview] unknown name",
type: '[[PC Preview] unknow type]',
appId: '[[PC Preview] unknow appId]',
label: "[PC preview] unknown label",
description: "[PC preview] unknown description",
uid: '[[PC Preview] unknow uid]',
installTime: '[[PC Preview] unknow installTime]',
updateTime: '[[PC Preview] unknow updateTime]',
applicationInfo: {
packageName: "[PC preview] unknown package name",
className: "[PC preview] unknown class name",
name: "[PC preview] unknown name",
labelId: "[PC preview] unknown label id",
iconId: "[PC preview] unknown icon id",
sourceDir: "[PC preview] unknown source dir",
flags: "[PC preview] unknown flags",
customizeData: {
key: "[PC preview] unknown key",
value: {
CustomizeData: {
name: "[PC preview] unknown name",
value: "[PC preview] unknown value",
}
}
}
},
formEntity: "[PC preview] unknown formEntity",
minFormHeight: "[PC preview] unknown minFormHeight",
defaultFormHeight: "[PC preview] unknown defaultFormHeight",
minFormWidth: "[PC preview] unknown minFormWidth",
defaultFormWidth: "[PC preview] unknown defaultFormWidth",
uri: "[PC preview] unknown uri",
customizeData: {
key: "[PC preview] unknown key",
value: [
{
CustomizeData: {
name: "[PC preview] unknown name",
value: "[PC preview] unknown value",
},
},
{
CustomizeData: {
name: "[PC preview] unknown name",
value: "[PC preview] unknown value",
},
}
]
},
}
],
reqPermissions: ["[PC preview] unknown repermission"],
reqPermissionDetails: [
{
name: "[PC preview] unknown name",
reason: "[PC preview] unknown reason",
usedScene: {
abilities: ["[PC preview] unknown ability"],
when: "[PC preview] unknown when",
}
}
],
appInfo: ApplicationInfo,
abilityInfos: [AbilityInfo],
reqPermissions: [paramMock.paramStringMock],
reqPermissionDetails: [ReqPermissionDetail],
vendor: "[PC preview] unknown vendor",
versionCode: "[PC preview] unknown versionCode",
versionName: "[PC preview] unknown versionName",
compatibleVersion: "[PC preview] unknown compatibleVersion",
targetVersion: "[PC preview] unknown targetVersion",
isCompressNativeLibs: "[PC preview] unknown isCompressNativeLibs",
hapModuleInfo: [
{
name: "string",
description: "string",
descriptionId: 1,
icon: "string",
label: "string",
labelId: 2,
iconId: 3,
backgroundImg: "string",
supportedModes: 4,
reqCapabilities: ["1", "2"],
deviceTypes: ["1", "2"],
abilityInfo: [
{
bundleName: "string",
name: "string",
label: "string",
description: "string",
icon: "string",
labelId: 1,
descriptionId: 2,
iconId: 3,
moduleName: "string",
process: "string",
targetAbility: "string",
backgroundModes: 4,
isVisible: true,
formEnabled: true,
type: "bundle.AbilityType",
subType: "bundle.AbilitySubType",
orientation: "bundle.DisplayOrientation",
launchMode: "bundle.LaunchMode",
permissions: ["1"],
deviceTypes: ["2"],
deviceCapabilities: ["3"],
readPermission: "string",
writePermission: "string",
applicationInfo: {
packageName: "[PC preview] unknown packageName",
className: "[PC preview] unknown className",
name: "[PC preview] unknown name",
labelId: 2,
iconId: 3,
sourceDir: "[PC preview] unknown sourceDir",
flags: 1,
customizeData: {
key: "[PC preview] unknown key",
value: {
CustomizeData: {
name: "[PC preview] unknown name",
value: "[PC preview] unknown value",
}
}
}
},
formEntity: 5,
minFormHeight: 6,
defaultFormHeight: 7,
minFormWidth: 8,
defaultFormWidth: 9,
uri: "string",
customizeData: {
key: "[PC preview] unknown key",
value: [
{
CustomizeData: {
name: "[PC preview] unknown name",
value: "[PC preview] unknown value",
},
},
{
CustomizeData: {
name: "[PC preview] unknown name",
value: "[PC preview] unknown value",
},
}
]
},
}
],
moduleName: "string",
mainAbilityName: "string",
installationFree: true,
}
],
entryModuleName: "string",
cpuAbi: "string",
isSilentInstallation: "string",
minCompatibleVersionCode: 7,
entryInstallationFree: true,
hapModuleInfos: [HapModuleInfo],
entryModuleName: "[PC preview] unknown entryModuleName",
cpuAbi: "[PC preview] unknown cpuAbi",
isSilentInstallation: "[PC preview] unknown isSilentInstallation",
minCompatibleVersionCode: "[PC preview] unknown minCompatibleVersionCode",
entryInstallationFree: "[PC preview] unknown entryInstallationFree",
reqPermissionStates: [paramMock.paramStringMock],
extensionAbilityInfo: [ExtensionAbilityInfo],
};
export const BundlePackInfo = {
packages: [{
deviceType: ["[PC preview] unknown deviceType"],
name: "[PC preview] unknown name",
moduleType: "[PC preview] unknown moduleType",
deliveryWithInstall: "[PC preview] unknown deliveryWithInstall",
}],
summary: {
app: {
bundleName: "[PC preview] unknown bundleName",
version: {
minCompatibleVersionCode: "[PC preview] unknown minCompatibleVersionCode",
name: "[PC preview] unknown name",
code: "[PC preview] unknown code",
},
},
modules: [
{
apiVersion: {
releaseType: "[PC preview] unknown releaseType",
compatible: "[PC preview] unknown compatible",
target: "[PC preview] unknown target",
},
deviceType: ["[PC preview] unknown deviceType"],
distro: {
mainAbility: "[PC preview] unknown mainAbility",
deliveryWithInstall: "[PC preview] unknown deliveryWithInstall",
installationFree: "[PC preview] unknown installationFree",
moduleName: "[PC preview] unknown moduleName",
moduleType: "[PC preview] unknown moduleType",
},
abilities: [
{
name: "[PC preview] unknown name",
label: "[PC preview] unknown label",
visible: "[PC preview] unknown visible",
forms: [
{
name: "[PC preview] unknown name",
type: "[PC preview] unknown type",
updateEnabled: "[PC preview] unknown updateEnabled",
scheduledUpdateTime: "[PC preview] unknown scheduledUpdateTime",
updateDuration: "[PC preview] unknown updateDuration",
supportDimensions: ["[PC preview] unknown supportDimensions"],
defaultDimension: "[PC preview] unknown defaultDimension",
}
],
}
],
extensionAbilities: [
{
name: "[PC preview] unknown name",
forms: [
{
name: "[PC preview] unknown name",
type: "[PC preview] unknown type",
updateEnabled: "[PC preview] unknown updateEnabled",
scheduledUpdateTime: "[PC preview] unknown scheduledUpdateTime",
updateDuration: "[PC preview] unknown updateDuration",
supportDimensions: ["[PC preview] unknown supportDimensions"],
defaultDimension: "[PC preview] unknown defaultDimension",
}
],
}
]
}
]
}
};
export const DispatchInfoMock = {
verison: "[PC preview] unknown verison",
dispatchAPI: "[PC preview] unknown dispatchAPI",
export const PixelMapFormat = {
UNKNOWN: 0,
RGB_565: 2,
RGBA_8888: 3,
}
@@ -0,0 +1,64 @@
/*
* 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"
import { InstallErrorCode } from '../ohos_bundle.js'
export const HashParam = {
moduleName: "[PC preview] unknown moduleName",
hashValue: "[PC preview] unknown hashValue",
}
export const InstallParam = {
userId: "[PC preview] unknown userId",
installFlag: "[PC preview] unknown installFlag",
isKeepData: "[PC preview] unknown isKeepData",
hashParams: [HashParam],
crowdtestDeadline: "[PC preview] unknown crowdtestDeadline",
}
export const InstallStatus = {
status: InstallErrorCode,
statusMessage: "[PC preview] unknown statusMessage",
}
export const BundleInstaller = {
moduleName: "[PC preview] unknown moduleName",
hashValue: "[PC preview] unknown hashValue",
}
export function mockBundleInstaller() {
const bundleInstaller = {
install: function(...args){
console.warn("bundleInstaller.install 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;
args[len - 1].call(this, paramMock.businessErrorMock, InstallStatus);
},
uninstall: function(...args){
console.warn("bundleInstaller.uninstall 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;
args[len - 1].call(this, paramMock.businessErrorMock, InstallStatus);
},
recover: function(...args){
console.warn("bundleInstaller.recover 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;
args[len - 1].call(this, paramMock.businessErrorMock, InstallStatus);
}
};
return bundleInstaller;
}
@@ -0,0 +1,32 @@
/*
* 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.
*/
export function mockBundleStatusCallback() {
const bundleStatusCallback = {
add: function(){
console.warn("bundleStatusCallback.add interface mocked in the Previewer. How this interface works on the" +
" Previewer may be different from that on a real device.")
},
update: function(){
console.warn("bundleStatusCallback.update interface mocked in the Previewer. How this interface works on the" +
" Previewer may be different from that on a real device.")
},
remove: function(){
console.warn("bundleStatusCallback.remove interface mocked in the Previewer. How this interface works on the" +
" Previewer may be different from that on a real device.")
}
};
return bundleStatusCallback;
}
@@ -0,0 +1,20 @@
/*
* 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.
*/
export const CustomizeData = {
name: "[PC preview] unknown name",
value: "[PC preview] unknown value",
extra: "[PC preview] unknown extra",
}
@@ -13,7 +13,7 @@
* limitations under the License.
*/
export const DefaultAppManagerMock = {
export const DefaultAppManager = {
BROWSER: "[PC preview] unknown BROWSER",
IMAGE: "[PC preview] unknown IMAGE",
AUDIO: "[PC preview] unknown AUDIO",
@@ -0,0 +1,19 @@
/*
* 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.
*/
export const DispatchInfo = {
verison: "[PC preview] unknown verison",
dispatchAPI: "[PC preview] unknown dispatchAPI",
}
@@ -0,0 +1,23 @@
/*
* 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.
*/
export const ElementName = {
deviceId: "[PC preview] unknown deviceId",
bundleName: "[PC preview] unknown bundleName",
abilityName: "[PC preview] unknown abilityName",
uri: "[PC preview] unknown uri",
shortName: "[PC preview] unknown shortName",
moduleName: "[PC preview] unknown moduleName",
}
@@ -0,0 +1,37 @@
/*
* 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"
import { ApplicationInfo } from './applicationInfo';
import { Metadata } from './metadata'
import { ExtensionAbilityType } from "./../ohos_bundle"
export const ExtensionAbilityInfo = {
bundleName: "[PC preview] unknown bundleName",
moduleName: "[PC preview] unknown moduleName",
name: "[PC preview] unknown name",
labelId: "[PC preview] unknown labelId",
descriptionId: "[PC preview] unknown descriptionId",
iconId: "[PC preview] unknown iconId",
isVisible: "[PC preview] unknown isVisible",
extensionAbilityType: ExtensionAbilityType,
metadata: [Metadata],
permissions: [paramMock.paramStringMock],
applicationInfo: ApplicationInfo,
enabled: "[PC preview] unknown enabled",
readPermission: "[PC preview] unknown readPermission",
writePermission: "[PC preview] unknown writePermission",
}
@@ -0,0 +1,41 @@
/*
* 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"
import { AbilityInfo } from './abilityInfo';
import { ExtensionAbilityInfo } from './extensionAbilityInfo';
import { Metadata } from './metadata';
export const HapModuleInfo = {
name: "[PC preview] unknown name",
description: "[PC preview] unknown description",
descriptionId: "[PC preview] unknown descriptionId",
icon: "[PC preview] unknown icon",
label: "[PC preview] unknown label",
labelId: "[PC preview] unknown labelId",
iconId: "[PC preview] unknown iconId",
backgroundImg: "[PC preview] unknown backgroundImg",
supportedModes: "[PC preview] unknown supportedModes",
reqCapabilities: [paramMock.paramStringMock],
deviceTypes: [paramMock.paramStringMock],
abilityInfo: [AbilityInfo],
moduleName: "[PC preview] unknown moduleName",
mainAbilityName: "[PC preview] unknown mainAbilityName",
installationFree: "[PC preview] unknown installationFree",
mainElementName: "[PC preview] unknown mainElementName",
extensionAbilityInfo: [ExtensionAbilityInfo],
metadata: [Metadata],
}
@@ -13,32 +13,13 @@
* limitations under the License.
*/
export const LauncherAbilityInfoMock = {
applicationInfo: {
packageName: "[PC preview] unknown packageName",
className: "[PC preview] unknown className",
name: "[PC preview] unknown name",
labelId: 1,
iconId: 2,
sourceDir: "[PC preview] unknown sourceDir",
flags: 3,
customizeData: {
key: "[PC preview] unknown key",
value: {
CustomizeData: {
name: "[PC preview] unknown name",
value: "[PC preview] unknown value",
}
}
}
},
elementName: {
deviceId: "[PC preview] unknown deviceId",
bundleName: "[PC preview] unknown bundleName",
abilityName: "[PC preview] unknown abilityName",
uri: "[PC preview] unknown uri",
shortName: "[PC preview] unknown shortName",
},
import { paramMock } from "../../utils"
import { ApplicationInfo } from './applicationInfo';
import { ElementName } from './elementName'
export const LauncherAbilityInfo = {
applicationInfo: ApplicationInfo,
elementName: ElementName,
labelId: "[PC preview] unknown labelId",
iconId: "[PC preview] unknown iconId",
userId: "[PC preview] unknown userId",
+20
View File
@@ -0,0 +1,20 @@
/*
* 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.
*/
export const Metadata = {
name: "[PC preview] unknown name",
value: "[PC preview] unknown value",
resource: "[PC preview] unknown resource",
}
+19
View File
@@ -0,0 +1,19 @@
/*
* 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.
*/
export const ModuleInfo = {
moduleName: "[PC preview] unknown moduleName",
moduleSourceDir: "[PC preview] unknown moduleSourceDir",
}
+95
View File
@@ -0,0 +1,95 @@
/*
* 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 const PackageConfig = {
deviceType: [paramMock.paramStringMock],
name: "[PC preview] unknown name",
moduleType: "[PC preview] unknown moduleType",
deliveryWithInstall: "[PC preview] unknown deliveryWithInstall",
}
export const ModuleDistroInfo = {
mainAbility: "[PC preview] unknown mainAbility",
deliveryWithInstall: "[PC preview] unknown deliveryWithInstall",
installationFree: "[PC preview] unknown installationFree",
moduleName: "[PC preview] unknown moduleName",
moduleType: "[PC preview] unknown moduleType",
}
export const AbilityFormInfo = {
name: "[PC preview] unknown name",
type: "[PC preview] unknown type",
updateEnabled: "[PC preview] unknown updateEnabled",
scheduledUpdateTime: "[PC preview] unknown scheduledUpdateTime",
updateDuration: "[PC preview] unknown updateDuration",
supportDimensions: [paramMock.paramNumberMock],
defaultDimension: "[PC preview] unknown defaultDimension",
}
export const ApiVersion = {
releaseType: "[PC preview] unknown releaseType",
compatible: "[PC preview] unknown compatible",
target: "[PC preview] unknown target",
}
export const Version = {
minCompatibleVersionCode: "[PC preview] unknown minCompatibleVersionCode",
name: "[PC preview] unknown name",
code: "[PC preview] unknown code",
}
export const ModuleAbilityInfo = {
name: "[PC preview] unknown name",
label: "[PC preview] unknown label",
visible: "[PC preview] unknown visible",
forms: [AbilityFormInfo],
}
export const ExtensionAbilities = {
name: "[PC preview] unknown name",
forms: [AbilityFormInfo],
}
export const ModuleConfigInfo = {
apiVersion: ApiVersion,
deviceType: [paramMock.paramStringMock],
distro: [paramMock.paramStringMock],
abilities: [ModuleAbilityInfo],
extensionAbilities: [ExtensionAbilities],
}
export const BundleConfigInfo = {
bundleName: "[PC preview] unknown bundleName",
version: Version,
}
export const PackageSummary = {
app: BundleConfigInfo,
modules: [ModuleConfigInfo]
}
export const BundlePackFlag = {
GET_PACK_INFO_ALL: 0x00000000,
GET_PACKAGES: 0x00000001,
GET_BUNDLE_SUMMARY: 0x00000002,
GET_MODULE_SUMMARY: 0x00000004,
}
export const BundlePackInfo = {
packages: [PackageConfig],
summary: PackageSummary
}
@@ -0,0 +1,22 @@
/*
* 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 { ElementName } from './elementName';
export const RemoteAbilityInfo = {
elementName: ElementName,
label: "[PC preview] unknown IMAGE",
icon: "[PC preview] unknown AUDIO",
}
@@ -0,0 +1,36 @@
/*
* 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.
*/
export const ShortcutWant = {
targetBundle: "[PC preview] unknown targetBundle",
targetModule: "[PC preview] unknown targetModule",
targetClass: "[PC preview] unknown targetClass",
}
export const ShortcutInfo = {
id: "[PC preview] unknown id",
bundleName: "[PC preview] unknown bundleName",
hostAbility: "[PC preview] unknown hostAbility",
icon: "[PC preview] unknown icon",
iconId: "[PC preview] unknown iconId",
label: "[PC preview] unknown label",
labelId: "[PC preview] unknown labelId",
disableMessage: "[PC preview] unknown disableMessage",
wants: [ShortcutWant],
isStatic: "[PC preview] unknown isStatic",
isHomeShortcut: "[PC preview] unknown isHomeShortcut",
isEnabled: "[PC preview] unknown isEnabled",
moduleName: "[PC preview] unknown moduleName",
}
@@ -0,0 +1,156 @@
/*
* 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 const Result = {
code: "[PC Preview] unknow code",
data: "[PC Preview] unknow data",
}
export const SubscribeMessageResponse = {
deviceId: "[PC Preview] unknow deviceId",
bundleName: "[PC Preview] unknow bundleName",
abilityName: "[PC Preview] unknow abilityName",
message: "[PC Preview] unknow message",
}
export const CallAbilityParam = {
bundleName: "[PC Preview] unknow bundleName",
abilityName: "[PC Preview] unknow abilityName",
messageCode: "[PC Preview] unknow messageCode",
abilityType: "[PC Preview] unknow abilityType",
data: "[PC Preview] unknow data",
syncOption: "[PC Preview] unknow syncOption",
}
export const SubscribeAbilityEventParam = {
bundleName: "[PC Preview] unknow bundleName",
abilityName: "[PC Preview] unknow abilityName",
messageCode: "[PC Preview] unknow messageCode",
abilityType: "[PC Preview] unknow abilityType",
syncOption: "[PC Preview] unknow syncOption",
}
export const SendMessageOptions = {
deviceId: "[PC Preview] unknow deviceId",
bundleName: "[PC Preview] unknow bundleName",
abilityName: "[PC Preview] unknow abilityName",
message: "[PC Preview] unknow message",
success: function () {
console.warn("SendMessageOptions.success interface mocked in the Previewer." +
" How this interface works on the Previewer may be different from that on a real device.")
},
fail: function (...args) {
console.warn("SendMessageOptions.fail interface mocked in the Previewer." +
" How this interface works on the Previewer may be different from that on a real device.")
},
complete: function () {
console.warn("SendMessageOptions.complete interface mocked in the Previewer." +
" How this interface works on the Previewer may be different from that on a real device.")
}
}
export const SubscribeMessageOptions = {
success: function (...args) {
console.warn("SubscribeMessageOptions.success interface mocked in the Previewer." +
" How this interface works on the Previewer may be different from that on a real device.")
},
fail: function (...args) {
console.warn("SubscribeMessageOptions.fail interface mocked in the Previewer." +
" How this interface works on the Previewer may be different from that on a real device.")
},
}
export const RequestParams = {
bundleName: "[PC Preview] unknow bundleName",
abilityName: "[PC Preview] unknow abilityName",
entities: [paramMock.paramStringMock],
action: "[PC Preview] unknow action",
deviceType: "[PC Preview] unknow deviceType",
data: "[PC Preview] unknow data",
flag: "[PC Preview] unknow flag",
url: "[PC Preview] unknow url",
}
export const FinishWithResultParams = {
code: "[PC Preview] unknow code",
result: "[PC Preview] unknow result",
}
export const FeatureAbilityClass = class FeatureAbility {
constructor() {
console.warn('FeatureAbility.constructor interface mocked in the Previewer. How this interface works on' +
' the Previewer may be different from that on a real device.');
this.startAbility = function (...args) {
console.warn("FeatureAbility.startAbility interface mocked in the Previewer. How this interface works on the Previewer" +
" may be different from that on a real device.")
return new Promise((resolve, reject) => {
resolve(Result);
})
};
this.startAbilityForResult = function (...args) {
console.warn("FeatureAbility.startAbilityForResult interface mocked in the Previewer. How this interface works on the Previewer" +
" may be different from that on a real device.")
return new Promise((resolve, reject) => {
resolve(Result);
})
};
this.finishWithResult = function (...args) {
console.warn("FeatureAbility.finishWithResult interface mocked in the Previewer. How this interface works on the Previewer" +
" may be different from that on a real device.")
return new Promise((resolve, reject) => {
resolve(Result);
})
};
this.getDeviceList = function (...args) {
console.warn("FeatureAbility.getDeviceList interface mocked in the Previewer. How this interface works on the Previewer" +
" may be different from that on a real device.")
return new Promise((resolve, reject) => {
resolve(Result);
})
};
this.callAbility = function (...args) {
console.warn("FeatureAbility.callAbility interface mocked in the Previewer. How this interface works on the Previewer" +
" may be different from that on a real device.")
return new Promise((resolve, reject) => {
resolve(paramMock.paramStringMock);
})
};
this.continueAbility = function () {
console.warn("FeatureAbility.continueAbility interface mocked in the Previewer. How this interface works on the Previewer" +
" may be different from that on a real device.")
return new Promise((resolve, reject) => {
resolve(Result);
})
};
this.subscribeAbilityEvent = function (...args) {
console.warn("FeatureAbility.subscribeAbilityEvent interface mocked in the Previewer. How this interface works on the Previewer" +
" may be different from that on a real device.")
return new Promise((resolve, reject) => {
resolve(paramMock.paramStringMock);
})
};
this.unsubscribeAbilityEvent = function (...args) {
console.warn("FeatureAbility.unsubscribeAbilityEvent interface mocked in the Previewer. How this interface works on the Previewer" +
" may be different from that on a real device.")
return new Promise((resolve, reject) => {
resolve(paramMock.paramStringMock);
})
};
this.sendMsg = function (...args) {
console.warn("FeatureAbility.sendMsg interface mocked in the Previewer. How this interface works on the Previewer" +
" may be different from that on a real device.")
};
this.subscribeMsg = function (...args) {
console.warn("FeatureAbility.subscribeMsg interface mocked in the Previewer. How this interface works on the Previewer" +
" may be different from that on a real device.")
};
this.unsubscribeMsg = function () {
console.warn("FeatureAbility.unsubscribeMsg interface mocked in the Previewer. How this interface works on the Previewer" +
" may be different from that on a real device.")
};
}
}
@@ -0,0 +1,22 @@
/*
* 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.
*/
export const CommonEventData = {
event: '[PC preview] unknow event',
bundleName: '[PC preview] unknow bundleName',
code: '[PC preview] unknow code',
data: '[PC preview] unknow data',
parameters: {}
}
@@ -0,0 +1,25 @@
/*
* 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 const CommonEventPublishData = {
bundleName: '[PC preview] unknow bundleName',
code: '[PC preview] unknow code',
data: '[PC preview] unknow data',
subscriberPermissions: [paramMock.paramStringMock],
isOrdered: '[PC preview] unknow isOrdered',
isSticky: '[PC preview] unknow isSticky',
parameters: {}
}
@@ -0,0 +1,23 @@
/*
* 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 const CommonEventSubscribeInfo = {
events: [paramMock.paramStringMock],
publisherPermission: '[PC preview] unknow publisherPermission',
publisherDeviceId: '[PC preview] unknow publisherDeviceId',
userId: '[PC preview] unknow userId',
priority: '[PC preview] unknow priority'
}
@@ -0,0 +1,163 @@
/*
* 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"
import { CommonEventSubscribeInfo } from "./commonEventSubscribeInfo"
export const CommonEventSubscriber = {
getCode: function (...args) {
console.warn('CommonEventSubscriber.getCode 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 (typeof args[len - 1] === 'function') {
args[len - 1].call(this, paramMock.businessErrorMock, paramMock.paramNumberMock);
} else {
return new Promise((resolve) => {
resolve(paramMock.paramNumberMock);
});
}
},
setCode: function (...args) {
console.warn('CommonEventSubscriber.setCode 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 (typeof args[len - 1] === 'function') {
args[len - 1].call(this, paramMock.businessErrorMock);
} else {
return new Promise((resolve) => {
resolve();
});
}
},
getData: function (...args) {
console.warn('CommonEventSubscriber.getData 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 (typeof args[len - 1] === 'function') {
args[len - 1].call(this, paramMock.businessErrorMock, paramMock.paramStringMock);
} else {
return new Promise((resolve) => {
resolve(paramMock.paramStringMock);
});
}
},
setData: function (...args) {
console.warn('CommonEventSubscriber.setData 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 (typeof args[len - 1] === 'function') {
args[len - 1].call(this, paramMock.businessErrorMock);
} else {
return new Promise((resolve) => {
resolve();
});
}
},
setCodeAndData: function (...args) {
console.warn('CommonEventSubscriber.setCodeAndData 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 (typeof args[len - 1] === 'function') {
args[len - 1].call(this, paramMock.businessErrorMock);
} else {
return new Promise((resolve) => {
resolve();
});
}
},
isOrderedCommonEvent: function (...args) {
console.warn('CommonEventSubscriber.isOrderedCommonEvent 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 (typeof args[len - 1] === 'function') {
args[len - 1].call(this, paramMock.businessErrorMock, paramMock.paramBooleanMock);
} else {
return new Promise((resolve) => {
resolve(paramMock.paramBooleanMock);
});
}
},
isStickyCommonEvent: function (...args) {
console.warn('CommonEventSubscriber.isStickyCommonEvent 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 (typeof args[len - 1] === 'function') {
args[len - 1].call(this, paramMock.businessErrorMock, paramMock.paramBooleanMock);
} else {
return new Promise((resolve) => {
resolve(paramMock.paramBooleanMock);
});
}
},
abortCommonEvent: function (...args) {
console.warn('CommonEventSubscriber.abortCommonEvent 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 (typeof args[len - 1] === 'function') {
args[len - 1].call(this, paramMock.businessErrorMock);
} else {
return new Promise((resolve) => {
resolve();
});
}
},
clearAbortCommonEvent: function (...args) {
console.warn('CommonEventSubscriber.clearAbortCommonEvent 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 (typeof args[len - 1] === 'function') {
args[len - 1].call(this, paramMock.businessErrorMock);
} else {
return new Promise((resolve) => {
resolve();
});
}
},
getAbortCommonEvent: function (...args) {
console.warn('CommonEventSubscriber.getAbortCommonEvent 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 (typeof args[len - 1] === 'function') {
args[len - 1].call(this, paramMock.businessErrorMock, paramMock.paramBooleanMock);
} else {
return new Promise((resolve) => {
resolve(paramMock.paramBooleanMock);
});
}
},
getSubscribeInfo: function (...args) {
console.warn('CommonEventSubscriber.getSubscribeInfo 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 (typeof args[len - 1] === 'function') {
args[len - 1].call(this, paramMock.businessErrorMock, CommonEventSubscribeInfo);
} else {
return new Promise((resolve) => {
resolve(CommonEventSubscribeInfo);
});
}
},
finishCommonEvent: function (...args) {
console.warn('CommonEventSubscriber.finishCommonEvent 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 (typeof args[len - 1] === 'function') {
args[len - 1].call(this, paramMock.businessErrorMock);
} else {
return new Promise((resolve, reject) => {
resolve();
});
}
},
}
@@ -0,0 +1,27 @@
/*
* 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"
const ContinuationMode = {
COLLABORATION_SINGLE: 0,
COLLABORATION_MULTIPLE: 1
}
export const ContinuationExtraParams = {
deviceType: [paramMock.paramStringMock],
targetBundle: "[PC Preview] unknow targetBundle",
description: "[PC Preview] unknow description",
filter: "[PC Preview] unknow filter",
continuationMode: ContinuationMode,
authInfo: {}
}
@@ -0,0 +1,19 @@
/*
* 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.
*/
export const ContinuationResult = {
id: "[PC Preview] unknow id",
type: "[PC Preview] unknow type",
name: "[PC Preview] unknow name",
}
@@ -0,0 +1,97 @@
/*
* 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 const resultSet = {
columnNames: [paramMock.paramStringMock],
columnCount: "[PC Preview] unknow columnCount",
rowCount: "[PC Preview] unknow rowCount",
rowIndex: "[PC Preview] unknow rowIndex",
isAtFirstRow: "[PC Preview] unknow isAtFirstRow",
isAtLastRow: "[PC Preview] unknow isAtLastRow",
isEnded: "[PC Preview] unknow isEnded",
isStarted: "[PC Preview] unknow isStarted",
isClosed: "[PC Preview] unknow isClosed",
getColumnIndex: function (...args) {
console.warn("ResultSet.getColumnIndex interface mocked in the Previewer. How this interface works on the" +
" Previewer may be different from that on a real device.")
return paramMock.paramNumberMock;
},
getColumnName: function (...args) {
console.warn("ResultSet.getColumnName interface mocked in the Previewer. How this interface works on the" +
" Previewer may be different from that on a real device.")
return paramMock.paramStringMock;
},
goTo: function (...args) {
console.warn("ResultSet.goTo interface mocked in the Previewer. How this interface works on the" +
" Previewer may be different from that on a real device.")
return paramMock.paramBooleanMock;
},
goToRow: function (...args) {
console.warn("ResultSet.goToRow interface mocked in the Previewer. How this interface works on the" +
" Previewer may be different from that on a real device.")
return paramMock.paramBooleanMock;
},
goToFirstRow: function (...args) {
console.warn("ResultSet.goToFirstRow interface mocked in the Previewer. How this interface works on the" +
" Previewer may be different from that on a real device.")
return paramMock.paramBooleanMock;
},
goToLastRow: function (...args) {
console.warn("ResultSet.goToLastRow interface mocked in the Previewer. How this interface works on the" +
" Previewer may be different from that on a real device.")
return paramMock.paramBooleanMock;
},
goToNextRow: function (...args) {
console.warn("ResultSet.goToNextRow interface mocked in the Previewer. How this interface works on the" +
" Previewer may be different from that on a real device.")
return paramMock.paramBooleanMock;
},
goToPreviousRow: function (...args) {
console.warn("ResultSet.goToPreviousRow interface mocked in the Previewer. How this interface works on the" +
" Previewer may be different from that on a real device.")
return paramMock.paramBooleanMock;
},
getBlob: function (...args) {
console.warn("ResultSet.getBlob interface mocked in the Previewer. How this interface works on the" +
" Previewer may be different from that on a real device.")
return paramMock.paramObjectMock;
},
getString: function (...args) {
console.warn("ResultSet.getString interface mocked in the Previewer. How this interface works on the" +
" Previewer may be different from that on a real device.")
return paramMock.paramStringMock;
},
getLong: function (...args) {
console.warn("ResultSet.getLong interface mocked in the Previewer. How this interface works on the" +
" Previewer may be different from that on a real device.")
return paramMock.paramNumberMock;
},
getDouble: function (...args) {
console.warn("ResultSet.getDouble interface mocked in the Previewer. How this interface works on the" +
" Previewer may be different from that on a real device.")
return paramMock.paramNumberMock;
},
isColumnNull: function (...args) {
console.warn("ResultSet.isColumnNull interface mocked in the Previewer. How this interface works on the" +
" Previewer may be different from that on a real device.")
return paramMock.paramBooleanMock;
},
close: function (...args) {
console.warn("ResultSet.close interface mocked in the Previewer. How this interface works on the" +
" Previewer may be different from that on a real device.")
},
}
@@ -0,0 +1,20 @@
/*
* 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.
*/
export const RawFileDescriptor = {
fd : '[PC Preview] unknow number',
offset : '[PC Preview] unknow number',
length : '[PC Preview] unknow number'
}
@@ -0,0 +1,20 @@
/*
* 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.
*/
export const Resource = {
bundleName : '[PC Preview] unknow string',
moduleName : '[PC Preview] unknow string',
id : '[PC Preview] unknow number'
}
+50 -14
View File
@@ -15,7 +15,15 @@
import { mockSystemParameter } from './ohos_systemparameter'
import { mockAbility } from './ohos_application_Ability'
import { mockFeatureAbility } from './ohos_ability_featureAbility'
import { mockDataUriUtils } from './ohos_ability_dataUriUtils'
import { mockAbilityDelegatorRegistry } from './ohos_application_abilityDelegatorRegistry'
import { mockAbilityLifecycleCallback } from './ohos_application_AbilityLifecycleCallback'
import { mockFormExtension } from './ohos_application_FormExtension'
import { mockStaticSubscriberExtensionAbility } from './ohos_application_StaticSubscriberExtensionAbility'
import { mockFormHost } from './ohos_application_formHost'
import { mockErrorManager } from './ohos_application_errorManager'
import { mockTestRunner } from './ohos_application_testRunner'
import { mockServiceExtensionAbility } from './ohos_application_ServiceExtensionAbility'
import { mockAbilityStage } from './ohos_application_AbilityStage'
import { mockFormBindingData } from './ohos_application_formBindingData'
@@ -56,7 +64,7 @@ import { mockStorage } from './system_storage'
import { mockRdb } from './ohos_data_rdb'
import { mockPreferences } from './ohos_data_preferences'
import { mockDataShare } from './ohos_data_dataShare'
import { DataSharePredicates } from './ohos_data_dataSharePredicates'
import { mockDataSharePredicates } from './ohos_data_dataSharePredicates'
import { DataShareResultSet } from './ohos_data_DataShareResultSet'
import { mockInputDevice } from './ohos_multimodalInput_inputDevice'
import { mockVibrator } from './ohos_vibrator'
@@ -97,12 +105,13 @@ import { mockStack } from './ohos_util_Stack'
import { mockTreeMap } from './ohos_util_TreeMap'
import { mockTreeSet } from './ohos_util_TreeSet'
import { mockVector } from './ohos_util_Vector'
import { mockMultimediaAVSession } from './ohos_multimedia_av_session'
import { mockMultimediaCamera } from './ohos_multimedia_camera'
import { mockMultimediaAudio } from './ohos_multimedia_audio'
import { mockMultimediaImage } from './ohos_multimedia_image'
import { mockMultimediaMedia } from './ohos_multimedia_media'
import { mockMultimediaMediaLibrary } from './ohos_multimedia_mediaLibrary'
import { mockOhosBatteryinfo } from './ohos_batteryInfo'
import { mockBatteryinfo } from './ohos_batteryInfo'
import { mockBluetooth } from './ohos_bluetooth'
import { mockBrightness } from './ohos_brightness'
import { mockBytrace } from './ohos_bytrace'
@@ -111,6 +120,7 @@ import { mockContact } from './ohos_contact'
import { mockDataStorage } from './ohos_data_Storage'
import { mockDeviceInfo } from './ohos_deviceInfo'
import { mockDeviceManager } from './ohos_distributedHardware_deviceManager'
import { mockDistributedMissionManager } from "./ohos_distributedMissionManager"
import { mockDisplay } from './ohos_display'
import { mockHuks } from './ohos_security_huks'
import { mockInputMethod } from './ohos_inputmethod'
@@ -150,7 +160,6 @@ import { mockScreen } from './ohos_screen'
import { mockDistributedBundle } from './ohos_distributedBundle'
import { mockInputConsumer } from './ohos_multimodalInput_inputConsumer'
import { mockDocument } from './ohos_document'
import { mockMediaQuery } from './ohos_mediaquery'
import { mockResourceManager } from './ohos_resourceManager'
import { mockFile } from './system_file'
import { mockEnterpriseDeviceManager } from './ohos_enterpriseDeviceManager'
@@ -164,15 +173,18 @@ import { mockTouchEvent } from './ohos_multimodalInput_touchEvent'
import { mockAccessibility } from './ohos_accessibility'
import { mockAccessibilityConfig } from './ohos_accessibility_config'
import { mockAccessibilityExtensionAbility } from './ohos_application_AccessibilityExtensionAbility'
import { mockUiAppearance } from './ohos_uiAppearance'
import { mockContinationManager } from './ohos_continuation_continuationManager'
import { mockUiTest } from './ohos_uitest'
export function mockRequireNapiFun() {
global.requireNapi = function (...args) {
switch (args[0]) {
case "file":
return mockFile();
case "uiAppearance":
return mockUiAppearance();
case "resourceManager":
return mockResourceManager();
case "mediaquery":
return mockMediaQuery();
case "document":
return mockDocument();
case "screen":
@@ -245,6 +257,8 @@ export function mockRequireNapiFun() {
return mockDisplay();
case "distributedHardware.deviceManager":
return mockDeviceManager();
case "distributedMissionManager":
return mockDistributedMissionManager();
case "deviceInfo":
return mockDeviceInfo();
case "data.storage":
@@ -259,16 +273,32 @@ export function mockRequireNapiFun() {
return mockBrightness();
case "bluetooth":
return mockBluetooth();
case "batteryInfo":
return mockOhosBatteryinfo();
case "batteryinfo":
return mockBatteryinfo();
case "systemParameter":
return mockSystemParameter();
case "11.Ability":
case "ability.dataUriUtils":
return mockDataUriUtils();
case "ability.featureAbility":
return mockFeatureAbility();
case "application.Ability":
return mockAbility();
case "application.formHost":
return mockFormHost();
case "application.FormExtension":
return mockFormExtension();
case "application.ServiceExtensionAbility":
return mockServiceExtensionAbility();
case "application.errorManager":
return mockErrorManager();
case "application.testRunner":
return mockTestRunner();
case "application.StaticSubscriberExtensionAbility":
return mockStaticSubscriberExtensionAbility();
case "application.abilityDelegatorRegistry":
return mockAbilityDelegatorRegistry();
case "application.AbilityLifecycleCallback":
return mockAbilityLifecycleCallback();
case "application.AbilityStage":
return mockAbilityStage();
case "application.formBindingData":
@@ -345,8 +375,8 @@ export function mockRequireNapiFun() {
return mockPreferences();
case "data.dataShare":
return mockDataShare();
case "data.DataSharePredicates":
return DataSharePredicates();
case "data.dataSharePredicates":
return mockDataSharePredicates();
case "data.DataShareResultSet":
return DataShareResultSet();
case "data.dataAbility":
@@ -377,13 +407,13 @@ export function mockRequireNapiFun() {
return mockConvertXml();
case "statfs":
return mockStatfs();
case "filemanager":
case "fileManager":
return mockFileManager();
case "environment":
return mockEnvironment();
case "storagestatistics":
case "storageStatistics":
return mockStorageStatistics();
case "volumemanager":
case "volumeManager":
return mockVolumeManager();
case "settings":
return mockSettings();
@@ -397,7 +427,7 @@ export function mockRequireNapiFun() {
return mockBackgroundTaskManager();
case "bundleState":
return mockBundleState();
case "securitylabel":
case "securityLabel":
return mockSecurityLabel();
case "workScheduler":
return mockWorkScheduler();
@@ -439,6 +469,8 @@ export function mockRequireNapiFun() {
return mockMultimediaMedia();
case "multimedia.image":
return mockMultimediaImage();
case "multimedia.avsession":
return mockMultimediaAVSession();
case "multimedia.camera":
return mockMultimediaCamera();
case "multimedia.audio":
@@ -469,6 +501,10 @@ export function mockRequireNapiFun() {
return mockAccessibilityConfig();
case "application.AccessibilityExtensionAbility":
return mockAccessibilityExtensionAbility();
case "continuation.continuationManager":
return mockContinationManager();
case "uitest":
return mockUiTest();
default:
return global.requireNapiPreview(...args);
}
@@ -0,0 +1,22 @@
/*
* 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 { NotificationUserInput } from "./notificationUserInput"
export const NotificationActionButton = {
title: '[PC preview] unknow title',
wantAgent: '[PC preview] unknow wantAgent',
extras: {},
userInput: NotificationUserInput,
}
@@ -0,0 +1,45 @@
/*
* 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"
import { ContentType } from "../ohos_notification"
import { PixelMapMock } from "../ohos_multimedia_image"
export const NotificationBasicContent = {
title: '[PC preview] unknow title',
text: '[PC preview] unknow text',
additionalText: '[PC preview] unknow additionalText',
}
export const NotificationLongTextContent = {
longText: '[PC preview] unknow longText',
briefText: '[PC preview] unknow briefText',
expandedTitle: '[PC preview] unknow expandedTitle',
}
export const NotificationMultiLineContent = {
briefText: '[PC preview] unknow briefText',
longTitle: '[PC preview] unknow longTitle',
lines: [paramMock.paramStringMock],
}
export const NotificationPictureContent = {
briefText: '[PC preview] unknow briefText',
expandedTitle: '[PC preview] unknow expandedTitle',
picture: PixelMapMock,
}
export const NotificationContent = {
contentType: ContentType,
normal: NotificationBasicContent,
longText: NotificationLongTextContent,
multiLine: NotificationMultiLineContent,
picture: NotificationPictureContent,
}
@@ -0,0 +1,24 @@
/*
* 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.
*/
export const NotificationFlagStatus = {
TYPE_NONE: 0,
TYPE_OPEN: 1,
TYPE_CLOSE: 2,
}
export const NotificationFlags = {
soundEnabled: NotificationFlagStatus,
vibrationEnabled: NotificationFlagStatus,
}
@@ -0,0 +1,67 @@
/*
* 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"
import { SlotType } from "../ohos_notification"
import { NotificationActionButton } from "./notificationActionButton"
import { PixelMapMock } from "../ohos_multimedia_image"
import { NotificationTemplate } from "./notificationTemplate"
import { NotificationFlags } from "./notificationFlags"
import { NotificationContent } from "./notificationContent"
export const NotificationRequest = {
content: NotificationContent,
id: '[PC preview] unknow id',
slotType: SlotType,
isOngoing: '[PC preview] unknow isOngoing',
isUnremovable: '[PC preview] unknow isUnremovable',
deliveryTime: '[PC preview] unknow deliveryTime',
tapDismissed: '[PC preview] unknow tapDismissed',
autoDeletedTime: '[PC preview] unknow autoDeletedTime',
wantAgent: '[PC preview] unknow wantAgent',
extraInfo: {},
color: '[PC preview] unknow color',
colorEnabled: '[PC preview] unknow colorEnabled',
isAlertOnce: '[PC preview] unknow isAlertOnce',
isStopwatch: '[PC preview] unknow isStopwatch',
isCountDown: '[PC preview] unknow isCountDown',
isFloatingIcon: '[PC preview] unknow isFloatingIcon',
label: '[PC preview] unknow label',
badgeIconStyle: '[PC preview] unknow badgeIconStyle',
showDeliveryTime: '[PC preview] unknow showDeliveryTime',
actionButtons: [NotificationActionButton],
smallIcon: PixelMapMock,
largeIcon: PixelMapMock,
groupName: '[PC preview] unknow groupName',
creatorBundleName: '[PC preview] unknow creatorBundleName',
creatorUid: '[PC preview] unknow creatorUid',
creatorPid: '[PC preview] unknow creatorPid',
creatorUserId: '[PC preview] unknow creatorUserId',
classification: '[PC preview] unknow classification',
hashCode: '[PC preview] unknow hashCode',
isRemoveAllowed: '[PC preview] unknow isRemveAllowd',
source: '[PC preview] unknow source',
template: NotificationTemplate,
distributedOption: DistributedOptions,
deviceId: '[PC preview] unknow deviceId',
notificationFlags: NotificationFlags,
removalWantAgent: '[PC preview] unknow removalWantAgent',
badgeNumber: '[PC preview] unknow badgeNumber',
}
export const DistributedOptions = {
isDistributed: '[PC preview] unknow isDistributed',
supportDisplayDevices: [paramMock.paramStringMock],
supportOperateDevices: [paramMock.paramStringMock],
remindType: '[PC preview] unknow remindType',
}
@@ -0,0 +1,31 @@
/*
* 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"
import { SlotType, SlotLevel } from "../ohos_notification"
export const NotificationSlot = {
type: SlotType,
level: SlotLevel,
desc: '[PC preview] unknow desc',
badgeFlag: '[PC preview] unknow badgeFlag',
bypassDnd: '[PC preview] unknow bypassDnd',
lockscreenVisibility: '[PC preview] unknow lockscreenVisibility',
vibrationEnabled: '[PC preview] unknow vibrationEnabled',
sound: '[PC preview] unknow sound',
lightEnabled: '[PC preview] unknow lightEnabled',
lightColor: '[PC preview] unknow lightColor',
vibrationValues: [paramMock.paramNumberMock],
enabled: '[PC preview] unknow enabled',
};
@@ -0,0 +1,21 @@
/*
* 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 { NotificationSlot } from "./notificationSlot"
export const NotificationSorting = {
slot: NotificationSlot,
hashCode: '[PC preview] unknow hashCode',
ranking: '[PC preview] unknow ranking',
};
@@ -0,0 +1,20 @@
/*
* 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 const NotificationSortingMap = {
sortings: {},
sortedHashCode: [paramMock.paramStringMock],
};
@@ -0,0 +1,20 @@
/*
* 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 const NotificationSubscribeInfo = {
bundleNames: [paramMock.paramStringMock],
userId: '[PC preview] unknow userId',
};
@@ -0,0 +1,64 @@
/*
* 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"
import { NotificationRequest } from "./notificationRequest"
import { NotificationSortingMap } from "./notificationSortingMap"
export const NotificationSubscriber = {
onConsume: function (...args) {
console.warn("NotificationSubscriber.onConsume interface mocked in the Previewer. How this interface works on the" +
" Previewer may be different from that on a real device.")
},
onCancel: function (...args) {
console.warn("NotificationSubscriber.onCancel interface mocked in the Previewer. How this interface works on the" +
" Previewer may be different from that on a real device.")
},
onUpdate: function (...args) {
console.warn("NotificationSubscriber.onUpdate interface mocked in the Previewer. How this interface works on the" +
" Previewer may be different from that on a real device.")
},
onConnect: function () {
console.warn("NotificationSubscriber.onConnect interface mocked in the Previewer. How this interface works on the" +
" Previewer may be different from that on a real device.")
},
onDisconnect: function () {
console.warn("NotificationSubscriber.onDisconnect interface mocked in the Previewer. How this interface works on the" +
" Previewer may be different from that on a real device.")
},
onDestroy: function () {
console.warn("NotificationSubscriber.onDestroy interface mocked in the Previewer. How this interface works on the" +
" Previewer may be different from that on a real device.")
},
onDoNotDisturbDateChange: function (...args) {
console.warn("NotificationSubscriber.onDoNotDisturbDateChange interface mocked in the Previewer. How this interface works on the" +
" Previewer may be different from that on a real device.")
},
onEnabledNotificationChanged: function (...args) {
console.warn("NotificationSubscriber.onEnabledNotificationChanged interface mocked in the Previewer. How this interface works on the" +
" Previewer may be different from that on a real device.")
}
}
export const SubscribeCallbackData = {
request: NotificationRequest,
sortingMap: NotificationSortingMap,
reason: '[PC preview] unknow reason',
sound: '[PC preview] unknow sound',
vibrationValues: [paramMock.paramNumberMock],
}
export const EnabledNotificationCallbackData = {
bundle: '[PC preview] unknow bundle',
uid: '[PC preview] unknow uid',
enable: '[PC preview] unknow enable',
}
@@ -0,0 +1,18 @@
/*
* 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.
*/
export const NotificationTemplate = {
name: '[PC preview] unknow name',
data: {},
}
@@ -0,0 +1,17 @@
/*
* 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.
*/
export const NotificationUserInput = {
inputKey: '[PC preview] unknow inputKey',
}
@@ -16,14 +16,21 @@
import { paramMock } from "../utils"
export function mockAbilityAccessCtrl() {
const AtManagerMock = {
const GrantStatus = "[PC preview] unknow GrantStatus";
const AtManager = {
verifyAccessToken: function (...args) {
console.warn("AtManager.verifyAccessToken interface mocked in the Previewer." +
" How this interface works on the Previewer may be different from that on a real device.")
return new Promise((resolve, reject) => {
resolve(GrantStatusMock);
resolve(GrantStatus);
})
},
verifyAccessTokenSync: function (...args) {
console.warn("AtManager.verifyAccessTokenSync interface mocked in the Previewer." +
" How this interface works on the Previewer may be different from that on a real device.")
return GrantStatus;
},
grantUserGrantedPermission: function (...args) {
console.warn("AtManager.grantUserGrantedPermission interface mocked in the Previewer." +
" How this interface works on the Previewer may be different from that on a real device.")
@@ -60,9 +67,8 @@ export function mockAbilityAccessCtrl() {
createAtManager : function (...args) {
console.warn("abilityAccessCtrl.createAtManager interface mocked in the Previewer." +
" How this interface works on the Previewer may be different from that on a real device.")
return AtManagerMock;
return AtManager;
},
GrantStatusMock:'[PC preview] unknow GrantStatusMock'
};
return abilityAccessCtrl;
@@ -0,0 +1,42 @@
/*
* 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 mockDataUriUtils() {
const dataUriUtils = {
getId: function (...args) {
console.warn("dataUriUtils.getId interface mocked in the Previewer. How this interface works" +
" on the Previewer may be different from that on a real device.")
return paramMock.paramNumberMock
},
attachId: function (...args) {
console.warn("dataUriUtils.attachId interface mocked in the Previewer. How this interface works" +
" on the Previewer may be different from that on a real device.")
return paramMock.paramStringMock
},
deleteId: function (...args) {
console.warn("dataUriUtils.deleteId interface mocked in the Previewer. How this interface works" +
" on the Previewer may be different from that on a real device.")
return paramMock.paramStringMock
},
updateId: function (...args) {
console.warn("dataUriUtils.updateId 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 dataUriUtils;
}
@@ -0,0 +1,20 @@
/*
* 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.
*/
export const ErrorCode = {
PERMISSION_DENY: -3,
ABILITY_NOT_FOUND: -2,
INVALID_PARAMETER: -1,
NO_ERROR: 0,
}
@@ -0,0 +1,425 @@
/*
* 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"
import { WantClass } from "./ohos_application_Want"
import { Context } from "./app/context"
import { AbilityResult } from "./ability/abilityResult"
import { windowMock } from "./ohos_window"
const DataAbilityResult = {
uri: "[PC Preview] unknow uri",
count: "[PC Preview] unknow count"
}
const DataAbilityResultArray = [
DataAbilityResult
]
export const PacMapType = {
PacMap: {key:{}}
}
export const ResultSet = {
columnNames: [paramMock.paramStringMock],
columnCount: "[PC Preview] unknow columnCount",
rowCount: "[PC Preview] unknow rowCount",
rowIndex: "[PC Preview] unknow rowIndex",
isAtFirstRow: "[PC Preview] unknow isAtFirstRow",
isAtLastRow: "[PC Preview] unknow isAtLastRow",
isEnded: "[PC Preview] unknow isEnded",
isStarted: "[PC Preview] unknow isStarted",
isClose: "[PC Preview] unknow isClose",
getColumnIndex: function (...args) {
console.warn("ResultSet.getColumnIndex interface mocked in the Previewer. How this interface works on the Previewer" +
" may be different from that on a real device.")
return paramMock.paramNumberMock;
},
getColumnName: function (...args) {
console.warn("ResultSet.getColumnName interface mocked in the Previewer. How this interface works on the Previewer" +
" may be different from that on a real device.")
return paramMock.paramStringMock;
},
goTo: function (...args) {
console.warn("ResultSet.goTo interface mocked in the Previewer. How this interface works on the Previewer" +
" may be different from that on a real device.")
return paramMock.paramBooleanMock;
},
goToRow: function (...args) {
console.warn("ResultSet.goToRow interface mocked in the Previewer. How this interface works on the Previewer" +
" may be different from that on a real device.")
return paramMock.paramBooleanMock;
},
goToLastRow: function (...args) {
console.warn("ResultSet.goToLastRow interface mocked in the Previewer. How this interface works on the Previewer" +
" may be different from that on a real device.")
return paramMock.paramBooleanMock;
},
goToFirstRow: function (...args) {
console.warn("ResultSet.goToFirstRow interface mocked in the Previewer. How this interface works on the Previewer" +
" may be different from that on a real device.")
return paramMock.paramBooleanMock;
},
goToNextRow: function (...args) {
console.warn("ResultSet.goToNextRow interface mocked in the Previewer. How this interface works on the Previewer" +
" may be different from that on a real device.")
return paramMock.paramBooleanMock;
},
goToPreviousRow: function (...args) {
console.warn("ResultSet.goToPreviousRow interface mocked in the Previewer. How this interface works on the Previewer" +
" may be different from that on a real device.")
return paramMock.paramBooleanMock;
},
getBlob: function (...args) {
console.warn("ResultSet.getBlob interface mocked in the Previewer. How this interface works on the Previewer" +
" may be different from that on a real device.")
return paramMock.paramArrayMock;
},
getString: function (...args) {
console.warn("ResultSet.getString interface mocked in the Previewer. How this interface works on the Previewer" +
" may be different from that on a real device.")
return paramMock.paramStringMock;
},
getLong: function (...args) {
console.warn("ResultSet.getLong interface mocked in the Previewer. How this interface works on the Previewer" +
" may be different from that on a real device.")
return paramMock.paramNumberMock;
},
getDouble: function (...args) {
console.warn("ResultSet.getDouble interface mocked in the Previewer. How this interface works on the Previewer" +
" may be different from that on a real device.")
return paramMock.paramNumberMock;
},
isColumnNull: function (...args) {
console.warn("ResultSet.isColumnNull interface mocked in the Previewer. How this interface works on the Previewer" +
" may be different from that on a real device.")
return paramMock.paramBooleanMock;
},
close: function () {
console.warn("ResultSet.isColumnNull interface mocked in the Previewer. How this interface works on the Previewer" +
" may be different from that on a real device.")
}
}
const DataAbilityHelper = {
openFile: function (...args) {
console.warn("DataAbilityHelper.openFile 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 (typeof args[len - 1] === 'function') {
args[len - 1].call(this, paramMock.businessErrorMock, paramMock.paramNumberMock)
} else {
return new Promise((resolve) => {
resolve(paramMock.paramNumberMock);
})
}
},
on: function (...args) {
console.warn("DataAbilityHelper.on 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 (typeof args[len - 1] === 'function') {
args[len - 1].call(this, paramMock.businessErrorMock)
}
},
off: function (...args) {
console.warn("DataAbilityHelper.off 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 (typeof args[len - 1] === 'function') {
args[len - 1].call(this, paramMock.businessErrorMock)
}
},
getType: function (...args) {
console.warn("DataAbilityHelper.getType 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 (typeof args[len - 1] === 'function') {
args[len - 1].call(this, paramMock.businessErrorMock, paramMock.paramStringMock)
} else {
return new Promise((resolve) => {
resolve(paramMock.paramStringMock);
})
}
},
getFileTypes: function (...args) {
console.warn("DataAbilityHelper.getFileTypes 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 (typeof args[len - 1] === 'function') {
args[len - 1].call(this, paramMock.businessErrorMock, [paramMock.paramStringMock])
} else {
return new Promise((resolve) => {
resolve([paramMock.paramStringMock]);
})
}
},
normalizeUri: function (...args) {
console.warn("DataAbilityHelper.normalizeUri 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 (typeof args[len - 1] === 'function') {
args[len - 1].call(this, paramMock.businessErrorMock, paramMock.paramStringMock)
} else {
return new Promise((resolve) => {
resolve(paramMock.paramStringMock);
})
}
},
denormalizeUri: function (...args) {
console.warn("DataAbilityHelper.denormalizeUri 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 (typeof args[len - 1] === 'function') {
args[len - 1].call(this, paramMock.businessErrorMock, paramMock.paramStringMock)
} else {
return new Promise((resolve) => {
resolve(paramMock.paramStringMock);
})
}
},
notifyChange: function (...args) {
console.warn("DataAbilityHelper.notifyChange 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 (typeof args[len - 1] === 'function') {
args[len - 1].call(this, paramMock.businessErrorMock)
} else {
return new Promise((resolve) => {
resolve();
})
}
},
insert: function (...args) {
console.warn("DataAbilityHelper.insert 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 (typeof args[len - 1] === 'function') {
args[len - 1].call(this, paramMock.businessErrorMock, paramMock.paramNumberMock)
} else {
return new Promise((resolve) => {
resolve(paramMock.paramNumberMock);
})
}
},
batchInsert: function (...args) {
console.warn("DataAbilityHelper.batchInsert 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 (typeof args[len - 1] === 'function') {
args[len - 1].call(this, paramMock.businessErrorMock, paramMock.paramNumberMock)
} else {
return new Promise((resolve) => {
resolve(paramMock.paramNumberMock);
})
}
},
delete: function (...args) {
console.warn("DataAbilityHelper.delete 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 (typeof args[len - 1] === 'function') {
args[len - 1].call(this, paramMock.businessErrorMock, paramMock.paramNumberMock)
} else {
return new Promise((resolve) => {
resolve(paramMock.paramNumberMock);
})
}
},
update: function (...args) {
console.warn("DataAbilityHelper.update 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 (typeof args[len - 1] === 'function') {
args[len - 1].call(this, paramMock.businessErrorMock, paramMock.paramNumberMock)
} else {
return new Promise((resolve) => {
resolve(paramMock.paramNumberMock);
})
}
},
query: function (...args) {
console.warn("DataAbilityHelper.query 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 (typeof args[len - 1] === 'function') {
args[len - 1].call(this, paramMock.businessErrorMock, ResultSet)
} else {
return new Promise((resolve) => {
resolve(ResultSet);
})
}
},
call: function (...args) {
console.warn("DataAbilityHelper.call 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 (typeof args[len - 1] === 'function') {
args[len - 1].call(this, paramMock.businessErrorMock, PacMapType)
} else {
return new Promise((resolve) => {
resolve(PacMapType);
})
}
},
executeBatch: function (...args) {
console.warn("DataAbilityHelper.executeBatch 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 (typeof args[len - 1] === 'function') {
args[len - 1].call(this, paramMock.businessErrorMock, DataAbilityResultArray)
} else {
return new Promise((resolve) => {
resolve(DataAbilityResultArray);
})
}
}
}
export function mockFeatureAbility() {
const featureAbility = {
getWant: function (...args) {
console.warn("featureAbility.getWant 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, new WantClass());
} else {
return new Promise((resolve, reject) => {
resolve(new WantClass());
})
}
},
startAbility: function (...args) {
console.warn("featureAbility.startAbility 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, paramMock.paramNumberMock);
} else {
return new Promise((resolve, reject) => {
resolve(paramMock.paramNumberMock);
})
}
},
getContext: function () {
console.warn("featureAbility.getContext interface mocked in the Previewer." +
" How this interface works on the Previewer may be different from that on a real device.")
return Context;
},
startAbilityForResult: function (...args) {
console.warn("featureAbility.startAbilityForResult 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, AbilityResult);
} else {
return new Promise((resolve, reject) => {
resolve(AbilityResult);
})
}
},
terminateSelfWithResult: function (...args) {
console.warn("featureAbility.terminateSelfWithResult 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);
} else {
return new Promise((resolve, reject) => {
resolve();
})
}
},
terminateSelf: function () {
console.warn("featureAbility.terminateSelf 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);
} else {
return new Promise((resolve, reject) => {
resolve();
})
}
},
acquireDataAbilityHelper: function (...args) {
console.warn("featureAbility.acquireDataAbilityHelper interface mocked in the Previewer." +
" How this interface works on the Previewer may be different from that on a real device.")
return DataAbilityHelper;
},
hasWindowFocus: function (...args) {
console.warn("featureAbility.hasWindowFocus 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, paramMock.paramBooleanMock);
} else {
return new Promise((resolve, reject) => {
resolve(paramMock.paramBooleanMock);
})
}
},
connectAbility: function (...args) {
console.warn("featureAbility.connectAbility interface mocked in the Previewer." +
" How this interface works on the Previewer may be different from that on a real device.")
return paramMock.paramNumberMock;
},
disconnectAbility: function (...args) {
console.warn("featureAbility.disconnectAbility 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);
} else {
return new Promise((resolve, reject) => {
resolve();
})
}
},
getWindow: function (...args) {
console.warn("featureAbility.getWindow 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, windowMock);
} else {
return new Promise((resolve, reject) => {
resolve(windowMock);
})
}
},
}
return featureAbility;
}
export const AbilityWindowConfiguration = {
WINDOW_MODE_UNDEFINED: 0,
WINDOW_MODE_FULLSCREEN: 1,
WINDOW_MODE_SPLIT_PRIMARY: 100,
WINDOW_MODE_SPLIT_SECONDARY: 101,
WINDOW_MODE_FLOATING: 102
}
export const AbilityStartSetting = {
BOUNDS_KEY: "abilityBounds",
WINDOW_MODE_KEY: "windowMode",
DISPLAY_ID_KEY: "displayId"
}
export const ErrorCode = {
NO_ERROR: 0,
INVALID_PARAMETER: -1,
ABILITY_NOT_FOUND: -2,
PERMISSION_DENY: -3
}
export const DataAbilityOperationType = {
TYPE_INSERT: 1,
TYPE_UPDATE: 2,
TYPE_DELETE: 3,
TYPE_ASSERT: 4,
}
@@ -0,0 +1,68 @@
/*
* 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.
*/
export const Action = {
ACTION_HOME: "ohos.want.action.home",
ACTION_DIAL: "ohos.want.action.dial",
ACTION_SEARCH: "ohos.want.action.search",
ACTION_WIRELESS_SETTINGS: "ohos.settings.wireless",
ACTION_MANAGE_APPLICATIONS_SETTINGS: "ohos.settings.manage.applications",
ACTION_APPLICATION_DETAILS_SETTINGS: "ohos.settings.application.details",
ACTION_SET_ALARM: "ohos.want.action.setAlarm",
ACTION_SHOW_ALARMS: "ohos.want.action.showAlarms",
ACTION_SNOOZE_ALARM: "ohos.want.action.snoozeAlarm",
ACTION_DISMISS_ALARM: "ohos.want.action.dismissAlarm",
ACTION_DISMISS_TIMER: "ohos.want.action.dismissTimer",
ACTION_SEND_SMS: "ohos.want.action.sendSms",
ACTION_CHOOSE: "ohos.want.action.choose",
ACTION_IMAGE_CAPTURE: "ohos.want.action.imageCapture",
ACTION_VIDEO_CAPTURE: "ohos.want.action.videoCapture",
ACTION_SELECT: "ohos.want.action.select",
ACTION_SEND_DATA: "ohos.want.action.sendData",
ACTION_SEND_MULTIPLE_DATA: "ohos.want.action.sendMultipleData",
ACTION_SCAN_MEDIA_FILE: "ohos.want.action.scanMediaFile",
ACTION_VIEW_DATA: "ohos.want.action.viewData",
ACTION_EDIT_DATA: "ohos.want.action.editData",
INTENT_PARAMS_INTENT: "ability.want.params.INTENT",
INTENT_PARAMS_TITLE: "ability.want.params.TITLE",
ACTION_FILE_SELECT: "ohos.action.fileSelect",
PARAMS_STREAM: "ability.params.stream",
ACTION_APP_ACCOUNT_OAUTH: "ohos.account.appAccount.action.oauth",
ACTION_MARKER_DOWNLOAD: "ohos.want.action.marketDownload"
}
export const Entity = {
ENTITY_DEFAULT: "entity.system.default",
ENTITY_HOME: "entity.system.home",
ENTITY_VOICE: "entity.system.voice",
ENTITY_BROWSABLE: "entity.system.browsable",
ENTITY_VIDEO: "entity.system.video"
}
export const Flags = {
FLAG_AUTH_READ_URI_PERMISSION: 0x00000001,
FLAG_AUTH_WRITE_URI_PERMISSION: 0x00000002,
FLAG_ABILITY_FORWARD_RESULT: 0x00000004,
FLAG_ABILITY_CONTINUATION: 0x00000008,
FLAG_NOT_OHOS_COMPONENT: 0x00000010,
FLAG_ABILITY_FORM_ENABLED: 0x00000020,
FLAG_AUTH_PERSISTABLE_URI_PERMISSION: 0x00000040,
FLAG_AUTH_PREFIX_URI_PERMISSION: 0x00000080,
FLAG_ABILITYSLICE_MULTI_DEVICE: 0x00000100,
FLAG_START_FOREGROUND_ABILITY: 0x00000200,
FLAG_ABILITY_CONTINUATION_REVERSIBLE: 0x00000400,
FLAG_INSTALL_ON_DEMAND: 0x00000800,
FLAG_INSTALL_WITH_BACKGROUND_MODE: 0x80000000,
FLAG_ABILITY_CLEAR_MISSION: 0x00008000,
FLAG_ABILITY_NEW_MISSION: 0x10000000,
FLAG_ABILITY_MISSION_TOP: 0x20000000
}
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2021 Huawei Device Co., Ltd.
* Copyright (c) 2021-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
@@ -14,24 +14,36 @@
*/
import { paramMock } from "../utils"
import { AbilityContextClass } from "./application/abilityContext"
import { AbilityContextClass } from "./application/AbilityContext"
import { WantClass } from "./ohos_application_Want"
import { OnContinueResult } from "./ohos_application_AbilityConstant"
import { MessageParcelClass } from "./ohos_rpc"
const WantClass = class Want {
constructor() {
console.warn('Ability.Want.constructor interface mocked in the Previewer. How this interface works on' +
' the Previewer may be different from that on a real device.');
this.deviceId = "[PC Preview] unknow deviceId";
this.bundleName = "[PC Preview] unknow bundleName";
this.abilityName = "[PC Preview] unknow abilityName";
this.uri = "[PC Preview] unknow uri";
this.type = "[PC Preview] unknow type";
this.flag = "[PC Preview] unknow flag";
this.action = "[PC Preview] unknow action";
this.parameters = {};
this.entities = [paramMock.paramStringMock];
}
export const Caller = {
call: function (...args) {
console.warn("Caller.call interface mocked in the Previewer." +
" How this interface works on the Previewer may be different from that on a real device.")
return new Promise((resolve, reject) => {
resolve();
})
},
callWithResult: function (...args) {
console.warn("Caller.callWithResult interface mocked in the Previewer." +
" How this interface works on the Previewer may be different from that on a real device.")
return new Promise((resolve, reject) => {
resolve(new MessageParcelClass());
})
},
release: function () {
console.warn("Caller.release interface mocked in the Previewer. How this interface works on the Previewer" +
" may be different from that on a real device.")
},
onRelease: function (...args) {
console.warn("Caller.onRelease interface mocked in the Previewer. How this interface works on the Previewer" +
" may be different from that on a real device.")
},
}
const calleeMock = {
export const Callee = {
on: function (...args) {
console.warn("Ability.calleeClass.on interface mocked in the Previewer. How this interface works on the Previewer" +
" may be different from that on a real device.")
@@ -41,53 +53,62 @@ const calleeMock = {
" may be different from that on a real device.")
},
}
export function mockAbility() {
const AbilityClass = class Ability {
constructor() {
console.warn('application.Ability.constructor interface mocked in the Previewer. How this interface works on' +
' the Previewer may be different from that on a real device.');
this.context = new AbilityContextClass();
this.launchWant = new WantClass();
this.lastRequestWant = new WantClass();
this.callee = calleeMock;
this.onCreate = function (...args) {
console.warn("application.Ability.onCreate interface mocked in the Previewer. How this interface works on the Previewer" +
" may be different from that on a real device.")
};
this.onWindowStageCreate = function (...args) {
console.warn("application.Ability.onWindowStageCreate interface mocked in the Previewer. How this interface works on the Previewer" +
" may be different from that on a real device.")
};
this.onWindowStageDestroy = function () {
console.warn("application.Ability.onWindowStageDestroy interface mocked in the Previewer. How this interface works on the Previewer" +
" may be different from that on a real device.")
};
this.onDestroy = function () {
console.warn("application.Ability.onDestroy interface mocked in the Previewer. How this interface works on the Previewer" +
" may be different from that on a real device.")
};
this.onForeground = function () {
console.warn("application.Ability.onForeground interface mocked in the Previewer. How this interface works on the Previewer" +
" may be different from that on a real device.")
};
this.onBackground = function () {
console.warn("application.Ability.onBackground interface mocked in the Previewer. How this interface works on the Previewer" +
" may be different from that on a real device.")
};
this.onContinue = function () {
console.warn("application.Ability.onContinue interface mocked in the Previewer. How this interface works on the Previewer" +
" may be different from that on a real device.")
return paramMock.paramBooleanMock;
};
this.onNewWant = function () {
console.warn("application.Ability.onNewWant interface mocked in the Previewer. How this interface works on the Previewer" +
" may be different from that on a real device.")
};
this.onConfigurationUpdated = function () {
console.warn("application.Ability.onConfigurationUpdated interface mocked in the Previewer. How this interface works on the Previewer" +
" may be different from that on a real device.")
};
}
export const AbilityClass = class Ability {
constructor() {
console.warn('application.Ability.constructor interface mocked in the Previewer. How this interface works on' +
' the Previewer may be different from that on a real device.');
this.context = new AbilityContextClass();
this.launchWant = new WantClass();
this.lastRequestWant = new WantClass();
this.callee = Callee;
this.onCreate = function (...args) {
console.warn("application.Ability.onCreate interface mocked in the Previewer. How this interface works on the Previewer" +
" may be different from that on a real device.")
};
this.onWindowStageCreate = function (...args) {
console.warn("application.Ability.onWindowStageCreate interface mocked in the Previewer. How this interface works on the Previewer" +
" may be different from that on a real device.")
};
this.onWindowStageDestroy = function () {
console.warn("application.Ability.onWindowStageDestroy interface mocked in the Previewer. How this interface works on the Previewer" +
" may be different from that on a real device.")
};
this.onWindowStageRestore = function (...args) {
console.warn("application.Ability.onWindowStageRestore interface mocked in the Previewer. How this interface works on the Previewer" +
" may be different from that on a real device.")
};
this.onDestroy = function () {
console.warn("application.Ability.onDestroy interface mocked in the Previewer. How this interface works on the Previewer" +
" may be different from that on a real device.")
};
this.onForeground = function () {
console.warn("application.Ability.onForeground interface mocked in the Previewer. How this interface works on the Previewer" +
" may be different from that on a real device.")
};
this.onBackground = function () {
console.warn("application.Ability.onBackground interface mocked in the Previewer. How this interface works on the Previewer" +
" may be different from that on a real device.")
};
this.onContinue = function (...args) {
console.warn("application.Ability.onContinue interface mocked in the Previewer. How this interface works on the Previewer" +
" may be different from that on a real device.")
return OnContinueResult;
};
this.onNewWant = function (...args) {
console.warn("application.Ability.onNewWant interface mocked in the Previewer. How this interface works on the Previewer" +
" may be different from that on a real device.")
};
this.onConfigurationUpdated = function (...args) {
console.warn("application.Ability.onConfigurationUpdated interface mocked in the Previewer. How this interface works on the Previewer" +
" may be different from that on a real device.")
};
this.dump = function (...args) {
console.warn("application.Ability.dump interface mocked in the Previewer. How this interface works on the Previewer" +
" may be different from that on a real device.")
return [paramMock.paramStringMock];
};
}
}
export function mockAbility() {
return new AbilityClass();
}
@@ -0,0 +1,35 @@
/*
* 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.
*/
export const LaunchParam = {
launchReason: LaunchReason,
lastExitReason: LastExitReason,
}
export const LaunchReason = {
UNKNOWN: 0,
START_ABILITY: 1,
CALL: 2,
CONTINUATION: 3,
}
export const LastExitReason = {
UNKNOWN: 0,
ABILITY_NOT_RESPONDING: 1,
NORMAL: 2,
}
export const OnContinueResult = {
AGREE: 0,
REJECT: 1,
MISMATCH: 2,
}
@@ -0,0 +1,54 @@
/*
* 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 mockAbilityLifecycleCallback() {
const AbilityLifecycleCallbackClass = class AbilityLifecycleCallback {
constructor() {
console.warn('application.AbilityLifecycleCallback.constructor interface mocked in the Previewer. How this interface works on' +
' the Previewer may be different from that on a real device.');
this.onAbilityCreate = function (...args) {
console.warn("application.AbilityLifecycleCallback.onAbilityCreate interface mocked in the Previewer. How this interface works on the Previewer" +
" may be different from that on a real device.")
};
this.onAbilityWindowStageCreate = function (...args) {
console.warn("application.AbilityLifecycleCallback.onAbilityWindowStageCreate interface mocked in the Previewer. How this interface works on the Previewer" +
" may be different from that on a real device.")
};
this.onAbilityWindowStageDestroy = function (...args) {
console.warn("application.AbilityLifecycleCallback.onAbilityWindowStageDestroy interface mocked in the Previewer. How this interface works on the Previewer" +
" may be different from that on a real device.")
};
this.onAbilityDestroy = function (...args) {
console.warn("application.AbilityLifecycleCallback.onAbilityDestroy interface mocked in the Previewer. How this interface works on the Previewer" +
" may be different from that on a real device.")
};
this.onAbilityForeground = function (...args) {
console.warn("application.AbilityLifecycleCallback.onAbilityForeground interface mocked in the Previewer. How this interface works on the Previewer" +
" may be different from that on a real device.")
};
this.onAbilityBackground = function (...args) {
console.warn("application.AbilityLifecycleCallback.onAbilityBackground interface mocked in the Previewer. How this interface works on the Previewer" +
" may be different from that on a real device.")
};
this.onAbilityContinue = function (...args) {
console.warn("application.AbilityLifecycleCallback.onAbilityContinue interface mocked in the Previewer. How this interface works on the Previewer" +
" may be different from that on a real device.")
};
}
}
return new AbilityLifecycleCallbackClass();
}
@@ -13,7 +13,7 @@
* limitations under the License.
*/
import { abilityStageContextClass } from "./application/abilityContext"
import { abilityStageContextClass } from "./application/AbilityContext"
import { paramMock } from "../utils"
export function mockAbilityStage() {
@@ -26,11 +26,15 @@ export function mockAbilityStage() {
console.warn("application.AbilityStage.onCreate interface mocked in the Previewer. How this interface works on the Previewer" +
" may be different from that on a real device.")
};
this.onAcceptWant = function () {
this.onAcceptWant = function (...args) {
console.warn("application.AbilityStage.onAcceptWant interface mocked in the Previewer. How this interface works on the Previewer" +
" may be different from that on a real device.")
return paramMock.paramStringMock;
}
};
this.onConfigurationUpdated = function (...args) {
console.warn("application.AbilityStage.onConfigurationUpdated interface mocked in the Previewer. How this interface works on the Previewer" +
" may be different from that on a real device.")
};
}
}
return new AbilityStageClass();
@@ -0,0 +1,22 @@
/*
* 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 { ColorMode, Direction, ScreenDensity} from "./ohos_application_ConfigurationConstant"
export const Configuration = {
language: '[PC preview] unknow language',
colorMode: ColorMode,
direction: Direction,
screenDensity: ScreenDensity,
displayId: '[PC preview] unknow displayId',
}
@@ -0,0 +1,33 @@
/*
* 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.
*/
export const ColorMode = {
COLOR_MODE_NOT_SET: -1,
COLOR_MODE_DARK: 0,
COLOR_MODE_LIGHT: 1,
}
export const Direction = {
DIRECTION_NOT_SET: -1,
DIRECTION_VERTICAL: 0,
DIRECTION_HORIZONTAL: 1,
}
export const ScreenDensity = {
SCREEN_DENSITY_NOT_SET: 0,
SCREEN_DENSITY_SDPI: 120,
SCREEN_DENSITY_MDPI: 160,
SCREEN_DENSITY_LDPI: 240,
SCREEN_DENSITY_XLDPI: 320,
SCREEN_DENSITY_XXLDPI: 480,
SCREEN_DENSITY_XXXLDPI: 640,
}
@@ -14,7 +14,7 @@
*/
import { paramMock } from "../utils"
import { ExtensionContextClass } from "./application/abilityContext"
import { ExtensionContextClass } from "./application/AbilityContext"
import { DataShareResultSetMock } from "./ohos_data_DataShareResultSet"
export function mockDataShareExtensionAbility() {
@@ -23,56 +23,95 @@ export function mockDataShareExtensionAbility() {
console.warn('application.DataShareExtensionAbility interface mocked in the Previewer. How this interface works on' +
' the Previewer may be different from that on a real device.');
this.context = new ExtensionContextClass();
this.onCreate = function () {
this.onCreate = function (...args) {
console.warn("application.DataShareExtensionAbility.onCreate interface mocked in the Previewer. How this interface works on the Previewer" +
" may be different from that on a real device.")
};
this.getFileTypes = function () {
" may be different from that on a real device.")
const len = args.length
if (typeof args[len - 1] === 'function') {
args[len - 1].call(this, paramMock.businessErrorMock)
}
},
this.getFileTypes = function (...args) {
console.warn("application.DataShareExtensionAbility.getFileTypes interface mocked in the Previewer. How this interface works on the Previewer" +
" may be different from that on a real device.")
return [paramMock.paramStringMock];
};
this.insert = function () {
" may be different from that on a real device.")
const len = args.length
if (typeof args[len - 1] === 'function') {
args[len - 1].call(this, paramMock.businessErrorMock,[paramMock.paramStringMock])
}
},
this.openFile = function (...args) {
console.warn("application.DataShareExtensionAbility.openFile 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 (typeof args[len - 1] === 'function') {
args[len - 1].call(this, paramMock.businessErrorMock, paramMock.paramNumberMock)
}
},
this.insert = function (...args) {
console.warn("application.DataShareExtensionAbility.insert interface mocked in the Previewer. How this interface works on the Previewer" +
" may be different from that on a real device.")
return paramMock.paramNumberMock;
};
this.update = function () {
" may be different from that on a real device.")
const len = args.length
if (typeof args[len - 1] === 'function') {
args[len - 1].call(this, paramMock.businessErrorMock, paramMock.paramNumberMock)
}
},
this.update = function (...args) {
console.warn("application.DataShareExtensionAbility.update interface mocked in the Previewer. How this interface works on the Previewer" +
" may be different from that on a real device.")
return paramMock.paramNumberMock;
};
this.delete = function () {
" may be different from that on a real device.")
const len = args.length
if (typeof args[len - 1] === 'function') {
args[len - 1].call(this, paramMock.businessErrorMock, paramMock.paramNumberMock)
}
},
this.delete = function (...args) {
console.warn("application.DataShareExtensionAbility.delete interface mocked in the Previewer. How this interface works on the Previewer" +
" may be different from that on a real device.")
return paramMock.paramNumberMock;
};
this.query = function () {
" may be different from that on a real device.")
const len = args.length
if (typeof args[len - 1] === 'function') {
args[len - 1].call(this, paramMock.businessErrorMock, paramMock.paramNumberMock)
}
},
this.query = function (...args) {
console.warn("application.DataShareExtensionAbility.query interface mocked in the Previewer. How this interface works on the Previewer" +
" may be different from that on a real device.")
return DataShareResultSetMock;
};
this.getType = function () {
" may be different from that on a real device.")
const len = args.length
if (typeof args[len - 1] === 'function') {
args[len - 1].call(this, paramMock.businessErrorMock, paramMock.paramStringMock)
}
},
this.getType = function (...args) {
console.warn("application.DataShareExtensionAbility.getType interface mocked in the Previewer. How this interface works on the Previewer" +
" may be different from that on a real device.")
return paramMock.paramStringMock;
};
this.batchInsert = function () {
" may be different from that on a real device.")
const len = args.length
if (typeof args[len - 1] === 'function') {
args[len - 1].call(this, paramMock.businessErrorMock, paramMock.paramStringMock)
}
},
this.batchInsert = function (...args) {
console.warn("application.DataShareExtensionAbility.batchInsert interface mocked in the Previewer. How this interface works on the Previewer" +
" may be different from that on a real device.")
return paramMock.paramNumberMock;
};
this.normalizeUri = function () {
" may be different from that on a real device.")
const len = args.length
if (typeof args[len - 1] === 'function') {
args[len - 1].call(this, paramMock.businessErrorMock, paramMock.paramNumberMock)
}
},
this.normalizeUri = function (...args) {
console.warn("application.DataShareExtensionAbility.normalizeUri interface mocked in the Previewer. How this interface works on the Previewer" +
" may be different from that on a real device.")
return paramMock.paramStringMock;
};
this.denormalizeUri = function () {
" may be different from that on a real device.")
const len = args.length
if (typeof args[len - 1] === 'function') {
args[len - 1].call(this, paramMock.businessErrorMock)
}
},
this.denormalizeUri = function (...args) {
console.warn("application.DataShareExtensionAbility.denormalizeUri interface mocked in the Previewer. How this interface works on the Previewer" +
" may be different from that on a real device.")
return paramMock.paramStringMock;
};
" may be different from that on a real device.")
const len = args.length
if (typeof args[len - 1] === 'function') {
args[len - 1].call(this, paramMock.businessErrorMock)
}
}
}
}
return new DataShareExtensionAbilityClass();
return DataShareExtensionAbilityClass;
}
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2021 Huawei Device Co., Ltd.
* Copyright (c) 2021-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
@@ -14,7 +14,8 @@
*/
import { paramMock } from "../utils"
import { ExtensionContextClass } from "./application/abilityContext"
import { ExtensionContextClass } from "./application/AbilityContext"
import { FormState } from "./ohos_application_formInfo"
export function mockFormExtension() {
const formBindingDataMock = {
@@ -36,7 +37,19 @@ export function mockFormExtension() {
resolve();
})
}
}
};
this.startAbility = function (...args) {
console.warn("formExtension.formExtensionContext.startAbility 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);
} else {
return new Promise((resolve, reject) => {
resolve();
})
}
};
}
}
const formExtensionClass = class formExtension {
@@ -69,6 +82,15 @@ export function mockFormExtension() {
console.warn("application.formExtension.onDestroy interface mocked in the Previewer. How this interface works on the Previewer" +
" may be different from that on a real device.")
};
this.onConfigurationUpdated = function (...args) {
console.warn("application.formExtension.onConfigurationUpdated interface mocked in the Previewer. How this interface works on the Previewer" +
" may be different from that on a real device.")
};
this.onAcquireFormState = function (...args) {
console.warn("application.formExtension.onAcquireFormState interface mocked in the Previewer. How this interface works on the Previewer" +
" may be different from that on a real device.")
return FormState;
};
}
}
return new formExtensionClass();
@@ -14,7 +14,7 @@
*/
import { paramMock } from "../utils"
import { ExtensionContextClass } from "./application/abilityContext"
import { ExtensionContextClass } from "./application/AbilityContext"
export const RemoteObjectClass = class RemoteObject {
constructor() {
@@ -231,6 +231,11 @@ export function mockServiceExtensionAbility() {
console.warn("application.ServiceExtensionAbility.onConfigurationUpdated interface mocked in the Previewer. How this interface works on the Previewer" +
" may be different from that on a real device.")
};
this.dump = function (...args) {
console.warn("application.ServiceExtensionAbility.dump 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 new ServiceExtensionAbilityClass();
@@ -0,0 +1,22 @@
/*
* 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.
*/
export const StartOptionsClass = class StartOptions {
constructor() {
console.warn('StartOptions.constructor interface mocked in the Previewer. How this interface works on' +
' the Previewer may be different from that on a real device.');
this.windowMode = "[PC Preview] unknow windowMode";
this.displayId = "[PC Preview] unknow displayId";
}
}
@@ -0,0 +1,27 @@
/*
* 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.
*/
export function mockStaticSubscriberExtensionAbility() {
const StaticSubscriberExtensionAbilityClass = class StaticSubscriberExtensionAbility {
constructor() {
console.warn('StaticSubscriberExtensionAbility.constructor interface mocked in the Previewer. How this interface works on' +
' the Previewer may be different from that on a real device.');
this.onReceiveEvent = function (...args) {
console.warn("StaticSubscriberExtensionAbility.onReceiveEvent interface mocked in the Previewer. How this interface works on the Previewer" +
" may be different from that on a real device.")
};
}
}
return new StaticSubscriberExtensionAbilityClass();
}
@@ -0,0 +1,32 @@
/*
* 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 const WantClass = class Want {
constructor() {
console.warn('Want.constructor interface mocked in the Previewer. How this interface works on' +
' the Previewer may be different from that on a real device.');
this.deviceId = "[PC Preview] unknow deviceId";
this.bundleName = "[PC Preview] unknow bundleName";
this.abilityName = "[PC Preview] unknow abilityName";
this.uri = "[PC Preview] unknow uri";
this.type = "[PC Preview] unknow type";
this.flag = "[PC Preview] unknow flag";
this.action = "[PC Preview] unknow action";
this.parameters = {};
this.entities = [paramMock.paramStringMock];
this.moduleName = "[PC Preview] unknow moduleName";
}
}
@@ -0,0 +1,41 @@
/*
* 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 { AbilityDelegator } from "./application/abilityDelegator"
import { AbilityDelegatorArgs } from "./application/abilityDelegatorArgs"
export const AbilityLifecycleState = {
UNINITIALIZED: '[PC preview] unknow UNINITIALIZED',
CREATE: '[PC preview] unknow CREATE',
FOREGROUND: '[PC preview] unknow FOREGROUND',
BACKGROUND: '[PC preview] unknow BACKGROUND',
DESTROY: '[PC preview] unknow DESTROY',
}
export function mockAbilityDelegatorRegistry() {
const abilityDelegatorRegistry = {
getAbilityDelegator: function () {
console.warn('abilityDelegatorRegistry.getAbilityDelegator interface mocked in the Previewer. How this interface works on the' +
' Previewer may be different from that on a real device.');
return AbilityDelegator;
},
getArguments: function () {
console.warn('abilityDelegatorRegistry.getArguments interface mocked in the Previewer. How this interface works on the' +
' Previewer may be different from that on a real device.');
return AbilityDelegatorArgs;
},
}
return abilityDelegatorRegistry
}
@@ -15,6 +15,13 @@
import { paramMock } from "../utils"
export const AbilityState = {
INITIAL: 0,
FOREGROUND: 9,
BACKGROUND: 10,
FOREGROUNDING: 11,
BACKGROUNDING: 12
}
export function mockAbilityManager() {
const AbilityRunningInfoMock = {
ability: ElementNameMock,
@@ -40,6 +47,14 @@ export function mockAbilityManager() {
clientPackage: [paramMock.paramStringMock],
ExtensionAbilityTypeMock: '[PC preview] unknow ExtensionAbilityTypeMock',
}
const elementName = {
deviceId: "[PC preview] unknown deviceId",
bundleName: "[PC preview] unknown bundleName",
abilityName: "[PC preview] unknown abilityName",
uri: "[PC preview] unknown uri",
shortName: "[PC preview] unknown shortName",
moduleName: "[PC preview] unknown moduleName",
}
const abilityManager = {
updateConfiguration: function (...args) {
console.warn('abilityManager.updateConfiguration interface mocked in the Previewer. How this interface works on the' +
@@ -76,6 +91,18 @@ export function mockAbilityManager() {
resolve([ExtensionRunningInfoMock]);
});
}
},
getTopAbility: function (...args) {
console.warn('abilityManager.getTopAbility 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 (typeof args[len - 1] === 'function') {
args[len - 1].call(this, paramMock.businessErrorMock, elementName);
} else {
return new Promise((resolve) => {
resolve(elementName);
});
}
}
}
return abilityManager
@@ -116,6 +116,30 @@ export function mockAppManager() {
resolve();
});
}
},
isRamConstrainedDevice: function (...args) {
console.warn('appManager.isRamConstrainedDevice 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 (typeof args[len - 1] === 'function') {
args[len - 1].call(this, paramMock.businessErrorMock, paramMock.paramBooleanMock);
} else {
return new Promise((resolve) => {
resolve(paramMock.paramBooleanMock);
});
}
},
getAppMemorySize: function (...args) {
console.warn('appManager.getAppMemorySize 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 (typeof args[len - 1] === 'function') {
args[len - 1].call(this, paramMock.businessErrorMock, paramMock.paramNumberMock);
} else {
return new Promise((resolve) => {
resolve(paramMock.paramNumberMock);
});
}
}
}
return appManager
@@ -0,0 +1,38 @@
/*
* 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 mockErrorManager() {
const errorManager = {
registerErrorObserver: function (...args) {
console.warn('errorManager.registerErrorObserver interface mocked in the Previewer. How this interface works on the' +
' Previewer may be different from that on a real device.');
return paramMock.paramNumberMock;
},
unregisterErrorObserver: function (...args) {
console.warn('errorManager.unregisterErrorObserver 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 (typeof args[len - 1] === 'function') {
args[len - 1].call(this, paramMock.businessErrorMock);
} else {
return new Promise((resolve, reject) => {
resolve();
});
}
},
}
return errorManager
}
@@ -14,17 +14,16 @@
*/
import { paramMock } from "../utils"
export const FormBindingData = {
data: paramMock.paramObjectMock
}
export function mockFormBindingData() {
const formBindingDatasMock = {
data: paramMock.paramObjectMock
}
const formBindingDataMock = {
const formBindingData = {
createFormBindingData: function (...args) {
console.warn("formBindingData.createFormBindingData interface mocked in the Previewer. How this interface works on the Previewer" +
" may be different from that on a real device.")
return formBindingDatasMock;
return FormBindingData;
},
}
return formBindingDataMock;
return formBindingData;
}
@@ -0,0 +1,39 @@
/*
* 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.
*/
export const FormError = {
ERR_COMMON: 1,
ERR_PERMISSION_DENY: 2,
ERR_GET_INFO_FAILED: 4,
ERR_GET_BUNDLE_FAILED: 5,
ERR_GET_LAYOUT_FAILED: 6,
ERR_ADD_INVALID_PARAM: 7,
ERR_CFG_NOT_MATCH_ID: 8,
ERR_NOT_EXIST_ID: 9,
ERR_BIND_PROVIDER_FAILED: 10,
ERR_MAX_SYSTEM_FORMS: 11,
ERR_MAX_INSTANCES_PER_FORM: 12,
ERR_OPERATION_FORM_NOT_SELF: 13,
ERR_PROVIDER_DEL_FAIL: 14,
ERR_MAX_FORMS_PER_CLIENT: 15,
ERR_MAX_SYSTEM_TEMP_FORMS: 16,
ERR_FORM_NO_SUCH_MODULE: 17,
ERR_FORM_NO_SUCH_ABILITY: 18,
ERR_FORM_NO_SUCH_DIMENSION: 19,
ERR_FORM_FA_NOT_INSTALLED: 20,
ERR_SYSTEM_RESPONSES_FAILED: 30,
ERR_FORM_DUPLICATE_ADDED: 31,
ERR_IN_RECOVERY: 36
}
@@ -0,0 +1,219 @@
/*
* 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"
import { FormInfo, FormStateInfo } from "./ohos_application_formInfo"
export function mockFormHost() {
const formHost = {
deleteForm: function (...args) {
console.warn('formHost.deleteForm 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 (typeof args[len - 1] === 'function') {
args[len - 1].call(this, paramMock.businessErrorMock);
} else {
return new Promise((resolve) => {
resolve();
});
}
},
releaseForm: function (...args) {
console.warn('formHost.releaseForm 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 (typeof args[len - 1] === 'function') {
args[len - 1].call(this, paramMock.businessErrorMock);
} else {
return new Promise((resolve) => {
resolve();
});
}
},
requestForm: function (...args) {
console.warn('formHost.requestForm 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 (typeof args[len - 1] === 'function') {
args[len - 1].call(this, paramMock.businessErrorMock);
} else {
return new Promise((resolve) => {
resolve();
});
}
},
castTempForm: function (...args) {
console.warn('formHost.castTempForm 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 (typeof args[len - 1] === 'function') {
args[len - 1].call(this, paramMock.businessErrorMock);
} else {
return new Promise((resolve) => {
resolve();
});
}
},
notifyVisibleForms: function (...args) {
console.warn('formHost.notifyVisibleForms 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 (typeof args[len - 1] === 'function') {
args[len - 1].call(this, paramMock.businessErrorMock);
} else {
return new Promise((resolve) => {
resolve();
});
}
},
notifyInvisibleForms: function (...args) {
console.warn('formHost.notifyInvisibleForms 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 (typeof args[len - 1] === 'function') {
args[len - 1].call(this, paramMock.businessErrorMock);
} else {
return new Promise((resolve) => {
resolve();
});
}
},
enableFormsUpdate: function (...args) {
console.warn('formHost.enableFormsUpdate 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 (typeof args[len - 1] === 'function') {
args[len - 1].call(this, paramMock.businessErrorMock);
} else {
return new Promise((resolve) => {
resolve();
});
}
},
disableFormsUpdate: function (...args) {
console.warn('formHost.disableFormsUpdate 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 (typeof args[len - 1] === 'function') {
args[len - 1].call(this, paramMock.businessErrorMock);
} else {
return new Promise((resolve) => {
resolve();
});
}
},
isSystemReady: function (...args) {
console.warn('formHost.isSystemReady 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 (typeof args[len - 1] === 'function') {
args[len - 1].call(this, paramMock.businessErrorMock);
} else {
return new Promise((resolve) => {
resolve();
});
}
},
getAllFormsInfo: function (...args) {
console.warn('formHost.getAllFormsInfo 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 (typeof args[len - 1] === 'function') {
args[len - 1].call(this, paramMock.businessErrorMock, [FormInfo]);
} else {
return new Promise((resolve) => {
resolve([FormInfo]);
});
}
},
getFormsInfo: function (...args) {
console.warn('formHost.getFormsInfo 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 (typeof args[len - 1] === 'function') {
args[len - 1].call(this, paramMock.businessErrorMock, [FormInfo]);
} else {
return new Promise((resolve) => {
resolve([FormInfo]);
});
}
},
deleteInvalidForms: function (...args) {
console.warn('formHost.deleteInvalidForms 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 (typeof args[len - 1] === 'function') {
args[len - 1].call(this, paramMock.businessErrorMock, [paramMock.paramNumberMock]);
} else {
return new Promise((resolve) => {
resolve([paramMock.paramNumberMock]);
});
}
},
acquireFormState: function (...args) {
console.warn('formHost.acquireFormState 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 (typeof args[len - 1] === 'function') {
args[len - 1].call(this, paramMock.businessErrorMock, FormStateInfo);
} else {
return new Promise((resolve) => {
resolve(FormStateInfo);
});
}
},
on: function (...args) {
console.warn("formHost.on 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 (typeof args[len - 1] === 'function') {
args[len - 1].call(this, paramMock.paramStringMock);
}
},
off: function (...args) {
console.warn("formHost.off 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 (typeof args[len - 1] === 'function') {
args[len - 1].call(this, paramMock.paramStringMock);
}
},
notifyFormsVisible: function (...args) {
console.warn('formHost.notifyFormsVisible 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 (typeof args[len - 1] === 'function') {
args[len - 1].call(this, paramMock.businessErrorMock);
} else {
return new Promise((resolve) => {
resolve();
});
}
},
notifyFormsEnableUpdate: function (...args) {
console.warn('formHost.notifyFormsEnableUpdate 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 (typeof args[len - 1] === 'function') {
args[len - 1].call(this, paramMock.businessErrorMock);
} else {
return new Promise((resolve) => {
resolve();
});
}
},
}
return formHost
}
@@ -0,0 +1,66 @@
/*
* 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"
import { WantClass } from "./ohos_application_Want"
export const FormInfo = {
bundleName: '[PC preview] unknow bundleName',
moduleName: '[PC preview] unknow moduleName',
abilityName: '[PC preview] unknow abilityName',
name: '[PC preview] unknow name',
description: '[PC preview] unknow description',
type: FormType,
jsComponentName: '[PC preview] unknow jsComponentName',
colorMode: ColorMode,
isDefault: '[PC preview] unknow isDefault',
updateEnabled: '[PC preview] unknow updateEnabled',
formVisibleNotify: '[PC preview] unknow formVisibleNotify',
relatedBundleName: '[PC preview] unknow relatedBundleName',
scheduledUpdateTime: '[PC preview] unknow scheduledUpdateTime',
formConfigAbility: '[PC preview] unknow formConfigAbility',
updateDuration: '[PC preview] unknow updateDuration',
defaultDimension: '[PC preview] unknow defaultDimension',
supportDimensions: [paramMock.paramNumberMock],
customizeData: {"key": paramMock.paramStringMock},
}
export const FormType = {
JS: 1,
}
export const ColorMode = {
MODE_AUTO: -1,
MODE_DARK: 0,
MODE_LIGHT: 1
}
export const FormStateInfo = {
formState: FormState,
want: new WantClass(),
}
export const FormState = {
UNKNOWN: -1,
DEFAULT: 0,
READY: 1,
}
export const FormParam = {
IDENTITY_KEY: "ohos.extra.param.key.form_identity",
DIMENSION_KEY: "ohos.extra.param.key.form_dimension",
NAME_KEY: "ohos.extra.param.key.form_name",
MODULE_NAME_KEY: "ohos.extra.param.key.module_name",
WIDTH_KEY: "ohos.extra.param.key.form_width",
HEIGHT_KEY: "ohos.extra.param.key.form_height",
TEMPORARY_KEY: "ohos.extra.param.key.form_temporary"
}
export const FormInfoFilter = {
moduleName: '[PC preview] unknow moduleName',
}
@@ -13,44 +13,42 @@
* limitations under the License.
*/
import { paramMock } from "../utils"
import { FormInfo } from "./ohos_application_formInfo"
export function mockFormProvider() {
const FormType = {
JS: 1,
}
const ColorMode = {
MODE_AUTO : -1,
MODE_DARK : 0,
MODE_LIGHT : 1,
}
// A mock version of formInfo.
const FormInfoMock = {
bundleName: '[PC preview] unknow bundleName',
moduleName: '[PC preview] unknow moduleName',
abilityName: '[PC preview] unknow abilityName',
name: '[PC preview] unknow name',
description: '[PC preview] unknow description',
type: FormType,
jsComponentName: '[PC preview] unknow jsComponentName',
colorMode: ColorMode,
isDefault: '[PC preview] unknow isDefault',
updateEnabled: '[PC preview] unknow updateEnabled',
formVisibleNotify: '[PC preview] unknow formVisibleNotify',
relatedBundleName: '[PC preview] unknow relatedBundleName',
scheduledUpdateTime: '[PC preview] unknow scheduledUpdateTime',
formConfigAbility: '[PC preview] unknow formConfigAbility',
updateDuration: '[PC preview] unknow updateDuration',
defaultDimension: '[PC preview] unknow defaultDimension',
supportDimensions: [paramMock.paramNumberMock],
customizeData: {"key": paramMock.paramStringMock},
}
const formProvider = {
setFormNextRefreshTime: function (...args) {
console.warn('formProvider.setFormNextRefreshTime 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;
// callback
if (typeof args[len - 1] === 'function') {
args[len - 1].call(this, paramMock.businessErrorMock);
} else {
return new Promise((resolve) => {
resolve();
});
}
},
updateForm: function (...args) {
console.warn('formProvider.updateForm 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;
// callback
if (typeof args[len - 1] === 'function') {
args[len - 1].call(this, paramMock.businessErrorMock);
} else {
return new Promise((resolve) => {
resolve();
});
}
},
getFormsInfo: function (...args) {
console.warn('formProvider.getFormsInfo 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;
var array = new Array();
array.push(FormInfoMock);
array.push(FormInfo);
// promise without option.
if (len == 0) {
return new Promise((resolve) => {
@@ -0,0 +1,27 @@
/*
* 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.
*/
export function mockTestRunner() {
const TestRunner = {
onPrepare: function () {
console.warn('TestRunner.onPrepare interface mocked in the Previewer. How this interface works on the' +
' Previewer may be different from that on a real device.');
},
onRun: function () {
console.warn('TestRunner.onRun interface mocked in the Previewer. How this interface works on the' +
' Previewer may be different from that on a real device.');
},
}
return TestRunner;
}
@@ -16,7 +16,7 @@
import { paramMock } from "../utils"
export function mockBackgroundTaskManager() {
const DelaySuspendInfoMock = {
const DelaySuspendInfo = {
requestId: '[PC preview] unknown requestId',
actualDelayTime: '[PC preview] unknown actualDelayTime',
};
@@ -38,7 +38,7 @@ export function mockBackgroundTaskManager() {
const len = args.length;
if (typeof args[len - 1] === 'function') {
args[len - 1].call(this, paramMock.businessErrorMock)
return DelaySuspendInfoMock;
return DelaySuspendInfo;
}
},
cancelSuspendDelay: function (...args) {
@@ -50,10 +50,10 @@ export function mockBackgroundTaskManager() {
" Previewer may be different from that on a real device.")
const len = args.length
if (typeof args[len - 1] === 'function') {
args[len - 1].call(this, paramMock.businessErrorMock, DelaySuspendInfoMock.actualDelayTime)
args[len - 1].call(this, paramMock.businessErrorMock, DelaySuspendInfo.actualDelayTime)
} else {
return new Promise((resolve) => {
resolve(DelaySuspendInfoMock.actualDelayTime)
resolve(DelaySuspendInfo.actualDelayTime)
});
}
},
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2021 Huawei Device Co., Ltd.
* Copyright (c) 2021-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
@@ -13,39 +13,67 @@
* limitations under the License.
*/
export function mockOhosBatteryinfo() {
export function mockBatteryinfo() {
const BatteryPluggedType = {
NONE: '[PC preview] unknow NONE',
AC: '[PC preview] unknow AC',
USB: '[PC preview] unknow USB',
WIRELESS: '[PC preview] unknow WIRELESS'
NONE: 0,
AC: 1,
USB: 2,
WIRELESS: 3
}
const BatteryChargeState = {
NONE: '[PC preview] unknow NONE',
ENABLE: '[PC preview] unknow ENABLE',
DISABLE: '[PC preview] unknow DISABLE',
FULL: '[PC preview] unknow FULL'
NONE: 0,
ENABLE: 1,
DISABLE: 2,
FULL: 3
}
const BatteryHealthState = {
UNKNOWN: '[PC preview] unknow UNKNOWN',
GOOD: '[PC preview] unknow GOOD',
OVERHEAT: '[PC preview] unknow OVERHEAT',
OVERVOLTAGE: '[PC preview] unknow OVERVOLTAGE',
COLD: '[PC preview] unknow COLD',
DEAD: '[PC preview] unknow DEAD'
UNKNOWN: 0,
GOOD: 1,
OVERHEAT: 2,
OVERVOLTAGE: 3,
COLD: 4,
DEAD: 5
}
const BatteryCapacityLevel = {
LEVEL_NONE: 0,
LEVEL_FULL: 1,
LEVEL_HIGH: 2,
LEVEL_NORMAL: 3,
LEVEL_LOW: 4,
LEVEL_CRITICAL: 5
}
const CommonEventBatteryChangedCode = {
EXTRA_SOC: 0,
EXTRA_VOLTAGE: 1,
EXTRA_TEMPERATURE: 2,
EXTRA_HEALTH_STATE: 3,
EXTRA_PLUGGED_TYPE: 4,
EXTRA_MAX_CURRENT: 5,
EXTRA_MAX_VOLTAGE: 6,
EXTRA_CHARGE_STATE: 7,
EXTRA_CHARGE_COUNTER: 8,
EXTRA_PRESENT: 9,
EXTRA_TECHNOLOGY: 10,
}
const batteryInfo = {
BatteryPluggedType,
BatteryChargeState,
BatteryHealthState,
BatteryCapacityLevel,
CommonEventBatteryChangedCode,
batterySOC: "[PC Preview] unknow batterySOC",
chargingStatus: "[PC Preview] unknow chargingStatus",
healthStatus: "[PC Preview] unknow healthStatus",
pluggedType: "[PC Preview] unknow pluggedType",
chargingStatus: BatteryChargeState,
healthStatus: BatteryHealthState,
pluggedType: BatteryPluggedType,
voltage: "[PC Preview] unknow voltage",
technology: "[PC Preview] unknow technology",
batteryTemperature: "[PC Preview] unknow batteryTemperature",
isBatteryPresent: "[PC Preview] unknow isBatteryPresent"
isBatteryPresent: "[PC Preview] unknow isBatteryPresent",
batteryCapacityLevel: BatteryCapacityLevel,
estimatedRemainingChargeTime: "[PC Preview] unknow estimatedRemainingChargeTime",
totalEnergy: "[PC Preview] unknow totalEnergy",
nowCurrent: "[PC Preview] unknow nowCurrent",
remainingEnergy: "[PC Preview] unknow remainingEnergy"
}
return batteryInfo
}
@@ -29,14 +29,14 @@ export function mockBatteryStatistics() {
}
const BatteryStatsInfo = {
uid: '[PC preview] unknow uid',
type: '[PC preview] unknow type',
type: ConsumptionType,
power: '[PC preview] unknow power',
}
const batteryStatistics = {
const batteryStats = {
ConsumptionType,
BatteryStatsInfo,
getBatteryStats: function (...args) {
console.warn("batteryStatistics.getBatteryStats interface mocked in the Previewer. How this interface works on the" +
console.warn("batteryStats.getBatteryStats interface mocked in the Previewer. How this interface works on the" +
" Previewer may be different from that on a real device.")
var batteryStatsInfos = new Array(BatteryStatsInfo)
const len = args.length
@@ -49,27 +49,27 @@ export function mockBatteryStatistics() {
}
},
getAppPowerValue: function (...args) {
console.warn("batteryStatistics.getAppPowerValue interface mocked in the Previewer. How this interface works on the" +
console.warn("batteryStats.getAppPowerValue interface mocked in the Previewer. How this interface works on the" +
" Previewer may be different from that on a real device.")
return paramMock.paramNumberMock;
},
getAppPowerPercent: function (...args) {
console.warn("batteryStatistics.getAppPowerPercent interface mocked in the Previewer. How this interface works on the" +
console.warn("batteryStats.getAppPowerPercent interface mocked in the Previewer. How this interface works on the" +
" Previewer may be different from that on a real device.")
return paramMock.paramNumberMock;
},
getHardwareUnitPowerValue: function (...args) {
console.warn("batteryStatistics.getHardwareUnitPowerValue interface mocked in the Previewer. How this interface works on the" +
console.warn("batteryStats.getHardwareUnitPowerValue interface mocked in the Previewer. How this interface works on the" +
" Previewer may be different from that on a real device.")
return paramMock.paramNumberMock;
},
getHardwareUnitPowerPercent: function (...args) {
console.warn("batteryStatistics.getHardwareUnitPowerPercent interface mocked in the Previewer. How this interface works on the" +
console.warn("batteryStats.getHardwareUnitPowerPercent interface mocked in the Previewer. How this interface works on the" +
" Previewer may be different from that on a real device.")
return paramMock.paramNumberMock;
}
}
return batteryStatistics
return batteryStats
}
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2021 Huawei Device Co., Ltd.
* Copyright (c) 2021-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
@@ -17,45 +17,9 @@ import { hasComplete } from "../utils"
export function mockBrightness() {
const brightness = {
argsV: {
value: 80
},
argsM: {
mode: 0
},
getValue: function (...args) {
console.warn("brightness.getValue interface mocked in the Previewer. How this interface works on the Previewer" +
" may be different from that on a real device.")
args[0].success(this.argsV)
hasComplete(args[0].complete)
},
setValue: function (...args) {
console.warn("brightness.setValue interface mocked in the Previewer. How this interface works on the Previewer" +
" may be different from that on a real device.")
if (args[0].value) {
this.argsV.value = args[0].value
args[0].success("brightness setValue successfully")
hasComplete(args[0].complete)
}
},
getMode: function (...args) {
console.warn("brightness.getMode interface mocked in the Previewer. How this interface works on the Previewer" +
" may be different from that on a real device.")
args[0].success(this.argsM)
hasComplete(args[0].complete)
},
setMode: function (...args) {
console.warn("brightness.setMode interface mocked in the Previewer. How this interface works on the Previewer" +
" may be different from that on a real device.")
this.argsM.mode = args[0].mode
args[0].success("brightness setMode successfully")
hasComplete(args[0].complete)
},
setKeepScreenOn: function (...args) {
console.warn("brightness.setKeepScreenOn interface mocked in the Previewer. How this interface works on the" +
" Previewer may be different from that on a real device.")
args[0].success("brightness setKeepScreenOn successfully")
hasComplete(args[0].complete)
}
}
return brightness
@@ -14,99 +14,155 @@
*/
import { paramMock } from "../utils"
import {resolve} from 'path/posix'
import {BundleInfoMock, BundlePackInfo, DispatchInfoMock} from './bundle/bundleInfo'
import {ApplicationInfoMock} from './bundle/applicationInfo'
import {AbilityInfoMock} from './bundle/abilityInfo'
import {WantMock} from './bundle/applicationInfo'
import {ShortcutInfoMock} from './bundle/applicationInfo'
import {ModuleUsageRecordMock} from './bundle/applicationInfo'
import { BundleInfo, PixelMapFormat } from './bundle/bundleInfo'
import { BundlePackInfo } from './bundle/packInfo'
import { DispatchInfo } from './bundle/dispatchInfo'
import { ApplicationInfo, Want } from './bundle/applicationInfo'
import { AbilityInfo } from './bundle/abilityInfo'
import { PermissionDef } from './bundle/PermissionDef'
import { ExtensionAbilityInfo } from './bundle/extensionAbilityInfo'
export const BundleFlag = {
GET_BUNDLE_DEFAULT: 0x00000000,
GET_BUNDLE_WITH_ABILITIES: 0x00000001,
GET_ABILITY_INFO_WITH_PERMISSION: 0x00000002,
GET_ABILITY_INFO_WITH_APPLICATION: 0x00000004,
GET_APPLICATION_INFO_WITH_PERMISSION: 0x00000008,
GET_BUNDLE_WITH_REQUESTED_PERMISSION: 0x00000010,
GET_ALL_APPLICATION_INFO: 0xFFFF0000,
GET_ABILITY_INFO_WITH_METADATA: 0x00000020,
GET_BUNDLE_WITH_EXTENSION_ABILITY: 0x00000020,
GET_BUNDLE_WITH_HASH_VALUE: 0x00000030,
GET_APPLICATION_INFO_WITH_METADATA: 0x00000040,
GET_ABILITY_INFO_SYSTEMAPP_ONLY: 0x00000080,
GET_ABILITY_INFO_WITH_DISABLE: 0x00000100,
GET_APPLICATION_INFO_WITH_DISABLE: 0x00000200,
GET_APPLICATION_INFO_WITH_CERTIFICATE_FINGERPRINT: 0x00000400,
}
export const ExtensionFlag = {
GET_EXTENSION_INFO_DEFAULT: 0x00000000,
GET_EXTENSION_INFO_WITH_PERMISSION: 0x00000002,
GET_EXTENSION_INFO_WITH_APPLICATION: 0x00000004,
GET_EXTENSION_INFO_WITH_METADATA: 0x00000020,
}
export const ColorMode = {
AUTO_MODE: -1,
DARK_MODE: 0,
LIGHT_MODE: 1,
}
export const GrantStatus = {
PERMISSION_DENIED: -1,
PERMISSION_GRANTED: 0,
}
export const AbilityType = {
UNKNOWN: 0,
PAGE: 1,
SERVICE: 2,
DATA: 3,
}
export const AbilitySubType = {
UNSPECIFIED: 0,
CA: 1,
}
export const DisplayOrientation = {
UNSPECIFIED: 0,
LANDSCAPE: 0,
PORTRAIT: 1,
FOLLOW_RECENT: 2,
LANDSCAPE_INVERTED: 3,
PORTRAIT_INVERTED: 4,
AUTO_ROTATION: 5,
AUTO_ROTATION_LANDSCAPE: 6,
AUTO_ROTATION_PORTRAIT: 7,
AUTO_ROTATION_RESTRICTED: 8,
AUTO_ROTATION_LANDSCAPE_RESTRICTED: 9,
AUTO_ROTATION_PORTRAIT_RESTRICTED: 10,
LOCKED: 11,
}
export const LaunchMode = {
SINGLETON: 0,
STANDARD: 1,
}
export const ExtensionAbilityType = {
FORM: 0,
WORK_SCHEDULER: 1,
INPUT_METHOD: 2,
SERVICE: 3,
ACCESSIBILITY: 4,
DATA_SHARE: 5,
FILE_SHARE: 6,
STATIC_SUBSCRIBER: 7,
WALLPAPER: 8,
BACKUP: 9,
WINDOW: 10,
ENTERPRISE_ADMIN: 11,
UNSPECIFIED: 20,
}
export const BundleOptions = {
userId: "[PC preview] unknown userId",
}
export const InstallErrorCode = {
SUCCESS: 0,
STATUS_INSTALL_FAILURE: 1,
STATUS_INSTALL_FAILURE_ABORTED: 2,
STATUS_INSTALL_FAILURE_INVALID: 3,
STATUS_INSTALL_FAILURE_CONFLICT: 4,
STATUS_INSTALL_FAILURE_STORAGE: 5,
STATUS_INSTALL_FAILURE_INCOMPATIBLE: 6,
STATUS_UNINSTALL_FAILURE: 7,
STATUS_UNINSTALL_FAILURE_BLOCKED: 8,
STATUS_UNINSTALL_FAILURE_ABORTED: 9,
STATUS_UNINSTALL_FAILURE_CONFLICT: 10,
STATUS_INSTALL_FAILURE_DOWNLOAD_TIMEOUT: 0x0B,
STATUS_INSTALL_FAILURE_DOWNLOAD_FAILED: 0x0C,
STATUS_RECOVER_FAILURE_INVALID: 0x0D,
STATUS_ABILITY_NOT_FOUND: 0x40,
STATUS_BMS_SERVICE_ERROR: 0x41,
STATUS_FAILED_NO_SPACE_LEFT: 0x42,
STATUS_GRANT_REQUEST_PERMISSIONS_FAILED: 0x43,
STATUS_INSTALL_PERMISSION_DENIED: 0x44,
STATUS_UNINSTALL_PERMISSION_DENIED: 0x45,
}
export const UpgradeFlag = {
NOT_UPGRADE: 0,
SINGLE_UPGRADE: 1,
RELATION_UPGRADE: 2,
}
export const SupportWindowMode = {
FULL_SCREEN: 0,
SPLIT: 1,
FLOATING: 2,
}
export function mockBundle() {
const extensionAbilityType = {
FORM: 0,
WORK_SCHEDULER: 1,
INPUT_METHOD: 2,
SERVICE: 3,
ACCESSIBILITY: 4,
DATA_SHARE: 5,
FILE_SHARE: 6,
STATIC_SUBSCRIBER: 7,
WALLPAPER: 8,
BACKUP: 9,
WINDOW: 10,
UNSPECIFIED: 20,
}
const ExtensionAbilityInfoMock = [
{
bundleName: "[PC preview] unknown bundle name",
moduleName: "[PC preview] unknown module name",
name: "[PC preview] unknown name",
labelId: "[PC preview] unknown label id",
descriptionId: "[PC preview] unknown description id",
iconId: "[PC preview] unknown icon id",
isVisible: "[PC preview] unknown is visible",
extensionAbilityType: extensionAbilityType,
permissions: ["[PC preview] unknown permissions"],
applicationInfo: {
name: "[PC preview] unknown is name",
description: "[PC preview] unknown is description",
descriptionId: "[PC preview] unknown is descriptionId",
systemApp: "[PC preview] unknown is systemApp",
enabled: "[PC preview] unknown is enabled",
labelId: "[PC preview] unknown is labelId",
icon: "[PC preview] unknown is icon",
iconId: "[PC preview] unknown is iconId",
process: "[PC preview] unknown is process",
supportedModes: "[PC preview] unknown is supportedModes",
moduleSourceDirs: "[PC preview] unknown is moduleSourceDirs",
permissions: ["[PC preview] unknown is permissions"],
moduleInfos: ["[PC preview] unknown is moduleSourceDirs"],
entryDir: "[PC preview] unknown is entryDir",
metaData: [{
name: "[PC preview] unknown name",
value: "[PC preview] unknown value",
resource: "[PC preview] unknown resource",
}],
metadata: [{
name: "[PC preview] unknown name",
value: "[PC preview] unknown value",
resource: "[PC preview] unknown resource",
}],
removable: "[PC preview] unknown is removable",
accessTokenId: "[PC preview] unknown is accessTokenId",
uid: "[PC preview] unknown is uid",
entityType: "[PC preview] unknown is entityType",
fingerprint: "[PC preview] unknown is fingerprint",
},
metadata: [{
name: "[PC preview] unknown name",
value: "[PC preview] unknown value",
resource: "[PC preview] unknown resource",
}],
enabled: "[PC preview] unknown enabled",
readPermission: "[PC preview] unknown read permission",
writePermission: "[PC preview] unknown write permission",
}
]
const bundle = {
getBundleInfo: function(...args) {
console.warn("bundle.getBundleInfo interface mocked in the Previewer. How this interface works on the" +
" Previewer may be different from that on a real device.")
" Previewer may be different from that on a real device.")
const len = args.length;
if (typeof args[len - 1] === 'function') {
args[len - 1].call(this, paramMock.businessErrorMock, BundleInfoMock);
args[len - 1].call(this, paramMock.businessErrorMock, BundleInfo);
} else {
return new Promise((resolve) => {
resolve(BundleInfoMock);
resolve(BundleInfo);
})
}
},
getBundleInstaller: function(...args) {
console.warn("bundle.getBundleInstaller interface mocked in the Previewer. How this interface works on the" +
" Previewer may be different from that on a real device.")
" Previewer may be different from that on a real device.")
const len = args.length;
if (typeof args[len - 1] === 'function') {
args[len - 1].call(this, paramMock.businessErrorMock);
@@ -118,115 +174,79 @@ export function mockBundle() {
},
getApplicationInfo: function(...args) {
console.warn("bundle.getApplicationInfo interface mocked in the Previewer. How this interface works on the" +
" Previewer may be different from that on a real device.")
" Previewer may be different from that on a real device.")
const len = args.length;
if (typeof args[len - 1] === 'function') {
args[len - 1].call(this, paramMock.businessErrorMock, ApplicationInfoMock);
args[len - 1].call(this, paramMock.businessErrorMock, ApplicationInfo);
} else {
return new Promise((resolve) => {
resolve(ApplicationInfoMock);
})
}
},
checkPermission: function(...args) {
console.warn("bundle.checkPermission 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 (typeof args[len - 1] === 'function') {
args[len - 1].call(this, paramMock.businessErrorMock, paramMock.paramNumberMock);
} else {
return new Promise((resolve) => {
resolve(paramMock.paramNumberMock);
resolve(ApplicationInfo);
})
}
},
queryAbilityByWant: function(...args) {
console.warn("bundle.queryAbilityByWant interface mocked in the Previewer. How this interface works on the" +
" Previewer may be different from that on a real device.")
" Previewer may be different from that on a real device.")
const len = args.length;
if (typeof args[len - 1] === 'function') {
args[len - 1].call(this, paramMock.businessErrorMock, Array(BundleInfoMock));
args[len - 1].call(this, paramMock.businessErrorMock, Array(BundleInfo));
} else {
return new Promise((resolve) => {
resolve(Array(BundleInfoMock));
resolve(Array(BundleInfo));
})
}
},
getAllApplicationInfo: function(...args){
console.warn("bundle.getAllApplicationInfo interface mocked in the Previewer. How this interface works on the" +
" Previewer may be different from that on a real device.")
" Previewer may be different from that on a real device.")
const len = args.length;
if (typeof args[len - 1] === 'function') {
args[len - 1].call(this, paramMock.businessErrorMock, Array(BundleInfoMock));
args[len - 1].call(this, paramMock.businessErrorMock, Array(BundleInfo));
} else {
return new Promise((resolve) => {
resolve(Array(BundleInfoMock));
resolve(Array(BundleInfo));
})
}
},
getAllBundleInfo: function(...args) {
console.warn("bundle.getAllBundleInfo interface mocked in the Previewer. How this interface works on the" +
" Previewer may be different from that on a real device.")
" Previewer may be different from that on a real device.")
const len = args.length;
if (typeof args[len - 1] === 'function') {
args[len - 1].call(this, paramMock.businessErrorMock, Array(ApplicationInfoMock));
args[len - 1].call(this, paramMock.businessErrorMock, Array(ApplicationInfo));
} else {
return new Promise((resolve) => {
resolve(Array(ApplicationInfoMock));
resolve(Array(ApplicationInfo));
})
}
},
getBundleArchiveInfo: function(...args) {
console.warn("bundle.getBundleArchiveInfo interface mocked in the Previewer. How this interface works on the" +
" Previewer may be different from that on a real device.")
" Previewer may be different from that on a real device.")
const len = args.length;
if (typeof args[len - 1] === 'function') {
args[len - 1].call(this, paramMock.businessErrorMock, Array(BundleInfoMock));
args[len - 1].call(this, paramMock.businessErrorMock, Array(BundleInfo));
} else {
return new Promise((resolve) => {
resolve(Array(BundleInfoMock));
resolve(Array(BundleInfo));
})
}
},
getLaunchWantForBundle: function(...args) {
console.warn("bundle.getBundleArchiveInfo interface mocked in the Previewer. How this interface works on the" +
" Previewer may be different from that on a real device.")
" Previewer may be different from that on a real device.")
const len = args.length;
if (typeof args[len - 1] === 'function') {
args[len - 1].call(this, paramMock.businessErrorMock, Array(WantMock));
args[len - 1].call(this, paramMock.businessErrorMock, Array(Want));
} else {
return new Promise((resolve) => {
resolve(Array(WantMock));
})
}
},
getAllShortcutInfo: function(...args) {
console.warn("bundle.getAllShortcutInfo 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 (typeof args[len - 1] === 'function') {
args[len - 1].call(this, paramMock.businessErrorMock, Array(ShortcutInfoMock));
} else {
return new Promise((resolve) => {
resolve(Array(ShortcutInfoMock));
})
}
},
getModuleUsageRecords: function(...args) {
console.warn("bundle.getAllShortcutInfo 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 (typeof args[len - 1] === 'function') {
args[len - 1].call(this, paramMock.businessErrorMock, Array(ModuleUsageRecordMock));
} else {
return new Promise((resolve) => {
resolve(Array(ModuleUsageRecordMock));
resolve(Array(Want));
})
}
},
cleanBundleCacheFiles: function(...args) {
console.warn("bundle.cleanBundleCacheFiles interface mocked in the Previewer. How this interface works on the" +
" Previewer may be different from that on a real device.")
" Previewer may be different from that on a real device.")
const len = args.length;
if (typeof args[len - 1] === 'function') {
args[len - 1].call(this, paramMock.businessErrorMock);
@@ -238,7 +258,7 @@ export function mockBundle() {
},
setApplicationEnabled: function(...args) {
console.warn("bundle.setApplicationEnabled interface mocked in the Previewer. How this interface works on the" +
" Previewer may be different from that on a real device.")
" Previewer may be different from that on a real device.")
const len = args.length;
if (typeof args[len - 1] === 'function') {
args[len - 1].call(this, paramMock.businessErrorMock);
@@ -250,7 +270,7 @@ export function mockBundle() {
},
setAbilityEnabled: function(...args) {
console.warn("bundle.setAbilityEnabled interface mocked in the Previewer. How this interface works on the" +
" Previewer may be different from that on a real device.")
" Previewer may be different from that on a real device.")
const len = args.length;
if (typeof args[len - 1] === 'function') {
args[len - 1].call(this, paramMock.businessErrorMock);
@@ -262,10 +282,10 @@ export function mockBundle() {
},
setModuleUpgradeFlag: function (...args) {
console.warn("bundle.setModuleUpgradeFlag interface mocked in the Previewer. How this interface works on the" +
" Previewer may be different from that on a real device.")
" Previewer may be different from that on a real device.")
const len = args.length
if (typeof args[len - 1] === 'function') {
args[len - 1].call(this, paramMock.businessErrorMock)
args[len - 1].call(this, paramMock.businessErrorMock)
} else {
return new Promise((resolve) => {
resolve()
@@ -274,10 +294,10 @@ export function mockBundle() {
},
isModuleRemovable: function (...args) {
console.warn("bundle.isModuleRemovable interface mocked in the Previewer. How this interface works on the" +
" Previewer may be different from that on a real device.")
" Previewer may be different from that on a real device.")
const len = args.length
if (typeof args[len - 1] === 'function') {
args[len - 1].call(this, paramMock.businessErrorMock, paramMock.paramBooleanMock)
args[len - 1].call(this, paramMock.businessErrorMock, paramMock.paramBooleanMock)
} else {
return new Promise((resolve) => {
resolve(paramMock.paramBooleanMock)
@@ -286,10 +306,10 @@ export function mockBundle() {
},
getProfileByAbility: function (...args) {
console.warn("bundle.getProfileByAbility interface mocked in the Previewer. How this interface works on the" +
" Previewer may be different from that on a real device.")
" Previewer may be different from that on a real device.")
const len = args.length
if (typeof args[len - 1] === 'function') {
args[len - 1].call(this, paramMock.businessErrorMock, new Array(paramMock.paramStringMock))
args[len - 1].call(this, paramMock.businessErrorMock, new Array(paramMock.paramStringMock))
} else {
return new Promise((resolve) => {
resolve(new Array(paramMock.paramStringMock))
@@ -298,10 +318,10 @@ export function mockBundle() {
},
getProfileByExtensionAbility: function (...args) {
console.warn("bundle.getProfileByExtensionAbility interface mocked in the Previewer. How this interface works on the" +
" Previewer may be different from that on a real device.")
" Previewer may be different from that on a real device.")
const len = args.length
if (typeof args[len - 1] === 'function') {
args[len - 1].call(this, paramMock.businessErrorMock, new Array(paramMock.paramStringMock))
args[len - 1].call(this, paramMock.businessErrorMock, new Array(paramMock.paramStringMock))
} else {
return new Promise((resolve) => {
resolve(new Array(paramMock.paramStringMock))
@@ -310,19 +330,19 @@ export function mockBundle() {
},
queryExtensionAbilityInfos: function (...args) {
console.warn("bundle.queryExtensionAbilityInfos interface mocked in the Previewer. How this interface works on the" +
" Previewer may be different from that on a real device.")
" Previewer may be different from that on a real device.")
const len = args.length
if (typeof args[len - 1] === 'function') {
args[len - 1].call(this,paramMock.businessErrorMock, Array(ExtensionAbilityInfoMock))
args[len - 1].call(this,paramMock.businessErrorMock, Array(ExtensionAbilityInfo))
} else {
return new Promise((resolve) => {
resolve(Array(ExtensionAbilityInfoMock))
resolve(Array(ExtensionAbilityInfo))
});
}
},
getBundlePackInfo: function(...args) {
console.warn("bundle.getBundlePackInfo interface mocked in the Previewer. How this interface works on the" +
" Previewer may be different from that on a real device.")
" Previewer may be different from that on a real device.")
const len = args.length;
if (typeof args[len - 1] === 'function') {
args[len - 1].call(this, paramMock.businessErrorMock, BundlePackInfo);
@@ -334,22 +354,22 @@ export function mockBundle() {
},
getDispatcherVersion: function(...args) {
console.warn("bundle.getDispatcherVersion interface mocked in the Previewer. How this interface works on the" +
" Previewer may be different from that on a real device.")
" Previewer may be different from that on a real device.")
const len = args.length;
if (typeof args[len - 1] === 'function') {
args[len - 1].call(this, paramMock.businessErrorMock, DispatchInfoMock);
args[len - 1].call(this, paramMock.businessErrorMock, DispatchInfo);
} else {
return new Promise((resolve) => {
resolve(DispatchInfoMock);
resolve(DispatchInfo);
})
}
},
setDisposedStatus: function (...args) {
console.warn("bundle.setDisposedStatus interface mocked in the Previewer. How this interface works on the" +
" Previewer may be different from that on a real device.")
" Previewer may be different from that on a real device.")
const len = args.length
if (typeof args[len - 1] === 'function') {
args[len - 1].call(this, paramMock.businessErrorMock)
args[len - 1].call(this, paramMock.businessErrorMock)
} else {
return new Promise((resolve) => {
resolve()
@@ -358,16 +378,100 @@ export function mockBundle() {
},
getDisposedStatus: function (...args) {
console.warn("bundle.getDisposedStatus interface mocked in the Previewer. How this interface works on the" +
" Previewer may be different from that on a real device.")
" Previewer may be different from that on a real device.")
const len = args.length
if (typeof args[len - 1] === 'function') {
args[len - 1].call(this, paramMock.businessErrorMock, paramMock.paramNumberMock)
args[len - 1].call(this, paramMock.businessErrorMock, paramMock.paramNumberMock)
} else {
return new Promise((resolve) => {
resolve(paramMock.paramNumberMock)
});
}
},
isAbilityEnabled: function(...args) {
console.warn("bundle.isAbilityEnabled 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 (typeof args[len - 1] === 'function') {
args[len - 1].call(this, paramMock.businessErrorMock, paramMock.paramBooleanMock);
} else {
return new Promise((resolve) => {
resolve(paramMock.paramBooleanMock);
})
}
},
isApplicationEnabled: function(...args) {
console.warn("bundle.isApplicationEnabled 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 (typeof args[len - 1] === 'function') {
args[len - 1].call(this, paramMock.businessErrorMock, paramMock.paramBooleanMock);
} else {
return new Promise((resolve) => {
resolve(paramMock.paramBooleanMock);
})
}
},
getAbilityIcon: function(...args) {
console.warn("bundle.getAbilityIcon 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 (typeof args[len - 1] === 'function') {
args[len - 1].call(this, paramMock.businessErrorMock, PixelMapFormat);
} else {
return new Promise((resolve) => {
resolve(PixelMapFormat);
})
}
},
getAbilityLabel: function(...args) {
console.warn("bundle.getAbilityLabel 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 (typeof args[len - 1] === 'function') {
args[len - 1].call(this, paramMock.businessErrorMock, paramMock.paramStringMock);
} else {
return new Promise((resolve) => {
resolve(paramMock.paramStringMock);
})
}
},
getPermissionDef: function(...args) {
console.warn("bundle.getPermissionDef 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 (typeof args[len - 1] === 'function') {
args[len - 1].call(this, paramMock.businessErrorMock, PermissionDef);
} else {
return new Promise((resolve) => {
resolve(PermissionDef);
})
}
},
getNameForUid: function(...args) {
console.warn("bundle.getNameForUid 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 (typeof args[len - 1] === 'function') {
args[len - 1].call(this, paramMock.businessErrorMock, paramMock.paramStringMock);
} else {
return new Promise((resolve) => {
resolve(paramMock.paramStringMock);
})
}
},
getAbilityInfo: function(...args) {
console.warn("bundle.getAbilityInfo 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 (typeof args[len - 1] === 'function') {
args[len - 1].call(this, paramMock.businessErrorMock, AbilityInfo);
} else {
return new Promise((resolve) => {
resolve(AbilityInfo);
})
}
},
};
return bundle;
}
@@ -16,7 +16,7 @@
import { paramMock } from "../utils"
export function mockBundleState() {
const bundleStateInfomMock = [{
const BundleStateInfo = {
abilityInFgTotalTime: '[PC preview] unknown abilityInFgTotalTime',
abilityPrevAccessTime: '[PC preview] unknown abilityPrevAccessTime',
abilityPrevSeenTime: '[PC preview] unknown abilityPrevSeenTime',
@@ -32,31 +32,41 @@ export function mockBundleState() {
console.warn("bundleState.merge interface mocked in the Previewer. How this interface works on the" +
" Previewer may be different from that on a real device.");
},
}]
const bundleActiveStateMock = [{
}
const BundleStateInfoArray = [BundleStateInfo]
const BundleActiveState = {
appUsagePriorityGroup: '[PC preview] unknown appUsagePriorityGroup',
bundleName: '[PC preview] unknown bundleName',
indexOfLink: '[PC preview] unknown indexOfLink',
nameOfClass: '[PC preview] unknown nameOfClass',
stateOccurredTime: '[PC preview] unknown stateOccurredTime',
stateType: '[PC preview] unknown stateType',
}]
const bundleActiveEventStateMock = [{
}
const BundleActiveStateArray = [BundleActiveState]
const BundleActiveEventState = {
name: '[PC preview] unknown name',
eventId: '[PC preview] unknown eventId',
count: '[PC preview] unknown count',
}]
const bundleActiveInfoResponseMock = {
"key": bundleStateInfomMock
}
const BundleActiveGroupCallbackInfoMock = {
const BundleActiveEventStateArray = [BundleActiveEventState]
const BundleActiveInfoResponse = {
"key": BundleStateInfo
}
const BundleActiveGroupCallbackInfo = {
appUsageOldGroup : '[PC preview] unknown appUsageOldGroup',
appUsageNewGroup : '[PC preview] unknown appUsageNewGroup',
userId : '[PC preview] unknown userId',
changeReason : '[PC preview] unknown changeReason',
bundleName : '[PC preview] unknown bundleName',
}
const BundleActiveModuleInfoMock = {
const BundleActiveFormInfo = {
count : '[PC preview] unknown count',
formLastUsedTime : '[PC preview] unknown formLastUsedTime',
formId : '[PC preview] unknown formId',
formDimension : '[PC preview] unknown formDimension',
formName : '[PC preview] unknown formName',
}
const BundleActiveModuleInfo = {
deviceId : '[PC preview] unknown deviceId',
bundleName : '[PC preview] unknown bundleName',
moduleName : '[PC preview] unknown moduleName',
@@ -69,16 +79,16 @@ export function mockBundleState() {
abilityIconId : '[PC preview] unknown abilityIconId',
launchedCount : '[PC preview] unknown launchedCount',
lastModuleUsedTime : '[PC preview] unknown lastModuleUsedTime',
formRecords : '[PC preview] unknown formRecords',
formRecords : [BundleActiveFormInfo],
}
const intervalTypeMock = {
const IntervalType = {
BY_OPTIMIZED: 0,
BY_DAILY: 1,
BY_WEEKLY: 2,
BY_MONTHLY: 3,
BY_ANNUALLY: 4
}
const groupType = {
const GroupType = {
ACTIVE_GROUP_ALIVE : 10,
ACTIVE_GROUP_DAILY : 20,
ACTIVE_GROUP_FIXED : 30,
@@ -116,10 +126,10 @@ export function mockBundleState() {
" Previewer may be different from that on a real device.");
const len = args.length;
if (typeof args[len - 1] === 'function') {
args[len - 1].call(this, paramMock.businessErrorMock, bundleActiveInfoResponseMock);
args[len - 1].call(this, paramMock.businessErrorMock, BundleActiveInfoResponse);
} else {
return new Promise((resolve) => {
resolve(bundleActiveInfoResponseMock)
resolve(BundleActiveInfoResponse)
});
}
},
@@ -128,10 +138,10 @@ export function mockBundleState() {
" Previewer may be different from that on a real device.");
const len = args.length;
if (typeof args[len - 1] === 'function') {
args[len - 1].call(this, paramMock.businessErrorMock, bundleStateInfomMock);
args[len - 1].call(this, paramMock.businessErrorMock, BundleStateInfoArray);
} else {
return new Promise((resolve) => {
resolve(bundleStateInfomMock)
resolve(BundleStateInfoArray)
});
}
},
@@ -140,10 +150,10 @@ export function mockBundleState() {
" Previewer may be different from that on a real device.");
const len = args.length;
if (typeof args[len - 1] === 'function') {
args[len - 1].call(this, paramMock.businessErrorMock, bundleActiveStateMock);
args[len - 1].call(this, paramMock.businessErrorMock, BundleActiveStateArray);
} else {
return new Promise((resolve) => {
resolve(bundleActiveStateMock)
resolve(BundleActiveStateArray)
});
}
},
@@ -152,10 +162,10 @@ export function mockBundleState() {
" Previewer may be different from that on a real device.");
const len = args.length;
if (typeof args[len - 1] === 'function') {
args[len - 1].call(this, paramMock.businessErrorMock, bundleActiveStateMock);
args[len - 1].call(this, paramMock.businessErrorMock, BundleActiveStateArray);
} else {
return new Promise((resolve) => {
resolve(bundleActiveStateMock)
resolve(BundleActiveStateArray)
});
}
},
@@ -164,10 +174,10 @@ export function mockBundleState() {
" Previewer may be different from that on a real device.");
const len = args.length;
if (typeof args[len - 1] === 'function') {
args[len - 1].call(this, paramMock.businessErrorMock, bundleActiveEventStateMock);
args[len - 1].call(this, paramMock.businessErrorMock, BundleActiveEventStateArray);
} else {
return new Promise((resolve) => {
resolve(bundleActiveEventStateMock)
resolve(BundleActiveEventStateArray)
});
}
},
@@ -176,10 +186,10 @@ export function mockBundleState() {
" Previewer may be different from that on a real device.");
const len = args.length;
if (typeof args[len - 1] === 'function') {
args[len - 1].call(this, paramMock.businessErrorMock, bundleActiveEventStateMock);
args[len - 1].call(this, paramMock.businessErrorMock, BundleActiveEventStateArray);
} else {
return new Promise((resolve) => {
resolve(bundleActiveEventStateMock)
resolve(BundleActiveEventStateArray)
});
}
},
@@ -224,10 +234,10 @@ export function mockBundleState() {
" Previewer may be different from that on a real device.");
const len = args.length;
if (typeof args[len - 1] === 'function') {
args[len - 1].call(this, paramMock.businessErrorMock, BundleActiveModuleInfoMock);
args[len - 1].call(this, paramMock.businessErrorMock, BundleActiveModuleInfo);
} else {
return new Promise((resolve) => {
resolve(BundleActiveModuleInfoMock)
resolve(BundleActiveModuleInfo)
});
}
},
@@ -14,7 +14,18 @@
*/
import { paramMock } from "../utils"
import { BundleInfoMock } from './bundle/bundleInfo'
import { BundleInfo } from './bundle/bundleInfo'
export const ApplicationType = {
BROWSER: "BROWSER",
IMAGE: "IMAGE",
AUDIO: "AUDIO",
VIDEO: "VIDEO",
PDF: "PDF",
WORD: "WORD",
EXCEL: "EXCEL",
PPT: "PPT",
};
export function mockDefaultAppManager() {
const defaultAppManager = {
@@ -35,10 +46,10 @@ export function mockDefaultAppManager() {
" Previewer may be different from that on a real device.")
const len = args.length;
if (typeof args[len - 1] === 'function') {
args[len - 1].call(this, paramMock.businessErrorMock, BundleInfoMock);
args[len - 1].call(this, paramMock.businessErrorMock, BundleInfo);
} else {
return new Promise((resolve) => {
resolve(BundleInfoMock);
resolve(BundleInfo);
})
}
},
@@ -14,14 +14,8 @@
*/
import { paramMock } from "../utils"
import {resolve} from 'path/posix'
import {BundleInfoMock} from './bundle/bundleInfo'
import {ApplicationInfoMock} from './bundle/applicationInfo'
import {AbilityInfoMock} from './bundle/abilityInfo'
import {WantMock} from './bundle/applicationInfo'
import {ShortcutInfoMock} from './bundle/applicationInfo'
import {ModuleUsageRecordMock} from './bundle/applicationInfo'
import {LauncherAbilityInfoMock} from './bundle/launcherAbilityInfo'
import { ShortcutInfo } from './bundle/shortcutInfo'
import { LauncherAbilityInfo } from './bundle/launcherAbilityInfo'
export function mockInnerBundle() {
const innerBundleManager = {
@@ -30,10 +24,10 @@ export function mockInnerBundle() {
" Previewer may be different from that on a real device.")
const len = args.length;
if (typeof args[len - 1] === 'function') {
args[len - 1].call(this, paramMock.businessErrorMock, LauncherAbilityInfoMock);
args[len - 1].call(this, paramMock.businessErrorMock, LauncherAbilityInfo);
} else {
return new Promise((resolve) => {
resolve(LauncherAbilityInfoMock);
resolve(LauncherAbilityInfo);
})
}
},
@@ -50,10 +44,10 @@ export function mockInnerBundle() {
" Previewer may be different from that on a real device.")
const len = args.length;
if (typeof args[len - 1] === 'function') {
args[len - 1].call(this, paramMock.businessErrorMock, Array(LauncherAbilityInfoMock));
args[len - 1].call(this, paramMock.businessErrorMock, Array(LauncherAbilityInfo));
} else {
return new Promise((resolve) => {
resolve(Array(LauncherAbilityInfoMock));
resolve(Array(LauncherAbilityInfo));
})
}
},
@@ -62,10 +56,10 @@ export function mockInnerBundle() {
" Previewer may be different from that on a real device.")
const len = args.length;
if (typeof args[len - 1] === 'function') {
args[len - 1].call(this, paramMock.businessErrorMock, Array(ShortcutInfoMock));
args[len - 1].call(this, paramMock.businessErrorMock, Array(ShortcutInfo));
} else {
return new Promise((resolve) => {
resolve(Array(ShortcutInfoMock));
resolve(Array(ShortcutInfo));
})
}
},
@@ -14,156 +14,200 @@
*/
import { paramMock } from "../utils"
import { CommonEventData } from "./commonEvent/commonEventData"
import { CommonEventSubscriber } from "./commonEvent/commonEventSubscriber"
export const Support = {
COMMON_EVENT_BOOT_COMPLETED: "usual.event.BOOT_COMPLETED",
COMMON_EVENT_LOCKED_BOOT_COMPLETED: "usual.event.LOCKED_BOOT_COMPLETED",
COMMON_EVENT_SHUTDOWN: "usual.event.SHUTDOWN",
COMMON_EVENT_BATTERY_CHANGED: "usual.event.BATTERY_CHANGED",
COMMON_EVENT_BATTERY_LOW: "usual.event.BATTERY_LOW",
COMMON_EVENT_BATTERY_OKAY: "usual.event.BATTERY_OKAY",
COMMON_EVENT_POWER_CONNECTED: "usual.event.POWER_CONNECTED",
COMMON_EVENT_POWER_DISCONNECTED: "usual.event.POWER_DISCONNECTED",
COMMON_EVENT_SCREEN_OFF: "usual.event.SCREEN_OFF",
COMMON_EVENT_SCREEN_ON: "usual.event.SCREEN_ON",
COMMON_EVENT_THERMAL_LEVEL_CHANGED: "usual.event.THERMAL_LEVEL_CHANGED",
COMMON_EVENT_USER_PRESENT: "usual.event.USER_PRESENT",
COMMON_EVENT_TIME_TICK: "usual.event.TIME_TICK",
COMMON_EVENT_TIME_CHANGED: "usual.event.TIME_CHANGED",
COMMON_EVENT_DATE_CHANGED: "usual.event.DATE_CHANGED",
COMMON_EVENT_TIMEZONE_CHANGED: "usual.event.TIMEZONE_CHANGED",
COMMON_EVENT_CLOSE_SYSTEM_DIALOGS: "usual.event.CLOSE_SYSTEM_DIALOGS",
COMMON_EVENT_PACKAGE_ADDED: "usual.event.PACKAGE_ADDED",
COMMON_EVENT_PACKAGE_REPLACED: "usual.event.PACKAGE_REPLACED",
COMMON_EVENT_MY_PACKAGE_REPLACED: "usual.event.MY_PACKAGE_REPLACED",
COMMON_EVENT_PACKAGE_REMOVED: "usual.event.PACKAGE_REMOVED",
COMMON_EVENT_BUNDLE_REMOVED: "usual.event.BUNDLE_REMOVED",
COMMON_EVENT_PACKAGE_FULLY_REMOVED: "usual.event.PACKAGE_FULLY_REMOVED",
COMMON_EVENT_PACKAGE_CHANGED: "usual.event.PACKAGE_CHANGED",
COMMON_EVENT_PACKAGE_RESTARTED: "usual.event.PACKAGE_RESTARTED",
COMMON_EVENT_PACKAGE_DATA_CLEARED: "usual.event.PACKAGE_DATA_CLEARED",
COMMON_EVENT_PACKAGE_CACHE_CLEARED: "usual.event.PACKAGE_CACHE_CLEARED",
COMMON_EVENT_PACKAGES_SUSPENDED: "usual.event.PACKAGES_SUSPENDED",
COMMON_EVENT_PACKAGES_UNSUSPENDED: "usual.event.PACKAGES_UNSUSPENDED",
COMMON_EVENT_MY_PACKAGE_SUSPENDED: "usual.event.MY_PACKAGE_SUSPENDED",
COMMON_EVENT_MY_PACKAGE_UNSUSPENDED: "usual.event.MY_PACKAGE_UNSUSPENDED",
COMMON_EVENT_UID_REMOVED: "usual.event.UID_REMOVED",
COMMON_EVENT_PACKAGE_FIRST_LAUNCH: "usual.event.PACKAGE_FIRST_LAUNCH",
COMMON_EVENT_PACKAGE_NEEDS_VERIFICATION: "usual.event.PACKAGE_NEEDS_VERIFICATION",
COMMON_EVENT_PACKAGE_VERIFIED: "usual.event.PACKAGE_VERIFIED",
COMMON_EVENT_EXTERNAL_APPLICATIONS_AVAILABLE: "usual.event.EXTERNAL_APPLICATIONS_AVAILABLE",
COMMON_EVENT_EXTERNAL_APPLICATIONS_UNAVAILABLE: "usual.event.EXTERNAL_APPLICATIONS_UNAVAILABLE",
COMMON_EVENT_CONFIGURATION_CHANGED: "usual.event.CONFIGURATION_CHANGED",
COMMON_EVENT_LOCALE_CHANGED: "usual.event.LOCALE_CHANGED",
COMMON_EVENT_MANAGE_PACKAGE_STORAGE: "usual.event.MANAGE_PACKAGE_STORAGE",
COMMON_EVENT_DRIVE_MODE: "common.event.DRIVE_MODE",
COMMON_EVENT_HOME_MODE: "common.event.HOME_MODE",
COMMON_EVENT_OFFICE_MODE: "common.event.OFFICE_MODE",
COMMON_EVENT_USER_STARTED: "usual.event.USER_STARTED",
COMMON_EVENT_USER_BACKGROUND: "usual.event.USER_BACKGROUND",
COMMON_EVENT_USER_FOREGROUND: "usual.event.USER_FOREGROUND",
COMMON_EVENT_USER_SWITCHED: "usual.event.USER_SWITCHED",
COMMON_EVENT_USER_STARTING: "usual.event.USER_STARTING",
COMMON_EVENT_USER_UNLOCKED: "usual.event.USER_UNLOCKED",
COMMON_EVENT_USER_STOPPING: "usual.event.USER_STOPPING",
COMMON_EVENT_USER_STOPPED: "usual.event.USER_STOPPED",
COMMON_EVENT_HWID_LOGIN: "common.event.HWID_LOGIN",
COMMON_EVENT_HWID_LOGOUT: "common.event.HWID_LOGOUT",
COMMON_EVENT_HWID_TOKEN_INVALID: "common.event.HWID_TOKEN_INVALID",
COMMON_EVENT_HWID_LOGOFF: "common.event.HWID_LOGOFF",
COMMON_EVENT_WIFI_POWER_STATE: "usual.event.wifi.POWER_STATE",
COMMON_EVENT_WIFI_SCAN_FINISHED: "usual.event.wifi.SCAN_FINISHED",
COMMON_EVENT_WIFI_RSSI_VALUE: "usual.event.wifi.RSSI_VALUE",
COMMON_EVENT_WIFI_CONN_STATE: "usual.event.wifi.CONN_STATE",
COMMON_EVENT_WIFI_HOTSPOT_STATE: "usual.event.wifi.HOTSPOT_STATE",
COMMON_EVENT_WIFI_AP_STA_JOIN: "usual.event.wifi.WIFI_HS_STA_JOIN",
COMMON_EVENT_WIFI_AP_STA_LEAVE: "usual.event.wifi.WIFI_HS_STA_LEAVE",
COMMON_EVENT_WIFI_MPLINK_STATE_CHANGE: "usual.event.wifi.mplink.STATE_CHANGE",
COMMON_EVENT_WIFI_P2P_CONN_STATE: "usual.event.wifi.p2p.CONN_STATE_CHANGE",
COMMON_EVENT_WIFI_P2P_STATE_CHANGED: "usual.event.wifi.p2p.STATE_CHANGE",
COMMON_EVENT_WIFI_P2P_PEERS_STATE_CHANGED: "usual.event.wifi.p2p.DEVICES_CHANGE",
COMMON_EVENT_WIFI_P2P_PEERS_DISCOVERY_STATE_CHANGED: "usual.event.wifi.p2p.PEER_DISCOVERY_STATE_CHANGE",
COMMON_EVENT_WIFI_P2P_CURRENT_DEVICE_STATE_CHANGED:"usual.event.wifi.p2p.CURRENT_DEVICE_CHANGE",
COMMON_EVENT_WIFI_P2P_GROUP_STATE_CHANGED:"usual.event.wifi.p2p.GROUP_STATE_CHANGED",
COMMON_EVENT_BLUETOOTH_HANDSFREE_AG_CONNECT_STATE_UPDATE:
"usual.event.bluetooth.handsfree.ag.CONNECT_STATE_UPDATE",
COMMON_EVENT_BLUETOOTH_HANDSFREE_AG_CURRENT_DEVICE_UPDATE:
"usual.event.bluetooth.handsfree.ag.CURRENT_DEVICE_UPDATE",
COMMON_EVENT_BLUETOOTH_HANDSFREE_AG_AUDIO_STATE_UPDATE: "usual.event.bluetooth.handsfree.ag.AUDIO_STATE_UPDATE",
COMMON_EVENT_BLUETOOTH_A2DPSOURCE_CONNECT_STATE_UPDATE:"usual.event.bluetooth.a2dpsource.CONNECT_STATE_UPDATE",
COMMON_EVENT_BLUETOOTH_A2DPSOURCE_CURRENT_DEVICE_UPDATE: "usual.event.bluetooth.a2dpsource.CURRENT_DEVICE_UPDATE",
COMMON_EVENT_BLUETOOTH_A2DPSOURCE_PLAYING_STATE_UPDATE: "usual.event.bluetooth.a2dpsource.PLAYING_STATE_UPDATE",
COMMON_EVENT_BLUETOOTH_A2DPSOURCE_AVRCP_CONNECT_STATE_UPDATE:
"usual.event.bluetooth.a2dpsource.AVRCP_CONNECT_STATE_UPDATE",
COMMON_EVENT_BLUETOOTH_A2DPSOURCE_CODEC_VALUE_UPDATE: "usual.event.bluetooth.a2dpsource.CODEC_VALUE_UPDATE",
COMMON_EVENT_BLUETOOTH_REMOTEDEVICE_DISCOVERED: "usual.event.bluetooth.remotedevice.DISCOVERED",
COMMON_EVENT_BLUETOOTH_REMOTEDEVICE_CLASS_VALUE_UPDATE: "usual.event.bluetooth.remotedevice.CLASS_VALUE_UPDATE",
COMMON_EVENT_BLUETOOTH_REMOTEDEVICE_ACL_CONNECTED: "usual.event.bluetooth.remotedevice.ACL_CONNECTED",
COMMON_EVENT_BLUETOOTH_REMOTEDEVICE_ACL_DISCONNECTED: "usual.event.bluetooth.remotedevice.ACL_DISCONNECTED",
COMMON_EVENT_BLUETOOTH_REMOTEDEVICE_NAME_UPDATE:
"usual.event.bluetooth.remotedevice.NAME_UPDATE",
COMMON_EVENT_BLUETOOTH_REMOTEDEVICE_PAIR_STATE:
"usual.event.bluetooth.remotedevice.PAIR_STATE",
COMMON_EVENT_BLUETOOTH_REMOTEDEVICE_BATTERY_VALUE_UPDATE:
"usual.event.bluetooth.remotedevice.BATTERY_VALUE_UPDATE",
COMMON_EVENT_BLUETOOTH_REMOTEDEVICE_SDP_RESULT:
"usual.event.bluetooth.remotedevice.SDP_RESULT",
COMMON_EVENT_BLUETOOTH_REMOTEDEVICE_UUID_VALUE:
"usual.event.bluetooth.remotedevice.UUID_VALUE",
COMMON_EVENT_BLUETOOTH_REMOTEDEVICE_PAIRING_REQ:
"usual.event.bluetooth.remotedevice.PAIRING_REQ",
COMMON_EVENT_BLUETOOTH_REMOTEDEVICE_PAIRING_CANCEL:
"usual.event.bluetooth.remotedevice.PAIRING_CANCEL",
COMMON_EVENT_BLUETOOTH_REMOTEDEVICE_CONNECT_REQ:
"usual.event.bluetooth.remotedevice.CONNECT_REQ",
COMMON_EVENT_BLUETOOTH_REMOTEDEVICE_CONNECT_REPLY:
"usual.event.bluetooth.remotedevice.CONNECT_REPLY",
COMMON_EVENT_BLUETOOTH_REMOTEDEVICE_CONNECT_CANCEL:
"usual.event.bluetooth.remotedevice.CONNECT_CANCEL",
COMMON_EVENT_BLUETOOTH_HANDSFREEUNIT_CONNECT_STATE_UPDATE:
"usual.event.bluetooth.handsfreeunit.CONNECT_STATE_UPDATE",
COMMON_EVENT_BLUETOOTH_HANDSFREEUNIT_AUDIO_STATE_UPDATE:
"usual.event.bluetooth.handsfreeunit.AUDIO_STATE_UPDATE",
COMMON_EVENT_BLUETOOTH_HANDSFREEUNIT_AG_COMMON_EVENT:
"usual.event.bluetooth.handsfreeunit.AG_COMMON_EVENT",
COMMON_EVENT_BLUETOOTH_HANDSFREEUNIT_AG_CALL_STATE_UPDATE:
"usual.event.bluetooth.handsfreeunit.AG_CALL_STATE_UPDATE",
COMMON_EVENT_BLUETOOTH_HOST_STATE_UPDATE:
"usual.event.bluetooth.host.STATE_UPDATE",
COMMON_EVENT_BLUETOOTH_HOST_REQ_DISCOVERABLE:
"usual.event.bluetooth.host.REQ_DISCOVERABLE",
COMMON_EVENT_BLUETOOTH_HOST_REQ_ENABLE: "usual.event.bluetooth.host.REQ_ENABLE",
COMMON_EVENT_BLUETOOTH_HOST_REQ_DISABLE:
"usual.event.bluetooth.host.REQ_DISABLE",
COMMON_EVENT_BLUETOOTH_HOST_SCAN_MODE_UPDATE:
"usual.event.bluetooth.host.SCAN_MODE_UPDATE",
COMMON_EVENT_BLUETOOTH_HOST_DISCOVERY_STARTED:
"usual.event.bluetooth.host.DISCOVERY_STARTED",
COMMON_EVENT_BLUETOOTH_HOST_DISCOVERY_FINISHED:
"usual.event.bluetooth.host.DISCOVERY_FINISHED",
COMMON_EVENT_BLUETOOTH_HOST_NAME_UPDATE:
"usual.event.bluetooth.host.NAME_UPDATE",
COMMON_EVENT_BLUETOOTH_A2DPSINK_CONNECT_STATE_UPDATE:
"usual.event.bluetooth.a2dpsink.CONNECT_STATE_UPDATE",
COMMON_EVENT_BLUETOOTH_A2DPSINK_PLAYING_STATE_UPDATE:
"usual.event.bluetooth.a2dpsink.PLAYING_STATE_UPDATE",
COMMON_EVENT_BLUETOOTH_A2DPSINK_AUDIO_STATE_UPDATE:
"usual.event.bluetooth.a2dpsink.AUDIO_STATE_UPDATE",
COMMON_EVENT_NFC_ACTION_ADAPTER_STATE_CHANGED:
"usual.event.nfc.action.ADAPTER_STATE_CHANGED",
COMMON_EVENT_NFC_ACTION_RF_FIELD_ON_DETECTED:
"usual.event.nfc.action.RF_FIELD_ON_DETECTED",
COMMON_EVENT_NFC_ACTION_RF_FIELD_OFF_DETECTED:
"usual.event.nfc.action.RF_FIELD_OFF_DETECTED",
COMMON_EVENT_DISCHARGING: "usual.event.DISCHARGING",
COMMON_EVENT_CHARGING: "usual.event.CHARGING",
COMMON_EVENT_DEVICE_IDLE_MODE_CHANGED: "usual.event.DEVICE_IDLE_MODE_CHANGED",
COMMON_EVENT_POWER_SAVE_MODE_CHANGED: "usual.event.POWER_SAVE_MODE_CHANGED",
COMMON_EVENT_USER_ADDED: "usual.event.USER_ADDED",
COMMON_EVENT_USER_REMOVED: "usual.event.USER_REMOVED",
COMMON_EVENT_ABILITY_ADDED: "common.event.ABILITY_ADDED",
COMMON_EVENT_ABILITY_REMOVED: "common.event.ABILITY_REMOVED",
COMMON_EVENT_ABILITY_UPDATED: "common.event.ABILITY_UPDATED",
COMMON_EVENT_LOCATION_MODE_STATE_CHANGED:
"usual.event.location.MODE_STATE_CHANGED",
COMMON_EVENT_IVI_SLEEP: "common.event.IVI_SLEEP",
COMMON_EVENT_IVI_PAUSE: "common.event.IVI_PAUSE",
COMMON_EVENT_IVI_STANDBY: "common.event.IVI_STANDBY",
COMMON_EVENT_IVI_LASTMODE_SAVE: "common.event.IVI_LASTMODE_SAVE",
COMMON_EVENT_IVI_VOLTAGE_ABNORMAL: "common.event.IVI_VOLTAGE_ABNORMAL",
COMMON_EVENT_IVI_HIGH_TEMPERATURE: "common.event.IVI_HIGH_TEMPERATURE",
COMMON_EVENT_IVI_EXTREME_TEMPERATURE: "common.event.IVI_EXTREME_TEMPERATURE",
COMMON_EVENT_IVI_TEMPERATURE_ABNORMAL: "common.event.IVI_TEMPERATURE_ABNORMAL",
COMMON_EVENT_IVI_VOLTAGE_RECOVERY: "common.event.IVI_VOLTAGE_RECOVERY",
COMMON_EVENT_IVI_TEMPERATURE_RECOVERY: "common.event.IVI_TEMPERATURE_RECOVERY",
COMMON_EVENT_IVI_ACTIVE: "common.event.IVI_ACTIVE",
COMMON_EVENT_USB_DEVICE_ATTACHED:
"usual.event.hardware.usb.action.USB_DEVICE_ATTACHED",
COMMON_EVENT_USB_DEVICE_DETACHED:
"usual.event.hardware.usb.action.USB_DEVICE_DETACHED",
COMMON_EVENT_USB_ACCESSORY_ATTACHED:
"usual.event.hardware.usb.action.USB_ACCESSORY_ATTACHED",
COMMON_EVENT_USB_ACCESSORY_DETACHED:
"usual.event.hardware.usb.action.USB_ACCESSORY_DETACHED",
COMMON_EVENT_DISK_REMOVED: "usual.event.data.DISK_REMOVED",
COMMON_EVENT_DISK_UNMOUNTED: "usual.event.data.DISK_UNMOUNTED",
COMMON_EVENT_DISK_MOUNTED: "usual.event.data.DISK_MOUNTED",
COMMON_EVENT_DISK_BAD_REMOVAL: "usual.event.data.DISK_BAD_REMOVAL",
COMMON_EVENT_DISK_UNMOUNTABLE: "usual.event.data.DISK_UNMOUNTABLE",
COMMON_EVENT_DISK_EJECT: "usual.event.data.DISK_EJECT",
COMMON_EVENT_VOLUME_REMOVED: "usual.event.data.VOLUME_REMOVED",
COMMON_EVENT_VOLUME_UNMOUNTED: "usual.event.data.VOLUME_UNMOUNTED",
COMMON_EVENT_VOLUME_MOUNTED: "usual.event.data.VOLUME_MOUNTED",
COMMON_EVENT_VOLUME_BAD_REMOVAL: "usual.event.data.VOLUME_BAD_REMOVAL",
COMMON_EVENT_VOLUME_EJECT: "usual.event.data.VOLUME_EJECT",
COMMON_EVENT_VISIBLE_ACCOUNTS_UPDATED:
"usual.event.data.VISIBLE_ACCOUNTS_UPDATED",
COMMON_EVENT_ACCOUNT_DELETED: "usual.event.data.ACCOUNT_DELETED",
COMMON_EVENT_FOUNDATION_READY: "common.event.FOUNDATION_READY",
COMMON_EVENT_AIRPLANE_MODE_CHANGED: "usual.event.AIRPLANE_MODE",
COMMON_EVENT_SPLIT_SCREEN: "common.event.SPLIT_SCREEN",
COMMON_EVENT_SLOT_CHANGE: "usual.event.SLOT_CHANGE",
COMMON_EVENT_SPN_INFO_CHANGED: "usual.event.SPN_INFO_CHANGED"
}
export function mockCommonEvent() {
const CommonEventDataMock = {
event: '[PC preview] unknow event',
bundleName: '[PC preview] unknow bundleName',
code: '[PC preview] unknow code',
data: '[PC preview] unknow data',
parameters: {}
}
const CommonEventSubscribeInfoMock = {
events: [paramMock.paramStringMock],
publisherPermission: '[PC preview] unknow publisherPermission',
publisherDeviceId: '[PC preview] unknow publisherDeviceId',
userId: '[PC preview] unknow userId',
priority: '[PC preview] unknow priority'
}
const CommonEventSubscriberMock = {
getCode: function (...args) {
console.warn('CommonEventSubscriber.getCode 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 (typeof args[len - 1] === 'function') {
args[len - 1].call(this, paramMock.businessErrorMock, paramMock.paramNumberMock);
} else {
return new Promise((resolve) => {
resolve(paramMock.paramNumberMock);
});
}
},
setCode: function (...args) {
console.warn('CommonEventSubscriber.setCode 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 (typeof args[len - 1] === 'function') {
args[len - 1].call(this, paramMock.businessErrorMock);
} else {
return new Promise((resolve) => {
resolve();
});
}
},
getData: function (...args) {
console.warn('CommonEventSubscriber.getData 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 (typeof args[len - 1] === 'function') {
args[len - 1].call(this, paramMock.businessErrorMock, paramMock.paramStringMock);
} else {
return new Promise((resolve) => {
resolve(paramMock.paramStringMock);
});
}
},
setData: function (...args) {
console.warn('CommonEventSubscriber.setData 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 (typeof args[len - 1] === 'function') {
args[len - 1].call(this, paramMock.businessErrorMock);
} else {
return new Promise((resolve) => {
resolve();
});
}
},
setCodeAndData: function (...args) {
console.warn('CommonEventSubscriber.setCodeAndData 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 (typeof args[len - 1] === 'function') {
args[len - 1].call(this, paramMock.businessErrorMock);
} else {
return new Promise((resolve) => {
resolve();
});
}
},
isOrderedCommonEvent: function (...args) {
console.warn('CommonEventSubscriber.isOrderedCommonEvent 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 (typeof args[len - 1] === 'function') {
args[len - 1].call(this, paramMock.businessErrorMock, paramMock.paramBooleanMock);
} else {
return new Promise((resolve) => {
resolve(paramMock.paramBooleanMock);
});
}
},
isStickyCommonEvent: function (...args) {
console.warn('CommonEventSubscriber.isStickyCommonEvent 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 (typeof args[len - 1] === 'function') {
args[len - 1].call(this, paramMock.businessErrorMock, paramMock.paramBooleanMock);
} else {
return new Promise((resolve) => {
resolve(paramMock.paramBooleanMock);
});
}
},
abortCommonEvent: function (...args) {
console.warn('CommonEventSubscriber.abortCommonEvent 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 (typeof args[len - 1] === 'function') {
args[len - 1].call(this, paramMock.businessErrorMock);
} else {
return new Promise((resolve) => {
resolve();
});
}
},
clearAbortCommonEvent: function (...args) {
console.warn('CommonEventSubscriber.clearAbortCommonEvent 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 (typeof args[len - 1] === 'function') {
args[len - 1].call(this, paramMock.businessErrorMock);
} else {
return new Promise((resolve) => {
resolve();
});
}
},
getAbortCommonEvent: function (...args) {
console.warn('CommonEventSubscriber.getAbortCommonEvent 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 (typeof args[len - 1] === 'function') {
args[len - 1].call(this, paramMock.businessErrorMock, paramMock.paramBooleanMock);
} else {
return new Promise((resolve) => {
resolve(paramMock.paramBooleanMock);
});
}
},
getSubscribeInfo: function (...args) {
console.warn('CommonEventSubscriber.getSubscribeInfo 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 (typeof args[len - 1] === 'function') {
args[len - 1].call(this, paramMock.businessErrorMock, CommonEventSubscribeInfoMock);
} else {
return new Promise((resolve) => {
resolve(CommonEventSubscribeInfoMock);
});
}
},
}
const commonEvent = {
publish: function (...args) {
console.warn('commonEvent.publish interface mocked in the Previewer. How this interface works on the' +
@@ -186,10 +230,10 @@ export function mockCommonEvent() {
' Previewer may be different from that on a real device.');
const len = args.length;
if (typeof args[len - 1] === 'function') {
args[len - 1].call(this, paramMock.businessErrorMock, CommonEventSubscriberMock);
args[len - 1].call(this, paramMock.businessErrorMock, CommonEventSubscriber);
} else {
return new Promise((resolve) => {
resolve(CommonEventSubscriberMock);
resolve(CommonEventSubscriber);
});
}
},
@@ -198,7 +242,7 @@ export function mockCommonEvent() {
' Previewer may be different from that on a real device.');
const len = args.length;
if (typeof args[len - 1] === 'function') {
args[len - 1].call(this, paramMock.businessErrorMock, CommonEventDataMock);
args[len - 1].call(this, paramMock.businessErrorMock, CommonEventData);
}
},
unsubscribe: function (...args) {
@@ -0,0 +1,118 @@
/*
* 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 mockContinationManager() {
const ContinuationExtraParams = {
deviceType: [paramMock.paramStringMock],
targetBundle: '[PC preview] unknown targetBundle',
description: '[PC preview] unknown description',
filter: '[PC preview] unknown filter',
continuationMode: continuationManager.ContinuationMode,
authInfo: '[PC preview] unknown authInfo'
}
const ContinuationResult = {
id: '[PC preview] unknown id',
type: '[PC preview] unknown type',
name: '[PC preview] unknown name'
}
const continuationManager = {
DeviceConnectState: {
IDLE: 0,
CONNECTING: 1,
CONNECTED: 2,
DISCONNECTING: 3
},
ContinuationMode: {
COLLABORATION_SINGLE: 0,
COLLABORATION_MULTIPLE: 1
},
on: function (...args) {
console.warn("continuationManager.on 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 (typeof args[len - 1] === 'function') {
if (args[0] == 'deviceConnect') {
args[len - 1].call(this, new Array(ContinuationResult));
} else if (args[0] == 'deviceDisconnect') {
args[len - 1].call(this, new Array(paramMock.paramStringMock));
}
}
},
off: function (...args) {
console.warn("continuationManager.off interface mocked in the Previewer. How this interface works on the Previewer may" +
" be different from that on a real device.")
},
register: function (...args) {
console.warn("continuationManager.register 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 (typeof args[len - 1] === 'function') {
args[len - 1].call(this, paramMock.businessErrorMock, paramMock.paramNumberMock);
} else {
return new Promise((resolve) => {
resolve(paramMock.paramNumberMock);
});
}
},
unregister: function (...args) {
console.warn("continuationManager.unregister 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 (typeof args[len - 1] === 'function') {
args[len - 1].call(this, paramMock.businessErrorMock);
} else {
return new Promise((resolve) => {
resolve();
});
}
},
updateConnectStatus: function (...args) {
console.warn("continuationManager.updateConnectStatus 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 (typeof args[len - 1] === 'function') {
args[len - 1].call(this, paramMock.businessErrorMock);
} else {
return new Promise((resolve) => {
resolve();
});
}
},
startDeviceManager: function (...args) {
console.warn("continuationManager.startDeviceManager 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 (typeof args[len - 1] === 'function') {
args[len - 1].call(this, paramMock.businessErrorMock);
} else {
return new Promise((resolve) => {
resolve();
});
}
},
}
return continuationManager
}
@@ -15,15 +15,18 @@
import {paramMock} from "../utils"
export const DataType = {
TYPE_NULL: 0,
TYPE_LONG: 1,
TYPE_DOUBLE: 2,
TYPE_STRING: 3,
TYPE_BLOB: 4
};
export const DataShareResultSetMock = {
columnNames: "[PC Preview] unknow columnNames",
columnCount: "[PC Preview] unknow columnCount",
rowCount: "[PC Preview] unknow rowCount",
rowIndex: "[PC Preview] unknow rowIndex",
goToFirstRow: "[PC Preview] unknow goToFirstRow",
goToLastRow: "[PC Preview] unknow goToLastRow",
goToNextRow: "[PC Preview] unknow goToNextRow",
goToPreviousRow: "[PC Preview] unknow goToPreviousRow",
isEnded: "[PC Preview] unknow isEnded",
isStarted: "[PC Preview] unknow isStarted",
isClosed: "[PC Preview] unknow isClosed",
@@ -98,7 +101,7 @@ export const DataShareResultSetMock = {
return paramMock.paramNumberMock;
},
close: function () {
console.warn("ResultSet.isColumnNull interface mocked in the Previewer. How this interface works on the Previewer" +
console.warn("ResultSet.close interface mocked in the Previewer. How this interface works on the Previewer" +
" may be different from that on a real device.")
}
}
@@ -15,6 +15,15 @@
import { paramMock } from "../utils"
const ValueTypes = '[PC Preview] unknow value type'
const StorageObserver = {
key: '[PC Preview] unknown key'
};
const MAX_KEY_LENGTH = 80;
const MAX_VALUE_LENGTH = 8192;
export function mockDataStorage() {
const storage = {
storageMock,
@@ -72,17 +81,17 @@ export function mockDataStorage() {
getSync: function () {
console.warn("Storage.getSync interface mocked in the Previewer. How this interface works on the Previewer may" +
" be different from that on a real device.")
return paramValueTypeMock
return ValueTypes
},
get: function (...args) {
console.warn("Storage.get 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 (typeof args[len - 1] === 'function') {
args[len - 1].call(this, paramMock.businessErrorMock, paramValueTypeMock)
args[len - 1].call(this, paramMock.businessErrorMock, ValueTypes)
} else {
return new Promise((resolve) => {
resolve(paramValueTypeMock)
resolve(ValueTypes)
})
}
},
@@ -171,13 +180,13 @@ export function mockDataStorage() {
console.warn("Storage.on 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
args[len - 1].call(this, storageObserverMock)
args[len - 1].call(this, StorageObserver)
},
off: function (...args) {
console.warn("Storage.off 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
args[len - 1].call(this, storageObserverMock)
args[len - 1].call(this, storageObserver)
}
}
return storage

Some files were not shown because too many files have changed in this diff Show More