mirror of
https://github.com/openharmony/third_party_jsframework.git
synced 2026-07-18 12:35:31 -04:00
@@ -0,0 +1,253 @@
|
||||
/*
|
||||
* Copyright (c) 2022 Huawei Device Co., Ltd.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
import { FormBindingData } from "../../ohos_application_formBindingData"
|
||||
import { FormState } from "../../ohos_application_formInfo"
|
||||
import { paramMock } from "../../../utils"
|
||||
import { RemoteObjectClass } from "../../ohos_rpc"
|
||||
import { ResultSet, PacMapType } from "../../ohos_ability_featureAbility"
|
||||
|
||||
const DataAbilityResult = {
|
||||
uri: "[PC Preview] unknow uri",
|
||||
count: "[PC Preview] unknow count",
|
||||
}
|
||||
export const LifecycleForm = {
|
||||
onCreate: function (...args) {
|
||||
console.warn("LifecycleForm.onCreate interface mocked in the Previewer. How this interface works on the Previewer may" +
|
||||
" be different from that on a real device.")
|
||||
return FormBindingData;
|
||||
},
|
||||
onCastToNormal: function (...args) {
|
||||
console.warn("LifecycleForm.onCastToNormal interface mocked in the Previewer. How this interface works on the Previewer may" +
|
||||
" be different from that on a real device.")
|
||||
},
|
||||
onUpdate: function (...args) {
|
||||
console.warn("LifecycleForm.onUpdate interface mocked in the Previewer. How this interface works on the Previewer may" +
|
||||
" be different from that on a real device.")
|
||||
},
|
||||
onVisibilityChange: function (...args) {
|
||||
console.warn("LifecycleForm.onVisibilityChange interface mocked in the Previewer. How this interface works on the Previewer may" +
|
||||
" be different from that on a real device.")
|
||||
},
|
||||
onEvent: function (...args) {
|
||||
console.warn("LifecycleForm.onEvent interface mocked in the Previewer. How this interface works on the Previewer may" +
|
||||
" be different from that on a real device.")
|
||||
},
|
||||
onDestroy: function (...args) {
|
||||
console.warn("LifecycleForm.onDestroy interface mocked in the Previewer. How this interface works on the Previewer may" +
|
||||
" be different from that on a real device.")
|
||||
},
|
||||
onAcquireFormState: function (...args) {
|
||||
console.warn("LifecycleForm.onAcquireFormState interface mocked in the Previewer. How this interface works on the Previewer may" +
|
||||
" be different from that on a real device.")
|
||||
return FormState;
|
||||
},
|
||||
}
|
||||
export const LifecycleApp = {
|
||||
onShow: function () {
|
||||
console.warn("LifecycleApp.onShow interface mocked in the Previewer. How this interface works on the Previewer may" +
|
||||
" be different from that on a real device.")
|
||||
},
|
||||
onHide: function () {
|
||||
console.warn("LifecycleApp.onHide interface mocked in the Previewer. How this interface works on the Previewer may" +
|
||||
" be different from that on a real device.")
|
||||
},
|
||||
onDestroy: function () {
|
||||
console.warn("LifecycleApp.onDestroy interface mocked in the Previewer. How this interface works on the Previewer may" +
|
||||
" be different from that on a real device.")
|
||||
},
|
||||
onCreate: function () {
|
||||
console.warn("LifecycleApp.onCreate interface mocked in the Previewer. How this interface works on the Previewer may" +
|
||||
" be different from that on a real device.")
|
||||
},
|
||||
onWindowDisplayModeChanged: function (...args) {
|
||||
console.warn("LifecycleApp.onWindowDisplayModeChanged interface mocked in the Previewer. How this interface works on the Previewer may" +
|
||||
" be different from that on a real device.")
|
||||
},
|
||||
onStartContinuation: function () {
|
||||
console.warn("LifecycleApp.onStartContinuation interface mocked in the Previewer. How this interface works on the Previewer may" +
|
||||
" be different from that on a real device.")
|
||||
return paramMock.paramBooleanMock;
|
||||
},
|
||||
onSaveData: function (...args) {
|
||||
console.warn("LifecycleApp.onSaveData interface mocked in the Previewer. How this interface works on the Previewer may" +
|
||||
" be different from that on a real device.")
|
||||
return paramMock.paramBooleanMock;
|
||||
},
|
||||
onCompleteContinuation: function (...args) {
|
||||
console.warn("LifecycleApp.onCompleteContinuation interface mocked in the Previewer. How this interface works on the Previewer may" +
|
||||
" be different from that on a real device.")
|
||||
},
|
||||
onRestoreData: function (...args) {
|
||||
console.warn("LifecycleApp.onRestoreData interface mocked in the Previewer. How this interface works on the Previewer may" +
|
||||
" be different from that on a real device.")
|
||||
},
|
||||
onRemoteTerminated: function () {
|
||||
console.warn("LifecycleApp.onRemoteTerminated interface mocked in the Previewer. How this interface works on the Previewer may" +
|
||||
" be different from that on a real device.")
|
||||
},
|
||||
onSaveAbilityState: function (...args) {
|
||||
console.warn("LifecycleApp.onSaveAbilityState interface mocked in the Previewer. How this interface works on the Previewer may" +
|
||||
" be different from that on a real device.")
|
||||
},
|
||||
onRestoreAbilityState: function (...args) {
|
||||
console.warn("LifecycleApp.onRestoreAbilityState interface mocked in the Previewer. How this interface works on the Previewer may" +
|
||||
" be different from that on a real device.")
|
||||
},
|
||||
onInactive: function () {
|
||||
console.warn("LifecycleApp.onInactive interface mocked in the Previewer. How this interface works on the Previewer may" +
|
||||
" be different from that on a real device.")
|
||||
},
|
||||
onActive: function () {
|
||||
console.warn("LifecycleApp.onActive interface mocked in the Previewer. How this interface works on the Previewer may" +
|
||||
" be different from that on a real device.")
|
||||
},
|
||||
onNewWant: function (...args) {
|
||||
console.warn("LifecycleApp.onNewWant interface mocked in the Previewer. How this interface works on the Previewer may" +
|
||||
" be different from that on a real device.")
|
||||
},
|
||||
onMemoryLevel: function (...args) {
|
||||
console.warn("LifecycleApp.onMemoryLevel interface mocked in the Previewer. How this interface works on the Previewer may" +
|
||||
" be different from that on a real device.")
|
||||
},
|
||||
}
|
||||
export const LifecycleService = {
|
||||
onStart: function () {
|
||||
console.warn("LifecycleService.onStart interface mocked in the Previewer. How this interface works on the Previewer may" +
|
||||
" be different from that on a real device.")
|
||||
},
|
||||
onCommand: function (...args) {
|
||||
console.warn("LifecycleService.onCommand interface mocked in the Previewer. How this interface works on the Previewer may" +
|
||||
" be different from that on a real device.")
|
||||
},
|
||||
onStop: function () {
|
||||
console.warn("LifecycleService.onStop interface mocked in the Previewer. How this interface works on the Previewer may" +
|
||||
" be different from that on a real device.")
|
||||
},
|
||||
onConnect: function (...args) {
|
||||
console.warn("LifecycleService.onConnect interface mocked in the Previewer. How this interface works on the Previewer may" +
|
||||
" be different from that on a real device.")
|
||||
return new RemoteObjectClass();
|
||||
},
|
||||
onDisconnect: function (...args) {
|
||||
console.warn("LifecycleService.onDisconnect interface mocked in the Previewer. How this interface works on the Previewer may" +
|
||||
" be different from that on a real device.")
|
||||
},
|
||||
onReconnect: function (...args) {
|
||||
console.warn("LifecycleService.onReconnect interface mocked in the Previewer. How this interface works on the Previewer may" +
|
||||
" be different from that on a real device.")
|
||||
},
|
||||
}
|
||||
export const LifecycleData = {
|
||||
update: function (...args) {
|
||||
console.warn("LifecycleData.update interface mocked in the Previewer. How this interface works on the Previewer" +
|
||||
" may be different from that on a real device.")
|
||||
const len = args.length
|
||||
if (typeof args[len - 1] === 'function') {
|
||||
args[len - 1].call(this, paramMock.businessErrorMock, paramMock.paramNumberMock);
|
||||
}
|
||||
},
|
||||
query: function (...args) {
|
||||
console.warn("LifecycleData.query interface mocked in the Previewer. How this interface works on the Previewer" +
|
||||
" may be different from that on a real device.")
|
||||
const len = args.length
|
||||
if (typeof args[len - 1] === 'function') {
|
||||
args[len - 1].call(this, paramMock.businessErrorMock, ResultSet);
|
||||
}
|
||||
},
|
||||
delete: function (...args) {
|
||||
console.warn("LifecycleData.delete interface mocked in the Previewer. How this interface works on the Previewer" +
|
||||
" may be different from that on a real device.")
|
||||
const len = args.length
|
||||
if (typeof args[len - 1] === 'function') {
|
||||
args[len - 1].call(this, paramMock.businessErrorMock, paramMock.paramNumberMock);
|
||||
}
|
||||
},
|
||||
normalizeUri: function (...args) {
|
||||
console.warn("LifecycleData.normalizeUri interface mocked in the Previewer. How this interface works on the Previewer" +
|
||||
" may be different from that on a real device.")
|
||||
const len = args.length
|
||||
if (typeof args[len - 1] === 'function') {
|
||||
args[len - 1].call(this, paramMock.businessErrorMock, paramMock.paramStringMock);
|
||||
}
|
||||
},
|
||||
batchInsert: function (...args) {
|
||||
console.warn("LifecycleData.batchInsert interface mocked in the Previewer. How this interface works on the Previewer" +
|
||||
" may be different from that on a real device.")
|
||||
const len = args.length
|
||||
if (typeof args[len - 1] === 'function') {
|
||||
args[len - 1].call(this, paramMock.businessErrorMock, paramMock.paramNumberMock);
|
||||
}
|
||||
},
|
||||
denormalizeUri: function (...args) {
|
||||
console.warn("LifecycleData.denormalizeUri interface mocked in the Previewer. How this interface works on the Previewer" +
|
||||
" may be different from that on a real device.")
|
||||
const len = args.length
|
||||
if (typeof args[len - 1] === 'function') {
|
||||
args[len - 1].call(this, paramMock.businessErrorMock, paramMock.paramStringMock);
|
||||
}
|
||||
},
|
||||
insert: function (...args) {
|
||||
console.warn("LifecycleData.insert interface mocked in the Previewer. How this interface works on the Previewer" +
|
||||
" may be different from that on a real device.")
|
||||
const len = args.length
|
||||
if (typeof args[len - 1] === 'function') {
|
||||
args[len - 1].call(this, paramMock.businessErrorMock, paramMock.paramNumberMock);
|
||||
}
|
||||
},
|
||||
openFile: function (...args) {
|
||||
console.warn("LifecycleData.openFile interface mocked in the Previewer. How this interface works on the Previewer" +
|
||||
" may be different from that on a real device.")
|
||||
const len = args.length
|
||||
if (typeof args[len - 1] === 'function') {
|
||||
args[len - 1].call(this, paramMock.businessErrorMock, paramMock.paramNumberMock);
|
||||
}
|
||||
},
|
||||
getFileTypes: function (...args) {
|
||||
console.warn("LifecycleData.getFileTypes interface mocked in the Previewer. How this interface works on the Previewer" +
|
||||
" may be different from that on a real device.")
|
||||
const len = args.length
|
||||
if (typeof args[len - 1] === 'function') {
|
||||
args[len - 1].call(this, paramMock.businessErrorMock, [paramMock.paramStringMock]);
|
||||
}
|
||||
},
|
||||
onInitialized: function (...args) {
|
||||
console.warn("LifecycleData.onInitialized interface mocked in the Previewer. How this interface works on the Previewer may" +
|
||||
" be different from that on a real device.")
|
||||
},
|
||||
getType: function (...args) {
|
||||
console.warn("LifecycleData.getType interface mocked in the Previewer. How this interface works on the Previewer" +
|
||||
" may be different from that on a real device.")
|
||||
const len = args.length
|
||||
if (typeof args[len - 1] === 'function') {
|
||||
args[len - 1].call(this, paramMock.businessErrorMock, paramMock.paramStringMock);
|
||||
}
|
||||
},
|
||||
executeBatch: function (...args) {
|
||||
console.warn("LifecycleData.executeBatch interface mocked in the Previewer. How this interface works on the Previewer" +
|
||||
" may be different from that on a real device.")
|
||||
const len = args.length
|
||||
if (typeof args[len - 1] === 'function') {
|
||||
args[len - 1].call(this, paramMock.businessErrorMock, [DataAbilityResult]);
|
||||
}
|
||||
},
|
||||
call: function (...args) {
|
||||
console.warn("LifecycleData.call interface mocked in the Previewer. How this interface works on the Previewer" +
|
||||
" may be different from that on a real device.")
|
||||
const len = args.length
|
||||
if (typeof args[len - 1] === 'function') {
|
||||
args[len - 1].call(this, paramMock.businessErrorMock, PacMapType);
|
||||
}
|
||||
},
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
/*
|
||||
* Copyright (c) 2022 Huawei Device Co., Ltd.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
import { WantClass } from "../ohos_application_Want"
|
||||
|
||||
export const AbilityResult = {
|
||||
resultCode: "[PC Preview] unknow resultCode",
|
||||
want: new WantClass(),
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
/*
|
||||
* Copyright (c) 2022 Huawei Device Co., Ltd.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
export const ConnectOptions = {
|
||||
onConnect: function (...args) {
|
||||
console.warn("ConnectOptions.onConnect interface mocked in the Previewer. How this interface works" +
|
||||
" on the Previewer may be different from that on a real device.")
|
||||
},
|
||||
onDisconnect: function (...args) {
|
||||
console.warn("ConnectOptions.onDisconnect interface mocked in the Previewer. How this interface works" +
|
||||
" on the Previewer may be different from that on a real device.")
|
||||
},
|
||||
onFailed: function (...args) {
|
||||
console.warn("ConnectOptions.onFailed interface mocked in the Previewer. How this interface works" +
|
||||
" on the Previewer may be different from that on a real device.")
|
||||
},
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
/*
|
||||
* Copyright (c) 2022 Huawei Device Co., Ltd.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
import { WantClass } from "../ohos_application_Want"
|
||||
|
||||
export const StartAbilityParameter = {
|
||||
want: new WantClass(),
|
||||
abilityStartSetting: {},
|
||||
}
|
||||
@@ -0,0 +1,27 @@
|
||||
/*
|
||||
* Copyright (c) 2022 Huawei Device Co., Ltd.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
import { paramMock } from "../../utils"
|
||||
|
||||
export const Want = {
|
||||
deviceId: "[PC Preview] unknow deviceId",
|
||||
bundleName: "[PC Preview] unknow bundleName",
|
||||
abilityName: "[PC Preview] unknow abilityName",
|
||||
uri: "[PC Preview] unknow uri",
|
||||
type: "[PC Preview] unknow type",
|
||||
flags: "[PC Preview] unknow flags",
|
||||
action: "[PC Preview] unknow action",
|
||||
parameters: {},
|
||||
entities: [paramMock.paramStringMock]
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
/*
|
||||
* Copyright (c) 2022 Huawei Device Co., Ltd.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
export const AppVersionInfo = {
|
||||
appName: "[PC Preview] unknow appName",
|
||||
versionCode: "[PC Preview] unknow versionCode",
|
||||
versionName: "[PC Preview] unknow versionName",
|
||||
}
|
||||
@@ -0,0 +1,317 @@
|
||||
/*
|
||||
* Copyright (c) 2022 Huawei Device Co., Ltd.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
import { paramMock } from "../../utils"
|
||||
import { ProcessInfo } from "./processInfo"
|
||||
import { AppVersionInfo } from "./appVersionInfo"
|
||||
import { AbilityInfo } from "../bundle/abilityInfo"
|
||||
import { ApplicationInfo } from "../bundle/applicationInfo"
|
||||
import { ElementName } from "../bundle/elementName"
|
||||
import { HapModuleInfo } from "../bundle/hapModuleInfo"
|
||||
|
||||
const DisplayOrientation = {
|
||||
UNSPECIFIED: "[PC preview] unknown is UNSPECIFIED",
|
||||
LANDSCAPE: "[PC preview] unknown is LANDSCAPE",
|
||||
PORTRAIT: "[PC preview] unknown is PORTRAIT",
|
||||
FOLLOW_RECENT: "[PC preview] unknown is FOLLOW_RECENT",
|
||||
LANDSCAPE_INVERTED: "[PC preview] unknown is LANDSCAPE_INVERTED",
|
||||
PORTRAIT_INVERTED: "[PC preview] unknown is PORTRAIT_INVERTED",
|
||||
AUTO_ROTATION: "[PC preview] unknown is AUTO_ROTATION",
|
||||
AUTO_ROTATION_LANDSCAPE: "[PC preview] unknown is AUTO_ROTATION_LANDSCAPE",
|
||||
AUTO_ROTATION_PORTRAIT: "[PC preview] unknown is AUTO_ROTATION_PORTRAIT",
|
||||
AUTO_ROTATION_RESTRICTED: "[PC preview] unknown is AUTO_ROTATION_RESTRICTED",
|
||||
AUTO_ROTATION_LANDSCAPE_RESTRICTED: "[PC preview] unknown is AUTO_ROTATION_LANDSCAPE_RESTRICTED",
|
||||
AUTO_ROTATION_PORTRAIT_RESTRICTED: "[PC preview] unknown is AUTO_ROTATION_PORTRAIT_RESTRICTED",
|
||||
LOCKED: "[PC preview] unknown is LOCKED",
|
||||
}
|
||||
export const Context = {
|
||||
getOrCreateLocalDir: function (...args) {
|
||||
console.warn("Context.getOrCreateLocalDir interface mocked in the Previewer." +
|
||||
" How this interface works on the Previewer may be different from that on a real device.")
|
||||
const len = args.length
|
||||
if (len > 0 && typeof args[len - 1] === 'function') {
|
||||
args[len - 1].call(this, paramMock.businessErrorMock, paramMock.paramStringMock);
|
||||
} else {
|
||||
return new Promise((resolve, reject) => {
|
||||
resolve(paramMock.paramStringMock);
|
||||
})
|
||||
}
|
||||
},
|
||||
verifyPermission: function (...args) {
|
||||
console.warn("Context.verifyPermission interface mocked in the Previewer." +
|
||||
" How this interface works on the Previewer may be different from that on a real device.")
|
||||
const len = args.length
|
||||
if (len > 0 && typeof args[len - 1] === 'function') {
|
||||
args[len - 1].call(this, paramMock.businessErrorMock, paramMock.paramNumberMock);
|
||||
} else {
|
||||
return new Promise((resolve, reject) => {
|
||||
resolve(paramMock.paramNumberMock);
|
||||
})
|
||||
}
|
||||
},
|
||||
requestPermissionsFromUser: function (...args) {
|
||||
console.warn("Context.requestPermissionsFromUser interface mocked in the Previewer." +
|
||||
" How this interface works on the Previewer may be different from that on a real device.")
|
||||
const len = args.length
|
||||
if (len > 0 && typeof args[len - 1] === 'function') {
|
||||
args[len - 1].call(this, paramMock.businessErrorMock, PermissionRequestResult);
|
||||
} else {
|
||||
return new Promise((resolve, reject) => {
|
||||
resolve(PermissionRequestResult);
|
||||
})
|
||||
}
|
||||
},
|
||||
getApplicationInfo: function (...args) {
|
||||
console.warn("Context.getApplicationInfo interface mocked in the Previewer." +
|
||||
" How this interface works on the Previewer may be different from that on a real device.")
|
||||
const len = args.length
|
||||
if (len > 0 && typeof args[len - 1] === 'function') {
|
||||
args[len - 1].call(this, paramMock.businessErrorMock, ApplicationInfo);
|
||||
} else {
|
||||
return new Promise((resolve, reject) => {
|
||||
resolve(ApplicationInfo);
|
||||
})
|
||||
}
|
||||
},
|
||||
getBundleName: function (...args) {
|
||||
console.warn("Context.getBundleName interface mocked in the Previewer." +
|
||||
" How this interface works on the Previewer may be different from that on a real device.")
|
||||
const len = args.length
|
||||
if (len > 0 && typeof args[len - 1] === 'function') {
|
||||
args[len - 1].call(this, paramMock.businessErrorMock, paramMock.paramStringMock);
|
||||
} else {
|
||||
return new Promise((resolve, reject) => {
|
||||
resolve(paramMock.paramStringMock);
|
||||
})
|
||||
}
|
||||
},
|
||||
getDisplayOrientation: function (...args) {
|
||||
console.warn("Context.getDisplayOrientation interface mocked in the Previewer." +
|
||||
" How this interface works on the Previewer may be different from that on a real device.")
|
||||
const len = args.length
|
||||
if (len > 0 && typeof args[len - 1] === 'function') {
|
||||
args[len - 1].call(this, paramMock.businessErrorMock, DisplayOrientation);
|
||||
} else {
|
||||
return new Promise((resolve, reject) => {
|
||||
resolve(DisplayOrientation);
|
||||
})
|
||||
}
|
||||
},
|
||||
setDisplayOrientation: function (...args) {
|
||||
console.warn("Context.setDisplayOrientation interface mocked in the Previewer." +
|
||||
" How this interface works on the Previewer may be different from that on a real device.")
|
||||
const len = args.length
|
||||
if (len > 0 && typeof args[len - 1] === 'function') {
|
||||
args[len - 1].call(this, paramMock.businessErrorMock);
|
||||
} else {
|
||||
return new Promise((resolve, reject) => {
|
||||
resolve();
|
||||
})
|
||||
}
|
||||
},
|
||||
setShowOnLockScreen: function (...args) {
|
||||
console.warn("Context.setShowOnLockScreen interface mocked in the Previewer." +
|
||||
" How this interface works on the Previewer may be different from that on a real device.")
|
||||
const len = args.length
|
||||
if (len > 0 && typeof args[len - 1] === 'function') {
|
||||
args[len - 1].call(this, paramMock.businessErrorMock);
|
||||
} else {
|
||||
return new Promise((resolve, reject) => {
|
||||
resolve();
|
||||
})
|
||||
}
|
||||
},
|
||||
setWakeUpScreen: function (...args) {
|
||||
console.warn("Context.setWakeUpScreen interface mocked in the Previewer." +
|
||||
" How this interface works on the Previewer may be different from that on a real device.")
|
||||
const len = args.length
|
||||
if (len > 0 && typeof args[len - 1] === 'function') {
|
||||
args[len - 1].call(this, paramMock.businessErrorMock);
|
||||
} else {
|
||||
return new Promise((resolve, reject) => {
|
||||
resolve();
|
||||
})
|
||||
}
|
||||
},
|
||||
getProcessInfo: function (...args) {
|
||||
console.warn("Context.getProcessInfo interface mocked in the Previewer." +
|
||||
" How this interface works on the Previewer may be different from that on a real device.")
|
||||
const len = args.length
|
||||
if (len > 0 && typeof args[len - 1] === 'function') {
|
||||
args[len - 1].call(this, paramMock.businessErrorMock, ProcessInfo);
|
||||
} else {
|
||||
return new Promise((resolve, reject) => {
|
||||
resolve(ProcessInfo);
|
||||
})
|
||||
}
|
||||
},
|
||||
getElementName: function (...args) {
|
||||
console.warn("Context.getElementName interface mocked in the Previewer." +
|
||||
" How this interface works on the Previewer may be different from that on a real device.")
|
||||
const len = args.length
|
||||
if (len > 0 && typeof args[len - 1] === 'function') {
|
||||
args[len - 1].call(this, paramMock.businessErrorMock, ElementName);
|
||||
} else {
|
||||
return new Promise((resolve, reject) => {
|
||||
resolve(ElementName);
|
||||
})
|
||||
}
|
||||
},
|
||||
getProcessName: function (...args) {
|
||||
console.warn("Context.getProcessName interface mocked in the Previewer." +
|
||||
" How this interface works on the Previewer may be different from that on a real device.")
|
||||
const len = args.length
|
||||
if (len > 0 && typeof args[len - 1] === 'function') {
|
||||
args[len - 1].call(this, paramMock.businessErrorMock, paramMock.paramStringMock);
|
||||
} else {
|
||||
return new Promise((resolve, reject) => {
|
||||
resolve(paramMock.paramStringMock);
|
||||
})
|
||||
}
|
||||
},
|
||||
getCallingBundle: function (...args) {
|
||||
console.warn("Context.getCallingBundle interface mocked in the Previewer." +
|
||||
" How this interface works on the Previewer may be different from that on a real device.")
|
||||
const len = args.length
|
||||
if (len > 0 && typeof args[len - 1] === 'function') {
|
||||
args[len - 1].call(this, paramMock.businessErrorMock, paramMock.paramStringMock);
|
||||
} else {
|
||||
return new Promise((resolve, reject) => {
|
||||
resolve(paramMock.paramStringMock);
|
||||
})
|
||||
}
|
||||
},
|
||||
getFilesDir: function (...args) {
|
||||
console.warn("Context.getFilesDir interface mocked in the Previewer." +
|
||||
" How this interface works on the Previewer may be different from that on a real device.")
|
||||
const len = args.length
|
||||
if (len > 0 && typeof args[len - 1] === 'function') {
|
||||
args[len - 1].call(this, paramMock.businessErrorMock, paramMock.paramStringMock);
|
||||
} else {
|
||||
return new Promise((resolve, reject) => {
|
||||
resolve(paramMock.paramStringMock);
|
||||
})
|
||||
}
|
||||
},
|
||||
getCacheDir: function (...args) {
|
||||
console.warn("Context.getCacheDir interface mocked in the Previewer." +
|
||||
" How this interface works on the Previewer may be different from that on a real device.")
|
||||
const len = args.length
|
||||
if (len > 0 && typeof args[len - 1] === 'function') {
|
||||
args[len - 1].call(this, paramMock.businessErrorMock, paramMock.paramStringMock);
|
||||
} else {
|
||||
return new Promise((resolve, reject) => {
|
||||
resolve(paramMock.paramStringMock);
|
||||
})
|
||||
}
|
||||
},
|
||||
getOrCreateDistributedDir: function (...args) {
|
||||
console.warn("Context.getOrCreateDistributedDir interface mocked in the Previewer." +
|
||||
" How this interface works on the Previewer may be different from that on a real device.")
|
||||
const len = args.length
|
||||
if (len > 0 && typeof args[len - 1] === 'function') {
|
||||
args[len - 1].call(this, paramMock.businessErrorMock, paramMock.paramStringMock);
|
||||
} else {
|
||||
return new Promise((resolve, reject) => {
|
||||
resolve(paramMock.paramStringMock);
|
||||
})
|
||||
}
|
||||
},
|
||||
getAppType: function (...args) {
|
||||
console.warn("Context.getAppType interface mocked in the Previewer." +
|
||||
" How this interface works on the Previewer may be different from that on a real device.")
|
||||
const len = args.length
|
||||
if (len > 0 && typeof args[len - 1] === 'function') {
|
||||
args[len - 1].call(this, paramMock.businessErrorMock, paramMock.paramStringMock);
|
||||
} else {
|
||||
return new Promise((resolve, reject) => {
|
||||
resolve(paramMock.paramStringMock);
|
||||
})
|
||||
}
|
||||
},
|
||||
getHapModuleInfo: function (...args) {
|
||||
console.warn("Context.getHapModuleInfo interface mocked in the Previewer." +
|
||||
" How this interface works on the Previewer may be different from that on a real device.")
|
||||
const len = args.length
|
||||
if (len > 0 && typeof args[len - 1] === 'function') {
|
||||
args[len - 1].call(this, paramMock.businessErrorMock, HapModuleInfo);
|
||||
} else {
|
||||
return new Promise((resolve, reject) => {
|
||||
resolve(HapModuleInfo);
|
||||
})
|
||||
}
|
||||
},
|
||||
getAppVersionInfo: function (...args) {
|
||||
console.warn("Context.getAppVersionInfo interface mocked in the Previewer." +
|
||||
" How this interface works on the Previewer may be different from that on a real device.")
|
||||
const len = args.length
|
||||
if (len > 0 && typeof args[len - 1] === 'function') {
|
||||
args[len - 1].call(this, paramMock.businessErrorMock, AppVersionInfo);
|
||||
} else {
|
||||
return new Promise((resolve, reject) => {
|
||||
resolve(AppVersionInfo);
|
||||
})
|
||||
}
|
||||
},
|
||||
getApplicationContext: function () {
|
||||
console.warn("Context.getApplicationContext interface mocked in the Previewer." +
|
||||
" How this interface works on the Previewer may be different from that on a real device.")
|
||||
return Context;
|
||||
},
|
||||
getAbilityInfo: function (...args) {
|
||||
console.warn("Context.getAbilityInfo interface mocked in the Previewer." +
|
||||
" How this interface works on the Previewer may be different from that on a real device.")
|
||||
const len = args.length
|
||||
if (len > 0 && typeof args[len - 1] === 'function') {
|
||||
args[len - 1].call(this, paramMock.businessErrorMock, AbilityInfo);
|
||||
} else {
|
||||
return new Promise((resolve, reject) => {
|
||||
resolve(AbilityInfo);
|
||||
})
|
||||
}
|
||||
},
|
||||
isUpdatingConfigurations: function (...args) {
|
||||
console.warn("Context.isUpdatingConfigurations interface mocked in the Previewer." +
|
||||
" How this interface works on the Previewer may be different from that on a real device.")
|
||||
const len = args.length
|
||||
if (len > 0 && typeof args[len - 1] === 'function') {
|
||||
args[len - 1].call(this, paramMock.businessErrorMock, paramMock.paramBooleanMock);
|
||||
} else {
|
||||
return new Promise((resolve, reject) => {
|
||||
resolve(paramMock.paramBooleanMock);
|
||||
})
|
||||
}
|
||||
},
|
||||
printDrawnCompleted: function (...args) {
|
||||
console.warn("Context.printDrawnCompleted interface mocked in the Previewer." +
|
||||
" How this interface works on the Previewer may be different from that on a real device.")
|
||||
const len = args.length
|
||||
if (len > 0 && typeof args[len - 1] === 'function') {
|
||||
args[len - 1].call(this, paramMock.businessErrorMock);
|
||||
} else {
|
||||
return new Promise((resolve, reject) => {
|
||||
resolve();
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
export const PermissionRequestResult = {
|
||||
requestCode: "[PC Preview] unknow requestCode",
|
||||
permissions: [paramMock.paramStringMock],
|
||||
authResults: [paramMock.paramNumberMock],
|
||||
}
|
||||
export const PermissionOptions = {
|
||||
pid: "[PC Preview] unknow pid",
|
||||
uid: "[PC Preview] unknow uid",
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
/*
|
||||
* Copyright (c) 2022 Huawei Device Co., Ltd.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
export const ProcessInfo = {
|
||||
pid: "[PC Preview] unknow pid",
|
||||
processName: "[PC Preview] unknow processName",
|
||||
}
|
||||
+68
-29
@@ -16,6 +16,8 @@
|
||||
import { paramMock } from "../../utils"
|
||||
import { MessageParcelClass } from "../ohos_rpc"
|
||||
import { ContextClass } from "../ohos_application_ServiceExtAbility"
|
||||
import { Configuration } from "../ohos_application_Configuration"
|
||||
import { Caller } from "../ohos_application_Ability"
|
||||
|
||||
const ModuleInfoMock = {
|
||||
moduleName: '[PC preview] unknow moduleName',
|
||||
@@ -240,37 +242,10 @@ export const ExtensionContextClass = class ExtensionContext extends ContextClass
|
||||
export const AbilityResultMock = {
|
||||
resultCode: "[PC Preview] unknow resultCode",
|
||||
}
|
||||
const ConfigurationMock = {
|
||||
language: '[PC preview] unknow language'
|
||||
}
|
||||
const PermissionRequestResultMock = {
|
||||
permissions: [paramMock.paramStringMock],
|
||||
authResults: [paramMock.paramNumberMock]
|
||||
}
|
||||
const CallerMock = {
|
||||
call: function (...args) {
|
||||
console.warn("AbilityContext.Caller.call interface mocked in the Previewer." +
|
||||
" How this interface works on the Previewer may be different from that on a real device.")
|
||||
return new Promise((resolve, reject) => {
|
||||
resolve();
|
||||
})
|
||||
},
|
||||
callWithResult: function (...args) {
|
||||
console.warn("AbilityContext.Caller.callWithResult interface mocked in the Previewer." +
|
||||
" How this interface works on the Previewer may be different from that on a real device.")
|
||||
return new Promise((resolve, reject) => {
|
||||
resolve(new MessageParcelClass());
|
||||
})
|
||||
},
|
||||
release: function (...args) {
|
||||
console.warn("AbilityContext.Caller.release interface mocked in the Previewer. How this interface works on the Previewer" +
|
||||
" may be different from that on a real device.")
|
||||
},
|
||||
onRelease: function (...args) {
|
||||
console.warn("AbilityContext.Caller.onRelease interface mocked in the Previewer. How this interface works on the Previewer" +
|
||||
" may be different from that on a real device.")
|
||||
},
|
||||
}
|
||||
export const AbilityContextClass = class AbilityContext extends ContextClass {
|
||||
constructor() {
|
||||
super();
|
||||
@@ -278,7 +253,7 @@ export const AbilityContextClass = class AbilityContext extends ContextClass {
|
||||
' the Previewer may be different from that on a real device.');
|
||||
this.abilityInfo = AbilityInfoMock;
|
||||
this.currentHapModuleInfo = HapModuleInfoMock;
|
||||
this.config = ConfigurationMock;
|
||||
this.config = Configuration;
|
||||
this.startAbility = function (...args) {
|
||||
console.warn("Ability.AbilityContext.startAbility interface mocked in the Previewer." +
|
||||
" How this interface works on the Previewer may be different from that on a real device.")
|
||||
@@ -295,7 +270,7 @@ export const AbilityContextClass = class AbilityContext extends ContextClass {
|
||||
console.warn("Ability.AbilityContext.startAbilityByCall interface mocked in the Previewer." +
|
||||
" How this interface works on the Previewer may be different from that on a real device.")
|
||||
return new Promise((resolve, reject) => {
|
||||
resolve(CallerMock);
|
||||
resolve(Caller);
|
||||
})
|
||||
};
|
||||
this.startAbilityWithAccount = function (...args) {
|
||||
@@ -334,6 +309,54 @@ export const AbilityContextClass = class AbilityContext extends ContextClass {
|
||||
})
|
||||
}
|
||||
};
|
||||
this.startServiceExtensionAbility = function (...args) {
|
||||
console.warn("Ability.AbilityContext.startServiceExtensionAbility interface mocked in the Previewer." +
|
||||
" How this interface works on the Previewer may be different from that on a real device.")
|
||||
const len = args.length
|
||||
if (len > 0 && typeof args[len - 1] === 'function') {
|
||||
args[len - 1].call(this, paramMock.businessErrorMock);
|
||||
} else {
|
||||
return new Promise((resolve, reject) => {
|
||||
resolve();
|
||||
})
|
||||
}
|
||||
};
|
||||
this.startServiceExtensionAbilityWithAccount = function (...args) {
|
||||
console.warn("Ability.AbilityContext.startServiceExtensionAbilityWithAccount interface mocked in the Previewer." +
|
||||
" How this interface works on the Previewer may be different from that on a real device.")
|
||||
const len = args.length
|
||||
if (len > 0 && typeof args[len - 1] === 'function') {
|
||||
args[len - 1].call(this, paramMock.businessErrorMock);
|
||||
} else {
|
||||
return new Promise((resolve, reject) => {
|
||||
resolve();
|
||||
})
|
||||
}
|
||||
};
|
||||
this.stopServiceExtensionAbility = function (...args) {
|
||||
console.warn("Ability.AbilityContext.stopServiceExtensionAbility interface mocked in the Previewer." +
|
||||
" How this interface works on the Previewer may be different from that on a real device.")
|
||||
const len = args.length
|
||||
if (len > 0 && typeof args[len - 1] === 'function') {
|
||||
args[len - 1].call(this, paramMock.businessErrorMock);
|
||||
} else {
|
||||
return new Promise((resolve, reject) => {
|
||||
resolve();
|
||||
})
|
||||
}
|
||||
};
|
||||
this.stopServiceExtensionAbilityWithAccount = function (...args) {
|
||||
console.warn("Ability.AbilityContext.stopServiceExtensionAbilityWithAccount interface mocked in the Previewer." +
|
||||
" How this interface works on the Previewer may be different from that on a real device.")
|
||||
const len = args.length
|
||||
if (len > 0 && typeof args[len - 1] === 'function') {
|
||||
args[len - 1].call(this, paramMock.businessErrorMock);
|
||||
} else {
|
||||
return new Promise((resolve, reject) => {
|
||||
resolve();
|
||||
})
|
||||
}
|
||||
};
|
||||
this.terminateSelf = function (...args) {
|
||||
console.warn("Ability.AbilityContext.terminateSelf interface mocked in the Previewer." +
|
||||
" How this interface works on the Previewer may be different from that on a real device.")
|
||||
@@ -392,6 +415,18 @@ export const AbilityContextClass = class AbilityContext extends ContextClass {
|
||||
})
|
||||
}
|
||||
};
|
||||
this.setMissionIcon = function (...args) {
|
||||
console.warn("Ability.AbilityContext.setMissionIcon interface mocked in the Previewer." +
|
||||
" How this interface works on the Previewer may be different from that on a real device.")
|
||||
const len = args.length
|
||||
if (len > 0 && typeof args[len - 1] === 'function') {
|
||||
args[len - 1].call(this, paramMock.businessErrorMock);
|
||||
} else {
|
||||
return new Promise((resolve, reject) => {
|
||||
resolve();
|
||||
})
|
||||
}
|
||||
};
|
||||
this.requestPermissionsFromUser = function (...args) {
|
||||
console.warn("Ability.AbilityContext.requestPermissionsFromUser interface mocked in the Previewer." +
|
||||
" How this interface works on the Previewer may be different from that on a real device.")
|
||||
@@ -404,6 +439,10 @@ export const AbilityContextClass = class AbilityContext extends ContextClass {
|
||||
})
|
||||
}
|
||||
};
|
||||
this.restoreWindowStage = function (...args) {
|
||||
console.warn("Ability.AbilityContext.restoreWindowStage interface mocked in the Previewer. How this interface works on the Previewer" +
|
||||
" may be different from that on a real device.")
|
||||
};
|
||||
this.isTerminating = function () {
|
||||
console.warn("Ability.AbilityContext.isTerminating interface mocked in the Previewer. How this interface works on the Previewer" +
|
||||
" may be different from that on a real device.")
|
||||
@@ -0,0 +1,18 @@
|
||||
/*
|
||||
* Copyright (c) 2022 Huawei Device Co., Ltd.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
export const BaseContext = {
|
||||
stageMode: "[PC Preview] unknow stageMode",
|
||||
}
|
||||
@@ -0,0 +1,311 @@
|
||||
/*
|
||||
* Copyright (c) 2022 Huawei Device Co., Ltd.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
import { ApplicationInfo } from "../bundle/applicationInfo"
|
||||
import { BaseContext } from "./BaseContext"
|
||||
const ResourceManager = {
|
||||
getString: function(...args) {
|
||||
console.warn("ResourceManager.getString interface mocked in the Previewer. " +
|
||||
"How this interface works on the Previewer may be different from that on a real device.")
|
||||
const len = args.length
|
||||
if (typeof args[len - 1] === 'function') {
|
||||
args[len - 1].call(this, paramMock.businessErrorMock, paramMock.paramStringMock);
|
||||
} else {
|
||||
return new Promise((resolve, reject) => {
|
||||
resolve(paramMock.paramStringMock);
|
||||
})
|
||||
}
|
||||
},
|
||||
|
||||
getStringArray: function(...args) {
|
||||
console.warn("ResourceManager.getStringArray interface mocked in the Previewer. " +
|
||||
"How this interface works on the Previewer may be different from that on a real device.")
|
||||
const len = args.length
|
||||
if (typeof args[len - 1] === 'function') {
|
||||
args[len - 1].call(this, paramMock.businessErrorMock, [paramMock.paramStringMock]);
|
||||
} else {
|
||||
return new Promise((resolve, reject) => {
|
||||
resolve([paramMock.paramStringMock]);
|
||||
})
|
||||
}
|
||||
},
|
||||
|
||||
getMedia: function(...args) {
|
||||
console.warn("ResourceManager.getMedia interface mocked in the Previewer. " +
|
||||
"How this interface works on the Previewer may be different from that on a real device.")
|
||||
const len = args.length
|
||||
if (typeof args[len - 1] === 'function') {
|
||||
args[len - 1].call(this, paramMock.businessErrorMock, paramMock.paramArrayMock);
|
||||
} else {
|
||||
return new Promise((resolve, reject) => {
|
||||
resolve(paramMock.paramArrayMock);
|
||||
})
|
||||
}
|
||||
},
|
||||
|
||||
getMediaBase64: function(...args) {
|
||||
console.warn("ResourceManager.getMediaBase64 interface mocked in the Previewer. " +
|
||||
"How this interface works on the Previewer may be different from that on a real device.")
|
||||
const len = args.length
|
||||
if (typeof args[len - 1] === 'function') {
|
||||
args[len - 1].call(this, paramMock.businessErrorMock, paramMock.paramArrayMock);
|
||||
} else {
|
||||
return new Promise((resolve, reject) => {
|
||||
resolve(paramMock.paramArrayMock);
|
||||
})
|
||||
}
|
||||
},
|
||||
|
||||
getPluralString: function(...args) {
|
||||
console.warn("ResourceManager.getPluralString interface mocked in the Previewer. " +
|
||||
"How this interface works on the Previewer may be different from that on a real device.")
|
||||
const len = args.length
|
||||
if (typeof args[len - 1] === 'function') {
|
||||
args[len - 1].call(this, paramMock.businessErrorMock, paramMock.paramStringMock);
|
||||
} else {
|
||||
return new Promise((resolve, reject) => {
|
||||
resolve(paramMock.paramStringMock);
|
||||
})
|
||||
}
|
||||
},
|
||||
|
||||
getConfiguration: function(...args) {
|
||||
console.warn("ResourceManager.getConfiguration interface mocked in the Previewer. " +
|
||||
"How this interface works on the Previewer may be different from that on a real device.")
|
||||
const len = args.length
|
||||
if (typeof args[len - 1] === 'function') {
|
||||
args[len - 1].call(this, paramMock.businessErrorMock, new ConfigurationClass());
|
||||
} else {
|
||||
return new Promise((resolve, reject) => {
|
||||
resolve(new ConfigurationClass());
|
||||
})
|
||||
}
|
||||
},
|
||||
|
||||
getDeviceCapability: function(...args) {
|
||||
console.warn("ResourceManager.getDeviceCapability interface mocked in the Previewer. " +
|
||||
"How this interface works on the Previewer may be different from that on a real device.")
|
||||
const len = args.length
|
||||
if (typeof args[len - 1] === 'function') {
|
||||
args[len - 1].call(this, paramMock.businessErrorMock, new DeviceCapabilityClass());
|
||||
} else {
|
||||
return new Promise((resolve, reject) => {
|
||||
resolve(new DeviceCapabilityClass());
|
||||
})
|
||||
}
|
||||
},
|
||||
|
||||
release: function() {
|
||||
console.warn("ResourceManager.release interface mocked in the Previewer. " +
|
||||
"How this interface works on the Previewer may be different from that on a real device.")
|
||||
},
|
||||
|
||||
getRawFile: function(...args) {
|
||||
console.warn("ResourceManager.getRawFile interface mocked in the Previewer. " +
|
||||
"How this interface works on the Previewer may be different from that on a real device.")
|
||||
const len = args.length
|
||||
if (typeof args[len - 1] === 'function') {
|
||||
args[len - 1].call(this, paramMock.businessErrorMock, paramMock.paramArrayMock);
|
||||
} else {
|
||||
return new Promise((resolve, reject) => {
|
||||
resolve(paramMock.paramArrayMock);
|
||||
})
|
||||
}
|
||||
},
|
||||
|
||||
getRawFileDescriptor: function(...args) {
|
||||
console.warn("ResourceManager.getRawFileDescriptor interface mocked in the Previewer. " +
|
||||
"How this interface works on the Previewer may be different from that on a real device.")
|
||||
const len = args.length
|
||||
if (typeof args[len - 1] === 'function') {
|
||||
args[len - 1].call(this, paramMock.businessErrorMock, RawFileDescriptor);
|
||||
} else {
|
||||
return new Promise((resolve, reject) => {
|
||||
resolve(RawFileDescriptor);
|
||||
})
|
||||
}
|
||||
},
|
||||
|
||||
closeRawFileDescriptor: function(...args) {
|
||||
console.warn("ResourceManager.closeRawFileDescriptor interface mocked in the Previewer. " +
|
||||
"How this interface works on the Previewer may be different from that on a real device.")
|
||||
const len = args.length
|
||||
if (typeof args[len - 1] === 'function') {
|
||||
args[len - 1].call(this, paramMock.businessErrorMock, paramMock.paramStringMock);
|
||||
} else {
|
||||
return new Promise((resolve, reject) => {
|
||||
resolve(paramMock.paramStringMock);
|
||||
})
|
||||
}
|
||||
},
|
||||
|
||||
getStringByName: function(...args) {
|
||||
console.warn("ResourceManager.getStringByName interface mocked in the Previewer. " +
|
||||
"How this interface works on the Previewer may be different from that on a real device.")
|
||||
const len = args.length
|
||||
if (typeof args[len - 1] === 'function') {
|
||||
args[len - 1].call(this, paramMock.businessErrorMock, paramMock.paramStringMock);
|
||||
} else {
|
||||
return new Promise((resolve, reject) => {
|
||||
resolve(paramMock.paramStringMock);
|
||||
})
|
||||
}
|
||||
},
|
||||
|
||||
getStringArrayByName: function(...args) {
|
||||
console.warn("ResourceManager.getStringArrayByName interface mocked in the Previewer. " +
|
||||
"How this interface works on the Previewer may be different from that on a real device.")
|
||||
const len = args.length
|
||||
if (typeof args[len - 1] === 'function') {
|
||||
args[len - 1].call(this, paramMock.businessErrorMock, [paramMock.paramStringMock]);
|
||||
} else {
|
||||
return new Promise((resolve, reject) => {
|
||||
resolve([paramMock.paramStringMock]);
|
||||
})
|
||||
}
|
||||
},
|
||||
|
||||
getMediaByName: function(...args) {
|
||||
console.warn("ResourceManager.getMediaByName interface mocked in the Previewer. " +
|
||||
"How this interface works on the Previewer may be different from that on a real device.")
|
||||
const len = args.length
|
||||
if (typeof args[len - 1] === 'function') {
|
||||
args[len - 1].call(this, paramMock.businessErrorMock, paramMock.paramArrayMock);
|
||||
} else {
|
||||
return new Promise((resolve, reject) => {
|
||||
resolve(paramMock.paramArrayMock);
|
||||
})
|
||||
}
|
||||
},
|
||||
|
||||
getMediaBase64ByName: function(...args) {
|
||||
console.warn("ResourceManager.getMediaBase64ByName interface mocked in the Previewer. " +
|
||||
"How this interface works on the Previewer may be different from that on a real device.")
|
||||
const len = args.length
|
||||
if (typeof args[len - 1] === 'function') {
|
||||
args[len - 1].call(this, paramMock.businessErrorMock, paramMock.paramArrayMock);
|
||||
} else {
|
||||
return new Promise((resolve, reject) => {
|
||||
resolve(paramMock.paramArrayMock);
|
||||
})
|
||||
}
|
||||
},
|
||||
|
||||
getPluralStringByName: function(...args) {
|
||||
console.warn("ResourceManager.getPluralStringByName interface mocked in the Previewer. " +
|
||||
"How this interface works on the Previewer may be different from that on a real device.")
|
||||
const len = args.length
|
||||
if (typeof args[len - 1] === 'function') {
|
||||
args[len - 1].call(this, paramMock.businessErrorMock, paramMock.paramStringMock);
|
||||
} else {
|
||||
return new Promise((resolve, reject) => {
|
||||
resolve(paramMock.paramStringMock);
|
||||
})
|
||||
}
|
||||
},
|
||||
|
||||
getStringSync: function(...args) {
|
||||
console.warn("ResourceManager.getStringSync interface mocked in the Previewer. " +
|
||||
"How this interface works on the Previewer may be different from that on a real device.")
|
||||
return paramMock.paramStringMock;
|
||||
},
|
||||
|
||||
getStringByNameSync: function(...args) {
|
||||
console.warn("ResourceManager.getStringByNameSync interface mocked in the Previewer. " +
|
||||
"How this interface works on the Previewer may be different from that on a real device.")
|
||||
return paramMock.paramStringMock;
|
||||
},
|
||||
|
||||
getBoolean: function(...args) {
|
||||
console.warn("ResourceManager.getBoolean interface mocked in the Previewer. " +
|
||||
"How this interface works on the Previewer may be different from that on a real device.")
|
||||
return paramMock.paramBooleanMock;
|
||||
},
|
||||
|
||||
getBooleanByName: function(...args) {
|
||||
console.warn("ResourceManager.getBooleanByName interface mocked in the Previewer. " +
|
||||
"How this interface works on the Previewer may be different from that on a real device.")
|
||||
return paramMock.paramBooleanMock;
|
||||
},
|
||||
|
||||
getNumber: function(...args) {
|
||||
console.warn("ResourceManager.getNumber interface mocked in the Previewer. " +
|
||||
"How this interface works on the Previewer may be different from that on a real device.")
|
||||
return paramMock.paramNumberMock;
|
||||
},
|
||||
|
||||
getNumberByName: function(...args) {
|
||||
console.warn("ResourceManager.getNumberByName interface mocked in the Previewer. " +
|
||||
"How this interface works on the Previewer may be different from that on a real device.")
|
||||
return paramMock.paramNumberMock;
|
||||
}
|
||||
}
|
||||
const EventHubClass = class EventHub {
|
||||
constructor() {
|
||||
console.warn('EventHub.constructor interface mocked in the Previewer. How this interface works on' +
|
||||
' the Previewer may be different from that on a real device.');
|
||||
this.on = function (...args) {
|
||||
console.warn("EventHub.on interface mocked in the Previewer. How this interface works on the Previewer" +
|
||||
" may be different from that on a real device.")
|
||||
};
|
||||
this.off = function (...args) {
|
||||
console.warn("EventHub.off interface mocked in the Previewer. How this interface works on the Previewer" +
|
||||
" may be different from that on a real device.")
|
||||
};
|
||||
this.emit = function (...args) {
|
||||
console.warn("EventHub.emit interface mocked in the Previewer. How this interface works on the Previewer" +
|
||||
" may be different from that on a real device.")
|
||||
};
|
||||
}
|
||||
}
|
||||
export const ContextClass = class Context extends BaseContext {
|
||||
constructor() {
|
||||
super();
|
||||
console.warn('Context.constructor interface mocked in the Previewer. How this interface works on' +
|
||||
' the Previewer may be different from that on a real device.');
|
||||
this.resourceManager = ResourceManager;
|
||||
this.applicationInfo = ApplicationInfo;
|
||||
this.cacheDir = "[PC Preview] unknow cacheDir";
|
||||
this.tempDir = "[PC Preview] unknow tempDir";
|
||||
this.filesDir = "[PC Preview] unknow filesDir";
|
||||
this.databaseDir = "[PC Preview] unknow databaseDir";
|
||||
this.storageDir = "[PC Preview] unknow storageDir";
|
||||
this.bundleCodeDir = "[PC Preview] unknow bundleCodeDir";
|
||||
this.distributedFilesDir = "[PC Preview] unknow distributedFilesDir";
|
||||
this.eventHub = new EventHubClass();
|
||||
this.createBundleContext = function (...args) {
|
||||
console.warn("Context.createBundleContext interface mocked in the Previewer. How this interface works on the Previewer" +
|
||||
" may be different from that on a real device.")
|
||||
return new ContextClass();
|
||||
};
|
||||
this.createModuleContext = function (...args) {
|
||||
console.warn("Context.createModuleContext interface mocked in the Previewer. How this interface works on the Previewer" +
|
||||
" may be different from that on a real device.")
|
||||
return new ContextClass();
|
||||
};
|
||||
this.getApplicationContext = function () {
|
||||
console.warn("Context.getApplicationContext interface mocked in the Previewer. How this interface works on the Previewer" +
|
||||
" may be different from that on a real device.")
|
||||
return new ContextClass();
|
||||
};
|
||||
this.switchArea = function (...args) {
|
||||
console.warn("Context.switchArea interface mocked in the Previewer. How this interface works on the Previewer" +
|
||||
" may be different from that on a real device.")
|
||||
};
|
||||
}
|
||||
}
|
||||
export const AreaMode = {
|
||||
EL1: 0,
|
||||
EL2: 1
|
||||
}
|
||||
@@ -0,0 +1,34 @@
|
||||
/*
|
||||
* Copyright (c) 2022 Huawei Device Co., Ltd.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
import { ExtensionContextClass } from "./abilityContext"
|
||||
export const formExtensionContextClass = class formExtensionContext extends ExtensionContextClass {
|
||||
constructor() {
|
||||
super();
|
||||
console.warn('formExtensionContext.constructor interface mocked in the Previewer. How this interface works on' +
|
||||
' the Previewer may be different from that on a real device.');
|
||||
this.startAbility = function (...args) {
|
||||
console.warn("formExtensionContext.startAbility interface mocked in the Previewer." +
|
||||
" How this interface works on the Previewer may be different from that on a real device.");
|
||||
const len = args.length;
|
||||
if (len > 0 && typeof args[len - 1] === 'function') {
|
||||
args[len - 1].call(this, paramMock.businessErrorMock);
|
||||
} else {
|
||||
return new Promise((resolve, reject) => {
|
||||
resolve();
|
||||
})
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,45 @@
|
||||
/*
|
||||
* Copyright (c) 2022 Huawei Device Co., Ltd.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
export const AbilityMonitor = {
|
||||
abilityName: "[PC Preview] unknow abilityName",
|
||||
onAbilityCreate: function (...args) {
|
||||
console.warn("AbilityMonitor.onAbilityCreate interface mocked in the Previewer." +
|
||||
" How this interface works on the Previewer may be different from that on a real device.")
|
||||
},
|
||||
onAbilityForeground: function (...args) {
|
||||
console.warn("AbilityMonitor.onAbilityForeground interface mocked in the Previewer." +
|
||||
" How this interface works on the Previewer may be different from that on a real device.")
|
||||
},
|
||||
onAbilityBackground: function (...args) {
|
||||
console.warn("AbilityMonitor.onAbilityBackground interface mocked in the Previewer." +
|
||||
" How this interface works on the Previewer may be different from that on a real device.")
|
||||
},
|
||||
onAbilityDestroy: function (...args) {
|
||||
console.warn("AbilityMonitor.onAbilityDestroy interface mocked in the Previewer." +
|
||||
" How this interface works on the Previewer may be different from that on a real device.")
|
||||
},
|
||||
onWindowStageCreate: function (...args) {
|
||||
console.warn("AbilityMonitor.onWindowStageCreate interface mocked in the Previewer." +
|
||||
" How this interface works on the Previewer may be different from that on a real device.")
|
||||
},
|
||||
onWindowStageRestore: function (...args) {
|
||||
console.warn("AbilityMonitor.onWindowStageRestore interface mocked in the Previewer." +
|
||||
" How this interface works on the Previewer may be different from that on a real device.")
|
||||
},
|
||||
onWindowStageDestroy: function (...args) {
|
||||
console.warn("AbilityMonitor.onWindowStageDestroy interface mocked in the Previewer." +
|
||||
" How this interface works on the Previewer may be different from that on a real device.")
|
||||
},
|
||||
}
|
||||
@@ -0,0 +1,156 @@
|
||||
/*
|
||||
* Copyright (c) 2022 Huawei Device Co., Ltd.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
import { paramMock } from "../../../utils"
|
||||
export const Result = {
|
||||
code: "[PC Preview] unknow code",
|
||||
data: "[PC Preview] unknow data",
|
||||
}
|
||||
export const SubscribeMessageResponse = {
|
||||
deviceId: "[PC Preview] unknow deviceId",
|
||||
bundleName: "[PC Preview] unknow bundleName",
|
||||
abilityName: "[PC Preview] unknow abilityName",
|
||||
message: "[PC Preview] unknow message",
|
||||
}
|
||||
export const CallAbilityParam = {
|
||||
bundleName: "[PC Preview] unknow bundleName",
|
||||
abilityName: "[PC Preview] unknow abilityName",
|
||||
messageCode: "[PC Preview] unknow messageCode",
|
||||
abilityType: "[PC Preview] unknow abilityType",
|
||||
data: "[PC Preview] unknow data",
|
||||
syncOption: "[PC Preview] unknow syncOption",
|
||||
}
|
||||
export const SubscribeAbilityEventParam = {
|
||||
bundleName: "[PC Preview] unknow bundleName",
|
||||
abilityName: "[PC Preview] unknow abilityName",
|
||||
messageCode: "[PC Preview] unknow messageCode",
|
||||
abilityType: "[PC Preview] unknow abilityType",
|
||||
syncOption: "[PC Preview] unknow syncOption",
|
||||
}
|
||||
export const SendMessageOptions = {
|
||||
deviceId: "[PC Preview] unknow deviceId",
|
||||
bundleName: "[PC Preview] unknow bundleName",
|
||||
abilityName: "[PC Preview] unknow abilityName",
|
||||
message: "[PC Preview] unknow message",
|
||||
success: function () {
|
||||
console.warn("SendMessageOptions.success interface mocked in the Previewer." +
|
||||
" How this interface works on the Previewer may be different from that on a real device.")
|
||||
},
|
||||
fail: function (...args) {
|
||||
console.warn("SendMessageOptions.fail interface mocked in the Previewer." +
|
||||
" How this interface works on the Previewer may be different from that on a real device.")
|
||||
},
|
||||
complete: function () {
|
||||
console.warn("SendMessageOptions.complete interface mocked in the Previewer." +
|
||||
" How this interface works on the Previewer may be different from that on a real device.")
|
||||
}
|
||||
}
|
||||
export const SubscribeMessageOptions = {
|
||||
success: function (...args) {
|
||||
console.warn("SubscribeMessageOptions.success interface mocked in the Previewer." +
|
||||
" How this interface works on the Previewer may be different from that on a real device.")
|
||||
},
|
||||
fail: function (...args) {
|
||||
console.warn("SubscribeMessageOptions.fail interface mocked in the Previewer." +
|
||||
" How this interface works on the Previewer may be different from that on a real device.")
|
||||
},
|
||||
}
|
||||
export const RequestParams = {
|
||||
bundleName: "[PC Preview] unknow bundleName",
|
||||
abilityName: "[PC Preview] unknow abilityName",
|
||||
entities: [paramMock.paramStringMock],
|
||||
action: "[PC Preview] unknow action",
|
||||
deviceType: "[PC Preview] unknow deviceType",
|
||||
data: "[PC Preview] unknow data",
|
||||
flag: "[PC Preview] unknow flag",
|
||||
url: "[PC Preview] unknow url",
|
||||
}
|
||||
export const FinishWithResultParams = {
|
||||
code: "[PC Preview] unknow code",
|
||||
result: "[PC Preview] unknow result",
|
||||
}
|
||||
export const FeatureAbilityClass = class FeatureAbility {
|
||||
constructor() {
|
||||
console.warn('FeatureAbility.constructor interface mocked in the Previewer. How this interface works on' +
|
||||
' the Previewer may be different from that on a real device.');
|
||||
this.startAbility = function (...args) {
|
||||
console.warn("FeatureAbility.startAbility interface mocked in the Previewer. How this interface works on the Previewer" +
|
||||
" may be different from that on a real device.")
|
||||
return new Promise((resolve, reject) => {
|
||||
resolve(Result);
|
||||
})
|
||||
};
|
||||
this.startAbilityForResult = function (...args) {
|
||||
console.warn("FeatureAbility.startAbilityForResult interface mocked in the Previewer. How this interface works on the Previewer" +
|
||||
" may be different from that on a real device.")
|
||||
return new Promise((resolve, reject) => {
|
||||
resolve(Result);
|
||||
})
|
||||
};
|
||||
this.finishWithResult = function (...args) {
|
||||
console.warn("FeatureAbility.finishWithResult interface mocked in the Previewer. How this interface works on the Previewer" +
|
||||
" may be different from that on a real device.")
|
||||
return new Promise((resolve, reject) => {
|
||||
resolve(Result);
|
||||
})
|
||||
};
|
||||
this.getDeviceList = function (...args) {
|
||||
console.warn("FeatureAbility.getDeviceList interface mocked in the Previewer. How this interface works on the Previewer" +
|
||||
" may be different from that on a real device.")
|
||||
return new Promise((resolve, reject) => {
|
||||
resolve(Result);
|
||||
})
|
||||
};
|
||||
this.callAbility = function (...args) {
|
||||
console.warn("FeatureAbility.callAbility interface mocked in the Previewer. How this interface works on the Previewer" +
|
||||
" may be different from that on a real device.")
|
||||
return new Promise((resolve, reject) => {
|
||||
resolve(paramMock.paramStringMock);
|
||||
})
|
||||
};
|
||||
this.continueAbility = function () {
|
||||
console.warn("FeatureAbility.continueAbility interface mocked in the Previewer. How this interface works on the Previewer" +
|
||||
" may be different from that on a real device.")
|
||||
return new Promise((resolve, reject) => {
|
||||
resolve(Result);
|
||||
})
|
||||
};
|
||||
this.subscribeAbilityEvent = function (...args) {
|
||||
console.warn("FeatureAbility.subscribeAbilityEvent interface mocked in the Previewer. How this interface works on the Previewer" +
|
||||
" may be different from that on a real device.")
|
||||
return new Promise((resolve, reject) => {
|
||||
resolve(paramMock.paramStringMock);
|
||||
})
|
||||
};
|
||||
this.unsubscribeAbilityEvent = function (...args) {
|
||||
console.warn("FeatureAbility.unsubscribeAbilityEvent interface mocked in the Previewer. How this interface works on the Previewer" +
|
||||
" may be different from that on a real device.")
|
||||
return new Promise((resolve, reject) => {
|
||||
resolve(paramMock.paramStringMock);
|
||||
})
|
||||
};
|
||||
this.sendMsg = function (...args) {
|
||||
console.warn("FeatureAbility.sendMsg interface mocked in the Previewer. How this interface works on the Previewer" +
|
||||
" may be different from that on a real device.")
|
||||
};
|
||||
this.subscribeMsg = function (...args) {
|
||||
console.warn("FeatureAbility.subscribeMsg interface mocked in the Previewer. How this interface works on the Previewer" +
|
||||
" may be different from that on a real device.")
|
||||
};
|
||||
this.unsubscribeMsg = function () {
|
||||
console.warn("FeatureAbility.unsubscribeMsg interface mocked in the Previewer. How this interface works on the Previewer" +
|
||||
" may be different from that on a real device.")
|
||||
};
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,27 @@
|
||||
/*
|
||||
* Copyright (c) 2022 Huawei Device Co., Ltd.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
import { paramMock } from "../../utils"
|
||||
const ContinuationMode = {
|
||||
COLLABORATION_SINGLE: 0,
|
||||
COLLABORATION_MULTIPLE: 1
|
||||
}
|
||||
export const ContinuationExtraParams = {
|
||||
deviceType: [paramMock.paramStringMock],
|
||||
targetBundle: "[PC Preview] unknow targetBundle",
|
||||
description: "[PC Preview] unknow description",
|
||||
filter: "[PC Preview] unknow filter",
|
||||
continuationMode: ContinuationMode,
|
||||
authInfo: {}
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
/*
|
||||
* Copyright (c) 2022 Huawei Device Co., Ltd.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
export const ContinuationResult = {
|
||||
id: "[PC Preview] unknow id",
|
||||
type: "[PC Preview] unknow type",
|
||||
name: "[PC Preview] unknow name",
|
||||
}
|
||||
@@ -15,10 +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'
|
||||
@@ -271,12 +276,22 @@ export function mockRequireNapiFun() {
|
||||
return mockSystemParameter();
|
||||
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":
|
||||
|
||||
@@ -0,0 +1,20 @@
|
||||
/*
|
||||
* Copyright (c) 2022 Huawei Device Co., Ltd.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
export const ErrorCode = {
|
||||
PERMISSION_DENY: -3,
|
||||
ABILITY_NOT_FOUND: -2,
|
||||
INVALID_PARAMETER: -1,
|
||||
NO_ERROR: 0,
|
||||
}
|
||||
@@ -0,0 +1,425 @@
|
||||
/*
|
||||
* Copyright (c) 2022 Huawei Device Co., Ltd.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import { paramMock } from "../utils"
|
||||
import { WantClass } from "./ohos_application_Want"
|
||||
import { Context } from "./app/context"
|
||||
import { AbilityResult } from "./ability/abilityResult"
|
||||
import { window } 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, window);
|
||||
} else {
|
||||
return new Promise((resolve, reject) => {
|
||||
resolve(window);
|
||||
})
|
||||
}
|
||||
},
|
||||
}
|
||||
return featureAbility;
|
||||
}
|
||||
export const AbilityWindowConfiguration = {
|
||||
WINDOW_MODE_UNDEFINED: 0,
|
||||
WINDOW_MODE_FULLSCREEN: 1,
|
||||
WINDOW_MODE_SPLIT_PRIMARY: 100,
|
||||
WINDOW_MODE_SPLIT_SECONDARY: 101,
|
||||
WINDOW_MODE_FLOATING: 102
|
||||
}
|
||||
export const AbilityStartSetting = {
|
||||
BOUNDS_KEY: "abilityBounds",
|
||||
WINDOW_MODE_KEY: "windowMode",
|
||||
DISPLAY_ID_KEY: "displayId"
|
||||
}
|
||||
export const ErrorCode = {
|
||||
NO_ERROR: 0,
|
||||
INVALID_PARAMETER: -1,
|
||||
ABILITY_NOT_FOUND: -2,
|
||||
PERMISSION_DENY: -3
|
||||
}
|
||||
export const DataAbilityOperationType = {
|
||||
TYPE_INSERT: 1,
|
||||
TYPE_UPDATE: 2,
|
||||
TYPE_DELETE: 3,
|
||||
TYPE_ASSERT: 4,
|
||||
}
|
||||
@@ -0,0 +1,68 @@
|
||||
/*
|
||||
* Copyright (c) 2022 Huawei Device Co., Ltd.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
export const Action = {
|
||||
ACTION_HOME: "ohos.want.action.home",
|
||||
ACTION_DIAL: "ohos.want.action.dial",
|
||||
ACTION_SEARCH: "ohos.want.action.search",
|
||||
ACTION_WIRELESS_SETTINGS: "ohos.settings.wireless",
|
||||
ACTION_MANAGE_APPLICATIONS_SETTINGS: "ohos.settings.manage.applications",
|
||||
ACTION_APPLICATION_DETAILS_SETTINGS: "ohos.settings.application.details",
|
||||
ACTION_SET_ALARM: "ohos.want.action.setAlarm",
|
||||
ACTION_SHOW_ALARMS: "ohos.want.action.showAlarms",
|
||||
ACTION_SNOOZE_ALARM: "ohos.want.action.snoozeAlarm",
|
||||
ACTION_DISMISS_ALARM: "ohos.want.action.dismissAlarm",
|
||||
ACTION_DISMISS_TIMER: "ohos.want.action.dismissTimer",
|
||||
ACTION_SEND_SMS: "ohos.want.action.sendSms",
|
||||
ACTION_CHOOSE: "ohos.want.action.choose",
|
||||
ACTION_IMAGE_CAPTURE: "ohos.want.action.imageCapture",
|
||||
ACTION_VIDEO_CAPTURE: "ohos.want.action.videoCapture",
|
||||
ACTION_SELECT: "ohos.want.action.select",
|
||||
ACTION_SEND_DATA: "ohos.want.action.sendData",
|
||||
ACTION_SEND_MULTIPLE_DATA: "ohos.want.action.sendMultipleData",
|
||||
ACTION_SCAN_MEDIA_FILE: "ohos.want.action.scanMediaFile",
|
||||
ACTION_VIEW_DATA: "ohos.want.action.viewData",
|
||||
ACTION_EDIT_DATA: "ohos.want.action.editData",
|
||||
INTENT_PARAMS_INTENT: "ability.want.params.INTENT",
|
||||
INTENT_PARAMS_TITLE: "ability.want.params.TITLE",
|
||||
ACTION_FILE_SELECT: "ohos.action.fileSelect",
|
||||
PARAMS_STREAM: "ability.params.stream",
|
||||
ACTION_APP_ACCOUNT_OAUTH: "ohos.account.appAccount.action.oauth",
|
||||
ACTION_MARKER_DOWNLOAD: "ohos.want.action.marketDownload"
|
||||
}
|
||||
export const Entity = {
|
||||
ENTITY_DEFAULT: "entity.system.default",
|
||||
ENTITY_HOME: "entity.system.home",
|
||||
ENTITY_VOICE: "entity.system.voice",
|
||||
ENTITY_BROWSABLE: "entity.system.browsable",
|
||||
ENTITY_VIDEO: "entity.system.video"
|
||||
}
|
||||
export const Flags = {
|
||||
FLAG_AUTH_READ_URI_PERMISSION: 0x00000001,
|
||||
FLAG_AUTH_WRITE_URI_PERMISSION: 0x00000002,
|
||||
FLAG_ABILITY_FORWARD_RESULT: 0x00000004,
|
||||
FLAG_ABILITY_CONTINUATION: 0x00000008,
|
||||
FLAG_NOT_OHOS_COMPONENT: 0x00000010,
|
||||
FLAG_ABILITY_FORM_ENABLED: 0x00000020,
|
||||
FLAG_AUTH_PERSISTABLE_URI_PERMISSION: 0x00000040,
|
||||
FLAG_AUTH_PREFIX_URI_PERMISSION: 0x00000080,
|
||||
FLAG_ABILITYSLICE_MULTI_DEVICE: 0x00000100,
|
||||
FLAG_START_FOREGROUND_ABILITY: 0x00000200,
|
||||
FLAG_ABILITY_CONTINUATION_REVERSIBLE: 0x00000400,
|
||||
FLAG_INSTALL_ON_DEMAND: 0x00000800,
|
||||
FLAG_INSTALL_WITH_BACKGROUND_MODE: 0x80000000,
|
||||
FLAG_ABILITY_CLEAR_MISSION: 0x00008000,
|
||||
FLAG_ABILITY_NEW_MISSION: 0x10000000,
|
||||
FLAG_ABILITY_MISSION_TOP: 0x20000000
|
||||
}
|
||||
@@ -14,11 +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 calleeMock = {
|
||||
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.")
|
||||
},
|
||||
}
|
||||
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.")
|
||||
@@ -35,7 +60,7 @@ export const AbilityClass = class Ability {
|
||||
this.context = new AbilityContextClass();
|
||||
this.launchWant = new WantClass();
|
||||
this.lastRequestWant = new WantClass();
|
||||
this.callee = calleeMock;
|
||||
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.")
|
||||
|
||||
@@ -13,6 +13,21 @@
|
||||
* 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,
|
||||
|
||||
@@ -13,7 +13,7 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import { abilityStageContextClass } from "./application/abilityContext"
|
||||
import { abilityStageContextClass } from "./application/AbilityContext"
|
||||
import { paramMock } from "../utils"
|
||||
|
||||
export function mockAbilityStage() {
|
||||
@@ -26,11 +26,15 @@ export function mockAbilityStage() {
|
||||
console.warn("application.AbilityStage.onCreate interface mocked in the Previewer. How this interface works on the Previewer" +
|
||||
" may be different from that on a real device.")
|
||||
};
|
||||
this.onAcceptWant = function () {
|
||||
this.onAcceptWant = function (...args) {
|
||||
console.warn("application.AbilityStage.onAcceptWant interface mocked in the Previewer. How this interface works on the Previewer" +
|
||||
" may be different from that on a real device.")
|
||||
return paramMock.paramStringMock;
|
||||
}
|
||||
};
|
||||
this.onConfigurationUpdated = function (...args) {
|
||||
console.warn("application.AbilityStage.onConfigurationUpdated interface mocked in the Previewer. How this interface works on the Previewer" +
|
||||
" may be different from that on a real device.")
|
||||
};
|
||||
}
|
||||
}
|
||||
return new AbilityStageClass();
|
||||
|
||||
@@ -0,0 +1,22 @@
|
||||
/*
|
||||
* Copyright (c) 2022 Huawei Device Co., Ltd.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
import { ColorMode, Direction, ScreenDensity} from "./ohos_application_ConfigurationConstant"
|
||||
export const Configuration = {
|
||||
language: '[PC preview] unknow language',
|
||||
colorMode: ColorMode,
|
||||
direction: Direction,
|
||||
screenDensity: ScreenDensity,
|
||||
displayId: '[PC preview] unknow displayId',
|
||||
}
|
||||
@@ -0,0 +1,33 @@
|
||||
/*
|
||||
* Copyright (c) 2022 Huawei Device Co., Ltd.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
export const ColorMode = {
|
||||
COLOR_MODE_NOT_SET: -1,
|
||||
COLOR_MODE_DARK: 0,
|
||||
COLOR_MODE_LIGHT: 1,
|
||||
}
|
||||
export const Direction = {
|
||||
DIRECTION_NOT_SET: -1,
|
||||
DIRECTION_VERTICAL: 0,
|
||||
DIRECTION_HORIZONTAL: 1,
|
||||
}
|
||||
export const ScreenDensity = {
|
||||
SCREEN_DENSITY_NOT_SET: 0,
|
||||
SCREEN_DENSITY_SDPI: 120,
|
||||
SCREEN_DENSITY_MDPI: 160,
|
||||
SCREEN_DENSITY_LDPI: 240,
|
||||
SCREEN_DENSITY_XLDPI: 320,
|
||||
SCREEN_DENSITY_XXLDPI: 480,
|
||||
SCREEN_DENSITY_XXXLDPI: 640,
|
||||
}
|
||||
@@ -14,7 +14,7 @@
|
||||
*/
|
||||
|
||||
import { paramMock } from "../utils"
|
||||
import { ExtensionContextClass } from "./application/abilityContext"
|
||||
import { ExtensionContextClass } from "./application/AbilityContext"
|
||||
import { DataShareResultSetMock } from "./ohos_data_DataShareResultSet"
|
||||
|
||||
export function mockDataShareExtensionAbility() {
|
||||
|
||||
@@ -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 = {
|
||||
@@ -81,7 +82,16 @@ 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 formExtensionClass;
|
||||
return new formExtensionClass();
|
||||
}
|
||||
@@ -14,7 +14,7 @@
|
||||
*/
|
||||
|
||||
import { paramMock } from "../utils"
|
||||
import { ExtensionContextClass } from "./application/abilityContext"
|
||||
import { ExtensionContextClass } from "./application/AbilityContext"
|
||||
|
||||
export const RemoteObjectClass = class RemoteObject {
|
||||
constructor() {
|
||||
@@ -231,6 +231,11 @@ export function mockServiceExtensionAbility() {
|
||||
console.warn("application.ServiceExtensionAbility.onConfigurationUpdated interface mocked in the Previewer. How this interface works on the Previewer" +
|
||||
" may be different from that on a real device.")
|
||||
};
|
||||
this.dump = function (...args) {
|
||||
console.warn("application.ServiceExtensionAbility.dump interface mocked in the Previewer. How this interface works on the Previewer" +
|
||||
" may be different from that on a real device.")
|
||||
return [paramMock.paramStringMock];
|
||||
};
|
||||
}
|
||||
}
|
||||
return new ServiceExtensionAbilityClass();
|
||||
|
||||
@@ -0,0 +1,22 @@
|
||||
/*
|
||||
* Copyright (c) 2022 Huawei Device Co., Ltd.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
export const StartOptionsClass = class StartOptions {
|
||||
constructor() {
|
||||
console.warn('StartOptions.constructor interface mocked in the Previewer. How this interface works on' +
|
||||
' the Previewer may be different from that on a real device.');
|
||||
this.windowMode = "[PC Preview] unknow windowMode";
|
||||
this.displayId = "[PC Preview] unknow displayId";
|
||||
}
|
||||
}
|
||||
+27
@@ -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();
|
||||
}
|
||||
@@ -15,6 +15,13 @@
|
||||
|
||||
import { paramMock } from "../utils"
|
||||
|
||||
export const AbilityState = {
|
||||
INITIAL: 0,
|
||||
FOREGROUND: 9,
|
||||
BACKGROUND: 10,
|
||||
FOREGROUNDING: 11,
|
||||
BACKGROUNDING: 12
|
||||
}
|
||||
export function mockAbilityManager() {
|
||||
const AbilityRunningInfoMock = {
|
||||
ability: ElementNameMock,
|
||||
@@ -40,6 +47,14 @@ export function mockAbilityManager() {
|
||||
clientPackage: [paramMock.paramStringMock],
|
||||
ExtensionAbilityTypeMock: '[PC preview] unknow ExtensionAbilityTypeMock',
|
||||
}
|
||||
const elementName = {
|
||||
deviceId: "[PC preview] unknown deviceId",
|
||||
bundleName: "[PC preview] unknown bundleName",
|
||||
abilityName: "[PC preview] unknown abilityName",
|
||||
uri: "[PC preview] unknown uri",
|
||||
shortName: "[PC preview] unknown shortName",
|
||||
moduleName: "[PC preview] unknown moduleName",
|
||||
}
|
||||
const abilityManager = {
|
||||
updateConfiguration: function (...args) {
|
||||
console.warn('abilityManager.updateConfiguration interface mocked in the Previewer. How this interface works on the' +
|
||||
@@ -76,6 +91,18 @@ export function mockAbilityManager() {
|
||||
resolve([ExtensionRunningInfoMock]);
|
||||
});
|
||||
}
|
||||
},
|
||||
getTopAbility: function (...args) {
|
||||
console.warn('abilityManager.getTopAbility interface mocked in the Previewer. How this interface works on the' +
|
||||
' Previewer may be different from that on a real device.');
|
||||
const len = args.length;
|
||||
if (typeof args[len - 1] === 'function') {
|
||||
args[len - 1].call(this, paramMock.businessErrorMock, elementName);
|
||||
} else {
|
||||
return new Promise((resolve) => {
|
||||
resolve(elementName);
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
return abilityManager
|
||||
|
||||
@@ -116,6 +116,30 @@ export function mockAppManager() {
|
||||
resolve();
|
||||
});
|
||||
}
|
||||
},
|
||||
isRamConstrainedDevice: function (...args) {
|
||||
console.warn('appManager.isRamConstrainedDevice interface mocked in the Previewer. How this interface works on the' +
|
||||
' Previewer may be different from that on a real device.');
|
||||
const len = args.length;
|
||||
if (typeof args[len - 1] === 'function') {
|
||||
args[len - 1].call(this, paramMock.businessErrorMock, paramMock.paramBooleanMock);
|
||||
} else {
|
||||
return new Promise((resolve) => {
|
||||
resolve(paramMock.paramBooleanMock);
|
||||
});
|
||||
}
|
||||
},
|
||||
getAppMemorySize: function (...args) {
|
||||
console.warn('appManager.getAppMemorySize interface mocked in the Previewer. How this interface works on the' +
|
||||
' Previewer may be different from that on a real device.');
|
||||
const len = args.length;
|
||||
if (typeof args[len - 1] === 'function') {
|
||||
args[len - 1].call(this, paramMock.businessErrorMock, paramMock.paramNumberMock);
|
||||
} else {
|
||||
return new Promise((resolve) => {
|
||||
resolve(paramMock.paramNumberMock);
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
return appManager
|
||||
|
||||
@@ -0,0 +1,38 @@
|
||||
/*
|
||||
* Copyright (c) 2022 Huawei Device Co., Ltd.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
import { paramMock } from "../utils"
|
||||
|
||||
export function mockErrorManager() {
|
||||
const errorManager = {
|
||||
registerErrorObserver: function (...args) {
|
||||
console.warn('errorManager.registerErrorObserver interface mocked in the Previewer. How this interface works on the' +
|
||||
' Previewer may be different from that on a real device.');
|
||||
return paramMock.paramNumberMock;
|
||||
},
|
||||
unregisterErrorObserver: function (...args) {
|
||||
console.warn('errorManager.unregisterErrorObserver interface mocked in the Previewer. How this interface works on the' +
|
||||
' Previewer may be different from that on a real device.');
|
||||
const len = args.length;
|
||||
if (typeof args[len - 1] === 'function') {
|
||||
args[len - 1].call(this, paramMock.businessErrorMock);
|
||||
} else {
|
||||
return new Promise((resolve, reject) => {
|
||||
resolve();
|
||||
});
|
||||
}
|
||||
},
|
||||
}
|
||||
return errorManager
|
||||
}
|
||||
@@ -14,17 +14,16 @@
|
||||
*/
|
||||
|
||||
import { paramMock } from "../utils"
|
||||
|
||||
export const FormBindingData = {
|
||||
data: paramMock.paramObjectMock
|
||||
}
|
||||
export function mockFormBindingData() {
|
||||
const formBindingDatasMock = {
|
||||
data: paramMock.paramObjectMock
|
||||
}
|
||||
const formBindingDataMock = {
|
||||
const formBindingData = {
|
||||
createFormBindingData: function (...args) {
|
||||
console.warn("formBindingData.createFormBindingData interface mocked in the Previewer. How this interface works on the Previewer" +
|
||||
" may be different from that on a real device.")
|
||||
return formBindingDatasMock;
|
||||
return FormBindingData;
|
||||
},
|
||||
}
|
||||
return formBindingDataMock;
|
||||
return formBindingData;
|
||||
}
|
||||
@@ -0,0 +1,39 @@
|
||||
/*
|
||||
* Copyright (c) 2022 Huawei Device Co., Ltd.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
export const FormError = {
|
||||
ERR_COMMON: 1,
|
||||
ERR_PERMISSION_DENY: 2,
|
||||
ERR_GET_INFO_FAILED: 4,
|
||||
ERR_GET_BUNDLE_FAILED: 5,
|
||||
ERR_GET_LAYOUT_FAILED: 6,
|
||||
ERR_ADD_INVALID_PARAM: 7,
|
||||
ERR_CFG_NOT_MATCH_ID: 8,
|
||||
ERR_NOT_EXIST_ID: 9,
|
||||
ERR_BIND_PROVIDER_FAILED: 10,
|
||||
ERR_MAX_SYSTEM_FORMS: 11,
|
||||
ERR_MAX_INSTANCES_PER_FORM: 12,
|
||||
ERR_OPERATION_FORM_NOT_SELF: 13,
|
||||
ERR_PROVIDER_DEL_FAIL: 14,
|
||||
ERR_MAX_FORMS_PER_CLIENT: 15,
|
||||
ERR_MAX_SYSTEM_TEMP_FORMS: 16,
|
||||
ERR_FORM_NO_SUCH_MODULE: 17,
|
||||
ERR_FORM_NO_SUCH_ABILITY: 18,
|
||||
ERR_FORM_NO_SUCH_DIMENSION: 19,
|
||||
ERR_FORM_FA_NOT_INSTALLED: 20,
|
||||
ERR_SYSTEM_RESPONSES_FAILED: 30,
|
||||
ERR_FORM_DUPLICATE_ADDED: 31,
|
||||
ERR_IN_RECOVERY: 36
|
||||
}
|
||||
@@ -0,0 +1,219 @@
|
||||
/*
|
||||
* Copyright (c) 2022 Huawei Device Co., Ltd.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import { paramMock } from "../utils"
|
||||
import { FormInfo, FormStateInfo } from "./ohos_application_formInfo"
|
||||
|
||||
export function mockFormHost() {
|
||||
const formHost = {
|
||||
deleteForm: function (...args) {
|
||||
console.warn('formHost.deleteForm interface mocked in the Previewer. How this interface works on the' +
|
||||
' Previewer may be different from that on a real device.');
|
||||
const len = args.length;
|
||||
if (typeof args[len - 1] === 'function') {
|
||||
args[len - 1].call(this, paramMock.businessErrorMock);
|
||||
} else {
|
||||
return new Promise((resolve) => {
|
||||
resolve();
|
||||
});
|
||||
}
|
||||
},
|
||||
releaseForm: function (...args) {
|
||||
console.warn('formHost.releaseForm interface mocked in the Previewer. How this interface works on the' +
|
||||
' Previewer may be different from that on a real device.');
|
||||
const len = args.length;
|
||||
if (typeof args[len - 1] === 'function') {
|
||||
args[len - 1].call(this, paramMock.businessErrorMock);
|
||||
} else {
|
||||
return new Promise((resolve) => {
|
||||
resolve();
|
||||
});
|
||||
}
|
||||
},
|
||||
requestForm: function (...args) {
|
||||
console.warn('formHost.requestForm interface mocked in the Previewer. How this interface works on the' +
|
||||
' Previewer may be different from that on a real device.');
|
||||
const len = args.length;
|
||||
if (typeof args[len - 1] === 'function') {
|
||||
args[len - 1].call(this, paramMock.businessErrorMock);
|
||||
} else {
|
||||
return new Promise((resolve) => {
|
||||
resolve();
|
||||
});
|
||||
}
|
||||
},
|
||||
castTempForm: function (...args) {
|
||||
console.warn('formHost.castTempForm interface mocked in the Previewer. How this interface works on the' +
|
||||
' Previewer may be different from that on a real device.');
|
||||
const len = args.length;
|
||||
if (typeof args[len - 1] === 'function') {
|
||||
args[len - 1].call(this, paramMock.businessErrorMock);
|
||||
} else {
|
||||
return new Promise((resolve) => {
|
||||
resolve();
|
||||
});
|
||||
}
|
||||
},
|
||||
notifyVisibleForms: function (...args) {
|
||||
console.warn('formHost.notifyVisibleForms interface mocked in the Previewer. How this interface works on the' +
|
||||
' Previewer may be different from that on a real device.');
|
||||
const len = args.length;
|
||||
if (typeof args[len - 1] === 'function') {
|
||||
args[len - 1].call(this, paramMock.businessErrorMock);
|
||||
} else {
|
||||
return new Promise((resolve) => {
|
||||
resolve();
|
||||
});
|
||||
}
|
||||
},
|
||||
notifyInvisibleForms: function (...args) {
|
||||
console.warn('formHost.notifyInvisibleForms interface mocked in the Previewer. How this interface works on the' +
|
||||
' Previewer may be different from that on a real device.');
|
||||
const len = args.length;
|
||||
if (typeof args[len - 1] === 'function') {
|
||||
args[len - 1].call(this, paramMock.businessErrorMock);
|
||||
} else {
|
||||
return new Promise((resolve) => {
|
||||
resolve();
|
||||
});
|
||||
}
|
||||
},
|
||||
enableFormsUpdate: function (...args) {
|
||||
console.warn('formHost.enableFormsUpdate interface mocked in the Previewer. How this interface works on the' +
|
||||
' Previewer may be different from that on a real device.');
|
||||
const len = args.length;
|
||||
if (typeof args[len - 1] === 'function') {
|
||||
args[len - 1].call(this, paramMock.businessErrorMock);
|
||||
} else {
|
||||
return new Promise((resolve) => {
|
||||
resolve();
|
||||
});
|
||||
}
|
||||
},
|
||||
disableFormsUpdate: function (...args) {
|
||||
console.warn('formHost.disableFormsUpdate interface mocked in the Previewer. How this interface works on the' +
|
||||
' Previewer may be different from that on a real device.');
|
||||
const len = args.length;
|
||||
if (typeof args[len - 1] === 'function') {
|
||||
args[len - 1].call(this, paramMock.businessErrorMock);
|
||||
} else {
|
||||
return new Promise((resolve) => {
|
||||
resolve();
|
||||
});
|
||||
}
|
||||
},
|
||||
isSystemReady: function (...args) {
|
||||
console.warn('formHost.isSystemReady interface mocked in the Previewer. How this interface works on the' +
|
||||
' Previewer may be different from that on a real device.');
|
||||
const len = args.length;
|
||||
if (typeof args[len - 1] === 'function') {
|
||||
args[len - 1].call(this, paramMock.businessErrorMock);
|
||||
} else {
|
||||
return new Promise((resolve) => {
|
||||
resolve();
|
||||
});
|
||||
}
|
||||
},
|
||||
getAllFormsInfo: function (...args) {
|
||||
console.warn('formHost.getAllFormsInfo interface mocked in the Previewer. How this interface works on the' +
|
||||
' Previewer may be different from that on a real device.');
|
||||
const len = args.length;
|
||||
if (typeof args[len - 1] === 'function') {
|
||||
args[len - 1].call(this, paramMock.businessErrorMock, [FormInfo]);
|
||||
} else {
|
||||
return new Promise((resolve) => {
|
||||
resolve([FormInfo]);
|
||||
});
|
||||
}
|
||||
},
|
||||
getFormsInfo: function (...args) {
|
||||
console.warn('formHost.getFormsInfo interface mocked in the Previewer. How this interface works on the' +
|
||||
' Previewer may be different from that on a real device.');
|
||||
const len = args.length;
|
||||
if (typeof args[len - 1] === 'function') {
|
||||
args[len - 1].call(this, paramMock.businessErrorMock, [FormInfo]);
|
||||
} else {
|
||||
return new Promise((resolve) => {
|
||||
resolve([FormInfo]);
|
||||
});
|
||||
}
|
||||
},
|
||||
deleteInvalidForms: function (...args) {
|
||||
console.warn('formHost.deleteInvalidForms interface mocked in the Previewer. How this interface works on the' +
|
||||
' Previewer may be different from that on a real device.');
|
||||
const len = args.length;
|
||||
if (typeof args[len - 1] === 'function') {
|
||||
args[len - 1].call(this, paramMock.businessErrorMock, [paramMock.paramNumberMock]);
|
||||
} else {
|
||||
return new Promise((resolve) => {
|
||||
resolve([paramMock.paramNumberMock]);
|
||||
});
|
||||
}
|
||||
},
|
||||
acquireFormState: function (...args) {
|
||||
console.warn('formHost.acquireFormState interface mocked in the Previewer. How this interface works on the' +
|
||||
' Previewer may be different from that on a real device.');
|
||||
const len = args.length;
|
||||
if (typeof args[len - 1] === 'function') {
|
||||
args[len - 1].call(this, paramMock.businessErrorMock, FormStateInfo);
|
||||
} else {
|
||||
return new Promise((resolve) => {
|
||||
resolve(FormStateInfo);
|
||||
});
|
||||
}
|
||||
},
|
||||
on: function (...args) {
|
||||
console.warn("formHost.on interface mocked in the Previewer. How this interface works on the Previewer" +
|
||||
" may be different from that on a real device.")
|
||||
const len = args.length
|
||||
if (typeof args[len - 1] === 'function') {
|
||||
args[len - 1].call(this, paramMock.paramStringMock);
|
||||
}
|
||||
},
|
||||
off: function (...args) {
|
||||
console.warn("formHost.off interface mocked in the Previewer. How this interface works on the Previewer" +
|
||||
" may be different from that on a real device.")
|
||||
const len = args.length
|
||||
if (typeof args[len - 1] === 'function') {
|
||||
args[len - 1].call(this, paramMock.paramStringMock);
|
||||
}
|
||||
},
|
||||
notifyFormsVisible: function (...args) {
|
||||
console.warn('formHost.notifyFormsVisible interface mocked in the Previewer. How this interface works on the' +
|
||||
' Previewer may be different from that on a real device.');
|
||||
const len = args.length;
|
||||
if (typeof args[len - 1] === 'function') {
|
||||
args[len - 1].call(this, paramMock.businessErrorMock);
|
||||
} else {
|
||||
return new Promise((resolve) => {
|
||||
resolve();
|
||||
});
|
||||
}
|
||||
},
|
||||
notifyFormsEnableUpdate: function (...args) {
|
||||
console.warn('formHost.notifyFormsEnableUpdate interface mocked in the Previewer. How this interface works on the' +
|
||||
' Previewer may be different from that on a real device.');
|
||||
const len = args.length;
|
||||
if (typeof args[len - 1] === 'function') {
|
||||
args[len - 1].call(this, paramMock.businessErrorMock);
|
||||
} else {
|
||||
return new Promise((resolve) => {
|
||||
resolve();
|
||||
});
|
||||
}
|
||||
},
|
||||
}
|
||||
return formHost
|
||||
}
|
||||
@@ -0,0 +1,66 @@
|
||||
/*
|
||||
* Copyright (c) 2022 Huawei Device Co., Ltd.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
import { paramMock } from "../utils"
|
||||
import { WantClass } from "./ohos_application_Want"
|
||||
|
||||
export const FormInfo = {
|
||||
bundleName: '[PC preview] unknow bundleName',
|
||||
moduleName: '[PC preview] unknow moduleName',
|
||||
abilityName: '[PC preview] unknow abilityName',
|
||||
name: '[PC preview] unknow name',
|
||||
description: '[PC preview] unknow description',
|
||||
type: FormType,
|
||||
jsComponentName: '[PC preview] unknow jsComponentName',
|
||||
colorMode: ColorMode,
|
||||
isDefault: '[PC preview] unknow isDefault',
|
||||
updateEnabled: '[PC preview] unknow updateEnabled',
|
||||
formVisibleNotify: '[PC preview] unknow formVisibleNotify',
|
||||
relatedBundleName: '[PC preview] unknow relatedBundleName',
|
||||
scheduledUpdateTime: '[PC preview] unknow scheduledUpdateTime',
|
||||
formConfigAbility: '[PC preview] unknow formConfigAbility',
|
||||
updateDuration: '[PC preview] unknow updateDuration',
|
||||
defaultDimension: '[PC preview] unknow defaultDimension',
|
||||
supportDimensions: [paramMock.paramNumberMock],
|
||||
customizeData: {"key": paramMock.paramStringMock},
|
||||
}
|
||||
export const FormType = {
|
||||
JS: 1,
|
||||
}
|
||||
export const ColorMode = {
|
||||
MODE_AUTO: -1,
|
||||
MODE_DARK: 0,
|
||||
MODE_LIGHT: 1
|
||||
}
|
||||
export const FormStateInfo = {
|
||||
formState: FormState,
|
||||
want: new WantClass(),
|
||||
}
|
||||
export const FormState = {
|
||||
UNKNOWN: -1,
|
||||
DEFAULT: 0,
|
||||
READY: 1,
|
||||
}
|
||||
export const FormParam = {
|
||||
IDENTITY_KEY: "ohos.extra.param.key.form_identity",
|
||||
DIMENSION_KEY: "ohos.extra.param.key.form_dimension",
|
||||
NAME_KEY: "ohos.extra.param.key.form_name",
|
||||
MODULE_NAME_KEY: "ohos.extra.param.key.module_name",
|
||||
WIDTH_KEY: "ohos.extra.param.key.form_width",
|
||||
HEIGHT_KEY: "ohos.extra.param.key.form_height",
|
||||
TEMPORARY_KEY: "ohos.extra.param.key.form_temporary"
|
||||
}
|
||||
export const FormInfoFilter = {
|
||||
moduleName: '[PC preview] unknow moduleName',
|
||||
}
|
||||
@@ -13,44 +13,42 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
import { paramMock } from "../utils"
|
||||
import { FormInfo } from "./ohos_application_formInfo"
|
||||
|
||||
export function mockFormProvider() {
|
||||
const FormType = {
|
||||
JS: 1,
|
||||
}
|
||||
const ColorMode = {
|
||||
MODE_AUTO : -1,
|
||||
MODE_DARK : 0,
|
||||
MODE_LIGHT : 1,
|
||||
}
|
||||
// A mock version of formInfo.
|
||||
const FormInfoMock = {
|
||||
bundleName: '[PC preview] unknow bundleName',
|
||||
moduleName: '[PC preview] unknow moduleName',
|
||||
abilityName: '[PC preview] unknow abilityName',
|
||||
name: '[PC preview] unknow name',
|
||||
description: '[PC preview] unknow description',
|
||||
type: FormType,
|
||||
jsComponentName: '[PC preview] unknow jsComponentName',
|
||||
colorMode: ColorMode,
|
||||
isDefault: '[PC preview] unknow isDefault',
|
||||
updateEnabled: '[PC preview] unknow updateEnabled',
|
||||
formVisibleNotify: '[PC preview] unknow formVisibleNotify',
|
||||
relatedBundleName: '[PC preview] unknow relatedBundleName',
|
||||
scheduledUpdateTime: '[PC preview] unknow scheduledUpdateTime',
|
||||
formConfigAbility: '[PC preview] unknow formConfigAbility',
|
||||
updateDuration: '[PC preview] unknow updateDuration',
|
||||
defaultDimension: '[PC preview] unknow defaultDimension',
|
||||
supportDimensions: [paramMock.paramNumberMock],
|
||||
customizeData: {"key": paramMock.paramStringMock},
|
||||
}
|
||||
const formProvider = {
|
||||
setFormNextRefreshTime: function (...args) {
|
||||
console.warn('formProvider.setFormNextRefreshTime interface mocked in the Previewer. How this interface works on' +
|
||||
' the Previewer may be different from that on a real device.');
|
||||
const len = args.length;
|
||||
// callback
|
||||
if (typeof args[len - 1] === 'function') {
|
||||
args[len - 1].call(this, paramMock.businessErrorMock);
|
||||
} else {
|
||||
return new Promise((resolve) => {
|
||||
resolve();
|
||||
});
|
||||
}
|
||||
},
|
||||
updateForm: function (...args) {
|
||||
console.warn('formProvider.updateForm interface mocked in the Previewer. How this interface works on' +
|
||||
' the Previewer may be different from that on a real device.');
|
||||
const len = args.length;
|
||||
// callback
|
||||
if (typeof args[len - 1] === 'function') {
|
||||
args[len - 1].call(this, paramMock.businessErrorMock);
|
||||
} else {
|
||||
return new Promise((resolve) => {
|
||||
resolve();
|
||||
});
|
||||
}
|
||||
},
|
||||
getFormsInfo: function (...args) {
|
||||
console.warn('formProvider.getFormsInfo interface mocked in the Previewer. How this interface works on the' +
|
||||
' Previewer may be different from that on a real device.');
|
||||
const len = args.length;
|
||||
var array = new Array();
|
||||
array.push(FormInfoMock);
|
||||
array.push(FormInfo);
|
||||
// promise without option.
|
||||
if (len == 0) {
|
||||
return new Promise((resolve) => {
|
||||
|
||||
@@ -0,0 +1,27 @@
|
||||
/*
|
||||
* Copyright (c) 2022 Huawei Device Co., Ltd.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
export function mockTestRunner() {
|
||||
const TestRunner = {
|
||||
onPrepare: function () {
|
||||
console.warn('TestRunner.onPrepare interface mocked in the Previewer. How this interface works on the' +
|
||||
' Previewer may be different from that on a real device.');
|
||||
},
|
||||
onRun: function () {
|
||||
console.warn('TestRunner.onRun interface mocked in the Previewer. How this interface works on the' +
|
||||
' Previewer may be different from that on a real device.');
|
||||
},
|
||||
}
|
||||
return TestRunner;
|
||||
}
|
||||
@@ -202,7 +202,9 @@ export const Support = {
|
||||
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_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 commonEvent = {
|
||||
|
||||
@@ -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);
|
||||
});
|
||||
}
|
||||
},
|
||||
|
||||
@@ -596,147 +596,147 @@ export const Window = {
|
||||
},
|
||||
}
|
||||
|
||||
export function mockWindow() {
|
||||
export 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
|
||||
}
|
||||
|
||||
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
|
||||
}
|
||||
export function mockWindow() {
|
||||
return window
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user