!276 js mock框架调整

Merge pull request !276 from 周末/local_master
This commit is contained in:
openharmony_ci
2022-05-24 05:21:47 +00:00
committed by Gitee
134 changed files with 4501 additions and 3419 deletions
+1 -1
View File
@@ -14,7 +14,7 @@
*/
import { paramMock } from "./utils"
import { windowMock } from "./window"
import { windowMock } from "./napi/ohos_window"
const DataAbilityResultMock = {
uri: "[PC Preview] unknow uri",
@@ -1,34 +0,0 @@
/*
* Copyright (c) 2021 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import { paramMock } from "./utils"
export function mockBytrace() {
const bytrace = {
startTrace: function (...args) {
console.warn("bytrace.startTrace interface mocked in the Previewer. How this interface works on the" +
" Previewer may be different from that on a real device.")
},
finishTrace: function (...args) {
console.warn("bytrace.finishTrace interface mocked in the Previewer. How this interface works on the" +
" Previewer may be different from that on a real device.")
},
traceByValue: function (...args) {
console.warn("bytrace.traceByValue interface mocked in the Previewer. How this interface works on the" +
" Previewer may be different from that on a real device.")
}
}
return bytrace
}
+1 -85
View File
@@ -27,39 +27,14 @@ import {
import { mockAppAbilityManager } from './ohos/app'
import { mockBattery } from './battery'
import { mockBrightness } from './brightness'
import { mockBluetooth } from './bluetooth'
import { mockOhosBluetooth } from './ohos/bluetooth'
import { mockCall, mockData, mockRadio, mockSim, mockSMS, mockObserver } from './telephony'
import { mockBundleState } from './ohos/bundleState'
import { mockCipher } from './cipher'
import { mockDataStorage } from './data'
import { mockDeviceInfo } from './deviceInfo'
import { mockDistributedSchedule } from './distributedSchedule'
import { mockDocument } from './document'
import { mockFetch } from './fetch'
import { mockFeatureAbility } from './featureAbility'
import { mockFile } from './file'
import { mockGeolocation } from './geolocation'
import { mockInputMethod } from './inputMethod'
import { mockInputMethodEngine } from './inputMethodEngine'
import { mockNetwork } from './network'
import { mockOhosNfc } from './ohos/nfc'
import { mockNotification } from './notification'
import { mockCommonEvent } from './ohos/commonEvent'
import { mockWantAgent } from './ohos/wantAgent'
import { mockOhosBatteryinfo } from './batteryinfo'
import { mockOhosRequest } from './ohos/request'
import { mockPasteBoard } from './ohos/pasteboard'
import { mockSystemTime } from './ohos/systemTime'
import { mockSystemTimer } from './ohos/systemTimer'
import { mockWallpaper } from './ohos/wallpaper'
import { mockReminderAgent } from './ohos/reminderAgent'
import { mockRequest } from './request'
import { mockResourceManager } from './resourceManager'
import { mockSensor } from './sensor'
import { mockStorage } from './storage'
import { mockStorageInfoManager } from './ohos/storageInfoManager'
@@ -67,28 +42,14 @@ import { mockSystemPackage } from './systemPackage'
import { mockUserauth } from './userIAM'
import { mockVibrator } from './vibrator'
import { mockWebSocket, mockHttp, mockMdns, mockSocket, mockHotspot, mockStatistics, mockConnection } from './net'
import { mockWindow } from './window'
import { mockRequireNapiFun } from './napi'
import { mockAccessibility } from './accessibility'
import { mockAI } from './ai'
import { mockDisplay } from './display'
import { mockDeviceManager } from './deviceManager'
import { mockScreenshot } from './screenshot'
import { mockContact } from './contact'
import { mockScreenLock } from "./screenLock"
import { mockAppAccount } from './ohos/appAccount'
import { mockOsAccount } from './ohos/osAccount'
import { mockOhosGeolocation } from './ohos/geolocation'
import { mockInputMonitor } from './ohos/inputMonitor'
import { mockUserIAMUserAuth } from './ohos/userIAMuserAuth.js'
import { mockBundleManager } from './ohos/bundleManager'
import { mockPackageManager } from './ohos/packageManager'
import { mockZlib } from './napi/zlib'
import { mockZlib } from './napi/ohos_zlib'
import { mockCalendar } from "./calendar"
import { mockHuks } from "./huks"
export function mockSystemPlugin() {
global.regeneratorRuntime = regeneratorRuntime
@@ -98,54 +59,20 @@ export function mockSystemPlugin() {
mockNotification()
mockCommonEvent()
mockWantAgent()
mockFetch()
mockRequest()
mockStorage()
mockFile()
mockVibrator()
mockSensor()
mockGeolocation()
mockNetwork()
mockBrightness()
mockBattery()
mockSystemPackage()
mockFeatureAbility()
mockBluetooth()
mockOhosBluetooth()
mockCipher()
mockOhosBatteryinfo()
mockUserauth()
mockDistributedSchedule()
mockDocument()
mockPasteBoard()
mockSystemTime()
mockSystemTimer()
mockWallpaper()
mockInputMethod()
mockInputMethodEngine()
mockOhosRequest()
mockCall()
mockData()
mockRadio()
mockSim()
mockSMS()
mockObserver()
mockWebSocket()
mockHttp()
mockMdns()
mockSocket()
mockHotspot()
mockStatistics()
mockConnection()
mockDeviceInfo()
mockResourceManager()
mockOhosNfc()
mockDataStorage()
mockWindow()
mockAbilityFeatureAbility()
mockAbilityContinuationRegisterManager()
mockReminderAgent()
mockRequireNapiFun()
mockAbilityDataUriUtils()
mockAccessibility()
@@ -154,22 +81,11 @@ export function mockSystemPlugin() {
mockAbilityAbilityAgent()
mockAbilityFormBindingData()
mockAI()
mockDisplay()
mockDeviceManager()
mockScreenshot()
mockStorageInfoManager()
mockContact()
mockScreenLock()
mockAppAbilityManager()
mockAppAccount()
mockOsAccount()
mockBundleState()
mockOhosGeolocation()
mockUserIAMUserAuth()
mockInputMonitor()
mockBundleManager()
mockPackageManager()
mockZlib()
mockCalendar()
mockHuks()
}
@@ -14,8 +14,8 @@
*/
import { paramMock } from "../../utils"
import { MessageParcelClass } from "../rpc"
import { ContextClass } from "../applicationServiceExtAbility"
import { MessageParcelClass } from "../ohos_rpc"
import { ContextClass } from "../ohos_application_ServiceExtAbility"
const ModuleInfoMock = {
moduleName: '[PC preview] unknow moduleName',
@@ -1,46 +0,0 @@
/*
* 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 mockDistributedObject() {
const DistributedObject = {
setSessionId: function (...args) {
console.warn("DistributedObject.setSessionId interface mocked in the Previewer." +
" How this interface works on the Previewer may be different from that on a real device.")
},
on: function (...args) {
console.warn("DistributedObject.on interface mocked in the Previewer. How this interface works" +
" on the Previewer may be different from that on a real device.")
},
off: function (...args) {
console.warn("DistributedObject.off interface mocked in the Previewer. How this interface works" +
" on the Previewer may be different from that on a real device.")
}
};
const distributedObjectMock = {
createDistributedObject: function (...args) {
console.warn("distributedObject.createDistributedObject interface mocked in the Previewer." +
" How this interface works on the Previewer may be different from that on a real device.");
return DistributedObject;
},
genSessionId: function (...args) {
console.warn("distributedObject.genSessionId interface mocked in the Previewer." +
" How this interface works on the Previewer may be different from that on a real device.");
return 'just test';
}
};
return distributedObjectMock;
}
+205 -88
View File
@@ -13,99 +13,218 @@
* limitations under the License.
*/
import { mockSystemParameter } from './systemParameter'
import { mockAbility } from './applicationAbility'
import { mockFormExtension } from './applicationFormExtension'
import { mockServiceExtensionAbility } from './applicationServiceExtensionAbility'
import { mockAbilityStage } from './applicationAbilityStage'
import { mockFormBindingData } from './applicationFormBindingData'
import { mockAbilityManager } from './applicationAbilityManager'
import { mockAppManager } from './applicationAppManager'
import { mockDataShareExtensionAbility } from './applicationDataShareExtensionAbility'
import { mockMissionManager } from "./applicationMissionManager"
import { mockServiceExtAbility } from "./applicationServiceExtAbility"
import { mockUriPermissionManager } from "./applicationUriPermissionManager"
import { mockCommonEvent } from './commonEvent'
import { mockNotification } from './notification'
import { mockFileio } from './fileio'
import { mockWorker } from './worker'
import { mockUtil } from './util'
import { mockPower } from './power'
import { mockRunninglock } from './runninglock'
import { mockThermal } from './thermal'
import { mockBatteryStatistics } from './batteryStatistics'
import { mockIntl } from './intl'
import { mockI18N } from './i18n'
import { mockRpc } from './rpc'
import { mockBytrace } from './bytrace'
import { mockSystemParameter } from './ohos_systemparameter'
import { mockAbility } from './ohos_application_Ability'
import { mockFormExtension } from './ohos_application_FormExtension'
import { mockServiceExtensionAbility } from './ohos_application_ServiceExtensionAbility'
import { mockAbilityStage } from './ohos_application_AbilityStage'
import { mockFormBindingData } from './ohos_application_formBindingData'
import { mockAbilityManager } from './ohos_application_abilityManager'
import { mockAppManager } from './ohos_application_appManager'
import { mockDataShareExtensionAbility } from './ohos_application_DataShareExtensionAbility'
import { mockMissionManager } from "./ohos_application_missionManager"
import { mockServiceExtAbility } from "./ohos_application_ServiceExtAbility"
import { mockUriPermissionManager } from "./ohos_application_uriPermissionManager"
import { mockCommonEvent } from './ohos_commonEvent'
import { mockNotification } from './ohos_notification'
import { mockFileio } from './ohos_fileio'
import { mockWorker } from './ohos_worker'
import { mockUtil } from './ohos_util'
import { mockPower } from './ohos_power'
import { mockRunninglock } from './ohos_runninglock'
import { mockThermal } from './ohos_thermal'
import { mockBatteryStatistics } from './ohos_batteryStatistics'
import { mockIntl } from './ohos_intl'
import { mockI18N } from './ohos_i18n'
import { mockRpc } from './ohos_rpc'
import { mockwebgl } from './webgl'
import { mockwebgl2 } from './webgl2'
import { mockProcess } from './process'
import { mockUrl } from './url'
import { mockHiAppEvent } from './hiAppEvent'
import { mockHilog } from './hilog'
import { mockProcess } from './ohos_process'
import { mockUrl } from './ohos_url'
import { mockHiAppEvent } from './ohos_hiAppEvent'
import { mockHilog } from './ohos_hilog'
import { mockTv } from './tv'
import { mockDtv } from './dtv'
import { mockDistributedAccount } from './distributedAccount'
import { mockEmitter } from './emitter'
import { mockDistributedData } from './distributedData'
import { mockDistributedObject } from './distributedDataObject'
import { mockDataAbility } from './dataAbility'
import { mockStorage } from './storage'
import { mockRdb } from './rdb'
import { mockDataShare } from './dataShare'
import { mockInputDevice } from './inputDevice'
import { mockVibrator } from './vibrator'
import { mockSensor } from './sensor'
import { mockWifi } from './wifi'
import { mockUsb } from './usb'
import { mockBundle } from './bundle'
import { mockInnerBundle } from './innerBundleManager'
import { mockUri } from './uri'
import { mockXml } from './xml'
import { mockConvertXml } from './convertxml'
import { mockStatfs } from './statfs'
import { mockFileManager } from "./filemanager"
import { mockEnvironment } from "./environment"
import { mockStorageStatistics } from "./storageStatistics"
import { mockVolumeManager } from "./volumeManager"
import { mockSettings } from './settings'
import { mockAbilityAccessCtrl } from './abilityAccessCtrl'
import { mockConfigPolicy } from './configPolicy'
import { mockUpdate } from './update'
import { mockBackgroundTaskManager } from './backgroundTaskManager'
import { mockSecurityLabel } from './securitylabel'
import { mockWorkScheduler } from './workScheduler'
import { mockWorkSchedulerExtensionAbility } from './WorkSchedulerExtensionAbility'
import { mockUserAuth } from './userAuth'
import { mockArrayList } from './arraylist'
import { mockDeque } from './deque'
import { mockHashMap } from './hashmap'
import { mockHashSet } from './hashset'
import { mockLightWeightMap } from './lightweightmap'
import { mockLightWeightSet } from './lightweightset'
import { mockLinkedList } from './linkedlist'
import { mockList } from './list'
import { mockPlainArray } from './plainarray'
import { mockQueue } from './queue'
import { mockStack } from './stack'
import { mockTreeMap } from './treemap'
import { mockTreeSet } from './treeset'
import { mockVector } from './vector'
import { mockMultimediaCamera } from './multimediaCamera'
import { mockMultimediaAudio } from './multimediaAudio'
import { mockMultimediaImage } from './multimediaImage'
import { mockMultimediaMedia } from './multimediaMedia'
import { mockMultimediaMediaLibrary } from './multimediaMediaLibrary'
import { mockDistributedAccount } from './ohos_account_distributedAccount'
import { mockEmitter } from './ohos_events_emitter'
import { mockDistributedData } from './ohos_data_distributedData'
import { mockDistributedObject } from './ohos_data_distributedDataObject'
import { mockDataAbility } from './ohos_data_dataAbility'
import { mockStorage } from './system_storage'
import { mockRdb } from './ohos_data_rdb'
import { mockDataShare } from './ohos_data_dataShare'
import { mockInputDevice } from './ohos_multimodalInput_inputDevice'
import { mockVibrator } from './ohos_vibrator'
import { mockSensor } from './ohos_sensor'
import { mockWifi } from './ohos_wifi'
import { mockUsb } from './ohos_usb'
import { mockBundle } from './ohos_bundle'
import { mockInnerBundle } from './ohos_bundle_innerBundleManager'
import { mockUri } from './ohos_uri'
import { mockXml } from './ohos_xml'
import { mockConvertXml } from './ohos_convertxml'
import { mockStatfs } from './ohos_statfs'
import { mockFileManager } from "./ohos_fileManager"
import { mockEnvironment } from "./ohos_environment"
import { mockStorageStatistics } from "./ohos_storageStatistics"
import { mockVolumeManager } from "./ohos_volumeManager"
import { mockSettings } from './ohos_settings'
import { mockAbilityAccessCtrl } from './ohos_abilityAccessCtrl'
import { mockConfigPolicy } from './ohos_configPolicy'
import { mockUpdate } from './ohos_update'
import { mockBackgroundTaskManager } from './ohos_backgroundTaskManager'
import { mockSecurityLabel } from './ohos_securitylabel'
import { mockWorkScheduler } from './ohos_workScheduler'
import { mockWorkSchedulerExtensionAbility } from './ohos_WorkSchedulerExtensionAbility'
import { mockUserAuth } from './ohos_userIAM_userAuth'
import { mockArrayList } from './ohos_util_Arraylist'
import { mockDeque } from './ohos_util_Deque'
import { mockHashMap } from './ohos_util_HashMap'
import { mockHashSet } from './ohos_util_HashSet'
import { mockLightWeightMap } from './ohos_util_LightWeightMap'
import { mockLightWeightSet } from './ohos_util_LightWeightSet'
import { mockLinkedList } from './ohos_util_LinkedList'
import { mockList } from './ohos_util_List'
import { mockPlainArray } from './ohos_util_PlainArray'
import { mockQueue } from './ohos_util_Queue'
import { mockStack } from './ohos_util_Stack'
import { mockTreeMap } from './ohos_util_TreeMap'
import { mockTreeSet } from './ohos_util_TreeSet'
import { mockVector } from './ohos_util_Vector'
import { mockMultimediaCamera } from './ohos_multimedia_camera'
import { mockMultimediaAudio } from './ohos_multimedia_audio'
import { mockMultimediaImage } from './ohos_multimedia_image'
import { mockMultimediaMedia } from './ohos_multimedia_media'
import { mockMultimediaMediaLibrary } from './ohos_multimedia_mediaLibrary'
import { mockOhosBatteryinfo } from './ohos_batteryInfo'
import { mockBluetooth } from './ohos_bluetooth'
import { mockBrightness } from './ohos_brightness'
import { mockBytrace } from './ohos_bytrace'
import { mockCipher } from './system_cipher'
import { mockContact } from './ohos_contact'
import { mockDataStorage } from './ohos_data_Storage'
import { mockDeviceInfo } from './ohos_deviceInfo'
import { mockDeviceManager } from './ohos_distributedHardware_deviceManager'
import { mockDisplay } from './ohos_display'
import { mockHuks } from './ohos_security_huks'
import { mockInputMethod } from './ohos_inputmethod'
import { mockInputMethodEngine } from './ohos_inputmethodengine'
import { mockConnection } from './ohos_net_connection'
import { mockHttp } from './ohos_net_http'
import { mockSocket } from './ohos_net_socket'
import { mockWebSocket } from './ohos_net_webSocket'
import { mockNetwork } from './ohos_network'
import { mockNfcCardEmulation } from './ohos_nfc_cardEmulation'
import { mockController } from './ohos_nfc_controller'
import { mockTag } from './ohos_nfc_tag'
import { mockPasteBoard } from './ohos_pasteboard'
import { mockRequest } from './ohos_request'
import { mockScreenLock } from './ohos_screenLock'
import { mockCall } from './ohos_telephony_call'
import { mockData } from './ohos_telephony_data'
import { mockObserver } from './ohos_telephony_observer'
import { mockRadio } from './ohos_telephony_radio'
import { mockSim } from './ohos_telephony_sim'
import { mockSMS } from './ohos_telephony_sms'
import { mockWindow } from './ohos_window'
import { mockAppAccount } from './ohos_account_appAccount'
import { mockOhosGeolocation } from './ohos_geolocation'
import { mockInputMonitor } from './ohos_multimodalInput_inputMonitor'
import { mockOsAccount } from './ohos_account_osAccount'
import { mockReminderAgent } from './ohos_reminderAgent'
import { mockSystemTime } from './ohos_systemTime'
import { mockSystemTimer } from './ohos_systemTimer'
import { mockWallpaper } from './ohos_wallpaper'
import { mockWantAgent } from './ohos_wantAgent'
import { mockScreenshot } from './ohos_screenshot'
export function mockRequireNapiFun() {
global.requireNapi = function (...args) {
switch (args[0]) {
case "screenshot":
return mockScreenshot();
case "WantAgent":
return mockWantAgent();
case "wallpaper":
return mockWallpaper();
case "systemTimer":
return mockSystemTimer();
case "systemTime":
return mockSystemTime();
case "reminderAgent":
return mockReminderAgent();
case "account.osAccount":
return mockOsAccount();
case "multimodalInput.inputMonitor":
return mockInputMonitor();
case "geolocation":
return mockOhosGeolocation();
case "account.appAccount":
return mockAppAccount();
case "window":
return mockWindow();
case "telephony.call":
return mockCall();
case "telephony.data":
return mockData();
case "telephony.observer":
return mockObserver();
case "telephony.radio":
return mockRadio();
case "telephony.sim":
return mockSim();
case "telephony.sms":
return mockSMS();
case "pasteboard":
return mockPasteBoard();
case "request":
return mockRequest();
case "screenLock":
return mockScreenLock();
case "nfc.cardEmulation":
return mockNfcCardEmulation();
case "nfc.controller":
return mockController();
case "nfc.tag":
return mockTag();
case "network":
return mockNetwork();
case "net.connection":
return mockConnection();
case "net.http":
return mockHttp();
case "net.socket":
return mockSocket();
case "net.webSocket":
return mockWebSocket();
case "inputmethodengine":
return mockInputMethodEngine();
case "inputmethod":
return mockInputMethod();
case "security.huks":
return mockHuks();
case "display":
return mockDisplay();
case "distributedHardware.deviceManager":
return mockDeviceManager();
case "deviceInfo":
return mockDeviceInfo();
case "data.storage":
return mockDataStorage();
case "contact":
return mockContact();
case "cipher":
return mockCipher();
case "bytrace":
return mockBytrace();
case "brightness":
return mockBrightness();
case "bluetooth":
return mockBluetooth();
case "batteryInfo":
return mockOhosBatteryinfo();
case "systemParameter":
return mockSystemParameter();
case "application.Ability":
case "11.Ability":
return mockAbility();
case "application.FormExtension":
return mockFormExtension();
@@ -157,8 +276,6 @@ export function mockRequireNapiFun() {
return mockwebgl2();
case "process":
return mockProcess();
case "bytrace":
return mockBytrace();
case "url":
return mockUrl();
case "hiAppEvent":
@@ -232,7 +349,7 @@ export function mockRequireNapiFun() {
case "WorkSchedulerExtensionAbility":
return mockWorkSchedulerExtensionAbility();
case "userIAM.userAuth":
return mockUserAuth();
return mockUserAuth();
case "util.ArrayList":
return mockArrayList();
case "util.Deque":
@@ -262,7 +379,7 @@ export function mockRequireNapiFun() {
case "util.Vector":
return mockVector();
case "multimedia.mediaLibrary":
return mockMultimediaMediaLibrary();
return mockMultimediaMediaLibrary();
case "multimedia.media":
return mockMultimediaMedia();
case "multimedia.image":
@@ -1,438 +1,437 @@
/*
* Copyright (c) 2021 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import { paramMock } from "../utils"
export function mockAppAccount() {
const appAccountInfoMock = {
owner: "[PC Preview] unknown owner",
name: "[PC Preview] unknown name"
};
const OAuthTokenInfoMock = {
authType: "[PC preview] unknown authType",
token: "[PC preview] unknown token"
};
const AuthenticatorInfoMock = {
owner: "[PC preview] unknown owner",
iconId: "[PC preview] unknown iconId",
labelId: "[PC preview] unknown labelId",
};
const appAccountManagerMock = {
addAccount: function (...args) {
console.warn("AppAccountManager.addAccount interface mocked 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();
})
}
},
addAccountImplicitly: function (...args) {
console.warn("AppAccountManager.addAccountImplicitly interface mocked 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, AuthenticatorCallbackMock);
}
},
deleteAccount: function (...args) {
console.warn("AppAccountManager.deleteAccount interface mocked 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();
})
}
},
disableAppAccess: function (...args) {
console.warn("AppAccountManager.disableAppAccess interface mocked 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();
})
}
},
enableAppAccess: function (...args) {
console.warn("AppAccountManager.enableAppAccess interface mocked 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();
})
}
},
checkAppAccountSyncEnable: function (...args) {
console.warn("AppAccountManager.checkAppAccountSyncEnable interface mocked 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);
})
}
},
setAccountCredential: function (...args) {
console.warn("AppAccountManager.setAccountCredential interface mocked 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();
})
}
},
setAccountExtraInfo: function (...args) {
console.warn("AppAccountManager.setAccountExtraInfo interface mocked 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();
})
}
},
setAppAccountSyncEnable: function (...args) {
console.warn("AppAccountManager.setAppAccountSyncEnable interface mocked 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();
})
}
},
setAssociatedData: function (...args) {
console.warn("AppAccountManager.setAssociatedData interface mocked 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();
})
}
},
getAllAccessibleAccounts: function (...args) {
console.warn("AppAccountManager.getAllAccessibleAccounts interface mocked in the Previewer. " +
"How this interface works on the Previewer may be different from that on a real device.")
var appAccountInfoArrayMock = new Array();
appAccountInfoArrayMock.push(appAccountInfoMock);
const len = args.length
if (len > 0 && typeof args[len - 1] === 'function') {
args[len - 1].call(this, paramMock.businessErrorMock, appAccountInfoArrayMock);
} else {
return new Promise((resolve, reject) => {
resolve(appAccountInfoArrayMock);
})
}
},
getAllAccounts: function (...args) {
console.warn("AppAccountManager.getAllAccounts interface mocked in the Previewer. " +
"How this interface works on the Previewer may be different from that on a real device.")
var appAccountInfoArrayMock = new Array();
appAccountInfoArrayMock.push(appAccountInfoMock);
const len = args.length
if (len > 0 && typeof args[len - 1] === 'function') {
args[len - 1].call(this, paramMock.businessErrorMock, appAccountInfoArrayMock);
} else {
return new Promise((resolve, reject) => {
resolve(appAccountInfoArrayMock);
})
}
},
getAccountCredential: function (...args) {
console.warn("AppAccountManager.getAccountCredential interface mocked 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);
})
}
},
getAccountExtraInfo: function (...args) {
console.warn("AppAccountManager.getAccountExtraInfo interface mocked 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);
})
}
},
getAssociatedData: function (...args) {
console.warn("AppAccountManager.getAssociatedData interface mocked 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);
})
}
},
on: function (...args) {
console.warn("AppAccountManager.on interface mocked in the Previewer. " +
"How this interface works on the Previewer may be different from that on a real device.")
var appAccountInfoArrayMock = new Array();
appAccountInfoArrayMock.push(appAccountInfoMock);
const len = args.length
if (len > 0 && typeof args[len - 1] === 'function') {
args[len - 1].call(this, appAccountInfoArrayMock);
} else {
return new Promise((resolve, reject) => {
resolve(appAccountInfoArrayMock);
})
}
},
off: function (...args) {
console.warn("AppAccountManager.off interface mocked in the Previewer. " +
"How this interface works on the Previewer may be different from that on a real device.")
var appAccountInfoArrayMock = new Array();
appAccountInfoArrayMock.push(appAccountInfoMock);
const len = args.length
if (len > 0 && typeof args[len - 1] === 'function') {
args[len - 1].call(this, appAccountInfoArrayMock);
} else {
return new Promise((resolve, reject) => {
resolve(appAccountInfoArrayMock);
})
}
},
authenticate: function (...args) {
console.warn("AppAccountManager.authenticate interface mocked 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, AuthenticatorCallbackMock);
}
},
getOAuthToken: function (...args) {
console.warn("AppAccountManager.getOAuthToken interface mocked 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)
})
}
},
setOAuthToken: function (...args) {
console.warn("AppAccountManager.setOAuthToken interface mocked 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()
})
}
},
deleteOAuthToken: function (...args) {
console.warn("AppAccountManager.deleteOAuthToken interface mocked 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()
})
}
},
setOAuthTokenVisibility: function (...args) {
console.warn("AppAccountManager.setOAuthTokenVisibility interface mocked 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()
})
}
},
checkOAuthTokenVisibility: function (...args) {
console.warn("AppAccountManager.checkOAuthTokenVisibility interface mocked 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()
})
}
},
getAllOAuthTokens: function (...args) {
console.warn("AppAccountManager.getAllOAuthTokens interface mocked 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 Array(OAuthTokenInfoMock));
} else {
return new Promise((resolve, reject) => {
resolve(new Array(OAuthTokenInfoMock))
})
}
},
getOAuthList: function (...args) {
console.warn("AppAccountManager.getOAuthList interface mocked 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 Array(paramMock.paramStringMock));
} else {
return new Promise((resolve, reject) => {
resolve(new Array(paramMock.paramStringMock))
})
}
},
getAuthenticatorCallback: function (...args) {
console.warn("AppAccountManager.getAuthenticatorCallback interface mocked 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, AuthenticatorCallbackMock);
} else {
return new Promise((resolve, reject) => {
resolve(AuthenticatorCallbackMock)
})
}
},
getAuthenticatorInfo: function (...args) {
console.warn("AppAccountManager.getAuthenticatorInfo interface mocked 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, AuthenticatorInfoMock);
} else {
return new Promise((resolve, reject) => {
resolve(AuthenticatorInfoMock)
})
}
}
};
const AuthenticatorCallbackMock = {
onResult: function (...args) {
console.warn("AuthenticatorCallback.onResult interface mocked in the Previewer. " +
"How this interface works on the Previewer may be different from that on a real device.")
},
onRequestRedirected: function (...args) {
console.warn("AuthenticatorCallback.onRequestRedirected interface mocked in the Previewer. " +
"How this interface works on the Previewer may be different from that on a real device.")
}
};
const AuthenticatorClass = class Authenticator {
constructor() {
console.warn("appAccount.Authenticator constructor interface mocked in the Previewer. " +
"How this interface works on the Previewer may be different from that on a real device.")
this.addAccountImplicitly = function (...args) {
console.warn("Authenticator.addAccountImplicitly interface mocked 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, AuthenticatorCallbackMock);
}
};
this.authenticate = function (...args) {
console.warn("Authenticator.authenticate interface mocked 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, AuthenticatorCallbackMock);
}
};
}
};
const ConstantsMock = {
ACTION_ADD_ACCOUNT_IMPLICITLY: '[PC preview] unknow string',
ACTION_AUTHENTICATE: '[PC preview] unknow string',
KEY_NAME: '[PC preview] unknow string',
KEY_OWNER: '[PC preview] unknow string',
KEY_TOKEN: '[PC preview] unknow string',
KEY_ACTION: '[PC preview] unknow string',
KEY_AUTH_TYPE: '[PC preview] unknow string',
KEY_SESSION_ID: '[PC preview] unknow string',
KEY_CALLER_PID: '[PC preview] unknow string',
KEY_CALLER_UID: '[PC preview] unknow string',
KEY_CALLER_BUNDLE_NAME: '[PC preview] unknow string'
};
const ResultCodeMock = {
SUCCESS: '[PC preview] unknow resultCode',
ERROR_ACCOUNT_NOT_EXIST: '[PC preview] unknow resultCode',
ERROR_APP_ACCOUNT_SERVICE_EXCEPTION: '[PC preview] unknow resultCode',
ERROR_INVALID_PASSWORD: '[PC preview] unknow resultCode',
ERROR_INVALID_REQUEST: '[PC preview] unknow resultCode',
ERROR_INVALID_RESPONSE: '[PC preview] unknow resultCode',
ERROR_NETWORK_EXCEPTION: '[PC preview] unknow resultCode',
ERROR_OAUTH_AUTHENTICATOR_NOT_EXIST: '[PC preview] unknow resultCode',
ERROR_OAUTH_CANCELED: '[PC preview] unknow resultCode',
ERROR_OAUTH_LIST_TOO_LARGE: '[PC preview] unknow resultCode',
ERROR_OAUTH_SERVICE_BUSY: '[PC preview] unknow resultCode',
ERROR_OAUTH_SERVICE_EXCEPTION: '[PC preview] unknow resultCode',
ERROR_OAUTH_SESSION_NOT_EXIST: '[PC preview] unknow resultCode',
ERROR_OAUTH_TIMEOUT: '[PC preview] unknow resultCode',
ERROR_OAUTH_TOKEN_NOT_EXIST: '[PC preview] unknow resultCode',
ERROR_OAUTH_TOKEN_TOO_MANY: '[PC preview] unknow resultCode',
ERROR_OAUTH_UNSUPPORT_ACTION: '[PC preview] unknow resultCode',
ERROR_OAUTH_UNSUPPORT_AUTH_TYPE: '[PC preview] unknow resultCode',
ERROR_PERMISSION_DENIED: '[PC preview] unknow resultCode'
};
global.ohosplugin.account = global.ohosplugin.account || {};
global.ohosplugin.account.appAccount = {
createAppAccountManager: function (...args) {
console.warn("appAccount.createAppAccountManager interface mocked in the Previewer. " +
"How this interface works on the Previewer may be different from that on a real device.")
return appAccountManagerMock;
},
AuthenticatorCallback:AuthenticatorCallbackMock,
Authenticator:AuthenticatorClass,
Constants:ConstantsMock,
ResultCode:ResultCodeMock,
}
/*
* Copyright (c) 2021 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import { paramMock } from "../utils"
export function mockAppAccount() {
const appAccountInfoMock = {
owner: "[PC Preview] unknown owner",
name: "[PC Preview] unknown name"
};
const OAuthTokenInfoMock = {
authType: "[PC preview] unknown authType",
token: "[PC preview] unknown token"
};
const AuthenticatorInfoMock = {
owner: "[PC preview] unknown owner",
iconId: "[PC preview] unknown iconId",
labelId: "[PC preview] unknown labelId",
};
const appAccountManagerMock = {
addAccount: function (...args) {
console.warn("AppAccountManager.addAccount interface mocked 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();
})
}
},
addAccountImplicitly: function (...args) {
console.warn("AppAccountManager.addAccountImplicitly interface mocked 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, AuthenticatorCallbackMock);
}
},
deleteAccount: function (...args) {
console.warn("AppAccountManager.deleteAccount interface mocked 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();
})
}
},
disableAppAccess: function (...args) {
console.warn("AppAccountManager.disableAppAccess interface mocked 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();
})
}
},
enableAppAccess: function (...args) {
console.warn("AppAccountManager.enableAppAccess interface mocked 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();
})
}
},
checkAppAccountSyncEnable: function (...args) {
console.warn("AppAccountManager.checkAppAccountSyncEnable interface mocked 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);
})
}
},
setAccountCredential: function (...args) {
console.warn("AppAccountManager.setAccountCredential interface mocked 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();
})
}
},
setAccountExtraInfo: function (...args) {
console.warn("AppAccountManager.setAccountExtraInfo interface mocked 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();
})
}
},
setAppAccountSyncEnable: function (...args) {
console.warn("AppAccountManager.setAppAccountSyncEnable interface mocked 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();
})
}
},
setAssociatedData: function (...args) {
console.warn("AppAccountManager.setAssociatedData interface mocked 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();
})
}
},
getAllAccessibleAccounts: function (...args) {
console.warn("AppAccountManager.getAllAccessibleAccounts interface mocked in the Previewer. " +
"How this interface works on the Previewer may be different from that on a real device.")
var appAccountInfoArrayMock = new Array();
appAccountInfoArrayMock.push(appAccountInfoMock);
const len = args.length
if (len > 0 && typeof args[len - 1] === 'function') {
args[len - 1].call(this, paramMock.businessErrorMock, appAccountInfoArrayMock);
} else {
return new Promise((resolve, reject) => {
resolve(appAccountInfoArrayMock);
})
}
},
getAllAccounts: function (...args) {
console.warn("AppAccountManager.getAllAccounts interface mocked in the Previewer. " +
"How this interface works on the Previewer may be different from that on a real device.")
var appAccountInfoArrayMock = new Array();
appAccountInfoArrayMock.push(appAccountInfoMock);
const len = args.length
if (len > 0 && typeof args[len - 1] === 'function') {
args[len - 1].call(this, paramMock.businessErrorMock, appAccountInfoArrayMock);
} else {
return new Promise((resolve, reject) => {
resolve(appAccountInfoArrayMock);
})
}
},
getAccountCredential: function (...args) {
console.warn("AppAccountManager.getAccountCredential interface mocked 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);
})
}
},
getAccountExtraInfo: function (...args) {
console.warn("AppAccountManager.getAccountExtraInfo interface mocked 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);
})
}
},
getAssociatedData: function (...args) {
console.warn("AppAccountManager.getAssociatedData interface mocked 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);
})
}
},
on: function (...args) {
console.warn("AppAccountManager.on interface mocked in the Previewer. " +
"How this interface works on the Previewer may be different from that on a real device.")
var appAccountInfoArrayMock = new Array();
appAccountInfoArrayMock.push(appAccountInfoMock);
const len = args.length
if (len > 0 && typeof args[len - 1] === 'function') {
args[len - 1].call(this, appAccountInfoArrayMock);
} else {
return new Promise((resolve, reject) => {
resolve(appAccountInfoArrayMock);
})
}
},
off: function (...args) {
console.warn("AppAccountManager.off interface mocked in the Previewer. " +
"How this interface works on the Previewer may be different from that on a real device.")
var appAccountInfoArrayMock = new Array();
appAccountInfoArrayMock.push(appAccountInfoMock);
const len = args.length
if (len > 0 && typeof args[len - 1] === 'function') {
args[len - 1].call(this, appAccountInfoArrayMock);
} else {
return new Promise((resolve, reject) => {
resolve(appAccountInfoArrayMock);
})
}
},
authenticate: function (...args) {
console.warn("AppAccountManager.authenticate interface mocked 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, AuthenticatorCallbackMock);
}
},
getOAuthToken: function (...args) {
console.warn("AppAccountManager.getOAuthToken interface mocked 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)
})
}
},
setOAuthToken: function (...args) {
console.warn("AppAccountManager.setOAuthToken interface mocked 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()
})
}
},
deleteOAuthToken: function (...args) {
console.warn("AppAccountManager.deleteOAuthToken interface mocked 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()
})
}
},
setOAuthTokenVisibility: function (...args) {
console.warn("AppAccountManager.setOAuthTokenVisibility interface mocked 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()
})
}
},
checkOAuthTokenVisibility: function (...args) {
console.warn("AppAccountManager.checkOAuthTokenVisibility interface mocked 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()
})
}
},
getAllOAuthTokens: function (...args) {
console.warn("AppAccountManager.getAllOAuthTokens interface mocked 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 Array(OAuthTokenInfoMock));
} else {
return new Promise((resolve, reject) => {
resolve(new Array(OAuthTokenInfoMock))
})
}
},
getOAuthList: function (...args) {
console.warn("AppAccountManager.getOAuthList interface mocked 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 Array(paramMock.paramStringMock));
} else {
return new Promise((resolve, reject) => {
resolve(new Array(paramMock.paramStringMock))
})
}
},
getAuthenticatorCallback: function (...args) {
console.warn("AppAccountManager.getAuthenticatorCallback interface mocked 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, AuthenticatorCallbackMock);
} else {
return new Promise((resolve, reject) => {
resolve(AuthenticatorCallbackMock)
})
}
},
getAuthenticatorInfo: function (...args) {
console.warn("AppAccountManager.getAuthenticatorInfo interface mocked 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, AuthenticatorInfoMock);
} else {
return new Promise((resolve, reject) => {
resolve(AuthenticatorInfoMock)
})
}
}
};
const AuthenticatorCallbackMock = {
onResult: function (...args) {
console.warn("AuthenticatorCallback.onResult interface mocked in the Previewer. " +
"How this interface works on the Previewer may be different from that on a real device.")
},
onRequestRedirected: function (...args) {
console.warn("AuthenticatorCallback.onRequestRedirected interface mocked in the Previewer. " +
"How this interface works on the Previewer may be different from that on a real device.")
}
};
const AuthenticatorClass = class Authenticator {
constructor() {
console.warn("appAccount.Authenticator constructor interface mocked in the Previewer. " +
"How this interface works on the Previewer may be different from that on a real device.")
this.addAccountImplicitly = function (...args) {
console.warn("Authenticator.addAccountImplicitly interface mocked 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, AuthenticatorCallbackMock);
}
};
this.authenticate = function (...args) {
console.warn("Authenticator.authenticate interface mocked 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, AuthenticatorCallbackMock);
}
};
}
};
const ConstantsMock = {
ACTION_ADD_ACCOUNT_IMPLICITLY: '[PC preview] unknow string',
ACTION_AUTHENTICATE: '[PC preview] unknow string',
KEY_NAME: '[PC preview] unknow string',
KEY_OWNER: '[PC preview] unknow string',
KEY_TOKEN: '[PC preview] unknow string',
KEY_ACTION: '[PC preview] unknow string',
KEY_AUTH_TYPE: '[PC preview] unknow string',
KEY_SESSION_ID: '[PC preview] unknow string',
KEY_CALLER_PID: '[PC preview] unknow string',
KEY_CALLER_UID: '[PC preview] unknow string',
KEY_CALLER_BUNDLE_NAME: '[PC preview] unknow string'
};
const ResultCodeMock = {
SUCCESS: '[PC preview] unknow resultCode',
ERROR_ACCOUNT_NOT_EXIST: '[PC preview] unknow resultCode',
ERROR_APP_ACCOUNT_SERVICE_EXCEPTION: '[PC preview] unknow resultCode',
ERROR_INVALID_PASSWORD: '[PC preview] unknow resultCode',
ERROR_INVALID_REQUEST: '[PC preview] unknow resultCode',
ERROR_INVALID_RESPONSE: '[PC preview] unknow resultCode',
ERROR_NETWORK_EXCEPTION: '[PC preview] unknow resultCode',
ERROR_OAUTH_AUTHENTICATOR_NOT_EXIST: '[PC preview] unknow resultCode',
ERROR_OAUTH_CANCELED: '[PC preview] unknow resultCode',
ERROR_OAUTH_LIST_TOO_LARGE: '[PC preview] unknow resultCode',
ERROR_OAUTH_SERVICE_BUSY: '[PC preview] unknow resultCode',
ERROR_OAUTH_SERVICE_EXCEPTION: '[PC preview] unknow resultCode',
ERROR_OAUTH_SESSION_NOT_EXIST: '[PC preview] unknow resultCode',
ERROR_OAUTH_TIMEOUT: '[PC preview] unknow resultCode',
ERROR_OAUTH_TOKEN_NOT_EXIST: '[PC preview] unknow resultCode',
ERROR_OAUTH_TOKEN_TOO_MANY: '[PC preview] unknow resultCode',
ERROR_OAUTH_UNSUPPORT_ACTION: '[PC preview] unknow resultCode',
ERROR_OAUTH_UNSUPPORT_AUTH_TYPE: '[PC preview] unknow resultCode',
ERROR_PERMISSION_DENIED: '[PC preview] unknow resultCode'
};
const appAccount = {
createAppAccountManager: function (...args) {
console.warn("appAccount.createAppAccountManager interface mocked in the Previewer. " +
"How this interface works on the Previewer may be different from that on a real device.")
return appAccountManagerMock;
},
AuthenticatorCallback: AuthenticatorCallbackMock,
Authenticator: AuthenticatorClass,
Constants: ConstantsMock,
ResultCode: ResultCodeMock,
}
return appAccount
}
@@ -1,394 +1,394 @@
/*
* Copyright (c) 2021 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import { paramMock } from "../utils"
export function mockOsAccount() {
const osAccountInfoMock = {
localId: "[PC Preview] unknown id",
localName: "[PC Preview] unknown name",
type: "[PC Preview] unknown type",
constraints: "[PC Preview] unknown constraints",
distributedInfo: "[PC Preview] unknown distributedInfo"
};
const osAccountTypeMock = "[PC Preview] unknown type";
const accountManagerMock = {
activateOsAccount: function (...args) {
console.warn("AccountManager.activateOsAccount interface mocked 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();
})
}
},
isMultiOsAccountEnable: function (...args) {
console.warn("AccountManager.isMultiOsAccountEnable interface mocked 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);
})
}
},
isOsAccountActived: function (...args) {
console.warn("AccountManager.isOsAccountActived interface mocked 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);
})
}
},
isOsAccountConstraintEnable: function (...args) {
console.warn("AccountManager.isOsAccountConstraintEnable interface mocked 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);
})
}
},
isTestOsAccount: function (...args) {
console.warn("AccountManager.isTestOsAccount interface mocked 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);
})
}
},
isOsAccountVerified: function (...args) {
console.warn("AccountManager.isOsAccountVerified interface mocked 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);
})
}
},
removeOsAccount: function (...args) {
console.warn("AccountManager.removeOsAccount interface mocked 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();
})
}
},
setOsAccountConstraints: function (...args) {
console.warn("AccountManager.setOsAccountConstraints interface mocked 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();
})
}
},
setOsAccountName: function (...args) {
console.warn("AccountManager.setOsAccountName interface mocked 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();
})
}
},
getCreatedOsAccountsCount: function (...args) {
console.warn("AccountManager.getCreatedOsAccountsCount interface mocked 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);
})
}
},
getOsAccountLocalIdFromProcess: function (...args) {
console.warn("AccountManager.getOsAccountLocalIdFromProcess interface mocked 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);
})
}
},
getOsAccountLocalIdFromUid: function (...args) {
console.warn("AccountManager.getOsAccountLocalIdFromUid interface mocked 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);
})
}
},
getOsAccountLocalIdFromDomain: function (...args) {
console.warn("AccountManager.getOsAccountLocalIdFromDomain interface mocked 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);
})
}
},
queryMaxOsAccountNumber: function (...args) {
console.warn("AccountManager.queryMaxOsAccountNumber interface mocked 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);
})
}
},
getOsAccountAllConstraints: function (...args) {
console.warn("AccountManager.getOsAccountAllConstraints interface mocked 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);
})
}
},
queryAllCreatedOsAccounts: function (...args) {
console.warn("AccountManager.queryAllCreatedOsAccounts interface mocked in the Previewer. " +
"How this interface works on the Previewer may be different from that on a real device.")
var osAccountInfoArrayMock = new Array();
osAccountInfoArrayMock.push(osAccountInfoMock);
const len = args.length
if (len > 0 && typeof args[len - 1] === 'function') {
args[len - 1].call(this, paramMock.businessErrorMock, osAccountInfoArrayMock);
} else {
return new Promise((resolve, reject) => {
resolve(osAccountInfoArrayMock);
})
}
},
queryActivatedOsAccountIds: function (...args) {
console.warn("AccountManager.queryActivatedOsAccountIds interface mocked in the Previewer. " +
"How this interface works on the Previewer may be different from that on a real device.")
var osAccountIdsArrayMock = new Array();
osAccountIdsArrayMock.push(osAccountInfoMock);
const len = args.length
if (len > 0 && typeof args[len - 1] === 'function') {
args[len - 1].call(this, paramMock.businessErrorMock, osAccountIdsArrayMock);
} else {
return new Promise((resolve, reject) => {
resolve(osAccountIdsArrayMock);
})
}
},
createOsAccount: function (...args) {
console.warn("AccountManager.createOsAccount interface mocked 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, osAccountInfoMock);
} else {
return new Promise((resolve, reject) => {
resolve(osAccountInfoMock);
})
}
},
createOsAccountForDomain: function (...args) {
console.warn("AccountManager.createOsAccountForDomain interface mocked 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, osAccountInfoMock);
} else {
return new Promise((resolve, reject) => {
resolve(osAccountInfoMock);
})
}
},
queryCurrentOsAccount: function (...args) {
console.warn("AccountManager.queryCurrentOsAccount interface mocked 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, osAccountInfoMock);
} else {
return new Promise((resolve, reject) => {
resolve(osAccountInfoMock);
})
}
},
queryOsAccountById: function (...args) {
console.warn("AccountManager.queryOsAccountById interface mocked 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, osAccountInfoMock);
} else {
return new Promise((resolve, reject) => {
resolve(osAccountInfoMock);
})
}
},
getOsAccountTypeFromProcess: function (...args) {
console.warn("AccountManager.getOsAccountTypeFromProcess interface mocked 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, osAccountTypeMock);
} else {
return new Promise((resolve, reject) => {
resolve(osAccountTypeMock);
})
}
},
getDistributedVirtualDeviceId: function (...args) {
console.warn("AccountManager.getDistributedVirtualDeviceId interface mocked 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);
})
}
},
getOsAccountProfilePhoto: function (...args) {
console.warn("AccountManager.getOsAccountProfilePhoto interface mocked 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);
})
}
},
setOsAccountProfilePhoto: function (...args) {
console.warn("AccountManager.setOsAccountProfilePhoto interface mocked 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();
})
}
},
getOsAccountLocalIdBySerialNumber: function (...args) {
console.warn("AccountManager.getOsAccountLocalIdBySerialNumber interface mocked 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();
})
}
},
getSerialNumberByOsAccountLocalId: function (...args) {
console.warn("AccountManager.getSerialNumberByOsAccountLocalId interface mocked in the Previewer. " +
"How this interface works on the Previewer may be different from that on a real device.")
const len = args.length
if (len > 0 && typeof args[len - 1] === 'function') {
args[len - 1].call(this, paramMock.businessErrorMock);
} else {
return new Promise((resolve, reject) => {
resolve();
})
}
},
on: function (...args) {
console.warn("AccountManager.on interface mocked in the Previewer. " +
"How this interface works on the Previewer may be different from that on a real device.")
const len = args.length
if (len > 0 && typeof args[len - 1] === 'function') {
args[len - 1].call(this, paramMock.paramNumberMock);
} else {
return new Promise((resolve, reject) => {
resolve(paramMock.paramNumberMock);
})
}
},
off: function (...args) {
console.warn("AccountManager.off interface mocked in the Previewer. " +
"How this interface works on the Previewer may be different from that on a real device.")
const len = args.length
if (len > 0 && typeof args[len - 1] === 'function') {
args[len - 1].call(this, paramMock.paramNumberMock);
} else {
return new Promise((resolve, reject) => {
resolve(paramMock.paramNumberMock);
})
}
}
};
global.ohosplugin.account = global.ohosplugin.account || {};
global.ohosplugin.account.osAccount = {
getAccountManager: function (...args) {
console.warn("osAccount.getAccountManager interface mocked in the Previewer. " +
"How this interface works on the Previewer may be different from that on a real device.")
return accountManagerMock;
},
OsAccountType: {
ADMIN: "[PC Preview] unknown ADMIN",
NORMAL: "[PC Preview] unknown NORMAL",
GUEST: "[PC Preview] unknown GUEST"
}
};
/*
* Copyright (c) 2021 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import { paramMock } from "../utils"
export function mockOsAccount() {
const osAccountInfoMock = {
localId: "[PC Preview] unknown id",
localName: "[PC Preview] unknown name",
type: "[PC Preview] unknown type",
constraints: "[PC Preview] unknown constraints",
distributedInfo: "[PC Preview] unknown distributedInfo"
};
const osAccountTypeMock = "[PC Preview] unknown type";
const accountManagerMock = {
activateOsAccount: function (...args) {
console.warn("AccountManager.activateOsAccount interface mocked 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();
})
}
},
isMultiOsAccountEnable: function (...args) {
console.warn("AccountManager.isMultiOsAccountEnable interface mocked 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);
})
}
},
isOsAccountActived: function (...args) {
console.warn("AccountManager.isOsAccountActived interface mocked 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);
})
}
},
isOsAccountConstraintEnable: function (...args) {
console.warn("AccountManager.isOsAccountConstraintEnable interface mocked 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);
})
}
},
isTestOsAccount: function (...args) {
console.warn("AccountManager.isTestOsAccount interface mocked 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);
})
}
},
isOsAccountVerified: function (...args) {
console.warn("AccountManager.isOsAccountVerified interface mocked 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);
})
}
},
removeOsAccount: function (...args) {
console.warn("AccountManager.removeOsAccount interface mocked 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();
})
}
},
setOsAccountConstraints: function (...args) {
console.warn("AccountManager.setOsAccountConstraints interface mocked 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();
})
}
},
setOsAccountName: function (...args) {
console.warn("AccountManager.setOsAccountName interface mocked 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();
})
}
},
getCreatedOsAccountsCount: function (...args) {
console.warn("AccountManager.getCreatedOsAccountsCount interface mocked 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);
})
}
},
getOsAccountLocalIdFromProcess: function (...args) {
console.warn("AccountManager.getOsAccountLocalIdFromProcess interface mocked 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);
})
}
},
getOsAccountLocalIdFromUid: function (...args) {
console.warn("AccountManager.getOsAccountLocalIdFromUid interface mocked 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);
})
}
},
getOsAccountLocalIdFromDomain: function (...args) {
console.warn("AccountManager.getOsAccountLocalIdFromDomain interface mocked 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);
})
}
},
queryMaxOsAccountNumber: function (...args) {
console.warn("AccountManager.queryMaxOsAccountNumber interface mocked 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);
})
}
},
getOsAccountAllConstraints: function (...args) {
console.warn("AccountManager.getOsAccountAllConstraints interface mocked 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);
})
}
},
queryAllCreatedOsAccounts: function (...args) {
console.warn("AccountManager.queryAllCreatedOsAccounts interface mocked in the Previewer. " +
"How this interface works on the Previewer may be different from that on a real device.")
var osAccountInfoArrayMock = new Array();
osAccountInfoArrayMock.push(osAccountInfoMock);
const len = args.length
if (len > 0 && typeof args[len - 1] === 'function') {
args[len - 1].call(this, paramMock.businessErrorMock, osAccountInfoArrayMock);
} else {
return new Promise((resolve, reject) => {
resolve(osAccountInfoArrayMock);
})
}
},
queryActivatedOsAccountIds: function (...args) {
console.warn("AccountManager.queryActivatedOsAccountIds interface mocked in the Previewer. " +
"How this interface works on the Previewer may be different from that on a real device.")
var osAccountIdsArrayMock = new Array();
osAccountIdsArrayMock.push(osAccountInfoMock);
const len = args.length
if (len > 0 && typeof args[len - 1] === 'function') {
args[len - 1].call(this, paramMock.businessErrorMock, osAccountIdsArrayMock);
} else {
return new Promise((resolve, reject) => {
resolve(osAccountIdsArrayMock);
})
}
},
createOsAccount: function (...args) {
console.warn("AccountManager.createOsAccount interface mocked 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, osAccountInfoMock);
} else {
return new Promise((resolve, reject) => {
resolve(osAccountInfoMock);
})
}
},
createOsAccountForDomain: function (...args) {
console.warn("AccountManager.createOsAccountForDomain interface mocked 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, osAccountInfoMock);
} else {
return new Promise((resolve, reject) => {
resolve(osAccountInfoMock);
})
}
},
queryCurrentOsAccount: function (...args) {
console.warn("AccountManager.queryCurrentOsAccount interface mocked 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, osAccountInfoMock);
} else {
return new Promise((resolve, reject) => {
resolve(osAccountInfoMock);
})
}
},
queryOsAccountById: function (...args) {
console.warn("AccountManager.queryOsAccountById interface mocked 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, osAccountInfoMock);
} else {
return new Promise((resolve, reject) => {
resolve(osAccountInfoMock);
})
}
},
getOsAccountTypeFromProcess: function (...args) {
console.warn("AccountManager.getOsAccountTypeFromProcess interface mocked 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, osAccountTypeMock);
} else {
return new Promise((resolve, reject) => {
resolve(osAccountTypeMock);
})
}
},
getDistributedVirtualDeviceId: function (...args) {
console.warn("AccountManager.getDistributedVirtualDeviceId interface mocked 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);
})
}
},
getOsAccountProfilePhoto: function (...args) {
console.warn("AccountManager.getOsAccountProfilePhoto interface mocked 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);
})
}
},
setOsAccountProfilePhoto: function (...args) {
console.warn("AccountManager.setOsAccountProfilePhoto interface mocked 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();
})
}
},
getOsAccountLocalIdBySerialNumber: function (...args) {
console.warn("AccountManager.getOsAccountLocalIdBySerialNumber interface mocked 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();
})
}
},
getSerialNumberByOsAccountLocalId: function (...args) {
console.warn("AccountManager.getSerialNumberByOsAccountLocalId interface mocked in the Previewer. " +
"How this interface works on the Previewer may be different from that on a real device.")
const len = args.length
if (len > 0 && typeof args[len - 1] === 'function') {
args[len - 1].call(this, paramMock.businessErrorMock);
} else {
return new Promise((resolve, reject) => {
resolve();
})
}
},
on: function (...args) {
console.warn("AccountManager.on interface mocked in the Previewer. " +
"How this interface works on the Previewer may be different from that on a real device.")
const len = args.length
if (len > 0 && typeof args[len - 1] === 'function') {
args[len - 1].call(this, paramMock.paramNumberMock);
} else {
return new Promise((resolve, reject) => {
resolve(paramMock.paramNumberMock);
})
}
},
off: function (...args) {
console.warn("AccountManager.off interface mocked in the Previewer. " +
"How this interface works on the Previewer may be different from that on a real device.")
const len = args.length
if (len > 0 && typeof args[len - 1] === 'function') {
args[len - 1].call(this, paramMock.paramNumberMock);
} else {
return new Promise((resolve, reject) => {
resolve(paramMock.paramNumberMock);
})
}
}
};
const osAccount = {
getAccountManager: function (...args) {
console.warn("osAccount.getAccountManager interface mocked in the Previewer. " +
"How this interface works on the Previewer may be different from that on a real device.")
return accountManagerMock;
},
OsAccountType: {
ADMIN: "[PC Preview] unknown ADMIN",
NORMAL: "[PC Preview] unknown NORMAL",
GUEST: "[PC Preview] unknown GUEST"
}
}
return osAccount
}
@@ -15,7 +15,7 @@
import { paramMock } from "../utils"
import { ExtensionContextClass } from "./application/abilityContext"
import { ResultSetMock } from "./dataShare"
import { ResultSetMock } from "./ohos_data_dataShare"
export function mockDataShareExtensionAbility() {
const DataShareExtensionAbilityClass = class DataShareExtensionAbility {
@@ -14,7 +14,7 @@
*/
import { paramMock } from "../utils"
import { RemoteObjectClass } from "./applicationServiceExtensionAbility"
import { RemoteObjectClass } from "./ohos_application_ServiceExtensionAbility"
const ApplicationInfoMock = {
name: '[PC preview] unknow name',
@@ -118,7 +118,7 @@ export function mockServiceExtAbility() {
this.currentHapModuleInfo = HapModuleInfoMock;
}
}
const ServiceExtAbilityContextClass = class ServiceExtAbilityContext extends ExtAbilityContextClass{
const ServiceExtAbilityContextClass = class ServiceExtAbilityContext extends ExtAbilityContextClass {
constructor() {
super();
console.warn('ServiceExtAbilityContext.constructor interface mocked in the Previewer. How this interface works on' +
@@ -203,7 +203,7 @@ export function mockServiceExtAbility() {
this.onConnect = function (...args) {
console.warn("ServiceExtAbility.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();
return new RemoteObjectClass();
};
this.onDisconnect = function (...args) {
console.warn("ServiceExtAbility.onDisconnect interface mocked in the Previewer. How this interface works on the Previewer" +
@@ -1,50 +1,51 @@
/*
* Copyright (c) 2021 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
export function mockOhosBatteryinfo() {
const BatteryPluggedType = {
NONE: '[PC preview] unknow NONE',
AC: '[PC preview] unknow AC',
USB: '[PC preview] unknow USB',
WIRELESS: '[PC preview] unknow WIRELESS'
}
const BatteryChargeState = {
NONE: '[PC preview] unknow NONE',
ENABLE: '[PC preview] unknow ENABLE',
DISABLE: '[PC preview] unknow DISABLE',
FULL: '[PC preview] unknow FULL'
}
const BatteryHealthState = {
UNKNOWN: '[PC preview] unknow UNKNOWN',
GOOD: '[PC preview] unknow GOOD',
OVERHEAT: '[PC preview] unknow OVERHEAT',
OVERVOLTAGE: '[PC preview] unknow OVERVOLTAGE',
COLD: '[PC preview] unknow COLD',
DEAD: '[PC preview] unknow DEAD'
}
global.systemplugin.batteryInfo = {
BatteryPluggedType,
BatteryChargeState,
BatteryHealthState,
batterySOC: "[PC Preview] unknow batterySOC",
chargingStatus: "[PC Preview] unknow chargingStatus",
healthStatus: "[PC Preview] unknow healthStatus",
pluggedType: "[PC Preview] unknow pluggedType",
voltage: "[PC Preview] unknow voltage",
technology: "[PC Preview] unknow technology",
batteryTemperature: "[PC Preview] unknow batteryTemperature",
isBatteryPresent: "[PC Preview] unknow isBatteryPresent"
}
}
/*
* Copyright (c) 2021 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
export function mockOhosBatteryinfo() {
const BatteryPluggedType = {
NONE: '[PC preview] unknow NONE',
AC: '[PC preview] unknow AC',
USB: '[PC preview] unknow USB',
WIRELESS: '[PC preview] unknow WIRELESS'
}
const BatteryChargeState = {
NONE: '[PC preview] unknow NONE',
ENABLE: '[PC preview] unknow ENABLE',
DISABLE: '[PC preview] unknow DISABLE',
FULL: '[PC preview] unknow FULL'
}
const BatteryHealthState = {
UNKNOWN: '[PC preview] unknow UNKNOWN',
GOOD: '[PC preview] unknow GOOD',
OVERHEAT: '[PC preview] unknow OVERHEAT',
OVERVOLTAGE: '[PC preview] unknow OVERVOLTAGE',
COLD: '[PC preview] unknow COLD',
DEAD: '[PC preview] unknow DEAD'
}
const batteryInfo = {
BatteryPluggedType,
BatteryChargeState,
BatteryHealthState,
batterySOC: "[PC Preview] unknow batterySOC",
chargingStatus: "[PC Preview] unknow chargingStatus",
healthStatus: "[PC Preview] unknow healthStatus",
pluggedType: "[PC Preview] unknow pluggedType",
voltage: "[PC Preview] unknow voltage",
technology: "[PC Preview] unknow technology",
batteryTemperature: "[PC Preview] unknow batteryTemperature",
isBatteryPresent: "[PC Preview] unknow isBatteryPresent"
}
return batteryInfo
}
@@ -13,10 +13,10 @@
* limitations under the License.
*/
import { hasComplete } from "./utils"
import { hasComplete } from "../utils"
export function mockBluetooth() {
global.systemplugin.bluetooth = {
const bluetooth = {
startBLEScan: function (...args) {
console.warn("bluetooth.startBLEScan interface mocked in the Previewer. How this interface works on the" +
" Previewer may be different from that on a real device.")
@@ -56,4 +56,5 @@ export function mockBluetooth() {
delete this.unsubscribeBLE
}
}
return bluetooth
}
@@ -13,10 +13,10 @@
* limitations under the License.
*/
import { hasComplete } from "./utils"
import { hasComplete } from "../utils"
export function mockBrightness() {
global.systemplugin.brightness = {
const brightness = {
argsV: {
value: 80
},
@@ -58,4 +58,5 @@ export function mockBrightness() {
hasComplete(args[0].complete)
}
}
return brightness
}
@@ -51,7 +51,7 @@ export function mockBundleState() {
BY_MONTHLY: 3,
BY_ANNUALLY: 4
}
global.ohosplugin.bundleState = {
const bundleState = {
isIdleState: function (...args) {
console.warn("bundleState.isIdleState interface mocked in the Previewer. How this interface works on the" +
" Previewer may be different from that on a real device.");
@@ -125,4 +125,5 @@ export function mockBundleState() {
}
}
}
return bundleState
}
@@ -13,7 +13,7 @@
* limitations under the License.
*/
import { paramMock } from "./utils"
import { paramMock } from "../utils"
export function mockContact() {
const ContactClass = class Contact {
@@ -251,7 +251,7 @@ export function mockContact() {
this.website = "[PC Preview] unknow website";
}
}
global.systemplugin.contact = {
const contact = {
Contact: ContactClass,
ContactAttributes: ContactAttributesClass,
Email: EmailClass,
@@ -452,4 +452,5 @@ export function mockContact() {
}
}
}
return contact
}
@@ -13,13 +13,60 @@
* limitations under the License.
*/
import { paramMock } from "./utils"
import { paramMock } from "../utils"
export function mockDataStorage() {
global.systemplugin.data = {}
const paramValueTypeMock = '[PC Preview] unknow ValueType'
const storageObserverMock = {
key: "[PC preview] unknow key"
const storage = {
storageMock,
getStorageSync: function () {
console.warn("data.storage.getStorageSync interface mocked in the Previewer. How this interface works on the" +
" Previewer may be different from that on a real device.")
return storageMock
},
getStorage: function (...args) {
console.warn("data.storage.getStorage interface mocked in the Previewer. How this interface works on the" +
" Previewer may be different from that on a real device.")
const len = args.length
if (typeof args[len - 1] === 'function') {
args[len - 1].call(this, paramMock.businessErrorMock, storageMock)
} else {
return new Promise((resolve) => {
resolve(storageMock)
})
}
},
deleteStorageSync: function () {
console.warn("data.storage.deleteStorageSync interface mocked in the Previewer. How this interface works on" +
" the Previewer may be different from that on a real device.")
},
deleteStorage: function (...args) {
console.warn("data.storage.deleteStorage interface mocked in the Previewer. How this interface works on the" +
" Previewer may be 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()
})
}
},
removeStorageFromCacheSync: function () {
console.warn("data.storage.removeStorageFromCacheSync interface mocked in the Previewer. How this interface" +
" works on the Previewer may be different from that on a real device.")
},
removeStorageFromCache: function (...args) {
console.warn("data.storage.removeStorageFromCache interface mocked in the Previewer. How this interface works" +
" on the Previewer may be 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()
})
}
}
}
const storageMock = {
getSync: function () {
@@ -133,55 +180,5 @@ export function mockDataStorage() {
args[len - 1].call(this, storageObserverMock)
}
}
global.systemplugin.data.storage = {
getStorageSync: function () {
console.warn("data.storage.getStorageSync interface mocked in the Previewer. How this interface works on the" +
" Previewer may be different from that on a real device.")
return storageMock
},
getStorage: function (...args) {
console.warn("data.storage.getStorage interface mocked in the Previewer. How this interface works on the" +
" Previewer may be different from that on a real device.")
const len = args.length
if (typeof args[len - 1] === 'function') {
args[len - 1].call(this, paramMock.businessErrorMock, storageMock)
} else {
return new Promise((resolve) => {
resolve(storageMock)
})
}
},
deleteStorageSync: function () {
console.warn("data.storage.deleteStorageSync interface mocked in the Previewer. How this interface works on" +
" the Previewer may be different from that on a real device.")
},
deleteStorage: function (...args) {
console.warn("data.storage.deleteStorage interface mocked in the Previewer. How this interface works on the" +
" Previewer may be 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()
})
}
},
removeStorageFromCacheSync: function () {
console.warn("data.storage.removeStorageFromCacheSync interface mocked in the Previewer. How this interface" +
" works on the Previewer may be different from that on a real device.")
},
removeStorageFromCache: function (...args) {
console.warn("data.storage.removeStorageFromCache interface mocked in the Previewer. How this interface works" +
" on the Previewer may be 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 storage
}
@@ -14,7 +14,7 @@
*/
import { paramMock } from '../utils';
import { RdbPredicatesClass } from './rdb'
import { RdbPredicatesClass } from './ohos_data_rdb'
export function mockDataAbility() {
const DataAbilityPredicatesClass = class DataAbilityPredicates {
@@ -0,0 +1,46 @@
/*
* 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 mockDistributedObject() {
const DistributedObject = {
setSessionId: function (...args) {
console.warn("DistributedObject.setSessionId interface mocked in the Previewer." +
" How this interface works on the Previewer may be different from that on a real device.")
},
on: function (...args) {
console.warn("DistributedObject.on interface mocked in the Previewer. How this interface works" +
" on the Previewer may be different from that on a real device.")
},
off: function (...args) {
console.warn("DistributedObject.off interface mocked in the Previewer. How this interface works" +
" on the Previewer may be different from that on a real device.")
}
};
const distributedObjectMock = {
createDistributedObject: function (...args) {
console.warn("distributedObject.createDistributedObject interface mocked in the Previewer." +
" How this interface works on the Previewer may be different from that on a real device.");
return DistributedObject;
},
genSessionId: function (...args) {
console.warn("distributedObject.genSessionId interface mocked in the Previewer." +
" How this interface works on the Previewer may be different from that on a real device.");
return 'just test';
}
};
return distributedObjectMock;
}
@@ -1,20 +1,20 @@
/*
* Copyright (c) 2021 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
* Copyright (c) 2021 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
export function mockDeviceInfo() {
global.systemplugin.deviceInfo = {
const deviceInfo = {
deviceType: '[PC preview] unknow type',
manufacture: '[PC preview] unknow manufacture',
brand: '[PC preview] unknow brand',
@@ -46,4 +46,5 @@ export function mockDeviceInfo() {
buildTime: '[PC preview] unknow build time',
buildRootHash: '[PC preview] unknow build root hash'
}
return deviceInfo
}
@@ -13,7 +13,7 @@
* limitations under the License.
*/
import { paramMock } from "./utils"
import { paramMock } from "../utils"
export function mockDisplay() {
const displayMock = {
@@ -46,7 +46,7 @@ export function mockDisplay() {
rotation: '[PC preview] unknow rotation',
name: '[PC preview] unknow name'
}]
global.systemplugin.display = {
const display = {
getDefaultDisplay: function (...args) {
console.warn("display.getDefaultDisplay interface mocked in the Previewer. How this interface works on the Previewer" +
" may be different from that on a real device.")
@@ -84,4 +84,5 @@ export function mockDisplay() {
args[len - 1].call(this, paramMock.businessErrorMock, paramMock.paramNumberMock)
},
}
return display
}
@@ -13,7 +13,7 @@
* limitations under the License.
*/
import { paramMock } from "./utils"
import { paramMock } from "../utils"
export function mockDeviceManager() {
const deviceInfoMock = {
@@ -130,8 +130,8 @@ export function mockDeviceManager() {
" be different from that on a real device.")
}
}
global.systemplugin.distributedHardware = global.systemplugin.distributedHardware || {};
global.systemplugin.distributedHardware.deviceManager = {
const deviceManager = {
deviceManagerMock,
createDeviceManager: function (...args) {
console.warn("distributedHardware.deviceManager.createDeviceManager interface mocked in the Previewer. How this interface works on the Previewer" +
" may be different from that on a real device.")
@@ -141,4 +141,5 @@ export function mockDeviceManager() {
}
}
}
return deviceManager
}
@@ -13,10 +13,10 @@
* limitations under the License.
*/
import { paramMock } from "./utils"
import { paramMock } from "../utils"
export function mockDocument() {
global.systemplugin.document = {
const document = {
create: function (...args) {
console.warn("document.create interface mocked in the Previewer. How this interface works on the Previewer may" +
" be different from that on a real device.")
@@ -54,4 +54,5 @@ export function mockDocument() {
}
}
}
return document
}
@@ -1,58 +1,58 @@
/*
* Copyright (c) 2021 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import { paramMock } from "../utils"
export function mockFileManager() {
const filemanager = {
getRoot: function (...args) {
console.warn("filemanager.getRoot interface mocked in the Previewer. How this interface works on the" +
" Previewer may be different from that on a real device.")
const len = args.length
if (typeof args[len - 1] === 'function') {
args[len - 1].call(this, paramMock.businessErrorMock, paramMock.paramArrayMock)
} else {
return new Promise((resolve, reject) => {
resolve(paramMock.paramArrayMock);
})
}
},
listFile: function (...args) {
console.warn("filemanager.listFile interface mocked in the Previewer. How this interface works on the" +
" Previewer may be 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);
})
}
},
createFile: function (...args) {
console.warn("filemanager.createFile interface mocked in the Previewer. How this interface works on the" +
" Previewer may be 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);
})
}
},
}
return filemanager;
}
/*
* Copyright (c) 2021 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import { paramMock } from "../utils"
export function mockFileManager() {
const filemanager = {
getRoot: function (...args) {
console.warn("filemanager.getRoot interface mocked in the Previewer. How this interface works on the" +
" Previewer may be different from that on a real device.")
const len = args.length
if (typeof args[len - 1] === 'function') {
args[len - 1].call(this, paramMock.businessErrorMock, paramMock.paramArrayMock)
} else {
return new Promise((resolve, reject) => {
resolve(paramMock.paramArrayMock);
})
}
},
listFile: function (...args) {
console.warn("filemanager.listFile interface mocked in the Previewer. How this interface works on the" +
" Previewer may be 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);
})
}
},
createFile: function (...args) {
console.warn("filemanager.createFile interface mocked in the Previewer. How this interface works on the" +
" Previewer may be 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);
})
}
},
}
return filemanager;
}
@@ -48,7 +48,7 @@ export function mockOhosGeolocation() {
descriptions: '[PC preview] unknow descriptions',
descriptionsSize: '[PC preview] unknow descriptionsSize',
}
global.ohosplugin.geolocation = {
const geolocation = {
on: function (...args) {
console.warn("geolocation.on interface mocked in the Previewer. How this interface works on the" +
" Previewer may be different from that on a real device.");
@@ -182,4 +182,5 @@ export function mockOhosGeolocation() {
}
},
}
return geolocation
}
@@ -13,7 +13,7 @@
* limitations under the License.
*/
import { paramMock } from "./utils"
import { paramMock } from "../utils"
export function mockInputMethod() {
const KeyboardType = {
@@ -136,7 +136,7 @@ export function mockInputMethod() {
}
},
}
global.systemplugin.inputMethod = {
const inputMethod = {
MAX_TYPE_MUN: 128,
getInputMethodController: function () {
console.warn("inputmethod.getInputMethodController interface mocked in the Previewer. How this interface works" +
@@ -149,4 +149,5 @@ export function mockInputMethod() {
return InputMethodSettingMock;
}
}
return inputMethod
}
@@ -13,7 +13,7 @@
* limitations under the License.
*/
import { paramMock } from "./utils"
import { paramMock } from "../utils"
const NOTIFY = "[PC Preview] unknow"
const Properties = [
@@ -403,7 +403,7 @@ export function mockInputMethodEngine() {
}
},
}
global.systemplugin.inputMethodEngine = {
const inputMethodEngine = {
getInputMethodEngine: function () {
console.warn("inputMethodEngine.getInputMethodEngine interface mocked in the Previewer. How this interface works" +
" on the Previewer may be different from that on a real device.")
@@ -417,6 +417,6 @@ export function mockInputMethodEngine() {
}
for (let Property of Properties) {
global.systemplugin.inputMethodEngine[Property] = NOTIFY + " " + Property
inputMethodEngine[Property] = NOTIFY + " " + Property
}
}
@@ -14,7 +14,7 @@
*/
import { paramMock } from "../utils"
import { PixelMapMock } from "./multimediaImage"
import { PixelMapMock } from "./ohos_multimedia_image"
export function mockMultimediaMediaLibrary() {
const mockFileAsset = {
@@ -39,9 +39,9 @@ export function mockMultimediaMediaLibrary() {
albumId: "[PC Preview] unknow albumId",
albumUri: "[PC Preview] unknow albumUri",
albumName: "[PC Preview] unknow albumName",
isDirectory: function(...args) {
isDirectory: function (...args) {
console.warn("FileAsset.isDirectory interface mocked in the Previewer. How this interface works on the" +
" Previewer may be different from that on a real device.")
" Previewer may be different from that on a real device.")
const len = args.length
if (len > 0 && typeof args[len - 1] === 'function') {
args[len - 1].call(this, paramMock.businessErrorMock, paramMock.paramBooleanMock)
@@ -51,9 +51,9 @@ export function mockMultimediaMediaLibrary() {
})
}
},
commitModify: function(...args) {
commitModify: function (...args) {
console.warn("FileAsset.commitModify interface mocked in the Previewer. How this interface works on the" +
" Previewer may be different from that on a real device.")
" Previewer may be different from that on a real device.")
const len = args.length
if (len > 0 && typeof args[len - 1] === 'function') {
args[len - 1].call(this, paramMock.businessErrorMock)
@@ -63,9 +63,9 @@ export function mockMultimediaMediaLibrary() {
})
}
},
open: function(...args) {
open: function (...args) {
console.warn("FileAsset.open interface mocked in the Previewer. How this interface works on the" +
" Previewer may be different from that on a real device.")
" Previewer may be different from that on a real device.")
const len = args.length
if (len > 0 && typeof args[len - 1] === 'function') {
args[len - 1].call(this, paramMock.businessErrorMock, paramMock.paramNumberMock)
@@ -75,9 +75,9 @@ export function mockMultimediaMediaLibrary() {
})
}
},
close: function(...args) {
close: function (...args) {
console.warn("FileAsset.close interface mocked in the Previewer. How this interface works on the" +
" Previewer may be different from that on a real device.")
" Previewer may be different from that on a real device.")
const len = args.length
if (len > 0 && typeof args[len - 1] === 'function') {
args[len - 1].call(this, paramMock.businessErrorMock)
@@ -87,9 +87,9 @@ export function mockMultimediaMediaLibrary() {
})
}
},
getThumbnail: function(...args) {
getThumbnail: function (...args) {
console.warn("FileAsset.getThumbnail interface mocked in the Previewer. How this interface works on the" +
" Previewer may be different from that on a real device.")
" Previewer may be different from that on a real device.")
const len = args.length
if (len > 0 && typeof args[len - 1] === 'function') {
args[len - 1].call(this, paramMock.businessErrorMock, mockImagePixelMap)
@@ -99,9 +99,9 @@ export function mockMultimediaMediaLibrary() {
})
}
},
favorite: function(...args) {
favorite: function (...args) {
console.warn("FileAsset.favorite interface mocked in the Previewer. How this interface works on the" +
" Previewer may be different from that on a real device.")
" Previewer may be different from that on a real device.")
const len = args.length
if (len > 0 && typeof args[len - 1] === 'function') {
args[len - 1].call(this, paramMock.businessErrorMock)
@@ -111,9 +111,9 @@ export function mockMultimediaMediaLibrary() {
})
}
},
isFavorite: function(...args) {
isFavorite: function (...args) {
console.warn("FileAsset.isFavorite interface mocked in the Previewer. How this interface works on the" +
" Previewer may be different from that on a real device.")
" Previewer may be different from that on a real device.")
const len = args.length
if (len > 0 && typeof args[len - 1] === 'function') {
args[len - 1].call(this, paramMock.businessErrorMock, paramMock.paramBooleanMock)
@@ -123,9 +123,9 @@ export function mockMultimediaMediaLibrary() {
})
}
},
trash: function(...args) {
trash: function (...args) {
console.warn("FileAsset.trash interface mocked in the Previewer. How this interface works on the" +
" Previewer may be different from that on a real device.")
" Previewer may be different from that on a real device.")
const len = args.length
if (len > 0 && typeof args[len - 1] === 'function') {
args[len - 1].call(this, paramMock.businessErrorMock)
@@ -135,9 +135,9 @@ export function mockMultimediaMediaLibrary() {
})
}
},
isTrash: function(...args) {
isTrash: function (...args) {
console.warn("FileAsset.isTrash interface mocked in the Previewer. How this interface works on the" +
" Previewer may be different from that on a real device.")
" Previewer may be different from that on a real device.")
const len = args.length
if (len > 0 && typeof args[len - 1] === 'function') {
args[len - 1].call(this, paramMock.businessErrorMock, paramMock.paramBooleanMock)
@@ -150,23 +150,23 @@ export function mockMultimediaMediaLibrary() {
};
const mockFetchFileResult = {
getCount: function(...args) {
getCount: function (...args) {
console.warn("FetchFileResult.getCount interface mocked in the Previewer. How this interface works on the" +
" Previewer may be different from that on a real device.")
" Previewer may be different from that on a real device.")
return paramMock.paramNumberMock
},
isAfterLast: function(...args) {
isAfterLast: function (...args) {
console.warn("FetchFileResult.isAfterLast interface mocked in the Previewer. How this interface works on the" +
" Previewer may be different from that on a real device.")
" Previewer may be different from that on a real device.")
return paramMock.paramBooleanMock
},
close: function(...args) {
close: function (...args) {
console.warn("FetchFileResult.close interface mocked in the Previewer. How this interface works on the" +
" Previewer may be different from that on a real device.")
" Previewer may be different from that on a real device.")
},
getFirstObject: function(...args) {
getFirstObject: function (...args) {
console.warn("FetchFileResult.getFirstObject interface mocked in the Previewer. How this interface works on the" +
" Previewer may be different from that on a real device.")
" Previewer may be different from that on a real device.")
const len = args.length
if (len > 0 && typeof args[len - 1] === 'function') {
args[len - 1].call(this, paramMock.businessErrorMock, mockFileAsset)
@@ -176,9 +176,9 @@ export function mockMultimediaMediaLibrary() {
})
}
},
getNextObject: function(...args) {
getNextObject: function (...args) {
console.warn("FetchFileResult.getNextObject interface mocked in the Previewer. How this interface works on the" +
" Previewer may be different from that on a real device.")
" Previewer may be different from that on a real device.")
const len = args.length
if (len > 0 && typeof args[len - 1] === 'function') {
args[len - 1].call(this, paramMock.businessErrorMock, mockFileAsset)
@@ -188,9 +188,9 @@ export function mockMultimediaMediaLibrary() {
})
}
},
getLastObject: function(...args) {
getLastObject: function (...args) {
console.warn("FetchFileResult.getLastObject interface mocked in the Previewer. How this interface works on the" +
" Previewer may be different from that on a real device.")
" Previewer may be different from that on a real device.")
const len = args.length
if (len > 0 && typeof args[len - 1] === 'function') {
args[len - 1].call(this, paramMock.businessErrorMock, mockFileAsset)
@@ -200,9 +200,9 @@ export function mockMultimediaMediaLibrary() {
})
}
},
getPositionObject: function(...args) {
getPositionObject: function (...args) {
console.warn("FetchFileResult.getPositionObject interface mocked in the Previewer. How this interface works on the" +
" Previewer may be different from that on a real device.")
" Previewer may be different from that on a real device.")
const len = args.length
if (len > 0 && typeof args[len - 1] === 'function') {
args[len - 1].call(this, paramMock.businessErrorMock, mockFileAsset)
@@ -212,9 +212,9 @@ export function mockMultimediaMediaLibrary() {
})
}
},
getAllObject: function(...args) {
getAllObject: function (...args) {
console.warn("FetchFileResult.getPositionObject interface mocked in the Previewer. How this interface works on the" +
" Previewer may be different from that on a real device.")
" Previewer may be different from that on a real device.")
const len = args.length
if (len > 0 && typeof args[len - 1] === 'function') {
args[len - 1].call(this, paramMock.businessErrorMock, [mockFileAsset])
@@ -243,9 +243,9 @@ export function mockMultimediaMediaLibrary() {
count: "[PC Preview] unknow count",
relativePath: "[PC Preview] unknow relativePath",
coverUri: "[PC Preview] unknow coverUri",
commitModify: function(...args) {
commitModify: function (...args) {
console.warn("Album.commitModify interface mocked in the Previewer. How this interface works on the" +
" Previewer may be different from that on a real device.")
" Previewer may be different from that on a real device.")
const len = args.length
if (len > 0 && typeof args[len - 1] === 'function') {
args[len - 1].call(this, paramMock.businessErrorMock);
@@ -255,9 +255,9 @@ export function mockMultimediaMediaLibrary() {
})
}
},
getFileAssets: function(...args) {
getFileAssets: function (...args) {
console.warn("Album.getFileAssets interface mocked in the Previewer. How this interface works on the" +
" Previewer may be different from that on a real device.")
" Previewer may be different from that on a real device.")
const len = args.length
if (len > 0 && typeof args[len - 1] === 'function') {
args[len - 1].call(this, paramMock.businessErrorMock, mockFetchFileResult);
@@ -270,9 +270,9 @@ export function mockMultimediaMediaLibrary() {
};
const mockMediaLibrary = {
getPublicDirectory: function(...args) {
getPublicDirectory: function (...args) {
console.warn("MediaLibrary.getPublicDirectory interface mocked in the Previewer. How this interface works on the" +
" Previewer may be different from that on a real device.")
" Previewer may be different from that on a real device.")
const len = args.length
if (typeof args[len - 1] === 'function') {
args[len - 1].call(this, paramMock.businessErrorMock, paramMock.paramStringMock);
@@ -282,9 +282,9 @@ export function mockMultimediaMediaLibrary() {
})
}
},
getFileAssets: function(...args) {
getFileAssets: function (...args) {
console.warn("MediaLibrary.getFileAssets interface mocked in the Previewer. How this interface works on the" +
" Previewer may be different from that on a real device.")
" Previewer may be different from that on a real device.")
const len = args.length
if (typeof args[len - 1] === 'function') {
args[len - 1].call(this, paramMock.businessErrorMock, mockFetchFileResult);
@@ -294,17 +294,17 @@ export function mockMultimediaMediaLibrary() {
})
}
},
on: function(...args) {
on: function (...args) {
console.warn("MediaLibrary.on interface mocked in the Previewer. How this interface works on the" +
" Previewer may be different from that on a real device.")
" Previewer may be different from that on a real device.")
},
off: function(...args) {
off: function (...args) {
console.warn("MediaLibrary.off interface mocked in the Previewer. How this interface works on the" +
" Previewer may be different from that on a real device.")
" Previewer may be different from that on a real device.")
},
createAsset: function(...args) {
createAsset: function (...args) {
console.warn("MediaLibrary.createAsset interface mocked in the Previewer. How this interface works on the" +
" Previewer may be different from that on a real device.")
" Previewer may be different from that on a real device.")
const len = args.length
if (typeof args[len - 1] === 'function') {
args[len - 1].call(this, paramMock.businessErrorMock, mockFileAsset);
@@ -314,9 +314,9 @@ export function mockMultimediaMediaLibrary() {
})
}
},
deleteAsset: function(...args) {
deleteAsset: function (...args) {
console.warn("MediaLibrary.deleteAsset interface mocked in the Previewer. How this interface works on the" +
" Previewer may be different from that on a real device.")
" Previewer may be different from that on a real device.")
const len = args.length
if (typeof args[len - 1] === 'function') {
args[len - 1].call(this, paramMock.businessErrorMock);
@@ -326,9 +326,9 @@ export function mockMultimediaMediaLibrary() {
})
}
},
getAlbums: function(...args) {
getAlbums: function (...args) {
console.warn("MediaLibrary.getAlbums interface mocked in the Previewer. How this interface works on the" +
" Previewer may be different from that on a real device.")
" Previewer may be different from that on a real device.")
const len = args.length
if (typeof args[len - 1] === 'function') {
args[len - 1].call(this, paramMock.businessErrorMock, [mockAlbum]);
@@ -338,9 +338,9 @@ export function mockMultimediaMediaLibrary() {
})
}
},
storeMediaAsset: function(...args) {
storeMediaAsset: function (...args) {
console.warn("MediaLibrary.storeMediaAsset interface mocked in the Previewer. How this interface works on the" +
" Previewer may be different from that on a real device.")
" Previewer may be different from that on a real device.")
const len = args.length
if (typeof args[len - 1] === 'function') {
args[len - 1].call(this, paramMock.businessErrorMock, paramMock.paramStringMock);
@@ -350,9 +350,9 @@ export function mockMultimediaMediaLibrary() {
})
}
},
startImagePreview: function(...args) {
startImagePreview: function (...args) {
console.warn("MediaLibrary.startImagePreview interface mocked in the Previewer. How this interface works on the" +
" Previewer may be different from that on a real device.")
" Previewer may be different from that on a real device.")
const len = args.length
if (typeof args[len - 1] === 'function') {
args[len - 1].call(this, paramMock.businessErrorMock);
@@ -362,9 +362,9 @@ export function mockMultimediaMediaLibrary() {
})
}
},
startMediaSelect: function(...args) {
startMediaSelect: function (...args) {
console.warn("MediaLibrary.startMediaSelect interface mocked in the Previewer. How this interface works on the" +
" Previewer may be different from that on a real device.")
" Previewer may be different from that on a real device.")
const len = args.length
if (typeof args[len - 1] === 'function') {
args[len - 1].call(this, paramMock.businessErrorMock, [paramMock.paramStringMock]);
@@ -374,9 +374,9 @@ export function mockMultimediaMediaLibrary() {
})
}
},
getActivePeers: function(...args) {
getActivePeers: function (...args) {
console.warn("MediaLibrary.getActivePeers interface mocked in the Previewer. How this interface works on the" +
" Previewer may be different from that on a real device.")
" Previewer may be different from that on a real device.")
const len = args.length
if (typeof args[len - 1] === 'function') {
args[len - 1].call(this, paramMock.businessErrorMock, [mockPeerInfo]);
@@ -386,9 +386,9 @@ export function mockMultimediaMediaLibrary() {
})
}
},
getAllPeers: function(...args) {
getAllPeers: function (...args) {
console.warn("MediaLibrary.getAllPeers interface mocked in the Previewer. How this interface works on the" +
" Previewer may be different from that on a real device.")
" Previewer may be different from that on a real device.")
const len = args.length
if (typeof args[len - 1] === 'function') {
args[len - 1].call(this, paramMock.businessErrorMock, [mockPeerInfo]);
@@ -398,9 +398,9 @@ export function mockMultimediaMediaLibrary() {
})
}
},
release: function(...args) {
release: function (...args) {
console.warn("MediaLibrary.startImagePreview interface mocked in the Previewer. How this interface works on the" +
" Previewer may be different from that on a real device.")
" Previewer may be different from that on a real device.")
const len = args.length
if (typeof args[len - 1] === 'function') {
args[len - 1].call(this, paramMock.businessErrorMock);
@@ -457,9 +457,9 @@ export function mockMultimediaMediaLibrary() {
TYPE_CAR: 5,
TYPE_TV: 6
},
getMediaLibrary: function(...args) {
getMediaLibrary: function (...args) {
console.warn("mediaLibrary.getMediaLibrary interface mocked in the Previewer. How this interface works on the Previewer may" +
" be different from that on a real device.")
" be different from that on a real device.")
return mockMediaLibrary;
}
};
@@ -20,26 +20,17 @@ export function mockInputDevice() {
source: '[PC preview] unknow source',
axis: '[PC preview] unknow axis',
max: '[PC preview] unknow max',
min: '[PC preview] unknow min',
fuzz: '[PC preview] unknow fuzz',
flat: '[PC preview] unknow flat',
resolution: '[PC preview] unknow resolution',
min: '[PC preview] unknow min'
}
const InputDeviceData = {
id: '[PC preview] unknow id',
name: '[PC preview] unknow name',
sources: ['[PC preview] unknow sources'],
axisRanges: [AxisRange],
bus: '[PC preview] unknow bus',
product: '[PC preview] unknow product',
vendor: '[PC preview] unknow vendor',
version: '[PC preview] unknow version',
phys: '[PC preview] unknow phys',
uniq: '[PC preview] unknow uniq',
axisRanges: [AxisRange]
}
const EventType = ['changed']
const DeviceIds = [0, 1, 2, 3, 4]
const DeviceIds = [0, 1, 2, 3, 4, 5, 6, 7]
const inputDevice = {
on: function (...args) {
console.warn("inputDevice.on interface mocked in the Previewer. How this interface works on the" +
@@ -139,8 +130,8 @@ export function mockInputDevice() {
args[1].call(this, InputDeviceData);
}
},
supportKeys: function(...args) {
console.warn("inputDevice.supportKeys interface mocked in the Previewer." +
getKeystrokeAbility: function(...args) {
console.warn("inputDevice.getKeystrokeAbility interface mocked in the Previewer." +
"How this interface works on the" + " Previewer may be different from that on a real device.");
const len = args.length;
if (len < 2 || len > 3) {
@@ -158,7 +149,11 @@ export function mockInputDevice() {
if (len === 2) {
var KeystrokeAbilityArr = [];
for (var i = 0; i < args[1].length; ++i) {
KeystrokeAbilityArr.unshift('[PC preview] unknow boolean');
var KeystrokeAbility = {
keyCode: args[1][i],
isSupport: '[PC preview] unknow isSupport',
}
KeystrokeAbilityArr[i] = KeystrokeAbility;
}
return new Promise((resolve, reject) => {
resolve(KeystrokeAbilityArr);
@@ -170,7 +165,11 @@ export function mockInputDevice() {
}
var KeystrokeAbilityArr = [];
for (var i = 0; i < args[1].length; ++i) {
KeystrokeAbilityArr.unshift('[PC preview] unknow boolean');
var KeystrokeAbility = {
keyCode: args[1][i],
isSupport: '[PC preview] unknow isSupport',
}
KeystrokeAbilityArr[i] = KeystrokeAbility;
}
args[2].call(this, KeystrokeAbilityArr);
}
@@ -0,0 +1,88 @@
/*
* Copyright (c) 2021 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
export function mockInputMonitor() {
const touches = [{
force: 1.67,
globalX: 122,
globalY: 3654,
localX: 0,
localY: 0,
size: 2.03
}];
const changedTouches = [{
force: 1.67,
globalX: 122,
globalY: 3654,
localX: 0,
localY: 0,
size: 2.03
}];
const pressedButtons = [10, 11, 12, 13, 14];
const inputMonitor = {
on: function (...args) {
console.warn('multimodalInput.inputMonitor.on interface mocked in the Previewer. How this interface works on the' +
' Previewer may be different from that on a real device.');
clearInterval(this.offInputMonitor);
delete this.offInputMonitor;
this.offInputMonitor = setInterval(() => {
const len = args.length;
if (len !== 2 || typeof args[0] !== 'string' || typeof args[len - 1] !== 'function') {
console.warn('multimodalInput.inputMonitor.on param invalid.');
return;
}
if (args[0] !== 'touch' && args[0] !== 'mouse') {
console.warn('multimodalInput.inputMonitor.on first param should be touch or mouse.');
return;
}
const value = {};
value.type = 'up';
value.timestamp = 318878;
value.deviceId = 0;
value.touches = touches;
value.changedTouches = changedTouches;
const mouse = {};
mouse.type = 'move';
mouse.pressedButtons = pressedButtons;
mouse.displayId = 20;
mouse.targetWindowId = 21;
mouse.agentWindowId = 22;
mouse.localX = 450;
mouse.localY = 736;
mouse.globalX = 450;
mouse.globalY = 784;
mouse.timestamp = 55670246;
mouse.axisVerticalValue = 15;
mouse.axisHorizontalValue = 20;
if (args[0] === 'touch') {
console.warn('multimodalInput.inputMonitor.on touch callback.');
args[len - 1].call(this, value);
} else if (args[0] === 'mouse') {
console.warn('multimodalInput.inputMonitor.on mouse callback.');
args[len - 1].call(this, mouse);
}
}, 1000);
},
off: function (...args) {
console.warn('multimodalInput.inputMonitor.off interface mocked in the Previewer. How this interface works on the' +
' Previewer may be different from that on a real device.');
clearInterval(this.offInputMonitor);
delete this.offInputMonitor;
}
}
return inputMonitor
}
@@ -0,0 +1,387 @@
/*
* Copyright (c) 2021 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import { paramMock } from "../utils"
export function mockConnection() {
const NetAddress = "[PC Preview] unknow NetAddress"
const NetHandle = {
netId: "[PC Preview] unknow netId",
bindSocket: function () {
console.warn("NetHandle.bindSocket interface mocked in the Previewer. How this interface works on the Previewer" +
" may be 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();
})
}
},
openConnection: function () {
console.warn("NetHandle.openConnection interface mocked in the Previewer. How this interface works on the Previewer" +
" may be different from that on a real device.")
const len = args.length
if (typeof args[len - 1] === 'function') {
args[len - 1].call(this, paramMock.businessErrorMock, HttpRequest);
} else {
return new Promise((resolve, reject) => {
resolve(HttpRequest);
})
}
},
getAddressesByName: function () {
console.warn("NetHandle.getAddressesByName interface mocked in the Previewer. How this interface works on the Previewer" +
" may be different from that on a real device.")
const len = args.length
if (typeof args[len - 1] === 'function') {
args[len - 1].call(this, paramMock.businessErrorMock, NetAddress);
} else {
return new Promise((resolve, reject) => {
resolve(NetAddress);
})
}
},
getAddressByName: function () {
console.warn("NetHandle.getAddressByName interface mocked in the Previewer. How this interface works on the Previewer" +
" may be different from that on a real device.")
const len = args.length
if (typeof args[len - 1] === 'function') {
args[len - 1].call(this, paramMock.businessErrorMock, NetAddress);
} else {
return new Promise((resolve, reject) => {
resolve(NetAddress);
})
}
},
}
const NetBearType = "[PC Preview] unknow NetBearType"
const NetCapabilities = {
bearerTypes: function () {
console.warn("NetCapabilities.bearerTypes interface mocked in the Previewer. How this interface works on the Previewer" +
" may be different from that on a real device.")
var netBearTypeArray = new Array();
netBearTypeArray.push(NetBearType);
return netBearTypeArray;
}
}
const NetCap = "[PC Preview] unknow NetCap"
const ConnectionProperties = {
interfaceName: "[PC Preview] unknow interfaceName",
isUsePrivateDns: "[PC Preview] unknow isUsePrivateDns",
privateDnsServerName: "[PC Preview] unknow privateDnsServerName",
domains: "[PC Preview] unknow domains",
httpProxy: "[PC Preview] unknow httpProxy",
linkAddresses: function () {
console.warn("ConnectionProperties.linkAddresses interface mocked in the Previewer. How this interface works on the Previewer" +
" may be different from that on a real device.")
var LinkAddress = new Array();
LinkAddress.push(NetBearType);
return LinkAddress;
},
dnses: function () {
console.warn("ConnectionProperties.dnses interface mocked in the Previewer. How this interface works on the Previewer" +
" may be different from that on a real device.")
var NetAddress = new Array();
NetAddress.push(NetBearType);
return NetAddress;
},
routes: function () {
console.warn("ConnectionProperties.routes interface mocked in the Previewer. How this interface works on the Previewer" +
" may be different from that on a real device.")
var RouteInfo = new Array();
RouteInfo.push(NetBearType);
return RouteInfo;
},
mtu: "[PC Preview] unknow mtu"
}
const HttpProxy = {
host: "[PC Preview] unknow host",
port: "[PC Preview] unknow port",
parsedExclusionList: "[PC Preview] unknow parsedExclusionList"
}
const blocked = "[PC Preview] unknow blocked"
const BackgroundPolicy = "[PC Preview] unknow BackgroundPolicy"
const connection = {
on: function (...args) {
console.warn("net.connection.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] === 'netAvailable') {
args[len - 1].call(this, paramMock.businessErrorMock, NetHandle);
} else if (args[0] === 'netBlockStatusChange') {
args[len - 1].call(this, paramMock.businessErrorMock, { NetHandle, blocked });
} else if (args[0] === 'netCapabilitiesChange') {
args[len - 1].call(this, { NetHandle, NetCap });
} else if (args[0] === 'netConnectionPropertiesChange') {
args[len - 1].call(this, { NetHandle, ConnectionProperties });
} else if (args[0] === 'netLosing') {
args[len - 1].call(this, {
NetHandle,
maxMsToLive: "[PC Preview] unknow maxMsToLive"
});
} else if (args[0] === 'netLost') {
args[len - 1].call(this, paramMock.businessErrorMock, NetHandle);
} else if (args[0] === 'netUnavailable') {
args[len - 1].call(this, paramMock.businessErrorMock);
}
}
},
off: function (...args) {
console.warn("net.connection.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] === 'netAvailable') {
args[len - 1].call(this, paramMock.businessErrorMock, NetHandle);
} else if (args[0] === 'netBlockStatusChange') {
args[len - 1].call(this, { NetHandle, blocked });
} else if (args[0] === 'netCapabilitiesChange') {
args[len - 1].call(this, { NetHandle, NetCap });
} else if (args[0] === 'netConnectionPropertiesChange') {
args[len - 1].call(this, { NetHandle, ConnectionProperties });
} else if (args[0] === 'netLosing') {
args[len - 1].call(this, {
NetHandle,
maxMsToLive: "[PC Preview] unknow maxMsToLive"
});
} else if (args[0] === 'netLost') {
args[len - 1].call(this, paramMock.businessErrorMock, NetHandle);
} else if (args[0] === 'netUnavailable') {
args[len - 1].call(this, paramMock.businessErrorMock);
}
}
},
addNetStatusCallback: function (...args) {
console.warn("net.connection.addNetStatusCallback interface mocked in the Previewer. How this interface works on the Previewer" +
" may be 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();
})
}
},
removeNetStatusCallback: function (...args) {
console.warn("net.connection.removeNetStatusCallback interface mocked in the Previewer. How this interface works on the Previewer" +
" may be 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();
})
}
},
getAppNet: function (...args) {
console.warn("net.connection.getAppNet interface mocked in the Previewer. How this interface works on the Previewer" +
" may be different from that on a real device.")
const len = args.length
if (typeof args[len - 1] === 'function') {
args[len - 1].call(this, paramMock.businessErrorMock, NetHandle);
} else {
return new Promise((resolve, reject) => {
resolve(NetHandle);
})
}
},
setAppNet: function (...args) {
console.warn("net.connection.setAppNet interface mocked in the Previewer. How this interface works on the Previewer" +
" may be 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();
})
}
},
getDefaultNet: function (...args) {
console.warn("net.connection.getDefaultNet interface mocked in the Previewer. How this interface works on the Previewer" +
" may be different from that on a real device.")
const len = args.length
if (typeof args[len - 1] === 'function') {
args[len - 1].call(this, paramMock.businessErrorMock, NetHandle);
} else {
return new Promise((resolve, reject) => {
resolve(NetHandle);
})
}
},
getAllNets: function (...args) {
console.warn("net.connection.getAllNets interface mocked in the Previewer. How this interface works on the Previewer" +
" may be different from that on a real device.")
const len = args.length
if (typeof args[len - 1] === 'function') {
args[len - 1].call(this, paramMock.businessErrorMock, NetHandle);
} else {
return new Promise((resolve, reject) => {
resolve(NetHandle);
})
}
},
getDefaultHttpProxy: function (...args) {
console.warn("net.connection.getDefaultHttpProxy interface mocked in the Previewer. How this interface works on the Previewer" +
" may be different from that on a real device.")
const len = args.length
if (typeof args[len - 1] === 'function') {
args[len - 1].call(this, paramMock.businessErrorMock, HttpProxy);
} else {
return new Promise((resolve, reject) => {
resolve(HttpProxy);
})
}
},
getConnectionProperties: function (...args) {
console.warn("net.connection.getConnectionProperties interface mocked in the Previewer. How this interface works on the Previewer" +
" may be different from that on a real device.")
const len = args.length
if (typeof args[len - 1] === 'function') {
args[len - 1].call(this, paramMock.businessErrorMock, ConnectionProperties);
} else {
return new Promise((resolve, reject) => {
resolve(ConnectionProperties);
})
}
},
getNetCapabilities: function (...args) {
console.warn("net.connection.getNetCapabilities interface mocked in the Previewer. How this interface works on the Previewer" +
" may be different from that on a real device.")
const len = args.length
if (typeof args[len - 1] === 'function') {
args[len - 1].call(this, paramMock.businessErrorMock, NetCapabilities);
} else {
return new Promise((resolve, reject) => {
resolve(NetCapabilities);
})
}
},
getBackgroundPolicy: function (...args) {
console.warn("net.connection.getBackgroundPolicy interface mocked in the Previewer. How this interface works on the Previewer" +
" may be different from that on a real device.")
const len = args.length
if (typeof args[len - 1] === 'function') {
args[len - 1].call(this, paramMock.businessErrorMock, BackgroundPolicy);
} else {
return new Promise((resolve, reject) => {
resolve(BackgroundPolicy);
})
}
},
isDefaultNetMetered: function (...args) {
console.warn("net.connection.isDefaultNetMetered interface mocked in the Previewer. How this interface works on the Previewer" +
" may be different from that on a real device.")
const len = args.length
if (typeof args[len - 1] === 'function') {
args[len - 1].call(this, paramMock.businessErrorMock, paramMock.paramBooleanMock);
} else {
return new Promise((resolve, reject) => {
resolve(paramMock.paramBooleanMock);
})
}
},
hasDefaultNet: function (...args) {
console.warn("net.connection.hasDefaultNet interface mocked in the Previewer. How this interface works on the Previewer" +
" may be different from that on a real device.")
const len = args.length
if (typeof args[len - 1] === 'function') {
args[len - 1].call(this, paramMock.businessErrorMock, paramMock.paramBooleanMock);
} else {
return new Promise((resolve, reject) => {
resolve(paramMock.paramBooleanMock);
})
}
},
enableAirplaneMode: function (...args) {
console.warn("net.connection.enableAirplaneMode interface mocked in the Previewer. How this interface works on the Previewer" +
" may be 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();
})
}
},
disableAirplaneMode: function (...args) {
console.warn("net.connection.disableAirplaneMode interface mocked in the Previewer. How this interface works on the Previewer" +
" may be 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();
})
}
},
enableDistributedCellularData: function (...args) {
console.warn("net.connection.enableDistributedCellularData interface mocked in the Previewer. How this interface works on the Previewer" +
" may be 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();
})
}
},
disableDistributedCellularData: function (...args) {
console.warn("net.connection.disableDistributedCellularData interface mocked in the Previewer. How this interface works on the Previewer" +
" may be 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();
})
}
},
reportNetConnected: function (...args) {
console.warn("net.connection.reportNetConnected interface mocked in the Previewer. How this interface works on the Previewer" +
" may be 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();
})
}
},
reportNetDisconnected: function (...args) {
console.warn("net.connection.reportNetDisconnected interface mocked in the Previewer. How this interface works on the Previewer" +
" may be 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 connection
}
@@ -0,0 +1,133 @@
/*
* Copyright (c) 2021 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import { paramMock } from "../utils"
export function mockHttp() {
const HttpResponseCacheOptions = {
filePath: "[PC Preview] unknow filePath",
fileChildPath: "[PC Preview] unknow fileChildPath",
cacheSize: "[PC Preview] unknow cacheSize"
}
const HttpResponseCache = {
close: function (...args) {
console.warn("net.HttpResponseCache.close interface mocked in the Previewer. How this interface works on the Previewer may" +
" be 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();
})
}
},
delete: function (...args) {
console.warn("net.HttpResponseCache.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);
} else {
return new Promise((resolve, reject) => {
resolve();
})
}
},
flush: function (...args) {
console.warn("net.HttpResponseCache.flush interface mocked in the Previewer. How this interface works on the Previewer may" +
" be different from that on a real device.")
const len = args.length
if (typeof args[len - 1] === 'function') {
args[len - 1].call(this, paramMock.businessErrorMock);
} else {
return new Promise((resolve, reject) => {
resolve();
})
}
}
}
const HttpResponseMock = {
result: "[PC Preview] unknow result",
responseCode: "[PC Preview] unknow responseCode",
header: "[PC Preview] unknow header"
}
const HttpRequestMock = {
request: function (...args) {
console.warn("HttpRequest.request interface mocked in the Previewer. How this interface works on the Previewer" +
" may be different from that on a real device.")
const len = args.length
if (typeof args[len - 1] === 'function') {
args[len - 1].call(this, paramMock.businessErrorMock, HttpResponseMock);
} else {
return new Promise((resolve, reject) => {
resolve(HttpResponseMock);
})
}
},
destroy: function () {
console.warn("HttpRequest.destroy interface mocked in the Previewer. How this interface works on the Previewer" +
" may be different from that on a real device.")
},
on: function (...args) {
console.warn("HttpRequest.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, paramMock.paramObjectMock);
}
},
off: function (...args) {
console.warn("HttpRequest.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, paramMock.paramObjectMock);
}
}
}
const http = {
createHttp: function () {
console.warn("net.http.createHttp interface mocked in the Previewer. How this interface works on the Previewer" +
" may be different from that on a real device.")
return HttpRequestMock;
},
getInstalledHttpResponseCache: function (...args) {
console.warn("net.http.getInstalledHttpResponseCache interface mocked in the Previewer. How this interface works on the Previewer may" +
" be different from that on a real device.")
const len = args.length
if (typeof args[len - 1] === 'function') {
args[len - 1].call(this, paramMock.businessErrorMock, HttpResponseCache);
} else {
return new Promise((resolve, reject) => {
resolve(HttpResponseCache);
})
}
},
createHttpResponseCache: function (...args) {
console.warn("net.http.createHttpResponseCache interface mocked in the Previewer. How this interface works on the Previewer may" +
" be different from that on a real device.")
const len = args.length
if (typeof args[len - 1] === 'function') {
args[len - 1].call(this, paramMock.businessErrorMock, HttpResponseCacheOptions);
} else {
return new Promise((resolve, reject) => {
resolve(HttpResponseCache);
})
}
}
}
return http
}
@@ -0,0 +1,265 @@
/*
* Copyright (c) 2021 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import { paramMock } from "../utils"
export function mockSocket() {
const SocketStateBase = {
isBound: "[PC Preview] unknow isBound",
isClose: "[PC Preview] unknow isClose",
isConnected: "[PC Preview] unknow isConnected"
}
const SocketRemoteInfo = {
address: "[PC Preview] unknow address",
family: "[PC Preview] unknow family",
port: "[PC Preview] unknow port",
size: "[PC Preview] unknow size"
}
const NetAddress = {
address: "[PC Preview] unknow saddressize",
family: "[PC Preview] unknow family",
port: "[PC Preview] unknow port "
}
const UDPSocket = {
bind: function (...args) {
console.warn("UDPSocket.bind interface mocked in the Previewer. How this interface works on the Previewer" +
" may be 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();
})
}
},
send: function (...args) {
console.warn("UDPSocket.send interface mocked in the Previewer. How this interface works on the Previewer may" +
" be 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();
})
}
},
close: function (...args) {
console.warn("UDPSocket.close interface mocked in the Previewer. How this interface works on the Previewer may" +
" be 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();
})
}
},
getState: function (...args) {
console.warn("UDPSocket.getState interface mocked in the Previewer. How this interface works on the Previewer may" +
" be different from that on a real device.")
const len = args.length
if (typeof args[len - 1] === 'function') {
args[len - 1].call(this, paramMock.businessErrorMock, SocketStateBase)
} else {
return new Promise((resolve, reject) => {
resolve(SocketStateBase);
})
}
},
setExtraOptions: function (...args) {
console.warn("UDPSocket.setExtraOptions interface mocked in the Previewer. How this interface works on the Previewer may" +
" be different from that on a real device.")
const len = args.length
if (typeof args[len - 1] === 'function') {
args[len - 1].call(this, paramMock.businessErrorMock)
} else {
return new Promise((resolve, reject) => {
resolve();
})
}
},
on: function (...args) {
console.warn("UDPSocket.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] === 'message') {
args[len - 1].call(this, {
message: "[PC Preview] unknow message",
remoteInfo: SocketRemoteInfo
});
} else if (args[0] === 'listening') {
args[len - 1].call(this, paramMock.businessErrorMock);
} else if (args[0] === 'error') {
args[len - 1].call(this, paramMock.businessErrorMock);
}
}
},
off: function (...args) {
console.warn("UDPSocket.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] === 'message') {
args[len - 1].call(this, {
message: "[PC Preview] unknow message",
remoteInfo: SocketRemoteInfo
});
} else if (args[0] === 'listening') {
args[len - 1].call(this, paramMock.businessErrorMock);
} else if (args[0] === 'error') {
args[len - 1].call(this, paramMock.businessErrorMock);
}
}
}
}
const TCPSocket = {
bind: function (...args) {
console.warn("TcpSocket.bind interface mocked in the Previewer. How this interface works on the Previewer" +
" may be 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();
})
}
},
connect: function (...args) {
console.warn("TcpSocket.connect interface mocked in the Previewer. How this interface works on the Previewer" +
" may be 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();
})
}
},
send: function (...args) {
console.warn("TcpSocket.send interface mocked in the Previewer. How this interface works on the Previewer may" +
" be 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();
})
}
},
close: function (...args) {
console.warn("TcpSocket.close interface mocked in the Previewer. How this interface works on the Previewer may" +
" be 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();
})
}
},
getRemoteAddress: function (...args) {
console.warn("TcpSocket.getRemoteAddress interface mocked in the Previewer. How this interface works on the Previewer may" +
" be different from that on a real device.")
const len = args.length
if (typeof args[len - 1] === 'function') {
args[len - 1].call(this, paramMock.businessErrorMock, NetAddress)
} else {
return new Promise((resolve, reject) => {
resolve(NetAddress);
})
}
},
getState: function (...args) {
console.warn("TcpSocket.getState interface mocked in the Previewer. How this interface works on the Previewer may" +
" be different from that on a real device.")
const len = args.length
if (typeof args[len - 1] === 'function') {
args[len - 1].call(this, paramMock.businessErrorMock, SocketStateBase)
} else {
return new Promise((resolve, reject) => {
resolve(SocketStateBase);
})
}
},
setExtraOptions: function (...args) {
console.warn("TcpSocket.setExtraOptions interface mocked in the Previewer. How this interface works on the Previewer may" +
" be different from that on a real device.")
const len = args.length
if (typeof args[len - 1] === 'function') {
args[len - 1].call(this, paramMock.businessErrorMock)
} else {
return new Promise((resolve, reject) => {
resolve();
})
}
},
on: function (...args) {
console.warn("TcpSocket.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] === 'message') {
args[len - 1].call(this, {
message: "[PC Preview] unknow message",
remoteInfo: SocketRemoteInfo
});
} else if (args[0] === 'listening') {
args[len - 1].call(this, paramMock.businessErrorMock);
} else if (args[0] === 'error') {
args[len - 1].call(this, paramMock.businessErrorMock);
}
}
},
off: function (...args) {
console.warn("TcpSocket.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] === 'message') {
args[len - 1].call(this, {
message: "[PC Preview] unknow message",
remoteInfo: SocketRemoteInfo
});
} else if (args[0] === 'listening') {
args[len - 1].call(this, paramMock.businessErrorMock);
} else if (args[0] === 'error') {
args[len - 1].call(this, paramMock.businessErrorMock);
}
}
}
}
const socket = {
constructUDPSocketInstance: function () {
console.warn("net.socket.constructUDPSocketInstance interface mocked in the Previewer. How this interface works on the Previewer" +
" may be different from that on a real device.")
return UDPSocket;
},
constructTCPSocketInstance: function () {
console.warn("net.socket.constructTCPSocketInstance interface mocked in the Previewer. How this interface works on the Previewer" +
" may be different from that on a real device.")
return TCPSocket;
}
}
return socket
}
@@ -0,0 +1,104 @@
/*
* Copyright (c) 2021 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import { paramMock } from "../utils"
export function mockWebSocket() {
global.systemplugin.net = {}
const WebSocketMock = {
connect: function (...args) {
console.warn("WebSocket.connect interface mocked in the Previewer. How this interface works on the Previewer" +
" may be different from that on a real device.")
const len = args.length
if (typeof args[len - 1] === 'function') {
args[len - 1].call(this, paramMock.businessErrorMock, paramMock.paramBooleanMock);
} else {
return new Promise((resolve, reject) => {
resolve(paramMock.paramBooleanMock);
})
}
},
send: function (...args) {
console.warn("WebSocket.send interface mocked in the Previewer. How this interface works on the Previewer may" +
" be different from that on a real device.")
const len = args.length
if (typeof args[len - 1] === 'function') {
args[len - 1].call(this, paramMock.businessErrorMock, paramMock.paramBooleanMock);
} else {
return new Promise((resolve, reject) => {
resolve(paramMock.paramBooleanMock);
})
}
},
close: function (...args) {
console.warn("WebSocket.close interface mocked in the Previewer. How this interface works on the Previewer " +
"may be different from that on a real device.")
const len = args.length
if (typeof args[len - 1] === 'function') {
args[len - 1].call(this, paramMock.businessErrorMock, paramMock.paramBooleanMock);
} else {
return new Promise((resolve, reject) => {
resolve(paramMock.paramBooleanMock);
})
}
},
on: function (...args) {
console.warn("WebSocket.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] === 'open') {
args[len - 1].call(this, paramMock.businessErrorMock, paramMock.paramObjectMock);
} else if (args[0] === 'message') {
args[len - 1].call(this, paramMock.businessErrorMock, paramMock.paramStringMock);
} else if (args[0] === 'close') {
args[len - 1].call(this, paramMock.businessErrorMock, {
code: "[PC Preview] unknow code",
reason: "[PC Preview] unknow reason"
});
} else if (args[0] === 'error') {
args[len - 1].call(this, paramMock.businessErrorMock);
}
}
},
off: function (...args) {
console.warn("WebSocket.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] === 'open') {
args[len - 1].call(this, paramMock.businessErrorMock, paramMock.paramObjectMock);
} else if (args[0] === 'message') {
args[len - 1].call(this, paramMock.businessErrorMock, paramMock.paramStringMock);
} else if (args[0] === 'close') {
args[len - 1].call(this, paramMock.businessErrorMock, {
code: "[PC Preview] unknow code",
reason: "[PC Preview] unknow reason"
});
} else if (args[0] === 'error') {
args[len - 1].call(this, paramMock.businessErrorMock);
}
}
}
}
const webSocket = {
createWebSocket: function () {
console.warn("net.webSocket.createWebSocket interface mocked in the Previewer. How this interface works on the" +
" Previewer may be different from that on a real device.")
return WebSocketMock;
}
}
return webSocket
}
@@ -18,7 +18,7 @@ export function mockNetwork() {
metered: true,
type: "5g"
}
global.systemplugin.network = {
const network = {
getType: function (...args) {
console.warn("network.getType interface mocked in the Previewer. How this interface works on the Previewer may" +
" be different from that on a real device.")
@@ -41,4 +41,5 @@ export function mockNetwork() {
delete this.unsubscribeNetwork
}
}
return network
}
@@ -13,15 +13,14 @@
* limitations under the License.
*/
import { paramMock } from "./utils"
import { paramMock } from "../utils"
export function mockNfcCardEmulation() {
global.systemplugin.nfc = {}
global.systemplugin.nfc.cardEmulation = {
const cardEmulation = {
isSupported: function (...args) {
console.warn("nfc.cardEmulation.isSupported interface mocked in the Previewer. How this interface works on the" +
" Previewer may be different from that on a real device.")
return paramMock.paramBooleanMock;
}
}
}
}
@@ -0,0 +1,45 @@
/*
* Copyright (c) 2021 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import { paramMock } from "../utils"
export function mockController() {
const controller = {
isNfcAvailable: function (...args) {
console.warn("nfc.controller.isNfcAvailable interface mocked in the Previewer." +
"How this interface works on the Previewer may be different from that on a real device.")
return paramMock.paramBooleanMock;
},
isNfcOpen: function (...args) {
console.warn("nfc.controller.isNfcOpen interface mocked in the Previewer." +
"How this interface works on the Previewer may be different from that on a real device.")
return paramMock.paramBooleanMock;
},
on: function (...args) {
console.warn("nfc.controller.on interface mocked in the Previewer." +
"How this interface works on the Previewer may be different from that on a real device.")
},
off: function (...args) {
console.warn("nfc.controller.off interface mocked in the Previewer." +
"How this interface works on the Previewer may be different from that on a real device.")
},
getNfcState: function (...args) {
console.warn("nfc.controller.getNfcState interface mocked in the Previewer." +
"How this interface works on the Previewer may be different from that on a real device.")
return paramMock.paramNumberMock;
},
}
return controller
}
@@ -15,11 +15,7 @@
import { paramMock } from "../utils"
export function mockOhosNfc() {
global.ohosplugin.nfc = {}
const TagInfoMock = {
supportedProfiles: "[PC preview] unknown supportedProfiles",
}
export function mockTag() {
const NfcATagMock = {
getTagInfo: function (...args) {
console.warn("NfcATag.getTagInfo interface mocked in the Previewer." +
@@ -252,39 +248,7 @@ export function mockOhosNfc() {
return paramMock.paramNumberMock
},
}
global.ohosplugin.nfc.cardEmulation = {
isSupported: function (...args) {
console.warn("nfc.cardEmulation.isSupported interface mocked in the Previewer. How this interface works on the" +
" Previewer may be different from that on a real device.")
return paramMock.paramBooleanMock;
}
}
global.ohosplugin.nfc.controller = {
isNfcAvailable: function (...args) {
console.warn("nfc.controller.isNfcAvailable interface mocked in the Previewer." +
"How this interface works on the Previewer may be different from that on a real device.")
return paramMock.paramBooleanMock;
},
isNfcOpen: function (...args) {
console.warn("nfc.controller.isNfcOpen interface mocked in the Previewer." +
"How this interface works on the Previewer may be different from that on a real device.")
return paramMock.paramBooleanMock;
},
on: function (...args) {
console.warn("nfc.controller.on interface mocked in the Previewer." +
"How this interface works on the Previewer may be different from that on a real device.")
},
off: function (...args) {
console.warn("nfc.controller.off interface mocked in the Previewer." +
"How this interface works on the Previewer may be different from that on a real device.")
},
getNfcState: function (...args) {
console.warn("nfc.controller.getNfcState interface mocked in the Previewer." +
"How this interface works on the Previewer may be different from that on a real device.")
return paramMock.paramNumberMock;
},
}
global.ohosplugin.nfc.tag = {
const tag = {
getNfcATag: function (...args) {
console.warn("nfc.tag.getNfcATag interface mocked in the Previewer. How this interface works on the" +
" Previewer may be different from that on a real device.")
@@ -306,4 +270,5 @@ export function mockOhosNfc() {
return NfcVTagMock;
},
}
}
return tag
}
@@ -13,7 +13,7 @@
* limitations under the License.
*/
import { paramMock } from "./utils"
import { paramMock } from "../utils"
export function mockPasteBoard() {
const PasteDataMock = {
@@ -49,7 +49,7 @@ export function mockPasteBoard() {
}
}
}
global.systemplugin.pasteboard = {
const pasteboard = {
createPlainTextData: function () {
console.warn("pasteboard.createPlainTextData interface mocked in the Previewer. How this interface works on" +
" the Previewer may be different from that on a real device.")
@@ -61,4 +61,5 @@ export function mockPasteBoard() {
return SystemPasteboardMock;
}
}
return pasteboard
}
@@ -49,7 +49,7 @@ export function mockReminderAgent() {
const reminderReqs = [
reminderReq
]
global.ohosplugin.reminderAgent = {
const reminderAgent = {
publishReminder: function (...args) {
console.warn("reminderAgent.publishReminder interface mocked in the Previewer." +
"How this interface works on the Previewer may be different from that on a real device.")
@@ -123,4 +123,5 @@ export function mockReminderAgent() {
}
}
}
return reminderAgent
}
@@ -13,7 +13,7 @@
* limitations under the License.
*/
import { hasComplete } from "./utils"
import { hasComplete } from "../utils"
export function mockRequest() {
const uploadResponseMock = {
@@ -27,7 +27,7 @@ export function mockRequest() {
const onDownloadCompleteMock = {
uri: "[PC Preview]: unknow uri"
}
global.systemplugin.request = {
const request = {
upload: function (...args) {
console.warn("system.request.upload interface mocked in the Previewer. How this interface works on the" +
" Previewer may be different from that on a real device.")
@@ -47,4 +47,5 @@ export function mockRequest() {
hasComplete(args[0].complete)
}
}
return request
}
@@ -0,0 +1,207 @@
/*
* Copyright (c) 2021 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
export function mockResourceManager() {
function Configuration(direction, locale) {
this.direction = direction;
this.locale = locale;
}
function DeviceCapability(screenDensity, deviceType) {
this.screenDensity = screenDensity;
this.deviceType = deviceType;
}
function ResourceManager(mgrId, module) {
var resMgrId = mgrId;
var resourcemgrModuleGroup = module;
this.getString = getString;
async function getString(resId, callback) {
var data = "mock string";
console.warn("ResourceManager.getString interface mocked in the Previewer. " +
"How this interface works on the Previewer may be different from that on a real device.")
if (typeof callback === 'function') {
callback.call(this, null, data);
} else {
return new Promise((resolve) => {
resolve(data);
})
}
}
this.getStringArray = getStringArray;
async function getStringArray(resId, callback) {
var data = ["mock string1", "mock string2"];
console.warn("ResourceManager.getStringArray interface mocked in the Previewer. " +
"How this interface works on the Previewer may be different from that on a real device.")
if (typeof callback === 'function') {
callback.call(this, null, data);
} else {
return new Promise((resolve) => {
resolve(data);
})
}
}
this.getMedia = getMedia;
async function getMedia(resId, callback) {
var data = "mock media data";
console.warn("ResourceManager.getMedia interface mocked in the Previewer. " +
"How this interface works on the Previewer may be different from that on a real device.")
if (typeof callback === 'function') {
callback.call(this, 1, data);
} else {
return new Promise((resolve, reject) => {
reject(data);
})
}
}
this.getMediaBase64 = getMediaBase64;
async function getMediaBase64(resId, callback) {
var data = "mock media data";
console.warn("ResourceManager.getMediaBase64 interface mocked in the Previewer. " +
"How this interface works on the Previewer may be different from that on a real device.")
if (typeof callback === 'function') {
callback.call(this, 1, data);
} else {
return new Promise((resolve, reject) => {
reject(data);
})
}
}
this.getPluralString = getPluralString;
async function getPluralString(resId, num, callback) {
var data = "mock plural string";
console.warn("ResourceManager.getPluralString interface mocked in the Previewer. " +
"How this interface works on the Previewer may be different from that on a real device.")
if (typeof callback === 'function') {
callback.call(this, null, data);
} else {
return new Promise((resolve) => {
resolve(data);
})
}
}
this.getConfiguration = getConfiguration;
async function getConfiguration(callback) {
var data = { "direction": 0, "locale": "zh_CN" };
console.warn("ResourceManager.getConfiguration interface mocked in the Previewer. " +
"How this interface works on the Previewer may be different from that on a real device.")
if (typeof callback === 'function') {
callback.call(this, null, data);
} else {
return new Promise((resolve) => {
resolve(data);
})
}
}
this.getDeviceCapability = getDeviceCapability;
async function getDeviceCapability(callback) {
var data = { "deviceType": 0, "screenDensity": 480 };
console.warn("ResourceManager.getDeviceCapability interface mocked in the Previewer. " +
"How this interface works on the Previewer may be different from that on a real device.")
if (typeof callback === 'function') {
callback.call(this, null, data);
} else {
return new Promise((resolve) => {
resolve(data);
})
}
}
this.release = release;
async function release(callback) {
console.warn("ResourceManager.release interface mocked in the Previewer. " +
"How this interface works on the Previewer may be different from that on a real device.")
}
this.getRawFile = getRawFile;
async function getRawFile(path, callback) {
var data = "mock raw file";
console.warn("ResourceManager.getRawFile interface mocked in the Previewer. " +
"How this interface works on the Previewer may be different from that on a real device.")
if (typeof callback === 'function') {
callback.call(this, null, data);
} else {
return new Promise((resolve) => {
resolve(data);
})
}
}
this.getRawFileDescriptor = getRawFileDescriptor;
async function getRawFileDescriptor(path, callback) {
var data = "mock raw file descriptor";
console.warn("ResourceManager.getRawFileDescriptor interface mocked in the Previewer. " +
"How this interface works on the Previewer may be different from that on a real device.")
if (typeof callback === 'function') {
callback.call(this, null, data);
} else {
return new Promise((resolve) => {
resolve(data);
})
}
}
this.closeRawFileDescriptor = closeRawFileDescriptor;
async function closeRawFileDescriptor(path, callback) {
var data = "mock close raw file descriptor";
console.warn("ResourceManager.closeRawFileDescriptor interface mocked in the Previewer. " +
"How this interface works on the Previewer may be different from that on a real device.")
if (typeof callback === 'function') {
callback.call(this, null, data);
} else {
return new Promise((resolve) => {
resolve(data);
})
}
}
}
var resourceManager = {
getResourceManager: async function getResourceManager(optBundleName, optCallback) {
let bundleName = '';
let callback;
if (typeof optCallback == 'function') {
bundleName = optBundleName ? optBundleName : '';
callback = optCallback;
} else if (typeof optBundleName == 'function') {
callback = optBundleName;
} else {
bundleName = optBundleName ? optBundleName : '';
}
let data = new ResourceManager(1, null);
console.warn("ResourceManager.getResourceManager interface mocked in the Previewer. " +
"How this interface works on the Previewer may be different from that on a real device.")
if (typeof callback === 'function') {
callback.call(this, 1, data);
} else {
return new Promise((resolve) => {
resolve(data);
})
}
}
};
const resourceManager = {
getResourceManager: resourceManager.getResourceManager
}
return resourceManager
}
@@ -13,10 +13,10 @@
* limitations under the License.
*/
import { paramMock } from "./utils"
import { paramMock } from "../utils"
export function mockScreenLock() {
global.systemplugin.screenLock = {
const screenLock = {
isScreenLocked: function (...args) {
console.warn("screenLock.isScreenLocked interface mocked in the Previewer. How this interface works on the" +
" Previewer may be different from that on a real device.")
@@ -54,4 +54,5 @@ export function mockScreenLock() {
}
}
}
return screenLock
}
@@ -13,31 +13,31 @@
* limitations under the License.
*/
import { paramMock } from "./utils"
import { paramMock } from "../utils"
export function mockScreenshot() {
const RectMock = {
const RectMock = {
left: '[PC preview] unknow Rect.left',
top: '[PC preview] unknow Rect.top',
width: '[PC preview] unknow Rect.width',
height: '[PC preview] unknow Rect.height'
}
const SizeMock = {
const SizeMock = {
width: '[PC preview] unknow Size.width',
height: '[PC preview] unknow Size.height',
}
const ScreenshotOptionsMock= {
const ScreenshotOptionsMock = {
screenRect: RectMock,
imageSize: SizeMock,
rotation: '[PC preview] unknow Size.width',
displayId: '[PC preview] unknow Size.width',
displayId: '[PC preview] unknow Size.width',
}
const screenshotMock = {
ImageSource: '[PC preview] unknow ImageSource'
}
global.systemplugin.screenshot = {
const screenshot = {
save: function (...args) {
console.warn("screenshot.save interface mocked in the Previewer. How this interface works on the Previewer" +
" may be different from that on a real device.")
@@ -51,4 +51,5 @@ export function mockScreenshot() {
}
}
}
return screenshot
}
@@ -13,7 +13,7 @@
* limitations under the License.
*/
import { paramMock } from "./utils"
import { paramMock } from "../utils"
export function mockHuks() {
@@ -36,7 +36,7 @@ export function mockHuks() {
properties: [HuksParamMock],
certChains: [paramMock.paramStringMock],
}
global.systemplugin.huks = {
const huks = {
generateKey: function (...args) {
console.warn("huks.generateKey interface mocked in the Previewer. How this interface works on the Previewer" +
" may be different from that on a real device.")
@@ -438,4 +438,5 @@ export function mockHuks() {
HUKS_TAG_ASYMMETRIC_PRIVATE_KEY_DATA: 20003,
},
}
return huks
}
@@ -16,7 +16,7 @@
import { paramMock } from "../utils"
export function mockSystemTime() {
global.ohosplugin.systemTime = {
const systemTime = {
setTime: function (...args) {
console.warn('systemTime.setTime interface mocked in the Previewer. How this interface works on the'
+ 'Previewer may be different from that on a real device.');
@@ -149,5 +149,6 @@ export function mockSystemTime() {
});
}
},
};
}
return systemTime
}
@@ -16,7 +16,7 @@
import { paramMock } from "../utils"
export function mockSystemTimer() {
global.ohosplugin.systemTimer = {
const systemTimer = {
TIMER_TYPE_REALTIME: '[PC preview] unknow TIMER_TYPE_REALTIME',
TIMER_TYPE_WAKEUP: '[PC preview] unknow TIMER_TYPE_WAKEUP',
TIMER_TYPE_EXACT: '[PC preview] unknow TIMER_TYPE_EXACT',
@@ -70,4 +70,5 @@ export function mockSystemTimer() {
}
}
}
return systemTimer
}
@@ -0,0 +1,561 @@
/*
* Copyright (c) 2021 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import { paramMock } from "../utils"
export function mockCall() {
const CallWaitingStatus = "[PC Preview] unknow CallWaitingStatus";
const RestrictionStatus = "[PC Preview] unknow RestrictionStatus";
const CallAttributeOptions = {
accountNumber: "[PC Preview] unknow accountNumber",
speakerphoneOn: "[PC Preview] unknow speakerphoneOn",
accountId: "[PC Preview] unknow accountId",
videoState: "[PC Preview] unknow videoState",
startTime: "[PC Preview] unknow startTime",
isEcc: "[PC Preview] unknow isEcc",
callType: "[PC Preview] unknow callType",
callId: "[PC Preview] unknow callId",
callState: "[PC Preview] unknow callState",
conferenceState: "[PC Preview] unknow conferenceState"
}
const CallTransferResult = {
status: "[PC Preview] unknow status",
number: "[PC Preview] unknow number",
}
const call = {
dial: function (...args) {
console.warn("telephony.call.dial interface mocked in the Previewer. How this interface works on the Previewer may" +
" be different from that on a real device.")
const len = args.length
if (typeof args[len - 1] === 'function') {
args[len - 1].call(this, paramMock.businessErrorMock, paramMock.paramBooleanMock);
} else {
return new Promise((resolve, reject) => {
resolve(paramMock.paramBooleanMock);
})
}
},
makeCall: function (...args) {
console.warn("telephony.call.makeCall interface mocked in the Previewer. How this interface works on the Previewer may" +
" be 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();
})
}
},
hasCall: function (...args) {
console.warn("telephony.call.hasCall interface mocked in the Previewer. How this interface works on the Previewer may" +
" be different from that on a real device.")
const len = args.length
if (typeof args[len - 1] === 'function') {
args[len - 1].call(this, paramMock.businessErrorMock, paramMock.paramBooleanMock);
} else {
return new Promise((resolve, reject) => {
resolve(paramMock.paramBooleanMock);
})
}
},
getCallState: function (...args) {
console.warn("telephony.call.getCallState interface mocked in the Previewer. How this interface works on the Previewer may" +
" be different from that on a real device.")
const len = args.length
if (typeof args[len - 1] === 'function') {
args[len - 1].call(this, paramMock.businessErrorMock, CallState);
} else {
return new Promise((resolve, reject) => {
resolve(CallState);
})
}
},
displayCallScreen: function (...args) {
console.warn("telephony.call.displayCallScreen interface mocked in the Previewer. How this interface works on the Previewer may" +
" be 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();
})
}
},
muteRinger: function (...args) {
console.warn("telephony.call.muteRinger interface mocked in the Previewer. How this interface works on the Previewer may" +
" be 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();
})
}
},
hasVoiceCapability: function () {
console.warn("telephony.call.hasVoiceCapability interface mocked in the Previewer. How this interface works on the Previewer may" +
" be different from that on a real device.")
return paramMock.paramBooleanMock;
},
isVideoCallingEnabled: function (...args) {
console.warn("telephony.call.isVideoCallingEnabled interface mocked in the Previewer. How this interface works on the Previewer may" +
" be different from that on a real device.")
const len = args.length
if (typeof args[len - 1] === 'function') {
args[len - 1].call(this, paramMock.businessErrorMock, paramMock.paramBooleanMock);
} else {
return new Promise((resolve, reject) => {
resolve(paramMock.paramBooleanMock);
})
}
},
inputDialerSpecialCode: function (...args) {
console.warn("telephony.call.inputDialerSpecialCode interface mocked in the Previewer. How this interface works on the Previewer may" +
" be 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();
})
}
},
isHacEnabled: function (...args) {
console.warn("telephony.call.isHacEnabled interface mocked in the Previewer. How this interface works on the Previewer may" +
" be different from that on a real device.")
const len = args.length
if (typeof args[len - 1] === 'function') {
args[len - 1].call(this, paramMock.businessErrorMock, paramMock.paramBooleanMock);
} else {
return new Promise((resolve, reject) => {
resolve(paramMock.paramBooleanMock);
})
}
},
isEmergencyPhoneNumber: function (...args) {
console.warn("telephony.call.isEmergencyPhoneNumber interface mocked in the Previewer. How this interface works on the Previewer may" +
" be different from that on a real device.")
const len = args.length
if (typeof args[len - 1] === 'function') {
args[len - 1].call(this, paramMock.businessErrorMock, paramMock.paramBooleanMock);
} else {
return new Promise((resolve, reject) => {
resolve(paramMock.paramBooleanMock);
})
}
},
formatPhoneNumber: function (...args) {
console.warn("telephony.call.formatPhoneNumber interface mocked in the Previewer. How this interface works on the Previewer may" +
" be 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);
})
}
},
formatPhoneNumberToE164: function (...args) {
console.warn("telephony.call.formatPhoneNumberToE164 interface mocked in the Previewer. How this interface works on the Previewer may" +
" be 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);
})
}
},
comparePhoneNumbers: function (...args) {
console.warn("telephony.call.comparePhoneNumbers interface mocked in the Previewer. How this interface works on the Previewer may" +
" be different from that on a real device.")
const len = args.length
if (typeof args[len - 1] === 'function') {
args[len - 1].call(this, paramMock.businessErrorMock, paramMock.paramBooleanMock);
} else {
return new Promise((resolve, reject) => {
resolve(paramMock.paramBooleanMock);
})
}
},
getCallerIndex: function (...args) {
console.warn("telephony.call.getCallerIndex interface mocked in the Previewer. How this interface works on the Previewer may" +
" be different from that on a real device.")
const len = args.length
if (typeof args[len - 1] === 'function') {
args[len - 1].call(this, paramMock.businessErrorMock, paramMock.paramNumberMock);
} else {
return new Promise((resolve, reject) => {
resolve(paramMock.paramNumberMock);
})
}
},
getCountryCodeFromDbNumber: function (...args) {
console.warn("telephony.call.getCountryCodeFromDbNumber interface mocked in the Previewer. How this interface works on the Previewer may" +
" be 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);
})
}
},
getIntlPrefixAndCountryCodeLen: function (...args) {
console.warn("telephony.call.getIntlPrefixAndCountryCodeLen interface mocked in the Previewer. How this interface works on the Previewer may" +
" be different from that on a real device.")
const len = args.length
if (typeof args[len - 1] === 'function') {
args[len - 1].call(this, paramMock.businessErrorMock, paramMock.paramNumberMock);
} else {
return new Promise((resolve, reject) => {
resolve(paramMock.paramNumberMock);
})
}
},
answer: function (...args) {
console.warn("telephony.call.answer interface mocked in the Previewer. How this interface works on the Previewer may" +
" be 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();
})
}
},
hangup: function (...args) {
console.warn("telephony.call.hangup interface mocked in the Previewer. How this interface works on the Previewer may" +
" be 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();
})
}
},
reject: function (...args) {
console.warn("telephony.call.reject interface mocked in the Previewer. How this interface works on the Previewer may" +
" be 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();
})
}
},
holdCall: function (...args) {
console.warn("telephony.call.holdCall interface mocked in the Previewer. How this interface works on the Previewer may" +
" be 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();
})
}
},
unHoldCall: function (...args) {
console.warn("telephony.call.unHoldCall interface mocked in the Previewer. How this interface works on the Previewer may" +
" be 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();
})
}
},
switchCall: function (...args) {
console.warn("telephony.call.switchCall interface mocked in the Previewer. How this interface works on the Previewer may" +
" be 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();
})
}
},
combineConference: function (...args) {
console.warn("telephony.call.combineConference interface mocked in the Previewer. How this interface works on the Previewer may" +
" be 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();
})
}
},
getMainCallId: function (...args) {
console.warn("telephony.call.getMainCallId interface mocked in the Previewer. How this interface works on the Previewer may" +
" be different from that on a real device.")
const len = args.length
if (typeof args[len - 1] === 'function') {
args[len - 1].call(this, paramMock.businessErrorMock, paramMock.paramNumberMock);
} else {
return new Promise((resolve, reject) => {
resolve(paramMock.paramNumberMock);
})
}
},
getSubCallIdList: function (...args) {
console.warn("telephony.call.getSubCallIdList interface mocked in the Previewer. How this interface works on the Previewer may" +
" be 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);
})
}
},
getCallIdListForConference: function (...args) {
console.warn("telephony.call.getCallIdListForConference interface mocked in the Previewer. How this interface works on the Previewer may" +
" be 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);
})
}
},
getCallWaitingStatus: function (...args) {
console.warn("telephony.call.getCallWaitingStatus interface mocked in the Previewer. How this interface works on the Previewer may" +
" be different from that on a real device.")
const len = args.length
if (typeof args[len - 1] === 'function') {
args[len - 1].call(this, paramMock.businessErrorMock, CallWaitingStatus);
} else {
return new Promise((resolve, reject) => {
resolve(CallWaitingStatus);
})
}
},
setCallWaiting: function (...args) {
console.warn("telephony.call.setCallWaiting interface mocked in the Previewer. How this interface works on the Previewer may" +
" be 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();
})
}
},
startDTMF: function (...args) {
console.warn("telephony.call.startDTMF interface mocked in the Previewer. How this interface works on the Previewer may" +
" be 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();
})
}
},
stopDTMF: function (...args) {
console.warn("telephony.call.stopDTMF interface mocked in the Previewer. How this interface works on the Previewer may" +
" be 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();
})
}
},
isInEmergencyCall: function (...args) {
console.warn("telephony.call.isInEmergencyCall interface mocked in the Previewer. How this interface works on the Previewer may" +
" be different from that on a real device.")
const len = args.length
if (typeof args[len - 1] === 'function') {
args[len - 1].call(this, paramMock.businessErrorMock, paramMock.paramBooleanMock);
} else {
return new Promise((resolve, reject) => {
resolve(paramMock.paramBooleanMock);
})
}
},
on: function (...args) {
console.warn("telephony.call.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] == 'callDetailsChange') {
args[len - 1].call(this, CallAttributeOptions);
} else if (args[0] == 'callEventChange') {
args[len - 1].call(this, paramMock.paramObjectMock);
}
}
},
off: function (...args) {
console.warn("telephony.call.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] == 'callDetailsChange') {
args[len - 1].call(this, CallAttributeOptions);
} else if (args[0] == 'callEventChange') {
args[len - 1].call(this, paramMock.paramObjectMock);
}
}
},
isNewCallAllowed: function (...args) {
console.warn("telephony.call.isNewCallAllowed interface mocked in the Previewer. How this interface works on the Previewer may" +
" be different from that on a real device.")
const len = args.length
if (typeof args[len - 1] === 'function') {
args[len - 1].call(this, paramMock.businessErrorMock, paramMock.paramBooleanMock);
} else {
return new Promise((resolve, reject) => {
resolve(paramMock.paramBooleanMock);
})
}
},
separateConference: function (...args) {
console.warn("telephony.call.separateConference interface mocked in the Previewer. How this interface works on the Previewer may" +
" be 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();
})
}
},
getCallRestrictionStatus: function (...args) {
console.warn("telephony.call.getCallRestrictionStatus interface mocked in the Previewer. How this interface works on the Previewer may" +
" be different from that on a real device.")
const len = args.length
if (typeof args[len - 1] === 'function') {
args[len - 1].call(this, paramMock.businessErrorMock, RestrictionStatus);
} else {
return new Promise((resolve, reject) => {
resolve(RestrictionStatus);
})
}
},
setCallRestriction: function (...args) {
console.warn("telephony.call.setCallRestriction interface mocked in the Previewer. How this interface works on the Previewer may" +
" be 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();
})
}
},
setCallTransfer: function (...args) {
console.warn("telephony.call.setCallTransfer interface mocked in the Previewer. How this interface works on the Previewer may" +
" be 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();
})
}
},
getCallTransferInfo: function (...args) {
console.warn("telephony.call.getCallTransferInfo interface mocked in the Previewer. How this interface works on the Previewer may" +
" be different from that on a real device.")
const len = args.length
if (typeof args[len - 1] === 'function') {
args[len - 1].call(this, paramMock.businessErrorMock, CallTransferResult);
} else {
return new Promise((resolve, reject) => {
resolve(CallTransferResult);
})
}
},
setCallTransferInfo: function (...args) {
console.warn("telephony.call.setCallTransferInfo interface mocked in the Previewer. How this interface works on the Previewer may" +
" be 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();
})
}
},
isRinging: function (...args) {
console.warn("telephony.call.isRinging interface mocked in the Previewer. How this interface works on the Previewer may" +
" be different from that on a real device.")
const len = args.length
if (typeof args[len - 1] === 'function') {
args[len - 1].call(this, paramMock.businessErrorMock, paramMock.paramBooleanMock);
} else {
return new Promise((resolve, reject) => {
resolve(paramMock.paramBooleanMock);
})
}
},
setMuted: function (...args) {
console.warn("telephony.call.setMuted interface mocked in the Previewer. How this interface works on the Previewer may" +
" be 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();
})
}
},
setAudioDevice: function (...args) {
console.warn("telephony.call.setAudioDevice interface mocked in the Previewer. How this interface works on the Previewer may" +
" be 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 call
}
@@ -0,0 +1,142 @@
/*
* Copyright (c) 2021 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import { paramMock } from "../utils"
export function mockData() {
const data = {
getDefaultCellularDataSlotId: function (...args) {
console.warn("telephony.data.getDefaultCellularDataSlotId interface mocked in the Previewer. How this interface works on the Previewer may" +
" be different from that on a real device.")
const len = args.length
if (typeof args[len - 1] === 'function') {
args[len - 1].call(this, paramMock.businessErrorMock, paramMock.paramNumberMock);
} else {
return new Promise((resolve, reject) => {
resolve(paramMock.paramNumberMock);
})
}
},
setDefaultCellularDataSlotId: function (...args) {
console.warn("telephony.data.setDefaultCellularDataSlotId interface mocked in the Previewer. How this interface works on the Previewer may" +
" be 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();
})
}
},
getCellularDataFlowType: function (...args) {
console.warn("telephony.data.getCellularDataFlowType interface mocked in the Previewer. How this interface works on the Previewer may" +
" be different from that on a real device.")
const len = args.length
if (typeof args[len - 1] === 'function') {
args[len - 1].call(this, paramMock.businessErrorMock, paramMock.paramNumberMock);
} else {
return new Promise((resolve, reject) => {
resolve(paramMock.paramNumberMock);
})
}
},
getCellularDataState: function (...args) {
console.warn("telephony.data.getCellularDataState interface mocked in the Previewer. How this interface works on the Previewer may" +
" be different from that on a real device.")
const len = args.length
if (typeof args[len - 1] === 'function') {
args[len - 1].call(this, paramMock.businessErrorMock, paramMock.paramNumberMock);
} else {
return new Promise((resolve, reject) => {
resolve(paramMock.paramNumberMock);
})
}
},
isCellularDataEnabled: function (...args) {
console.warn("telephony.data.isCellularDataEnabled interface mocked in the Previewer. How this interface works on the Previewer may" +
" be different from that on a real device.")
const len = args.length
if (typeof args[len - 1] === 'function') {
args[len - 1].call(this, paramMock.businessErrorMock, paramMock.paramBooleanMock);
} else {
return new Promise((resolve, reject) => {
resolve(paramMock.paramBooleanMock);
})
}
},
enableCellularData: function (...args) {
console.warn("telephony.data.enableCellularData interface mocked in the Previewer. How this interface works on the Previewer may" +
" be 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();
})
}
},
disableCellularData: function (...args) {
console.warn("telephony.data.disableCellularData interface mocked in the Previewer. How this interface works on the Previewer may" +
" be 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();
})
}
},
isCellularDataRoamingEnabled: function (...args) {
console.warn("telephony.data.isCellularDataRoamingEnabled interface mocked in the Previewer. How this interface works on the Previewer may" +
" be different from that on a real device.")
const len = args.length
if (typeof args[len - 1] === 'function') {
args[len - 1].call(this, paramMock.businessErrorMock, paramMock.paramBooleanMock);
} else {
return new Promise((resolve, reject) => {
resolve(paramMock.paramBooleanMock);
})
}
},
enableCellularDataRoaming: function (...args) {
console.warn("telephony.data.enableCellularDataRoaming interface mocked in the Previewer. How this interface works on the Previewer may" +
" be 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();
})
}
},
disableCellularDataRoaming: function (...args) {
console.warn("telephony.data.disableCellularDataRoaming interface mocked in the Previewer. How this interface works on the Previewer may" +
" be 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 data
}
@@ -0,0 +1,116 @@
/*
* Copyright (c) 2021 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import { paramMock } from "../utils"
export function mockObserver() {
const SimStateData = {
type: "[PC Preview] unknow type",
state: "[PC Preview] unknow state",
}
const observer = {
on: function (...args) {
console.warn("telephony.observer.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] === 'networkStateChange') {
args[len - 1].call(this, NetworkState);
} else if (args[0] === 'signalInfoChange') {
args[len - 1].call(this, [SignalInformation]);
} else if (args[0] === 'cellInfoChange') {
args[len - 1].call(this, [CellInformation]);
} else if (args[0] === 'cellularDataConnectionStateChange') {
args[len - 1].call(this, paramMock.businessErrorMock, {
state: "[PC Preview] unknow state",
network: "[PC Preview] unknow network"
});
} else if (args[0] === 'cellularDataFlowChange') {
args[len - 1].call(this, DataFlowType);
} else if (args[0] === 'callStateChange') {
args[len - 1].call(this, paramMock.businessErrorMock, {
state: "[PC Preview] unknow state",
number: "[PC Preview] unknow number"
});
} else if (args[0] === 'cfuIndicatorChange' || 'voiceMailMsgIndicatorChange') {
args[len - 1].call(this, paramMock.paramBooleanMock);
} else if (args[0] === 'simStateChange') {
args[len - 1].call(this, SimStateData);
}
}
},
off: function (...args) {
console.warn("telephony.observer.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] === 'networkStateChange') {
args[len - 1].call(this, NetworkState);
} else if (args[0] === 'signalInfoChange') {
args[len - 1].call(this, [SignalInformation]);
} else if (args[0] === 'cellInfoChange') {
args[len - 1].call(this, [CellInformation]);
} else if (args[0] === 'cellularDataConnectionStateChange') {
args[len - 1].call(this, paramMock.businessErrorMock, {
state: "[PC Preview] unknow state",
network: "[PC Preview] unknow network"
});
} else if (args[0] === 'cellularDataFlowChange') {
args[len - 1].call(this, DataFlowType);
} else if (args[0] === 'callStateChange') {
args[len - 1].call(this, paramMock.businessErrorMock, {
state: "[PC Preview] unknow state",
number: "[PC Preview] unknow number"
});
} else if (args[0] === 'cfuIndicatorChange' || 'voiceMailMsgIndicatorChange') {
args[len - 1].call(this, paramMock.paramBooleanMock);
} else if (args[0] === 'simStateChange') {
args[len - 1].call(this, SimStateData);
}
}
},
once: function (...args) {
console.warn("telephony.observer.once interface mocked in the Previewer. How this interface works on the Previewer may " +
"be different from that on a real device.")
const len = args.length
if (typeof args[len - 1] === 'function') {
if (args[0] === 'networkStateChange') {
args[len - 1].call(this, NetworkState);
} else if (args[0] === 'signalInfoChange') {
args[len - 1].call(this, [SignalInformation]);
} else if (args[0] === 'cellInfoChange') {
args[len - 1].call(this, [CellInformation]);
} else if (args[0] === 'cellularDataConnectionStateChange') {
args[len - 1].call(this, paramMock.businessErrorMock, {
state: "[PC Preview] unknow state",
network: "[PC Preview] unknow network"
});
} else if (args[0] === 'cellularDataFlowChange') {
args[len - 1].call(this, DataFlowType);
} else if (args[0] === 'callStateChange') {
args[len - 1].call(this, paramMock.businessErrorMock, {
state: "[PC Preview] unknow state",
number: "[PC Preview] unknow number"
});
} else if (args[0] === 'cfuIndicatorChange' || 'voiceMailMsgIndicatorChange') {
args[len - 1].call(this, paramMock.paramBooleanMock);
} else if (args[0] === 'simStateChange') {
args[len - 1].call(this, SimStateData);
}
}
}
}
return observer
}
@@ -0,0 +1,320 @@
/*
* Copyright (c) 2021 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import { paramMock } from "../utils"
const NetworkState = {
longOperatorName: "[PC Preview] unknow longOperatorName",
shortOperatorName: "[PC Preview] unknow shortOperatorName",
plmnNumeric: "[PC Preview] unknow plmnNumeric",
isRoaming: "[PC Preview] unknow isRoaming",
regState: "[PC Preview] unknow regState",
nsaState: "[PC Preview] unknow nsaState",
isCaActive: "[PC Preview] unknow isCaActive",
isEmergency: "[PC Preview] unknow isEmergency",
}
const SignalInformation = {
signalType: "[PC Preview] unknow signalType",
signalLevel: "[PC Preview] unknow signalLevel"
}
const DataFlowType = "[PC Preview] unknow DataFlowType"
const DataConnectState = "[PC Preview] unknow DataConnectState"
const CellInformation = {
networkType: "[PC Preview] unknow networkType",
isCamped: "[PC Preview] unknow isCamped",
timeStamp: "[PC Preview] unknow timeStamp",
signalInformation: "[PC Preview] unknow signalInformation",
data: "[PC Preview] unknow unkown data"
}
export function mockRadio() {
const NetworkSearchResult = {
isNetworkSearchSuccess: "[PC Preview] unknow isNetworkSearchSuccess",
networkSearchResult: [{
operatorName: "[PC Preview] unknow operatorName",
operatorNumeric: "[PC Preview] unknow operatorNumeric",
state: "[PC Preview] unknow state",
radioTech: "[PC Preview] unknow radioTech"
}]
}
const PreferredNetworkMode = "[PC Preview] unknow PreferredNetworkMode"
const NrOptionMode = "[PC Preview] unknow NrOptionMode"
const NetworkSelectionMode = "[PC Preview] unknow unkown NetworkSelectionMode"
const radio = {
getRadioTech: function (...args) {
console.warn("telephony.radio.getRadioTech interface mocked in the Previewer. How this interface works on the Previewer may" +
" be different from that on a real device.")
const len = args.length
if (typeof args[len - 1] === 'function') {
args[len - 1].call(this, paramMock.businessErrorMock, {
psRadioTech: "[PC Preview] unknow psRadioTech",
csRadioTech: "[PC Preview] unknow csRadioTech"
});
} else {
return new Promise((resolve, reject) => {
resolve({
psRadioTech: "[PC Preview] unknow psRadioTech",
csRadioTech: "[PC Preview] unknow csRadioTech"
});
})
}
},
getNetworkState: function (...args) {
console.warn("telephony.radio.getNetworkState interface mocked in the Previewer. How this interface works on the Previewer may" +
" be different from that on a real device.")
const len = args.length
if (typeof args[len - 1] === 'function') {
args[len - 1].call(this, paramMock.businessErrorMock, NetworkState);
} else {
return new Promise((resolve, reject) => {
resolve(NetworkState);
})
}
},
sendUpdateCellLocationRequest: function (...args) {
console.warn("telephony.radio.sendUpdateCellLocationRequest interface mocked in the Previewer. How this interface works on the Previewer may" +
" be 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();
})
}
},
getCellInformation: function (...args) {
console.warn("telephony.radio.getCellInformation interface mocked in the Previewer. How this interface works on the Previewer may" +
" be different from that on a real device.")
const len = args.length
if (typeof args[len - 1] === 'function') {
args[len - 1].call(this, paramMock.businessErrorMock, [CellInformation]);
} else {
return new Promise((resolve, reject) => {
resolve([CellInformation]);
})
}
},
getNetworkSelectionMode: function (...args) {
console.warn("telephony.radio.getNetworkSelectionMode interface mocked in the Previewer. How this interface works on the Previewer may" +
" be different from that on a real device.")
const len = args.length
if (typeof args[len - 1] === 'function') {
args[len - 1].call(this, paramMock.businessErrorMock, NetworkSelectionMode);
} else {
return new Promise((resolve, reject) => {
resolve(NetworkSelectionMode);
})
}
},
setNetworkSelectionMode: function (...args) {
console.warn("telephony.radio.setNetworkSelectionMode interface mocked in the Previewer. How this interface works on the Previewer may" +
" be 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();
})
}
},
getNetworkSearchInformation: function (...args) {
console.warn("telephony.radio.getNetworkSearchInformation interface mocked in the Previewer. How this interface works on the Previewer may" +
" be different from that on a real device.")
const len = args.length
if (typeof args[len - 1] === 'function') {
args[len - 1].call(this, paramMock.businessErrorMock, NetworkSearchResult);
} else {
return new Promise((resolve, reject) => {
resolve(NetworkSearchResult);
})
}
},
getISOCountryCodeForNetwork: function (...args) {
console.warn("telephony.radio.getISOCountryCodeForNetwork interface mocked in the Previewer. How this interface works on the Previewer may" +
" be 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);
})
}
},
getNrOptionMode: function (...args) {
console.warn("telephony.radio.getNrOptionMode interface mocked in the Previewer. How this interface works on the Previewer may" +
" be different from that on a real device.")
const len = args.length
if (typeof args[len - 1] === 'function') {
args[len - 1].call(this, paramMock.businessErrorMock, NrOptionMode);
} else {
return new Promise((resolve, reject) => {
resolve(NrOptionMode);
})
}
},
getIMEI: function (...args) {
console.warn("telephony.radio.getIMEI interface mocked in the Previewer. How this interface works on the Previewer may" +
" be 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);
})
}
},
getMEID: function (...args) {
console.warn("telephony.radio.getMEID interface mocked in the Previewer. How this interface works on the Previewer may" +
" be 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);
})
}
},
getUniqueDeviceId: function (...args) {
console.warn("telephony.radio.getUniqueDeviceId interface mocked in the Previewer. How this interface works on the Previewer may" +
" be 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);
})
}
},
getPrimarySlotId: function (...args) {
console.warn("telephony.radio.getPrimarySlotId interface mocked in the Previewer. How this interface works on the Previewer may" +
" be different from that on a real device.")
const len = args.length
if (typeof args[len - 1] === 'function') {
args[len - 1].call(this, paramMock.businessErrorMock, paramMock.paramNumberMock);
} else {
return new Promise((resolve, reject) => {
resolve(paramMock.paramNumberMock);
})
}
},
getSignalInformation: function (...args) {
console.warn("telephony.radio.getSignalInformation interface mocked in the Previewer. How this interface works on the Previewer may" +
" be different from that on a real device.")
const len = args.length
if (typeof args[len - 1] === 'function') {
args[len - 1].call(this, paramMock.businessErrorMock, [SignalInformation]);
} else {
return new Promise((resolve, reject) => {
resolve([SignalInformation]);
})
}
},
isNrSupported: function () {
console.warn("telephony.radio.isNrSupported interface mocked in the Previewer. How this interface works on the Previewer may" +
" be different from that on a real device.")
return paramMock.paramBooleanMock;
},
isRadioOn: function (...args) {
console.warn("telephony.radio.isRadioOn interface mocked in the Previewer. How this interface works on the Previewer may" +
" be different from that on a real device.")
const len = args.length
if (typeof args[len - 1] === 'function') {
args[len - 1].call(this, paramMock.businessErrorMock, paramMock.paramBooleanMock);
} else {
return new Promise((resolve, reject) => {
resolve(paramMock.paramBooleanMock);
})
}
},
turnOnRadio: function (...args) {
console.warn("telephony.radio.turnOnRadio interface mocked in the Previewer. How this interface works on the Previewer may" +
" be 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();
})
}
},
turnOffRadio: function (...args) {
console.warn("telephony.radio.turnOffRadio interface mocked in the Previewer. How this interface works on the Previewer may" +
" be 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();
})
}
},
getOperatorName: function (...args) {
console.warn("telephony.radio.getOperatorName interface mocked in the Previewer. How this interface works on the Previewer may" +
" be 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);
})
}
},
setPreferredNetwork: function (...args) {
console.warn("telephony.radio.setPreferredNetwork interface mocked in the Previewer. How this interface works on the Previewer may" +
" be 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();
})
}
},
getPreferredNetwork: function (...args) {
console.warn("telephony.radio.getPreferredNetwork interface mocked in the Previewer. How this interface works on the Previewer may" +
" be different from that on a real device.")
const len = args.length
if (typeof args[len - 1] === 'function') {
args[len - 1].call(this, paramMock.businessErrorMock, PreferredNetworkMode);
} else {
return new Promise((resolve, reject) => {
resolve(PreferredNetworkMode);
})
}
},
getIMEISV: function (...args) {
console.warn("telephony.radio.getIMEISV interface mocked in the Previewer. How this interface works on the Previewer may" +
" be 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);
})
}
}
}
return radio
}
@@ -0,0 +1,521 @@
/*
* Copyright (c) 2021 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import { paramMock } from "../utils"
export function mockSim() {
const IccAccountInfo = {
simId: "[PC Preview] unknow simId",
slotIndex: "[PC Preview] unknow slotIndex",
isEsim: "[PC Preview] unknow isEsim",
isActive: "[PC Preview] unknow isActive",
iccId: "[PC Preview] unknow iccId",
showName: "[PC Preview] unknow showName",
showNumber: "[PC Preview] unknow showNumber"
}
const OperatorConfigMock = {
field: "[PC Preview] unknow field",
value: "[PC Preview] unknow value"
}
const LockStatusResponse = {
result: "[PC Preview] unknow result",
remain: "[PC Preview] unknow remain"
}
const DiallingNumbersInfo = {
efid: "[PC Preview] unknow efid",
recordNumber: "[PC Preview] unknow recordNumber",
alphaTag: "[PC Preview] unknow alphaTag",
number: "[PC Preview] unknow number",
emails: "[PC Preview] unknow emails"
}
const CardType = "[PC Preview] unknow CardType";
const SimState = "[PC Preview] unknow SimState";
const sim = {
isSimActive: function (...args) {
console.warn("telephony.sim.isSimActive interface mocked in the Previewer. How this interface works on the Previewer may" +
" be different from that on a real device.")
const len = args.length
if (typeof args[len - 1] === 'function') {
args[len - 1].call(this, paramMock.businessErrorMock, paramMock.paramBooleanMock);
} else {
return new Promise((resolve, reject) => {
resolve(paramMock.paramBooleanMock);
})
}
},
getDefaultVoiceSlotId: function (...args) {
console.warn("telephony.sim.getDefaultVoiceSlotId interface mocked in the Previewer. How this interface works on the Previewer may" +
" be different from that on a real device.")
const len = args.length
if (typeof args[len - 1] === 'function') {
args[len - 1].call(this, paramMock.businessErrorMock, paramMock.paramNumberMock);
} else {
return new Promise((resolve, reject) => {
resolve(paramMock.paramNumberMock);
})
}
},
hasOperatorPrivileges: function (...args) {
console.warn("telephony.sim.hasOperatorPrivileges interface mocked in the Previewer. How this interface works on the Previewer may" +
" be different from that on a real device.")
const len = args.length
if (typeof args[len - 1] === 'function') {
args[len - 1].call(this, paramMock.businessErrorMock, paramMock.paramBooleanMock);
} else {
return new Promise((resolve, reject) => {
resolve(paramMock.paramBooleanMock);
})
}
},
getISOCountryCodeForSim: function (...args) {
console.warn("telephony.sim.getISOCountryCodeForSim interface mocked in the Previewer. How this interface works on the Previewer may" +
" be 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);
})
}
},
getSimOperatorNumeric: function (...args) {
console.warn("telephony.sim.getSimOperatorNumeric interface mocked in the Previewer. How this interface works on the Previewer may" +
" be 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);
})
}
},
getSimSpn: function (...args) {
console.warn("telephony.sim.getSimSpn interface mocked in the Previewer. How this interface works on the Previewer may" +
" be 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);
})
}
},
getSimState: function (...args) {
console.warn("telephony.sim.getSimState interface mocked in the Previewer. How this interface works on the Previewer may" +
" be different from that on a real device.")
const len = args.length
if (typeof args[len - 1] === 'function') {
args[len - 1].call(this, paramMock.businessErrorMock, SimState);
} else {
return new Promise((resolve, reject) => {
resolve(SimState);
})
}
},
getCardType: function (...args) {
console.warn("telephony.sim.getCardType interface mocked in the Previewer. How this interface works on the Previewer may" +
" be different from that on a real device.")
const len = args.length
if (typeof args[len - 1] === 'function') {
args[len - 1].call(this, paramMock.businessErrorMock, CardType);
} else {
return new Promise((resolve, reject) => {
resolve(CardType);
})
}
},
getSimIccId: function (...args) {
console.warn("telephony.sim.getSimIccId interface mocked in the Previewer. How this interface works on the Previewer may" +
" be 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);
})
}
},
getVoiceMailIdentifier: function (...args) {
console.warn("telephony.sim.getVoiceMailIdentifier interface mocked in the Previewer. How this interface works on the Previewer may" +
" be 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);
})
}
},
getVoiceMailNumber: function (...args) {
console.warn("telephony.sim.getVoiceMailNumber interface mocked in the Previewer. How this interface works on the Previewer may" +
" be 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);
})
}
},
getVoiceMailCount: function (...args) {
console.warn("telephony.sim.getVoiceMailCount interface mocked in the Previewer. How this interface works on the Previewer may" +
" be different from that on a real device.")
const len = args.length
if (typeof args[len - 1] === 'function') {
args[len - 1].call(this, paramMock.businessErrorMock, paramMock.paramNumberMock);
} else {
return new Promise((resolve, reject) => {
resolve(paramMock.paramNumberMock);
})
}
},
getSimTelephoneNumber: function (...args) {
console.warn("telephony.sim.getSimTelephoneNumber interface mocked in the Previewer. How this interface works on the Previewer may" +
" be 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);
})
}
},
getSimGid1: function (...args) {
console.warn("telephony.sim.getSimGid1 interface mocked in the Previewer. How this interface works on the Previewer may" +
" be 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);
})
}
},
getSimTeleNumberIdentifier: function (...args) {
console.warn("telephony.sim.getSimTeleNumberIdentifier interface mocked in the Previewer. How this interface works on the Previewer may" +
" be 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);
})
}
},
getLine1NumberFromImpu: function (...args) {
console.warn("telephony.sim.getLine1NumberFromImpu interface mocked in the Previewer. How this interface works on the Previewer may" +
" be 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);
})
}
},
getMaxSimCount: function () {
console.warn("telephony.sim.getMaxSimCount interface mocked in the Previewer. How this interface works on the Previewer may" +
" be different from that on a real device.")
return paramMock.paramNumberMock;
},
getIMSI: function (...args) {
console.warn("telephony.sim.getIMSI interface mocked in the Previewer. How this interface works on the Previewer may" +
" be 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);
})
}
},
hasSimCard: function (...args) {
console.warn("telephony.sim.hasSimCard interface mocked in the Previewer. How this interface works on the Previewer may" +
" be different from that on a real device.")
const len = args.length
if (typeof args[len - 1] === 'function') {
args[len - 1].call(this, paramMock.businessErrorMock, paramMock.paramBooleanMock);
} else {
return new Promise((resolve, reject) => {
resolve(paramMock.paramBooleanMock);
})
}
},
getSimAccountInfo: function (...args) {
console.warn("telephony.sim.getSimAccountInfo interface mocked in the Previewer. How this interface works on the Previewer may" +
" be different from that on a real device.")
const len = args.length
if (typeof args[len - 1] === 'function') {
args[len - 1].call(this, paramMock.businessErrorMock, IccAccountInfo);
} else {
return new Promise((resolve, reject) => {
resolve(IccAccountInfo);
})
}
},
getActiveSimAccountInfoList: function (...args) {
console.warn("telephony.sim.getActiveSimAccountInfoList interface mocked in the Previewer. How this interface works on the Previewer may" +
" be different from that on a real device.")
const len = args.length
if (typeof args[len - 1] === 'function') {
args[len - 1].call(this, paramMock.businessErrorMock, [IccAccountInfo]);
} else {
return new Promise((resolve, reject) => {
resolve([IccAccountInfo]);
})
}
},
setDefaultVoiceSlotId: function (...args) {
console.warn("telephony.sim.setDefaultVoiceSlotId interface mocked in the Previewer. How this interface works on the Previewer may" +
" be 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();
})
}
},
activateSim: function (...args) {
console.warn("telephony.sim.activateSim interface mocked in the Previewer. How this interface works on the Previewer may" +
" be 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();
})
}
},
deactivateSim: function (...args) {
console.warn("telephony.sim.deactivateSim interface mocked in the Previewer. How this interface works on the Previewer may" +
" be 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();
})
}
},
setShowName: function (...args) {
console.warn("telephony.sim.setShowName interface mocked in the Previewer. How this interface works on the Previewer may" +
" be 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();
})
}
},
getShowName: function (...args) {
console.warn("telephony.sim.getShowName interface mocked in the Previewer. How this interface works on the Previewer may" +
" be 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);
})
}
},
setShowNumber: function (...args) {
console.warn("telephony.sim.setShowNumber interface mocked in the Previewer. How this interface works on the Previewer may" +
" be 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();
})
}
},
getShowNumber: function (...args) {
console.warn("telephony.sim.getShowNumber interface mocked in the Previewer. How this interface works on the Previewer may" +
" be 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);
})
}
},
getOperatorConfigs: function (...args) {
console.warn("telephony.sim.getOperatorConfigs interface mocked in the Previewer. How this interface works on the Previewer may" +
" be different from that on a real device.")
const len = args.length
if (typeof args[len - 1] === 'function') {
args[len - 1].call(this, paramMock.businessErrorMock, [OperatorConfigMock]);
} else {
return new Promise((resolve, reject) => {
resolve([OperatorConfigMock]);
})
}
},
unlockPin: function (...args) {
console.warn("telephony.sim.unlockPin interface mocked in the Previewer. How this interface works on the Previewer may" +
" be different from that on a real device.")
const len = args.length
if (typeof args[len - 1] === 'function') {
args[len - 1].call(this, paramMock.businessErrorMock, LockStatusResponse);
} else {
return new Promise((resolve, reject) => {
resolve(LockStatusResponse);
})
}
},
unlockPuk: function (...args) {
console.warn("telephony.sim.unlockPuk interface mocked in the Previewer. How this interface works on the Previewer may" +
" be different from that on a real device.")
const len = args.length
if (typeof args[len - 1] === 'function') {
args[len - 1].call(this, paramMock.businessErrorMock, LockStatusResponse);
} else {
return new Promise((resolve, reject) => {
resolve(LockStatusResponse);
})
}
},
alterPin: function (...args) {
console.warn("telephony.sim.alterPin interface mocked in the Previewer. How this interface works on the Previewer may" +
" be different from that on a real device.")
const len = args.length
if (typeof args[len - 1] === 'function') {
args[len - 1].call(this, paramMock.businessErrorMock, LockStatusResponse);
} else {
return new Promise((resolve, reject) => {
resolve(LockStatusResponse);
})
}
},
setLockState: function (...args) {
console.warn("telephony.sim.setLockState interface mocked in the Previewer. How this interface works on the Previewer may" +
" be different from that on a real device.")
const len = args.length
if (typeof args[len - 1] === 'function') {
args[len - 1].call(this, paramMock.businessErrorMock, LockStatusResponse);
} else {
return new Promise((resolve, reject) => {
resolve(LockStatusResponse);
})
}
},
unlockPin2: function (...args) {
console.warn("telephony.sim.unlockPin2 interface mocked in the Previewer. How this interface works on the Previewer may" +
" be different from that on a real device.")
const len = args.length
if (typeof args[len - 1] === 'function') {
args[len - 1].call(this, paramMock.businessErrorMock, LockStatusResponse);
} else {
return new Promise((resolve, reject) => {
resolve(LockStatusResponse);
})
}
},
unlockPuk2: function (...args) {
console.warn("telephony.sim.unlockPuk2 interface mocked in the Previewer. How this interface works on the Previewer may" +
" be different from that on a real device.")
const len = args.length
if (typeof args[len - 1] === 'function') {
args[len - 1].call(this, paramMock.businessErrorMock, LockStatusResponse);
} else {
return new Promise((resolve, reject) => {
resolve(LockStatusResponse);
})
}
},
alterPin2: function (...args) {
console.warn("telephony.sim.alterPin2 interface mocked in the Previewer. How this interface works on the Previewer may" +
" be different from that on a real device.")
const len = args.length
if (typeof args[len - 1] === 'function') {
args[len - 1].call(this, paramMock.businessErrorMock, LockStatusResponse);
} else {
return new Promise((resolve, reject) => {
resolve(LockStatusResponse);
})
}
},
queryIccDiallingNumbers: function (...args) {
console.warn("telephony.sim.queryIccDiallingNumbers interface mocked in the Previewer. How this interface works on the Previewer may" +
" be different from that on a real device.")
const len = args.length
if (typeof args[len - 1] === 'function') {
args[len - 1].call(this, paramMock.businessErrorMock, [DiallingNumbersInfo]);
} else {
return new Promise((resolve, reject) => {
resolve([DiallingNumbersInfo]);
})
}
},
addIccDiallingNumbers: function (...args) {
console.warn("telephony.sim.addIccDiallingNumbers interface mocked in the Previewer. How this interface works on the Previewer may" +
" be 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();
})
}
},
delIccDiallingNumbers: function (...args) {
console.warn("telephony.sim.delIccDiallingNumbers interface mocked in the Previewer. How this interface works on the Previewer may" +
" be 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();
})
}
},
updateIccDiallingNumbers: function (...args) {
console.warn("telephony.sim.updateIccDiallingNumbers interface mocked in the Previewer. How this interface works on the Previewer may" +
" be 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 sim
}
@@ -0,0 +1,185 @@
/*
* Copyright (c) 2021 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import { paramMock } from "../utils"
export function mockSMS() {
const SimShortMessage = {
shortMessage: "[PC Preview] unknow shortMessage",
simMessageStatus: "[PC Preview] unknow simMessageStatus",
indexOnSim: "[PC Preview] unknow indexOnSim"
}
const ShortMessage = {
visibleMessageBody: "[PC Preview] unknow visibleMessageBody",
visibleRawAddress: "[PC Preview] unknow visibleRawAddress",
messageClass: "[PC Preview] unknow messageClass",
protocolId: "[PC Preview] unknow protocolId",
scAddress: "[PC Preview] unknow scAddress",
scTimestamp: "[PC Preview] unknow scTimestamp",
isReplaceMessage: "[PC Preview] unknow isReplaceMessage",
hasReplyPath: "[PC Preview] unknow hasReplyPath",
pdu: ["[PC Preview] unknow pdu"],
status: "[PC Preview] unknow status",
isSmsStatusReportMessage: "[PC Preview] unknow isSmsStatusReportMessage",
emailAddress: "[PC Preview] unknow emailAddress",
emailMessageBody: "[PC Preview] unknow emailMessageBody",
userRawData: ["[PC Preview] unknow userRawData"],
isEmailMessage: "[PC Preview] unknow isEmailMessage",
}
const sms = {
splitMessage: function (...args) {
console.warn("telephony.sms.splitMessage interface mocked in the Previewer. How this interface works on the Previewer may" +
" be 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]);
})
}
},
createMessage: function (...args) {
console.warn("telephony.sms.createMessage interface mocked in the Previewer. How this interface works on the Previewer may" +
" be different from that on a real device.")
const len = args.length
if (typeof args[len - 1] === 'function') {
args[len - 1].call(this, paramMock.businessErrorMock, ShortMessage);
} else {
return new Promise((resolve, reject) => {
resolve(ShortMessage);
})
}
},
sendMessage: function (...args) {
console.warn("telephony.sms.sendMessage interface mocked in the Previewer. How this interface works on the Previewer may" +
" be different from that on a real device.")
},
setDefaultSmsSlotId: function (...args) {
console.warn("telephony.sms.setDefaultSmsSlotId interface mocked in the Previewer. How this interface works on the Previewer may" +
" be 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();
})
}
},
getDefaultSmsSlotId: function (...args) {
console.warn("telephony.sms.getDefaultSmsSlotId interface mocked in the Previewer. How this interface works on the Previewer may" +
" be different from that on a real device.")
const len = args.length
if (typeof args[len - 1] === 'function') {
args[len - 1].call(this, paramMock.businessErrorMock, paramMock.paramNumberMock);
} else {
return new Promise((resolve, reject) => {
resolve(paramMock.paramNumberMock);
})
}
},
setSmscAddr: function (...args) {
console.warn("telephony.sms.setSmscAddr interface mocked in the Previewer. How this interface works on the Previewer may" +
" be 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();
})
}
},
getSmscAddr: function (...args) {
console.warn("telephony.sms.getSmscAddr interface mocked in the Previewer. How this interface works on the Previewer may" +
" be 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);
})
}
},
hasSmsCapability: function () {
console.warn("telephony.sms.hasSmsCapability interface mocked in the Previewer. How this interface works on the Previewer may" +
" be different from that on a real device.")
return paramMock.paramBooleanMock;
},
addSimMessage: function (...args) {
console.warn("telephony.sms.addSimMessage interface mocked in the Previewer. How this interface works on the Previewer may" +
" be 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();
})
}
},
delSimMessage: function (...args) {
console.warn("telephony.sms.delSimMessage interface mocked in the Previewer. How this interface works on the Previewer may" +
" be 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();
})
}
},
updateSimMessage: function (...args) {
console.warn("telephony.sms.updateSimMessage interface mocked in the Previewer. How this interface works on the Previewer may" +
" be 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();
})
}
},
getAllSimMessages: function (...args) {
console.warn("telephony.sms.getAllSimMessages interface mocked in the Previewer. How this interface works on the Previewer may" +
" be different from that on a real device.")
const len = args.length
if (typeof args[len - 1] === 'function') {
args[len - 1].call(this, paramMock.businessErrorMock, [SimShortMessage]);
} else {
return new Promise((resolve, reject) => {
resolve([SimShortMessage]);
})
}
},
setCBConfig: function (...args) {
console.warn("telephony.sms.setCBConfig interface mocked in the Previewer. How this interface works on the Previewer may" +
" be 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 sms
}

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