diff --git a/BUILD.gn b/BUILD.gn index 7dc25231..e39ecde3 100644 --- a/BUILD.gn +++ b/BUILD.gn @@ -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" diff --git a/build.js b/build.js index 73d4e330..25a59fad 100644 --- a/build.js +++ b/build.js @@ -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 => { diff --git a/runtime/main/extend/systemplugin/ability.js b/runtime/main/extend/systemplugin/ability.js index e69545de..64ecc6d8 100644 --- a/runtime/main/extend/systemplugin/ability.js +++ b/runtime/main/extend/systemplugin/ability.js @@ -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) { diff --git a/runtime/main/extend/systemplugin/brightness.js b/runtime/main/extend/systemplugin/brightness.js new file mode 100755 index 00000000..d8bf446b --- /dev/null +++ b/runtime/main/extend/systemplugin/brightness.js @@ -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) + } + } +} diff --git a/runtime/main/extend/systemplugin/index.js b/runtime/main/extend/systemplugin/index.js index 30c51278..50d08416 100644 --- a/runtime/main/extend/systemplugin/index.js +++ b/runtime/main/extend/systemplugin/index.js @@ -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() diff --git a/runtime/main/extend/systemplugin/napi/@internal/ets/lifecycle.js b/runtime/main/extend/systemplugin/napi/@internal/ets/lifecycle.js new file mode 100644 index 00000000..ae8cf1c1 --- /dev/null +++ b/runtime/main/extend/systemplugin/napi/@internal/ets/lifecycle.js @@ -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); + } + }, +} \ No newline at end of file diff --git a/runtime/main/extend/systemplugin/napi/ability/abilityResult.js b/runtime/main/extend/systemplugin/napi/ability/abilityResult.js new file mode 100644 index 00000000..ce560932 --- /dev/null +++ b/runtime/main/extend/systemplugin/napi/ability/abilityResult.js @@ -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(), +} \ No newline at end of file diff --git a/runtime/main/extend/systemplugin/napi/ability/connectOptions.js b/runtime/main/extend/systemplugin/napi/ability/connectOptions.js new file mode 100644 index 00000000..b07a5d9a --- /dev/null +++ b/runtime/main/extend/systemplugin/napi/ability/connectOptions.js @@ -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.") + }, +} \ No newline at end of file diff --git a/runtime/main/extend/systemplugin/napi/ability/startAbilityParameter.js b/runtime/main/extend/systemplugin/napi/ability/startAbilityParameter.js new file mode 100644 index 00000000..626ad3ac --- /dev/null +++ b/runtime/main/extend/systemplugin/napi/ability/startAbilityParameter.js @@ -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: {}, +} \ No newline at end of file diff --git a/runtime/main/extend/systemplugin/napi/ability/want.js b/runtime/main/extend/systemplugin/napi/ability/want.js new file mode 100644 index 00000000..57e17e11 --- /dev/null +++ b/runtime/main/extend/systemplugin/napi/ability/want.js @@ -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] +} \ No newline at end of file diff --git a/runtime/main/extend/systemplugin/napi/app/appVersionInfo.js b/runtime/main/extend/systemplugin/napi/app/appVersionInfo.js new file mode 100644 index 00000000..b482c73b --- /dev/null +++ b/runtime/main/extend/systemplugin/napi/app/appVersionInfo.js @@ -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", +} \ No newline at end of file diff --git a/runtime/main/extend/systemplugin/napi/app/context.js b/runtime/main/extend/systemplugin/napi/app/context.js new file mode 100644 index 00000000..a6c2338f --- /dev/null +++ b/runtime/main/extend/systemplugin/napi/app/context.js @@ -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", +} \ No newline at end of file diff --git a/runtime/main/extend/systemplugin/napi/app/processInfo.js b/runtime/main/extend/systemplugin/napi/app/processInfo.js new file mode 100644 index 00000000..0fcda95b --- /dev/null +++ b/runtime/main/extend/systemplugin/napi/app/processInfo.js @@ -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", +} \ No newline at end of file diff --git a/runtime/main/extend/systemplugin/napi/application/abilityContext.js b/runtime/main/extend/systemplugin/napi/application/AbilityContext.js similarity index 82% rename from runtime/main/extend/systemplugin/napi/application/abilityContext.js rename to runtime/main/extend/systemplugin/napi/application/AbilityContext.js index d8ca6563..1b7a9305 100644 --- a/runtime/main/extend/systemplugin/napi/application/abilityContext.js +++ b/runtime/main/extend/systemplugin/napi/application/AbilityContext.js @@ -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.") diff --git a/runtime/main/extend/systemplugin/napi/application/BaseContext.js b/runtime/main/extend/systemplugin/napi/application/BaseContext.js new file mode 100644 index 00000000..7d8b0e82 --- /dev/null +++ b/runtime/main/extend/systemplugin/napi/application/BaseContext.js @@ -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", +} \ No newline at end of file diff --git a/runtime/main/extend/systemplugin/napi/application/Context.js b/runtime/main/extend/systemplugin/napi/application/Context.js new file mode 100644 index 00000000..bc9339ef --- /dev/null +++ b/runtime/main/extend/systemplugin/napi/application/Context.js @@ -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 +} \ No newline at end of file diff --git a/runtime/main/extend/systemplugin/napi/application/FormExtensionContext.js b/runtime/main/extend/systemplugin/napi/application/FormExtensionContext.js new file mode 100644 index 00000000..7dc55b19 --- /dev/null +++ b/runtime/main/extend/systemplugin/napi/application/FormExtensionContext.js @@ -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(); + }) + } + }; + } +} \ No newline at end of file diff --git a/runtime/main/extend/systemplugin/napi/application/abilityDelegator.js b/runtime/main/extend/systemplugin/napi/application/abilityDelegator.js new file mode 100644 index 00000000..fb5d7fa1 --- /dev/null +++ b/runtime/main/extend/systemplugin/napi/application/abilityDelegator.js @@ -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(); + }) + } + } +} \ No newline at end of file diff --git a/runtime/main/extend/systemplugin/napi/application/abilityDelegatorArgs.js b/runtime/main/extend/systemplugin/napi/application/abilityDelegatorArgs.js new file mode 100644 index 00000000..104b0367 --- /dev/null +++ b/runtime/main/extend/systemplugin/napi/application/abilityDelegatorArgs.js @@ -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", +} \ No newline at end of file diff --git a/runtime/main/extend/systemplugin/napi/application/abilityMonitor.js b/runtime/main/extend/systemplugin/napi/application/abilityMonitor.js new file mode 100644 index 00000000..22195d2b --- /dev/null +++ b/runtime/main/extend/systemplugin/napi/application/abilityMonitor.js @@ -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.") + }, +} \ No newline at end of file diff --git a/runtime/main/extend/systemplugin/napi/application/shellCmdResult.js b/runtime/main/extend/systemplugin/napi/application/shellCmdResult.js new file mode 100644 index 00000000..920d25dd --- /dev/null +++ b/runtime/main/extend/systemplugin/napi/application/shellCmdResult.js @@ -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", +} \ No newline at end of file diff --git a/runtime/main/extend/systemplugin/napi/bundle/PermissionDef.js b/runtime/main/extend/systemplugin/napi/bundle/PermissionDef.js new file mode 100755 index 00000000..3caaf73d --- /dev/null +++ b/runtime/main/extend/systemplugin/napi/bundle/PermissionDef.js @@ -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", +} \ No newline at end of file diff --git a/runtime/main/extend/systemplugin/napi/bundle/abilityInfo.js b/runtime/main/extend/systemplugin/napi/bundle/abilityInfo.js index 99300e9b..3a0bbf33 100644 --- a/runtime/main/extend/systemplugin/napi/bundle/abilityInfo.js +++ b/runtime/main/extend/systemplugin/napi/bundle/abilityInfo.js @@ -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", } \ No newline at end of file diff --git a/runtime/main/extend/systemplugin/napi/bundle/applicationInfo.js b/runtime/main/extend/systemplugin/napi/bundle/applicationInfo.js index 05b117fd..a2b65f88 100644 --- a/runtime/main/extend/systemplugin/napi/bundle/applicationInfo.js +++ b/runtime/main/extend/systemplugin/napi/bundle/applicationInfo.js @@ -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", } \ No newline at end of file diff --git a/runtime/main/extend/systemplugin/napi/bundle/bundleInfo.js b/runtime/main/extend/systemplugin/napi/bundle/bundleInfo.js index aa6120e6..68793e40 100644 --- a/runtime/main/extend/systemplugin/napi/bundle/bundleInfo.js +++ b/runtime/main/extend/systemplugin/napi/bundle/bundleInfo.js @@ -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, } \ No newline at end of file diff --git a/runtime/main/extend/systemplugin/napi/bundle/bundleInstaller.js b/runtime/main/extend/systemplugin/napi/bundle/bundleInstaller.js new file mode 100755 index 00000000..d0c85129 --- /dev/null +++ b/runtime/main/extend/systemplugin/napi/bundle/bundleInstaller.js @@ -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; +} \ No newline at end of file diff --git a/runtime/main/extend/systemplugin/napi/bundle/bundleStatusCallback.js b/runtime/main/extend/systemplugin/napi/bundle/bundleStatusCallback.js new file mode 100755 index 00000000..2215a05f --- /dev/null +++ b/runtime/main/extend/systemplugin/napi/bundle/bundleStatusCallback.js @@ -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; +} \ No newline at end of file diff --git a/runtime/main/extend/systemplugin/napi/bundle/customizeData.js b/runtime/main/extend/systemplugin/napi/bundle/customizeData.js new file mode 100755 index 00000000..dce34591 --- /dev/null +++ b/runtime/main/extend/systemplugin/napi/bundle/customizeData.js @@ -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", +} \ No newline at end of file diff --git a/runtime/main/extend/systemplugin/napi/bundle/defaultAppManager.js b/runtime/main/extend/systemplugin/napi/bundle/defaultAppManager.js index 0e47ba4b..f66db7aa 100755 --- a/runtime/main/extend/systemplugin/napi/bundle/defaultAppManager.js +++ b/runtime/main/extend/systemplugin/napi/bundle/defaultAppManager.js @@ -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", diff --git a/runtime/main/extend/systemplugin/napi/bundle/dispatchInfo.js b/runtime/main/extend/systemplugin/napi/bundle/dispatchInfo.js new file mode 100755 index 00000000..36c5110d --- /dev/null +++ b/runtime/main/extend/systemplugin/napi/bundle/dispatchInfo.js @@ -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", +} \ No newline at end of file diff --git a/runtime/main/extend/systemplugin/napi/bundle/elementName.js b/runtime/main/extend/systemplugin/napi/bundle/elementName.js new file mode 100755 index 00000000..ffa0992a --- /dev/null +++ b/runtime/main/extend/systemplugin/napi/bundle/elementName.js @@ -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", +} \ No newline at end of file diff --git a/runtime/main/extend/systemplugin/napi/bundle/extensionAbilityInfo.js b/runtime/main/extend/systemplugin/napi/bundle/extensionAbilityInfo.js new file mode 100755 index 00000000..ebbb9f78 --- /dev/null +++ b/runtime/main/extend/systemplugin/napi/bundle/extensionAbilityInfo.js @@ -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", +} \ No newline at end of file diff --git a/runtime/main/extend/systemplugin/napi/bundle/hapModuleInfo.js b/runtime/main/extend/systemplugin/napi/bundle/hapModuleInfo.js new file mode 100755 index 00000000..d137641f --- /dev/null +++ b/runtime/main/extend/systemplugin/napi/bundle/hapModuleInfo.js @@ -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], +} \ No newline at end of file diff --git a/runtime/main/extend/systemplugin/napi/bundle/launcherAbilityInfo.js b/runtime/main/extend/systemplugin/napi/bundle/launcherAbilityInfo.js index 53fb1653..830d0533 100644 --- a/runtime/main/extend/systemplugin/napi/bundle/launcherAbilityInfo.js +++ b/runtime/main/extend/systemplugin/napi/bundle/launcherAbilityInfo.js @@ -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", diff --git a/runtime/main/extend/systemplugin/napi/bundle/metadata.js b/runtime/main/extend/systemplugin/napi/bundle/metadata.js new file mode 100755 index 00000000..6157307c --- /dev/null +++ b/runtime/main/extend/systemplugin/napi/bundle/metadata.js @@ -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", +} \ No newline at end of file diff --git a/runtime/main/extend/systemplugin/napi/bundle/moduleInfo.js b/runtime/main/extend/systemplugin/napi/bundle/moduleInfo.js new file mode 100755 index 00000000..4b0193f6 --- /dev/null +++ b/runtime/main/extend/systemplugin/napi/bundle/moduleInfo.js @@ -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", +} \ No newline at end of file diff --git a/runtime/main/extend/systemplugin/napi/bundle/packInfo.js b/runtime/main/extend/systemplugin/napi/bundle/packInfo.js new file mode 100755 index 00000000..fd6e7dc8 --- /dev/null +++ b/runtime/main/extend/systemplugin/napi/bundle/packInfo.js @@ -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 +} \ No newline at end of file diff --git a/runtime/main/extend/systemplugin/napi/bundle/remoteAbilityInfo.js b/runtime/main/extend/systemplugin/napi/bundle/remoteAbilityInfo.js new file mode 100755 index 00000000..ab31d377 --- /dev/null +++ b/runtime/main/extend/systemplugin/napi/bundle/remoteAbilityInfo.js @@ -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", +} \ No newline at end of file diff --git a/runtime/main/extend/systemplugin/napi/bundle/shortcutInfo.js b/runtime/main/extend/systemplugin/napi/bundle/shortcutInfo.js new file mode 100755 index 00000000..e90805ca --- /dev/null +++ b/runtime/main/extend/systemplugin/napi/bundle/shortcutInfo.js @@ -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", +} \ No newline at end of file diff --git a/runtime/main/extend/systemplugin/napi/common/full/featureability.js b/runtime/main/extend/systemplugin/napi/common/full/featureability.js new file mode 100644 index 00000000..084bf211 --- /dev/null +++ b/runtime/main/extend/systemplugin/napi/common/full/featureability.js @@ -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.") + }; + } +} \ No newline at end of file diff --git a/runtime/main/extend/systemplugin/napi/commonEvent/commonEventData.js b/runtime/main/extend/systemplugin/napi/commonEvent/commonEventData.js new file mode 100644 index 00000000..83ee21a6 --- /dev/null +++ b/runtime/main/extend/systemplugin/napi/commonEvent/commonEventData.js @@ -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: {} +} \ No newline at end of file diff --git a/runtime/main/extend/systemplugin/napi/commonEvent/commonEventPublishData.js b/runtime/main/extend/systemplugin/napi/commonEvent/commonEventPublishData.js new file mode 100644 index 00000000..9174974b --- /dev/null +++ b/runtime/main/extend/systemplugin/napi/commonEvent/commonEventPublishData.js @@ -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: {} +} \ No newline at end of file diff --git a/runtime/main/extend/systemplugin/napi/commonEvent/commonEventSubscribeInfo.js b/runtime/main/extend/systemplugin/napi/commonEvent/commonEventSubscribeInfo.js new file mode 100644 index 00000000..d2cc1633 --- /dev/null +++ b/runtime/main/extend/systemplugin/napi/commonEvent/commonEventSubscribeInfo.js @@ -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' +} \ No newline at end of file diff --git a/runtime/main/extend/systemplugin/napi/commonEvent/commonEventSubscriber.js b/runtime/main/extend/systemplugin/napi/commonEvent/commonEventSubscriber.js new file mode 100644 index 00000000..0f478d53 --- /dev/null +++ b/runtime/main/extend/systemplugin/napi/commonEvent/commonEventSubscriber.js @@ -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(); + }); + } + }, +} \ No newline at end of file diff --git a/runtime/main/extend/systemplugin/napi/continuation/continuationExtraParams.js b/runtime/main/extend/systemplugin/napi/continuation/continuationExtraParams.js new file mode 100644 index 00000000..7d494bf6 --- /dev/null +++ b/runtime/main/extend/systemplugin/napi/continuation/continuationExtraParams.js @@ -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: {} +} \ No newline at end of file diff --git a/runtime/main/extend/systemplugin/napi/continuation/continuationResult.js b/runtime/main/extend/systemplugin/napi/continuation/continuationResult.js new file mode 100644 index 00000000..1d8521f2 --- /dev/null +++ b/runtime/main/extend/systemplugin/napi/continuation/continuationResult.js @@ -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", +} \ No newline at end of file diff --git a/runtime/main/extend/systemplugin/napi/data/rdb/resultSet.js b/runtime/main/extend/systemplugin/napi/data/rdb/resultSet.js new file mode 100644 index 00000000..25a16440 --- /dev/null +++ b/runtime/main/extend/systemplugin/napi/data/rdb/resultSet.js @@ -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.") + }, +} diff --git a/runtime/main/extend/systemplugin/napi/global/rawFileDescriptor.js b/runtime/main/extend/systemplugin/napi/global/rawFileDescriptor.js new file mode 100644 index 00000000..ef263de1 --- /dev/null +++ b/runtime/main/extend/systemplugin/napi/global/rawFileDescriptor.js @@ -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' +} \ No newline at end of file diff --git a/runtime/main/extend/systemplugin/napi/global/resource.js b/runtime/main/extend/systemplugin/napi/global/resource.js new file mode 100644 index 00000000..8d2d8906 --- /dev/null +++ b/runtime/main/extend/systemplugin/napi/global/resource.js @@ -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' +} \ No newline at end of file diff --git a/runtime/main/extend/systemplugin/napi/index.js b/runtime/main/extend/systemplugin/napi/index.js index 9ac62d9a..7ee16d79 100644 --- a/runtime/main/extend/systemplugin/napi/index.js +++ b/runtime/main/extend/systemplugin/napi/index.js @@ -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); } diff --git a/runtime/main/extend/systemplugin/napi/notification/notificationActionButton.js b/runtime/main/extend/systemplugin/napi/notification/notificationActionButton.js new file mode 100644 index 00000000..f78f5a58 --- /dev/null +++ b/runtime/main/extend/systemplugin/napi/notification/notificationActionButton.js @@ -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, +} \ No newline at end of file diff --git a/runtime/main/extend/systemplugin/napi/notification/notificationContent.js b/runtime/main/extend/systemplugin/napi/notification/notificationContent.js new file mode 100644 index 00000000..25da4a05 --- /dev/null +++ b/runtime/main/extend/systemplugin/napi/notification/notificationContent.js @@ -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, +} \ No newline at end of file diff --git a/runtime/main/extend/systemplugin/napi/notification/notificationFlags.js b/runtime/main/extend/systemplugin/napi/notification/notificationFlags.js new file mode 100644 index 00000000..44942bd3 --- /dev/null +++ b/runtime/main/extend/systemplugin/napi/notification/notificationFlags.js @@ -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, +} \ No newline at end of file diff --git a/runtime/main/extend/systemplugin/napi/notification/notificationRequest.js b/runtime/main/extend/systemplugin/napi/notification/notificationRequest.js new file mode 100644 index 00000000..ccb0bb7b --- /dev/null +++ b/runtime/main/extend/systemplugin/napi/notification/notificationRequest.js @@ -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', +} \ No newline at end of file diff --git a/runtime/main/extend/systemplugin/napi/notification/notificationSlot.js b/runtime/main/extend/systemplugin/napi/notification/notificationSlot.js new file mode 100644 index 00000000..bc884a43 --- /dev/null +++ b/runtime/main/extend/systemplugin/napi/notification/notificationSlot.js @@ -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', +}; \ No newline at end of file diff --git a/runtime/main/extend/systemplugin/napi/notification/notificationSorting.js b/runtime/main/extend/systemplugin/napi/notification/notificationSorting.js new file mode 100644 index 00000000..efc1e751 --- /dev/null +++ b/runtime/main/extend/systemplugin/napi/notification/notificationSorting.js @@ -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', +}; \ No newline at end of file diff --git a/runtime/main/extend/systemplugin/napi/notification/notificationSortingMap.js b/runtime/main/extend/systemplugin/napi/notification/notificationSortingMap.js new file mode 100644 index 00000000..d7ca9875 --- /dev/null +++ b/runtime/main/extend/systemplugin/napi/notification/notificationSortingMap.js @@ -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], +}; \ No newline at end of file diff --git a/runtime/main/extend/systemplugin/napi/notification/notificationSubscribeInfo.js b/runtime/main/extend/systemplugin/napi/notification/notificationSubscribeInfo.js new file mode 100644 index 00000000..8476e26c --- /dev/null +++ b/runtime/main/extend/systemplugin/napi/notification/notificationSubscribeInfo.js @@ -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', +}; \ No newline at end of file diff --git a/runtime/main/extend/systemplugin/napi/notification/notificationSubscriber.js b/runtime/main/extend/systemplugin/napi/notification/notificationSubscriber.js new file mode 100644 index 00000000..e9568430 --- /dev/null +++ b/runtime/main/extend/systemplugin/napi/notification/notificationSubscriber.js @@ -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', +} \ No newline at end of file diff --git a/runtime/main/extend/systemplugin/napi/notification/notificationTemplate.js b/runtime/main/extend/systemplugin/napi/notification/notificationTemplate.js new file mode 100644 index 00000000..62d68e12 --- /dev/null +++ b/runtime/main/extend/systemplugin/napi/notification/notificationTemplate.js @@ -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: {}, +} \ No newline at end of file diff --git a/runtime/main/extend/systemplugin/napi/notification/notificationUserInput.js b/runtime/main/extend/systemplugin/napi/notification/notificationUserInput.js new file mode 100644 index 00000000..8c12935d --- /dev/null +++ b/runtime/main/extend/systemplugin/napi/notification/notificationUserInput.js @@ -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', +} \ No newline at end of file diff --git a/runtime/main/extend/systemplugin/napi/ohos_abilityAccessCtrl.js b/runtime/main/extend/systemplugin/napi/ohos_abilityAccessCtrl.js index c0c93dd7..9f41c7f9 100644 --- a/runtime/main/extend/systemplugin/napi/ohos_abilityAccessCtrl.js +++ b/runtime/main/extend/systemplugin/napi/ohos_abilityAccessCtrl.js @@ -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; diff --git a/runtime/main/extend/systemplugin/napi/ohos_ability_dataUriUtils.js b/runtime/main/extend/systemplugin/napi/ohos_ability_dataUriUtils.js new file mode 100644 index 00000000..9ed2ad00 --- /dev/null +++ b/runtime/main/extend/systemplugin/napi/ohos_ability_dataUriUtils.js @@ -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; +} diff --git a/runtime/main/extend/systemplugin/napi/ohos_ability_errorCode.js b/runtime/main/extend/systemplugin/napi/ohos_ability_errorCode.js new file mode 100644 index 00000000..59f0bd7a --- /dev/null +++ b/runtime/main/extend/systemplugin/napi/ohos_ability_errorCode.js @@ -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, +} \ No newline at end of file diff --git a/runtime/main/extend/systemplugin/napi/ohos_ability_featureAbility.js b/runtime/main/extend/systemplugin/napi/ohos_ability_featureAbility.js new file mode 100644 index 00000000..ae1aa3cd --- /dev/null +++ b/runtime/main/extend/systemplugin/napi/ohos_ability_featureAbility.js @@ -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, +} \ No newline at end of file diff --git a/runtime/main/extend/systemplugin/napi/ohos_ability_wantConstant.js b/runtime/main/extend/systemplugin/napi/ohos_ability_wantConstant.js new file mode 100644 index 00000000..7f469b89 --- /dev/null +++ b/runtime/main/extend/systemplugin/napi/ohos_ability_wantConstant.js @@ -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 +} \ No newline at end of file diff --git a/runtime/main/extend/systemplugin/napi/ohos_application_Ability.js b/runtime/main/extend/systemplugin/napi/ohos_application_Ability.js index 7402c1bb..66e3015a 100644 --- a/runtime/main/extend/systemplugin/napi/ohos_application_Ability.js +++ b/runtime/main/extend/systemplugin/napi/ohos_application_Ability.js @@ -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(); } diff --git a/runtime/main/extend/systemplugin/napi/ohos_application_AbilityConstant.js b/runtime/main/extend/systemplugin/napi/ohos_application_AbilityConstant.js new file mode 100644 index 00000000..f32f7d60 --- /dev/null +++ b/runtime/main/extend/systemplugin/napi/ohos_application_AbilityConstant.js @@ -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, +} \ No newline at end of file diff --git a/runtime/main/extend/systemplugin/napi/ohos_application_AbilityLifecycleCallback.js b/runtime/main/extend/systemplugin/napi/ohos_application_AbilityLifecycleCallback.js new file mode 100644 index 00000000..511379ed --- /dev/null +++ b/runtime/main/extend/systemplugin/napi/ohos_application_AbilityLifecycleCallback.js @@ -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(); +} \ No newline at end of file diff --git a/runtime/main/extend/systemplugin/napi/ohos_application_AbilityStage.js b/runtime/main/extend/systemplugin/napi/ohos_application_AbilityStage.js index 192e9a4e..526875db 100644 --- a/runtime/main/extend/systemplugin/napi/ohos_application_AbilityStage.js +++ b/runtime/main/extend/systemplugin/napi/ohos_application_AbilityStage.js @@ -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(); diff --git a/runtime/main/extend/systemplugin/napi/ohos_application_Configuration.js b/runtime/main/extend/systemplugin/napi/ohos_application_Configuration.js new file mode 100644 index 00000000..487bf868 --- /dev/null +++ b/runtime/main/extend/systemplugin/napi/ohos_application_Configuration.js @@ -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', +} diff --git a/runtime/main/extend/systemplugin/napi/ohos_application_ConfigurationConstant.js b/runtime/main/extend/systemplugin/napi/ohos_application_ConfigurationConstant.js new file mode 100644 index 00000000..e4f874a9 --- /dev/null +++ b/runtime/main/extend/systemplugin/napi/ohos_application_ConfigurationConstant.js @@ -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, +} \ No newline at end of file diff --git a/runtime/main/extend/systemplugin/napi/ohos_application_DataShareExtensionAbility.js b/runtime/main/extend/systemplugin/napi/ohos_application_DataShareExtensionAbility.js index 28fd0a32..69cccc55 100644 --- a/runtime/main/extend/systemplugin/napi/ohos_application_DataShareExtensionAbility.js +++ b/runtime/main/extend/systemplugin/napi/ohos_application_DataShareExtensionAbility.js @@ -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; } diff --git a/runtime/main/extend/systemplugin/napi/ohos_application_FormExtension.js b/runtime/main/extend/systemplugin/napi/ohos_application_FormExtension.js index 0062016c..d1aa94ca 100644 --- a/runtime/main/extend/systemplugin/napi/ohos_application_FormExtension.js +++ b/runtime/main/extend/systemplugin/napi/ohos_application_FormExtension.js @@ -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(); diff --git a/runtime/main/extend/systemplugin/napi/ohos_application_ServiceExtensionAbility.js b/runtime/main/extend/systemplugin/napi/ohos_application_ServiceExtensionAbility.js index 23146d19..3fc1e183 100644 --- a/runtime/main/extend/systemplugin/napi/ohos_application_ServiceExtensionAbility.js +++ b/runtime/main/extend/systemplugin/napi/ohos_application_ServiceExtensionAbility.js @@ -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(); diff --git a/runtime/main/extend/systemplugin/napi/ohos_application_StartOptions.js b/runtime/main/extend/systemplugin/napi/ohos_application_StartOptions.js new file mode 100644 index 00000000..530bd319 --- /dev/null +++ b/runtime/main/extend/systemplugin/napi/ohos_application_StartOptions.js @@ -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"; + } +} \ No newline at end of file diff --git a/runtime/main/extend/systemplugin/napi/ohos_application_StaticSubscriberExtensionAbility.js b/runtime/main/extend/systemplugin/napi/ohos_application_StaticSubscriberExtensionAbility.js new file mode 100644 index 00000000..45c9875f --- /dev/null +++ b/runtime/main/extend/systemplugin/napi/ohos_application_StaticSubscriberExtensionAbility.js @@ -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(); +} \ No newline at end of file diff --git a/runtime/main/extend/systemplugin/napi/ohos_application_Want.js b/runtime/main/extend/systemplugin/napi/ohos_application_Want.js new file mode 100644 index 00000000..1fad9fd2 --- /dev/null +++ b/runtime/main/extend/systemplugin/napi/ohos_application_Want.js @@ -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"; + } +} \ No newline at end of file diff --git a/runtime/main/extend/systemplugin/napi/ohos_application_abilityDelegatorRegistry.js b/runtime/main/extend/systemplugin/napi/ohos_application_abilityDelegatorRegistry.js new file mode 100644 index 00000000..6b3df79d --- /dev/null +++ b/runtime/main/extend/systemplugin/napi/ohos_application_abilityDelegatorRegistry.js @@ -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 +} \ No newline at end of file diff --git a/runtime/main/extend/systemplugin/napi/ohos_application_abilityManager.js b/runtime/main/extend/systemplugin/napi/ohos_application_abilityManager.js index 29613408..c438205c 100644 --- a/runtime/main/extend/systemplugin/napi/ohos_application_abilityManager.js +++ b/runtime/main/extend/systemplugin/napi/ohos_application_abilityManager.js @@ -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 diff --git a/runtime/main/extend/systemplugin/napi/ohos_application_appManager.js b/runtime/main/extend/systemplugin/napi/ohos_application_appManager.js index 14241881..7c3dfdf0 100644 --- a/runtime/main/extend/systemplugin/napi/ohos_application_appManager.js +++ b/runtime/main/extend/systemplugin/napi/ohos_application_appManager.js @@ -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 diff --git a/runtime/main/extend/systemplugin/napi/ohos_application_errorManager.js b/runtime/main/extend/systemplugin/napi/ohos_application_errorManager.js new file mode 100644 index 00000000..ae82557b --- /dev/null +++ b/runtime/main/extend/systemplugin/napi/ohos_application_errorManager.js @@ -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 +} \ No newline at end of file diff --git a/runtime/main/extend/systemplugin/napi/ohos_application_formBindingData.js b/runtime/main/extend/systemplugin/napi/ohos_application_formBindingData.js index ee6a78a0..da8ffa55 100644 --- a/runtime/main/extend/systemplugin/napi/ohos_application_formBindingData.js +++ b/runtime/main/extend/systemplugin/napi/ohos_application_formBindingData.js @@ -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; } \ No newline at end of file diff --git a/runtime/main/extend/systemplugin/napi/ohos_application_formError.js b/runtime/main/extend/systemplugin/napi/ohos_application_formError.js new file mode 100644 index 00000000..431d7166 --- /dev/null +++ b/runtime/main/extend/systemplugin/napi/ohos_application_formError.js @@ -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 +} \ No newline at end of file diff --git a/runtime/main/extend/systemplugin/napi/ohos_application_formHost.js b/runtime/main/extend/systemplugin/napi/ohos_application_formHost.js new file mode 100644 index 00000000..ae11360d --- /dev/null +++ b/runtime/main/extend/systemplugin/napi/ohos_application_formHost.js @@ -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 +} \ No newline at end of file diff --git a/runtime/main/extend/systemplugin/napi/ohos_application_formInfo.js b/runtime/main/extend/systemplugin/napi/ohos_application_formInfo.js new file mode 100644 index 00000000..23a551b8 --- /dev/null +++ b/runtime/main/extend/systemplugin/napi/ohos_application_formInfo.js @@ -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', +} \ No newline at end of file diff --git a/runtime/main/extend/systemplugin/napi/ohos_application_formProvider.js b/runtime/main/extend/systemplugin/napi/ohos_application_formProvider.js index 2492537e..078f3e77 100644 --- a/runtime/main/extend/systemplugin/napi/ohos_application_formProvider.js +++ b/runtime/main/extend/systemplugin/napi/ohos_application_formProvider.js @@ -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) => { diff --git a/runtime/main/extend/systemplugin/napi/ohos_application_testRunner.js b/runtime/main/extend/systemplugin/napi/ohos_application_testRunner.js new file mode 100644 index 00000000..21abc4d6 --- /dev/null +++ b/runtime/main/extend/systemplugin/napi/ohos_application_testRunner.js @@ -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; +} \ No newline at end of file diff --git a/runtime/main/extend/systemplugin/napi/ohos_backgroundTaskManager.js b/runtime/main/extend/systemplugin/napi/ohos_backgroundTaskManager.js index 5eacd161..d3e9eebf 100644 --- a/runtime/main/extend/systemplugin/napi/ohos_backgroundTaskManager.js +++ b/runtime/main/extend/systemplugin/napi/ohos_backgroundTaskManager.js @@ -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) }); } }, diff --git a/runtime/main/extend/systemplugin/napi/ohos_batteryInfo.js b/runtime/main/extend/systemplugin/napi/ohos_batteryInfo.js index fa2d3348..8c0c9340 100644 --- a/runtime/main/extend/systemplugin/napi/ohos_batteryInfo.js +++ b/runtime/main/extend/systemplugin/napi/ohos_batteryInfo.js @@ -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 } diff --git a/runtime/main/extend/systemplugin/napi/ohos_batteryStatistics.js b/runtime/main/extend/systemplugin/napi/ohos_batteryStatistics.js index 7e771254..41ac82b0 100644 --- a/runtime/main/extend/systemplugin/napi/ohos_batteryStatistics.js +++ b/runtime/main/extend/systemplugin/napi/ohos_batteryStatistics.js @@ -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 } \ No newline at end of file diff --git a/runtime/main/extend/systemplugin/napi/ohos_brightness.js b/runtime/main/extend/systemplugin/napi/ohos_brightness.js index f2aaea3b..37e2fa58 100644 --- a/runtime/main/extend/systemplugin/napi/ohos_brightness.js +++ b/runtime/main/extend/systemplugin/napi/ohos_brightness.js @@ -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 diff --git a/runtime/main/extend/systemplugin/napi/ohos_bundle.js b/runtime/main/extend/systemplugin/napi/ohos_bundle.js index 8a515d27..3003706b 100644 --- a/runtime/main/extend/systemplugin/napi/ohos_bundle.js +++ b/runtime/main/extend/systemplugin/napi/ohos_bundle.js @@ -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; } \ No newline at end of file diff --git a/runtime/main/extend/systemplugin/napi/ohos_bundleState.js b/runtime/main/extend/systemplugin/napi/ohos_bundleState.js index 35f75ed3..f7bb772d 100644 --- a/runtime/main/extend/systemplugin/napi/ohos_bundleState.js +++ b/runtime/main/extend/systemplugin/napi/ohos_bundleState.js @@ -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) }); } }, diff --git a/runtime/main/extend/systemplugin/napi/ohos_bundle_defaultAppManager.js b/runtime/main/extend/systemplugin/napi/ohos_bundle_defaultAppManager.js index d5487114..6d35a272 100755 --- a/runtime/main/extend/systemplugin/napi/ohos_bundle_defaultAppManager.js +++ b/runtime/main/extend/systemplugin/napi/ohos_bundle_defaultAppManager.js @@ -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); }) } }, diff --git a/runtime/main/extend/systemplugin/napi/ohos_bundle_innerBundleManager.js b/runtime/main/extend/systemplugin/napi/ohos_bundle_innerBundleManager.js index 72fe60d6..175a0249 100644 --- a/runtime/main/extend/systemplugin/napi/ohos_bundle_innerBundleManager.js +++ b/runtime/main/extend/systemplugin/napi/ohos_bundle_innerBundleManager.js @@ -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)); }) } }, diff --git a/runtime/main/extend/systemplugin/napi/ohos_commonEvent.js b/runtime/main/extend/systemplugin/napi/ohos_commonEvent.js index 43f94185..9dbe65dd 100644 --- a/runtime/main/extend/systemplugin/napi/ohos_commonEvent.js +++ b/runtime/main/extend/systemplugin/napi/ohos_commonEvent.js @@ -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) { diff --git a/runtime/main/extend/systemplugin/napi/ohos_continuation_continuationManager.js b/runtime/main/extend/systemplugin/napi/ohos_continuation_continuationManager.js new file mode 100644 index 00000000..dd0925a6 --- /dev/null +++ b/runtime/main/extend/systemplugin/napi/ohos_continuation_continuationManager.js @@ -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 +} \ No newline at end of file diff --git a/runtime/main/extend/systemplugin/napi/ohos_data_DataShareResultSet.js b/runtime/main/extend/systemplugin/napi/ohos_data_DataShareResultSet.js index 6dc2f411..26f86584 100644 --- a/runtime/main/extend/systemplugin/napi/ohos_data_DataShareResultSet.js +++ b/runtime/main/extend/systemplugin/napi/ohos_data_DataShareResultSet.js @@ -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.") } } diff --git a/runtime/main/extend/systemplugin/napi/ohos_data_Storage.js b/runtime/main/extend/systemplugin/napi/ohos_data_Storage.js index 23aa2fc2..36977af0 100644 --- a/runtime/main/extend/systemplugin/napi/ohos_data_Storage.js +++ b/runtime/main/extend/systemplugin/napi/ohos_data_Storage.js @@ -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 diff --git a/runtime/main/extend/systemplugin/napi/ohos_data_dataSharePredicates.js b/runtime/main/extend/systemplugin/napi/ohos_data_dataSharePredicates.js index 0faa8777..a803141b 100644 --- a/runtime/main/extend/systemplugin/napi/ohos_data_dataSharePredicates.js +++ b/runtime/main/extend/systemplugin/napi/ohos_data_dataSharePredicates.js @@ -14,8 +14,8 @@ */ import { paramMock } from "../utils" -export function DataSharePredicates() { - const DataSharePredicatesClass = class data_DataSharePredicates { +export function mockDataSharePredicates() { + const DataSharePredicatesClass = class DataSharePredicates { constructor() { this.equalTo = function (...args) { console.warn("DataSharePredicates.equalTo interface mocked in the Previewer. How this interface works on the" + diff --git a/runtime/main/extend/systemplugin/napi/ohos_data_distributedData.js b/runtime/main/extend/systemplugin/napi/ohos_data_distributedData.js index 0cf30c63..17c6cd9f 100644 --- a/runtime/main/extend/systemplugin/napi/ohos_data_distributedData.js +++ b/runtime/main/extend/systemplugin/napi/ohos_data_distributedData.js @@ -229,13 +229,13 @@ export function mockDistributedData() { S4: 6, }, - SyncMode :{ + SyncMode: { PULL_ONLY: 0, PUSH_ONLY: 1, PUSH_PULL: 2, }, - SubscribeType : { + SubscribeType: { SUBSCRIBE_TYPE_LOCAL: 0, SUBSCRIBE_TYPE_REMOTE: 1, SUBSCRIBE_TYPE_ALL: 2, @@ -264,7 +264,8 @@ export function mockDistributedData() { }; const kvManagerConfigMock = { userInfo: "[PC Preview] unknown userInfo", - bundleName: "[PC Preview] unknown bundleName" + bundleName: "[PC Preview] unknown bundleName", + context : "[PC Preview] unknown context" }; const constantsMock = { MAX_KEY_LENGTH: "[PC Preview] unknown MAX_KEY_LENGTH", @@ -274,6 +275,17 @@ export function mockDistributedData() { MAX_QUERY_LENGTH: "[PC Preview] unknown MAX_QUERY_LENGTH", MAX_BATCH_SIZE: "[PC Preview] unknown MAX_BATCH_SIZE" }; + const schemaMock = { + root: "[PC Preview] unknown root", + indexes: "[PC Preview] unknown indexes", + mode: "[PC Preview] unknown mode", + skip: "[PC Preview] unknown skip" + }; + const fieldnodeMock = { + default: "[PC Preview] unknown default", + nullable: "[PC Preview] unknown nullable", + type: "[PC Preview] unknown type" + }; const valueTypeMock = { STRING: "[PC Preview] unknown STRING", INTEGER: "[PC Preview] unknown INTEGER", @@ -303,6 +315,7 @@ export function mockDistributedData() { autoSync: "[PC Preview] unknown autoSync", kvStoreType: "[PC Preview] unknown kvStoreType", securityLevel: "[PC Preview] unknown securityLevel", + schema: "[PC Preview] unknown schema" }; const KVStoreClass = class KVStore { @@ -355,6 +368,9 @@ export function mockDistributedData() { if (typeof args[len - 1] === 'function') { if (args[0] == 'dataChange') { args[len - 1].call(this, paramMock.businessErrorMock, changeNotificationMock) + } else if (args[0] === 'syncComplete') { + var array = new Array([paramMock.paramStringMock, paramMock.paramNumberMock]); + args[len - 1].call(this, array); } } }; @@ -366,6 +382,9 @@ export function mockDistributedData() { if (typeof args[len - 1] === 'function') { if (args[0] == 'dataChange') { args[len - 1].call(this, paramMock.businessErrorMock, changeNotificationMock) + } else if (args[0] === 'syncComplete') { + var array = new Array([paramMock.paramStringMock, paramMock.paramNumberMock]); + args[len - 1].call(this, array); } } }; diff --git a/runtime/main/extend/systemplugin/napi/ohos_data_distributedDataObject.js b/runtime/main/extend/systemplugin/napi/ohos_data_distributedDataObject.js index 0c2335d0..ad34651e 100644 --- a/runtime/main/extend/systemplugin/napi/ohos_data_distributedDataObject.js +++ b/runtime/main/extend/systemplugin/napi/ohos_data_distributedDataObject.js @@ -62,7 +62,7 @@ export function mockDistributedObject() { const RevokeSaveSuccessResponse = { sessionId: "[[PC Preview] unknow sessionId]" }; - const distributedObjectMock = { + const distributedDataObject = { createDistributedObject: function (...args) { console.warn("distributedObject.createDistributedObject interface mocked in the Previewer." + " How this interface works on the Previewer may be different from that on a real device."); @@ -74,5 +74,5 @@ export function mockDistributedObject() { return 'just test'; } }; - return distributedObjectMock; -} \ No newline at end of file + return distributedDataObject; +} diff --git a/runtime/main/extend/systemplugin/napi/ohos_data_rdb.js b/runtime/main/extend/systemplugin/napi/ohos_data_rdb.js index 403eefdd..e9ac4c8c 100644 --- a/runtime/main/extend/systemplugin/napi/ohos_data_rdb.js +++ b/runtime/main/extend/systemplugin/napi/ohos_data_rdb.js @@ -14,6 +14,7 @@ */ import { paramMock } from "../utils" +import { resultSet } from "./data/rdb/resultSet" export const RdbPredicatesClass = class RdbPredicates { constructor(...args) { @@ -200,89 +201,20 @@ export function mockRdb() { }, RdbPredicates: RdbPredicatesClass }; - const resultSetMock = { - columnNames: "[[PC Preview] unknow columnNames]", - 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.") - } - } + const storeConfig = { name: "[PC Preview] unknown name" } + + const SyncMode = { + SYNC_MODE_PUSH: 0, + SYNC_MODE_PULL: 1 + } + + const SubscribeType = { + SUBSCRIBE_TYPE_REMOTE: 0 + } + const rdbStore = { insert: function (...args) { console.warn("RdbStore.insert interface mocked in the Previewer. How this interface works on the" + @@ -325,10 +257,10 @@ export function mockRdb() { " 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, resultSetMock); + args[len - 1].call(this, paramMock.businessErrorMock, resultSet); } else { return new Promise((resolve, reject) => { - resolve(resultSetMock); + resolve(resultSet); }) } }, @@ -337,10 +269,10 @@ export function mockRdb() { " 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, resultSetMock); + args[len - 1].call(this, paramMock.businessErrorMock, resultSet); } else { return new Promise((resolve, reject) => { - resolve(resultSetMock); + resolve(resultSet); }) } }, @@ -356,6 +288,18 @@ export function mockRdb() { }) } }, + beginTransaction: function () { + console.warn("RdbStore.beginTransaction interface mocked in the Previewer. How this interface works on the" + + " Previewer may be different from that on a real device.") + }, + commit: function () { + console.warn("RdbStore.commit interface mocked in the Previewer. How this interface works on the" + + " Previewer may be different from that on a real device.") + }, + rollBack: function () { + console.warn("RdbStore.rollBack interface mocked in the Previewer. How this interface works on the" + + " Previewer may be different from that on a real device.") + }, backup: function (...args) { console.warn("RdbStore.backup interface mocked in the Previewer. How this interface works on the" + " Previewer may be different from that on a real device.") diff --git a/runtime/main/extend/systemplugin/napi/ohos_display.js b/runtime/main/extend/systemplugin/napi/ohos_display.js index 9ef6e171..cd7c5f84 100644 --- a/runtime/main/extend/systemplugin/napi/ohos_display.js +++ b/runtime/main/extend/systemplugin/napi/ohos_display.js @@ -1,88 +1,120 @@ -/* - * Copyright (c) 2021 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 mockDisplay() { - const displayMock = { - densityDPI: '[PC preview] unknow densityDPI', - densityPixels: '[PC preview] unknow densityPixels', - scaledDensity: '[PC preview] unknow scaledDensity', - xDPI: '[PC preview] unknow xDPI', - yDPI: '[PC preview] unknow yDPI', - width: '[PC preview] unknow width', - height: '[PC preview] unknow height', - alive: '[PC preview] unknow alive', - refreshRate: '[PC preview] unknow refreshRate', - id: '[PC preview] unknow id', - state: '[PC preview] unknow state', - rotation: '[PC preview] unknow rotation', - name: '[PC preview] unknow name' - } - const allDisplayMock = [{ - densityDPI: '[PC preview] unknow densityDPI', - densityPixels: '[PC preview] unknow densityPixels', - scaledDensity: '[PC preview] unknow scaledDensity', - xDPI: '[PC preview] unknow xDPI', - yDPI: '[PC preview] unknow yDPI', - width: '[PC preview] unknow width', - height: '[PC preview] unknow height', - alive: '[PC preview] unknow alive', - refreshRate: '[PC preview] unknow refreshRate', - id: '[PC preview] unknow id', - state: '[PC preview] unknow state', - rotation: '[PC preview] unknow rotation', - name: '[PC preview] unknow name' - }] - const display = { - getDefaultDisplay: function (...args) { - console.warn("display.getDefaultDisplay 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, displayMock) - } else { - return new Promise((resolve, reject) => { - resolve(displayMock) - }) - } - }, - getAllDisplay: function (...args) { - console.warn("display.getAllDisplay 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, allDisplayMock) - } else { - return new Promise((resolve, reject) => { - resolve(allDisplayMock) - }) - } - }, - on: function (...args) { - console.warn("display.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, paramMock.businessErrorMock, paramMock.paramNumberMock) - }, - off: function (...args) { - console.warn("display.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, paramMock.businessErrorMock, paramMock.paramNumberMock) - }, - } - return display +/* + * 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 + * + * 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 DisplayState = { + STATE_UNKNOWN: 0, + STATE_OFF: 1, + STATE_ON: 2, + STATE_DOZE: 3, + STATE_DOZE_SUSPEND: 4, + STATE_VR: 5, + STATE_ON_SUSPEND: 6 +} +const DisplayType = { + add: 'add', + remove: 'remove', + change: 'change' +} + +export const Display = { + id: '[PC preview] unknow id', + name: '[PC preview] unknow name', + alive: '[PC preview] unknow alive', + state: DisplayState, + refreshRate: '[PC preview] unknow refreshRate', + rotation: '[PC preview] unknow rotation', + width: '[PC preview] unknow width', + height: '[PC preview] unknow height', + densityDPI: '[PC preview] unknow densityDPI', + densityPixels: '[PC preview] unknow densityPixels', + scaledDensity: '[PC preview] unknow scaledDensity', + xDPI: '[PC preview] unknow xDPI', + yDPI: '[PC preview] unknow yDPI' +} + +export function mockDisplay() { + + const display = { + getDefaultDisplay: function (...args) { + console.warn("Display.getDefaultDisplay 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, Display) + } else { + return new Promise((resolve, reject) => { + resolve(Display) + }) + } + }, + getDefaultDisplaySync: function (...args) { + console.warn("Display.getDefaultDisplay interface mocked in the Previewer. How this interface works on the Previewer" + + " may be different from that on a real device.") + return Display + }, + getAllDisplay: function (...args) { + console.warn("Display.getAllDisplay 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, [Display]) + } else { + return new Promise((resolve, reject) => { + resolve([Display]) + }) + } + }, + on: function (...args) { + console.warn("Display.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 (len!==2){ + console.warn("Display.on:please check params !") + return + } + if (typeof args[len - 1] === 'function') { + if (args[0] === DisplayType.add|| args[0] === DisplayType.remove || args[0] === DisplayType.change){ + console.warn(`Display.on: you has registered ${args[0]} event.`) + } else { + console.warn("Display.on:please check first param!") + } + } else { + console.warn("Display.on:please check params, the second parma must be a function!") + } + }, + off: function (...args) { + console.warn("Display.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 (len!==2){ + console.warn("Display.off:please check params!") + return + } + if (typeof args[len - 1] === 'function') { + if (args[0] === DisplayType.add|| args[0] === DisplayType.remove || args[0] === DisplayType.change){ + console.warn(`Display.off: you has registered ${args[0]} event`) + } else { + console.warn("Display.off:please check first param!") + } + } else { + console.warn("Display.off:please check params, the second parma must be a function!") + } + }, + DisplayState + } + return display } \ No newline at end of file diff --git a/runtime/main/extend/systemplugin/napi/ohos_distributedMissionManager.js b/runtime/main/extend/systemplugin/napi/ohos_distributedMissionManager.js new file mode 100755 index 00000000..9990e237 --- /dev/null +++ b/runtime/main/extend/systemplugin/napi/ohos_distributedMissionManager.js @@ -0,0 +1,70 @@ +/* + * 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 mockDistributedMissionManager() { + const distributedMissionManager = { + startSyncRemoteMissions: function (...args) { + console.warn('distributedMissionManager.startSyncRemoteMission 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(); + }); + } + }, + stopSyncRemoteMissions: function (...args) { + console.warn('distributedMissionManager.stopSyncRemoteMission 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(); + }); + } + }, + registerMissionListener: function (...args) { + console.warn('distributedMissionManager.registerMissionListener 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(); + }); + } + }, + unRegisterMissionListener: function (...args) { + console.warn('distributedMissionManager.unRegisterMissionListener 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 distributedMissionManager +} \ No newline at end of file diff --git a/runtime/main/extend/systemplugin/napi/ohos_events_emitter.js b/runtime/main/extend/systemplugin/napi/ohos_events_emitter.js index ccc47fcf..b712a291 100644 --- a/runtime/main/extend/systemplugin/napi/ohos_events_emitter.js +++ b/runtime/main/extend/systemplugin/napi/ohos_events_emitter.js @@ -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 @@ -15,17 +15,28 @@ import { paramMock } from "../utils" +export const EventPriority = { + IMMEDIATE: 0, + HIGH: 1, + LOW: 2, + IDLE: 3, +} +export const EventData = { + data: '[PC preview] unknow data', +} +export const InnerEvent = { + eventId: '[PC preview] unknow eventId', + priority: EventPriority, +} + export function mockEmitter() { - const EventDataMock = { - data: '[PC preview] unknow data', - }; const emitter = { on: function (...args) { console.warn("emitter.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, EventDataMock); + args[len - 1].call(this, EventData); } }, once: function (...args) { @@ -33,7 +44,7 @@ export function mockEmitter() { " 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, EventDataMock); + args[len - 1].call(this, EventData); } }, off: function (...args) { diff --git a/runtime/main/extend/systemplugin/napi/ohos_fileManager.js b/runtime/main/extend/systemplugin/napi/ohos_fileManager.js index f06e905c..d9fc9eb9 100644 --- a/runtime/main/extend/systemplugin/napi/ohos_fileManager.js +++ b/runtime/main/extend/systemplugin/napi/ohos_fileManager.js @@ -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 @@ -16,16 +16,29 @@ import { paramMock } from "../utils" export function mockFileManager() { + const FileInfo = { + name: '[PC preview] unknow name', + path: '[PC preview] unknow path', + type: '[PC preview] unknow type', + size: '[PC preview] unknow size', + addedTime: '[PC preview] unknow addedTime', + modifiedTime: '[PC preview] unknow modifiedTime' + }; + const DevInfo = { + name: '[PC preview] unknow name' + }; const filemanager = { + FileInfo: FileInfo, + DevInfo: DevInfo, getRoot: function (...args) { console.warn("filemanager.getRoot 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) + args[len - 1].call(this, paramMock.businessErrorMock, new Array(FileInfo)) } else { return new Promise((resolve, reject) => { - resolve(paramMock.paramArrayMock); + resolve(new Array(FileInfo)); }) } }, @@ -34,10 +47,10 @@ export function mockFileManager() { " 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) + args[len - 1].call(this, paramMock.businessErrorMock, new Array(FileInfo)) } else { return new Promise((resolve, reject) => { - resolve(paramMock.paramArrayMock); + resolve(new Array(FileInfo)); }) } }, @@ -52,7 +65,7 @@ export function mockFileManager() { resolve(paramMock.paramStringMock); }) } - }, + } } return filemanager; } diff --git a/runtime/main/extend/systemplugin/napi/ohos_geolocation.js b/runtime/main/extend/systemplugin/napi/ohos_geolocation.js index c234ce77..011a3f7b 100644 --- a/runtime/main/extend/systemplugin/napi/ohos_geolocation.js +++ b/runtime/main/extend/systemplugin/napi/ohos_geolocation.js @@ -16,7 +16,7 @@ import { paramMock } from "../utils" export function mockOhosGeolocation() { - const LocationMock = { + const Location = { latitude: '[PC preview] unknow latitude', longitude: '[PC preview] unknow longitude', altitude: '[PC preview] unknow altitude', @@ -25,10 +25,10 @@ export function mockOhosGeolocation() { timeStamp: '[PC preview] unknow timeStamp', direction: '[PC preview] unknow direction', timeSinceBoot: '[PC preview] unknow timeSinceBoot', - additions: '[PC preview] unknow additions', + additions: [paramMock.paramStringMock], additionSize: '[PC preview] unknow additionSize', } - const GeoAddressMock = { + const GeoAddress = { latitude: '[PC preview] unknow latitude', longitude: '[PC preview] unknow longitude', locale: '[PC preview] unknow locale', @@ -45,9 +45,27 @@ export function mockOhosGeolocation() { postalCode: '[PC preview] unknow postalCode', phoneNumber: '[PC preview] unknow phoneNumber', addressUrl: '[PC preview] unknow addressUrl', - descriptions: '[PC preview] unknow descriptions', + descriptions: [paramMock.paramStringMock], descriptionsSize: '[PC preview] unknow descriptionsSize', } + const SatelliteStatusInfo = { + satellitesNumber: '[PC preview] unknow satellitesNumber', + satelliteIds: [paramMock.paramNumberMock], + carrierToNoiseDensitys: [paramMock.paramNumberMock], + altitudes: [paramMock.paramNumberMock], + azimuths: [paramMock.paramNumberMock], + carrierFrequencies: [paramMock.paramNumberMock], + } + const CountryCodeType = { + COUNTRY_CODE_FROM_LOCALE: 1, + COUNTRY_CODE_FROM_SIM: 2, + COUNTRY_CODE_FROM_LOCATION: 3, + COUNTRY_CODE_FROM_NETWORK: 4, + } + const CountryCode = { + country: '[PC preview] unknow country', + type: CountryCodeType, + } const geolocation = { on: function (...args) { console.warn("geolocation.on interface mocked in the Previewer. How this interface works on the" + @@ -55,9 +73,17 @@ export function mockOhosGeolocation() { const len = args.length; if (typeof args[len - 1] === 'function') { if (args[0] == 'locationChange') { - args[len - 1].call(this, LocationMock); + args[len - 1].call(this, Location); } else if (args[0] == 'locationServiceState') { - args[len - 1].call(this, paramMock.paramBooleanMock); + args[len - 1].call(this, paramMock.paramBooleanMock); + } else if (args[0] == 'cachedGnssLocationsReporting') { + args[len - 1].call(this, [Location]); + } else if (args[0] == 'gnssStatusChange') { + args[len - 1].call(this, SatelliteStatusInfo); + } else if (args[0] == 'nmeaMessageChange') { + args[len - 1].call(this, paramMock.paramStringMock); + } else if (args[0] == 'countryCodeChange') { + args[len - 1].call(this, CountryCode); } } }, @@ -67,9 +93,17 @@ export function mockOhosGeolocation() { const len = args.length; if (typeof args[len - 1] === 'function') { if (args[0] == 'locationChange') { - args[len - 1].call(this, LocationMock); + args[len - 1].call(this, Location); } else if (args[0] == 'locationServiceState') { - args[len - 1].call(this, paramMock.paramBooleanMock); + args[len - 1].call(this, paramMock.paramBooleanMock); + } else if (args[0] == 'cachedGnssLocationsReporting') { + args[len - 1].call(this, [Location]); + } else if (args[0] == 'gnssStatusChange') { + args[len - 1].call(this, SatelliteStatusInfo); + } else if (args[0] == 'nmeaMessageChange') { + args[len - 1].call(this, paramMock.paramStringMock); + } else if (args[0] == 'countryCodeChange') { + args[len - 1].call(this, CountryCode); } } }, @@ -78,10 +112,10 @@ export function mockOhosGeolocation() { " 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, LocationMock); + args[len - 1].call(this, paramMock.businessErrorMock, Location); } else { return new Promise((resolve) => { - resolve(LocationMock); + resolve(Location); }); } }, @@ -90,10 +124,10 @@ export function mockOhosGeolocation() { " 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, LocationMock); + args[len - 1].call(this, paramMock.businessErrorMock, Location); } else { return new Promise((resolve) => { - resolve(LocationMock); + resolve(Location); }); } }, @@ -150,10 +184,10 @@ export function mockOhosGeolocation() { " 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, [GeoAddressMock]); + args[len - 1].call(this, paramMock.businessErrorMock, [GeoAddress]); } else { return new Promise((resolve) => { - resolve([GeoAddressMock]); + resolve([GeoAddress]); }); } }, @@ -162,10 +196,10 @@ export function mockOhosGeolocation() { " 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, [GeoAddressMock]); + args[len - 1].call(this, paramMock.businessErrorMock, [GeoAddress]); } else { return new Promise((resolve) => { - resolve([GeoAddressMock]); + resolve([GeoAddress]); }); } }, @@ -181,6 +215,150 @@ export function mockOhosGeolocation() { }); } }, + getCachedGnssLocationsSize: function (...args) { + console.warn("geolocation.getCachedGnssLocationsSize 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); + }); + } + }, + flushCachedGnssLocations: function (...args) { + console.warn("geolocation.flushCachedGnssLocations 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); + }); + } + }, + sendCommand: function (...args) { + console.warn("geolocation.sendCommand 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); + }); + } + }, + getCountryCode: function (...args) { + console.warn("geolocation.getCountryCode 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, CountryCode); + } else { + return new Promise((resolve) => { + resolve(CountryCode); + }); + } + }, + enableLocationMock: function (...args) { + console.warn("geolocation.enableLocationMock 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(); + }); + } + }, + disableLocationMock: function (...args) { + console.warn("geolocation.disableLocationMock 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(); + }); + } + }, + setMockedLocations: function (...args) { + console.warn("geolocation.setMockedLocations 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(); + }); + } + }, + enableReverseGeocodingMock: function (...args) { + console.warn("geolocation.enableReverseGeocodingMock 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(); + }); + } + }, + disableReverseGeocodingMock: function (...args) { + console.warn("geolocation.disableReverseGeocodingMock 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(); + }); + } + }, + setReverseGeocodingMockInfo: function (...args) { + console.warn("geolocation.setReverseGeocodingMockInfo 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(); + }); + } + }, + isLocationPrivacyConfirmed: function (...args) { + console.warn("geolocation.isLocationPrivacyConfirmed 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); + }); + } + }, + setLocationPrivacyConfirmStatus: function (...args) { + console.warn("geolocation.setLocationPrivacyConfirmStatus 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); + }); + } + }, } return geolocation } diff --git a/runtime/main/extend/systemplugin/napi/ohos_i18n.js b/runtime/main/extend/systemplugin/napi/ohos_i18n.js index 0b946057..5aa4ad09 100644 --- a/runtime/main/extend/systemplugin/napi/ohos_i18n.js +++ b/runtime/main/extend/systemplugin/napi/ohos_i18n.js @@ -30,12 +30,12 @@ export function mockI18N() { getSystemLanguages: function() { console.warn("I18N.getSystemLanguages interface mocked in the Previewer. How this interface works on the Previewer" + " may be different from that on a real device.") - return paramMock.paramArrayMock; + return new Array(paramMock.paramStringMock); }, getSystemCountries: function(...args) { console.warn("I18N.getSystemCountries interface mocked in the Previewer. How this interface works on the Previewer" + " may be different from that on a real device.") - return paramMock.paramArrayMock; + return new Array(paramMock.paramStringMock); }, isSuggested: function(...args) { console.warn("I18N.isSuggested interface mocked in the Previewer. How this interface works on the Previewer" + @@ -72,11 +72,6 @@ export function mockI18N() { " may be different from that on a real device.") return paramMock.paramBooleanMock; }, - PhoneNumberFormat: function(...args) { - console.warn("I18N.PhoneNumberFormat interface mocked in the Previewer. How this interface works on the Previewer" + - " may be different from that on a real device.") - return PhoneNumberFormatMock; - }, getCalendar: function(...args) { console.warn("I18N.getCalendar interface mocked in the Previewer. How this interface works on the Previewer" + " may be different from that on a real device.") @@ -95,7 +90,7 @@ export function mockI18N() { getTimeZone: function(...args) { console.warn("I18N.getTimeZone interface mocked in the Previewer. How this interface works on the Previewer" + " may be different from that on a real device.") - return TimeZoneMock; + return new TimeZoneClass(); }, Util: { unitConvert: function(...args) { @@ -180,25 +175,25 @@ export function mockI18N() { getPreferredLanguageList: function() { console.warn("I18N.getPreferredLanguageList interface mocked in the Previewer. How this interface works on the Previewer" + " may be different from that on a real device.") - return paramMock.paramArrayMock; + return new Array(paramMock.paramStringMock); }, getFirstPreferredLanguage: function() { console.warn("I18N.getFirstPreferredLanguage interface mocked in the Previewer. How this interface works on the Previewer" + " may be different from that on a real device.") return paramMock.paramStringMock; - } - } - const PhoneNumberFormatMock = { - isValidNumber: function(...args) { - console.warn("I18N.PhoneNumberFormat.isValidNumber interface mocked in the Previewer. How this interface works on the Previewer" + + }, + TimeZone: TimeZoneClass, + setUsingLocalDigit: function(...args) { + console.warn("I18N.setUsingLocalDigit interface mocked in the Previewer. How this interface works on the Previewer" + " may be different from that on a real device.") return paramMock.paramBooleanMock; }, - format: function(...args) { - console.warn("I18N.PhoneNumberFormat.format interface mocked in the Previewer. How this interface works on the Previewer" + + getUsingLocalDigit: function() { + console.warn("I18N.getUsingLocalDigit 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 paramMock.paramBooleanMock; }, + PhoneNumberFormat: PhoneNumberFormatClass } const CalendarMock = { setTime: function(...args) { @@ -302,7 +297,7 @@ export function mockI18N() { getIndexList: function() { console.warn("I18N.IndexUtil.getIndexList interface mocked in the Previewer. How this interface works on the Previewer" + " may be different from that on a real device.") - return paramMock.paramArrayMock; + return new Array(paramMock.paramStringMock); }, addLocale: function(...args) { console.warn("I18N.IndexUtil.addLocale interface mocked in the Previewer. How this interface works on the Previewer" + @@ -314,27 +309,71 @@ export function mockI18N() { return paramMock.paramStringMock; } } - const TimeZoneMock = { - getID: function() { + return result; +} + +export const TimeZoneClass = class TimeZone{ + constructor() { + this.getID = function() { console.warn("I18N.TimeZone.getID interface mocked in the Previewer. How this interface works on the Previewer" + " may be different from that on a real device.") return paramMock.paramStringMock; - }, - getDisplayName: function(...args) { + }; + this.getDisplayName = function(...args) { console.warn("I18N.TimeZone.getDisplayName interface mocked in the Previewer. How this interface works on the Previewer" + " may be different from that on a real device.") return paramMock.paramStringMock; - }, - getRawOffset: function() { + }; + this.getRawOffset = function() { console.warn("I18N.TimeZone.getRawOffset interface mocked in the Previewer. How this interface works on the Previewer" + " may be different from that on a real device.") return paramMock.paramNumberMock; - }, - getOffset: function(...args) { + }; + this.getOffset = function(...args) { console.warn("I18N.TimeZone.getOffset 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 result; +} +TimeZoneClass.getAvailableIDs = function() { + console.warn("I18N.TimeZone.getAvailableIDs interface mocked in the Previewer. How this interface works on the Previewer" + + " may be different from that on a real device.") + return new Array(paramMock.paramStringMock); +}; +TimeZoneClass.getAvailableZoneCityIDs = function() { + console.warn("I18N.TimeZone.getAvailableZoneCityIDs interface mocked in the Previewer. How this interface works on the Previewer" + + " may be different from that on a real device.") + return new Array(paramMock.paramStringMock); +}; +TimeZoneClass.getCityDisplayName = function(...args) { + console.warn("I18N.TimeZone.getCityDisplayName interface mocked in the Previewer. How this interface works on the Previewer" + + " may be different from that on a real device.") + return paramMock.paramStringMock; +}; +TimeZoneClass.getTimezoneFromCity = function(...args) { + console.warn("I18N.TimeZone.getTimezoneFromCity interface mocked in the Previewer. How this interface works on the Previewer" + + " may be different from that on a real device.") + return new TimeZoneClass(); +}; +const PhoneNumberFormatClass = class PhoneNumberFormat{ + constructor(...args) { + console.warn("I18N.PhoneNumberFormat.constructor interface mocked in the Previewer. How this interface works on the Previewer" + + " may be different from that on a real device.") + this.isValidNumber = function(...args) { + console.warn("I18N.PhoneNumberFormat.isValidNumber 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.format = function(...args) { + console.warn("I18N.PhoneNumberFormat.format interface mocked in the Previewer. How this interface works on the Previewer" + + " may be different from that on a real device.") + return paramMock.paramStringMock; + }; + } +} +PhoneNumberFormatClass.getLocationName = function(...args) { + console.warn("I18N.PhoneNumberFormat.getLocationName interface mocked in the Previewer. How this interface works on the Previewer" + + " may be different from that on a real device.") + return paramMock.paramStringMock; } \ No newline at end of file diff --git a/runtime/main/extend/systemplugin/napi/ohos_inputmethod.js b/runtime/main/extend/systemplugin/napi/ohos_inputmethod.js index ca1a920b..4596334c 100644 --- a/runtime/main/extend/systemplugin/napi/ohos_inputmethod.js +++ b/runtime/main/extend/systemplugin/napi/ohos_inputmethod.js @@ -39,14 +39,8 @@ export function mockInputMethod() { } ] const InputMethodProperty = { - methodId: "[PC Preview] unknow method id", - bundleName: "[PC Preview] unknow bundle name", - abilityName: "[PC Preview] unknow ability name", - configurationPage: "[PC Preview] unknow configuration page", - isSystemIme: true, - typeCount: 1, - defaultImeId: 2, - keyboardTypes: KeyboardTypeArry + packageName :"[PC Preview] unknow packageName", + methodId: "[PC Preview] unknow method id" } const InputMethodPropertyArry = [ { @@ -137,7 +131,7 @@ export function mockInputMethod() { }, } const inputMethod = { - MAX_TYPE_MUN: 128, + MAX_TYPE_NUM: 128, getInputMethodController: function () { console.warn("inputmethod.getInputMethodController interface mocked in the Previewer. How this interface works" + " on the Previewer may be different from that on a real device.") @@ -147,7 +141,24 @@ export function mockInputMethod() { console.warn("inputmethod.getInputMethodSetting interface mocked in the Previewer. How this interface works" + " on the Previewer may be different from that on a real device.") return InputMethodSettingMock; - } + }, + getCurrentInputMethod: function () { + console.warn("inputmethod.getCurrentInputMethod interface mocked in the Previewer. How this interface works" + + " on the Previewer may be different from that on a real device.") + return InputMethodProperty; + }, + switchInputMethod: function (...args) { + console.warn("inputMethod.switchInputMethod 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, reject) => { + resolve(paramMock.paramBooleanMock); + }) + } + }, } return inputMethod } \ No newline at end of file diff --git a/runtime/main/extend/systemplugin/napi/ohos_inputmethodengine.js b/runtime/main/extend/systemplugin/napi/ohos_inputmethodengine.js index 7024338b..d7722b82 100644 --- a/runtime/main/extend/systemplugin/napi/ohos_inputmethodengine.js +++ b/runtime/main/extend/systemplugin/napi/ohos_inputmethodengine.js @@ -15,36 +15,6 @@ import { paramMock } from "../utils" -const NOTIFY = "[PC Preview] unknow" -const Properties = [ - 'ENTER_KEY_TYPE_NEXT', - 'ENTER_KEY_TYPE_PREVIOUS', - 'ENTER_KEY_TYPE_UNSPECIFIED', - 'ENTER_KEY_TYPE_SEARCH', - 'ENTER_KEY_TYPE_GO', - 'ENTER_KEY_TYPE_SEND', - 'ENTER_KEY_TYPE_DONE', - 'DISPLAY_MODE_PART', - 'DISPLAY_MODE_FULL', - 'OPTION_AUTO_CAP_CHARACTERS', - 'OPTION_AUTO_CAP_WORDS', - 'OPTION_AUTO_CAP_SENTENCES', - 'OPTION_NO_FULLSCREEN', - 'OPTION_ASCII', - 'OPTION_NONE', - 'OPTION_MULTI_LINE', - 'FLAG_SINGLE_LINE', - 'FLAG_SELECTING', - 'PATTERN_TEXT', - 'PATTERN_NUMBER', - 'PATTERN_NULL', - 'PATTERN_PHONE', - 'PATTERN_DATETIME', - 'PATTERN_URI', - 'PATTERN_EMAIL', - 'PATTERN_PASSWORD' -] - export function mockInputMethodEngine() { const EditingText = { textContent: "[PC Preview] unknow textContent", @@ -65,6 +35,10 @@ export function mockInputMethodEngine() { enterKeyType: 2, inputOption: 3 } + const KeyEvent = { + keyCode: "[PC Preview] unknow keyCode", + keyAction: "[PC Preview] unknow keyAction" + } const RichContent = { contentURI: "[PC Preview] unknow contentURI", linkURI: "[PC Preview] unknow linkURI", @@ -376,7 +350,7 @@ export function mockInputMethodEngine() { const len = args.length if (typeof args[len - 1] === 'function') { if (args[0] == 'keyDown' || args[0] == 'keyUp') { - args[len - 1].call(this, paramMock.paramObjectMock); + args[len - 1].call(this, KeyEvent); } else if (args[0] == 'selectionChange') { args[len - 1].call(this, paramMock.paramNumberMock, paramMock.paramNumberMock, paramMock.paramNumberMock, paramMock.paramNumberMock); } else if (args[0] == 'cursorContextChange') { @@ -413,11 +387,33 @@ export function mockInputMethodEngine() { console.warn("inputMethodEngine.createKeyboardDelegate interface mocked in the Previewer. How this interface works" + " on the Previewer may be different from that on a real device.") return KeyboardDelegateMock; - } - } - - for (let Property of Properties) { - inputMethodEngine[Property] = NOTIFY + " " + Property + }, + ENTER_KEY_TYPE_UNSPECIFIED: "[PC Preview] unknow ENTER_KEY_TYPE_UNSPECIFIED", + ENTER_KEY_TYPE_GO: "[PC Preview] unknow ENTER_KEY_TYPE_GO", + ENTER_KEY_TYPE_SEARCH: "[PC Preview] unknow ENTER_KEY_TYPE_SEARCH", + ENTER_KEY_TYPE_SEND: "[PC Preview] unknow ENTER_KEY_TYPE_SEND", + ENTER_KEY_TYPE_NEXT: "[PC Preview] unknow ENTER_KEY_TYPE_NEXT", + ENTER_KEY_TYPE_DONE: "[PC Preview] unknow ENTER_KEY_TYPE_DONE", + ENTER_KEY_TYPE_PREVIOUS: "[PC Preview] unknow ENTER_KEY_TYPE_PREVIOUS", + PATTERN_NULL: "[PC Preview] unknow PATTERN_NULL", + PATTERN_TEXT: "[PC Preview] unknow PATTERN_TEXT", + PATTERN_NUMBER: "[PC Preview] unknow PATTERN_NUMBER", + PATTERN_PHONE: "[PC Preview] unknow PATTERN_PHONE", + PATTERN_DATETIME: "[PC Preview] unknow PATTERN_DATETIME", + PATTERN_EMAIL: "[PC Preview] unknow PATTERN_EMAIL", + PATTERN_URI: "[PC Preview] unknow PATTERN_URI", + PATTERN_PASSWORD: "[PC Preview] unknow PATTERN_PASSWORD", + FLAG_SELECTING: "[PC Preview] unknow FLAG_SELECTING", + FLAG_SINGLE_LINE: "[PC Preview] unknow FLAG_SINGLE_LINE", + DISPLAY_MODE_PART: "[PC Preview] unknow DISPLAY_MODE_PART", + DISPLAY_MODE_FULL: "[PC Preview] unknow DISPLAY_MODE_FULL", + OPTION_ASCII: "[PC Preview] unknow OPTION_ASCII", + OPTION_NONE: "[PC Preview] unknow OPTION_NONE", + OPTION_AUTO_CAP_CHARACTERS: "[PC Preview] unknow OPTION_AUTO_CAP_CHARACTERS", + OPTION_AUTO_CAP_SENTENCES: "[PC Preview] unknow OPTION_AUTO_CAP_SENTENCES", + OPTION_AUTO_WORDS: "[PC Preview] unknow OPTION_AUTO_WORDS", + OPTION_MULTI_LINE: "[PC Preview] unknow OPTION_MULTI_LINE", + OPTION_NO_FULLSCREEN: "[PC Preview] unknow OPTION_NO_FULLSCREEN" } return inputMethodEngine } \ No newline at end of file diff --git a/runtime/main/extend/systemplugin/napi/ohos_mediaquery.js b/runtime/main/extend/systemplugin/napi/ohos_mediaquery.js deleted file mode 100644 index 2045071f..00000000 --- a/runtime/main/extend/systemplugin/napi/ohos_mediaquery.js +++ /dev/null @@ -1,40 +0,0 @@ -/* - * Copyright (c) 2021 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 mockMediaQuery() { - const mediaquery = { - matchMediaSync: function (...args) { - console.warn("mediaquery.matchMediaSync interface mocked in the Previewer." + - " How this interface works on the Previewer may be different from that on a real device.") - var listener = { - on: function (...args) { - console.warn("listener.on interface mocked in the Previewer." + - " How this interface works on the Previewer may be different from that on a real device.") - }, - off: function (...args) { - console.warn("listener.off interface mocked in the Previewer." + - " How this interface works on the Previewer may be different from that on a real device.") - }, - matches: false, - media: String - }; - if (args.length === 1 && typeof args[0] === 'string') { - listener.media = args[0]; - } - return listener; - } - } - return mediaquery -} \ No newline at end of file diff --git a/runtime/main/extend/systemplugin/napi/ohos_multimedia_audio.js b/runtime/main/extend/systemplugin/napi/ohos_multimedia_audio.js index a85b21bc..8de8a9c0 100644 --- a/runtime/main/extend/systemplugin/napi/ohos_multimedia_audio.js +++ b/runtime/main/extend/systemplugin/napi/ohos_multimedia_audio.js @@ -16,84 +16,113 @@ import { paramMock } from "../utils" export function mockMultimediaAudio() { - const interruptActionMock = { + const interruptAction = { actionType: "[PC Preview] unknow actionType", type: "[PC Preview] unknow type", hint: "[PC Preview] unknow hint", activated: "[PC Preview] unknow activated", } - const DeviceRoleMock = "[PC Preview] unknow DeviceRole" - const DeviceTypeMock = "[PC Preview] unknow DeviceType" - const AudioDeviceDescriptorMock = { - deviceRole: DeviceRoleMock, - deviceType: DeviceTypeMock, + const DeviceRole = "[PC Preview] unknow DeviceRole" + const DeviceType = "[PC Preview] unknow DeviceType" + const AudioDeviceDescriptor = { + deviceRole: DeviceRole, + deviceType: DeviceType, + id: "[PC Preview] unknow id", + name: "[PC Preview] unknow name", + address: "[PC Preview] unknow address", + sampleRates: [paramMock.paramNumberMock], + channelCounts: [paramMock.paramNumberMock], + channelMasks: [paramMock.paramNumberMock], } - const DeviceChangeActionMock = { + const DeviceChangeAction = { type: "[PC Preview] unknow type", - deviceDescriptors: AudioDeviceDescriptorMock, + deviceDescriptors: AudioDeviceDescriptor, } - const AudioRingModeMock = '[PC Preview] unknow AudioRingMode' - const VolumeEventMock = { + const AudioRingMode = '[PC Preview] unknow AudioRingMode' + const VolumeEvent = { volumeType: "[PC Preview] unknow volumeType", volume: "[PC Preview] unknow volume", updateUi: "[PC Preview] unknow updateUi", } - const AudioSceneMock = '[PC Preview] unknow AudioScene' - const AudioStreamInfoMock = { + const AudioScene = '[PC Preview] unknow AudioScene' + const AudioStreamInfo = { samplingRate: "[PC Preview] unknow samplingRate", channels: "[PC Preview] unknow channels", sampleFormat: "[PC Preview] unknow sampleFormat", encodingType: "[PC Preview] unknow encodingType", } - const AudioRendererInfoMock = { + const AudioRendererInfo = { content: "[PC Preview] unknow content", usage: "[PC Preview] unknow usage", rendererFlags: "[PC Preview] unknow rendererFlags", } - const AudioRendererOptionsMock = { - streamInfo: AudioStreamInfoMock, - rendererInfo: AudioRendererInfoMock, + const AudioRendererOptions = { + streamInfo: AudioStreamInfo, + rendererInfo: AudioRendererInfo, } - const AudioCapturerInfoMock = { + const AudioCapturerInfo = { source: "[PC Preview] unknow source", capturerFlags: "[PC Preview] unknow capturerFlags", } - const AudioCapturerOptionsMock = { - streamInfo: AudioStreamInfoMock, - capturerInfo: AudioCapturerInfoMock, + const AudioCapturerOptions = { + streamInfo: AudioStreamInfo, + capturerInfo: AudioCapturerInfo, } - const AudioStateMock = '[PC Preview] unknow AudioState' - const AudioRendererRateMock = '[PC Preview] unknow AudioRendererRate' - const InterruptEventMock = '[PC Preview] unknow InterruptEvent' - const AudioCapturerMock = { + const AudioState = '[PC Preview] unknow AudioState' + const AudioRendererRate = '[PC Preview] unknow AudioRendererRate' + const InterruptEvent = { + eventType: "[PC Preview] unknow eventType", + forceType: "[PC Preview] unknow forceType", + hintType: "[PC Preview] unknow hintType", + } + const AudioInterrupt = { + streamUsage: "[PC Preview] unknow streamUsage", + contentType: "[PC Preview] unknow contentType", + pauseWhenDucked: "[PC Preview] unknow pauseWhenDucked", + } + const AudioRendererChangeInfo = { + streamId: "[PC Preview] unknow streamId", + clientUid: "[PC Preview] unknow clientUid", + rendererInfo: AudioRendererInfo, + rendererState: AudioState, + deviceDescriptors: [AudioDeviceDescriptor], + } + const AudioCapturerChangeInfo = { + streamId: "[PC Preview] unknow streamId", + clientUid: "[PC Preview] unknow clientUid", + capturerInfo: AudioRendererInfo, + capturerState: AudioState, + deviceDescriptors: [AudioDeviceDescriptor], + } + const AudioCapturer = { state: "[PC Preview] unknow state", getCapturerInfo: function (...args) { - console.warn("AudioCapturer.getCapturerInfo interface mocked in the Previewer. How this interface works on the" + - " Previewer may be different from that on a real device.") + console.warn("AudioCapturer.getCapturerInfo 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, AudioCapturerInfoMock); + args[len - 1].call(this, paramMock.businessErrorMock, AudioCapturerInfo); } else { return new Promise((resolve, reject) => { - resolve(AudioCapturerInfoMock); + resolve(AudioCapturerInfo); }) } }, getStreamInfo: function (...args) { - console.warn("AudioCapturer.getStreamInfo interface mocked in the Previewer. How this interface works on the" + - " Previewer may be different from that on a real device.") + console.warn("AudioCapturer.getStreamInfo 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, AudioStreamInfoMock); + args[len - 1].call(this, paramMock.businessErrorMock, AudioStreamInfo); } else { return new Promise((resolve, reject) => { - resolve(AudioStreamInfoMock); + resolve(AudioStreamInfo); }) } }, start: function (...args) { - console.warn("AudioCapturer.start interface mocked in the Previewer. How this interface works on the" + - " Previewer may be different from that on a real device.") + console.warn("AudioCapturer.start 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); @@ -104,8 +133,8 @@ export function mockMultimediaAudio() { } }, read: function (...args) { - console.warn("AudioCapturer.read interface mocked in the Previewer. How this interface works on the" + - " Previewer may be different from that on a real device.") + console.warn("AudioCapturer.read 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); @@ -116,8 +145,8 @@ export function mockMultimediaAudio() { } }, getAudioTime: function (...args) { - console.warn("AudioCapturer.getAudioTime interface mocked in the Previewer. How this interface works on the" + - " Previewer may be different from that on a real device.") + console.warn("AudioCapturer.getAudioTime 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); @@ -128,8 +157,8 @@ export function mockMultimediaAudio() { } }, stop: function (...args) { - console.warn("AudioCapturer.stop interface mocked in the Previewer. How this interface works on the" + - " Previewer may be different from that on a real device.") + console.warn("AudioCapturer.stop 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); @@ -140,8 +169,8 @@ export function mockMultimediaAudio() { } }, release: function (...args) { - console.warn("AudioCapturer.release interface mocked in the Previewer. How this interface works on the" + - " Previewer may be different from that on a real device.") + console.warn("AudioCapturer.release 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); @@ -152,8 +181,8 @@ export function mockMultimediaAudio() { } }, getBufferSize: function (...args) { - console.warn("AudioCapturer.getBufferSize interface mocked in the Previewer. How this interface works on the" + - " Previewer may be different from that on a real device.") + console.warn("AudioCapturer.getBufferSize 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); @@ -164,43 +193,43 @@ export function mockMultimediaAudio() { } }, on: function (...args) { - console.warn("AudioCapturer.on interface mocked in the Previewer. How this interface works on the Previewer" + - " may be different from that on a real device.") + console.warn("AudioCapturer.on interface mocked in the Previewer." + + " How this interface works on the Previewer may be different from that on a real device.") }, off: function (...args) { - console.warn("AudioCapturer.off interface mocked in the Previewer. How this interface works on the Previewer" + - " may be different from that on a real device.") + console.warn("AudioCapturer.off interface mocked in the Previewer." + + " How this interface works on the Previewer may be different from that on a real device.") }, } - const AudioRendererMock ={ + const AudioRenderer = { state: "[PC Preview] unknow state", getRendererInfo: function (...args) { - console.warn("AudioRenderer.getRendererInfo interface mocked in the Previewer. How this interface works on the" + - " Previewer may be different from that on a real device.") + console.warn("AudioRenderer.getRendererInfo 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, AudioRendererInfoMock); + args[len - 1].call(this, paramMock.businessErrorMock, AudioRendererInfo); } else { return new Promise((resolve, reject) => { - resolve(AudioRendererInfoMock); + resolve(AudioRendererInfo); }) } }, getStreamInfo: function (...args) { - console.warn("AudioRenderer.getStreamInfo interface mocked in the Previewer. How this interface works on the" + - " Previewer may be different from that on a real device.") + console.warn("AudioRenderer.getStreamInfo 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, AudioStreamInfoMock); + args[len - 1].call(this, paramMock.businessErrorMock, AudioStreamInfo); } else { return new Promise((resolve, reject) => { - resolve(AudioStreamInfoMock); + resolve(AudioStreamInfo); }) } }, start: function (...args) { - console.warn("AudioRenderer.start interface mocked in the Previewer. How this interface works on the" + - " Previewer may be different from that on a real device.") + console.warn("AudioRenderer.start 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); @@ -211,8 +240,8 @@ export function mockMultimediaAudio() { } }, write: function (...args) { - console.warn("AudioRenderer.write interface mocked in the Previewer. How this interface works on the" + - " Previewer may be different from that on a real device.") + console.warn("AudioRenderer.write 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); @@ -223,8 +252,8 @@ export function mockMultimediaAudio() { } }, getAudioTime: function (...args) { - console.warn("AudioRenderer.getAudioTime interface mocked in the Previewer. How this interface works on the" + - " Previewer may be different from that on a real device.") + console.warn("AudioRenderer.getAudioTime 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); @@ -235,8 +264,8 @@ export function mockMultimediaAudio() { } }, drain: function (...args) { - console.warn("AudioRenderer.drain interface mocked in the Previewer. How this interface works on the" + - " Previewer may be different from that on a real device.") + console.warn("AudioRenderer.drain 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); @@ -247,8 +276,8 @@ export function mockMultimediaAudio() { } }, pause: function (...args) { - console.warn("AudioRenderer.pause interface mocked in the Previewer. How this interface works on the" + - " Previewer may be different from that on a real device.") + console.warn("AudioRenderer.pause 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); @@ -259,8 +288,8 @@ export function mockMultimediaAudio() { } }, stop: function (...args) { - console.warn("AudioRenderer.stop interface mocked in the Previewer. How this interface works on the" + - " Previewer may be different from that on a real device.") + console.warn("AudioRenderer.stop 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); @@ -271,8 +300,8 @@ export function mockMultimediaAudio() { } }, release: function (...args) { - console.warn("AudioRenderer.release interface mocked in the Previewer. How this interface works on the" + - " Previewer may be different from that on a real device.") + console.warn("AudioRenderer.release 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); @@ -283,8 +312,8 @@ export function mockMultimediaAudio() { } }, getBufferSize: function (...args) { - console.warn("AudioRenderer.getBufferSize interface mocked in the Previewer. How this interface works on the" + - " Previewer may be different from that on a real device.") + console.warn("AudioRenderer.getBufferSize 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); @@ -295,8 +324,8 @@ export function mockMultimediaAudio() { } }, setRenderRate: function (...args) { - console.warn("AudioRenderer.setRenderRate interface mocked in the Previewer. How this interface works on the" + - " Previewer may be different from that on a real device.") + console.warn("AudioRenderer.setRenderRate 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); @@ -307,28 +336,28 @@ export function mockMultimediaAudio() { } }, getRenderRate: function (...args) { - console.warn("AudioRenderer.getRenderRate interface mocked in the Previewer. How this interface works on the" + - " Previewer may be different from that on a real device.") + console.warn("AudioRenderer.getRenderRate 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, AudioRendererRateMock); + args[len - 1].call(this, paramMock.businessErrorMock, AudioRendererRate); } else { return new Promise((resolve, reject) => { - resolve(AudioRendererRateMock); + resolve(AudioRendererRate); }) } }, on: function (...args) { - console.warn("AudioRenderer.on interface mocked in the Previewer. How this interface works on the Previewer" + - " may be different from that on a real device.") + console.warn("AudioRenderer.on interface mocked in the Previewer." + + " How this interface works on the Previewer may be different from that on a real device.") }, off: function (...args) { - console.warn("AudioRenderer.off interface mocked in the Previewer. How this interface works on the Previewer" + - " may be different from that on a real device.") + console.warn("AudioRenderer.off interface mocked in the Previewer." + + " How this interface works on the Previewer may be different from that on a real device.") }, setInterruptMode: function (...args) { - console.warn("AudioRenderer.setInterruptMode interface mocked in the Previewer. How this interface works on the" + - " Previewer may be different from that on a real device.") + console.warn("AudioRenderer.setInterruptMode 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); @@ -339,31 +368,31 @@ export function mockMultimediaAudio() { } } } - const audioManagerMock = { + const AudioManager = { on: function (...args) { - console.warn("AudioManager.on interface mocked in the Previewer. How this interface works on the Previewer" + - " may be different from that on a real device.") + console.warn("AudioManager.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] == 'interrupt') { - args[len - 1].call(this, interruptActionMock); + args[len - 1].call(this, interruptAction); } else if (args[0] == 'deviceChange') { - args[len - 1].call(this, DeviceChangeActionMock); + args[len - 1].call(this, DeviceChangeAction); } else if (args[0] == 'volumeChange') { - args[len - 1].call(this, VolumeEventMock); + args[len - 1].call(this, VolumeEvent); } else if (args[0] == 'ringerModeChange') { - args[len - 1].call(this, AudioRingModeMock); + args[len - 1].call(this, AudioRingMode); } } }, off: function (...args) { - console.warn("AudioManager.off interface mocked in the Previewer. How this interface works on the Previewer" + - " may be different from that on a real device.") + console.warn("AudioManager.off interface mocked in the Previewer." + + " How this interface works on the Previewer may be different from that on a real device.") }, getDevices: function (...args) { - console.warn("AudioManager.getDevices interface mocked in the Previewer. How this interface works on the" + - " Previewer may be different from that on a real device.") - var AudioDeviceDescriptors = new Array(AudioDeviceDescriptorMock) + console.warn("AudioManager.getDevices interface mocked in the Previewer." + + " How this interface works on the Previewer may be different from that on a real device.") + var AudioDeviceDescriptors = new Array(AudioDeviceDescriptor) const len = args.length if (typeof args[len - 1] === 'function') { args[len - 1].call(this, paramMock.businessErrorMock, AudioDeviceDescriptors); @@ -374,8 +403,8 @@ export function mockMultimediaAudio() { } }, isDeviceActive: function (...args) { - console.warn("AudioManager.isDeviceActive interface mocked in the Previewer. How this interface works on" + - " the Previewer may be different from that on a real device.") + console.warn("AudioManager.isDeviceActive 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); @@ -386,8 +415,8 @@ export function mockMultimediaAudio() { } }, setDeviceActive: function (...args) { - console.warn("AudioManager.setDeviceActive interface mocked in the Previewer. How this interface works on the" + - " Previewer may be different from that on a real device.") + console.warn("AudioManager.setDeviceActive 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); @@ -398,8 +427,8 @@ export function mockMultimediaAudio() { } }, setRingerMode: function (...args) { - console.warn("AudioManager.setRingerMode interface mocked in the Previewer. How this interface works on the" + - " Previewer may be different from that on a real device.") + console.warn("AudioManager.setRingerMode 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); @@ -410,8 +439,8 @@ export function mockMultimediaAudio() { } }, setAudioParameter: function (...args) { - console.warn("AudioManager.setAudioParameter interface mocked in the Previewer. How this interface works on the" + - " Previewer may be different from that on a real device.") + console.warn("AudioManager.setAudioParameter 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); @@ -422,8 +451,8 @@ export function mockMultimediaAudio() { } }, setVolume: function (...args) { - console.warn("AudioManager.setVolume interface mocked in the Previewer. How this interface works on the" + - " Previewer may be different from that on a real device.") + console.warn("AudioManager.setVolume 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); @@ -434,8 +463,8 @@ export function mockMultimediaAudio() { } }, getVolume: function (...args) { - console.warn("AudioManager.getVolume interface mocked in the Previewer. How this interface works on the" + - " Previewer may be different from that on a real device.") + console.warn("AudioManager.getVolume 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); @@ -446,8 +475,8 @@ export function mockMultimediaAudio() { } }, getMinVolume: function (...args) { - console.warn("AudioManager.getMinVolume interface mocked in the Previewer. How this interface works on the" + - " Previewer may be different from that on a real device.") + console.warn("AudioManager.getMinVolume 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); @@ -458,8 +487,8 @@ export function mockMultimediaAudio() { } }, getMaxVolume: function (...args) { - console.warn("AudioManager.getMaxVolume interface mocked in the Previewer. How this interface works on the" + - " Previewer may be different from that on a real device.") + console.warn("AudioManager.getMaxVolume 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); @@ -470,8 +499,8 @@ export function mockMultimediaAudio() { } }, isMute: function (...args) { - console.warn("AudioManager.isMute interface mocked in the Previewer. How this interface works on the" + - " Previewer may be different from that on a real device.") + console.warn("AudioManager.isMute 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); @@ -482,8 +511,8 @@ export function mockMultimediaAudio() { } }, mute: function (...args) { - console.warn("AudioManager.mute interface mocked in the Previewer. How this interface works on the" + - " Previewer may be different from that on a real device.") + console.warn("AudioManager.mute 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); @@ -494,8 +523,8 @@ export function mockMultimediaAudio() { } }, isActive: function (...args) { - console.warn("AudioManager.isActive interface mocked in the Previewer. How this interface works on the" + - " Previewer may be different from that on a real device.") + console.warn("AudioManager.isActive 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); @@ -506,8 +535,8 @@ export function mockMultimediaAudio() { } }, isMicrophoneMute: function (...args) { - console.warn("AudioManager.isMicrophoneMute interface mocked in the Previewer. How this interface works on the" + - " Previewer may be different from that on a real device.") + console.warn("AudioManager.isMicrophoneMute 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); @@ -518,8 +547,8 @@ export function mockMultimediaAudio() { } }, setMicrophoneMute: function (...args) { - console.warn("AudioManager.setMicrophoneMute interface mocked in the Previewer. How this interface works on the" + - " Previewer may be different from that on a real device.") + console.warn("AudioManager.setMicrophoneMute 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); @@ -530,8 +559,8 @@ export function mockMultimediaAudio() { } }, getAudioParameter: function (...args) { - console.warn("AudioManager.getAudioParameter interface mocked in the Previewer. How this interface works on the" + - " Previewer may be different from that on a real device.") + console.warn("AudioManager.getAudioParameter 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); @@ -542,20 +571,20 @@ export function mockMultimediaAudio() { } }, getRingerMode: function (...args) { - console.warn("AudioManager.getRingerMode interface mocked in the Previewer. How this interface works on the" + - " Previewer may be different from that on a real device.") + console.warn("AudioManager.getRingerMode 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, AudioRingModeMock); + args[len - 1].call(this, paramMock.businessErrorMock, AudioRingMode); } else { return new Promise((resolve, reject) => { - resolve(AudioRingModeMock); + resolve(AudioRingMode); }) } }, setAudioScene: function (...args) { - console.warn("AudioManager.setAudioScene interface mocked in the Previewer. How this interface works on the" + - " Previewer may be different from that on a real device.") + console.warn("AudioManager.setAudioScene 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); @@ -566,20 +595,20 @@ export function mockMultimediaAudio() { } }, getAudioScene: function (...args) { - console.warn("AudioManager.getAudioScene interface mocked in the Previewer. How this interface works on the" + - " Previewer may be different from that on a real device.") + console.warn("AudioManager.getAudioScene 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, AudioSceneMock); + args[len - 1].call(this, paramMock.businessErrorMock, AudioScene); } else { return new Promise((resolve, reject) => { - resolve(AudioSceneMock); + resolve(AudioScene); }) } }, requestIndependentInterrupt: function (...args) { - console.warn("AudioManager.requestIndependentInterrupt interface mocked in the Previewer. How this interface works on the" + - " Previewer may be different from that on a real device.") + console.warn("AudioManager.requestIndependentInterrupt 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); @@ -590,8 +619,8 @@ export function mockMultimediaAudio() { } }, abandonIndependentInterrupt: function (...args) { - console.warn("AudioManager.abandonIndependentInterrupt interface mocked in the Previewer. How this interface works on the" + - " Previewer may be different from that on a real device.") + console.warn("AudioManager.abandonIndependentInterrupt 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); @@ -600,6 +629,62 @@ export function mockMultimediaAudio() { resolve(paramMock.paramBooleanMock); }) } + }, + getStreamManager: function (...args) { + console.warn("AudioManager.getStreamManager 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, AudioStreamManager); + } else { + return new Promise((resolve, reject) => { + resolve(AudioStreamManager); + }) + } + } + } + const AudioStreamManager = { + on: function (...args) { + const len = args.length + if (typeof args[len - 1] === 'function') { + if (args[0] == 'audioRendererChange') { + console.warn("AudioStreamManager.on_audioRendererChange interface mocked in the Previewer." + + " How this interface works on the Previewer may be different from that on a real device.") + } else if (args[0] == 'audioCapturerChange') { + console.warn("AudioStreamManager.on_audioCapturerChange interface mocked in the Previewer." + + " How this interface works on the Previewer may be different from that on a real device.") + } + } + }, + off: function (...args) { + console.warn("AudioStreamManager.off interface mocked in the Previewer." + + " How this interface works on the Previewer may be different from that on a real device.") + }, + getCurrentAudioRendererInfoArray: function (...args) { + console.warn("AudioStreamManager.getCurrentAudioRendererInfoArray interface mocked in the Previewer." + + " How this interface works on the Previewer may be different from that on a real device.") + var AudioRendererChangeInfoArray = new Array(AudioRendererChangeInfo) + const len = args.length + if (typeof args[len - 1] === 'function') { + args[len - 1].call(this, paramMock.businessErrorMock, AudioRendererChangeInfoArray); + } else { + return new Promise((resolve, reject) => { + resolve(AudioRendererChangeInfoArray); + }) + } + }, + getCurrentAudioCapturerInfoArray: function (...args) { + console.warn("AudioStreamManager.getCurrentAudioCapturerInfoArray interface mocked in the Previewer." + + " How this interface works on the Previewer may be different from that on a real device.") + var AudioCapturerChangeInfoArray = new Array(AudioCapturerChangeInfo) + const len = args.length + if (typeof args[len - 1] === 'function') { + args[len - 1].call(this, paramMock.businessErrorMock, AudioCapturerChangeInfoArray); + } else { + return new Promise((resolve, reject) => { + resolve(AudioCapturerChangeInfoArray); + }) + } } } const audio = { @@ -653,6 +738,7 @@ export function mockMultimediaAudio() { SAMPLE_FORMAT_S16LE: 1, SAMPLE_FORMAT_S24LE: 2, SAMPLE_FORMAT_S32LE: 3, + SAMPLE_FORMAT_F32LE: 4, }, AudioChannel: { CHANNEL_1: 1, @@ -691,13 +777,6 @@ export function mockMultimediaAudio() { AUDIO_SCENE_PHONE_CALL: 2, AUDIO_SCENE_VOICE_CHAT: 3, }, - AudioSampleFormat: { - SAMPLE_FORMAT_INVALID: -1, - SAMPLE_FORMAT_U8: 0, - SAMPLE_FORMAT_S16LE: 1, - SAMPLE_FORMAT_S24LE: 2, - SAMPLE_FORMAT_S32LE: 3, - }, InterruptType: { INTERRUPT_TYPE_BEGIN: 1, INTERRUPT_TYPE_END: 2, @@ -714,31 +793,31 @@ export function mockMultimediaAudio() { INDEPENDENT_MODE: 1 }, getAudioManager: function () { - console.warn("audio.getAudioManager interface mocked in the Previewer. How this interface works" + - " on the Previewer may be different from that on a real device.") - return audioManagerMock; + console.warn("audio.getAudioManager interface mocked in the Previewer." + + " How this interface works on the Previewer may be different from that on a real device.") + return AudioManager; }, createAudioCapturer: function (...args) { - console.warn("audio.createAudioCapturer interface mocked in the Previewer. How this interface works on the" + - " Previewer may be different from that on a real device.") + console.warn("audio.createAudioCapturer 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, AudioCapturerMock); + args[len - 1].call(this, paramMock.businessErrorMock, AudioCapturer); } else { return new Promise((resolve, reject) => { - resolve(AudioCapturerMock); + resolve(AudioCapturer); }) } }, createAudioRenderer: function (...args) { - console.warn("audio.createAudioRenderer interface mocked in the Previewer. How this interface works on the" + - " Previewer may be different from that on a real device.") + console.warn("audio.createAudioRenderer 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, AudioRendererMock); + args[len - 1].call(this, paramMock.businessErrorMock, AudioRenderer); } else { return new Promise((resolve, reject) => { - resolve(AudioRendererMock); + resolve(AudioRenderer); }) } } diff --git a/runtime/main/extend/systemplugin/napi/ohos_multimedia_av_session.js b/runtime/main/extend/systemplugin/napi/ohos_multimedia_av_session.js new file mode 100644 index 00000000..8cf529a9 --- /dev/null +++ b/runtime/main/extend/systemplugin/napi/ohos_multimedia_av_session.js @@ -0,0 +1,436 @@ +/* + * 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 mockMultimediaAVSession() { + const AVMetadata = { + assetId: "[PC Preview] unknow assetId", + title: "[PC Preview] unknow title", + artist: "[PC Preview] unknow artist", + author: "[PC Preview] unknow author", + album: "[PC Preview] unknow album", + writer: "[PC Preview] unknow writer", + composer: "[PC Preview] unknow composer", + duration: "[PC Preview] unknow duration", + mediaImage: "[PC Preview] unknow mediaImage", + publishDate: "[PC Preview] unknow publishDate", + subtitle: "[PC Preview] unknow subtitle", + description: "[PC Preview] unknow description", + lyric: "[PC Preview] unknow lyric", + previousAssetId: "[PC Preview] unknow previousAssetId", + nextAssetId: "[PC Preview] unknow nextAssetId" + } + + const AVPlaybackState = { + state: "[PC Preview] unknow state", + speed: "[PC Preview] unknow speed", + position: PlaybackPosition, + bufferedTime: "[PC Preview] unknow bufferedTime", + loopMode: "[PC Preview] unknow loopMode", + isFavorite: "[PC Preview] unknow isFavorite" + } + + const PlaybackPosition = { + elapsedTime: "[PC Preview] unknow elapsedTime", + updateTime: "[PC Preview] unknow updateTime" + } + + const OutputDeviceInfo = { + isRemote: "[PC Preview] unknow isRemote", + deviceId: [paramMock.paramStringMock], + deviceName: [paramMock.paramStringMock] + } + + const AVSessionDescriptor = { + sessionId: "[PC Preview] unknow sessionId", + type: "[PC Preview] unknow type", + sessionTag: "[PC Preview] unknow sessionTag", + elementName: "[PC Preview] unknow elementName", + isActive: "[PC Preview] unknow isActive", + isTopSession: "[PC Preview] unknow isTopSession", + outputDevice: + "[PC Preview] unknow outputDevice" + } + + const AVControlCommandType = ['play', 'pause', 'stop', 'playNext', 'playPrevious', 'fastForward', 'rewind', 'seek', 'setSpeed', 'setLoopMode', 'toggleFavorite']; + + const AVSession = { + sessionId: "[PC Preview] unknow sessionId", + setAVMetadata: function (...args) { + console.warn("AVSession.setAVMetadata 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(); + }) + } + }, + setAVPlaybackState: function (...args) { + console.warn("AVSession.setAVPlaybackState 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(); + }) + } + }, + setLaunchAbility: function (...args) { + console.warn("AVSession.setLaunchAbility 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(); + }) + } + }, + setAudioStreamId: function (...args) { + console.warn("AVSession.setAudioStreamId 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(); + }) + } + }, + getController: function (...args) { + console.warn("AVSession.getController 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, AVSessionController); + } else { + return new Promise((resolve, reject) => { + resolve(AVSessionController); + }) + } + }, + getOutputDevice: function (...args) { + console.warn("AVSession.getOutputDevice 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, OutputDeviceInfo); + } else { + return new Promise((resolve, reject) => { + resolve(OutputDeviceInfo); + }) + } + }, + on: function (...args) { + console.warn("AVSession.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 (args[0] == 'play' || args[0] == 'pause' ||args[0] == 'stop' ||args[0] == 'playNext' + ||args[0] == 'playPrevious' ||args[0] == 'fastForward' ||args[0] == 'rewind') { + args[len - 1].call(this); + } else if(args[0] == 'seek' || args[0] == 'setSpeed') { + args[len - 1].call(this, paramMock.paramNumberMock); + } else if(args[0] == 'setLoopMode') { + var loopMode = "[PC Preview] unknow LoopMode"; + args[len - 1].call(this, loopMode); + } else if(args[0] == 'toggleFavorite') { + args[len - 1].call(this, paramMock.paramStringMock); + } else if(args[0] == 'handleKeyEvent') { + args[len - 1].call(this, paramMock.paramObjectMock); + } else if(args[0] == 'outputDeviceChanged') { + args[len - 1].call(this, OutputDeviceInfo); + } + }, + off: function (...args) { + console.warn("AVSession.off interface mocked in the Previewer. How this interface works on the Previewer" + + " may be different from that on a real device.") + }, + activate: function (...args) { + console.warn("AVSession.activate 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(); + }) + } + }, + deactivate: function (...args) { + console.warn("AVSession.deactivate 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(); + }) + } + }, + destroy: function (...args) { + console.warn("AVSession.destroy 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(); + }) + } + } + } + + const AVSessionController = { + sessionId: "[PC Preview] unknow sessionId", + getAVPlaybackState: function (...args) { + console.warn("AVSessionController.getAVPlaybackState 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, AVPlaybackState); + } else { + return new Promise((resolve, reject) => { + resolve(AVPlaybackState); + }) + } + }, + getAVMetadata: function (...args) { + console.warn("AVSessionController.getAVMetadata 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, AVMetadata); + } else { + return new Promise((resolve, reject) => { + resolve(AVMetadata); + }) + } + }, + getOutputDevice: function (...args) { + console.warn("AVSessionController.getOutputDevice 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, OutputDeviceInfo); + } else { + return new Promise((resolve, reject) => { + resolve(OutputDeviceInfo); + }) + } + }, + sendAVKeyEvent: function (...args) { + console.warn("AVSessionController.sendAVKeyEvent 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(); + }) + } + }, + getLaunchAbility: function (...args) { + console.warn("AVSessionController.getLaunchAbility 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.paramObjectMock); + } else { + return new Promise((resolve, reject) => { + resolve(paramMock.paramObjectMock); + }) + } + }, + getRealPlaybackPositionSync: function (...args) { + console.warn("AVSessionController.getRealPlaybackPositionSync interface mocked in the Previewer. How this interface works on the Previewer" + + " may be different from that on a real device.") + return paramMock.paramNumberMock; + }, + isActive: function (...args) { + console.warn("AVSessionController.isActive 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, reject) => { + resolve(paramMock.paramBooleanMock); + }) + } + }, + destroy: function (...args) { + console.warn("AVSessionController.destroy 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(); + }) + } + }, + getValidCommands: function (...args) { + console.warn("AVSessionController.getValidCommands 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, AVControlCommandType); + } else { + return new Promise((resolve, reject) => { + resolve(AVControlCommandType); + }) + } + }, + sendControlCommand: function (...args) { + console.warn("AVSessionController.sendControlCommand 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(); + }) + } + }, + on: function (...args) { + console.warn("AVSessionController.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 (args[0] == 'metadataChanged') { + args[len-1].call(this, AVMetadata); + } else if (args[0] == 'playbackStateChanged') { + args[len-1].call(this, AVPlaybackState); + } else if (args[0] == 'sessionDestroyed') { + args[len-1].call(this); + } else if (args[0] == 'activeStateChanged') { + args[len-1].call(this, paramMock.paramBooleanMock); + } else if (args[0] == 'validCommandChanged') { + args[len-1].call(this, AVControlCommandType); + } else if (args[0] == 'outputDeviceChanged') { + args[len-1].call(this, OutputDeviceInfo); + } + }, + off: function (...args) { + console.warn("AVSessionController.off interface mocked in the Previewer. How this interface works on the Previewer" + + " may be different from that on a real device.") + } + } + + const avsession = { + createAVSession: function (...args) { + console.warn("AVSession.createAVSession 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, AVSession); + } else { + return new Promise((resolve, reject) => { + resolve(AVSession); + }) + } + + }, + getAllSessionDescriptors: function (...args) { + console.warn("AVSession.getAllSessionDescriptors 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 desArr = Array(AVSessionDescriptor); + if (typeof args[len - 1] === 'function') { + args[len - 1].call(this, paramMock.businessErrorMock, desArr); + } else { + return new Promise((resolve, reject) => { + resolve(desArr); + }) + } + }, + createController: function (...args) { + console.warn("AVSession.createController 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, AVSessionController); + } else { + return new Promise((resolve, reject) => { + resolve(AVSessionController); + }) + } + }, + castAudio: function (...args) { + console.warn("AVSession.castAudio 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(); + }) + } + }, + on: function (...args) { + console.warn("AVSession.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 (args[0] == 'sessionCreated' || args[0] == 'sessionDestroyed' || args[0] == 'topSessionChanged') { + args[len - 1].call(this, AVSessionDescriptor); + } else if (args[0] == 'sessionServiceDied') { + args[len - 1].call(this); + } + }, + off: function (...args) { + console.warn("AVSession.off interface mocked in the Previewer. How this interface works on the Previewer" + + " may be different from that on a real device.") + }, + sendSystemAVKeyEvent: function (...args) { + console.warn("AVSession.sendSystemAVKeyEvent 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(); + }) + } + }, + sendSystemControlCommand: function (...args) { + console.warn("AVSession.sendSystemControlCommand 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 avsession +} diff --git a/runtime/main/extend/systemplugin/napi/ohos_multimodalInput_inputConsumer.js b/runtime/main/extend/systemplugin/napi/ohos_multimodalInput_inputConsumer.js index c251ab58..772faabd 100644 --- a/runtime/main/extend/systemplugin/napi/ohos_multimodalInput_inputConsumer.js +++ b/runtime/main/extend/systemplugin/napi/ohos_multimodalInput_inputConsumer.js @@ -16,6 +16,12 @@ import { paramMock } from "../utils" export function mockInputConsumer() { + const KeyOptions = { + preKeys: [param.paramNumberMock], + finalKey: "[PC preview] unknown finalKey", + isFinalKeyDown: "[PC preview] unknown isFinalKeyDown", + finalKeyDownDuration: "[PC preview] unknown finalKeyDownDuration", + } const EventType = ['key'] const inputConsumer = { on: function (...args) { diff --git a/runtime/main/extend/systemplugin/napi/ohos_multimodalInput_inputDevice.js b/runtime/main/extend/systemplugin/napi/ohos_multimodalInput_inputDevice.js index 874f1756..2edabfd6 100644 --- a/runtime/main/extend/systemplugin/napi/ohos_multimodalInput_inputDevice.js +++ b/runtime/main/extend/systemplugin/napi/ohos_multimodalInput_inputDevice.js @@ -16,17 +16,30 @@ import { paramMock } from "../utils" export function mockInputDevice() { + const DeviceListener = { + type: '[PC preview] unknow type', + deviceId: '[PC preview] unknow deviceId', + } const AxisRange = { source: '[PC preview] unknow source', axis: '[PC preview] unknow axis', max: '[PC preview] unknow max', - min: '[PC preview] unknow min' + min: '[PC preview] unknow min', + fuzz: '[PC preview] unknow fuzz', + flat: '[PC preview] unknow flat', + resolution: '[PC preview] unknow resolution', } const InputDeviceData = { id: '[PC preview] unknow id', name: '[PC preview] unknow name', sources: ['[PC preview] unknow sources'], - axisRanges: [AxisRange] + axisRanges: [AxisRange], + bus: '[PC preview] unknow bus', + product: '[PC preview] unknow product', + vendor: '[PC preview] unknow vendor', + version: '[PC preview] unknow version', + phys: '[PC preview] unknow phys', + uniq: '[PC preview] unknow uniq', } const KeyboardType = { NONE: 0, diff --git a/runtime/main/extend/systemplugin/napi/volume/volumeInfo.js b/runtime/main/extend/systemplugin/napi/ohos_multimodalInput_inputEvent.js old mode 100644 new mode 100755 similarity index 68% rename from runtime/main/extend/systemplugin/napi/volume/volumeInfo.js rename to runtime/main/extend/systemplugin/napi/ohos_multimodalInput_inputEvent.js index 529b1fe8..1deaf88f --- a/runtime/main/extend/systemplugin/napi/volume/volumeInfo.js +++ b/runtime/main/extend/systemplugin/napi/ohos_multimodalInput_inputEvent.js @@ -1,23 +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. - */ - -export const VolumeMock = { - id: '[PC preview] unknow id', - uuid: '[PC preview] unknow uuid', - description: '[PC preview] unknow description', - removeAble: '[PC preview] unknow removeAble', - path: '[PC preview] unknow path', - state: '[PC preview] unknow state', -}; \ No newline at end of file +/* + * 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 mockInputEvent() { + const InputEvent = { + id: '[PC preview] unknow id', + deviceId: '[PC preview] unknow deviceId', + actionTime: '[PC preview] unknow actionTime', + screenId: '[PC preview] unknow screenId', + windowId: '[PC preview] unknow windowId', + } + return InputEvent; +} \ No newline at end of file diff --git a/runtime/main/extend/systemplugin/napi/ohos_multimodalInput_inputEventClient.js b/runtime/main/extend/systemplugin/napi/ohos_multimodalInput_inputEventClient.js index 09a64faa..4ebf7cee 100644 --- a/runtime/main/extend/systemplugin/napi/ohos_multimodalInput_inputEventClient.js +++ b/runtime/main/extend/systemplugin/napi/ohos_multimodalInput_inputEventClient.js @@ -16,6 +16,12 @@ import { paramMock } from "../utils" export function mockInputEventClient() { + const KeyEvent = { + isPressed: '[PC preview] unknow isPressed', + keyCode: '[PC preview] unknow keyCode', + keyDownDuration: '[PC preview] unknow keyDownDuration', + isIntercepted: '[PC preview] unknow isIntercepted', + } const inputEventClient = { injectEvent: function(...args) { console.warn("inputEventClient.injectEvent interface mocked in the Previewer. How this interface works on the" + @@ -29,19 +35,23 @@ export function mockInputEventClient() { console.warn("the second parameter type must be 'object'"); return; } - if (typeof args[0].isPressed !== 'boolean') { + if (!('KeyEvent' in args[0])) { + console.warn("missing 'KeyEvent' field"); + return; + } + if (typeof args[0].KeyEvent.isPressed !== 'boolean') { console.warn("Field isPressed must be boolean"); return; } - if (typeof args[0].keyCode !== 'number') { + if (typeof args[0].KeyEvent.keyCode !== 'number') { console.warn("Field keyCode must be number"); return; } - if (typeof args[0].keyDownDuration !== 'number') { + if (typeof args[0].KeyEvent.keyDownDuration !== 'number') { console.warn("Field keyDownDuration must be number"); return; } - if (typeof args[0].isIntercepted !== 'boolean') { + if (typeof args[0].KeyEvent.isIntercepted !== 'boolean') { console.warn("Field isIntercepted must be boolean"); return; } diff --git a/runtime/main/extend/systemplugin/napi/ohos_multimodalInput_inputMonitor.js b/runtime/main/extend/systemplugin/napi/ohos_multimodalInput_inputMonitor.js index ff969d42..d808db3b 100644 --- a/runtime/main/extend/systemplugin/napi/ohos_multimodalInput_inputMonitor.js +++ b/runtime/main/extend/systemplugin/napi/ohos_multimodalInput_inputMonitor.js @@ -14,6 +14,9 @@ */ export function mockInputMonitor() { + const TouchEventReceiver = { + "touchEvent": '[PC preview] unknow boolean' + } const touches = [{ force: 1.67, globalX: 122, @@ -79,8 +82,26 @@ export function mockInputMonitor() { off: function (...args) { console.warn('multimodalInput.inputMonitor.off interface mocked in the Previewer. How this interface works on the' + ' Previewer may be different from that on a real device.'); - clearInterval(this.offInputMonitor); - delete this.offInputMonitor; + const len = args.length; + if (len < 1 || len > 2) { + console.warn("a maximum of two parameters"); + return; + } + if (typeof args[0] !== 'string') { + console.warn("the first parameter type must be string"); + return; + } + if (len === 1) { + if (args[0] !== 'touch' && args[0] !== 'mouse') { + console.warn("the first param should be touch or mouse"); + return; + } + } else { + if (typeof args[1] !== 'function') { + console.warn("the second parameter type must be function"); + return; + } + } } } return inputMonitor diff --git a/runtime/main/extend/systemplugin/napi/ohos_multimodalInput_keyCode.js b/runtime/main/extend/systemplugin/napi/ohos_multimodalInput_keyCode.js index 3a9e8180..63a34cfc 100644 --- a/runtime/main/extend/systemplugin/napi/ohos_multimodalInput_keyCode.js +++ b/runtime/main/extend/systemplugin/napi/ohos_multimodalInput_keyCode.js @@ -16,6 +16,8 @@ export const KeyCode = { KEYCODE_FN: 0, KEYCODE_UNKNOWN: -1, + KEYCODE_HOME: 1, + KEYCODE_BACK: 2, KEYCODE_MEDIA_PLAY_PAUSE: 10, KEYCODE_MEDIA_STOP: 11, KEYCODE_MEDIA_NEXT: 12, diff --git a/runtime/main/extend/systemplugin/napi/ohos_multimodalInput_keyEvent.js b/runtime/main/extend/systemplugin/napi/ohos_multimodalInput_keyEvent.js index 93d84695..888f6432 100644 --- a/runtime/main/extend/systemplugin/napi/ohos_multimodalInput_keyEvent.js +++ b/runtime/main/extend/systemplugin/napi/ohos_multimodalInput_keyEvent.js @@ -20,6 +20,25 @@ export const Action = { } export function mockKeyEvent() { + const Key = { + code: '[PC preview] unknow code', + pressedTime: '[PC preview] unknow pressedTime', + deviceId: '[PC preview] unknow deviceId', + } + const KeyEvent = { + action: '[PC preview] unknow action', + key: Key, + unicodeChar: '[PC preview] unknow unicodeChar', + keys: ['[PC preview] unknow Key'], + ctrlKey: '[PC preview] unknow ctrlKey', + altKey: '[PC preview] unknow altKey', + shiftKey: '[PC preview] unknow shiftKey', + logoKey: '[PC preview] unknow logoKey', + fnKey: '[PC preview] unknow fnKey', + capsLock: '[PC preview] unknow capsLock', + numLock: '[PC preview] unknow numLock', + scrollLock: '[PC preview] unknow scrollLock', + } const keyEvent = { Action, } diff --git a/runtime/main/extend/systemplugin/napi/ohos_multimodalInput_mouseEvent.js b/runtime/main/extend/systemplugin/napi/ohos_multimodalInput_mouseEvent.js index f0f65236..7d7fd3bb 100644 --- a/runtime/main/extend/systemplugin/napi/ohos_multimodalInput_mouseEvent.js +++ b/runtime/main/extend/systemplugin/napi/ohos_multimodalInput_mouseEvent.js @@ -41,6 +41,31 @@ export const Axis = { } export function mockMouseEvent() { + const AxisValue = { + axis: '[PC preview] unknow axis', + value: '[PC preview] unknow value', + } + const MouseEvent = { + action: '[PC preview] unknow action', + screenX: '[PC preview] unknow screenX', + screenY: '[PC preview] unknow screenY', + windowX: '[PC preview] unknow windowX', + windowY: '[PC preview] unknow windowY', + rawDeltaX: '[PC preview] unknow rawDeltaX', + rawDeltaY: '[PC preview] unknow rawDeltaY', + button: '[PC preview] unknow button', + pressedButtons: ['[PC preview] unknow pressedButtons'], + axes: ['[PC preview] unknow axes'], + pressedKeys: ['[PC preview] unknow pressedKeys'], + ctrlKey: '[PC preview] unknow ctrlKey', + altKey: '[PC preview] unknow altKey', + shiftKey: '[PC preview] unknow shiftKey', + logoKey: '[PC preview] unknow logoKey', + fnKey: '[PC preview] unknow fnKey', + capsLock: '[PC preview] unknow capsLock', + numLock: '[PC preview] unknow numLock', + scrollLock: '[PC preview] unknow scrollLock', + } const mouseEvent = { Action, Button, diff --git a/runtime/main/extend/systemplugin/napi/ohos_multimodalInput_touchEvent.js b/runtime/main/extend/systemplugin/napi/ohos_multimodalInput_touchEvent.js index 58b53f7a..76655570 100644 --- a/runtime/main/extend/systemplugin/napi/ohos_multimodalInput_touchEvent.js +++ b/runtime/main/extend/systemplugin/napi/ohos_multimodalInput_touchEvent.js @@ -38,6 +38,32 @@ export const SourceType = { } export function mockTouchEvent() { + const Touch = { + id: '[PC preview] unknow id', + pressedTime: '[PC preview] unknow pressedTime', + screenX: '[PC preview] unknow screenX', + screenY: '[PC preview] unknow screenY', + windowX: '[PC preview] unknow windowX', + windowY: '[PC preview] unknow windowY', + pressure: '[PC preview] unknow pressure', + width: '[PC preview] unknow width', + height: '[PC preview] unknow height', + tiltX: '[PC preview] unknow tiltX', + tiltY: '[PC preview] unknow tiltY', + toolX: '[PC preview] unknow toolX', + toolY: '[PC preview] unknow toolY', + toolWidth: '[PC preview] unknow toolWidth', + toolHeight: '[PC preview] unknow toolHeight', + rawX: '[PC preview] unknow rawX', + rawY: '[PC preview] unknow rawY', + toolType: '[PC preview] unknow toolType', + } + const TouchEvent = { + action: '[PC preview] unknow action', + touch: '[PC preview] unknow Touch', + touches: ['[PC preview] unknow Touch'], + sourceType: '[PC preview] unknow SourceType', + } const touchEvent = { Action, ToolType, diff --git a/runtime/main/extend/systemplugin/napi/ohos_notification.js b/runtime/main/extend/systemplugin/napi/ohos_notification.js index ec3660b2..6aa55fb7 100644 --- a/runtime/main/extend/systemplugin/napi/ohos_notification.js +++ b/runtime/main/extend/systemplugin/napi/ohos_notification.js @@ -14,297 +14,279 @@ */ import { paramMock } from "../utils" +import { NotificationSlot } from "./notification/notificationSlot" +import { NotificationRequest } from "./notification/notificationRequest" +export const SlotType = { + UNKNOWN_TYPE: 0, + SOCIAL_COMMUNICATION: 1, + SERVICE_INFORMATION: 2, + CONTENT_INFORMATION: 3, + OTHER_TYPES: 0xFFFF, +} +export const ContentType = { + NOTIFICATION_CONTENT_BASIC_TEXT: 0, + NOTIFICATION_CONTENT_LONG_TEXT: 1, + NOTIFICATION_CONTENT_PICTURE: 2, + NOTIFICATION_CONTENT_CONVERSATION: 3, + NOTIFICATION_CONTENT_MULTILINE: 4, +} +export const SlotLevel = { + LEVEL_NONE: 0, + LEVEL_MIN: 1, + LEVEL_LOW: 2, + LEVEL_DEFAULT: 3, + LEVEL_HIGH: 4, +} +export const BundleOption = { + bundle: '[PC preview] unknow bundle', + uid: '[PC preview] unknow uid', +} +export const NotificationKey = { + id: '[PC preview] unknow id', + label: '[PC preview] unknow label', +} +export const DoNotDisturbType = { + TYPE_NONE: 0, + TYPE_ONCE: 1, + TYPE_DAILY: 2, + TYPE_CLEARLY: 3, +} +const Date = { + toString: function () { + console.warn("Date.toString interface mocked in the Previewer. How this interface works on the Previewer" + + " may be different from that on a real device.") + return paramMock.paramStringMock + }, + toDateString: function () { + console.warn("Date.toDateString interface mocked in the Previewer. How this interface works on the Previewer" + + " may be different from that on a real device.") + return paramMock.paramStringMock + }, + toTimeString: function () { + console.warn("Date.toTimeString interface mocked in the Previewer. How this interface works on the Previewer" + + " may be different from that on a real device.") + return paramMock.paramStringMock + }, + toLocaleString: function () { + console.warn("Date.toLocaleString interface mocked in the Previewer. How this interface works on the Previewer" + + " may be different from that on a real device.") + return paramMock.paramStringMock + }, + toLocaleDateString: function () { + console.warn("Date.toLocaleDateString interface mocked in the Previewer. How this interface works on the Previewer" + + " may be different from that on a real device.") + return paramMock.paramStringMock + }, + toLocaleTimeString: function () { + console.warn("Date.toLocaleTimeString interface mocked in the Previewer. How this interface works on the Previewer" + + " may be different from that on a real device.") + return paramMock.paramStringMock + }, + valueOf: function () { + console.warn("Date.valueOf interface mocked in the Previewer. How this interface works on the Previewer" + + " may be different from that on a real device.") + return paramMock.paramNumberMock + }, + getTime: function () { + console.warn("Date.getTime interface mocked in the Previewer. How this interface works on the Previewer" + + " may be different from that on a real device.") + return paramMock.paramNumberMock + }, + getFullYear: function () { + console.warn("Date.getFullYear interface mocked in the Previewer. How this interface works on the Previewer" + + " may be different from that on a real device.") + return paramMock.paramNumberMock + }, + getUTCFullYear: function () { + console.warn("Date.getUTCFullYear interface mocked in the Previewer. How this interface works on the Previewer" + + " may be different from that on a real device.") + return paramMock.paramNumberMock + }, + getMonth: function () { + console.warn("Date.getMonth interface mocked in the Previewer. How this interface works on the Previewer" + + " may be different from that on a real device.") + return paramMock.paramNumberMock + }, + getUTCMonth: function () { + console.warn("Date.getUTCMonth interface mocked in the Previewer. How this interface works on the Previewer" + + " may be different from that on a real device.") + return paramMock.paramNumberMock + }, + getDate: function () { + console.warn("Date.getDate interface mocked in the Previewer. How this interface works on the Previewer" + + " may be different from that on a real device.") + return paramMock.paramNumberMock + }, + getUTCDate: function () { + console.warn("Date.getUTCDate interface mocked in the Previewer. How this interface works on the Previewer" + + " may be different from that on a real device.") + return paramMock.paramNumberMock + }, + getDay: function () { + console.warn("Date.getDay interface mocked in the Previewer. How this interface works on the Previewer" + + " may be different from that on a real device.") + return paramMock.paramNumberMock + }, + getUTCDay: function () { + console.warn("Date.getUTCDay interface mocked in the Previewer. How this interface works on the Previewer" + + " may be different from that on a real device.") + return paramMock.paramNumberMock + }, + getHours: function () { + console.warn("Date.getHours interface mocked in the Previewer. How this interface works on the Previewer" + + " may be different from that on a real device.") + return paramMock.paramNumberMock + }, + getUTCHours: function () { + console.warn("Date.getUTCHours interface mocked in the Previewer. How this interface works on the Previewer" + + " may be different from that on a real device.") + return paramMock.paramNumberMock + }, + getMinutes: function () { + console.warn("Date.getMinutes interface mocked in the Previewer. How this interface works on the Previewer" + + " may be different from that on a real device.") + return paramMock.paramNumberMock + }, + getUTCMinutes: function () { + console.warn("Date.getUTCMinutes interface mocked in the Previewer. How this interface works on the Previewer" + + " may be different from that on a real device.") + return paramMock.paramNumberMock + }, + getSeconds: function () { + console.warn("Date.getSeconds interface mocked in the Previewer. How this interface works on the Previewer" + + " may be different from that on a real device.") + return paramMock.paramNumberMock + }, + getUTCSeconds: function () { + console.warn("Date.getUTCSeconds interface mocked in the Previewer. How this interface works on the Previewer" + + " may be different from that on a real device.") + return paramMock.paramNumberMock + }, + getMilliseconds: function () { + console.warn("Date.getMilliseconds interface mocked in the Previewer. How this interface works on the Previewer" + + " may be different from that on a real device.") + return paramMock.paramNumberMock + }, + getUTCMilliseconds: function () { + console.warn("Date.getUTCMilliseconds interface mocked in the Previewer. How this interface works on the Previewer" + + " may be different from that on a real device.") + return paramMock.paramNumberMock + }, + getTimezoneOffset: function () { + console.warn("Date.getTimezoneOffset interface mocked in the Previewer. How this interface works on the Previewer" + + " may be different from that on a real device.") + return paramMock.paramNumberMock + }, + setTime: function (...args) { + console.warn("Date.setTime interface mocked in the Previewer. How this interface works on the Previewer" + + " may be different from that on a real device.") + return paramMock.paramNumberMock + }, + setMilliseconds: function (...args) { + console.warn("Date.setMilliseconds interface mocked in the Previewer. How this interface works on the Previewer" + + " may be different from that on a real device.") + return paramMock.paramNumberMock + }, + setUTCMilliseconds: function (...args) { + console.warn("Date.setUTCMilliseconds interface mocked in the Previewer. How this interface works on the Previewer" + + " may be different from that on a real device.") + return paramMock.paramNumberMock + }, + setSeconds: function (...args) { + console.warn("Date.setSeconds interface mocked in the Previewer. How this interface works on the Previewer" + + " may be different from that on a real device.") + return paramMock.paramNumberMock + }, + setUTCSeconds: function (...args) { + console.warn("Date.setUTCSeconds interface mocked in the Previewer. How this interface works on the Previewer" + + " may be different from that on a real device.") + return paramMock.paramNumberMock + }, + setMinutes: function (...args) { + console.warn("Date.setMinutes interface mocked in the Previewer. How this interface works on the Previewer" + + " may be different from that on a real device.") + return paramMock.paramNumberMock + }, + setUTCMinutes: function (...args) { + console.warn("Date.setUTCMinutes interface mocked in the Previewer. How this interface works on the Previewer" + + " may be different from that on a real device.") + return paramMock.paramNumberMock + }, + setHours: function (...args) { + console.warn("Date.setHours interface mocked in the Previewer. How this interface works on the Previewer" + + " may be different from that on a real device.") + return paramMock.paramNumberMock + }, + setUTCHours: function (...args) { + console.warn("Date.setUTCHours interface mocked in the Previewer. How this interface works on the Previewer" + + " may be different from that on a real device.") + return paramMock.paramNumberMock + }, + setDate: function (...args) { + console.warn("Date.setDate interface mocked in the Previewer. How this interface works on the Previewer" + + " may be different from that on a real device.") + return paramMock.paramNumberMock + }, + setUTCDate: function (...args) { + console.warn("Date.setUTCDate interface mocked in the Previewer. How this interface works on the Previewer" + + " may be different from that on a real device.") + return paramMock.paramNumberMock + }, + setMonth: function (...args) { + console.warn("Date.setMonth interface mocked in the Previewer. How this interface works on the Previewer" + + " may be different from that on a real device.") + return paramMock.paramNumberMock + }, + setUTCMonth: function (...args) { + console.warn("Date.setUTCMonth interface mocked in the Previewer. How this interface works on the Previewer" + + " may be different from that on a real device.") + return paramMock.paramNumberMock + }, + setFullYear: function (...args) { + console.warn("Date.setFullYear interface mocked in the Previewer. How this interface works on the Previewer" + + " may be different from that on a real device.") + return paramMock.paramNumberMock + }, + setUTCFullYear: function (...args) { + console.warn("Date.setUTCFullYear interface mocked in the Previewer. How this interface works on the Previewer" + + " may be different from that on a real device.") + return paramMock.paramNumberMock + }, + toUTCString: function () { + console.warn("Date.toUTCString interface mocked in the Previewer. How this interface works on the Previewer" + + " may be different from that on a real device.") + return paramMock.paramStringMock + }, + toISOString: function () { + console.warn("Date.toISOString interface mocked in the Previewer. How this interface works on the Previewer" + + " may be different from that on a real device.") + return paramMock.paramStringMock + }, + toJSON: function (...args) { + console.warn("Date.toJSON 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 const DoNotDisturbDate = { + type: DoNotDisturbType, + begin: Date, + end: Date, +} +export const DeviceRemindType = { + IDLE_DONOT_REMIND: 0, + IDLE_REMIND: 1, + ACTIVE_DONOT_REMIND: 2, + ACTIVE_REMIND: 3, +} +export const SourceType = { + TYPE_NORMAL: 0, + TYPE_CONTINUOUS: 1, + TYPE_TIMER: 2, +} export function mockNotification() { - const DateMock = { - toString: function () { - console.warn("Date.toString interface mocked in the Previewer. How this interface works on the Previewer" + - " may be different from that on a real device.") - return paramMock.paramStringMock - }, - toDateString: function () { - console.warn("Date.toDateString interface mocked in the Previewer. How this interface works on the Previewer" + - " may be different from that on a real device.") - return paramMock.paramStringMock - }, - toTimeString: function () { - console.warn("Date.toTimeString interface mocked in the Previewer. How this interface works on the Previewer" + - " may be different from that on a real device.") - return paramMock.paramStringMock - }, - toLocaleString: function () { - console.warn("Date.toLocaleString interface mocked in the Previewer. How this interface works on the Previewer" + - " may be different from that on a real device.") - return paramMock.paramStringMock - }, - toLocaleDateString: function () { - console.warn("Date.toLocaleDateString interface mocked in the Previewer. How this interface works on the Previewer" + - " may be different from that on a real device.") - return paramMock.paramStringMock - }, - toLocaleTimeString: function () { - console.warn("Date.toLocaleTimeString interface mocked in the Previewer. How this interface works on the Previewer" + - " may be different from that on a real device.") - return paramMock.paramStringMock - }, - valueOf: function () { - console.warn("Date.valueOf interface mocked in the Previewer. How this interface works on the Previewer" + - " may be different from that on a real device.") - return paramMock.paramNumberMock - }, - getTime: function () { - console.warn("Date.getTime interface mocked in the Previewer. How this interface works on the Previewer" + - " may be different from that on a real device.") - return paramMock.paramNumberMock - }, - getFullYear: function () { - console.warn("Date.getFullYear interface mocked in the Previewer. How this interface works on the Previewer" + - " may be different from that on a real device.") - return paramMock.paramNumberMock - }, - getUTCFullYear: function () { - console.warn("Date.getUTCFullYear interface mocked in the Previewer. How this interface works on the Previewer" + - " may be different from that on a real device.") - return paramMock.paramNumberMock - }, - getMonth: function () { - console.warn("Date.getMonth interface mocked in the Previewer. How this interface works on the Previewer" + - " may be different from that on a real device.") - return paramMock.paramNumberMock - }, - getUTCMonth: function () { - console.warn("Date.getUTCMonth interface mocked in the Previewer. How this interface works on the Previewer" + - " may be different from that on a real device.") - return paramMock.paramNumberMock - }, - getDate: function () { - console.warn("Date.getDate interface mocked in the Previewer. How this interface works on the Previewer" + - " may be different from that on a real device.") - return paramMock.paramNumberMock - }, - getUTCDate: function () { - console.warn("Date.getUTCDate interface mocked in the Previewer. How this interface works on the Previewer" + - " may be different from that on a real device.") - return paramMock.paramNumberMock - }, - getDay: function () { - console.warn("Date.getDay interface mocked in the Previewer. How this interface works on the Previewer" + - " may be different from that on a real device.") - return paramMock.paramNumberMock - }, - getUTCDay: function () { - console.warn("Date.getUTCDay interface mocked in the Previewer. How this interface works on the Previewer" + - " may be different from that on a real device.") - return paramMock.paramNumberMock - }, - getHours: function () { - console.warn("Date.getHours interface mocked in the Previewer. How this interface works on the Previewer" + - " may be different from that on a real device.") - return paramMock.paramNumberMock - }, - getUTCHours: function () { - console.warn("Date.getUTCHours interface mocked in the Previewer. How this interface works on the Previewer" + - " may be different from that on a real device.") - return paramMock.paramNumberMock - }, - getMinutes: function () { - console.warn("Date.getMinutes interface mocked in the Previewer. How this interface works on the Previewer" + - " may be different from that on a real device.") - return paramMock.paramNumberMock - }, - getUTCMinutes: function () { - console.warn("Date.getUTCMinutes interface mocked in the Previewer. How this interface works on the Previewer" + - " may be different from that on a real device.") - return paramMock.paramNumberMock - }, - getSeconds: function () { - console.warn("Date.getSeconds interface mocked in the Previewer. How this interface works on the Previewer" + - " may be different from that on a real device.") - return paramMock.paramNumberMock - }, - getUTCSeconds: function () { - console.warn("Date.getUTCSeconds interface mocked in the Previewer. How this interface works on the Previewer" + - " may be different from that on a real device.") - return paramMock.paramNumberMock - }, - getMilliseconds: function () { - console.warn("Date.getMilliseconds interface mocked in the Previewer. How this interface works on the Previewer" + - " may be different from that on a real device.") - return paramMock.paramNumberMock - }, - getUTCMilliseconds: function () { - console.warn("Date.getUTCMilliseconds interface mocked in the Previewer. How this interface works on the Previewer" + - " may be different from that on a real device.") - return paramMock.paramNumberMock - }, - getTimezoneOffset: function () { - console.warn("Date.getTimezoneOffset interface mocked in the Previewer. How this interface works on the Previewer" + - " may be different from that on a real device.") - return paramMock.paramNumberMock - }, - setTime: function (...args) { - console.warn("Date.setTime interface mocked in the Previewer. How this interface works on the Previewer" + - " may be different from that on a real device.") - return paramMock.paramNumberMock - }, - setMilliseconds: function (...args) { - console.warn("Date.setMilliseconds interface mocked in the Previewer. How this interface works on the Previewer" + - " may be different from that on a real device.") - return paramMock.paramNumberMock - }, - setUTCMilliseconds: function (...args) { - console.warn("Date.setUTCMilliseconds interface mocked in the Previewer. How this interface works on the Previewer" + - " may be different from that on a real device.") - return paramMock.paramNumberMock - }, - setSeconds: function (...args) { - console.warn("Date.setSeconds interface mocked in the Previewer. How this interface works on the Previewer" + - " may be different from that on a real device.") - return paramMock.paramNumberMock - }, - setUTCSeconds: function (...args) { - console.warn("Date.setUTCSeconds interface mocked in the Previewer. How this interface works on the Previewer" + - " may be different from that on a real device.") - return paramMock.paramNumberMock - }, - setMinutes: function (...args) { - console.warn("Date.setMinutes interface mocked in the Previewer. How this interface works on the Previewer" + - " may be different from that on a real device.") - return paramMock.paramNumberMock - }, - setUTCMinutes: function (...args) { - console.warn("Date.setUTCMinutes interface mocked in the Previewer. How this interface works on the Previewer" + - " may be different from that on a real device.") - return paramMock.paramNumberMock - }, - setHours: function (...args) { - console.warn("Date.setHours interface mocked in the Previewer. How this interface works on the Previewer" + - " may be different from that on a real device.") - return paramMock.paramNumberMock - }, - setUTCHours: function (...args) { - console.warn("Date.setUTCHours interface mocked in the Previewer. How this interface works on the Previewer" + - " may be different from that on a real device.") - return paramMock.paramNumberMock - }, - setDate: function (...args) { - console.warn("Date.setDate interface mocked in the Previewer. How this interface works on the Previewer" + - " may be different from that on a real device.") - return paramMock.paramNumberMock - }, - setUTCDate: function (...args) { - console.warn("Date.setUTCDate interface mocked in the Previewer. How this interface works on the Previewer" + - " may be different from that on a real device.") - return paramMock.paramNumberMock - }, - setMonth: function (...args) { - console.warn("Date.setMonth interface mocked in the Previewer. How this interface works on the Previewer" + - " may be different from that on a real device.") - return paramMock.paramNumberMock - }, - setUTCMonth: function (...args) { - console.warn("Date.setUTCMonth interface mocked in the Previewer. How this interface works on the Previewer" + - " may be different from that on a real device.") - return paramMock.paramNumberMock - }, - setFullYear: function (...args) { - console.warn("Date.setFullYear interface mocked in the Previewer. How this interface works on the Previewer" + - " may be different from that on a real device.") - return paramMock.paramNumberMock - }, - setUTCFullYear: function (...args) { - console.warn("Date.setUTCFullYear interface mocked in the Previewer. How this interface works on the Previewer" + - " may be different from that on a real device.") - return paramMock.paramNumberMock - }, - toUTCString: function () { - console.warn("Date.toUTCString interface mocked in the Previewer. How this interface works on the Previewer" + - " may be different from that on a real device.") - return paramMock.paramStringMock - }, - toISOString: function () { - console.warn("Date.toISOString interface mocked in the Previewer. How this interface works on the Previewer" + - " may be different from that on a real device.") - return paramMock.paramStringMock - }, - toJSON: function (...args) { - console.warn("Date.toJSON interface mocked in the Previewer. How this interface works on the Previewer" + - " may be different from that on a real device.") - return paramMock.paramStringMock - }, - } - const DoNotDisturbDateMock = { - DoNotDisturbTypeMock: '[PC preview] unknow DoNotDisturbTypeMock', - begin: DateMock, - end: DateMock - } - const NotificationSlotMock = { - SlotTypeMock: '[PC preview] unknow SlotTypeMock', - SlotLevelMock: '[PC preview] unknow SlotLevelMock', - 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] - }; - const NotificationActionButtonMock = { - title: '[PC preview] unknow title', - wantAgent: '[PC preview] unknow wantAgent', - extras: {}, - userInput: '[PC preview] unknow userInput', - } - const NotificationRequestMock = { - content: '[PC preview] unknow content', - id: '[PC preview] unknow id', - slotTypeMock: '[PC preview] unknow slotTypeMock', - 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: [NotificationActionButtonMock], - smallIcon: '[PC preview] unknow smallIcon', - largeIcon: '[PC preview] unknow largeIcon', - groupName: '[PC preview] unknow groupName', - creatorBundleName: '[PC preview] unknow creatorBundleName', - creatorUid: '[PC preview] unknow creatorUid', - creatorPid: '[PC preview] unknow creatorPid', - classification: '[PC preview] unknow classification', - hashCode: '[PC preview] unknow hashCode', - isRemveAllowd: '[PC preview] unknow isRemveAllowd', - source: '[PC preview] unknow source', - template: '[PC preview] unknow template' - }; const notification = { - SlotType: { - UNKNOWN_TYPE: 0, - SOCIAL_COMMUNICATION: 1, - SERVICE_INFORMATION: 2, - CONTENT_INFORMATION: 3, - OTHER_TYPES: 0xFFFF, - }, - ContentType: { - NOTIFICATION_CONTENT_BASIC_TEXT: 0, - NOTIFICATION_CONTENT_LONG_TEXT: 1, - NOTIFICATION_CONTENT_PICTURE: 2, - NOTIFICATION_CONTENT_CONVERSATION: 3, - NOTIFICATION_CONTENT_MULTILINE: 4, - }, publish: function (...args) { console.warn('notification.publish interface mocked in the Previewer. How this interface works on the' + ' Previewer may be different from that on a real device.'); @@ -317,6 +299,18 @@ export function mockNotification() { }); } }, + publishAsBundle: function (...args) { + console.warn('notification.publishAsBundle 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(); + }); + } + }, cancel: function (...args) { console.warn('notification.cancel interface mocked in the Previewer. How this interface works on the' + ' Previewer may be different from that on a real device.'); @@ -329,6 +323,18 @@ export function mockNotification() { }); } }, + cancelAsBundle: function (...args) { + console.warn('notification.cancelAsBundle 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(); + }); + } + }, cancelAll: function (...args) { console.warn('notification.cancelAll interface mocked in the Previewer. How this interface works on the' + ' Previewer may be different from that on a real device.'); @@ -370,10 +376,10 @@ export function mockNotification() { ' 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, NotificationSlotMock); + args[len - 1].call(this, paramMock.businessErrorMock, NotificationSlot); } else { return new Promise((resolve) => { - resolve(NotificationSlotMock); + resolve(NotificationSlot); }); } }, @@ -382,10 +388,10 @@ export function mockNotification() { ' 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, [NotificationSlotMock]); + args[len - 1].call(this, paramMock.businessErrorMock, [NotificationSlot]); } else { return new Promise((resolve) => { - resolve([NotificationSlotMock]); + resolve([NotificationSlot]); }); } }, @@ -502,10 +508,10 @@ export function mockNotification() { ' 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, [NotificationSlotMock]); + args[len - 1].call(this, paramMock.businessErrorMock, [NotificationSlot]); } else { return new Promise((resolve) => { - resolve([NotificationSlotMock]); + resolve([NotificationSlot]); }); } }, @@ -550,10 +556,10 @@ export function mockNotification() { ' 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, [NotificationRequestMock]); + args[len - 1].call(this, paramMock.businessErrorMock, [NotificationRequest]); } else { return new Promise((resolve) => { - resolve([NotificationRequestMock]); + resolve([NotificationRequest]); }); } }, @@ -574,10 +580,10 @@ export function mockNotification() { ' 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, [NotificationRequestMock]); + args[len - 1].call(this, paramMock.businessErrorMock, [NotificationRequest]); } else { return new Promise((resolve) => { - resolve([NotificationRequestMock]); + resolve([NotificationRequest]); }); } }, @@ -622,10 +628,10 @@ export function mockNotification() { " 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, DoNotDisturbDateMock); + args[len - 1].call(this, paramMock.businessErrorMock, DoNotDisturbDate); } else { return new Promise((resolve, reject) => { - resolve(DoNotDisturbDateMock); + resolve(DoNotDisturbDate); }) } }, @@ -653,8 +659,32 @@ export function mockNotification() { }) } }, - isNotificationEnabledSelf: function (...args) { - console.warn("notification.isNotificationEnabledSelf interface mocked in the Previewer. How this interface works on the" + + requestEnableNotification: function (...args) { + console.warn("notification.requestEnableNotification 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(); + }) + } + }, + enableDistributed: function (...args) { + console.warn("notification.enableDistributed 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(); + }) + } + }, + isDistributedEnabled: function (...args) { + console.warn("notification.isDistributedEnabled 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') { @@ -665,8 +695,56 @@ export function mockNotification() { }) } }, - requestEnableNotification: function (...args) { - console.warn("notification.requestEnableNotification interface mocked in the Previewer. How this interface works on the" + + enableDistributedByBundle: function (...args) { + console.warn("notification.enableDistributedByBundle 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(); + }) + } + }, + isDistributedEnabledByBundle: function (...args) { + console.warn("notification.isDistributedEnabledByBundle 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); + }) + } + }, + getDeviceRemindType: function (...args) { + console.warn("notification.getDeviceRemindType 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, DeviceRemindType); + } else { + return new Promise((resolve, reject) => { + resolve(DeviceRemindType); + }) + } + }, + isNotificationSlotEnabled: function (...args) { + console.warn("notification.isNotificationSlotEnabled 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); + }) + } + }, + setSyncNotificationEnabledForUninstallApp: function (...args) { + console.warn("notification.setSyncNotificationEnabledForUninstallApp 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') { @@ -689,8 +767,8 @@ export function mockNotification() { }) } }, - isNotificationSlotEnabled: function (...args) { - console.warn("notification.isNotificationSlotEnabled interface mocked in the Previewer. How this interface works on the" + + getSyncNotificationEnabledForUninstallApp: function (...args) { + console.warn("notification.getSyncNotificationEnabledForUninstallApp 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') { diff --git a/runtime/main/extend/systemplugin/napi/ohos_reminderAgent.js b/runtime/main/extend/systemplugin/napi/ohos_reminderAgent.js index 8e69469b..609b0a16 100644 --- a/runtime/main/extend/systemplugin/napi/ohos_reminderAgent.js +++ b/runtime/main/extend/systemplugin/napi/ohos_reminderAgent.js @@ -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,15 +17,15 @@ import { paramMock } from "../utils" export function mockReminderAgent() { const infoMock = { - reminderId: 1, + reminderId: "[PC preview] unknown reminderId", info: "[PC preview] unknown info" } const reminderReq = { - reminderType: 1, + reminderType: "[PC preview] unknown reminderType", actionButton: [ { title: "[PC preview] unknown title", - type: 0 + type: "[PC preview] unknown type" } ], wantAgent: { @@ -36,20 +36,77 @@ export function mockReminderAgent() { pkgName: "[PC preview] unknown pkg name", abilityName: "[PC preview] unknown ability name" }, - ringDuration: 1, - snoozeTimes: 1, - timeInterval: 1, + ringDuration: "[PC preview] unknown ringDuration", + snoozeTimes: "[PC preview] unknown snoozeTimes", + timeInterval: "[PC preview] unknown timeInterval", title: "[PC preview] unknown title", content: "[PC preview] unknown content", expiredContent: "[PC preview] unknown expiredContent", snoozeContent: "[PC preview] unknown snoozeContent", - notificationId: 1, - slotType: 3 + notificationId: "[PC preview] unknown notificationId", + slotType: "[PC preview] unknown slotType" } const reminderReqs = [ reminderReq ] + const ActionButton = { + title: "[PC preview] unknown title", + type: "[PC preview] unknown type" + } + const WantAgent = { + pkgName: "[PC preview] unknown pkgName", + abilityName: "[PC preview] unknown abilityName" + } + const MaxScreenWantAgent = { + pkgName: "[PC preview] unknown pkgName", + abilityName: "[PC preview] unknown abilityName" + } + const ReminderRequest = { + reminderType: "[PC preview] unknown reminderType", + actionButton: ActionButton, + wantAgent: WantAgent, + maxScreenWantAgent: MaxScreenWantAgent, + ringDuration: "[PC preview] unknown ringDuration", + snoozeTimes: "[PC preview] unknown snoozeTimes", + timeInterval: "[PC preview] unknown timeInterval", + title: "[PC preview] unknown title", + content: "[PC preview] unknown content", + expiredContent: "[PC preview] unknown expiredContent", + snoozeContent: "[PC preview] unknown snoozeContent", + notificationId: "[PC preview] unknown notificationId", + slotType: "[PC preview] unknown slotType" + } + const ReminderRequestCalendar = { + dateTime: LocalDateTime, + repeatMonths: "[PC preview] unknown repeatMonths", + repeatDays: "[PC preview] unknown repeatDays" + } + const ReminderRequestAlarm = { + hour: "[PC preview] unknown hour", + minute: "[PC preview] unknown minute", + daysOfWeek: "[PC preview] unknown daysOfWeek" + } + const ReminderRequestTimer = { + triggerTimeInSeconds: "[PC preview] unknown triggerTimeInSeconds" + } + const LocalDateTime = { + year: "[PC preview] unknown year", + month: "[PC preview] unknown month", + day: "[PC preview] unknown day", + hour: "[PC preview] unknown hour", + minute: "[PC preview] unknown minute", + second: "[PC preview] unknown second" + } const reminderAgent = { + ActionButtonType: { + ACTION_BUTTON_TYPE_CLOSE: 0, + ACTION_BUTTON_TYPE_SNOOZE: 1 + }, + ReminderType: { + REMINDER_TYPE_TIMER: 0, + REMINDER_TYPE_CALENDAR: 1, + REMINDER_TYPE_ALARM: 2 + }, publishReminder: function (...args) { console.warn("reminderAgent.publishReminder interface mocked in the Previewer." + "How this interface works on the Previewer may be different from that on a real device.") diff --git a/runtime/main/extend/systemplugin/napi/ohos_resourceManager.js b/runtime/main/extend/systemplugin/napi/ohos_resourceManager.js index c5c1d19e..d6bb618e 100644 --- a/runtime/main/extend/systemplugin/napi/ohos_resourceManager.js +++ b/runtime/main/extend/systemplugin/napi/ohos_resourceManager.js @@ -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,169 +13,291 @@ * limitations under the License. */ +import { paramMock } from "../utils"; +import { RawFileDescriptor } from "./global/rawFileDescriptor" + export function mockResourceManager() { - function Configuration(direction, locale) { - this.direction = direction; - this.locale = locale; + const Direction = { + DIRECTION_VERTICAL : 0, + DIRECTION_HORIZONTAL : 1 } - function DeviceCapability(screenDensity, deviceType) { - this.screenDensity = screenDensity; - this.deviceType = deviceType; + const ConfigurationClass = class Configuration { + constructor() { + console.warn('resourceManager.Configuration.constructor interface mocked in the Previewer. How this interface works on' + + ' the Previewer may be different from that on a real device.'); + this.direction = Direction; + this.locale = '[PC Preview] unknow string'; + } } - function ResourceManager(mgrId, module) { - var resMgrId = mgrId; - var resourcemgrModuleGroup = module; + const ScreenDensity = { + SCREEN_SDPI : 120, + SCREEN_MDPI : 160, + SCREEN_LDPI : 240, + SCREEN_XLDPI : 320, + SCREEN_XXLDPI : 480, + SCREEN_XXXLDPI : 640 + } - this.getString = getString; - async function getString(resId, callback) { - var data = "mock string"; + const DeviceType = { + DEVICE_TYPE_PHONE : 0x00, + DEVICE_TYPE_TABLET : 0x01, + DEVICE_TYPE_CAR : 0x02, + DEVICE_TYPE_PC : 0x03, + DEVICE_TYPE_TV : 0x04, + DEVICE_TYPE_WEARABLE : 0x06 + } + + const DeviceCapabilityClass = class DeviceCapability { + constructor() { + console.warn('resourceManager.DeviceCapability.constructor interface mocked in the Previewer. How this interface works on' + + ' the Previewer may be different from that on a real device.'); + this.screenDensity = ScreenDensity; + this.deviceType = DeviceType; + } + } + + 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.") - if (typeof callback === 'function') { - callback.call(this, null, data); + 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(data); + return new Promise((resolve, reject) => { + resolve(paramMock.paramStringMock); }) } - } + }, - this.getStringArray = getStringArray; - async function getStringArray(resId, callback) { - var data = ["mock string1", "mock string2"]; + 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.") - if (typeof callback === 'function') { - callback.call(this, null, data); + 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(data); + return new Promise((resolve, reject) => { + resolve([paramMock.paramStringMock]); }) } - } + }, - this.getMedia = getMedia; - async function getMedia(resId, callback) { - var data = "mock media data"; + 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.") - if (typeof callback === 'function') { - callback.call(this, 1, data); + 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) => { - reject(data); + resolve(paramMock.paramArrayMock); }) } - } + }, - this.getMediaBase64 = getMediaBase64; - async function getMediaBase64(resId, callback) { - var data = "mock media data"; + 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.") - if (typeof callback === 'function') { - callback.call(this, 1, data); + 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) => { - reject(data); + resolve(paramMock.paramArrayMock); }) } - } + }, - this.getPluralString = getPluralString; - async function getPluralString(resId, num, callback) { - var data = "mock plural string"; + 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.") - if (typeof callback === 'function') { - callback.call(this, null, data); + 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(data); + return new Promise((resolve, reject) => { + resolve(paramMock.paramStringMock); }) } - } + }, - this.getConfiguration = getConfiguration; - async function getConfiguration(callback) { - var data = { "direction": 0, "locale": "zh_CN" }; + 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.") - if (typeof callback === 'function') { - callback.call(this, null, data); + const len = args.length + if (typeof args[len - 1] === 'function') { + args[len - 1].call(this, paramMock.businessErrorMock, new ConfigurationClass()); } else { - return new Promise((resolve) => { - resolve(data); + return new Promise((resolve, reject) => { + resolve(new ConfigurationClass()); }) } - } + }, - this.getDeviceCapability = getDeviceCapability; - async function getDeviceCapability(callback) { - var data = { "deviceType": 0, "screenDensity": 480 }; + 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.") - if (typeof callback === 'function') { - callback.call(this, null, data); + const len = args.length + if (typeof args[len - 1] === 'function') { + args[len - 1].call(this, paramMock.businessErrorMock, new DeviceCapabilityClass()); } else { - return new Promise((resolve) => { - resolve(data); + return new Promise((resolve, reject) => { + resolve(new DeviceCapabilityClass()); }) } - } + }, - this.release = release; - async function release(callback) { + 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.") - } + }, - this.getRawFile = getRawFile; - async function getRawFile(path, callback) { - var data = "mock raw file"; + 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.") - if (typeof callback === 'function') { - callback.call(this, null, data); + const len = args.length + if (typeof args[len - 1] === 'function') { + args[len - 1].call(this, paramMock.businessErrorMock, paramMock.paramArrayMock); } else { - return new Promise((resolve) => { - resolve(data); + return new Promise((resolve, reject) => { + resolve(paramMock.paramArrayMock); }) } - } + }, - this.getRawFileDescriptor = getRawFileDescriptor; - async function getRawFileDescriptor(path, callback) { - var data = "mock raw file descriptor"; + 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.") - if (typeof callback === 'function') { - callback.call(this, null, data); + const len = args.length + if (typeof args[len - 1] === 'function') { + args[len - 1].call(this, paramMock.businessErrorMock, RawFileDescriptor); } else { - return new Promise((resolve) => { - resolve(data); + return new Promise((resolve, reject) => { + resolve(RawFileDescriptor); }) } - } + }, - this.closeRawFileDescriptor = closeRawFileDescriptor; - async function closeRawFileDescriptor(path, callback) { - var data = "mock close raw file descriptor"; + 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.") - if (typeof callback === 'function') { - callback.call(this, null, data); + 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(data); + 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; } } - var resourceManagerMock = { + const resourceManager = { + ResourceManager, getResourceManager: async function getResourceManager(optBundleName, optCallback) { let bundleName = ''; let callback; @@ -187,21 +309,18 @@ export function mockResourceManager() { } else { bundleName = optBundleName ? optBundleName : ''; } - let data = new ResourceManager(1, null); console.warn("ResourceManager.getResourceManager interface mocked in the Previewer. " + "How this interface works on the Previewer may be different from that on a real device.") if (typeof callback === 'function') { - callback.call(this, 1, data); + callback.call(this, paramMock.businessErrorMock, ResourceManager); } else { - return new Promise((resolve) => { - resolve(data); + return new Promise((resolve, reject) => { + resolve(ResourceManager); }) } - } - }; - - const resourceManager = { - getResourceManager: resourceManagerMock.getResourceManager + }, } - return resourceManager + return resourceManager; } + + diff --git a/runtime/main/extend/systemplugin/napi/ohos_rpc.js b/runtime/main/extend/systemplugin/napi/ohos_rpc.js index a5141d9c..f8f0d322 100644 --- a/runtime/main/extend/systemplugin/napi/ohos_rpc.js +++ b/runtime/main/extend/systemplugin/napi/ohos_rpc.js @@ -428,12 +428,12 @@ export const MessageOptionClass = class MessageOption { console.warn("MessageOption.setWaitTime interface mocked in the Previewer. How this interface works on the" + " Previewer may be different from that on a real device.") }; + this.TF_SYNC = 0; + this.TF_ASYNC = 1; + this.TF_ACCEPT_FDS = 0x10; + this.TF_WAIT_TIME = 4; } }; -MessageOptionClass.TF_SYNC = '[PC preview] unknow TF_SYNC'; -MessageOptionClass.TF_ASYNC = '[PC preview] unknow TF_ASYNC'; -MessageOptionClass.TF_ACCEPT_FDS = '[PC preview] unknow TF_ACCEPT_FDS'; -MessageOptionClass.TF_WAIT_TIME = '[PC preview] unknow TF_WAIT_TIME'; export const AshmemClass = class Ashmem { constructor() { console.warn('rpc.Ashmem constructor interface mocked in the Previewer. How this interface works on the' + @@ -481,6 +481,10 @@ export const AshmemClass = class Ashmem { ' Previewer may be different from that on a real device.') return paramMock.paramArrayMock }; + this.PROT_EXEC = 4; + this.PROT_NONE = 0; + this.PROT_READ = 1; + this.PROT_WRITE = 2; } }; AshmemClass.createAshmem = function (...args) { @@ -493,10 +497,6 @@ AshmemClass.createAshmemFromExisting = function (...args) { ' Previewer may be different from that on a real device.') return new AshmemClass() }; -AshmemClass.PROT_EXEC = '[PC preview] unknow PROT_EXEC'; -AshmemClass.PROT_NONE = '[PC preview] unknow PROT_NONE'; -AshmemClass.PROT_READ = '[PC preview] unknow PROT_READ'; -AshmemClass.PROT_WRITE = '[PC preview] unknow PROT_WRITE'; export const RemoteObjectClass = class RemoteObject { constructor(...args) { console.warn("rpc.RemoteObject constructor interface mocked in the Previewer. How this interface works on the" + @@ -600,13 +600,16 @@ export const RemoteProxyClass = class RemoteProxy { }) } }; + this.PING_TRANSACTION = ('_'.charCodeAt(0) << 24) | ('P'.charCodeAt(0) << 16) | + ('N'.charCodeAt(0) << 8) | 'G'.charCodeAt(0); + this.DUMP_TRANSACTION = ('_'.charCodeAt(0) << 24) | ('D'.charCodeAt(0) << 16) | + ('M'.charCodeAt(0) << 8) | 'P'.charCodeAt(0); + this.INTERFACE_TRANSACTION = ('_'.charCodeAt(0) << 24) | ('N'.charCodeAt(0) << 16) | + ('T'.charCodeAt(0) << 8) | 'F'.charCodeAt(0); + this.MIN_TRANSACTION_ID = 0x1; + this.MAX_TRANSACTION_ID = 0x00FFFFFF; } }; -RemoteProxyClass.PING_TRANSACTION = '[PC preview] unknow PING_TRANSACTION'; -RemoteProxyClass.DUMP_TRANSACTION = '[PC preview] unknow DUMP_TRANSACTION'; -RemoteProxyClass.INTERFACE_TRANSACTION = '[PC preview] unknow INTERFACE_TRANSACTION'; -RemoteProxyClass.MIN_TRANSACTION_ID = '[PC preview] unknow MIN_TRANSACTION_ID'; -RemoteProxyClass.MAX_TRANSACTION_ID = '[PC preview] unknow MAX_TRANSACTION_ID'; export const IRemoteObjectMock = { queryLocalInterface: function (...args) { console.warn("IRemoteObject.queryLocalInterface interface mocked in the Previewer. How this interface works on the" + diff --git a/runtime/main/extend/systemplugin/napi/ohos_screen.js b/runtime/main/extend/systemplugin/napi/ohos_screen.js index 7f1f597f..3740235b 100644 --- a/runtime/main/extend/systemplugin/napi/ohos_screen.js +++ b/runtime/main/extend/systemplugin/napi/ohos_screen.js @@ -1,211 +1,247 @@ -/* - * 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 OrientationMock = { - UNSPECIFIED: 0, - VERTICAL: 1, - HORIZONTAL: 2, - REVERSE_VERTICAL: 3, - REVERSE_HORIZONTAL: 4, - SENSOR: 5, - SENSOR_VERTICAL: 6, - SENSOR_HORIZONTAL: 7 -}; - -export const screenMock = { - id: 'PC preview] unknown id', - parent: '[PC preview] unknown parent', - supportedModeInfo: supportedModeInfoMock, - activeModeIndex: '[PC preview] unknown activeModeIndex', - orientation: OrientationMock, - setOrientation: function(...args) { - console.warn('Screen.setOrientation 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(); - }); - } - }, - setScreenActiveMode: function(...args) { - console.warn('Screen.setScreenActiveMode 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(); - }); - } - }, - setDensityDpi: function(...args) { - console.warn('Screen.setDensityDpi 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(); - }); - } - } -}; - -export const allScreenMock = [ - screenMock -]; - -export const ExpandOptionMock = { - screenId: '[PC preview] unknown screenId', - startX: '[PC preview] unknown startX', - startY: '[PC preview] unknown startY' -}; - -export const VirtualScreenOptionMock = { - name: '[PC preview] unknown name', - width: '[PC preview] unknown width', - height: '[PC preview] unknown height', - density: '[PC preview] unknown density', - surfaceId: '[PC preview] unknown surfaceId' -}; - -export const screenModeInfoMock = { - id: '[PC preview] unknown id', - width: '[PC preview] unknown width', - height: '[PC preview] unknown height', - refreshRate: '[PC preview] unknown refreshRate' -}; - -export const supportedModeInfoMock = [ - screenModeInfoMock -] - -export function mockScreen() { - const screen = { - ExpandOption: ExpandOptionMock, - VirtualScreenOption: VirtualScreenOptionMock, - Orientation: OrientationMock, - ScreenModeInfo: screenModeInfoMock, - getAllScreens: function(...args) { - console.warn('Screen.getAllScreens 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, allScreenMock); - } else { - return new Promise((resolve) => { - resolve(allScreenMock); - }); - } - }, - on: function(...args) { - console.warn('Screen.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] === 'connect' || args[0] === 'disconnect' || args[0] === 'change') { - console.warn(`you has registered ${args[0]} event`) - } else { - console.warn('on: please check first param!') - } - } else { - console.warn('on: please check param!') - } - }, - off: function(...args) { - console.warn('Screen.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') { - if (args[0] === 'connect' || args[0] === 'disconnect' || args[0] === 'change') { - console.warn(`you has registered ${args[0]} event`) - } else { - console.warn('off: please check first param!') - } - } else { - console.warn('off: please check param!') - } - }, - makeExpand: function(...args) { - console.warn('Screen.makeExpand 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); - }); - } - }, - makeMirror: function(...args) { - console.warn('Screen.makeMirror 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); - }); - } - }, - createVirtualScreen: function(...args) { - console.warn('Screen.createVirtualScreen 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, screenMock); - } else { - return new Promise((resolve) => { - resolve(screenMock); - }); - } - }, - destroyVirtualScreen: function(...args) { - console.warn('Screen.destroyVirtualScreen 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(); - }); - } - }, - setVirtualScreenSurface: function(...args) { - console.warn('Screen.setVirtualScreenSurface 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 screen -} - +/* + * 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 Orientation = { + UNSPECIFIED: 0, + VERTICAL: 1, + HORIZONTAL: 2, + REVERSE_VERTICAL: 3, + REVERSE_HORIZONTAL: 4, + SENSOR: 5, + SENSOR_VERTICAL: 6, + SENSOR_HORIZONTAL: 7 +}; + +export const Screen = { + id: 'PC preview] unknown id', + parent: '[PC preview] unknown parent', + supportedModeInfo: supportedModeInfoArray, + activeModeIndex: '[PC preview] unknown activeModeIndex', + orientation: Orientation, + setOrientation: function(...args) { + console.warn('Screen.setOrientation 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(); + }); + } + }, + setScreenActiveMode: function(...args) { + console.warn('Screen.setScreenActiveMode 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(); + }); + } + }, + setDensityDpi: function(...args) { + console.warn('Screen.setDensityDpi 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(); + }); + } + } +}; + +export const allScreenMock = [ + Screen +]; + +export const ExpandOption = { + screenId: '[PC preview] unknown screenId', + startX: '[PC preview] unknown startX', + startY: '[PC preview] unknown startY' +}; + +export const VirtualScreenOption = { + name: '[PC preview] unknown name', + width: '[PC preview] unknown width', + height: '[PC preview] unknown height', + density: '[PC preview] unknown density', + surfaceId: '[PC preview] unknown surfaceId' +}; + +export const ScreenModeInfo = { + id: '[PC preview] unknown id', + width: '[PC preview] unknown width', + height: '[PC preview] unknown height', + refreshRate: '[PC preview] unknown refreshRate' +}; + +export const supportedModeInfoArray = [ + ScreenModeInfo +] +const EventTypeMock = { + connect: 'connect', + disconnect: 'disconnect', + change: 'change' +} +export function mockScreen() { + const screen = { + ExpandOption, + VirtualScreenOption, + Orientation, + ScreenModeInfo, + getAllScreens: function(...args) { + console.warn('Screen.getAllScreens 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, allScreenMock); + } else { + return new Promise((resolve) => { + resolve(allScreenMock); + }); + } + }, + on: function(...args) { + console.warn('Screen.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 (len!==2){ + console.warn("Screen.on please check params!") + return + } + if (typeof args[len - 1] === 'function') { + if (args[0] === EventTypeMock.connect || args[0] === EventTypeMock.disconnect || args[0] === EventTypeMock.change) { + console.warn(`Screen.on you has registered ${args[0]} event`) + } else { + console.warn('Screen.on please check first param!') + } + } else { + console.warn('Screen.on please check param!') + } + }, + off: function(...args) { + console.warn('Screen.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 (len!==2){ + console.warn("Screen.off please check params!") + return + } + if (typeof args[len - 1] === 'function') { + if (args[0] === EventTypeMock.connect || args[0] === EventTypeMock.disconnect || args[0] === EventTypeMock.change) { + console.warn(`Screen.off you has registered ${args[0]} event`) + } else { + console.warn('Screen.off please check first param!') + } + } else { + console.warn('Screen.off please check param!') + } + }, + makeExpand: function(...args) { + console.warn('Screen.makeExpand 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); + }); + } + }, + makeMirror: function(...args) { + console.warn( 'Screen.makeMirror 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); + }); + } + }, + createVirtualScreen: function(...args) { + console.warn( 'Screen.createVirtualScreen 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, Screen); + } else { + return new Promise((resolve) => { + resolve(Screen); + }); + } + }, + destroyVirtualScreen: function(...args) { + console.warn('Screen.destroyVirtualScreen 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(); + }); + } + }, + setVirtualScreenSurface: function(...args) { + console.warn( 'Screen.setVirtualScreenSurface 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(); + }); + } + }, + isScreenRotationLocked: function(...args) { + console.warn( 'Screen.setVirtualScreenSurface 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); + }); + } + }, + setScreenRotationLocked: function(...args) { + console.warn( 'Screen.setVirtualScreenSurface 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); + }); + } + } + } + return screen +} + diff --git a/runtime/main/extend/systemplugin/napi/ohos_screenLock.js b/runtime/main/extend/systemplugin/napi/ohos_screenLock.js index 893f232c..2d3c9501 100644 --- a/runtime/main/extend/systemplugin/napi/ohos_screenLock.js +++ b/runtime/main/extend/systemplugin/napi/ohos_screenLock.js @@ -52,6 +52,45 @@ export function mockScreenLock() { resolve(); }) } + }, + on: function (...args) { + console.warn("screenLock.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] == 'beginWakeUp' || args[0] == 'endWakeUp' || args[0] == 'beginScreenOn' || args[0] == 'endScreenOn' + || args[0] == 'beginScreenOff' || args[0] == 'endScreenOff' || args[0] == 'unlockScreen' || args[0] == 'beginExitAnimation') { + args[len - 1].call(this); + } else if (args[0] == 'beginSleep' || args[0] == 'endSleep' || args[0] == 'changeUser') { + args[len - 1].call(this, paramMock.paramNumberMock); + } else if (args[0] == 'screenlockEnabled') { + args[len - 1].call(this, paramMock.paramBooleanMock); + } + } + }, + off: function (...args) { + console.warn("screenLock.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') { + if (args[0] == 'beginWakeUp' || args[0] == 'endWakeUp' || args[0] == 'beginScreenOn' || args[0] == 'endScreenOn' + || args[0] == 'beginScreenOff' || args[0] == 'endScreenOff' || args[0] == 'unlockScreen' || args[0] == 'beginExitAnimation' + || args[0] == 'screenlockEnabled' || args[0] == 'beginSleep' || args[0] == 'endSleep' || args[0] == 'changeUser') { + args[len - 1].call(this); + } + } + }, + sendScreenLockEvent: function (...args) { + console.warn("screenLock.sendScreenLockEvent 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); + }) + } } } return screenLock diff --git a/runtime/main/extend/systemplugin/napi/ohos_securitylabel.js b/runtime/main/extend/systemplugin/napi/ohos_securitylabel.js index 3189193f..3270c0a2 100644 --- a/runtime/main/extend/systemplugin/napi/ohos_securitylabel.js +++ b/runtime/main/extend/systemplugin/napi/ohos_securitylabel.js @@ -29,6 +29,10 @@ export function mockSecurityLabel() { }) } }, + setSecurityLabelSync: function (...args) { + console.warn("securitylabel.setSecurityLabelSync interface mocked in the Previewer. How this interface works on the" + + " Previewer may be different from that on a real device.") + }, getSecurityLabel: function (...args) { console.warn("securitylabel.getSecurityLabel interface mocked in the Previewer. How this interface works on the" + " Previewer may be different from that on a real device.") @@ -41,6 +45,11 @@ export function mockSecurityLabel() { }) } }, + getSecurityLabelSync: function (...args) { + console.warn("securitylabel.getSecurityLabelSync 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 securitylabel; } diff --git a/runtime/main/extend/systemplugin/napi/ohos_sensor.js b/runtime/main/extend/systemplugin/napi/ohos_sensor.js index f81ae7c1..fddc787f 100644 --- a/runtime/main/extend/systemplugin/napi/ohos_sensor.js +++ b/runtime/main/extend/systemplugin/napi/ohos_sensor.js @@ -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 @@ -16,341 +16,395 @@ import { paramMock } from "../utils" export function mockSensor() { - const AccelerometerResponse = { - x: "[PC preview] unknown x", - y: "[PC preview] unknown y", - z: "[PC preview] unknown z" - } - const LinearAccelerometerResponse = { - x: "[PC preview] unknown x", - y: "[PC preview] unknown y", - z: "[PC preview] unknown z" - } - const AccelerometerUncalibratedResponse = { - x: "[PC preview] unknown x", - y: "[PC preview] unknown y", - z: "[PC preview] unknown z", - biasX: "[PC preview] unknown biasX", - biasY: "[PC preview] unknown biasY", - biasZ: "[PC preview] unknown biasZ" - } - const GravityResponse = { - x: "[PC preview] unknown x", - y: "[PC preview] unknown y", - z: "[PC preview] unknown z" - } - const OrientationResponse = { - alpha: "[PC preview] unknown alpha", - beta: "[PC preview] unknown beta", - gamma: "[PC preview] unknown gamma" - } - const RotationVectorResponse = { - x: "[PC preview] unknown x", - y: "[PC preview] unknown y", - z: "[PC preview] unknown z" - } - const GyroscopeResponse = { - x: "[PC preview] unknown x", - y: "[PC preview] unknown y", - z: "[PC preview] unknown z" - } - const GyroscopeUncalibratedResponse = { - x: "[PC preview] unknown x", - y: "[PC preview] unknown y", - z: "[PC preview] unknown z", - biasX: "[PC preview] unknown biasX", - biasY: "[PC preview] unknown biasY", - biasZ: "[PC preview] unknown biasZ" - } - const SignificantMotionResponse = { - scalar: "[PC preview] unknown scalar" - } - const ProximityResponse = { - distance: "[PC preview] unknown distance" - } - const LightResponse = { - intensity: "[PC preview] unknown intensity" - } - const HallResponse = { - status: "[PC preview] unknown status" - } - const MagneticFieldResponse = { - x: "[PC preview] unknown x", - y: "[PC preview] unknown y", - z: "[PC preview] unknown z" - } - const MagneticFieldUncalibratedResponse = { - x: "[PC preview] unknown x", - y: "[PC preview] unknown y", - z: "[PC preview] unknown z", - biasX: "[PC preview] unknown biasX", - biasY: "[PC preview] unknown biasY", - biasZ: "[PC preview] unknown biasZ" - } - const PedometerResponse = { - steps: "[PC preview] unknown steps" - } - const HumidityResponse = { - humidity: "[PC preview] unknown humidity" - } - const PedometerDetectResponse = { - scalar: "[PC preview] unknown scalar" - } - const AmbientTemperatureResponse = { - temperature: "[PC preview] unknown temperature" - } - const BarometerResponse = { - pressure: "[PC preview] unknown pressure" - } - const HeartRateResponse = { - heartRate: "[PC preview] unknown heartRate" - } - const WearDetectionResponse = { - value: "[PC preview] unknown value" - } - const Options = { - interval: "[PC preview] unknown value" - } - const GeomagneticResponse = { - x: "[PC preview] unknown x", - y: "[PC preview] unknown y", - z: "[PC preview] unknown z", - biasX: "[PC preview] unknown biasX", - biasY: "[PC preview] unknown biasY", - biasZ: "[PC preview] unknown biasZ" - } - const LocationOptions = { - latitude: "[PC preview] unknown latitude", - longitude: "[PC preview] unknown longitude", - altitude: "[PC preview] unknown altitude", - } - const CoordinatesOptions = { - x: "[PC preview] unknown x", - y: "[PC preview] unknown y" - } - const SensorType = { - SENSOR_TYPE_ID_ACCELEROMETER: 1, - SENSOR_TYPE_ID_GYROSCOPE: 2, - SENSOR_TYPE_ID_AMBIENT_LIGHT: 5, - SENSOR_TYPE_ID_MAGNETIC_FIELD: 6, - SENSOR_TYPE_ID_BAROMETER: 8, - SENSOR_TYPE_ID_HALL: 10, - SENSOR_TYPE_ID_PROXIMITY: 12, - SENSOR_TYPE_ID_HUMIDITY: 13, - SENSOR_TYPE_ID_ORIENTATION: 256, - SENSOR_TYPE_ID_GRAVITY: 257, - SENSOR_TYPE_ID_LINEAR_ACCELERATION: 258, - SENSOR_TYPE_ID_ROTATION_VECTOR: 259, - SENSOR_TYPE_ID_AMBIENT_TEMPERATURE: 260, - SENSOR_TYPE_ID_MAGNETIC_FIELD_UNCALIBRATED: 261, - SENSOR_TYPE_ID_GYROSCOPE_UNCALIBRATED: 263, - SENSOR_TYPE_ID_SIGNIFICANT_MOTION: 264, - SENSOR_TYPE_ID_PEDOMETER_DETECTION: 265, - SENSOR_TYPE_ID_PEDOMETER: 266, - SENSOR_TYPE_ID_HEART_RATE: 278, - SENSOR_TYPE_ID_WEAR_DETECTION: 280, - SENSOR_TYPE_ID_ACCELEROMETER_UNCALIBRATED: 281 - } - const sensor = { - on: function (...args) { - console.warn("sensor.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; - const callback = typeof args[len - 1] == 'function' ? args[len - 1] : args[len - 2]; - if (args[0] == 1) { - callback.call(this, paramMock.businessErrorMock, AccelerometerResponse); - } else if (args[0] == 2) { - callback.call(this, paramMock.businessErrorMock, GyroscopeResponse); - } else if (args[0] == 5) { - callback.call(this, paramMock.businessErrorMock, LightResponse); - } else if (args[0] == 6) { - callback.call(this, paramMock.businessErrorMock, MagneticFieldResponse); - } else if (args[0] == 8) { - callback.call(this, paramMock.businessErrorMock, BarometerResponse); - } else if (args[0] == 10) { - callback.call(this, paramMock.businessErrorMock, HallResponse); - } else if (args[0] == 12) { - callback.call(this, paramMock.businessErrorMock, ProximityResponse); - } else if (args[0] == 13) { - callback.call(this, paramMock.businessErrorMock, HumidityResponse); - } else if (args[0] == 256) { - callback.call(this, paramMock.businessErrorMock, OrientationResponse); - } else if (args[0] == 257) { - callback.call(this, paramMock.businessErrorMock, GravityResponse); - } else if (args[0] == 258) { - callback.call(this, paramMock.businessErrorMock, LinearAccelerometerResponse); - } else if (args[0] == 259) { - callback.call(this, paramMock.businessErrorMock, RotationVectorResponse); - } else if (args[0] == 260) { - callback.call(this, paramMock.businessErrorMock, AmbientTemperatureResponse); - } else if (args[0] == 261) { - callback.call(this, paramMock.businessErrorMock, MagneticFieldUncalibratedResponse); - } else if (args[0] == 263) { - callback.call(this, paramMock.businessErrorMock, GyroscopeUncalibratedResponse); - } else if (args[0] == 264) { - callback.call(this, paramMock.businessErrorMock, SignificantMotionResponse); - } else if (args[0] == 265) { - callback.call(this, paramMock.businessErrorMock, PedometerDetectResponse); - } else if (args[0] == 266) { - callback.call(this, paramMock.businessErrorMock, PedometerResponse); - } else if (args[0] == 278) { - callback.call(this, paramMock.businessErrorMock, HeartRateResponse); - } else if (args[0] == 280) { - callback.call(this, paramMock.businessErrorMock, WearDetectionResponse); - } else if (args[0] == 281) { - callback.call(this, paramMock.businessErrorMock, AccelerometerUncalibratedResponse); - } - }, - once: function (...args) { - console.warn("sensor.once 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 (args[0] == 1) { - args[len - 1].call(this, paramMock.businessErrorMock, AccelerometerResponse); - } else if (args[0] == 2) { - args[len - 1].call(this, paramMock.businessErrorMock, GyroscopeResponse); - } else if (args[0] == 5) { - args[len - 1].call(this, paramMock.businessErrorMock, LightResponse); - } else if (args[0] == 6) { - args[len - 1].call(this, paramMock.businessErrorMock, MagneticFieldResponse); - } else if (args[0] == 8) { - args[len - 1].call(this, paramMock.businessErrorMock, BarometerResponse); - } else if (args[0] == 10) { - args[len - 1].call(this, paramMock.businessErrorMock, HallResponse); - } else if (args[0] == 12) { - args[len - 1].call(this, paramMock.businessErrorMock, ProximityResponse); - } else if (args[0] == 13) { - args[len - 1].call(this, paramMock.businessErrorMock, HumidityResponse); - } else if (args[0] == 256) { - args[len - 1].call(this, paramMock.businessErrorMock, OrientationResponse); - } else if (args[0] == 257) { - args[len - 1].call(this, paramMock.businessErrorMock, GravityResponse); - } else if (args[0] == 258) { - args[len - 1].call(this, paramMock.businessErrorMock, LinearAccelerometerResponse); - } else if (args[0] == 259) { - args[len - 1].call(this, paramMock.businessErrorMock, RotationVectorResponse); - } else if (args[0] == 260) { - args[len - 1].call(this, paramMock.businessErrorMock, AmbientTemperatureResponse); - } else if (args[0] == 261) { - args[len - 1].call(this, paramMock.businessErrorMock, MagneticFieldUncalibratedResponse); - } else if (args[0] == 263) { - args[len - 1].call(this, paramMock.businessErrorMock, GyroscopeUncalibratedResponse); - } else if (args[0] == 264) { - args[len - 1].call(this, paramMock.businessErrorMock, SignificantMotionResponse); - } else if (args[0] == 265) { - args[len - 1].call(this, paramMock.businessErrorMock, PedometerDetectResponse); - } else if (args[0] == 266) { - args[len - 1].call(this, paramMock.businessErrorMock, PedometerResponse); - } else if (args[0] == 278) { - args[len - 1].call(this, paramMock.businessErrorMock, HeartRateResponse); - } else if (args[0] == 280) { - args[len - 1].call(this, paramMock.businessErrorMock, WearDetectionResponse); - } else if (args[0] == 281) { - args[len - 1].call(this, paramMock.businessErrorMock, AccelerometerUncalibratedResponse); - } - }, - off: function (...args) { - console.warn("sensor.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, paramMock.businessErrorMock); - }, - getGeomagneticField: function (...args) { - console.warn("sensor.getGeomagneticField 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.businessErrorMoc, GeomagneticResponse); - } else { - return new Promise((resolve, reject) => { - resolve(GeomagneticResponse); - }) - } - }, - getAltitude: function (...args) { - console.warn("sensor.getAltitude 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.businessErrorMoc, paramMock.paramNumberMock); - } else { - return new Promise((resolve, reject) => { - resolve(paramMock.paramNumberMock); - }) - } - }, - getGeomagneticDip: function (...args) { - console.warn("sensor.getGeomagneticDip 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.businessErrorMoc, paramMock.paramNumberMock); - } else { - return new Promise((resolve, reject) => { - resolve(paramMock.paramNumberMock); - }) - } - }, - getAngleModifiy: function (...args) { - console.warn("sensor.getAngleModifiy 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.businessErrorMoc, paramMock.paramArrayMock); - } else { - return new Promise((resolve, reject) => { - resolve(paramMock.paramArrayMock); - }) - } - }, - createRotationMatrix: function (...args) { - console.warn("sensor.createRotationMatrix 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.businessErrorMoc, paramMock.paramArrayMock); - } else { - return new Promise((resolve, reject) => { - resolve(paramMock.paramArrayMock); - }) - } - }, - transformCoordinateSystem: function (...args) { - console.warn("sensor.transformCoordinateSystem 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.businessErrorMoc, paramMock.paramArrayMock); - } else { - return new Promise((resolve, reject) => { - resolve(paramMock.paramArrayMock); - }) - } - }, - createQuaternion: function (...args) { - console.warn("sensor.createQuaternion 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.businessErrorMoc, paramMock.paramArrayMock); - } else { - return new Promise((resolve, reject) => { - resolve(paramMock.paramArrayMock); - }) - } - }, - getDirection: function (...args) { - console.warn("sensor.getDirection 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.businessErrorMoc, paramMock.paramArrayMock); - } else { - return new Promise((resolve, reject) => { - resolve(paramMock.paramArrayMock); - }) - } + const AccelerometerResponse = { + x: '[PC preview] unknown x', + y: '[PC preview] unknown y', + z: '[PC preview] unknown z' } - } - return sensor -} + const LinearAccelerometerResponse = { + x: '[PC preview] unknown x', + y: '[PC preview] unknown y', + z: '[PC preview] unknown z' + } + const AccelerometerUncalibratedResponse = { + x: '[PC preview] unknown x', + y: '[PC preview] unknown y', + z: '[PC preview] unknown z', + biasX: '[PC preview] unknown biasX', + biasY: '[PC preview] unknown biasY', + biasZ: '[PC preview] unknown biasZ' + } + const GravityResponse = { + x: '[PC preview] unknown x', + y: '[PC preview] unknown y', + z: '[PC preview] unknown z' + } + const OrientationResponse = { + alpha: '[PC preview] unknown alpha', + beta: '[PC preview] unknown beta', + gamma: '[PC preview] unknown gamma' + } + const RotationVectorResponse = { + x: '[PC preview] unknown x', + y: '[PC preview] unknown y', + z: '[PC preview] unknown z', + w: '[PC preview] unknown w' + } + const GyroscopeResponse = { + x: '[PC preview] unknown x', + y: '[PC preview] unknown y', + z: '[PC preview] unknown z' + } + const GyroscopeUncalibratedResponse = { + x: '[PC preview] unknown x', + y: '[PC preview] unknown y', + z: '[PC preview] unknown z', + biasX: '[PC preview] unknown biasX', + biasY: '[PC preview] unknown biasY', + biasZ: '[PC preview] unknown biasZ' + } + const SignificantMotionResponse = { + scalar: '[PC preview] unknown scalar' + } + const ProximityResponse = { + distance: '[PC preview] unknown distance' + } + const LightResponse = { + intensity: '[PC preview] unknown intensity' + } + const HallResponse = { + status: '[PC preview] unknown status' + } + const MagneticFieldResponse = { + x: '[PC preview] unknown x', + y: '[PC preview] unknown y', + z: '[PC preview] unknown z' + } + const MagneticFieldUncalibratedResponse = { + x: '[PC preview] unknown x', + y: '[PC preview] unknown y', + z: '[PC preview] unknown z', + biasX: '[PC preview] unknown biasX', + biasY: '[PC preview] unknown biasY', + biasZ: '[PC preview] unknown biasZ' + } + const PedometerResponse = { + steps: '[PC preview] unknown steps' + } + const HumidityResponse = { + humidity: '[PC preview] unknown humidity' + } + const PedometerDetectResponse = { + scalar: '[PC preview] unknown scalar' + } + const AmbientTemperatureResponse = { + temperature: '[PC preview] unknown temperature' + } + const BarometerResponse = { + pressure: '[PC preview] unknown pressure' + } + const HeartRateResponse = { + heartRate: '[PC preview] unknown heartRate' + } + const WearDetectionResponse = { + value: '[PC preview] unknown value' + } + const Options = { + interval: '[PC preview] unknown value' + } + const GeomagneticResponse = { + x: '[PC preview] unknown x', + y: '[PC preview] unknown y', + z: '[PC preview] unknown z', + geomagneticDip: '[PC preview] unknown geomagneticDip', + deflectionAngle: '[PC preview] unknown deflectionAngle', + levelIntensity: '[PC preview] unknown levelIntensity', + totalIntensity: '[PC preview] unknown totalIntensity' + } + const PedometerDetectionResponse = { + scalar: '[PC preview] unknown scalar' + } + const Response = { + timestamp: '[PC preview] unknown z' + } + const LocationOptions = { + latitude: '[PC preview] unknown latitude', + longitude: '[PC preview] unknown longitude', + altitude: '[PC preview] unknown altitude' + } + const CoordinatesOptions = { + x: '[PC preview] unknown x', + y: '[PC preview] unknown y' + } + const RotationMatrixResponse = { + rotation: '[PC preview] unknown rotation', + inclination: '[PC preview] unknown inclination' + } + const Sensor = { + sensorName: '[PC preview] unknown sensorName', + venderName: '[PC preview] unknown venderName', + firmwareVersion: '[PC preview] unknown firmwareVersion', + hardwareVersion: '[PC preview] unknown hardwareVersion', + sensorTypeId: '[PC preview] unknown sensorTypeId', + maxRange: '[PC preview] unknown maxRange', + precision: '[PC preview] unknown precision', + power: '[PC preview] unknown power' + } + const SensorType = { + SENSOR_TYPE_ID_ACCELEROMETER: 1, + SENSOR_TYPE_ID_GYROSCOPE: 2, + SENSOR_TYPE_ID_AMBIENT_LIGHT: 5, + SENSOR_TYPE_ID_MAGNETIC_FIELD: 6, + SENSOR_TYPE_ID_BAROMETER: 8, + SENSOR_TYPE_ID_HALL: 10, + SENSOR_TYPE_ID_PROXIMITY: 12, + SENSOR_TYPE_ID_HUMIDITY: 13, + SENSOR_TYPE_ID_ORIENTATION: 256, + SENSOR_TYPE_ID_GRAVITY: 257, + SENSOR_TYPE_ID_LINEAR_ACCELERATION: 258, + SENSOR_TYPE_ID_ROTATION_VECTOR: 259, + SENSOR_TYPE_ID_AMBIENT_TEMPERATURE: 260, + SENSOR_TYPE_ID_MAGNETIC_FIELD_UNCALIBRATED: 261, + SENSOR_TYPE_ID_GYROSCOPE_UNCALIBRATED: 263, + SENSOR_TYPE_ID_SIGNIFICANT_MOTION: 264, + SENSOR_TYPE_ID_PEDOMETER_DETECTION: 265, + SENSOR_TYPE_ID_PEDOMETER: 266, + SENSOR_TYPE_ID_HEART_RATE: 278, + SENSOR_TYPE_ID_WEAR_DETECTION: 280, + SENSOR_TYPE_ID_ACCELEROMETER_UNCALIBRATED: 281 + } + const sensor = { + Sensor, + on: function (...args) { + console.warn('sensor.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; + const callback = typeof args[len - 1] === 'function' ? args[len - 1] : args[len - 2]; + if (args[0] == 1) { + callback.call(this, AccelerometerResponse); + } else if (args[0] == 2) { + callback.call(this, GyroscopeResponse); + } else if (args[0] == 5) { + callback.call(this, LightResponse); + } else if (args[0] == 6) { + callback.call(this, MagneticFieldResponse); + } else if (args[0] == 8) { + callback.call(this, BarometerResponse); + } else if (args[0] == 10) { + callback.call(this, HallResponse); + } else if (args[0] == 12) { + callback.call(this, ProximityResponse); + } else if (args[0] == 13) { + callback.call(this, HumidityResponse); + } else if (args[0] == 256) { + callback.call(this, OrientationResponse); + } else if (args[0] == 257) { + callback.call(this, GravityResponse); + } else if (args[0] == 258) { + callback.call(this, LinearAccelerometerResponse); + } else if (args[0] == 259) { + callback.call(this, RotationVectorResponse); + } else if (args[0] == 260) { + callback.call(this, AmbientTemperatureResponse); + } else if (args[0] == 261) { + callback.call(this, MagneticFieldUncalibratedResponse); + } else if (args[0] == 263) { + callback.call(this, GyroscopeUncalibratedResponse); + } else if (args[0] == 264) { + callback.call(this, SignificantMotionResponse); + } else if (args[0] == 265) { + callback.call(this, PedometerDetectResponse); + } else if (args[0] == 266) { + callback.call(this, PedometerResponse); + } else if (args[0] == 278) { + callback.call(this, HeartRateResponse); + } else if (args[0] == 280) { + callback.call(this, WearDetectionResponse); + } else if (args[0] == 281) { + callback.call(this, AccelerometerUncalibratedResponse); + } + }, + once: function (...args) { + console.warn('sensor.once 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 (args[0] == 1) { + args[len - 1].call(this, AccelerometerResponse); + } else if (args[0] == 2) { + args[len - 1].call(this, GyroscopeResponse); + } else if (args[0] == 5) { + args[len - 1].call(this, LightResponse); + } else if (args[0] == 6) { + args[len - 1].call(this, MagneticFieldResponse); + } else if (args[0] == 8) { + args[len - 1].call(this, BarometerResponse); + } else if (args[0] == 10) { + args[len - 1].call(this, HallResponse); + } else if (args[0] == 12) { + args[len - 1].call(this, ProximityResponse); + } else if (args[0] == 13) { + args[len - 1].call(this, HumidityResponse); + } else if (args[0] == 256) { + args[len - 1].call(this, OrientationResponse); + } else if (args[0] == 257) { + args[len - 1].call(this, GravityResponse); + } else if (args[0] == 258) { + args[len - 1].call(this, LinearAccelerometerResponse); + } else if (args[0] == 259) { + args[len - 1].call(this, RotationVectorResponse); + } else if (args[0] == 260) { + args[len - 1].call(this, AmbientTemperatureResponse); + } else if (args[0] == 261) { + args[len - 1].call(this, MagneticFieldUncalibratedResponse); + } else if (args[0] == 263) { + args[len - 1].call(this, GyroscopeUncalibratedResponse); + } else if (args[0] == 264) { + args[len - 1].call(this, SignificantMotionResponse); + } else if (args[0] == 265) { + args[len - 1].call(this, PedometerDetectResponse); + } else if (args[0] == 266) { + args[len - 1].call(this, PedometerResponse); + } else if (args[0] == 278) { + args[len - 1].call(this, HeartRateResponse); + } else if (args[0] == 280) { + args[len - 1].call(this, WearDetectionResponse); + } else if (args[0] == 281) { + args[len - 1].call(this, AccelerometerUncalibratedResponse); + } + }, + off: function (...args) { + console.warn('sensor.off interface mocked in the Previewer. How this interface works on the' + + 'Previewer may be different from that on a real device.') + }, + getGeomagneticField: function (...args) { + console.warn('sensor.getGeomagneticField 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, GeomagneticResponse); + } else { + return new Promise((resolve, reject) => { + resolve(GeomagneticResponse); + }); + } + }, + getAltitude: function (...args) { + console.warn('sensor.getAltitude 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, reject) => { + resolve(paramMock.paramNumberMock); + }); + } + }, + getGeomagneticDip: function (...args) { + console.warn('sensor.getGeomagneticDip 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, reject) => { + resolve(paramMock.paramNumberMock); + }); + } + }, + getAngleModify: function (...args) { + console.warn('sensor.getAngleModifiy 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.paraNumberMock]); + } else { + return new Promise((resolve, reject) => { + resolve([paramMock.paraNumberMock]); + }); + } + }, + createRotationMatrix: function (...args) { + console.warn('sensor.createRotationMatrix 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 == 1) { + return new Promise((resolve, reject) => { + resolve(paramMock.paramArrayMock); + }); + } else if (len == 2) { + if (typeof args[len - 1] == 'function') { + args[len - 1].call(this, paramMock.businessErrorMock, paramMock.paramArrayMock); + } else { + return new Promise((resolve, reject) => { + resolve(RotationMatrixResponse); + }); + } + } else if (len == 3) { + args[len - 1].call(this, paramMock.businessErrorMock, paramMock.RotationMatrixResponse); + } + + }, + transformCoordinateSystem: function (...args) { + console.warn('sensor.transformCoordinateSystem 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.paraNumberMock]); + } else { + return new Promise((resolve, reject) => { + resolve([paramMock.paraNumberMock]); + }); + } + }, + createQuaternion: function (...args) { + console.warn('sensor.createQuaternion 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.paraNumberMock]); + } else { + return new Promise((resolve, reject) => { + resolve([paramMock.paraNumberMock]); + }); + } + }, + getDirection: function (...args) { + console.warn('sensor.getDirection 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.paraNumberMock]); + } else { + return new Promise((resolve, reject) => { + resolve([paramMock.paraNumberMock]); + }); + } + }, + getSingleSensor: function (...args) { + console.warn('sensor.getSingleSensor 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, Sensor); + } else { + return new Promise((resolve, reject) => { + resolve(Sensor); + }); + } + }, + getSensorLists: function (...args) { + console.warn('sensor.getSensorLists 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 Array(Sensor)); + } else { + return new Promise((resolve, reject) => { + resolve(Array(Sensor)); + }); + } + } + }; + return sensor +} \ No newline at end of file diff --git a/runtime/main/extend/systemplugin/napi/ohos_storageStatistics.js b/runtime/main/extend/systemplugin/napi/ohos_storageStatistics.js index c954be1e..4f4c7511 100644 --- a/runtime/main/extend/systemplugin/napi/ohos_storageStatistics.js +++ b/runtime/main/extend/systemplugin/napi/ohos_storageStatistics.js @@ -16,13 +16,22 @@ import { paramMock } from '../utils'; export function mockStorageStatistics() { - const BundleStatsMock = { + const BundleStats = { appSize: '[PC preview] unknow appSize', cacheSize: '[PC preview] unknow cacheSize', dataSize: '[PC preview] unknow dataSize' }; + const StorageStats= { + total: '[PC preview] unknow total', + audio: '[PC preview] unknow audio', + video: '[PC preview] unknow video', + image: '[PC preview] unknow image', + file: '[PC preview] unknow file', + app: '[PC preview] unknow app' + } const storageStatistics = { - BundleStats: BundleStatsMock, + BundleStats: BundleStats, + StorageStats: StorageStats, getTotalSizeOfVolume: function(...args) { console.warn('storageStatistics.getTotalSizeOfVolume interface mocked in the Previewer. How this interface works on the' + ' Previewer may be different from that on a real device.'); @@ -58,6 +67,66 @@ export function mockStorageStatistics() { resolve(BundleStatsMock); }); } + }, + getCurrentBundleStats: function(...args) { + console.warn('storageStatistics.getCurrentBundleStats 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, BundleStats); + } else { + return new Promise((resolve, reject) => { + resolve(BundleStats); + }); + } + }, + getSystemSize: function(...args) { + console.warn('storageStatistics.getSystemSize 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, reject) => { + resolve(paramMock.paramNumberMock); + }); + } + }, + getUserStorageStats: function(...args) { + console.warn('storageStatistics.getUserStorageStats 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, StorageStats); + } else { + return new Promise((resolve, reject) => { + resolve(StorageStats); + }); + } + }, + getTotalSize: function(...args) { + console.warn('storageStatistics.getTotalSize 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, reject) => { + resolve(paramMock.paramNumberMock); + }); + } + }, + getFreeSize: function(...args) { + console.warn('storageStatistics.getFreeSize 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, reject) => { + resolve(paramMock.paramNumberMock); + }); + } } }; return storageStatistics; diff --git a/runtime/main/extend/systemplugin/napi/ohos_uiAppearance.js b/runtime/main/extend/systemplugin/napi/ohos_uiAppearance.js new file mode 100644 index 00000000..69302595 --- /dev/null +++ b/runtime/main/extend/systemplugin/napi/ohos_uiAppearance.js @@ -0,0 +1,44 @@ +/* + * 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 mockUiAppearance() { + const DarkMode = { + ALWAYS_DARK: 0, + ALWAYS_LIGHT: 1 + } + const uiAppearance = { + DarkMode, + setDarkMode: function (...args) { + console.warn("uiAppearance.setDarkMode 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) => { + resolve(); + }); + } + }, + getDarkMode: function () { + console.warn("uiAppearance.getDarkMode interface mocked in the Previewer." + + " How this interface works on the Previewer may be different from that on a real device.") + return DarkMode; + } + } + return uiAppearance; +} diff --git a/runtime/main/extend/systemplugin/napi/ohos_uitest.js b/runtime/main/extend/systemplugin/napi/ohos_uitest.js new file mode 100644 index 00000000..550bd76e --- /dev/null +++ b/runtime/main/extend/systemplugin/napi/ohos_uitest.js @@ -0,0 +1,493 @@ +/* + * 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 warnMessage = + ' interface mocked in the Previewer. How this interface works on the' + + ' Previewer may be different from that on a real device.' + +export const ResizeDirection = { + LEFT: 0, + RIGHT: 1, + UP: 2, + DOWN: 3, + LEFT_UP: 4, + LEFT_DOWN: 5, + RIGHT_UP: 6, + RIGHT_DOWN: 7 +} + +export const MatchPattern = { + EQUALS: 0, + CONTAINS: 1, + STARTS_WITH: 2, + ENDS_WITH: 3 +} + +export const WindowMode = { + FULLSCREEN: 0, + PRIMARY: 1, + SECONDARY: 2, + FLOATING: 3 +} + +export const Point = { + X: '[PC Preview] unknown X', + Y: '[PC Preview] unknown Y' +} + +export const Rect = { + leftX: '[PC Preview] unknown leftX', + topY: '[PC Preview] unknown topY', + rightX: '[PC Preview] unknown rightX', + bottomY: '[PC Preview] unknown bottomY' +} + +export const WindowFilter = { + bundleName: '[PC Preview] unknown bundleName', + title: '[PC Preview] unknown title', + focused: '[PC Preview] unknown focused', + actived: '[PC Preview] unknown actived' +} + +const ByClass = class ByMock { + constructor() { + console.warn('uitest.By.constructor' + warnMessage); + this.id = function(...args) { + console.warn('uitest.By.id' + warnMessage) + return new ByClass() + }; + this.text = function(...args) { + console.warn('uitest.By.text' + warnMessage) + return new ByClass() + }; + this.key = function(...args) { + console.warn('uitest.By.key' + warnMessage) + return new ByClass() + }; + this.type = function(...args) { + console.warn('uitest.By.type' + warnMessage) + return new ByClass() + }; + this.enabled = function(...args) { + console.warn('uitest.By.enabled' + warnMessage) + return new ByClass() + }; + this.focused = function(...args) { + console.warn('uitest.By.focused' + warnMessage) + return new ByClass() + }; + this.selected = function(...args) { + console.warn('uitest.By.selected' + warnMessage) + return new ByClass() + }; + this.clickable = function(...args) { + console.warn('uitest.By.clickable' + warnMessage) + return new ByClass() + }; + this.enabled = function(...args) { + console.warn('uitest.By.enabled' + warnMessage) + return new ByClass() + }; + this.longClickable = function(...args) { + console.warn('uitest.By.longClickable' + warnMessage) + return new ByClass() + }; + this.scrollable = function(...args) { + console.warn('uitest.By.scrollable' + warnMessage) + return new ByClass() + }; + this.checkable = function(...args) { + console.warn('uitest.By.checkable' + warnMessage) + return new ByClass() + }; + this.checked = function(...args) { + console.warn('uitest.By.checked' + warnMessage) + return new ByClass() + }; + this.isBefore = function(...args) { + console.warn('uitest.By.isBefore' + warnMessage) + return new ByClass() + }; + this.isAfter = function(...args) { + console.warn('uitest.By.isAfter' + warnMessage) + return new ByClass() + }; + } +} + +const UiDriverClass = class UiDriverMock { + constructor() { + console.warn('uitest.UiDriver.constructor' + warnMessage); + this.delayMs = function(...args) { + console.warn('uitest.UiDriver.delayMs' + warnMessage) + return new Promise((resolve) => { + resolve() + }); + }; + this.findComponent = function(...args) { + console.warn('uitest.UiDriver.findComponent' + warnMessage) + return new Promise((resolve) => { + resolve(new UiComponentClass()) + }); + }; + this.findWindow = function(...args) { + console.warn('uitest.UiDriver.findWindow' + warnMessage) + return new Promise((resolve) => { + resolve(new UiWindowClass()) + }); + }; + this.findComponents = function(...args) { + console.warn('uitest.UiDriver.findComponents' + warnMessage) + return new Promise((resolve) => { + resolve(new Array(new UiComponentClass())) + }); + }; + this.waitForComponent = function(...args) { + console.warn('uitest.UiDriver.waitForComponent' + warnMessage) + return new Promise((resolve) => { + resolve(new UiComponentClass()) + }); + }; + this.screenCap = function(...args) { + console.warn('uitest.UiDriver.screenCap' + warnMessage) + return new Promise((resolve) => { + resolve(paramMock.paramBooleanMock) + }); + }; + this.assertComponentExist = function(...args) { + console.warn('uitest.UiDriver.assertComponentExist' + warnMessage) + return new Promise((resolve) => { + resolve() + }); + }; + this.pressBack = function(...args) { + console.warn('uitest.UiDriver.pressBack' + warnMessage) + return new Promise((resolve) => { + resolve() + }); + }; + this.triggerKey = function(...args) { + console.warn('uitest.UiDriver.triggerKey' + warnMessage) + return new Promise((resolve) => { + resolve() + }); + }; + this.triggerCombineKeys = function(...args) { + console.warn('uitest.UiDriver.triggerCombineKeys' + warnMessage) + return new Promise((resolve) => { + resolve() + }); + }; + this.click = function(...args) { + console.warn('uitest.UiDriver.click' + warnMessage) + return new Promise((resolve) => { + resolve() + }); + }; + this.longClick = function(...args) { + console.warn('uitest.UiDriver.longClick' + warnMessage) + return new Promise((resolve) => { + resolve() + }); + }; + this.doubleClick = function(...args) { + console.warn('uitest.UiDriver.doubleClick' + warnMessage) + return new Promise((resolve) => { + resolve() + }); + }; + this.swipe = function(...args) { + console.warn('uitest.UiDriver.swipe' + warnMessage) + return new Promise((resolve) => { + resolve() + }); + }; + this.drag = function(...args) { + console.warn('uitest.UiDriver.drag' + warnMessage) + return new Promise((resolve) => { + resolve() + }); + }; + } +} + +UiDriverClass.create = function () { + console.warn('uitest.UiDriver.create' + warnMessage) + return new UiDriverClass() +} + +const UiComponentClass = class UiComponentMock { + constructor() { + console.warn('uitest.UiComponent.constructor' + warnMessage); + this.getId = function(...args) { + console.warn('uitest.UiComponent.getId' + warnMessage) + return new Promise((resolve) => { + resolve(paramMock.paramNumberMock) + }); + }; + this.getText = function(...args) { + console.warn('uitest.UiComponent.getText' + warnMessage) + return new Promise((resolve) => { + resolve(paramMock.paramStringMock) + }); + }; + this.getKey = function(...args) { + console.warn('uitest.UiComponent.getKey' + warnMessage) + return new Promise((resolve) => { + resolve(paramMock.paramStringMock) + }); + }; + this.getType = function(...args) { + console.warn('uitest.UiComponent.getType' + warnMessage) + return new Promise((resolve) => { + resolve(paramMock.paramStringMock) + }); + }; + this.isEnabled = function(...args) { + console.warn('uitest.UiComponent.isEnabled' + warnMessage) + return new Promise((resolve) => { + resolve(paramMock.paramBooleanMock) + }); + }; + this.isFocused = function(...args) { + console.warn('uitest.UiComponent.isFocused' + warnMessage) + return new Promise((resolve) => { + resolve(paramMock.paramBooleanMock) + }); + }; + this.isSelected = function(...args) { + console.warn('uitest.UiComponent.isSelected' + warnMessage) + return new Promise((resolve) => { + resolve(paramMock.paramBooleanMock) + }); + }; + this.isClickable = function(...args) { + console.warn('uitest.UiComponent.isClickable' + warnMessage) + return new Promise((resolve) => { + resolve(paramMock.paramBooleanMock) + }); + }; + this.isLongClickable = function(...args) { + console.warn('uitest.UiComponent.isLongClickable' + warnMessage) + return new Promise((resolve) => { + resolve(paramMock.paramBooleanMock) + }); + }; + this.isScrollable = function(...args) { + console.warn('uitest.UiComponent.isScrollable' + warnMessage) + return new Promise((resolve) => { + resolve(paramMock.paramBooleanMock) + }); + }; + this.isCheckable = function(...args) { + console.warn('uitest.UiComponent.isCheckable' + warnMessage) + return new Promise((resolve) => { + resolve(paramMock.paramBooleanMock) + }); + }; + this.isChecked = function(...args) { + console.warn('uitest.UiComponent.isChecked' + warnMessage) + return new Promise((resolve) => { + resolve(paramMock.paramBooleanMock) + }); + }; + this.getBounds = function(...args) { + console.warn('uitest.UiComponent.getBounds' + warnMessage) + return new Promise((resolve) => { + resolve(Rect) + }); + }; + this.getBoundsCenter = function(...args) { + console.warn('uitest.UiComponent.getBoundsCenter' + warnMessage) + return new Promise((resolve) => { + resolve(Point) + }); + }; + this.click = function(...args) { + console.warn('uitest.UiComponent.click' + warnMessage) + return new Promise((resolve) => { + resolve() + }); + }; + this.longClick = function(...args) { + console.warn('uitest.UiComponent.longClick' + warnMessage) + return new Promise((resolve) => { + resolve() + }); + }; + this.doubleClick = function(...args) { + console.warn('uitest.UiComponent.doubleClick' + warnMessage) + return new Promise((resolve) => { + resolve() + }); + }; + this.scrollToTop = function(...args) { + console.warn('uitest.UiComponent.scrollToTop' + warnMessage) + return new Promise((resolve) => { + resolve() + }); + }; + this.scrollToBottom = function(...args) { + console.warn('uitest.UiComponent.scrollToBottom' + warnMessage) + return new Promise((resolve) => { + resolve() + }); + }; + this.inputText = function(...args) { + console.warn('uitest.UiComponent.inputText' + warnMessage) + return new Promise((resolve) => { + resolve() + }); + }; + this.clearText = function(...args) { + console.warn('uitest.UiComponent.clearText' + warnMessage) + return new Promise((resolve) => { + resolve() + }); + }; + this.scrollSearch = function(...args) { + console.warn('uitest.UiComponent.scrollSearch' + warnMessage) + return new Promise((resolve) => { + resolve(new UiComponentClass()) + }); + }; + this.dragTo = function(...args) { + console.warn('uitest.UiComponent.dragTo' + warnMessage) + return new Promise((resolve) => { + resolve() + }); + }; + this.pinchOut = function(...args) { + console.warn('uitest.UiComponent.pinchOut' + warnMessage) + return new Promise((resolve) => { + resolve() + }); + }; + this.pinchIn = function(...args) { + console.warn('uitest.UiComponent.pinchIn' + warnMessage) + return new Promise((resolve) => { + resolve() + }); + }; + } +} + +const UiWindowClass = class UiWindowMock { + constructor() { + console.warn('uitest.UiWindow.constructor' + warnMessage); + this.getBundleName = function(...args) { + console.warn('uitest.UiWindow.getBundleName' + warnMessage) + return new Promise((resolve) => { + resolve(paramMock.paramStringMock) + }); + }; + this.getBounds = function(...args) { + console.warn('uitest.UiWindow.getBounds' + warnMessage) + return new Promise((resolve) => { + resolve(Rect) + }); + }; + this.getTitle = function(...args) { + console.warn('uitest.UiWindow.getTitle' + warnMessage) + return new Promise((resolve) => { + resolve(paramMock.paramStringMock) + }); + }; + this.getWindowMode = function(...args) { + console.warn('uitest.UiWindow.getWindowMode' + warnMessage) + return new Promise((resolve) => { + resolve(WindowMode) + }); + }; + this.isFocused = function(...args) { + console.warn('uitest.UiWindow.isFocused' + warnMessage) + return new Promise((resolve) => { + resolve(paramMock.paramBooleanMock) + }); + }; + this.isActived = function(...args) { + console.warn('uitest.UiWindow.isActived' + warnMessage) + return new Promise((resolve) => { + resolve(paramMock.paramBooleanMock) + }); + }; + this.focus = function(...args) { + console.warn('uitest.UiWindow.focus' + warnMessage) + return new Promise((resolve) => { + resolve(paramMock.paramBooleanMock) + }); + }; + this.moveTo = function(...args) { + console.warn('uitest.UiWindow.moveTo' + warnMessage) + return new Promise((resolve) => { + resolve(paramMock.paramBooleanMock) + }); + }; + this.resize = function(...args) { + console.warn('uitest.UiWindow.resize' + warnMessage) + return new Promise((resolve) => { + resolve(paramMock.paramBooleanMock) + }); + }; + this.split = function(...args) { + console.warn('uitest.UiWindow.split' + warnMessage) + return new Promise((resolve) => { + resolve(paramMock.paramBooleanMock) + }); + }; + this.maximize = function(...args) { + console.warn('uitest.UiWindow.maximize' + warnMessage) + return new Promise((resolve) => { + resolve(paramMock.paramBooleanMock) + }); + }; + this.resume = function(...args) { + console.warn('uitest.UiWindow.resume' + warnMessage) + return new Promise((resolve) => { + resolve(paramMock.paramBooleanMock) + }); + }; + this.minimize = function(...args) { + console.warn('uitest.UiWindow.minimize' + warnMessage) + return new Promise((resolve) => { + resolve(paramMock.paramBooleanMock) + }); + }; + this.close = function(...args) { + console.warn('uitest.UiWindow.close' + warnMessage) + return new Promise((resolve) => { + resolve(paramMock.paramBooleanMock) + }); + }; + }; +} + +export function mockUiTest() { + const module = { + ResizeDirection: ResizeDirection, + MatchPattern: MatchPattern, + WindowMode: WindowMode, + Point: Point, + Rect: Rect, + WindowFilter: WindowFilter, + BY: new ByClass(), + UiDriver: UiDriverClass, + UiComponent: UiComponentClass, + UiWindow: UiWindowClass + }; + return module +} \ No newline at end of file diff --git a/runtime/main/extend/systemplugin/napi/ohos_update.js b/runtime/main/extend/systemplugin/napi/ohos_update.js index f3efb101..d78eeb32 100644 --- a/runtime/main/extend/systemplugin/napi/ohos_update.js +++ b/runtime/main/extend/systemplugin/napi/ohos_update.js @@ -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,13 +13,25 @@ * limitations under the License. */ -import {paramMock} from "../utils" +import { paramMock } from "../utils" export function mockUpdate() { - const updater = { + const Updater = { checkNewVersion: function (...args) { console.warn("Updater.checkNewVersion 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 (len > 0 && typeof args[len - 1] === 'function') { + args[len - 1].call(this, paramMock.businessErrorMock, CheckResult); + } else { + return new Promise((resolve, reject) => { + resolve(CheckResult); + }) + } + }, + getNewVersionInfo: function (...args) { + console.warn("Updater.getNewVersionInfo 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, NewVersionInfo); @@ -29,41 +41,161 @@ export function mockUpdate() { }) } }, + getCurrentVersionInfo: function (...args) { + console.warn("Updater.getCurrentVersionInfo interface mocked in the Previewer. How this interface works" + + " on the Previewer may be different from that on a real device.") + const len = args.length + if (len > 0 && typeof args[len - 1] === 'function') { + args[len - 1].call(this, paramMock.businessErrorMock, CurrentVersionInfo); + } else { + return new Promise((resolve, reject) => { + resolve(CurrentVersionInfo); + }) + } + }, + getTaskInfo: function (...args) { + console.warn("Updater.getTaskInfo interface mocked in the Previewer. How this interface works on the" + + " Previewer may be different from that on a real device.") + const len = args.length + if (len > 0 && typeof args[len - 1] === 'function') { + args[len - 1].call(this, paramMock.businessErrorMock, TaskInfo); + } else { + return new Promise((resolve, reject) => { + resolve(TaskInfo); + }) + } + }, download: function (...args) { console.warn("Updater.download 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 (len > 0 && typeof args[len - 1] === 'function') { + args[len - 1].call(this, paramMock.businessErrorMock); + } else { + return new Promise((resolve, reject) => { + resolve(); + }) + } + }, + resumeDownload: function (...args) { + console.warn("Updater.resumeDownload 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(); + }) + } + }, + pauseDownload: function (...args) { + console.warn("Updater.pauseDownload 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(); + }) + } }, upgrade: function (...args) { console.warn("Updater.upgrade interface mocked in the Previewer. How this interface works on the" + - " Previewer may be different from that on a real device.") - }, - getNewVersionInfo: function (...args) { - console.warn("Updater.getNewVersionInfo 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 (len > 0 && typeof args[len - 1] === 'function') { - args[len - 1].call(this, paramMock.businessErrorMock, NewVersionInfo); + args[len - 1].call(this, paramMock.businessErrorMock); } else { return new Promise((resolve, reject) => { - resolve(NewVersionInfo); + resolve(); }) } }, - getUpdatePolicy: function (...args) { - console.warn("Updater.getUpdatePolicy interface mocked in the Previewer. How this interface works on the" + - " Previewer may be different from that on a real device.") + clearError: function (...args) { + console.warn("Updater.clearError 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, UpdatePolicy); + args[len - 1].call(this, paramMock.businessErrorMock); } else { return new Promise((resolve, reject) => { - resolve(UpdatePolicy); + resolve(); }) } }, - setUpdatePolicy: function (...args) { - console.warn("Updater.setUpdatePolicy interface mocked in the Previewer. How this interface works on the" + - " Previewer may be different from that on a real device.") + getUpgradePolicy: function (...args) { + console.warn("Updater.getUpgradePolicy 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, UpgradePolicy); + } else { + return new Promise((resolve, reject) => { + resolve(UpgradePolicy); + }) + } + }, + setUpgradePolicy: function (...args) { + console.warn("Updater.setUpgradePolicy 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); + }) + } + }, + terminateUpgrade: function (...args) { + console.warn("Updater.terminateUpgrade 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(); + }) + } + }, + on: function (...args) { + console.warn("Updater.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 (len > 0 && typeof args[len - 1] === 'function') { + args[len - 1].call(this, EventInfo); + } + }, + off: function (...args) { + console.warn("Updater.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 (len > 0 && typeof args[len - 1] === 'function') { + args[len - 1].call(this, EventInfo); + } + }, + } + const Restorer = { + factoryReset: function (...args) { + console.warn("Restorer.factoryReset 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 LocalUpdater = { + verifyUpgradePackage: function (...args) { + console.warn("LocalUpdater.verifyUpgradePackage 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); @@ -74,154 +206,210 @@ export function mockUpdate() { } }, applyNewVersion: function (...args) { - console.warn("Updater.applyNewVersion interface mocked in the Previewer. How this interface works on the" + - " Previewer may be different from that on a real device.") + console.warn("LocalUpdater.applyNewVersion 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); + args[len - 1].call(this, paramMock.businessErrorMock); } else { return new Promise((resolve, reject) => { - resolve(paramMock.paramNumberMock); + resolve(); }) } }, - rebootAndCleanCache: function (...args) { - console.warn("Updater.rebootAndCleanCache 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); - }) - } - }, - verifyUpdatePackage: function (...args) { - console.warn("Updater.verifyUpdatePackage interface mocked in the Previewer. How this interface works on the" + - " Previewer may be different from that on a real device.") - }, on: function (...args) { - console.warn("Updater.on interface mocked in the Previewer. How this interface works on the" + - " Previewer may be different from that on a real device.") + console.warn("LocalUpdater.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 (len > 0 && typeof args[len - 1] === 'function') { - args[len - 1].call(this, Progress); + args[len - 1].call(this, EventInfo); } }, off: function (...args) { - console.warn("Updater.off interface mocked in the Previewer. How this interface works on the" + - " Previewer may be different from that on a real device.") + console.warn("LocalUpdater.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 (len > 0 && typeof args[len - 1] === 'function') { - args[len - 1].call(this, Progress); + args[len - 1].call(this, EventInfo); } }, - cancel: function (...args) { - console.warn("Updater.cancel interface mocked in the Previewer. How this interface works on the" + - " Previewer may be different from that on a real device.") - }, } const update = { - PackageTypes, - NewVersionStatus, - UpdateState, - InstallMode, - getUpdater: function (...args) { - console.warn("update.getUpdater interface mocked in the Previewer. How this interface works on the" + - " Previewer may be different from that on a real device.") - return updater; + BusinessVendor, + BusinessSubType, + ComponentType, + UpgradeAction, + EffectiveMode, + DescriptionType, + NetType, + Order, + UpgradeStatus, + EventClassify, + EventId, + getOnlineUpdater: function (...args) { + console.warn("update.getOnlineUpdater interface mocked in the Previewer. How this interface works on the" + + " Previewer may be different from that on a real device.") + return Updater; }, - getUpdaterForOther: function (...args) { - console.warn("update.getUpdaterForOther interface mocked in the Previewer. How this interface works on the" + - " Previewer may be different from that on a real device.") - return updater; + getRestorer: function (...args) { + console.warn("update.getRestorer interface mocked in the Previewer. How this interface works on the" + + " Previewer may be different from that on a real device.") + return Restorer; }, - getUpdaterFromOther: function (...args) { - console.warn("update.getUpdaterFromOther interface mocked in the Previewer. How this interface works on the" + - " Previewer may be different from that on a real device.") - return updater; + getLocalUpdater: function (...args) { + console.warn("update.getLocalUpdater interface mocked in the Previewer. How this interface works on the" + + " Previewer may be different from that on a real device.") + return LocalUpdater; } } return update; } -const PackageTypes = { - PACKAGE_TYPE_NORMAL: 1, - PACKAGE_TYPE_BASE: 2, - PACKAGE_TYPE_CUST: 3, - PACKAGE_TYPE_PRELOAD: 4, - PACKAGE_TYPE_COTA: 5, - PACKAGE_TYPE_VERSION: 6, - PACKAGE_TYPE_PATCH: 7, +const BusinessVendor = { + PUBLIC: "public", } -const CheckResult = { - versionName: "[PC Preview] unknow versionName", - versionCode: "[PC Preview] unknow versionCode", - size: "[PC Preview] unknow size", - verifyInfo: "[PC Preview] unknow verifyInfo", - packageType: PackageTypes.PACKAGE_TYPE_NORMAL, - descriptionId: "[PC Preview] unknow descriptionId", +const BusinessSubType = { + FIRMWARE: 1, + PARAM: 2, +} + +const ComponentType = { + OTA: 1, +} + +const UpgradeAction = { + UPGRADE: "upgrade", + RECOVERY: "recovery", +} + +const EffectiveMode = { + COLD: 1, + LIVE: 2, + LIVE_AND_COLD: 3, +} + +const DescriptionType = { + CONTENT: 0, + URI: 1, +} + +const NetType = { + CELLULAR: 1, + METERED_WIFI: 2, + NOT_METERED_WIFI: 4, +} + +const Order = { + DOWNLOAD: 1, + INSTALL: 2, + APPLY: 4, +} + +const UpgradeStatus = { + WAITING_DOWNLOAD: 20, + DOWNLOADING: 21, + DOWNLOAD_PAUSED: 22, + DOWNLOAD_FAIL: 23, + WAITING_INSTALL: 30, + UPDATING: 31, + WAITING_APPLY: 40, + APPLYING: 41, + UPGRADE_SUCCESS: 50, + UPGRADE_FAIL: 51, +} + +const EventClassify = { + TASK: 0x01000000, +} + +const EventId = { + EVENT_TASK_BASE: 0x01000000, + EVENT_TASK_RECEIVE: 0x01000001, + EVENT_TASK_CANCEL: 0x01000010, + EVENT_DOWNLOAD_WAIT: 0x01000011, + EVENT_DOWNLOAD_START: 0x01000100, + EVENT_DOWNLOAD_UPDATE: 0x01000101, + EVENT_DOWNLOAD_PAUSE: 0x01000110, + EVENT_DOWNLOAD_RESUME: 0x01000111, + EVENT_DOWNLOAD_SUCCESS: 0x01001000, + EVENT_DOWNLOAD_FAIL: 0x01001001, + EVENT_UPGRADE_WAIT: 0x01001010, + EVENT_UPGRADE_START: 0x01001011, + EVENT_UPGRADE_UPDATE: 0x01001100, + EVENT_APPLY_WAIT: 0x01001101, + EVENT_APPLY_START: 0x01001110, + EVENT_UPGRADE_SUCCESS: 0x01001111, + EVENT_UPGRADE_FAIL: 0x01010000, +} + +const VersionDigestInfo = { + versionDigest: "[PC Preview] unknown versionDigest", } const DescriptionInfo = { - descriptionId: "[PC Preview] unknow descriptionId", - content: "[PC Preview] unknow content", + descriptionType: DescriptionType.CONTENT, + content: "[PC Preview] unknown content", } -const NewVersionStatus = { - VERSION_STATUS_ERR: -1, - VERSION_STATUS_NEW: 0, - VERSION_STATUS_NONE: 1, - VERSION_STATUS_BUSY: 2, +const VersionComponent = { + componentType: ComponentType.OTA, + upgradeAction: UpgradeAction.UPGRADE, + displayVersion: "[PC Preview] unknown displayVersion", + innerVersion: "[PC Preview] unknown innerVersion", + size: "[PC Preview] unknown size", + effectiveMode: EffectiveMode.COLD, + descriptionInfo: DescriptionInfo, } const NewVersionInfo = { - status: NewVersionStatus.VERSION_STATUS_NEW, - errMsg: "[PC Preview] unknow errMsg", - checkResults: [CheckResult], - descriptionInfo: [DescriptionInfo] + versionDigestInfo: VersionDigestInfo, + versionComponents: [VersionComponent], } -const UpdateState = { - UPDATE_STATE_INIT: 0, - UPDATE_STATE_CHECK_VERSION_ON: 10, - UPDATE_STATE_CHECK_VERSION_FAIL: 11, - UPDATE_STATE_CHECK_VERSION_SUCCESS: 12, - UPDATE_STATE_DOWNLOAD_ON: 20, - UPDATE_STATE_DOWNLOAD_PAUSE: 21, - UPDATE_STATE_DOWNLOAD_CANCEL: 22, - UPDATE_STATE_DOWNLOAD_FAIL: 23, - UPDATE_STATE_DOWNLOAD_SUCCESS: 24, - UPDATE_STATE_VERIFY_ON: 30, - UPDATE_STATE_VERIFY_FAIL: 31, - UPDATE_STATE_VERIFY_SUCCESS: 32, - UPDATE_STATE_PACKAGE_TRANS_ON: 70, - UPDATE_STATE_PACKAGE_TRANS_FAIL: 71, - UPDATE_STATE_PACKAGE_TRANS_SUCCESS: 72, - UPDATE_STATE_INSTALL_ON: 80, - UPDATE_STATE_INSTALL_FAIL: 81, - UPDATE_STATE_INSTALL_SUCCESS: 82, - UPDATE_STATE_UPDATE_ON: 90, - UPDATE_STATE_UPDATE_FAIL: 91, - UPDATE_STATE_UPDATE_SUCCESS: 92 +const CheckResult = { + isExistNewVersion: "[PC Preview] unknown isExistNewVersion", + newVersionInfo: NewVersionInfo, } -const Progress = { - percent: "[PC Preview] unknow percent", - status: UpdateState.UPDATE_STATE_INIT, - endReason: "[PC Preview] unknow endReason" +const CurrentVersionInfo = { + osVersion: "[PC Preview] unknown osVersion", + deviceName: "[PC Preview] unknown deviceName", + versionComponents: [VersionComponent], } -const InstallMode = { - INSTALL_MODE_NORMAL: "[PC Preview] unknow INSTALL_MODE_NORMAL", - INSTALL_MODE_NIGHT: "[PC Preview] unknow INSTALL_MODE_NIGHT", - INSTALL_MODE_AUTO: "[PC Preview] unknow INSTALL_MODE_AUTO" +const UpgradePeriod = { + start: "[PC Preview] unknown start", + end: "[PC Preview] unknown end", } -const UpdatePolicy = { - autoDownload: "[PC Preview] unknow autoDownload", - installMode: InstallMode.INSTALL_MODE_NORMAL, - autoUpgradeInterval: [0] -} \ No newline at end of file +const UpgradePolicy = { + downloadStrategy: "[PC Preview] unknown downloadStrategy", + autoUpgradeStrategy: "[PC Preview] unknown autoUpgradeStrategy", + autoUpgradePeriods: [UpgradePeriod], +} + +const ErrorMessage = { + errorCode: "[PC Preview] unknown errorCode", + errorMessage: "[PC Preview] unknown errorMessage", +} + +const TaskBody = { + versionDigestInfo: VersionDigestInfo, + status: UpgradeStatus.WAITING_DOWNLOAD, + subStatus: "[PC Preview] unknown subStatus", + progress: "[PC Preview] unknown progress", + installMode: "[PC Preview] unknown installMode", + errorMessages: [ErrorMessage], + versionComponents: [VersionComponent], +} + +const TaskInfo = { + existTask: "[PC Preview] unknown existTask", + taskBody: TaskBody, +} + +const EventInfo = { + eventId: EventId.EVENT_TASK_RECEIVE, + taskBody: TaskBody, +} diff --git a/runtime/main/extend/systemplugin/napi/ohos_volumeManager.js b/runtime/main/extend/systemplugin/napi/ohos_volumeManager.js index 9adf2ac3..4854b912 100644 --- a/runtime/main/extend/systemplugin/napi/ohos_volumeManager.js +++ b/runtime/main/extend/systemplugin/napi/ohos_volumeManager.js @@ -14,19 +14,27 @@ */ import { paramMock } from "../utils" -import {VolumeMock} from './volume/volumeInfo' export function mockVolumeManager() { + const Volume = { + id: '[PC preview] unknow id', + uuid: '[PC preview] unknow uuid', + description: '[PC preview] unknow description', + removeAble: '[PC preview] unknow removeAble', + path: '[PC preview] unknow path', + state: '[PC preview] unknow state' + }; const volumeManager = { + Volume: Volume, getAllVolumes: function (...args) { console.warn("volumeManager.getAllVolumes 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(VolumeMock)); + args[len - 1].call(this, paramMock.businessErrorMock, new Array(Volume)); } else { return new Promise((resolve, reject) => { - resolve(Array(VolumeMock)); + resolve(new Array(Volume)); }) } }, @@ -54,6 +62,66 @@ export function mockVolumeManager() { }) } }, + getVolumeByUuid: function (...args) { + console.warn("volumeManager.getVolumeByUuid 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, Volume); + } else { + return new Promise((resolve, reject) => { + resolve(Volume); + }) + } + }, + getVolumeById: function (...args) { + console.warn("volumeManager.getVolumeById 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, Volume); + } else { + return new Promise((resolve, reject) => { + resolve(Volume); + }) + } + }, + setVolumeDescription: function (...args) { + console.warn("volumeManager.setVolumeDescription 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(); + }) + } + }, + format: function (...args) { + console.warn("volumeManager.format 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(); + }) + } + }, + partition: function (...args) { + console.warn("volumeManager.partition 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 volumeManager; } diff --git a/runtime/main/extend/systemplugin/napi/ohos_wantAgent.js b/runtime/main/extend/systemplugin/napi/ohos_wantAgent.js index 25072ba4..0ec5aa2b 100644 --- a/runtime/main/extend/systemplugin/napi/ohos_wantAgent.js +++ b/runtime/main/extend/systemplugin/napi/ohos_wantAgent.js @@ -14,47 +14,37 @@ */ import { paramMock } from "../utils" +import { WantClass } from "./ohos_application_Want" +export const WantAgentFlags = { + ONE_TIME_FLAG: 0, + NO_BUILD_FLAG: 1, + CANCEL_PRESENT_FLAG: 2, + UPDATE_PRESENT_FLAG: 3, + CONSTANT_FLAG: 4, + REPLACE_ELEMENT: 5, + REPLACE_ACTION: 6, + REPLACE_URI: 7, + REPLACE_ENTITIES: 8, + REPLACE_BUNDLE: 9 +} +export const OperationType = { + UNKNOWN_TYPE: 0, + START_ABILITY: 1, + START_ABILITIES: 2, + START_SERVICE: 3, + SEND_COMMON_EVENT: 4 +} +export const CompleteData = { + info: WantAgent, + want: new WantClass(), + finalCode: '[PC preview] unknow finalCode', + finalData: '[PC preview] unknow finalData', + extraInfo: {}, +} +export const WantAgent = {} export function mockWantAgent() { - const WantMock = { - 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: '[PC preview] unknow parameters', - entities: '[PC preview] unknow entities', - } - const CompleteDataMock = { - info: '[PC preview] unknow info', - want: '[PC preview] unknow want', - finalCode: '[PC preview] unknow finalCode', - finalData: '[PC preview] unknow finalData', - extraInfo: '[PC preview] unknow extraInfo', - } - const WantAgentMock = {} const wantAgent = { - OperationType: { - UNKNOWN_TYPE: 0, - START_ABILITY: 1, - START_ABILITIES: 2, - START_SERVICE: 3, - SEND_COMMON_EVENT: 4 - }, - WantAgentFlags: { - ONE_TIME_FLAG: 0, - NO_BUILD_FLAG: 1, - CANCEL_PRESENT_FLAG: 2, - UPDATE_PRESENT_FLAG: 3, - CONSTANT_FLAG: 4, - REPLACE_ELEMENT: 5, - REPLACE_ACTION: 6, - REPLACE_URI: 7, - REPLACE_ENTITIES: 8, - REPLACE_BUNDLE: 9 - }, getBundleName: function (...args) { console.warn("wantAgent.getBundleName interface mocked in the Previewer. How this interface works on the" + " Previewer may be different from that on a real device."); @@ -84,10 +74,10 @@ export function mockWantAgent() { " 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, WantMock); + args[len - 1].call(this, paramMock.businessErrorMock, new WantClass()); } else { return new Promise((resolve) => { - resolve(WantMock); + resolve(new WantClass()); }); } }, @@ -108,7 +98,7 @@ export function mockWantAgent() { " 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, CompleteDataMock); + args[len - 1].call(this, paramMock.businessErrorMock, CompleteData); } }, equal: function (...args) { @@ -128,10 +118,22 @@ export function mockWantAgent() { " 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, WantAgentMock); + args[len - 1].call(this, paramMock.businessErrorMock, WantAgent); } else { return new Promise((resolve) => { - resolve(WantAgentMock); + resolve(WantAgent); + }); + } + }, + getOperationType: function (...args) { + console.warn("wantAgent.getOperationType 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); }); } }, diff --git a/runtime/main/extend/systemplugin/napi/ohos_window.js b/runtime/main/extend/systemplugin/napi/ohos_window.js index f06438a1..58327ee4 100644 --- a/runtime/main/extend/systemplugin/napi/ohos_window.js +++ b/runtime/main/extend/systemplugin/napi/ohos_window.js @@ -1,738 +1,744 @@ -/* - * 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 - * - * 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 windowPropertiesMock = { - windowRect: '[PC preview] unknow windowRect', - type: '[PC preview] unknow type', - brightness: '[PC preview] unknow brightness', - isTransparent: '[PC preview] unknow isTransparent', - isFullScreen: '[PC preview] unknow isFullScreen', - isKeepScreenOn: '[PC preview] unknow isKeepScreenOn', - dimBehindValue: '[PC preview] unknow dimBehindValue', - isLayoutFullScreen: '[PC preview] unknow isLayoutFullScreen', - focusable: '[PC preview] unknow focusable', - touchable: '[PC preview] unknow touchable', - isPrivacyMode: '[PC preview] unknow isPrivacyMode', - isRoundCorner: '[PC preview] unknow isRoundCorner' -} -export const RectMock = { - left: '[PC preview] unknow Rect.left', - top: '[PC preview] unknow Rect.top', - width: '[PC preview] unknow Rect.width', - height: '[PC preview] unknow Rect.height' -} -export const AvoidAreaMock = { - visible: '[PC preview] unknow visible', - leftRect: RectMock, - topRect: RectMock, - rightRect: RectMock, - bottomRect: RectMock -} -export const WindowTypeMock = { - TYPE_APP: 0, - TYPE_SYSTEM_ALERT: 1, - TYPE_INPUT_METHOD: 2, - TYPE_STATUS_BAR: 3, - TYPE_PANEL: 4, - TYPE_KEYGUARD: 5, - TYPE_VOLUME_OVERLAY: 6, - TYPE_NAVIGATION_BAR: 7 -} -export const SystemBarRegionTintMock={ - type: WindowTypeMock, - isEnable: '[PC preview] unknow isEnable', - region: RectMock, - backgroundColor: '[PC preview] unknow backgroundColor', - contentColor: '[PC preview] unknow contentColor' -} -export const SystemBarTintStateMock= { - displayId: '[PC preview] unknow brightness', - regionTint:[SystemBarRegionTintMock] -} -export const SizeMock = { - width: '[PC preview] unknow width', - height: '[PC preview] unknow height' -} -export const WindowStageEventTypeMock = { - FOREGROUND: 1, - ACTIVE: 2, - INACTIVE: 3, - BACKGROUND: 4 -} - -export const WindowStageMock= { - getMainWindow: function (...args) { - console.warn("windowStage.getMainWindow 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,windowMock) - } else { - return new Promise((resolve, reject) => { - resolve(windowMock) - }) - } - }, - createSubWindow: function (...args) { - console.warn("windowStage.createSubWindow 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,windowMock) - } else { - return new Promise((resolve, reject) => { - resolve(windowMock) - }) - } - }, - getSubWindow: function (...args) { - console.warn("windowStage.getSubWindow 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,[windowMock]) - } else { - return new Promise((resolve, reject) => { - resolve([windowMock]) - }) - } - }, - loadContent: function (...args) { - console.warn("windowStage.loadContent 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() - }) - } - }, - on: function (...args) { - console.warn("windowStage.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]==='windowStageEvent'){ - console.warn(`you has registered ${args[0]} event`) - }else { - console.warn("on:please check first param!") - } - }else { - console.warn("on:please check param!") - } - }, - off: function (...args) { - console.warn("windowStage.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') { - if (args[0]==='windowStageEvent'){ - console.warn(`you has registered ${args[0]} event`) - }else { - console.warn("off:please check first param!") - } - }else { - console.warn("off:please check param!") - } - }, - disableWindowDecor: function (){ - console.warn("windowStage.disableWindowDecor interface mocked in the Previewer. How this interface works on the Previewer" + - " may be different from that on a real device.") - }, - setShowOnLockScreen: function (){ - console.warn("windowStage.setShowOnLockScreen interface mocked in the Previewer. How this interface works on the Previewer" + - " may be different from that on a real device.") - } -} - -export const windowMock = { - setBrightness: function (...args) { - console.warn("Window.setBrightness 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() - }) - } - }, - setBackgroundColor: function (...args) { - console.warn("Window.setBackgroundColor 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() - }) - } - }, - setTransparent: function (...args) { - console.warn("Window.setTransparent 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() - }) - } - }, - setFullScreen: function (...args) { - console.warn("Window.setFullScreen 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() - }) - } - }, - setKeepScreenOn: function (...args) { - console.warn("Window.setKeepScreenOn 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() - }) - } - }, - setDimBehind: function (...args) { - console.warn("Window.setDimBehind 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() - }) - } - }, - setLayoutFullScreen: function (...args) { - console.warn("Window.setLayoutFullScreen 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() - }) - } - }, - setFocusable: function (...args) { - console.warn("Window.setFocusable 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() - }) - } - }, - setTouchable: function (...args) { - console.warn("Window.setTouchable 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() - }) - } - }, - setPrivacyMode: function (...args) { - console.warn("Window.setPrivacyMode 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() - }) - } - }, - setSystemBarEnable: function (...args) { - console.warn("Window.setSystemBarEnable 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() - }) - } - }, - setSystemBarProperties: function (...args) { - console.warn("Window.setSystemBarProperties 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() - }) - } - }, - setForbidSplitMove: function (...args) { - console.warn("Window.setForbidSplitMove 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() - }) - } - }, - getProperties: function (...args) { - console.warn("Window.getProperties 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, windowPropertiesMock) - } else { - return new Promise((resolve) => { - resolve(windowPropertiesMock) - }) - } - }, - getAvoidArea: function (...args) { - console.warn("Window.getAvoidArea 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, AvoidAreaMock) - } else { - return new Promise((resolve) => { - resolve(AvoidAreaMock) - }) - } - }, - moveTo: function (...args) { - console.warn("Window.moveTo 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() - }) - } - }, - resetSize: function (...args) { - console.warn("Window.resetSize 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() - }) - } - }, - setWindowType: function (...args) { - console.warn("Window.setWindowType 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() - }) - } - }, - loadContent: function (...args) { - console.warn("Window.loadContent 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() - }) - } - }, - hide: function (...args) { - console.warn("Window.hide 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() - }) - } - }, - show: function (...args) { - console.warn("Window.show 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() - }) - } - }, - isShowing: function (...args) { - console.warn("Window.isShowing 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) - }) - } - }, - destroy: function (...args) { - console.warn("Window.destroy 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() - }) - } - }, - setOutsideTouchable: function (...args) { - console.warn("Window.setOutsideTouchable 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() - }) - } - }, - on: function (...args) { - console.warn('Window.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] === 'keyboardHeightChange' || args[0] === 'systemAvoidAreaChange' - || args[0] === 'avoidAreaChange' || args[0] === 'windowSizeChange' || args[0] === 'touchOutside') { - console.warn(`you has registered ${args[0]} event`) - } else { - console.warn('on: please check first param!') - } - } else { - console.warn('on:please check param!') - } - }, - off: function (...args) { - console.warn('Window.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') { - if (args[0] === 'keyboardHeightChange' || args[0] === 'systemAvoidAreaChange' - || args[0] === 'avoidAreaChange' || args[0] === 'windowSizeChange' || args[0] === 'touchOutside') { - console.warn(`you has registered ${args[0]} event`) - } else { - console.warn('off:please check first param!') - } - } else { - console.warn('off:please check param!') - } - }, - setColorSpace: function (...args) { - console.warn("Window.setColorSpace 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() - }) - } - }, - getColorSpace: function (...args) { - console.warn("Window.getColorSpace 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) - }) - } - }, - isSupportWideGamut: function (...args) { - console.warn("Window.isSupportWideGamut 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) - }) - } - }, -} - -export function mockWindow() { - const SizeMock = { - width: '[PC preview] unknow width', - height: '[PC preview] unknow height' - } - const getSplitScreenBoundsMock = { - splitMode: '[PC preview] unknow splitMode', - primaryBounds: RectMock, - secondaryBounds: RectMock, - } - const window = { - getTopWindow: function (...args) { - console.warn("window.getTopWindow 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, windowMock) - } else { - return new Promise((resolve, reject) => { - resolve(windowMock) - }) - } - }, - create: function (...args) { - console.warn("Window.create 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, windowMock) - } else { - return new Promise((resolve, reject) => { - resolve(windowMock) - }) - } - }, - find: function (...args) { - console.warn("Window.find 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, windowMock) - } else { - return new Promise((resolve, reject) => { - resolve(windowMock) - }) - } - }, - getAbilityWindowMode: function (...args) { - console.warn("Window.getAbilityWindowMode 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, reject) => { - resolve(paramMock.paramNumberMock) - }) - } - }, - getSplitScreenBounds: function (...args) { - console.warn("window.getSplitScreenBounds 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, getSplitScreenBoundsMock) - } else { - return new Promise((resolve, reject) => { - resolve(getSplitScreenBoundsMock) - }) - } - }, - isFloatingAbilityWindowVisible: function (...args) { - console.warn("window.isFloatingAbilityWindowVisible 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, reject) => { - resolve(paramMock.paramBooleanMock) - }) - } - }, - setSplitBarVisibility: function (...args) { - console.warn("window.setSplitBarVisibility 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() - }) - } - }, - minimizeAll: function (...args) { - console.warn("window.minimizeAll 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() - }) - } - }, - toggleShownStateForAllAppWindows: function (...args) { - console.warn("window.toggleShownStateForAllAppWindows 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() - }) - } - }, - setWindowLayoutMode: function (...args) { - console.warn("window.setWindowLayoutMode 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() - }) - } - }, - on: function (...args) { - console.warn("window.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]==='systemBarTintChange'){ - console.warn(`you has registered ${args[0]} event`) - }else { - console.warn("on:please check first param!") - } - }else { - console.warn("on:please check param!") - } - }, - off: function (...args) { - console.warn("window.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') { - if (args[0]==='systemBarTintChange'){ - console.warn(`you has registered ${args[0]} event`) - }else { - console.warn("off:please check first param!") - } - }else { - console.warn("off:please check param!") - } - }, - WindowType: WindowTypeMock, - AvoidAreaType: { - TYPE_SYSTEM: 0, - TYPE_CUTOUT: 1, - TYPE_SYSTEM_GESTURE: 2, - TYPE_KEYBOARD: 3 - }, - WindowMode: { - UNDEFINED: 1, - FULLSCREEN: 2, - PRIMARY: 3, - SECONDARY: 4, - FLOATING: 5 - }, - WindowLayoutMode: { - WINDOW_LAYOUT_MODE_CASCADE: 0, - WINDOW_LAYOUT_MODE_TILE: 1 - }, - SystemBarProperties: { - statusBarColor: '[PC preview] unknow statusBarColor', - isStatusBarLightIcon: '[PC preview] unknow isStatusBarLightIcon', - statusBarContentColor: '[PC preview] unknow statusBarContentColor', - navigationBarColor: '[PC preview] unknow navigationBarColor', - isNavigationBarLightIcon: '[PC preview] unknow isNavigationBarLightIcon', - navigationBarContentColor: '[PC preview] unknow navigationBarContentColor' - }, - SystemBarRegionTint: SystemBarRegionTintMock, - SystemBarTintState: SystemBarTintStateMock, - Rect: { - left: '[PC preview] unknow left', - top: '[PC preview] unknow top', - width: '[PC preview] unknow width', - height: '[PC preview] unknow height' - }, - AvoidArea:AvoidAreaMock, - Size: SizeMock, - WindowProperties: { - windowRect: RectMock, - type: WindowTypeMock, - isFullScreen: '[PC preview] unknow isFullScreen', - isLayoutFullScreen: '[PC preview] unknow isLayoutFullScreen', - focusable: '[PC preview] unknow focusable', - touchable: '[PC preview] unknow touchable', - brightness: '[PC preview] unknow brightness', - dimBehindValue: '[PC preview] unknow dimBehindValue', - isKeepScreenOn: '[PC preview] unknow isKeepScreenOn', - isPrivacyMode: '[PC preview] unknow isPrivacyMode', - isRoundCorner: '[PC preview] unknow isRoundCorner', - isTransparent: '[PC preview] unknow isTransparent' - }, - ColorSpace: { - DEFAULT: 0, - WIDE_GAMUT: 1 - }, - WindowStageEventType: WindowStageEventTypeMock, - WindowStage: WindowStageMock - } - return window -} +/* + * 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 + * + * 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 WindowType = { + TYPE_APP: 0, + TYPE_SYSTEM_ALERT: 1, + TYPE_INPUT_METHOD: 2, + TYPE_STATUS_BAR: 3, + TYPE_PANEL: 4, + TYPE_KEYGUARD: 5, + TYPE_VOLUME_OVERLAY: 6, + TYPE_NAVIGATION_BAR: 7, + TYPE_FLOAT: 8, + TYPE_WALLPAPER: 9, + TYPE_DESKTOP: 10, + TYPE_LAUNCHER_RECENT: 11, + TYPE_LAUNCHER_DOCK: 12, + TYPE_VOICE_INTERACTION: 13, + TYPE_POINTER: 14 +} + +export const AvoidAreaType= { + TYPE_SYSTEM: 0, + TYPE_CUTOUT: 1, + TYPE_SYSTEM_GESTURE: 2, + TYPE_KEYBOARD: 3 +} + +export const Orientation = { + UNSPECIFIED: 0, + PORTRAIT: 1, + LANDSCAPE: 2, + PORTRAIT_INVERTED: 3, + LANDSCAPE_INVERTED: 4, + AUTO_ROTATION: 5, + AUTO_ROTATION_PORTRAIT: 6, + AUTO_ROTATION_LANDSCAPE: 7, + AUTO_ROTATION_RESTRICTED: 8, + AUTO_ROTATION_PORTRAIT_RESTRICTED: 9, + AUTO_ROTATION_LANDSCAPE_RESTRICTED: 10, + LOCKED: 11 +} + + +export const WindowMode= { + UNDEFINED: 1, + FULLSCREEN: 2, + PRIMARY: 3, + SECONDARY: 4, + FLOATING: 5 +} + +export const WindowLayoutMode= { + WINDOW_LAYOUT_MODE_CASCADE: 0, + WINDOW_LAYOUT_MODE_TILE: 1 +} + +export const SystemBarProperties= { + statusBarColor: '[PC preview] unknow statusBarColor', + isStatusBarLightIcon: '[PC preview] unknow isStatusBarLightIcon', + statusBarContentColor: '[PC preview] unknow statusBarContentColor', + navigationBarColor: '[PC preview] unknow navigationBarColor', + isNavigationBarLightIcon: '[PC preview] unknow isNavigationBarLightIcon', + navigationBarContentColor: '[PC preview] unknow navigationBarContentColor' +} + +export const Rect = { + left: '[PC preview] unknow Rect.left', + top: '[PC preview] unknow Rect.top', + width: '[PC preview] unknow Rect.width', + height: '[PC preview] unknow Rect.height' +} + +export const SystemBarRegionTint = { + type: WindowType, + isEnable: '[PC preview] unknow isEnable', + region: Rect, + backgroundColor: '[PC preview] unknow backgroundColor', + contentColor: '[PC preview] unknow contentColor' +} + +export const SystemBarTintState = { + displayId: '[PC preview] unknow brightness', + regionTint:[SystemBarRegionTint] +} + +export const AvoidArea = { + visible: '[PC preview] unknow AvoidArea.visible', + leftRect: Rect, + topRect: Rect, + rightRect: Rect, + bottomRect: Rect +} + +export const Size = { + width: '[PC preview] unknow width', + height: '[PC preview] unknow height' +} + +export const WindowProperties = { + windowRect: '[PC preview] unknow windowRect', + type: '[PC preview] unknow type', + brightness: '[PC preview] unknow brightness', + isTransparent: '[PC preview] unknow isTransparent', + isFullScreen: '[PC preview] unknow isFullScreen', + isKeepScreenOn: '[PC preview] unknow isKeepScreenOn', + dimBehindValue: '[PC preview] unknow dimBehindValue', + isLayoutFullScreen: '[PC preview] unknow isLayoutFullScreen', + focusable: '[PC preview] unknow focusable', + touchable: '[PC preview] unknow touchable', + isPrivacyMode: '[PC preview] unknow isPrivacyMode', + isRoundCorner: '[PC preview] unknow isRoundCorner' +} + +export const ColorSpace = { + DEFAULT: 0, + WIDE_GAMUT: 1 +} + +export const WindowStageEventType = { + FOREGROUND: 1, + ACTIVE: 2, + INACTIVE: 3, + BACKGROUND: 4 +} + +export const WindowStage = { + getMainWindow: function(...args) { + console.warn("WindowStage.getMainWindow 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, Window) + } else { + return new Promise((resolve) => { + resolve(Window) + }) + } + }, + createSubWindow: function(...args) { + console.warn("WindowStage.createSubWindow 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, Window) + } else { + return new Promise((resolve) => { + resolve(Window) + }) + } + }, + getSubWindow: function(...args) { + console.warn("WindowStage.getSubWindow 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, [Window]) + } else { + return new Promise((resolve) => { + resolve([Window]) + }) + } + }, + loadContent: function(...args) { + console.warn("WindowStage.loadContent 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() + }) + } + }, + on: function(...args) { + console.warn("WindowStage.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] === 'windowStageEvent') { + console.warn(`WindowStage.on you has registered ${args[0]} event`) + } else { + console.warn("WindowStage.on:please check first param!") + } + } else { + console.warn("WindowStage.on:please check param!") + } + }, + off: function(...args) { + console.warn("WindowStage.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') { + if (args[0] === 'windowStageEvent') { + console.warn(`you has registered ${args[0]} event`) + }else { + console.warn("WindowStage.off:please check first param!") + } + }else { + console.warn("WindowStage.off:please check param!") + } + }, + disableWindowDecor: function() { + console.warn("WindowStage.disableWindowDecor interface mocked in the Previewer. How this interface works on the Previewer" + + "may be different from that on a real device.") + }, + setShowOnLockScreen: function() { + console.warn("WindowStage.setShowOnLockScreen interface mocked in the Previewer. How this interface works on the" + + " Previewer may be different from that on a real device.") + } +} + +export const Window = { + setBrightness: function(...args) { + console.warn("Window.setBrightness 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() + }) + } + }, + setBackgroundColor: function(...args) { + console.warn("Window.setBackgroundColor 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() + }) + } + }, + setTransparent: function(...args) { + console.warn("Window.setTransparent 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() + }) + } + }, + setFullScreen: function(...args) { + console.warn("Window.setFullScreen 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() + }) + } + }, + setKeepScreenOn: function(...args) { + console.warn("Window.setKeepScreenOn 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() + }) + } + }, + setDimBehind: function(...args) { + console.warn("Window.setDimBehind 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() + }) + } + }, + setLayoutFullScreen: function(...args) { + console.warn("Window.setLayoutFullScreen 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() + }) + } + }, + setFocusable: function(...args) { + console.warn("Window.setFocusable 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() + }) + } + }, + setTouchable: function(...args) { + console.warn("Window.setTouchable 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() + }) + } + }, + setPrivacyMode: function(...args) { + console.warn("Window.setPrivacyMode 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() + }) + } + }, + setSystemBarEnable: function(...args) { + console.warn("Window.setSystemBarEnable 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() + }) + } + }, + setSystemBarProperties: function(...args) { + console.warn("Window.setSystemBarProperties 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() + }) + } + }, + setPreferredOrientation: function(...args) { + console.warn("Window.setPreferredOrientation 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,Orientation) + } else { + return new Promise((resolve) => { + resolve(Orientation) + }) + } + }, + setForbidSplitMove: function(...args) { + console.warn("Window.setForbidSplitMove 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() + }) + } + }, + getProperties: function(...args) { + console.warn("Window.getProperties 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, WindowProperties) + } else { + return new Promise((resolve) => { + resolve(WindowProperties) + }) + } + }, + getAvoidArea: function(...args) { + console.warn("Window.getAvoidArea 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, AvoidArea) + } else { + return new Promise((resolve) => { + resolve(AvoidArea) + }) + } + }, + moveTo: function(...args) { + console.warn("Window.moveTo 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() + }) + } + }, + resetSize: function(...args) { + console.warn("Window.resetSize 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() + }) + } + }, + setWindowType: function(...args) { + console.warn("Window.setWindowType 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() + }) + } + }, + loadContent: function(...args) { + console.warn("Window.loadContent 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() + }) + } + }, + hide: function(...args) { + console.warn("Window.hide 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() + }) + } + }, + show: function(...args) { + console.warn("Window.show 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() + }) + } + }, + isShowing: function(...args) { + console.warn("Window.isShowing 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) + }) + } + }, + destroy: function(...args) { + console.warn("Window.destroy 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() + }) + } + }, + setOutsideTouchable: function(...args) { + console.warn("Window.setOutsideTouchable 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() + }) + } + }, + on: function(...args) { + console.warn("Window.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] === 'keyboardHeightChange'|| args[0] === 'systemAvoidAreaChange' + || args[0] === 'windowSizeChange'|| args[0] === 'touchOutside'|| args[0] === 'avoidAreaChange' + ){ + console.warn(`Window.on you has registered ${args[0]} event`) + } else { + console.warn("Window.on please check first param!") + } + } else { + console.warn("Window.on please check param!") + } + }, + off: function(...args) { + console.warn("Window.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') { + if (args[0] === 'keyboardHeightChange'|| args[0] === 'systemAvoidAreaChange' + || args[0] === 'windowSizeChange'|| args[0] === 'touchOutside'|| args[0] === 'avoidAreaChange' + ){ + console.warn(`Window.off you has registered ${args[0]} event`) + } else { + console.warn("Window.off please check first param!") + } + } else { + console.warn("Window.off please check param!") + } + }, + setColorSpace: function(...args) { + console.warn("Window.setColorSpace 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() + }) + } + }, + getColorSpace: function(...args) { + console.warn("Window.getColorSpace 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) + }) + } + }, + isSupportWideGamut: function(...args) { + console.warn("Window.isSupportWideGamut 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) + }) + } + }, +} + +export const windowMock = Window + +export function mockWindow() { + + const window = { + getTopWindow: function(...args) { + console.warn("Window.getTopWindow 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, Window) + } else { + return new Promise((resolve) => { + resolve(Window) + }) + } + }, + create: function(...args) { + console.warn("Window.create 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, Window) + } else { + return new Promise((resolve) => { + resolve(Window) + }) + } + }, + find: function(...args) { + console.warn("Window.find 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, Window) + } else { + return new Promise((resolve) => { + resolve(Window) + }) + } + }, + isFloatingAbilityWindowVisible: function(...args) { + console.warn("Window.isFloatingAbilityWindowVisible 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) + }) + } + }, + setSplitBarVisibility: function(...args) { + console.warn("Window.setSplitBarVisibility 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() + }) + } + }, + minimizeAll: function(...args) { + console.warn("Window.minimizeAll 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() + }) + } + }, + toggleShownStateForAllAppWindows: function(...args) { + console.warn("Window.toggleShownStateForAllAppWindows 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() + }) + } + }, + setWindowLayoutMode: function(...args) { + console.warn("Window.setWindowLayoutMode 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() + }) + } + }, + on: function(...args) { + console.warn("Window.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] === 'systemBarTintChange') { + console.warn(`Window.on you has registered ${args[0]} event`) + } else { + console.warn("Window.on please check first param!") + } + } else { + console.warn("Window.on please check param!") + } + }, + off: function(...args) { + console.warn("Window.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') { + if (args[0] === 'systemBarTintChange') { + console.warn(`Window.off you has registered ${args[0]} event`) + } else { + console.warn("Window.off please check first param!") + } + } else { + console.warn("Window.off please check param!") + } + }, + WindowType, + AvoidAreaType, + WindowMode, + WindowLayoutMode, + SystemBarProperties, + SystemBarRegionTint, + SystemBarTintState, + Rect, + AvoidArea, + Size, + WindowProperties, + ColorSpace, + WindowStageEventType, + WindowStage + } + return window +} diff --git a/runtime/main/extend/systemplugin/napi/ohos_workScheduler.js b/runtime/main/extend/systemplugin/napi/ohos_workScheduler.js index 374d0947..4a6419b8 100644 --- a/runtime/main/extend/systemplugin/napi/ohos_workScheduler.js +++ b/runtime/main/extend/systemplugin/napi/ohos_workScheduler.js @@ -16,7 +16,7 @@ import { paramMock } from "../utils" export function mockWorkScheduler() { - const WorkInfoMock = { + const WorkInfo = { workId: '[PC preview] unknown workId', bundleName: '[PC preview] unknown bundleName', abilityName: '[PC preview] unknown abilityName', @@ -33,7 +33,7 @@ export function mockWorkScheduler() { isDeepIdle: '[PC preview] unknown isDeepIdle', idleWaitTime: '[PC preview] unknown idleWaitTime', }; - const WorkInfoArrayMock = [WorkInfoMock] + const WorkInfoArray = [WorkInfo] const workScheduler = { NetworkType : { NETWORK_TYPE_ANY: 0, @@ -74,10 +74,10 @@ export function mockWorkScheduler() { " 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, WorkInfoMock) + args[len - 1].call(this, paramMock.businessErrorMock, WorkInfo) } else { return new Promise(resolve => { - resolve(WorkInfoMock); + resolve(WorkInfo); }) } }, @@ -86,10 +86,10 @@ export function mockWorkScheduler() { " 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, WorkInfoArrayMock) + args[len - 1].call(this, paramMock.businessErrorMock, WorkInfoArray) } else { return new Promise(resolve => { - resolve(WorkInfoArrayMock); + resolve(WorkInfoArray); }) } }, diff --git a/runtime/main/extend/systemplugin/napi/ohos_zlib.js b/runtime/main/extend/systemplugin/napi/ohos_zlib.js index 0caab86f..d0a632c1 100644 --- a/runtime/main/extend/systemplugin/napi/ohos_zlib.js +++ b/runtime/main/extend/systemplugin/napi/ohos_zlib.js @@ -13,51 +13,52 @@ * limitations under the License. */ export const MemLevel = { - MEM_LEVEL_MIN: 1, - MEM_LEVEL_MAX: 9, - MEM_LEVEL_DEFAULT: 8 + MEM_LEVEL_MIN: 1, + MEM_LEVEL_MAX: 9, + MEM_LEVEL_DEFAULT: 8 }; export const ErrorCode = { - ERROR_CODE_OK: 0, - ERROR_CODE_ERRND: -1, + ERROR_CODE_OK: 0, + ERROR_CODE_ERRNO: -1, }; export const CompressLevel = { - COMPRESS_LEVEL_NO_COMPRESSION: 0, - COMPRESS_LEVEL_BEST_SPEED: 1, - COMPRESS_LEVEL_BEST_COMPRESSION: 9, - COMPRESS_LEVEL_DEFAULT_COMPRESSION: -1 + COMPRESS_LEVEL_NO_COMPRESSION: 0, + COMPRESS_LEVEL_BEST_SPEED: 1, + COMPRESS_LEVEL_BEST_COMPRESSION: 9, + COMPRESS_LEVEL_DEFAULT_COMPRESSION: -1 }; export const CompressStrategy = { - COMPRESS_STRATEGY_DEFAULT_STRATEGY: 0, - COMPRESS_STRATEGY_FILTERED: 1, - COMPRESS_STRATEGY_HUFFMAN_ONLY: 2, - COMPRESS_STRATEGY_RLE: 3, - COMPRESS_STRATEGY_FIXED: 4 + COMPRESS_STRATEGY_DEFAULT_STRATEGY: 0, + COMPRESS_STRATEGY_FILTERED: 1, + COMPRESS_STRATEGY_HUFFMAN_ONLY: 2, + COMPRESS_STRATEGY_RLE: 3, + COMPRESS_STRATEGY_FIXED: 4 }; -export function mockZlib() { - const zlib = { - ErrorCode, - MemLevel, - CompressLevel, - CompressStrategy, - Options: { - level: CompressLevel, - memLevel: MemLevel, - strategy: CompressStrategy, - }, - zipFile(...args) { - console.warn("zlib.zipFile 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() - }) - }, +export const Options = { + level: CompressLevel, + memLevel: MemLevel, + strategy: CompressStrategy, +}; +export function mockZlib() { + const zlib = { + ErrorCode, + MemLevel, + CompressLevel, + CompressStrategy, + Options, + zipFile: function(...args) { + console.warn("zlib.zipFile 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) => { + resolve(); + }) + }, - unzipFile(...args) { - console.warn("zlib.unzipFile 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() - }) + unzipFile: function(...args) { + console.warn("zlib.unzipFile 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) => { + resolve(); + }) + } } - } - return zlib; + return zlib; } \ No newline at end of file diff --git a/runtime/main/extend/systemplugin/napi/wantAgent/triggerInfo.js b/runtime/main/extend/systemplugin/napi/wantAgent/triggerInfo.js new file mode 100644 index 00000000..d3acf68f --- /dev/null +++ b/runtime/main/extend/systemplugin/napi/wantAgent/triggerInfo.js @@ -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 { WantClass } from "../ohos_application_Want" +export const TriggerInfo = { + code: '[PC preview] unknow code', + want: new WantClass(), + permission: '[PC preview] unknow permission', + extraInfo: {}, +}; \ No newline at end of file diff --git a/runtime/main/extend/systemplugin/napi/wantAgent/wantAgentInfo.js b/runtime/main/extend/systemplugin/napi/wantAgent/wantAgentInfo.js new file mode 100644 index 00000000..c0e91b07 --- /dev/null +++ b/runtime/main/extend/systemplugin/napi/wantAgent/wantAgentInfo.js @@ -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. + */ +import { WantClass } from "../ohos_application_Want" +import { OperationType, WantAgentFlags } from "../ohos_wantAgent" + +export const WantAgentInfo = { + wants: [new WantClass()], + operationType: OperationType, + requestCode: '[PC preview] unknow requestCode', + wantAgentFlags: [WantAgentFlags], + extraInfo: {}, +}; \ No newline at end of file diff --git a/runtime/main/extend/systemplugin/napi/webgl.js b/runtime/main/extend/systemplugin/napi/webgl.js old mode 100644 new mode 100755 index 62372732..f007becf --- a/runtime/main/extend/systemplugin/napi/webgl.js +++ b/runtime/main/extend/systemplugin/napi/webgl.js @@ -76,266 +76,565 @@ export function mockwebgl() { glBooleanArray: '[PC preview] unknow glBooleanArray', WebGLShaderArray: '[PC preview] unknow WebGLShaderArray', } - const webglmock = { + const WebGLRenderingContext = { + DEPTH_BUFFER_BIT: 0x00000100, + STENCIL_BUFFER_BIT: 0x00000400, + COLOR_BUFFER_BIT: 0x00004000, + POINTS: 0x0000, + LINES: 0x0001, + LINE_LOOP: 0x0002, + LINE_STRIP: 0x0003, + TRIANGLES: 0x0004, + TRIANGLE_STRIP: 0x0005, + TRIANGLE_FAN: 0x0006, + ZERO: 0, + ONE: 1, + SRC_COLOR: 0x0300, + ONE_MINUS_SRC_COLOR: 0x0301, + SRC_ALPHA: 0x0302, + ONE_MINUS_SRC_ALPHA: 0x0303, + DST_ALPHA: 0x0304, + ONE_MINUS_DST_ALPHA: 0x0305, + DST_COLOR: 0x0306, + ONE_MINUS_DST_COLOR: 0x0307, + SRC_ALPHA_SATURATE: 0x0308, + FUNC_ADD: 0x8006, + BLEND_EQUATION: 0x8009, + BLEND_EQUATION_RGB: 0x8009, + BLEND_EQUATION_ALPHA: 0x883D, + FUNC_SUBTRACT: 0x800A, + FUNC_REVERSE_SUBTRACT: 0x800B, + BLEND_DST_RGB: 0x80C8, + BLEND_SRC_RGB: 0x80C9, + BLEND_DST_ALPHA: 0x80CA, + BLEND_SRC_ALPHA: 0x80CB, + CONSTANT_COLOR: 0x8001, + ONE_MINUS_CONSTANT_COLOR: 0x8002, + CONSTANT_ALPHA: 0x8003, + ONE_MINUS_CONSTANT_ALPHA: 0x8004, + BLEND_COLOR: 0x8005, + ARRAY_BUFFER: 0x8892, + ELEMENT_ARRAY_BUFFER: 0x8893, + ARRAY_BUFFER_BINDING: 0x8894, + ELEMENT_ARRAY_BUFFER_BINDING: 0x8895, + STREAM_DRAW: 0x88E0, + STATIC_DRAW: 0x88E4, + DYNAMIC_DRAW: 0x88E8, + BUFFER_SIZE: 0x8764, + BUFFER_USAGE: 0x8765, + CURRENT_VERTEX_ATTRIB: 0x8626, + FRONT: 0x0404, + BACK: 0x0405, + FRONT_AND_BACK: 0x0408, + CULL_FACE: 0x0B44, + BLEND: 0x0BE2, + DITHER: 0x0BD0, + STENCIL_TEST: 0x0B90, + DEPTH_TEST: 0x0B71, + SCISSOR_TEST: 0x0C11, + POLYGON_OFFSET_FILL: 0x8037, + SAMPLE_ALPHA_TO_COVERAGE: 0x809E, + SAMPLE_COVERAGE: 0x80A0, + NO_ERROR: 0, + INVALID_ENUM: 0x0500, + INVALID_VALUE: 0x0501, + INVALID_OPERATION: 0x0502, + OUT_OF_MEMORY: 0x0505, + CW: 0x0900, + CCW: 0x0901, + LINE_WIDTH: 0x0B21, + ALIASED_POINT_SIZE_RANGE: 0x846D, + ALIASED_LINE_WIDTH_RANGE: 0x846E, + CULL_FACE_MODE: 0x0B45, + FRONT_FACE: 0x0B46, + DEPTH_RANGE: 0x0B70, + DEPTH_WRITEMASK: 0x0B72, + DEPTH_CLEAR_VALUE: 0x0B73, + DEPTH_FUNC: 0x0B74, + STENCIL_CLEAR_VALUE: 0x0B91, + STENCIL_FUNC: 0x0B92, + STENCIL_FAIL: 0x0B94, + STENCIL_PASS_DEPTH_FAIL: 0x0B95, + STENCIL_PASS_DEPTH_PASS: 0x0B96, + STENCIL_REF: 0x0B97, + STENCIL_VALUE_MASK: 0x0B93, + STENCIL_WRITEMASK: 0x0B98, + STENCIL_BACK_FUNC: 0x8800, + STENCIL_BACK_FAIL: 0x8801, + STENCIL_BACK_PASS_DEPTH_FAIL: 0x8802, + STENCIL_BACK_PASS_DEPTH_PASS: 0x8803, + STENCIL_BACK_REF: 0x8CA3, + STENCIL_BACK_VALUE_MASK: 0x8CA4, + STENCIL_BACK_WRITEMASK: 0x8CA5, + VIEWPORT: 0x0BA2, + SCISSOR_BOX: 0x0C10, + COLOR_CLEAR_VALUE: 0x0C22, + COLOR_WRITEMASK: 0x0C23, + UNPACK_ALIGNMENT: 0x0CF5, + PACK_ALIGNMENT: 0x0D05, + MAX_TEXTURE_SIZE: 0x0D33, + MAX_VIEWPORT_DIMS: 0x0D3A, + SUBPIXEL_BITS: 0x0D50, + RED_BITS: 0x0D52, + GREEN_BITS: 0x0D53, + BLUE_BITS: 0x0D54, + ALPHA_BITS: 0x0D55, + DEPTH_BITS: 0x0D56, + STENCIL_BITS: 0x0D57, + POLYGON_OFFSET_UNITS: 0x2A00, + POLYGON_OFFSET_FACTOR: 0x8038, + TEXTURE_BINDING_2D: 0x8069, + SAMPLE_BUFFERS: 0x80A8, + SAMPLES: 0x80A9, + SAMPLE_COVERAGE_VALUE: 0x80AA, + SAMPLE_COVERAGE_INVERT: 0x80AB, + COMPRESSED_TEXTURE_FORMATS: 0x86A3, + DONT_CARE: 0x1100, + FASTEST: 0x1101, + NICEST: 0x1102, + GENERATE_MIPMAP_HINT: 0x8192, + BYTE: 0x1400, + UNSIGNED_BYTE: 0x1401, + SHORT: 0x1402, + UNSIGNED_SHORT: 0x1403, + INT: 0x1404, + UNSIGNED_INT: 0x1405, + FLOAT: 0x1406, + DEPTH_COMPONENT: 0x1902, + ALPHA: 0x1906, + RGB: 0x1907, + RGBA: 0x1908, + LUMINANCE: 0x1909, + LUMINANCE_ALPHA: 0x190A, + UNSIGNED_SHORT_4_4_4_4: 0x8033, + UNSIGNED_SHORT_5_5_5_1: 0x8034, + UNSIGNED_SHORT_5_6_5: 0x8363, + FRAGMENT_SHADER: 0x8B30, + VERTEX_SHADER: 0x8B31, + MAX_VERTEX_ATTRIBS: 0x8869, + MAX_VERTEX_UNIFORM_VECTORS: 0x8DFB, + MAX_VARYING_VECTORS: 0x8DFC, + MAX_COMBINED_TEXTURE_IMAGE_UNITS: 0x8B4D, + MAX_VERTEX_TEXTURE_IMAGE_UNITS: 0x8B4C, + MAX_TEXTURE_IMAGE_UNITS: 0x8872, + MAX_FRAGMENT_UNIFORM_VECTORS: 0x8DFD, + SHADER_TYPE: 0x8B4F, + DELETE_STATUS: 0x8B80, + LINK_STATUS: 0x8B82, + VALIDATE_STATUS: 0x8B83, + ATTACHED_SHADERS: 0x8B85, + ACTIVE_UNIFORMS: 0x8B86, + ACTIVE_ATTRIBUTES: 0x8B89, + SHADING_LANGUAGE_VERSION: 0x8B8C, + CURRENT_PROGRAM: 0x8B8D, + NEVER: 0x0200, + LESS: 0x0201, + EQUAL: 0x0202, + LEQUAL: 0x0203, + GREATER: 0x0204, + NOTEQUAL: 0x0205, + GEQUAL: 0x0206, + ALWAYS: 0x0207, + KEEP: 0x1E00, + REPLACE: 0x1E01, + INCR: 0x1E02, + DECR: 0x1E03, + INVERT: 0x150A, + INCR_WRAP: 0x8507, + DECR_WRAP: 0x8508, + VENDOR: 0x1F00, + RENDERER: 0x1F01, + VERSION: 0x1F02, + NEAREST: 0x2600, + LINEAR: 0x2601, + NEAREST_MIPMAP_NEAREST: 0x2700, + LINEAR_MIPMAP_NEAREST: 0x2701, + NEAREST_MIPMAP_LINEAR: 0x2702, + LINEAR_MIPMAP_LINEAR: 0x2703, + TEXTURE_MAG_FILTER: 0x2800, + TEXTURE_MIN_FILTER: 0x2801, + TEXTURE_WRAP_S: 0x2802, + TEXTURE_WRAP_T: 0x2803, + TEXTURE_2D: 0x0DE1, + TEXTURE: 0x1702, + TEXTURE_CUBE_MAP: 0x8513, + TEXTURE_BINDING_CUBE_MAP: 0x8514, + TEXTURE_CUBE_MAP_POSITIVE_X: 0x8515, + TEXTURE_CUBE_MAP_NEGATIVE_X: 0x8516, + TEXTURE_CUBE_MAP_POSITIVE_Y: 0x8517, + TEXTURE_CUBE_MAP_NEGATIVE_Y: 0x8518, + TEXTURE_CUBE_MAP_POSITIVE_Z: 0x8519, + TEXTURE_CUBE_MAP_NEGATIVE_Z: 0x851A, + MAX_CUBE_MAP_TEXTURE_SIZE: 0x851C, + TEXTURE0: 0x84C0, + TEXTURE1: 0x84C1, + TEXTURE2: 0x84C2, + TEXTURE3: 0x84C3, + TEXTURE4: 0x84C4, + TEXTURE5: 0x84C5, + TEXTURE6: 0x84C6, + TEXTURE7: 0x84C7, + TEXTURE8: 0x84C8, + TEXTURE9: 0x84C9, + TEXTURE10: 0x84CA, + TEXTURE11: 0x84CB, + TEXTURE12: 0x84CC, + TEXTURE13: 0x84CD, + TEXTURE14: 0x84CE, + TEXTURE15: 0x84CF, + TEXTURE16: 0x84D0, + TEXTURE17: 0x84D1, + TEXTURE18: 0x84D2, + TEXTURE19: 0x84D3, + TEXTURE20: 0x84D4, + TEXTURE21: 0x84D5, + TEXTURE22: 0x84D6, + TEXTURE23: 0x84D7, + TEXTURE24: 0x84D8, + TEXTURE25: 0x84D9, + TEXTURE26: 0x84DA, + TEXTURE27: 0x84DB, + TEXTURE28: 0x84DC, + TEXTURE29: 0x84DD, + TEXTURE30: 0x84DE, + TEXTURE31: 0x84DF, + ACTIVE_TEXTURE: 0x84E0, + REPEAT: 0x2901, + CLAMP_TO_EDGE: 0x812F, + MIRRORED_REPEAT: 0x8370, + FLOAT_VEC2: 0x8B50, + FLOAT_VEC3: 0x8B51, + FLOAT_VEC4: 0x8B52, + INT_VEC2: 0x8B53, + INT_VEC3: 0x8B54, + INT_VEC4: 0x8B55, + BOOL: 0x8B56, + BOOL_VEC2: 0x8B57, + BOOL_VEC3: 0x8B58, + BOOL_VEC4: 0x8B59, + FLOAT_MAT2: 0x8B5A, + FLOAT_MAT3: 0x8B5B, + FLOAT_MAT4: 0x8B5C, + SAMPLER_2D: 0x8B5E, + SAMPLER_CUBE: 0x8B60, + VERTEX_ATTRIB_ARRAY_ENABLED: 0x8622, + VERTEX_ATTRIB_ARRAY_SIZE: 0x8623, + VERTEX_ATTRIB_ARRAY_STRIDE: 0x8624, + VERTEX_ATTRIB_ARRAY_TYPE: 0x8625, + VERTEX_ATTRIB_ARRAY_NORMALIZED: 0x886A, + VERTEX_ATTRIB_ARRAY_POINTER: 0x8645, + VERTEX_ATTRIB_ARRAY_BUFFER_BINDING: 0x889F, + IMPLEMENTATION_COLOR_READ_TYPE: 0x8B9A, + IMPLEMENTATION_COLOR_READ_FORMAT: 0x8B9B, + COMPILE_STATUS: 0x8B81, + LOW_FLOAT: 0x8DF0, + MEDIUM_FLOAT: 0x8DF1, + HIGH_FLOAT: 0x8DF2, + LOW_INT: 0x8DF3, + MEDIUM_INT: 0x8DF4, + HIGH_INT: 0x8DF5, + FRAMEBUFFER: 0x8D40, + RENDERBUFFER: 0x8D41, + RGBA4: 0x8056, + RGB5_A1: 0x8057, + RGB565: 0x8D62, + DEPTH_COMPONENT16: 0x81A5, + STENCIL_INDEX8: 0x8D48, + DEPTH_STENCIL: 0x84F9, + RENDERBUFFER_WIDTH: 0x8D42, + RENDERBUFFER_HEIGHT: 0x8D43, + RENDERBUFFER_INTERNAL_FORMAT: 0x8D44, + RENDERBUFFER_RED_SIZE: 0x8D50, + RENDERBUFFER_GREEN_SIZE: 0x8D51, + RENDERBUFFER_BLUE_SIZE: 0x8D52, + RENDERBUFFER_ALPHA_SIZE: 0x8D53, + RENDERBUFFER_DEPTH_SIZE: 0x8D54, + RENDERBUFFER_STENCIL_SIZE: 0x8D55, + FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE: 0x8CD0, + FRAMEBUFFER_ATTACHMENT_OBJECT_NAME: 0x8CD1, + FRAMEBUFFER_ATTACHMENT_TEXTURE_LEVEL: 0x8CD2, + FRAMEBUFFER_ATTACHMENT_TEXTURE_CUBE_MAP_FACE: 0x8CD3, + COLOR_ATTACHMENT0: 0x8CE0, + DEPTH_ATTACHMENT: 0x8D00, + STENCIL_ATTACHMENT: 0x8D20, + DEPTH_STENCIL_ATTACHMENT: 0x821A, + NONE: 0, + FRAMEBUFFER_COMPLETE: 0x8CD5, + FRAMEBUFFER_INCOMPLETE_ATTACHMENT: 0x8CD6, + FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT: 0x8CD7, + FRAMEBUFFER_INCOMPLETE_DIMENSIONS: 0x8CD9, + FRAMEBUFFER_UNSUPPORTED: 0x8CDD, + FRAMEBUFFER_BINDING: 0x8CA6, + RENDERBUFFER_BINDING: 0x8CA7, + MAX_RENDERBUFFER_SIZE: 0x84E8, + INVALID_FRAMEBUFFER_OPERATION: 0x0506, + UNPACK_FLIP_Y_WEBGL: 0x9240, + UNPACK_PREMULTIPLY_ALPHA_WEBGL: 0x9241, + CONTEXT_LOST_WEBGL: 0x9242, + UNPACK_COLORSPACE_CONVERSION_WEBGL: 0x9243, + BROWSER_DEFAULT_WEBGL: 0x9244, + canvas: '[PC preview] unknow canvas', + drawingBufferWidth:'[PC preview] unknow drawingBufferWidth', + drawingBufferHeight:'[PC preview] unknow drawingBufferHeight', getContextAttributes: function (...args) { - console.warn("webgl.getContextAttributes interface mocked in the Previewer. How this interface works on the" + + console.warn("WebGLRenderingContext.getContextAttributes interface mocked in the Previewer. How this interface works on the" + " Previewer may be different from that on a real device.") return WebGLContextAttributes }, isContextLost: function (...args) { - console.warn("webgl.isContextLost interface mocked in the Previewer. How this interface works on the" + + console.warn("WebGLRenderingContext.isContextLost interface mocked in the Previewer. How this interface works on the" + " Previewer may be different from that on a real device.") return paramMock.paramBooleanMock }, getSupportedExtensions: function (...args) { - console.warn("webgl.getSupportedExtensions interface mocked in the Previewer. How this interface works on the" + + console.warn("WebGLRenderingContext.getSupportedExtensions interface mocked in the Previewer. How this interface works on the" + " Previewer may be different from that on a real device.") return glParamMock.stringArray }, getExtension: function (...args) { - console.warn("webgl.getExtension interface mocked in the Previewer. How this interface works on the" + + console.warn("WebGLRenderingContext.getExtension interface mocked in the Previewer. How this interface works on the" + " Previewer may be different from that on a real device.") return glParamMock.paramAnyMock }, activeTexture: function (...args) { - console.warn("webgl.activeTexture interface mocked in the Previewer. How this interface works on the" + + console.warn("WebGLRenderingContext.activeTexture interface mocked in the Previewer. How this interface works on the" + " Previewer may be different from that on a real device.") }, attachShader: function (...args) { - console.warn("webgl.attachShader interface mocked in the Previewer. How this interface works on the" + + console.warn("WebGLRenderingContext.attachShader interface mocked in the Previewer. How this interface works on the" + " Previewer may be different from that on a real device.") }, bindAttribLocation: function (...args) { - console.warn("webgl.bindAttribLocation interface mocked in the Previewer. How this interface works on the" + + console.warn("WebGLRenderingContext.bindAttribLocation interface mocked in the Previewer. How this interface works on the" + " Previewer may be different from that on a real device.") }, bindBuffer: function (...args) { - console.warn("webgl.bindBuffer interface mocked in the Previewer. How this interface works on the" + + console.warn("WebGLRenderingContext.bindBuffer interface mocked in the Previewer. How this interface works on the" + " Previewer may be different from that on a real device.") }, bindFramebuffer: function (...args) { - console.warn("webgl.bindFramebuffer interface mocked in the Previewer. How this interface works on the" + + console.warn("WebGLRenderingContext.bindFramebuffer interface mocked in the Previewer. How this interface works on the" + " Previewer may be different from that on a real device.") }, bindRenderbuffer: function (...args) { - console.warn("webgl.bindRenderbuffer interface mocked in the Previewer. How this interface works on the" + + console.warn("WebGLRenderingContext.bindRenderbuffer interface mocked in the Previewer. How this interface works on the" + " Previewer may be different from that on a real device.") }, bindTexture: function (...args) { - console.warn("webgl.bindTexture interface mocked in the Previewer. How this interface works on the" + + console.warn("WebGLRenderingContext.bindTexture interface mocked in the Previewer. How this interface works on the" + " Previewer may be different from that on a real device.") }, blendColor: function (...args) { - console.warn("webgl.blendColor interface mocked in the Previewer. How this interface works on the" + + console.warn("WebGLRenderingContext.blendColor interface mocked in the Previewer. How this interface works on the" + " Previewer may be different from that on a real device.") }, blendEquation: function (...args) { - console.warn("webgl.blendEquation interface mocked in the Previewer. How this interface works on the" + + console.warn("WebGLRenderingContext.blendEquation interface mocked in the Previewer. How this interface works on the" + " Previewer may be different from that on a real device.") }, blendEquationSeparate: function (...args) { - console.warn("webgl.blendEquationSeparate interface mocked in the Previewer. How this interface works on the" + + console.warn("WebGLRenderingContext.blendEquationSeparate interface mocked in the Previewer. How this interface works on the" + " Previewer may be different from that on a real device.") }, blendFunc: function (...args) { - console.warn("webgl.blendFunc interface mocked in the Previewer. How this interface works on the" + + console.warn("WebGLRenderingContext.blendFunc interface mocked in the Previewer. How this interface works on the" + " Previewer may be different from that on a real device.") }, blendFuncSeparate: function (...args) { - console.warn("webgl.blendFuncSeparate interface mocked in the Previewer. How this interface works on the" + + console.warn("WebGLRenderingContext.blendFuncSeparate interface mocked in the Previewer. How this interface works on the" + " Previewer may be different from that on a real device.") }, checkFramebufferStatus: function (...args) { - console.warn("webgl.checkFramebufferStatus interface mocked in the Previewer. How this interface works on the" + + console.warn("WebGLRenderingContext.checkFramebufferStatus interface mocked in the Previewer. How this interface works on the" + " Previewer may be different from that on a real device.") return paramMock.paramNumberMock }, clear: function (...args) { - console.warn("webgl.clear interface mocked in the Previewer. How this interface works on the" + + console.warn("WebGLRenderingContext.clear interface mocked in the Previewer. How this interface works on the" + " Previewer may be different from that on a real device.") }, clearColor: function (...args) { - console.warn("webgl.clearColor interface mocked in the Previewer. How this interface works on the" + + console.warn("WebGLRenderingContext.clearColor interface mocked in the Previewer. How this interface works on the" + " Previewer may be different from that on a real device.") }, clearDepth: function (...args) { - console.warn("webgl.clearDepth interface mocked in the Previewer. How this interface works on the" + + console.warn("WebGLRenderingContext.clearDepth interface mocked in the Previewer. How this interface works on the" + " Previewer may be different from that on a real device.") }, clearStencil: function (...args) { - console.warn("webgl.clearStencil interface mocked in the Previewer. How this interface works on the" + + console.warn("WebGLRenderingContext.clearStencil interface mocked in the Previewer. How this interface works on the" + " Previewer may be different from that on a real device.") }, colorMask: function (...args) { - console.warn("webgl.colorMask interface mocked in the Previewer. How this interface works on the" + + console.warn("WebGLRenderingContext.colorMask interface mocked in the Previewer. How this interface works on the" + " Previewer may be different from that on a real device.") }, compileShader: function (...args) { - console.warn("webgl.compileShader interface mocked in the Previewer. How this interface works on the" + + console.warn("WebGLRenderingContext.compileShader interface mocked in the Previewer. How this interface works on the" + " Previewer may be different from that on a real device.") }, copyTexImage2D: function (...args) { - console.warn("webgl.copyTexImage2D interface mocked in the Previewer. How this interface works on the" + + console.warn("WebGLRenderingContext.copyTexImage2D interface mocked in the Previewer. How this interface works on the" + " Previewer may be different from that on a real device.") }, copyTexSubImage2D: function (...args) { - console.warn("webgl.copyTexSubImage2D interface mocked in the Previewer. How this interface works on the" + + console.warn("WebGLRenderingContext.copyTexSubImage2D interface mocked in the Previewer. How this interface works on the" + " Previewer may be different from that on a real device.") }, createBuffer: function (...args) { - console.warn("webgl.createBuffer interface mocked in the Previewer. How this interface works on the" + + console.warn("WebGLRenderingContext.createBuffer interface mocked in the Previewer. How this interface works on the" + " Previewer may be different from that on a real device.") return WebGLBuffer; }, createFramebuffer: function (...args) { - console.warn("webgl.createFramebuffer interface mocked in the Previewer. How this interface works on the" + + console.warn("WebGLRenderingContext.createFramebuffer interface mocked in the Previewer. How this interface works on the" + " Previewer may be different from that on a real device.") return WebGLFramebuffer; }, createProgram: function (...args) { - console.warn("webgl.createProgram interface mocked in the Previewer. How this interface works on the" + + console.warn("WebGLRenderingContext.createProgram interface mocked in the Previewer. How this interface works on the" + " Previewer may be different from that on a real device.") return WebGLProgram; }, createRenderbuffer: function (...args) { - console.warn("webgl.createRenderbuffer interface mocked in the Previewer. How this interface works on the" + + console.warn("WebGLRenderingContext.createRenderbuffer interface mocked in the Previewer. How this interface works on the" + " Previewer may be different from that on a real device.") return WebGLRenderbuffer; }, createShader: function (...args) { - console.warn("webgl.createShader interface mocked in the Previewer. How this interface works on the" + + console.warn("WebGLRenderingContext.createShader interface mocked in the Previewer. How this interface works on the" + " Previewer may be different from that on a real device.") return WebGLShader; }, createTexture: function (...args) { - console.warn("webgl.createTexture interface mocked in the Previewer. How this interface works on the" + + console.warn("WebGLRenderingContext.createTexture interface mocked in the Previewer. How this interface works on the" + " Previewer may be different from that on a real device.") return WebGLTexture; }, cullFace: function (...args) { - console.warn("webgl.cullFace interface mocked in the Previewer. How this interface works on the" + + console.warn("WebGLRenderingContext.cullFace interface mocked in the Previewer. How this interface works on the" + " Previewer may be different from that on a real device.") }, deleteBuffer: function (...args) { - console.warn("webgl.deleteBuffer interface mocked in the Previewer. How this interface works on the" + + console.warn("WebGLRenderingContext.deleteBuffer interface mocked in the Previewer. How this interface works on the" + " Previewer may be different from that on a real device.") }, deleteFramebuffer: function (...args) { - console.warn("webgl.deleteFramebuffer interface mocked in the Previewer. How this interface works on the" + + console.warn("WebGLRenderingContext.deleteFramebuffer interface mocked in the Previewer. How this interface works on the" + " Previewer may be different from that on a real device.") }, deleteProgram: function (...args) { - console.warn("webgl.deleteProgram interface mocked in the Previewer. How this interface works on the" + + console.warn("WebGLRenderingContext.deleteProgram interface mocked in the Previewer. How this interface works on the" + " Previewer may be different from that on a real device.") }, deleteRenderbuffer: function (...args) { - console.warn("webgl.deleteRenderbuffer interface mocked in the Previewer. How this interface works on the" + + console.warn("WebGLRenderingContext.deleteRenderbuffer interface mocked in the Previewer. How this interface works on the" + " Previewer may be different from that on a real device.") }, deleteShader: function (...args) { - console.warn("webgl.deleteRenderbuffer interface mocked in the Previewer. How this interface works on the" + + console.warn("WebGLRenderingContext.deleteRenderbuffer interface mocked in the Previewer. How this interface works on the" + " Previewer may be different from that on a real device.") }, deleteTexture: function (...args) { - console.warn("webgl.deleteRenderbuffer interface mocked in the Previewer. How this interface works on the" + + console.warn("WebGLRenderingContext.deleteRenderbuffer interface mocked in the Previewer. How this interface works on the" + " Previewer may be different from that on a real device.") }, depthFunc: function (...args) { - console.warn("webgl.deleteRenderbuffer interface mocked in the Previewer. How this interface works on the" + + console.warn("WebGLRenderingContext.deleteRenderbuffer interface mocked in the Previewer. How this interface works on the" + " Previewer may be different from that on a real device.") }, depthMask: function (...args) { - console.warn("webgl.deleteRenderbuffer interface mocked in the Previewer. How this interface works on the" + + console.warn("WebGLRenderingContext.deleteRenderbuffer interface mocked in the Previewer. How this interface works on the" + " Previewer may be different from that on a real device.") }, depthRange: function (...args) { - console.warn("webgl.depthRange interface mocked in the Previewer. How this interface works on the" + + console.warn("WebGLRenderingContext.depthRange interface mocked in the Previewer. How this interface works on the" + " Previewer may be different from that on a real device.") }, detachShader: function (...args) { - console.warn("webgl.detachShader interface mocked in the Previewer. How this interface works on the" + + console.warn("WebGLRenderingContext.detachShader interface mocked in the Previewer. How this interface works on the" + " Previewer may be different from that on a real device.") }, disable: function (...args) { - console.warn("webgl.disable interface mocked in the Previewer. How this interface works on the" + + console.warn("WebGLRenderingContext.disable interface mocked in the Previewer. How this interface works on the" + " Previewer may be different from that on a real device.") }, disableVertexAttribArray: function (...args) { - console.warn("webgl.disableVertexAttribArray interface mocked in the Previewer. How this interface works on the" + + console.warn("WebGLRenderingContext.disableVertexAttribArray interface mocked in the Previewer. How this interface works on the" + " Previewer may be different from that on a real device.") }, drawArrays: function (...args) { - console.warn("webgl.drawArrays interface mocked in the Previewer. How this interface works on the" + + console.warn("WebGLRenderingContext.drawArrays interface mocked in the Previewer. How this interface works on the" + " Previewer may be different from that on a real device.") }, drawElements: function (...args) { - console.warn("webgl.drawElements interface mocked in the Previewer. How this interface works on the" + + console.warn("WebGLRenderingContext.drawElements interface mocked in the Previewer. How this interface works on the" + " Previewer may be different from that on a real device.") }, enable: function (...args) { - console.warn("webgl.enable interface mocked in the Previewer. How this interface works on the" + + console.warn("WebGLRenderingContext.enable interface mocked in the Previewer. How this interface works on the" + " Previewer may be different from that on a real device.") }, enableVertexAttribArray: function (...args) { - console.warn("webgl.enableVertexAttribArray interface mocked in the Previewer. How this interface works on the" + + console.warn("WebGLRenderingContext.enableVertexAttribArray interface mocked in the Previewer. How this interface works on the" + " Previewer may be different from that on a real device.") }, finish: function (...args) { - console.warn("webgl.finish interface mocked in the Previewer. How this interface works on the" + + console.warn("WebGLRenderingContext.finish interface mocked in the Previewer. How this interface works on the" + " Previewer may be different from that on a real device.") }, flush: function (...args) { - console.warn("webgl.flush interface mocked in the Previewer. How this interface works on the" + + console.warn("WebGLRenderingContext.flush interface mocked in the Previewer. How this interface works on the" + " Previewer may be different from that on a real device.") }, framebufferRenderbuffer: function (...args) { - console.warn("webgl.framebufferRenderbuffer interface mocked in the Previewer. How this interface works on the" + + console.warn("WebGLRenderingContext.framebufferRenderbuffer interface mocked in the Previewer. How this interface works on the" + " Previewer may be different from that on a real device.") }, framebufferTexture2D: function (...args) { - console.warn("webgl.framebufferTexture2D interface mocked in the Previewer. How this interface works on the" + + console.warn("WebGLRenderingContext.framebufferTexture2D interface mocked in the Previewer. How this interface works on the" + " Previewer may be different from that on a real device.") }, frontFace: function (...args) { - console.warn("webgl.frontFace interface mocked in the Previewer. How this interface works on the" + + console.warn("WebGLRenderingContext.frontFace interface mocked in the Previewer. How this interface works on the" + " Previewer may be different from that on a real device.") }, generateMipmap: function (...args) { - console.warn("webgl.generateMipmap interface mocked in the Previewer. How this interface works on the" + + console.warn("WebGLRenderingContext.generateMipmap interface mocked in the Previewer. How this interface works on the" + " Previewer may be different from that on a real device.") }, getActiveAttrib: function (...args) { - console.warn("webgl.getActiveAttrib interface mocked in the Previewer. How this interface works on the" + + console.warn("WebGLRenderingContext.getActiveAttrib interface mocked in the Previewer. How this interface works on the" + " Previewer may be different from that on a real device.") return WebGLActiveInfo; }, getActiveUniform: function (...args) { - console.warn("webgl.getActiveAttrib interface mocked in the Previewer. How this interface works on the" + + console.warn("WebGLRenderingContext.getActiveAttrib interface mocked in the Previewer. How this interface works on the" + " Previewer may be different from that on a real device.") return WebGLActiveInfo; }, getAttachedShaders: function (...args) { - console.warn("webgl.getActiveAttrib interface mocked in the Previewer. How this interface works on the" + + console.warn("WebGLRenderingContext.getActiveAttrib interface mocked in the Previewer. How this interface works on the" + " Previewer may be different from that on a real device.") return glParamMock.WebGLShaderArray; }, getAttribLocation: function (...args) { - console.warn("webgl.getActiveAttrib interface mocked in the Previewer. How this interface works on the" + + console.warn("WebGLRenderingContext.getActiveAttrib interface mocked in the Previewer. How this interface works on the" + " Previewer may be different from that on a real device.") return paramMock.paramNumberMock; }, getBufferParameter: function (...args) { - console.warn("webgl.getActiveAttrib interface mocked in the Previewer. How this interface works on the" + + console.warn("WebGLRenderingContext.getActiveAttrib interface mocked in the Previewer. How this interface works on the" + " Previewer may be different from that on a real device.") return paramMock.paramNumberMock; }, getParameter: function (...args) { - console.warn("webgl.getActiveAttrib interface mocked in the Previewer. How this interface works on the" + + console.warn("WebGLRenderingContext.getActiveAttrib interface mocked in the Previewer. How this interface works on the" + " Previewer may be different from that on a real device.") if (args[0] == 0x0B73 || args[0] == 0x0B21 || args[0] == 0x8038 || args[0] == 0x2A00 || @@ -379,12 +678,12 @@ export function mockwebgl() { } }, getError: function (...args) { - console.warn("webgl.getError interface mocked in the Previewer. How this interface works on the" + + console.warn("WebGLRenderingContext.getError interface mocked in the Previewer. How this interface works on the" + " Previewer may be different from that on a real device.") return paramMock.paramNumberMock; }, getFramebufferAttachmentParameter: function (...args) { - console.warn("webgl.getFramebufferAttachmentParameter interface mocked in the Previewer. How this interface works on the" + + console.warn("WebGLRenderingContext.getFramebufferAttachmentParameter interface mocked in the Previewer. How this interface works on the" + " Previewer may be different from that on a real device.") if (args[2] == 0x8CD0 || args[2] == 0x8CD2 || @@ -404,7 +703,7 @@ export function mockwebgl() { } }, getProgramParameter: function (...args) { - console.warn("webgl.getProgramParameter interface mocked in the Previewer. How this interface works on the" + + console.warn("WebGLRenderingContext.getProgramParameter interface mocked in the Previewer. How this interface works on the" + " Previewer may be different from that on a real device.") if (args[1] == 0x8B80 || args[1] == 0x8B82 || args[1] == 0x8B83) { return paramMock.paramBooleanMock; @@ -413,18 +712,18 @@ export function mockwebgl() { } }, getProgramInfoLog: function (...args) { - console.warn("webgl.getProgramInfoLog interface mocked in the Previewer. How this interface works on the" + + console.warn("WebGLRenderingContext.getProgramInfoLog interface mocked in the Previewer. How this interface works on the" + " Previewer may be different from that on a real device.") return paramMock.paramStringMock; }, getRenderbufferParameter: function (...args) { - console.warn("webgl.getRenderbufferParameter interface mocked in the Previewer. How this interface works on the" + + console.warn("WebGLRenderingContext.getRenderbufferParameter interface mocked in the Previewer. How this interface works on the" + " Previewer may be different from that on a real device.") return paramMock.paramNumberMock; }, getShaderParameter: function (...args) { - console.warn("webgl.getShaderParameter interface mocked in the Previewer. How this interface works on the" + + console.warn("WebGLRenderingContext.getShaderParameter interface mocked in the Previewer. How this interface works on the" + " Previewer may be different from that on a real device.") if (args[1] == 0x8B4F) { return paramMock.paramNumberMock; @@ -433,22 +732,22 @@ export function mockwebgl() { } }, getShaderPrecisionFormat: function (...args) { - console.warn("webgl.getShaderPrecisionFormat interface mocked in the Previewer. How this interface works on the" + + console.warn("WebGLRenderingContext.getShaderPrecisionFormat interface mocked in the Previewer. How this interface works on the" + " Previewer may be different from that on a real device.") return WebGLShaderPrecisionFormat; }, getShaderInfoLog: function (...args) { - console.warn("webgl.getShaderInfoLog interface mocked in the Previewer. How this interface works on the" + + console.warn("WebGLRenderingContext.getShaderInfoLog interface mocked in the Previewer. How this interface works on the" + " Previewer may be different from that on a real device.") return paramMock.paramStringMock; }, getShaderSource: function (...args) { - console.warn("webgl.getShaderSource interface mocked in the Previewer. How this interface works on the" + + console.warn("WebGLRenderingContext.getShaderSource interface mocked in the Previewer. How this interface works on the" + " Previewer may be different from that on a real device.") return paramMock.paramStringMock; }, getTexParameter: function (...args) { - console.warn("webgl.getTexParameter interface mocked in the Previewer. How this interface works on the" + + console.warn("WebGLRenderingContext.getTexParameter interface mocked in the Previewer. How this interface works on the" + " Previewer may be different from that on a real device.") if (args[1] == 0x84FE) { return glParamMock.paramDoubleMock; @@ -457,293 +756,293 @@ export function mockwebgl() { } }, getUniform: function (...args) { - console.warn("webgl.getUniform interface mocked in the Previewer. How this interface works on the" + + console.warn("WebGLRenderingContext.getUniform interface mocked in the Previewer. How this interface works on the" + " Previewer may be different from that on a real device.") return glParamMock.paramAnyMock; }, getUniformLocation: function (...args) { - console.warn("webgl.getUniformLocation interface mocked in the Previewer. How this interface works on the" + + console.warn("WebGLRenderingContext.getUniformLocation interface mocked in the Previewer. How this interface works on the" + " Previewer may be different from that on a real device.") return WebGLUniformLocation; }, getVertexAttrib: function (...args) { - console.warn("webgl.getVertexAttrib interface mocked in the Previewer. How this interface works on the" + + console.warn("WebGLRenderingContext.getVertexAttrib interface mocked in the Previewer. How this interface works on the" + " Previewer may be different from that on a real device.") return paramMock.paramBooleanMock; }, getVertexAttribOffset: function (...args) { - console.warn("webgl.getVertexAttribOffset interface mocked in the Previewer. How this interface works on the" + + console.warn("WebGLRenderingContext.getVertexAttribOffset interface mocked in the Previewer. How this interface works on the" + " Previewer may be different from that on a real device.") return paramMock.paramNumberMock; }, hint: function (...args) { - console.warn("webgl.hint interface mocked in the Previewer. How this interface works on the" + + console.warn("WebGLRenderingContext.hint interface mocked in the Previewer. How this interface works on the" + " Previewer may be different from that on a real device.") }, isBuffer: function (...args) { - console.warn("webgl.isBuffer interface mocked in the Previewer. How this interface works on the" + + console.warn("WebGLRenderingContext.isBuffer interface mocked in the Previewer. How this interface works on the" + " Previewer may be different from that on a real device.") return paramMock.paramBooleanMock; }, isEnabled: function (...args) { - console.warn("webgl.isEnabled interface mocked in the Previewer. How this interface works on the" + + console.warn("WebGLRenderingContext.isEnabled interface mocked in the Previewer. How this interface works on the" + " Previewer may be different from that on a real device.") return paramMock.paramBooleanMock; }, isFramebuffer: function (...args) { - console.warn("webgl.isFramebuffer interface mocked in the Previewer. How this interface works on the" + + console.warn("WebGLRenderingContext.isFramebuffer interface mocked in the Previewer. How this interface works on the" + " Previewer may be different from that on a real device.") return paramMock.paramBooleanMock; }, isProgram: function (...args) { - console.warn("webgl.isProgram interface mocked in the Previewer. How this interface works on the" + + console.warn("WebGLRenderingContext.isProgram interface mocked in the Previewer. How this interface works on the" + " Previewer may be different from that on a real device.") return paramMock.paramBooleanMock; }, isRenderbuffer: function (...args) { - console.warn("webgl.isRenderbuffer interface mocked in the Previewer. How this interface works on the" + + console.warn("WebGLRenderingContext.isRenderbuffer interface mocked in the Previewer. How this interface works on the" + " Previewer may be different from that on a real device.") return paramMock.paramBooleanMock; }, isShader: function (...args) { - console.warn("webgl.isShader interface mocked in the Previewer. How this interface works on the" + + console.warn("WebGLRenderingContext.isShader interface mocked in the Previewer. How this interface works on the" + " Previewer may be different from that on a real device.") return paramMock.paramBooleanMock; }, isTexture: function (...args) { - console.warn("webgl.isTexture interface mocked in the Previewer. How this interface works on the" + + console.warn("WebGLRenderingContext.isTexture interface mocked in the Previewer. How this interface works on the" + " Previewer may be different from that on a real device.") return paramMock.paramBooleanMock; }, lineWidth: function (...args) { - console.warn("webgl.lineWidth interface mocked in the Previewer. How this interface works on the" + + console.warn("WebGLRenderingContext.lineWidth interface mocked in the Previewer. How this interface works on the" + " Previewer may be different from that on a real device.") }, linkProgram: function (...args) { - console.warn("webgl.linkProgram interface mocked in the Previewer. How this interface works on the" + + console.warn("WebGLRenderingContext.linkProgram interface mocked in the Previewer. How this interface works on the" + " Previewer may be different from that on a real device.") }, pixelStorei: function (...args) { - console.warn("webgl.pixelStorei interface mocked in the Previewer. How this interface works on the" + + console.warn("WebGLRenderingContext.pixelStorei interface mocked in the Previewer. How this interface works on the" + " Previewer may be different from that on a real device.") }, polygonOffset: function (...args) { - console.warn("webgl.polygonOffset interface mocked in the Previewer. How this interface works on the" + + console.warn("WebGLRenderingContext.polygonOffset interface mocked in the Previewer. How this interface works on the" + " Previewer may be different from that on a real device.") }, renderbufferStorage: function (...args) { - console.warn("webgl.renderbufferStorage interface mocked in the Previewer. How this interface works on the" + + console.warn("WebGLRenderingContext.renderbufferStorage interface mocked in the Previewer. How this interface works on the" + " Previewer may be different from that on a real device.") }, sampleCoverage: function (...args) { - console.warn("webgl.sampleCoverage interface mocked in the Previewer. How this interface works on the" + + console.warn("WebGLRenderingContext.sampleCoverage interface mocked in the Previewer. How this interface works on the" + " Previewer may be different from that on a real device.") }, scissor: function (...args) { - console.warn("webgl.scissor interface mocked in the Previewer. How this interface works on the" + + console.warn("WebGLRenderingContext.scissor interface mocked in the Previewer. How this interface works on the" + " Previewer may be different from that on a real device.") }, shaderSource: function (...args) { - console.warn("webgl.shaderSource interface mocked in the Previewer. How this interface works on the" + + console.warn("WebGLRenderingContext.shaderSource interface mocked in the Previewer. How this interface works on the" + " Previewer may be different from that on a real device.") }, stencilFunc: function (...args) { - console.warn("webgl.stencilFunc interface mocked in the Previewer. How this interface works on the" + + console.warn("WebGLRenderingContext.stencilFunc interface mocked in the Previewer. How this interface works on the" + " Previewer may be different from that on a real device.") }, stencilFuncSeparate: function (...args) { - console.warn("webgl.stencilFuncSeparate interface mocked in the Previewer. How this interface works on the" + + console.warn("WebGLRenderingContext.stencilFuncSeparate interface mocked in the Previewer. How this interface works on the" + " Previewer may be different from that on a real device.") }, stencilMask: function (...args) { - console.warn("webgl.stencilMask interface mocked in the Previewer. How this interface works on the" + + console.warn("WebGLRenderingContext.stencilMask interface mocked in the Previewer. How this interface works on the" + " Previewer may be different from that on a real device.") }, stencilMaskSeparate: function (...args) { - console.warn("webgl.stencilMaskSeparate interface mocked in the Previewer. How this interface works on the" + + console.warn("WebGLRenderingContext.stencilMaskSeparate interface mocked in the Previewer. How this interface works on the" + " Previewer may be different from that on a real device.") }, stencilOp: function (...args) { - console.warn("webgl.stencilOp interface mocked in the Previewer. How this interface works on the" + + console.warn("WebGLRenderingContext.stencilOp interface mocked in the Previewer. How this interface works on the" + " Previewer may be different from that on a real device.") }, stencilOpSeparate: function (...args) { - console.warn("webgl.stencilOpSeparate interface mocked in the Previewer. How this interface works on the" + + console.warn("WebGLRenderingContext.stencilOpSeparate interface mocked in the Previewer. How this interface works on the" + " Previewer may be different from that on a real device.") }, texParameterf: function (...args) { - console.warn("webgl.texParameterf interface mocked in the Previewer. How this interface works on the" + + console.warn("WebGLRenderingContext.texParameterf interface mocked in the Previewer. How this interface works on the" + " Previewer may be different from that on a real device.") }, texParameteri: function (...args) { - console.warn("webgl.texParameteri interface mocked in the Previewer. How this interface works on the" + + console.warn("WebGLRenderingContext.texParameteri interface mocked in the Previewer. How this interface works on the" + " Previewer may be different from that on a real device.") }, uniform1f: function (...args) { - console.warn("webgl.uniform1f interface mocked in the Previewer. How this interface works on the" + + console.warn("WebGLRenderingContext.uniform1f interface mocked in the Previewer. How this interface works on the" + " Previewer may be different from that on a real device.") }, uniform2f: function (...args) { - console.warn("webgl.uniform2f interface mocked in the Previewer. How this interface works on the" + + console.warn("WebGLRenderingContext.uniform2f interface mocked in the Previewer. How this interface works on the" + " Previewer may be different from that on a real device.") }, uniform3f: function (...args) { - console.warn("webgl.uniform3f interface mocked in the Previewer. How this interface works on the" + + console.warn("WebGLRenderingContext.uniform3f interface mocked in the Previewer. How this interface works on the" + " Previewer may be different from that on a real device.") }, uniform4f: function (...args) { - console.warn("webgl.uniform4f interface mocked in the Previewer. How this interface works on the" + + console.warn("WebGLRenderingContext.uniform4f interface mocked in the Previewer. How this interface works on the" + " Previewer may be different from that on a real device.") }, uniform1i: function (...args) { - console.warn("webgl.uniform1i interface mocked in the Previewer. How this interface works on the" + + console.warn("WebGLRenderingContext.uniform1i interface mocked in the Previewer. How this interface works on the" + " Previewer may be different from that on a real device.") }, uniform2i: function (...args) { - console.warn("webgl.uniform2i interface mocked in the Previewer. How this interface works on the" + + console.warn("WebGLRenderingContext.uniform2i interface mocked in the Previewer. How this interface works on the" + " Previewer may be different from that on a real device.") }, uniform3i: function (...args) { - console.warn("webgl.uniform3i interface mocked in the Previewer. How this interface works on the" + + console.warn("WebGLRenderingContext.uniform3i interface mocked in the Previewer. How this interface works on the" + " Previewer may be different from that on a real device.") }, uniform4i: function (...args) { - console.warn("webgl.uniform4i interface mocked in the Previewer. How this interface works on the" + + console.warn("WebGLRenderingContext.uniform4i interface mocked in the Previewer. How this interface works on the" + " Previewer may be different from that on a real device.") }, useProgram: function (...args) { - console.warn("webgl.useProgram interface mocked in the Previewer. How this interface works on the" + + console.warn("WebGLRenderingContext.useProgram interface mocked in the Previewer. How this interface works on the" + " Previewer may be different from that on a real device.") }, validateProgram: function (...args) { - console.warn("webgl.validateProgram interface mocked in the Previewer. How this interface works on the" + + console.warn("WebGLRenderingContext.validateProgram interface mocked in the Previewer. How this interface works on the" + " Previewer may be different from that on a real device.") }, vertexAttrib1f: function (...args) { - console.warn("webgl.vertexAttrib1f interface mocked in the Previewer. How this interface works on the" + + console.warn("WebGLRenderingContext.vertexAttrib1f interface mocked in the Previewer. How this interface works on the" + " Previewer may be different from that on a real device.") }, vertexAttrib2f: function (...args) { - console.warn("webgl.vertexAttrib2f interface mocked in the Previewer. How this interface works on the" + + console.warn("WebGLRenderingContext.vertexAttrib2f interface mocked in the Previewer. How this interface works on the" + " Previewer may be different from that on a real device.") }, vertexAttrib3f: function (...args) { - console.warn("webgl.vertexAttrib3f interface mocked in the Previewer. How this interface works on the" + + console.warn("WebGLRenderingContext.vertexAttrib3f interface mocked in the Previewer. How this interface works on the" + " Previewer may be different from that on a real device.") }, vertexAttrib4f: function (...args) { - console.warn("webgl.vertexAttrib4f interface mocked in the Previewer. How this interface works on the" + + console.warn("WebGLRenderingContext.vertexAttrib4f interface mocked in the Previewer. How this interface works on the" + " Previewer may be different from that on a real device.") }, vertexAttrib1fv: function (...args) { - console.warn("webgl.vertexAttrib1fv interface mocked in the Previewer. How this interface works on the" + + console.warn("WebGLRenderingContext.vertexAttrib1fv interface mocked in the Previewer. How this interface works on the" + " Previewer may be different from that on a real device.") }, vertexAttrib2fv: function (...args) { - console.warn("webgl.vertexAttrib2fv interface mocked in the Previewer. How this interface works on the" + + console.warn("WebGLRenderingContext.vertexAttrib2fv interface mocked in the Previewer. How this interface works on the" + " Previewer may be different from that on a real device.") }, vertexAttrib3fv: function (...args) { - console.warn("webgl.vertexAttrib3fv interface mocked in the Previewer. How this interface works on the" + + console.warn("WebGLRenderingContext.vertexAttrib3fv interface mocked in the Previewer. How this interface works on the" + " Previewer may be different from that on a real device.") }, vertexAttrib4fv: function (...args) { - console.warn("webgl.vertexAttrib4fv interface mocked in the Previewer. How this interface works on the" + + console.warn("WebGLRenderingContext.vertexAttrib4fv interface mocked in the Previewer. How this interface works on the" + " Previewer may be different from that on a real device.") }, vertexAttribPointer: function (...args) { - console.warn("webgl.vertexAttribPointer interface mocked in the Previewer. How this interface works on the" + + console.warn("WebGLRenderingContext.vertexAttribPointer interface mocked in the Previewer. How this interface works on the" + " Previewer may be different from that on a real device.") }, viewport: function (...args) { - console.warn("webgl.vertexAttrib3fv interface mocked in the Previewer. How this interface works on the" + + console.warn("WebGLRenderingContext.vertexAttrib3fv interface mocked in the Previewer. How this interface works on the" + " Previewer may be different from that on a real device.") }, bufferData: function (...args) { - console.warn("webgl.bufferData interface mocked in the Previewer. How this interface works on the" + + console.warn("WebGLRenderingContext.bufferData interface mocked in the Previewer. How this interface works on the" + " Previewer may be different from that on a real device.") }, bufferSubData: function (...args) { - console.warn("webgl.bufferSubData interface mocked in the Previewer. How this interface works on the" + + console.warn("WebGLRenderingContext.bufferSubData interface mocked in the Previewer. How this interface works on the" + " Previewer may be different from that on a real device.") }, compressedTexImage2D: function (...args) { - console.warn("webgl.compressedTexImage2D interface mocked in the Previewer. How this interface works on the" + + console.warn("WebGLRenderingContext.compressedTexImage2D interface mocked in the Previewer. How this interface works on the" + " Previewer may be different from that on a real device.") }, compressedTexSubImage2D: function (...args) { - console.warn("webgl.compressedTexSubImage2D interface mocked in the Previewer. How this interface works on the" + + console.warn("WebGLRenderingContext.compressedTexSubImage2D interface mocked in the Previewer. How this interface works on the" + " Previewer may be different from that on a real device.") }, readPixels: function (...args) { - console.warn("webgl.readPixels interface mocked in the Previewer. How this interface works on the" + + console.warn("WebGLRenderingContext.readPixels interface mocked in the Previewer. How this interface works on the" + " Previewer may be different from that on a real device.") }, texImage2D: function (...args) { - console.warn("webgl.texImage2D interface mocked in the Previewer. How this interface works on the" + + console.warn("WebGLRenderingContext.texImage2D interface mocked in the Previewer. How this interface works on the" + " Previewer may be different from that on a real device.") }, texSubImage2D: function (...args) { - console.warn("webgl.texSubImage2D interface mocked in the Previewer. How this interface works on the" + + console.warn("WebGLRenderingContext.texSubImage2D interface mocked in the Previewer. How this interface works on the" + " Previewer may be different from that on a real device.") }, uniform1fv: function (...args) { - console.warn("webgl.uniform1fv interface mocked in the Previewer. How this interface works on the" + + console.warn("WebGLRenderingContext.uniform1fv interface mocked in the Previewer. How this interface works on the" + " Previewer may be different from that on a real device.") }, uniform2fv: function (...args) { - console.warn("webgl.uniform2fv interface mocked in the Previewer. How this interface works on the" + + console.warn("WebGLRenderingContext.uniform2fv interface mocked in the Previewer. How this interface works on the" + " Previewer may be different from that on a real device.") }, uniform3fv: function (...args) { - console.warn("webgl.uniform3fv interface mocked in the Previewer. How this interface works on the" + + console.warn("WebGLRenderingContext.uniform3fv interface mocked in the Previewer. How this interface works on the" + " Previewer may be different from that on a real device.") }, uniform4fv: function (...args) { - console.warn("webgl.uniform4fv interface mocked in the Previewer. How this interface works on the" + + console.warn("WebGLRenderingContext.uniform4fv interface mocked in the Previewer. How this interface works on the" + " Previewer may be different from that on a real device.") }, uniform1iv: function (...args) { - console.warn("webgl.uniform1iv interface mocked in the Previewer. How this interface works on the" + + console.warn("WebGLRenderingContext.uniform1iv interface mocked in the Previewer. How this interface works on the" + " Previewer may be different from that on a real device.") }, uniform2iv: function (...args) { - console.warn("webgl.uniform2iv interface mocked in the Previewer. How this interface works on the" + + console.warn("WebGLRenderingContext.uniform2iv interface mocked in the Previewer. How this interface works on the" + " Previewer may be different from that on a real device.") }, uniform3iv: function (...args) { - console.warn("webgl.uniform3iv interface mocked in the Previewer. How this interface works on the" + + console.warn("WebGLRenderingContext.uniform3iv interface mocked in the Previewer. How this interface works on the" + " Previewer may be different from that on a real device.") }, uniform4iv: function (...args) { - console.warn("webgl.uniform4iv interface mocked in the Previewer. How this interface works on the" + + console.warn("WebGLRenderingContext.uniform4iv interface mocked in the Previewer. How this interface works on the" + " Previewer may be different from that on a real device.") }, uniformMatrix2fv: function (...args) { - console.warn("webgl.uniformMatrix2fv interface mocked in the Previewer. How this interface works on the" + + console.warn("WebGLRenderingContext.uniformMatrix2fv interface mocked in the Previewer. How this interface works on the" + " Previewer may be different from that on a real device.") }, uniformMatrix3fv: function (...args) { - console.warn("webgl.uniformMatrix3fv interface mocked in the Previewer. How this interface works on the" + + console.warn("WebGLRenderingContext.uniformMatrix3fv interface mocked in the Previewer. How this interface works on the" + " Previewer may be different from that on a real device.") }, uniformMatrix4fv: function (...args) { - console.warn("webgl.uniformMatrix4fv interface mocked in the Previewer. How this interface works on the" + + console.warn("WebGLRenderingContext.uniformMatrix4fv interface mocked in the Previewer. How this interface works on the" + " Previewer may be different from that on a real device.") } } - return webglmock + return WebGLRenderingContext; } \ No newline at end of file diff --git a/runtime/main/extend/systemplugin/napi/webgl2.js b/runtime/main/extend/systemplugin/napi/webgl2.js old mode 100644 new mode 100755 index 4888c98d..966199a5 --- a/runtime/main/extend/systemplugin/napi/webgl2.js +++ b/runtime/main/extend/systemplugin/napi/webgl2.js @@ -40,225 +40,484 @@ export function mockwebgl2() { int32Array: '[PC preview] unknow int32Array', uintArray: '[PC preview] unknow uintArray' } - const GL_SAMPLES = 0x80A9; - const GL_QUERY_RESULT = 0x8866; - const GL_QUERY_RESULT_AVAILABLE = 0x8867; - const GL_TEXTURE_MAX_LOD = 0x813B; - const GL_TEXTURE_MIN_LOD = 0x813A; - const webgl2Mock = { + + const WebGL2RenderingContext = { + READ_BUFFER: 0x0C02, + UNPACK_ROW_LENGTH: 0x0CF2, + UNPACK_SKIP_ROWS: 0x0CF3, + UNPACK_SKIP_PIXELS: 0x0CF4, + PACK_ROW_LENGTH: 0x0D02, + PACK_SKIP_ROWS: 0x0D03, + PACK_SKIP_PIXELS: 0x0D04, + COLOR: 0x1800, + DEPTH: 0x1801, + STENCIL: 0x1802, + RED: 0x1903, + RGB8: 0x8051, + RGBA8: 0x8058, + RGB10_A2: 0x8059, + TEXTURE_BINDING_3D: 0x806A, + UNPACK_SKIP_IMAGES: 0x806D, + UNPACK_IMAGE_HEIGHT: 0x806E, + TEXTURE_3D: 0x806F, + TEXTURE_WRAP_R: 0x8072, + MAX_3D_TEXTURE_SIZE: 0x8073, + UNSIGNED_INT_2_10_10_10_REV: 0x8368, + MAX_ELEMENTS_VERTICES: 0x80E8, + MAX_ELEMENTS_INDICES: 0x80E9, + TEXTURE_MIN_LOD: 0x813A, + TEXTURE_MAX_LOD: 0x813B, + TEXTURE_BASE_LEVEL: 0x813C, + TEXTURE_MAX_LEVEL: 0x813D, + MIN: 0x8007, + MAX: 0x8008, + DEPTH_COMPONENT24: 0x81A6, + MAX_TEXTURE_LOD_BIAS: 0x84FD, + TEXTURE_COMPARE_MODE: 0x884C, + TEXTURE_COMPARE_FUNC: 0x884D, + CURRENT_QUERY: 0x8865, + QUERY_RESULT: 0x8866, + QUERY_RESULT_AVAILABLE: 0x8867, + STREAM_READ: 0x88E1, + STREAM_COPY: 0x88E2, + STATIC_READ: 0x88E5, + STATIC_COPY: 0x88E6, + DYNAMIC_READ: 0x88E9, + DYNAMIC_COPY: 0x88EA, + MAX_DRAW_BUFFERS: 0x8824, + DRAW_BUFFER0: 0x8825, + DRAW_BUFFER1: 0x8826, + DRAW_BUFFER2: 0x8827, + DRAW_BUFFER3: 0x8828, + DRAW_BUFFER4: 0x8829, + DRAW_BUFFER5: 0x882A, + DRAW_BUFFER6: 0x882B, + DRAW_BUFFER7: 0x882C, + DRAW_BUFFER8: 0x882D, + DRAW_BUFFER9: 0x882E, + DRAW_BUFFER10: 0x882F, + DRAW_BUFFER11: 0x8830, + DRAW_BUFFER12: 0x8831, + DRAW_BUFFER13: 0x8832, + DRAW_BUFFER14: 0x8833, + DRAW_BUFFER15: 0x8834, + MAX_FRAGMENT_UNIFORM_COMPONENTS: 0x8B49, + MAX_VERTEX_UNIFORM_COMPONENTS: 0x8B4A, + SAMPLER_3D: 0x8B5F, + SAMPLER_2D_SHADOW: 0x8B62, + FRAGMENT_SHADER_DERIVATIVE_HINT: 0x8B8B, + PIXEL_PACK_BUFFER: 0x88EB, + PIXEL_UNPACK_BUFFER: 0x88EC, + PIXEL_PACK_BUFFER_BINDING: 0x88ED, + PIXEL_UNPACK_BUFFER_BINDING: 0x88EF, + FLOAT_MAT2x3: 0x8B65, + FLOAT_MAT2x4: 0x8B66, + FLOAT_MAT3x2: 0x8B67, + FLOAT_MAT3x4: 0x8B68, + FLOAT_MAT4x2: 0x8B69, + FLOAT_MAT4x3: 0x8B6A, + SRGB: 0x8C40, + SRGB8: 0x8C41, + SRGB8_ALPHA8: 0x8C43, + COMPARE_REF_TO_TEXTURE: 0x884E, + RGBA32F: 0x8814, + RGB32F: 0x8815, + RGBA16F: 0x881A, + RGB16F: 0x881B, + VERTEX_ATTRIB_ARRAY_INTEGER: 0x88FD, + MAX_ARRAY_TEXTURE_LAYERS: 0x88FF, + MIN_PROGRAM_TEXEL_OFFSET: 0x8904, + MAX_PROGRAM_TEXEL_OFFSET: 0x8905, + MAX_VARYING_COMPONENTS: 0x8B4B, + TEXTURE_2D_ARRAY: 0x8C1A, + TEXTURE_BINDING_2D_ARRAY: 0x8C1D, + R11F_G11F_B10F: 0x8C3A, + UNSIGNED_INT_10F_11F_11F_REV: 0x8C3B, + RGB9_E5: 0x8C3D, + UNSIGNED_INT_5_9_9_9_REV: 0x8C3E, + TRANSFORM_FEEDBACK_BUFFER_MODE: 0x8C7F, + MAX_TRANSFORM_FEEDBACK_SEPARATE_COMPONENTS: 0x8C80, + TRANSFORM_FEEDBACK_VARYINGS: 0x8C83, + TRANSFORM_FEEDBACK_BUFFER_START: 0x8C84, + TRANSFORM_FEEDBACK_BUFFER_SIZE: 0x8C85, + TRANSFORM_FEEDBACK_PRIMITIVES_WRITTEN: 0x8C88, + RASTERIZER_DISCARD: 0x8C89, + MAX_TRANSFORM_FEEDBACK_INTERLEAVED_COMPONENTS: 0x8C8A, + MAX_TRANSFORM_FEEDBACK_SEPARATE_ATTRIBS: 0x8C8B, + INTERLEAVED_ATTRIBS: 0x8C8C, + SEPARATE_ATTRIBS: 0x8C8D, + TRANSFORM_FEEDBACK_BUFFER: 0x8C8E, + TRANSFORM_FEEDBACK_BUFFER_BINDING: 0x8C8F, + RGBA32UI: 0x8D70, + RGB32UI: 0x8D71, + RGBA16UI: 0x8D76, + RGB16UI: 0x8D77, + RGBA8UI: 0x8D7C, + RGB8UI: 0x8D7D, + RGBA32I: 0x8D82, + RGB32I: 0x8D83, + RGBA16I: 0x8D88, + RGB16I: 0x8D89, + RGBA8I: 0x8D8E, + RGB8I: 0x8D8F, + RED_INTEGER: 0x8D94, + RGB_INTEGER: 0x8D98, + RGBA_INTEGER: 0x8D99, + SAMPLER_2D_ARRAY: 0x8DC1, + SAMPLER_2D_ARRAY_SHADOW: 0x8DC4, + SAMPLER_CUBE_SHADOW: 0x8DC5, + UNSIGNED_INT_VEC2: 0x8DC6, + UNSIGNED_INT_VEC3: 0x8DC7, + UNSIGNED_INT_VEC4: 0x8DC8, + INT_SAMPLER_2D: 0x8DCA, + INT_SAMPLER_3D: 0x8DCB, + INT_SAMPLER_CUBE: 0x8DCC, + INT_SAMPLER_2D_ARRAY: 0x8DCF, + UNSIGNED_INT_SAMPLER_2D: 0x8DD2, + UNSIGNED_INT_SAMPLER_3D: 0x8DD3, + UNSIGNED_INT_SAMPLER_CUBE: 0x8DD4, + UNSIGNED_INT_SAMPLER_2D_ARRAY: 0x8DD7, + DEPTH_COMPONENT32F: 0x8CAC, + DEPTH32F_STENCIL8: 0x8CAD, + FLOAT_32_UNSIGNED_INT_24_8_REV: 0x8DAD, + FRAMEBUFFER_ATTACHMENT_COLOR_ENCODING: 0x8210, + FRAMEBUFFER_ATTACHMENT_COMPONENT_TYPE: 0x8211, + FRAMEBUFFER_ATTACHMENT_RED_SIZE: 0x8212, + FRAMEBUFFER_ATTACHMENT_GREEN_SIZE: 0x8213, + FRAMEBUFFER_ATTACHMENT_BLUE_SIZE: 0x8214, + FRAMEBUFFER_ATTACHMENT_ALPHA_SIZE: 0x8215, + FRAMEBUFFER_ATTACHMENT_DEPTH_SIZE: 0x8216, + FRAMEBUFFER_ATTACHMENT_STENCIL_SIZE: 0x8217, + FRAMEBUFFER_DEFAULT: 0x8218, + UNSIGNED_INT_24_8: 0x84FA, + DEPTH24_STENCIL8: 0x88F0, + UNSIGNED_NORMALIZED: 0x8C17, + DRAW_FRAMEBUFFER_BINDING: 0x8CA6, + READ_FRAMEBUFFER: 0x8CA8, + DRAW_FRAMEBUFFER: 0x8CA9, + READ_FRAMEBUFFER_BINDING: 0x8CAA, + RENDERBUFFER_SAMPLES: 0x8CAB, + FRAMEBUFFER_ATTACHMENT_TEXTURE_LAYER: 0x8CD4, + MAX_COLOR_ATTACHMENTS: 0x8CDF, + COLOR_ATTACHMENT1: 0x8CE1, + COLOR_ATTACHMENT2: 0x8CE2, + COLOR_ATTACHMENT3: 0x8CE3, + COLOR_ATTACHMENT4: 0x8CE4, + COLOR_ATTACHMENT5: 0x8CE5, + COLOR_ATTACHMENT6: 0x8CE6, + COLOR_ATTACHMENT7: 0x8CE7, + COLOR_ATTACHMENT8: 0x8CE8, + COLOR_ATTACHMENT9: 0x8CE9, + COLOR_ATTACHMENT10: 0x8CEA, + COLOR_ATTACHMENT11: 0x8CEB, + COLOR_ATTACHMENT12: 0x8CEC, + COLOR_ATTACHMENT13: 0x8CED, + COLOR_ATTACHMENT14: 0x8CEE, + COLOR_ATTACHMENT15: 0x8CEF, + FRAMEBUFFER_INCOMPLETE_MULTISAMPLE: 0x8D56, + MAX_SAMPLES: 0x8D57, + HALF_FLOAT: 0x140B, + RG: 0x8227, + RG_INTEGER: 0x8228, + R8: 0x8229, + RG8: 0x822B, + R16F: 0x822D, + R32F: 0x822E, + RG16F: 0x822F, + RG32F: 0x8230, + R8I: 0x8231, + R8UI: 0x8232, + R16I: 0x8233, + R16UI: 0x8234, + R32I: 0x8235, + R32UI: 0x8236, + RG8I: 0x8237, + RG8UI: 0x8238, + RG16I: 0x8239, + RG16UI: 0x823A, + RG32I: 0x823B, + RG32UI: 0x823C, + VERTEX_ARRAY_BINDING: 0x85B5, + R8_SNORM: 0x8F94, + RG8_SNORM: 0x8F95, + RGB8_SNORM: 0x8F96, + RGBA8_SNORM: 0x8F97, + SIGNED_NORMALIZED: 0x8F9C, + COPY_READ_BUFFER: 0x8F36, + COPY_WRITE_BUFFER: 0x8F37, + COPY_READ_BUFFER_BINDING: 0x8F36, + COPY_WRITE_BUFFER_BINDING: 0x8F37, + UNIFORM_BUFFER: 0x8A11, + UNIFORM_BUFFER_BINDING: 0x8A28, + UNIFORM_BUFFER_START: 0x8A29, + UNIFORM_BUFFER_SIZE: 0x8A2A, + MAX_VERTEX_UNIFORM_BLOCKS: 0x8A2B, + MAX_FRAGMENT_UNIFORM_BLOCKS: 0x8A2D, + MAX_COMBINED_UNIFORM_BLOCKS: 0x8A2E, + MAX_UNIFORM_BUFFER_BINDINGS: 0x8A2F, + MAX_UNIFORM_BLOCK_SIZE: 0x8A30, + MAX_COMBINED_VERTEX_UNIFORM_COMPONENTS: 0x8A31, + MAX_COMBINED_FRAGMENT_UNIFORM_COMPONENTS: 0x8A33, + UNIFORM_BUFFER_OFFSET_ALIGNMENT: 0x8A34, + ACTIVE_UNIFORM_BLOCKS: 0x8A36, + UNIFORM_TYPE: 0x8A37, + UNIFORM_SIZE: 0x8A38, + UNIFORM_BLOCK_INDEX: 0x8A3A, + UNIFORM_OFFSET: 0x8A3B, + UNIFORM_ARRAY_STRIDE: 0x8A3C, + UNIFORM_MATRIX_STRIDE: 0x8A3D, + UNIFORM_IS_ROW_MAJOR: 0x8A3E, + UNIFORM_BLOCK_BINDING: 0x8A3F, + UNIFORM_BLOCK_DATA_SIZE: 0x8A40, + UNIFORM_BLOCK_ACTIVE_UNIFORMS: 0x8A42, + UNIFORM_BLOCK_ACTIVE_UNIFORM_INDICES: 0x8A43, + UNIFORM_BLOCK_REFERENCED_BY_VERTEX_SHADER: 0x8A44, + UNIFORM_BLOCK_REFERENCED_BY_FRAGMENT_SHADER: 0x8A46, + INVALID_INDEX: 0xFFFFFFFF, + MAX_VERTEX_OUTPUT_COMPONENTS: 0x9122, + MAX_FRAGMENT_INPUT_COMPONENTS: 0x9125, + MAX_SERVER_WAIT_TIMEOUT: 0x9111, + OBJECT_TYPE: 0x9112, + SYNC_CONDITION: 0x9113, + SYNC_STATUS: 0x9114, + SYNC_FLAGS: 0x9115, + SYNC_FENCE: 0x9116, + SYNC_GPU_COMMANDS_COMPLETE: 0x9117, + UNSIGNALED: 0x9118, + SIGNALED: 0x9119, + ALREADY_SIGNALED: 0x911A, + TIMEOUT_EXPIRED: 0x911B, + CONDITION_SATISFIED: 0x911C, + WAIT_FAILED: 0x911D, + SYNC_FLUSH_COMMANDS_BIT: 0x00000001, + VERTEX_ATTRIB_ARRAY_DIVISOR: 0x88FE, + ANY_SAMPLES_PASSED: 0x8C2F, + ANY_SAMPLES_PASSED_CONSERVATIVE: 0x8D6A, + SAMPLER_BINDING: 0x8919, + RGB10_A2UI: 0x906F, + INT_2_10_10_10_REV: 0x8D9F, + TRANSFORM_FEEDBACK: 0x8E22, + TRANSFORM_FEEDBACK_PAUSED: 0x8E23, + TRANSFORM_FEEDBACK_ACTIVE: 0x8E24, + TRANSFORM_FEEDBACK_BINDING: 0x8E25, + TEXTURE_IMMUTABLE_FORMAT: 0x912F, + MAX_ELEMENT_INDEX: 0x8D6B, + TEXTURE_IMMUTABLE_LEVELS: 0x82DF, + TIMEOUT_IGNORED: -1, + MAX_CLIENT_WAIT_TIMEOUT_WEBGL: 0x9247, copyBufferSubData: function (...args) { - console.warn("webgl.copyBufferSubData interface mocked in the Previewer. How this interface works on the" + + console.warn("WebGL2RenderingContext.copyBufferSubData interface mocked in the Previewer. How this interface works on the" + " Previewer may be different from that on a real device.") }, getBufferSubData: function (...args) { - console.warn("webgl.getBufferSubData interface mocked in the Previewer. How this interface works on the" + + console.warn("WebGL2RenderingContext.getBufferSubData interface mocked in the Previewer. How this interface works on the" + " Previewer may be different from that on a real device.") }, blitFramebuffer: function (...args) { - console.warn("webgl.blitFramebuffer interface mocked in the Previewer. How this interface works on the" + + console.warn("WebGL2RenderingContext.blitFramebuffer interface mocked in the Previewer. How this interface works on the" + " Previewer may be different from that on a real device.") }, framebufferTextureLayer: function (...args) { - console.warn("webgl.framebufferTextureLayer interface mocked in the Previewer. How this interface works on the" + + console.warn("WebGL2RenderingContext.framebufferTextureLayer interface mocked in the Previewer. How this interface works on the" + " Previewer may be different from that on a real device.") }, invalidateFramebuffer: function (...args) { - console.warn("webgl.invalidateFramebuffer interface mocked in the Previewer. How this interface works on the" + + console.warn("WebGL2RenderingContext.invalidateFramebuffer interface mocked in the Previewer. How this interface works on the" + " Previewer may be different from that on a real device.") }, invalidateSubFramebuffer: function (...args) { - console.warn("webgl.invalidateFramebuffer interface mocked in the Previewer. How this interface works on the" + + console.warn("WebGL2RenderingContext.invalidateFramebuffer interface mocked in the Previewer. How this interface works on the" + " Previewer may be different from that on a real device.") }, readBuffer: function (...args) { - console.warn("webgl.readBuffer interface mocked in the Previewer. How this interface works on the" + + console.warn("WebGL2RenderingContext.readBuffer interface mocked in the Previewer. How this interface works on the" + " Previewer may be different from that on a real device.") }, getInternalformatParameter: function (...args) { - console.warn("webgl.getInternalformatParameter interface mocked in the Previewer. How this interface works on the" + + console.warn("WebGL2RenderingContext.getInternalformatParameter interface mocked in the Previewer. How this interface works on the" + " Previewer may be different from that on a real device.") if (args[2] == GL_SAMPLES) { return glParamMock.int32Array } }, renderbufferStorageMultisample: function (...args) { - console.warn("webgl.renderbufferStorageMultisample interface mocked in the Previewer. How this interface works on the" + + console.warn("WebGL2RenderingContext.renderbufferStorageMultisample interface mocked in the Previewer. How this interface works on the" + " Previewer may be different from that on a real device.") }, texStorage2D: function (...args) { - console.warn("webgl.texStorage2D interface mocked in the Previewer. How this interface works on the" + + console.warn("WebGL2RenderingContext.texStorage2D interface mocked in the Previewer. How this interface works on the" + " Previewer may be different from that on a real device.") }, texStorage3D: function (...args) { - console.warn("webgl.texStorage3D interface mocked in the Previewer. How this interface works on the" + + console.warn("WebGL2RenderingContext.texStorage3D interface mocked in the Previewer. How this interface works on the" + " Previewer may be different from that on a real device.") }, texImage3D: function (...args) { - console.warn("webgl.texImage3D interface mocked in the Previewer. How this interface works on the" + + console.warn("WebGL2RenderingContext.texImage3D interface mocked in the Previewer. How this interface works on the" + " Previewer may be different from that on a real device.") }, texSubImage3D: function (...args) { - console.warn("webgl.texSubImage3D interface mocked in the Previewer. How this interface works on the" + + console.warn("WebGL2RenderingContext.texSubImage3D interface mocked in the Previewer. How this interface works on the" + " Previewer may be different from that on a real device.") }, copyTexSubImage3D: function (...args) { - console.warn("webgl.copyTexSubImage3D interface mocked in the Previewer. How this interface works on the" + + console.warn("WebGL2RenderingContext.copyTexSubImage3D interface mocked in the Previewer. How this interface works on the" + " Previewer may be different from that on a real device.") }, compressedTexImage3D: function (...args) { - console.warn("webgl.compressedTexImage3D interface mocked in the Previewer. How this interface works on the" + + console.warn("WebGL2RenderingContext.compressedTexImage3D interface mocked in the Previewer. How this interface works on the" + " Previewer may be different from that on a real device.") }, compressedTexSubImage3D: function (...args) { - console.warn("webgl.compressedTexSubImage3D interface mocked in the Previewer. How this interface works on the" + + console.warn("WebGL2RenderingContext.compressedTexSubImage3D interface mocked in the Previewer. How this interface works on the" + " Previewer may be different from that on a real device.") }, getFragDataLocation: function (...args) { - console.warn("webgl.getFragDataLocation interface mocked in the Previewer. How this interface works on the" + + console.warn("WebGL2RenderingContext.getFragDataLocation interface mocked in the Previewer. How this interface works on the" + " Previewer may be different from that on a real device.") return paramMock.paramNumberMock; }, uniform1ui: function (...args) { - console.warn("webgl.uniform1ui interface mocked in the Previewer. How this interface works on the" + + console.warn("WebGL2RenderingContext.uniform1ui interface mocked in the Previewer. How this interface works on the" + " Previewer may be different from that on a real device.") }, uniform2ui: function (...args) { - console.warn("webgl.uniform2ui interface mocked in the Previewer. How this interface works on the" + + console.warn("WebGL2RenderingContext.uniform2ui interface mocked in the Previewer. How this interface works on the" + " Previewer may be different from that on a real device.") }, uniform3ui: function (...args) { - console.warn("webgl.uniform3ui interface mocked in the Previewer. How this interface works on the" + + console.warn("WebGL2RenderingContext.uniform3ui interface mocked in the Previewer. How this interface works on the" + " Previewer may be different from that on a real device.") }, uniform4ui: function (...args) { - console.warn("webgl.uniform4ui interface mocked in the Previewer. How this interface works on the" + + console.warn("WebGL2RenderingContext.uniform4ui interface mocked in the Previewer. How this interface works on the" + " Previewer may be different from that on a real device.") }, uniform1uiv: function (...args) { - console.warn("webgl.uniform1uiv interface mocked in the Previewer. How this interface works on the" + + console.warn("WebGL2RenderingContext.uniform1uiv interface mocked in the Previewer. How this interface works on the" + " Previewer may be different from that on a real device.") }, uniform2uiv: function (...args) { - console.warn("webgl.uniform2uiv interface mocked in the Previewer. How this interface works on the" + + console.warn("WebGL2RenderingContext.uniform2uiv interface mocked in the Previewer. How this interface works on the" + " Previewer may be different from that on a real device.") }, uniform3uiv: function (...args) { - console.warn("webgl.uniform3uiv interface mocked in the Previewer. How this interface works on the" + + console.warn("WebGL2RenderingContext.uniform3uiv interface mocked in the Previewer. How this interface works on the" + " Previewer may be different from that on a real device.") }, uniform4uiv: function (...args) { - console.warn("webgl.uniform4uiv interface mocked in the Previewer. How this interface works on the" + + console.warn("WebGL2RenderingContext.uniform4uiv interface mocked in the Previewer. How this interface works on the" + " Previewer may be different from that on a real device.") }, uniformMatrix3x2fv: function (...args) { - console.warn("webgl.uniformMatrix3x2fv interface mocked in the Previewer. How this interface works on the" + + console.warn("WebGL2RenderingContext.uniformMatrix3x2fv interface mocked in the Previewer. How this interface works on the" + " Previewer may be different from that on a real device.") }, uniformMatrix4x2fv: function (...args) { - console.warn("webgl.uniformMatrix4x2fv interface mocked in the Previewer. How this interface works on the" + + console.warn("WebGL2RenderingContext.uniformMatrix4x2fv interface mocked in the Previewer. How this interface works on the" + " Previewer may be different from that on a real device.") }, uniformMatrix2x3fv: function (...args) { - console.warn("webgl.uniformMatrix2x3fv interface mocked in the Previewer. How this interface works on the" + + console.warn("WebGL2RenderingContext.uniformMatrix2x3fv interface mocked in the Previewer. How this interface works on the" + " Previewer may be different from that on a real device.") }, uniformMatrix4x3fv: function (...args) { - console.warn("webgl.uniformMatrix4x3fv interface mocked in the Previewer. How this interface works on the" + + console.warn("WebGL2RenderingContext.uniformMatrix4x3fv interface mocked in the Previewer. How this interface works on the" + " Previewer may be different from that on a real device.") }, uniformMatrix2x4fv: function (...args) { - console.warn("webgl.uniformMatrix2x4fv interface mocked in the Previewer. How this interface works on the" + + console.warn("WebGL2RenderingContext.uniformMatrix2x4fv interface mocked in the Previewer. How this interface works on the" + " Previewer may be different from that on a real device.") }, uniformMatrix3x4fv: function (...args) { - console.warn("webgl.uniformMatrix3x4fv interface mocked in the Previewer. How this interface works on the" + + console.warn("WebGL2RenderingContext.uniformMatrix3x4fv interface mocked in the Previewer. How this interface works on the" + " Previewer may be different from that on a real device.") }, vertexAttribI4i: function (...args) { - console.warn("webgl.vertexAttribI4i interface mocked in the Previewer. How this interface works on the" + + console.warn("WebGL2RenderingContext.vertexAttribI4i interface mocked in the Previewer. How this interface works on the" + " Previewer may be different from that on a real device.") }, vertexAttribI4iv: function (...args) { - console.warn("webgl.vertexAttribI4iv interface mocked in the Previewer. How this interface works on the" + + console.warn("WebGL2RenderingContext.vertexAttribI4iv interface mocked in the Previewer. How this interface works on the" + " Previewer may be different from that on a real device.") }, vertexAttribI4ui: function (...args) { - console.warn("webgl.vertexAttribI4ui interface mocked in the Previewer. How this interface works on the" + + console.warn("WebGL2RenderingContext.vertexAttribI4ui interface mocked in the Previewer. How this interface works on the" + " Previewer may be different from that on a real device.") }, vertexAttribI4uiv: function (...args) { - console.warn("webgl.vertexAttribI4uiv interface mocked in the Previewer. How this interface works on the" + + console.warn("WebGL2RenderingContext.vertexAttribI4uiv interface mocked in the Previewer. How this interface works on the" + " Previewer may be different from that on a real device.") }, vertexAttribIPointer: function (...args) { - console.warn("webgl.vertexAttribIPointer interface mocked in the Previewer. How this interface works on the" + + console.warn("WebGL2RenderingContext.vertexAttribIPointer interface mocked in the Previewer. How this interface works on the" + " Previewer may be different from that on a real device.") }, vertexAttribDivisor: function (...args) { - console.warn("webgl.vertexAttribDivisor interface mocked in the Previewer. How this interface works on the" + + console.warn("WebGL2RenderingContext.vertexAttribDivisor interface mocked in the Previewer. How this interface works on the" + " Previewer may be different from that on a real device.") }, drawArraysInstanced: function (...args) { - console.warn("webgl.drawArraysInstanced interface mocked in the Previewer. How this interface works on the" + + console.warn("WebGL2RenderingContext.drawArraysInstanced interface mocked in the Previewer. How this interface works on the" + " Previewer may be different from that on a real device.") }, drawElementsInstanced: function (...args) { - console.warn("webgl.drawElementsInstanced interface mocked in the Previewer. How this interface works on the" + + console.warn("WebGL2RenderingContext.drawElementsInstanced interface mocked in the Previewer. How this interface works on the" + " Previewer may be different from that on a real device.") }, drawRangeElements: function (...args) { - console.warn("webgl.drawRangeElements interface mocked in the Previewer. How this interface works on the" + + console.warn("WebGL2RenderingContext.drawRangeElements interface mocked in the Previewer. How this interface works on the" + " Previewer may be different from that on a real device.") }, drawBuffers: function (...args) { - console.warn("webgl.drawBuffers interface mocked in the Previewer. How this interface works on the" + + console.warn("WebGL2RenderingContext.drawBuffers interface mocked in the Previewer. How this interface works on the" + " Previewer may be different from that on a real device.") }, clearBufferfv: function (...args) { - console.warn("webgl.clearBufferfv interface mocked in the Previewer. How this interface works on the" + + console.warn("WebGL2RenderingContext.clearBufferfv interface mocked in the Previewer. How this interface works on the" + " Previewer may be different from that on a real device.") }, clearBufferiv: function (...args) { - console.warn("webgl.clearBufferiv interface mocked in the Previewer. How this interface works on the" + + console.warn("WebGL2RenderingContext.clearBufferiv interface mocked in the Previewer. How this interface works on the" + " Previewer may be different from that on a real device.") }, clearBufferuiv: function (...args) { - console.warn("webgl.clearBufferuiv interface mocked in the Previewer. How this interface works on the" + + console.warn("WebGL2RenderingContext.clearBufferuiv interface mocked in the Previewer. How this interface works on the" + " Previewer may be different from that on a real device.") }, clearBufferfi: function (...args) { - console.warn("webgl.clearBufferfi interface mocked in the Previewer. How this interface works on the" + + console.warn("WebGL2RenderingContext.clearBufferfi interface mocked in the Previewer. How this interface works on the" + " Previewer may be different from that on a real device.") }, createQuery: function (...args) { - console.warn("webgl.createQuery interface mocked in the Previewer. How this interface works on the" + + console.warn("WebGL2RenderingContext.createQuery interface mocked in the Previewer. How this interface works on the" + " Previewer may be different from that on a real device.") return WebGLQuery; }, deleteQuery: function (...args) { - console.warn("webgl.deleteQuery interface mocked in the Previewer. How this interface works on the" + + console.warn("WebGL2RenderingContext.deleteQuery interface mocked in the Previewer. How this interface works on the" + " Previewer may be different from that on a real device.") }, isQuery: function (...args) { - console.warn("webgl.isQuery interface mocked in the Previewer. How this interface works on the" + + console.warn("WebGL2RenderingContext.isQuery interface mocked in the Previewer. How this interface works on the" + " Previewer may be different from that on a real device.") return paramMock.paramBooleanMock; }, beginQuery: function (...args) { - console.warn("webgl.beginQuery interface mocked in the Previewer. How this interface works on the" + + console.warn("WebGL2RenderingContext.beginQuery interface mocked in the Previewer. How this interface works on the" + " Previewer may be different from that on a real device.") }, endQuery: function (...args) { - console.warn("webgl.endQuery interface mocked in the Previewer. How this interface works on the" + + console.warn("WebGL2RenderingContext.endQuery interface mocked in the Previewer. How this interface works on the" + " Previewer may be different from that on a real device.") }, getQuery: function (...args) { - console.warn("webgl2.getQuery interface mocked in the Previewer. How this interface works on the" + + console.warn("WebGL2RenderingContext.getQuery interface mocked in the Previewer. How this interface works on the" + " Previewer may be different from that on a real device.") return WebGLQuery; }, getQueryParameter: function (...args) { - console.warn("webgl2.getQueryParameter interface mocked in the Previewer. How this interface works on the" + + console.warn("WebGL2RenderingContext.getQueryParameter interface mocked in the Previewer. How this interface works on the" + " Previewer may be different from that on a real device.") if (args[1] == GL_QUERY_RESULT) { return paramMock.paramNumberMock; @@ -267,34 +526,34 @@ export function mockwebgl2() { } }, createSampler: function (...args) { - console.warn("webgl2.createSampler interface mocked in the Previewer. How this interface works on the" + + console.warn("WebGL2RenderingContext.createSampler interface mocked in the Previewer. How this interface works on the" + " Previewer may be different from that on a real device.") return WebGLSampler; }, deleteSampler: function (...args) { - console.warn("webgl2.deleteSampler interface mocked in the Previewer. How this interface works on the" + + console.warn("WebGL2RenderingContext.deleteSampler interface mocked in the Previewer. How this interface works on the" + " Previewer may be different from that on a real device.") }, isSampler: function (...args) { - console.warn("webgl2.isSampler interface mocked in the Previewer. How this interface works on the" + + console.warn("WebGL2RenderingContext.isSampler interface mocked in the Previewer. How this interface works on the" + " Previewer may be different from that on a real device.") return paramMock.paramBooleanMock; }, bindSampler: function (...args) { - console.warn("webgl2.bindSampler interface mocked in the Previewer. How this interface works on the" + + console.warn("WebGL2RenderingContext.bindSampler interface mocked in the Previewer. How this interface works on the" + " Previewer may be different from that on a real device.") }, samplerParameteri: function (...args) { - console.warn("webgl2.samplerParameteri interface mocked in the Previewer. How this interface works on the" + + console.warn("WebGL2RenderingContext.samplerParameteri interface mocked in the Previewer. How this interface works on the" + " Previewer may be different from that on a real device.") }, samplerParameterf: function (...args) { - console.warn("webgl2.samplerParameterf interface mocked in the Previewer. How this interface works on the" + + console.warn("WebGL2RenderingContext.samplerParameterf interface mocked in the Previewer. How this interface works on the" + " Previewer may be different from that on a real device.") }, getSamplerParameter: function (...args) { - console.warn("webgl2.getSamplerParameter interface mocked in the Previewer. How this interface works on the" + + console.warn("WebGL2RenderingContext.getSamplerParameter interface mocked in the Previewer. How this interface works on the" + " Previewer may be different from that on a real device.") if (args[1] == GL_TEXTURE_MAX_LOD || args[1] == GL_TEXTURE_MIN_LOD) { return glParamMock.paramDoubleMock; @@ -303,209 +562,209 @@ export function mockwebgl2() { } }, fenceSync: function (...args) { - console.warn("webgl2.fenceSync interface mocked in the Previewer. How this interface works on the" + + console.warn("WebGL2RenderingContext.fenceSync interface mocked in the Previewer. How this interface works on the" + " Previewer may be different from that on a real device.") return WebGLSync; }, isSync: function (...args) { - console.warn("webgl2.isSync interface mocked in the Previewer. How this interface works on the" + + console.warn("WebGL2RenderingContext.isSync interface mocked in the Previewer. How this interface works on the" + " Previewer may be different from that on a real device.") return paramMock.paramBooleanMock; }, deleteSync: function (...args) { - console.warn("webgl2.deleteSync interface mocked in the Previewer. How this interface works on the" + + console.warn("WebGL2RenderingContext.deleteSync interface mocked in the Previewer. How this interface works on the" + " Previewer may be different from that on a real device.") }, clientWaitSync: function (...args) { - console.warn("webgl2.clientWaitSync interface mocked in the Previewer. How this interface works on the" + + console.warn("WebGL2RenderingContext.clientWaitSync interface mocked in the Previewer. How this interface works on the" + " Previewer may be different from that on a real device.") return paramMock.paramNumberMock; }, waitSync: function (...args) { - console.warn("webgl2.waitSync interface mocked in the Previewer. How this interface works on the" + + console.warn("WebGL2RenderingContext.waitSync interface mocked in the Previewer. How this interface works on the" + " Previewer may be different from that on a real device.") }, getSyncParameter: function (...args) { - console.warn("webgl2.getSyncParameter interface mocked in the Previewer. How this interface works on the" + + console.warn("WebGL2RenderingContext.getSyncParameter interface mocked in the Previewer. How this interface works on the" + " Previewer may be different from that on a real device.") return glParamMock.paramAnyMock; }, createTransformFeedback: function (...args) { - console.warn("webgl2.createTransformFeedback interface mocked in the Previewer. How this interface works on the" + + console.warn("WebGL2RenderingContext.createTransformFeedback interface mocked in the Previewer. How this interface works on the" + " Previewer may be different from that on a real device.") return WebGLTransformFeedback; }, deleteTransformFeedback: function (...args) { - console.warn("webgl2.deleteTransformFeedback interface mocked in the Previewer. How this interface works on the" + + console.warn("WebGL2RenderingContext.deleteTransformFeedback interface mocked in the Previewer. How this interface works on the" + " Previewer may be different from that on a real device.") }, isTransformFeedback: function (...args) { - console.warn("webgl2.isTransformFeedback interface mocked in the Previewer. How this interface works on the" + + console.warn("WebGL2RenderingContext.isTransformFeedback interface mocked in the Previewer. How this interface works on the" + " Previewer may be different from that on a real device.") return paramMock.paramBooleanMock; }, bindTransformFeedback: function (...args) { - console.warn("webgl2.bindTransformFeedback interface mocked in the Previewer. How this interface works on the" + + console.warn("WebGL2RenderingContext.bindTransformFeedback interface mocked in the Previewer. How this interface works on the" + " Previewer may be different from that on a real device.") }, beginTransformFeedback: function (...args) { - console.warn("webgl2.beginTransformFeedback interface mocked in the Previewer. How this interface works on the" + + console.warn("WebGL2RenderingContext.beginTransformFeedback interface mocked in the Previewer. How this interface works on the" + " Previewer may be different from that on a real device.") }, endTransformFeedback: function (...args) { - console.warn("webgl2.endTransformFeedback interface mocked in the Previewer. How this interface works on the" + + console.warn("WebGL2RenderingContext.endTransformFeedback interface mocked in the Previewer. How this interface works on the" + " Previewer may be different from that on a real device.") }, transformFeedbackVaryings: function (...args) { - console.warn("webgl2.transformFeedbackVaryings interface mocked in the Previewer. How this interface works on the" + + console.warn("WebGL2RenderingContext.transformFeedbackVaryings interface mocked in the Previewer. How this interface works on the" + " Previewer may be different from that on a real device.") }, getTransformFeedbackVarying: function (...args) { - console.warn("webgl2.getTransformFeedbackVarying interface mocked in the Previewer. How this interface works on the" + + console.warn("WebGL2RenderingContext.getTransformFeedbackVarying interface mocked in the Previewer. How this interface works on the" + " Previewer may be different from that on a real device.") return WebGLActiveInfo; }, pauseTransformFeedback: function (...args) { - console.warn("webgl2.pauseTransformFeedback interface mocked in the Previewer. How this interface works on the" + + console.warn("WebGL2RenderingContext.pauseTransformFeedback interface mocked in the Previewer. How this interface works on the" + " Previewer may be different from that on a real device.") }, resumeTransformFeedback: function (...args) { - console.warn("webgl2.resumeTransformFeedback interface mocked in the Previewer. How this interface works on the" + + console.warn("WebGL2RenderingContext.resumeTransformFeedback interface mocked in the Previewer. How this interface works on the" + " Previewer may be different from that on a real device.") }, bindBufferBase: function (...args) { - console.warn("webgl2.bindBufferBase interface mocked in the Previewer. How this interface works on the" + + console.warn("WebGL2RenderingContext.bindBufferBase interface mocked in the Previewer. How this interface works on the" + " Previewer may be different from that on a real device.") }, bindBufferRange: function (...args) { - console.warn("webgl2.bindBufferRange interface mocked in the Previewer. How this interface works on the" + + console.warn("WebGL2RenderingContext.bindBufferRange interface mocked in the Previewer. How this interface works on the" + " Previewer may be different from that on a real device.") }, getIndexedParameter: function (...args) { - console.warn("webgl2.getIndexedParameter interface mocked in the Previewer. How this interface works on the" + + console.warn("WebGL2RenderingContext.getIndexedParameter interface mocked in the Previewer. How this interface works on the" + " Previewer may be different from that on a real device.") return glParamMock.paramAnyMock; }, getUniformIndices: function (...args) { - console.warn("webgl2.getUniformIndices interface mocked in the Previewer. How this interface works on the" + + console.warn("WebGL2RenderingContext.getUniformIndices interface mocked in the Previewer. How this interface works on the" + " Previewer may be different from that on a real device.") return glParamMock.uintArray; }, getActiveUniforms: function (...args) { - console.warn("webgl2.getActiveUniforms interface mocked in the Previewer. How this interface works on the" + + console.warn("WebGL2RenderingContext.getActiveUniforms interface mocked in the Previewer. How this interface works on the" + " Previewer may be different from that on a real device.") return glParamMock.paramAnyMock; }, getUniformBlockIndex: function (...args) { - console.warn("webgl2.getUniformBlockIndex interface mocked in the Previewer. How this interface works on the" + + console.warn("WebGL2RenderingContext.getUniformBlockIndex interface mocked in the Previewer. How this interface works on the" + " Previewer may be different from that on a real device.") return paramMock.paramNumberMock; }, getActiveUniformBlockParameter: function (...args) { - console.warn("webgl2.getActiveUniformBlockParameter interface mocked in the Previewer. How this interface works on the" + + console.warn("WebGL2RenderingContext.getActiveUniformBlockParameter interface mocked in the Previewer. How this interface works on the" + " Previewer may be different from that on a real device.") return glParamMock.paramAnyMock; }, getActiveUniformBlockName: function (...args) { - console.warn("webgl2.getActiveUniformBlockName interface mocked in the Previewer. How this interface works on the" + + console.warn("WebGL2RenderingContext.getActiveUniformBlockName interface mocked in the Previewer. How this interface works on the" + " Previewer may be different from that on a real device.") return paramMock.paramStringMock; }, uniformBlockBinding: function (...args) { - console.warn("webgl2.uniformBlockBinding interface mocked in the Previewer. How this interface works on the" + + console.warn("WebGL2RenderingContext.uniformBlockBinding interface mocked in the Previewer. How this interface works on the" + " Previewer may be different from that on a real device.") }, createVertexArray: function (...args) { - console.warn("webgl2.createVertexArray interface mocked in the Previewer. How this interface works on the" + + console.warn("WebGL2RenderingContext.createVertexArray interface mocked in the Previewer. How this interface works on the" + " Previewer may be different from that on a real device.") return WebGLVertexArrayObject; }, deleteVertexArray: function (...args) { - console.warn("webgl2.deleteVertexArray interface mocked in the Previewer. How this interface works on the" + + console.warn("WebGL2RenderingContext.deleteVertexArray interface mocked in the Previewer. How this interface works on the" + " Previewer may be different from that on a real device.") }, isVertexArray: function (...args) { - console.warn("webgl2.isVertexArray interface mocked in the Previewer. How this interface works on the" + + console.warn("WebGL2RenderingContext.isVertexArray interface mocked in the Previewer. How this interface works on the" + " Previewer may be different from that on a real device.") return paramMock.paramBooleanMock; }, bindVertexArray: function (...args) { - console.warn("webgl2.bindVertexArray interface mocked in the Previewer. How this interface works on the" + + console.warn("WebGL2RenderingContext.bindVertexArray interface mocked in the Previewer. How this interface works on the" + " Previewer may be different from that on a real device.") }, bufferData: function (...args) { - console.warn("webgl2.bufferData interface mocked in the Previewer. How this interface works on the" + + console.warn("WebGL2RenderingContext.bufferData interface mocked in the Previewer. How this interface works on the" + " Previewer may be different from that on a real device.") }, bufferSubData: function (...args) { - console.warn("webgl2.bufferSubData interface mocked in the Previewer. How this interface works on the" + + console.warn("WebGL2RenderingContext.bufferSubData interface mocked in the Previewer. How this interface works on the" + " Previewer may be different from that on a real device.") }, texImage2D: function (...args) { - console.warn("webgl2.texImage2D interface mocked in the Previewer. How this interface works on the" + + console.warn("WebGL2RenderingContext.texImage2D interface mocked in the Previewer. How this interface works on the" + " Previewer may be different from that on a real device.") }, texSubImage2D: function (...args) { - console.warn("webgl2.texSubImage2D interface mocked in the Previewer. How this interface works on the" + + console.warn("WebGL2RenderingContext.texSubImage2D interface mocked in the Previewer. How this interface works on the" + " Previewer may be different from that on a real device.") }, compressedTexImage2D: function (...args) { - console.warn("webgl2.compressedTexImage2D interface mocked in the Previewer. How this interface works on the" + + console.warn("WebGL2RenderingContext.compressedTexImage2D interface mocked in the Previewer. How this interface works on the" + " Previewer may be different from that on a real device.") }, compressedTexSubImage2D: function (...args) { - console.warn("webgl2.compressedTexSubImage2D interface mocked in the Previewer. How this interface works on the" + + console.warn("WebGL2RenderingContext.compressedTexSubImage2D interface mocked in the Previewer. How this interface works on the" + " Previewer may be different from that on a real device.") }, uniform1fv: function (...args) { - console.warn("webgl2.uniform1fv interface mocked in the Previewer. How this interface works on the" + + console.warn("WebGL2RenderingContext.uniform1fv interface mocked in the Previewer. How this interface works on the" + " Previewer may be different from that on a real device.") }, uniform2fv: function (...args) { - console.warn("webgl2.uniform2fv interface mocked in the Previewer. How this interface works on the" + + console.warn("WebGL2RenderingContext.uniform2fv interface mocked in the Previewer. How this interface works on the" + " Previewer may be different from that on a real device.") }, uniform3fv: function (...args) { - console.warn("webgl2.uniform3fv interface mocked in the Previewer. How this interface works on the" + + console.warn("WebGL2RenderingContext.uniform3fv interface mocked in the Previewer. How this interface works on the" + " Previewer may be different from that on a real device.") }, uniform4fv: function (...args) { - console.warn("webgl2.uniform4fv interface mocked in the Previewer. How this interface works on the" + + console.warn("WebGL2RenderingContext.uniform4fv interface mocked in the Previewer. How this interface works on the" + " Previewer may be different from that on a real device.") }, uniform1iv: function (...args) { - console.warn("webgl2.uniform1iv interface mocked in the Previewer. How this interface works on the" + + console.warn("WebGL2RenderingContext.uniform1iv interface mocked in the Previewer. How this interface works on the" + " Previewer may be different from that on a real device.") }, uniform2iv: function (...args) { - console.warn("webgl2.uniform2iv interface mocked in the Previewer. How this interface works on the" + + console.warn("WebGL2RenderingContext.uniform2iv interface mocked in the Previewer. How this interface works on the" + " Previewer may be different from that on a real device.") }, uniform3iv: function (...args) { - console.warn("webgl2.uniform3iv interface mocked in the Previewer. How this interface works on the" + + console.warn("WebGL2RenderingContext.uniform3iv interface mocked in the Previewer. How this interface works on the" + " Previewer may be different from that on a real device.") }, uniform4iv: function (...args) { - console.warn("webgl2.uniform4iv interface mocked in the Previewer. How this interface works on the" + + console.warn("WebGL2RenderingContext.uniform4iv interface mocked in the Previewer. How this interface works on the" + " Previewer may be different from that on a real device.") }, uniformMatrix2fv: function (...args) { - console.warn("webgl2.uniformMatrix2fv interface mocked in the Previewer. How this interface works on the" + + console.warn("WebGL2RenderingContext.uniformMatrix2fv interface mocked in the Previewer. How this interface works on the" + " Previewer may be different from that on a real device.") }, uniformMatrix3fv: function (...args) { - console.warn("webgl2.uniformMatrix3fv interface mocked in the Previewer. How this interface works on the" + + console.warn("WebGL2RenderingContext.uniformMatrix3fv interface mocked in the Previewer. How this interface works on the" + " Previewer may be different from that on a real device.") }, uniformMatrix4fv: function (...args) { - console.warn("webgl2.uniformMatrix4fv interface mocked in the Previewer. How this interface works on the" + + console.warn("WebGL2RenderingContext.uniformMatrix4fv interface mocked in the Previewer. How this interface works on the" + " Previewer may be different from that on a real device.") }, readPixels: function (...args) { - console.warn("webgl2.readPixels interface mocked in the Previewer. How this interface works on the" + + console.warn("WebGL2RenderingContext.readPixels interface mocked in the Previewer. How this interface works on the" + " Previewer may be different from that on a real device.") } } - return webgl2Mock; + return WebGL2RenderingContext; } \ No newline at end of file