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

This commit is contained in:
jiangyuan0000
2022-07-28 03:33:37 +00:00
committed by Gitee
147 changed files with 8214 additions and 3723 deletions
@@ -1,173 +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 mockAccessibility() {
const AbilityTypeMock = {
audible: 'audible',
generic: 'generic',
haptic: 'haptic',
spoken: 'spoken',
visual: 'visual'
};
const CapabilityMock = {
retrieve: 'retrieve',
touchGuide: 'touchGuide',
keyEventObserver: 'keyEventObserver',
zoom: 'zoom',
gesture: 'gesture'
};
const EventTypeMock = '[PC Preview] unknow EventType';
const AccessibilityAbilityInfoMock = {
id: '[PC Preview] unknow id',
name: '[PC Preview] unknow name',
bundleName: '[PC Preview] unknow bundleName',
abilityTypes: [AbilityTypeMock],
capabilities: [CapabilityMock],
description: '[PC Preview] unknow description',
eventTypes: [EventTypeMock]
};
const CaptionsFontEdgeTypeMock = '[PC Preview] unknow CaptionsFontEdgeType';
const CaptionsFontFamilyMock = '[PC Preview] unknow CaptionsFontFamily';
const CaptionStyleMock = {
fontFamily: [CaptionsFontFamilyMock],
fontScale: '[PC Preview] unknow fontScale',
fontColor: '[PC Preview] unknow fontColor',
fontEdgeType: [CaptionsFontEdgeTypeMock],
backgroundColor: '[PC Preview] unknow backgroundColor',
windowColor: '[PC Preview] unknow windowColor'
};
const CaptionsManagerMock = {
enabled: '[PC Preview] unknow enabled',
style: [CaptionStyleMock]
};
const WindowUpdateTypeMock = '[PC Preview] unknow WindowUpdateType';
const ActionMock = '[PC Preview] unknow Action';
const TextMoveUnitMock = '[PC Preview] unknow TextMoveUnit';
const EventInfoClass = class EventInfo {
constructor(jsonObject) {
console.warn('accessibility.EventInfoClass.constructor interface mocked in the Previewer. How this interface works on' +
' the Previewer may be different from that on a real device.');
this.type = EventTypeMock;
this.windowUpdateType = WindowUpdateTypeMock;
this.bundleName = '[PC Preview] unknow bundleName';
this.componentType = '[PC Preview] unknow componentType';
this.pageId = '[PC Preview] unknow pageId';
this.description = '[PC Preview] unknow description';
this.triggerAction = ActionMock;
this.textMoveUnit = TextMoveUnitMock;
this.contents = '[PC Preview] unknow contents';
this.lastContent = '[PC Preview] unknow lastContent';
this.beginIndex = '[PC Preview] unknow beginIndex';
this.currentIndex = '[PC Preview] unknow currentIndex';
this.endIndex = '[PC Preview] unknow endIndex';
this.itemCount = '[PC Preview] unknow itemCount';
}
};
const StateEventMock = {
eventType: '[PC Preview] unknow eventType',
state: '[PC Preview] unknow state',
description: '[PC Preview] unknow description'
};
global.systemplugin.accessibility = {
EventInfo: EventInfoClass,
isOpenAccessibility: function (...args) {
console.warn('accessibility.isOpenAccessibility interface mocked in the Previewer. How this interface works on the' +
' Previewer may be different 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);
});
}
},
isOpenTouchGuide: function (...args) {
console.warn('accessibility.isOpenTouchGuide interface mocked in the Previewer. How this interface works on the' +
' Previewer may be different from that on a real device.');
const len = args.length;
if (typeof args[len - 1] === 'function') {
args[len - 1].call(this, paramMock.businessErrorMock, paramMock.paramBooleanMock);
} else {
return new Promise((resolve) => {
resolve(paramMock.paramBooleanMock);
});
}
},
on: function (...args) {
console.warn('accessibility.on interface mocked in the Previewer. How this interface works on the Previewer may be' +
' different from that on a real device.');
const len = args.length;
args[len - 1].call(this, paramMock.businessErrorMock, StateEventMock);
},
off: function (...args) {
console.warn('accessibility.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.businessErrorMock, StateEventMock);
}
},
getAbilityLists: function (...args) {
console.warn('accessibility.getAbilityLists interface mocked in the Previewer. How this interface works on the' +
' Previewer may be different from that on a real device.');
const len = args.length;
if (typeof args[len - 1] === 'function') {
args[len - 1].call(this, paramMock.businessErrorMock, [AccessibilityAbilityInfoMock]);
} else {
return new Promise((resolve, reject) => {
resolve([AccessibilityAbilityInfoMock]);
});
}
},
sendEvent: function (...args) {
console.warn('accessibility.sendEvent interface mocked in the Previewer. How this interface works on the' +
' Previewer may be 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();
});
}
},
getCaptionsManager: function (...args) {
console.warn('accessibility.getCaptionsManager interface mocked in the Previewer. How this interface works on the' +
' Previewer may be different from that on a real device.');
const len = args.length;
if (typeof args[len - 1] === 'function') {
args[len - 1].call(this, paramMock.businessErrorMock, [CaptionsManagerMock]);
} else {
return new Promise((resolve, reject) => {
resolve([CaptionsManagerMock]);
});
}
}
};
}
@@ -43,7 +43,6 @@ import { mockSystemPackage } from './systemPackage'
import { mockUserauth } from './userIAM'
import { mockVibrator } from './vibrator'
import { mockRequireNapiFun } from './napi'
import { mockAccessibility } from './accessibility'
import { mockAI } from './ai'
import { mockUserIAMUserAuth } from './ohos/userIAMuserAuth.js'
import { mockBundleManager } from './ohos/bundleManager'
@@ -74,7 +73,6 @@ export function mockSystemPlugin() {
mockAbilityFeatureAbility()
mockAbilityContinuationRegisterManager()
mockRequireNapiFun()
mockAccessibility()
mockAbilityParticleAbility()
mockAbilityFormManager()
mockAbilityAbilityAgent()
@@ -0,0 +1,289 @@
/*
* Copyright (c) 2022 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import { paramMock } from "../../utils"
const DataAbilityResult = {
uri: "[PC Preview] unknow uri",
count: "[PC Preview] unknow count"
}
const ResultSet = {
columnNames: [paramMock.paramStringMock],
columnCount: "[PC Preview] unknow columnCount",
rowCount: "[PC Preview] unknow rowCount",
rowIndex: "[PC Preview] unknow rowIndex",
isAtFirstRow: "[PC Preview] unknow isAtFirstRow",
isAtLastRow: "[PC Preview] unknow isAtLastRow",
isEnded: "[PC Preview] unknow isEnded",
isStarted: "[PC Preview] unknow isStarted",
isClose: "[PC Preview] unknow isClose",
getColumnIndex: function (...args) {
console.warn("ResultSet.getColumnIndex interface mocked in the Previewer. How this interface works on the Previewer" +
" may be different from that on a real device.")
return paramMock.paramNumberMock;
},
getColumnName: function (...args) {
console.warn("ResultSet.getColumnName interface mocked in the Previewer. How this interface works on the Previewer" +
" may be different from that on a real device.")
return paramMock.paramStringMock;
},
goTo: function (...args) {
console.warn("ResultSet.goTo interface mocked in the Previewer. How this interface works on the Previewer" +
" may be different from that on a real device.")
return paramMock.paramBooleanMock;
},
goToRow: function (...args) {
console.warn("ResultSet.goToRow interface mocked in the Previewer. How this interface works on the Previewer" +
" may be different from that on a real device.")
return paramMock.paramBooleanMock;
},
goToLastRow: function (...args) {
console.warn("ResultSet.goToLastRow interface mocked in the Previewer. How this interface works on the Previewer" +
" may be different from that on a real device.")
return paramMock.paramBooleanMock;
},
goToFirstRow: function (...args) {
console.warn("ResultSet.goToFirstRow interface mocked in the Previewer. How this interface works on the Previewer" +
" may be different from that on a real device.")
return paramMock.paramBooleanMock;
},
goToNextRow: function (...args) {
console.warn("ResultSet.goToNextRow interface mocked in the Previewer. How this interface works on the Previewer" +
" may be different from that on a real device.")
return paramMock.paramBooleanMock;
},
goToPreviousRow: function (...args) {
console.warn("ResultSet.goToPreviousRow interface mocked in the Previewer. How this interface works on the Previewer" +
" may be different from that on a real device.")
return paramMock.paramBooleanMock;
},
getBlob: function (...args) {
console.warn("ResultSet.getBlob interface mocked in the Previewer. How this interface works on the Previewer" +
" may be different from that on a real device.")
return paramMock.paramArrayMock;
},
getString: function (...args) {
console.warn("ResultSet.getString interface mocked in the Previewer. How this interface works on the Previewer" +
" may be different from that on a real device.")
return paramMock.paramStringMock;
},
getLong: function (...args) {
console.warn("ResultSet.getLong interface mocked in the Previewer. How this interface works on the Previewer" +
" may be different from that on a real device.")
return paramMock.paramNumberMock;
},
getDouble: function (...args) {
console.warn("ResultSet.getDouble interface mocked in the Previewer. How this interface works on the Previewer" +
" may be different from that on a real device.")
return paramMock.paramNumberMock;
},
isColumnNull: function (...args) {
console.warn("ResultSet.isColumnNull interface mocked in the Previewer. How this interface works on the Previewer" +
" may be different from that on a real device.")
return paramMock.paramBooleanMock;
},
close: function () {
console.warn("ResultSet.close interface mocked in the Previewer. How this interface works on the Previewer" +
" may be different from that on a real device.")
}
}
export const PacMap = {key:{}}
export const DataAbilityHelper = {
openFile: function (...args) {
console.warn("dataAbilityHelper.openFile interface mocked in the Previewer. How this interface works on the Previewer" +
" may be different from that on a real device.")
const len = args.length
if (typeof args[len - 1] === 'function') {
args[len - 1].call(this, paramMock.businessErrorMock, paramMock.paramNumberMock)
} else {
return new Promise((resolve) => {
resolve(paramMock.paramNumberMock);
})
}
},
on: function (...args) {
console.warn("dataAbilityHelper.on interface mocked in the Previewer. How this interface works on the Previewer" +
" may be different from that on a real device.")
const len = args.length
if (typeof args[len - 1] === 'function') {
args[len - 1].call(this, paramMock.businessErrorMock)
}
},
off: function (...args) {
console.warn("dataAbilityHelper.off interface mocked in the Previewer. How this interface works on the Previewer" +
" may be different from that on a real device.")
const len = args.length
if (typeof args[len - 1] === 'function') {
args[len - 1].call(this, paramMock.businessErrorMock)
}
},
call: function (...args) {
console.warn("dataAbilityHelper.call interface mocked in the Previewer. How this interface works on the Previewer" +
" may be different from that on a real device.")
const len = args.length
if (typeof args[len - 1] === 'function') {
args[len - 1].call(this, paramMock.businessErrorMock, PacMap)
} else {
return new Promise((resolve) => {
resolve(PacMap);
})
}
},
getType: function (...args) {
console.warn("dataAbilityHelper.getType interface mocked in the Previewer. How this interface works on the Previewer" +
" may be different from that on a real device.")
const len = args.length
if (typeof args[len - 1] === 'function') {
args[len - 1].call(this, paramMock.businessErrorMock, paramMock.paramStringMock)
} else {
return new Promise((resolve) => {
resolve(paramMock.paramStringMock);
})
}
},
getFileTypes: function (...args) {
console.warn("dataAbilityHelper.getFileTypes interface mocked in the Previewer. How this interface works on the Previewer" +
" may be different from that on a real device.")
const len = args.length
if (typeof args[len - 1] === 'function') {
args[len - 1].call(this, paramMock.businessErrorMock, [paramMock.paramStringMock])
} else {
return new Promise((resolve) => {
resolve([paramMock.paramStringMock]);
})
}
},
normalizeUri: function (...args) {
console.warn("dataAbilityHelper.normalizeUri interface mocked in the Previewer. How this interface works on the Previewer" +
" may be different from that on a real device.")
const len = args.length
if (typeof args[len - 1] === 'function') {
args[len - 1].call(this, paramMock.businessErrorMock, paramMock.paramStringMock)
} else {
return new Promise((resolve) => {
resolve(paramMock.paramStringMock);
})
}
},
denormalizeUri: function (...args) {
console.warn("dataAbilityHelper.denormalizeUri interface mocked in the Previewer. How this interface works on the Previewer" +
" may be different from that on a real device.")
const len = args.length
if (typeof args[len - 1] === 'function') {
args[len - 1].call(this, paramMock.businessErrorMock, paramMock.paramStringMock)
} else {
return new Promise((resolve) => {
resolve(paramMock.paramStringMock);
})
}
},
notifyChange: function (...args) {
console.warn("dataAbilityHelper.notifyChange interface mocked in the Previewer. How this interface works on the Previewer" +
" may be different from that on a real device.")
const len = args.length
if (typeof args[len - 1] === 'function') {
args[len - 1].call(this, paramMock.businessErrorMock)
} else {
return new Promise((resolve) => {
resolve();
})
}
},
insert: function (...args) {
console.warn("dataAbilityHelper.insert interface mocked in the Previewer. How this interface works on the Previewer" +
" may be different from that on a real device.")
const len = args.length
if (typeof args[len - 1] === 'function') {
args[len - 1].call(this, paramMock.businessErrorMock, paramMock.paramNumberMock)
} else {
return new Promise((resolve) => {
resolve(paramMock.paramNumberMock);
})
}
},
batchInsert: function (...args) {
console.warn("dataAbilityHelper.batchInsert interface mocked in the Previewer. How this interface works on the Previewer" +
" may be different from that on a real device.")
const len = args.length
if (typeof args[len - 1] === 'function') {
args[len - 1].call(this, paramMock.businessErrorMock, paramMock.paramNumberMock)
} else {
return new Promise((resolve) => {
resolve(paramMock.paramNumberMock);
})
}
},
delete: function (...args) {
console.warn("dataAbilityHelper.delete interface mocked in the Previewer. How this interface works on the Previewer" +
" may be different from that on a real device.")
const len = args.length
if (typeof args[len - 1] === 'function') {
args[len - 1].call(this, paramMock.businessErrorMock, paramMock.paramNumberMock)
} else {
return new Promise((resolve) => {
resolve(paramMock.paramNumberMock);
})
}
},
update: function (...args) {
console.warn("dataAbilityHelper.update interface mocked in the Previewer. How this interface works on the Previewer" +
" may be different from that on a real device.")
const len = args.length
if (typeof args[len - 1] === 'function') {
args[len - 1].call(this, paramMock.businessErrorMock, paramMock.paramNumberMock)
} else {
return new Promise((resolve) => {
resolve(paramMock.paramNumberMock);
})
}
},
query: function (...args) {
console.warn("dataAbilityHelper.query interface mocked in the Previewer. How this interface works on the Previewer" +
" may be different from that on a real device.")
const len = args.length
if (typeof args[len - 1] === 'function') {
args[len - 1].call(this, paramMock.businessErrorMock, ResultSet)
} else {
return new Promise((resolve) => {
resolve(ResultSet);
})
}
},
call: function (...args) {
console.warn("dataAbilityHelper.call interface mocked in the Previewer. How this interface works on the Previewer" +
" may be different from that on a real device.")
const len = args.length
if (typeof args[len - 1] === 'function') {
args[len - 1].call(this, paramMock.businessErrorMock, PacMap)
} else {
return new Promise((resolve) => {
resolve(PacMap);
})
}
},
executeBatch: function (...args) {
console.warn("dataAbilityHelper.executeBatch interface mocked in the Previewer. How this interface works on the Previewer" +
" may be different from that on a real device.")
const len = args.length
if (typeof args[len - 1] === 'function') {
args[len - 1].call(this, paramMock.businessErrorMock, [DataAbilityResult])
} else {
return new Promise((resolve) => {
resolve([DataAbilityResult]);
})
}
}
}
@@ -0,0 +1,33 @@
/*
* Copyright (c) 2022 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import { paramMock } from "../../utils"
import { mockDataAbility } from "../ohos_data_dataAbility"
export const DataAbilityOperation = {
uri: "[PC Preview] unknow uri",
type: {
TYPE_INSERT: 1,
TYPE_UPDATE: 2,
TYPE_DELETE: 3,
TYPE_ASSERT: 4
},
valuesBucket: {key:{}},
valueBackReferences: {key:{}},
predicates: mockDataAbility().DataAbilityPredicates,
predicatesBackReferences: new Map([[paramMock.paramNumberMock, paramMock.paramNumberMock]]),
interrupted: "[PC Preview] unknow interrupted",
expectedCount: "[PC Preview] unknow expectedCount"
}
@@ -1,23 +1,19 @@
/*
* Copyright (c) 2022 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
export const VolumeMock = {
id: '[PC preview] unknow id',
uuid: '[PC preview] unknow uuid',
description: '[PC preview] unknow description',
removeAble: '[PC preview] unknow removeAble',
path: '[PC preview] unknow path',
state: '[PC preview] unknow state',
};
/*
* Copyright (c) 2022 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
export const DataAbilityResult = {
uri: "[PC Preview] unknow uri",
count: "[PC Preview] unknow count",
}
@@ -14,245 +14,21 @@
*/
import { paramMock } from "../../utils"
import { MessageParcelClass } from "../ohos_rpc"
import { ContextClass } from "../ohos_application_ServiceExtAbility"
import { ContextClass } from "./Context"
import { Configuration } from "../ohos_application_Configuration"
import { Caller } from "../ohos_application_Ability"
import { AbilityInfo } from "../bundle/abilityInfo"
import { HapModuleInfo } from "../bundle/hapModuleInfo"
import { AbilityResult } from "../ability/abilityResult"
import { PermissionRequestResultClass } from "./PermissionRequestResult"
const ModuleInfoMock = {
moduleName: '[PC preview] unknow moduleName',
moduleSourceDir: '[PC preview] unknow moduleSourceDir',
}
export const AbilityInfoMock = {
bundleName: '[PC preview] unknow bundleName',
name: '[PC preview] unknow name',
label: '[PC preview] unknow label',
description: '[PC preview] unknow description',
icon: '[PC preview] unknow icon',
labelId: '[PC preview] unknow labelId',
descriptionId: '[PC preview] unknow descriptionId',
iconId: '[PC preview] unknow iconId',
moduleName: '[PC preview] unknow moduleName',
process: '[PC preview] unknow process',
targetAbility: '[PC preview] unknow targetAbility',
backgroundModes: '[PC preview] unknow backgroundModes',
isVisible: '[PC preview] unknow isVisible',
abilityTypeMock: '[PC preview] unknow abilityTypeMock',
AbilitySubTypeMock: '[PC preview] unknow AbilitySubTypeMock',
DisplayOrientationMock: '[PC preview] unknow DisplayOrientationMock',
launchModeMock: '[PC preview] unknow launchModeMock',
formEnabled: '[PC preview] unknow formEnabled',
permissions: [paramMock.paramStringMock],
deviceTypes: [paramMock.paramStringMock],
deviceCapabilities: [paramMock.paramStringMock],
readPermission: '[PC preview] unknow readPermission',
writePermission: '[PC preview] unknow writePermission',
applicationInfo: applicationInfoMock,
formEntity: '[PC preview] unknow formEntity',
minFormHeight: '[PC preview] unknow minFormHeight',
defaultFormHeight: '[PC preview] unknow defaultFormHeight',
minFormWidth: '[PC preview] unknow minFormWidth',
defaultFormWidth: '[PC preview] unknow defaultFormWidth',
uri: '[PC preview] unknow uri',
customizeData: new Map([["[PC Preview] unknow customizeDataKey", "[PC Preview] unknow customizeDataValue"]])
}
const applicationInfoMock = {
name: '[PC preview] unknow name',
description: '[PC preview] unknow description',
descriptionId: '[PC preview] unknow descriptionId',
systemApp: '[PC preview] unknow systemApp',
enabled: '[PC preview] unknow enabled',
label: '[PC preview] unknow label',
labelId: '[PC preview] unknow labelId',
icon: '[PC preview] unknow icon',
iconId: '[PC preview] unknow iconId',
process: '[PC preview] unknow process',
supportedModes: '[PC preview] unknow supportedModes',
moduleSourceDirs: [paramMock.paramStringMock],
permissions: [paramMock.paramStringMock],
moduleInfo: [ModuleInfoMock],
entryDir: '[PC preview] unknow entryDir',
codepath: '[PC preview] unknow codepath',
removable: '[PC preview] unknow removable',
customizeData: new Map([["[PC Preview] unknow customizeDataKey", "[PC Preview] unknow customizeDataValue"]])
}
const HapModuleInfoMock = {
name: '[PC preview] unknow name',
description: '[PC preview] unknow description',
descriptionId: '[PC preview] unknow descriptionId',
icon: '[PC preview] unknow icon',
label: '[PC preview] unknow label',
labelId: '[PC preview] unknow labelId',
iconId: '[PC preview] unknow iconId',
backgroundImg: '[PC preview] unknow backgroundImg',
supportedModes: '[PC preview] unknow supportedModes',
reqCapabilities: [paramMock.paramStringMock],
deviceTypes: [paramMock.paramStringMock],
abilityInfo: AbilityInfoMock,
moduleName: '[PC preview] unknow moduleName',
mainAbilityName: '[PC preview] unknow mainAbilityName',
installationFree: '[PC preview] unknow installationFree',
}
const screenDensityMock = {
SCREEN_SDPI: '[PC preview] unknow SCREEN_SDPI',
SCREEN_MDPI: '[PC preview] unknow SCREEN_MDPI',
SCREEN_LDPI: '[PC preview] unknow SCREEN_LDPI',
SCREEN_XLDPI: '[PC preview] unknow SCREEN_XLDPI',
SCREEN_XXLDPI: '[PC preview] unknow SCREEN_XXLDPI',
SCREEN_XXXLDPI: '[PC preview] unknow SCREEN_XXXLDPI'
}
const deviceTypeMock = {
DEVICE_TYPE_PHONE: '[PC preview] unknow DEVICE_TYPE_PHONE',
DEVICE_TYPE_TABLET: '[PC preview] unknow DEVICE_TYPE_TABLET',
DEVICE_TYPE_CAR: '[PC preview] unknow DEVICE_TYPE_CAR',
DEVICE_TYPE_PC: '[PC preview] unknow DEVICE_TYPE_PC',
DEVICE_TYPE_TV: '[PC preview] unknow DEVICE_TYPE_TV',
DEVICE_TYPE_WEARABLE: '[PC preview] unknow DEVICE_TYPE_WEARABLE'
}
const DeviceCapabilityClass = class DeviceCapability {
constructor() {
console.warn('DeviceCapability.constructor interface mocked in the Previewer. How this interface works on' +
' the Previewer may be different from that on a real device.');
this.screenDensity = screenDensityMock;
this.deviceType = deviceTypeMock;
}
}
const configurationClass = class configuration {
constructor() {
console.warn('configuration.constructor interface mocked in the Previewer. How this interface works on' +
' the Previewer may be different from that on a real device.');
this.directionMock = '[PC preview] unknow directionMock';
this.locale = '[PC preview] unknow locale';
}
}
const resourceManagerMock = {
getString: function (...args) {
console.warn("ResourceManager.getString interface mocked in the Previewer." +
" How this interface works on the Previewer may be different from that on a real device.")
const len = args.length
if (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);
})
}
},
getStringArray: function (...args) {
console.warn("ResourceManager.getStringArray interface mocked in the Previewer." +
" How this interface works on the Previewer may be different from that on a real device.")
const len = args.length
if (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]);
})
}
},
getMedia: function (...args) {
console.warn("ResourceManager.getMedia interface mocked in the Previewer." +
" How this interface works on the Previewer may be different from that on a real device.")
const len = args.length
if (len > 0 && typeof args[len - 1] === 'function') {
args[len - 1].call(this, paramMock.businessErrorMock, new Uint8Array());
} else {
return new Promise((resolve, reject) => {
resolve(new Uint8Array());
})
}
},
getMediaBase64: function (...args) {
console.warn("ResourceManager.getMediaBase64 interface mocked in the Previewer." +
" How this interface works on the Previewer may be different from that on a real device.")
const len = args.length
if (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);
})
}
},
getDeviceCapability: function (...args) {
console.warn("ResourceManager.getDeviceCapability interface mocked in the Previewer." +
" How this interface works on the Previewer may be different from that on a real device.")
const len = args.length
if (len > 0 && typeof args[len - 1] === 'function') {
args[len - 1].call(this, paramMock.businessErrorMock, new DeviceCapabilityClass());
} else {
return new Promise((resolve, reject) => {
resolve(new DeviceCapabilityClass());
})
}
},
getConfiguration: function (...args) {
console.warn("ResourceManager.getConfiguration interface mocked in the Previewer." +
" How this interface works on the Previewer may be different from that on a real device.")
const len = args.length
if (len > 0 && typeof args[len - 1] === 'function') {
args[len - 1].call(this, paramMock.businessErrorMock, new configurationClass());
} else {
return new Promise((resolve, reject) => {
resolve(new configurationClass());
})
}
},
getPluralString: function (...args) {
console.warn("ResourceManager.getPluralString interface mocked in the Previewer." +
" How this interface works on the Previewer may be different from that on a real device.")
const len = args.length
if (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);
})
}
},
getRawFile: function (...args) {
console.warn("ResourceManager.getRawFile interface mocked in the Previewer." +
" How this interface works on the Previewer may be different from that on a real device.")
const len = args.length
if (len > 0 && typeof args[len - 1] === 'function') {
args[len - 1].call(this, paramMock.businessErrorMock, new Uint8Array());
} else {
return new Promise((resolve, reject) => {
resolve(new Uint8Array());
})
}
},
}
export const abilityStageContextClass = class abilityStageContext extends ContextClass {
constructor() {
super();
console.warn('Context.abilityStageContext.constructor interface mocked in the Previewer. How this interface works on' +
' the Previewer may be different from that on a real device.');
this.currentHapModuleInfo = HapModuleInfoMock;
}
}
export const ExtensionContextClass = class ExtensionContext extends ContextClass {
constructor() {
super();
console.warn('Context.ExtensionContext.constructor interface mocked in the Previewer. How this interface works on' +
' the Previewer may be different from that on a real device.');
this.currentHapModuleInfo = HapModuleInfoMock;
}
};
export const AbilityResultMock = {
resultCode: "[PC Preview] unknow resultCode",
}
const PermissionRequestResultMock = {
permissions: [paramMock.paramStringMock],
authResults: [paramMock.paramNumberMock]
}
export const AbilityContextClass = class AbilityContext extends ContextClass {
constructor() {
super();
console.warn('Ability.AbilityContext.constructor interface mocked in the Previewer. How this interface works on' +
' the Previewer may be different from that on a real device.');
this.abilityInfo = AbilityInfoMock;
this.currentHapModuleInfo = HapModuleInfoMock;
this.abilityInfo = AbilityInfo;
this.currentHapModuleInfo = HapModuleInfo;
this.config = Configuration;
this.startAbility = function (...args) {
console.warn("Ability.AbilityContext.startAbility interface mocked in the Previewer." +
@@ -290,10 +66,10 @@ export const AbilityContextClass = class AbilityContext extends ContextClass {
" How this interface works on the Previewer may be different from that on a real device.")
const len = args.length
if (len > 0 && typeof args[len - 1] === 'function') {
args[len - 1].call(this, paramMock.businessErrorMock, AbilityResultMock);
args[len - 1].call(this, paramMock.businessErrorMock, AbilityResult);
} else {
return new Promise((resolve, reject) => {
resolve(AbilityResultMock);
resolve(AbilityResult);
})
}
};
@@ -302,10 +78,10 @@ export const AbilityContextClass = class AbilityContext extends ContextClass {
" How this interface works on the Previewer may be different from that on a real device.")
const len = args.length
if (len > 0 && typeof args[len - 1] === 'function') {
args[len - 1].call(this, paramMock.businessErrorMock, AbilityResultMock);
args[len - 1].call(this, paramMock.businessErrorMock, AbilityResult);
} else {
return new Promise((resolve, reject) => {
resolve(AbilityResultMock);
resolve(AbilityResult);
})
}
};
@@ -432,10 +208,10 @@ export const AbilityContextClass = class AbilityContext extends ContextClass {
" How this interface works on the Previewer may be different from that on a real device.")
const len = args.length
if (len > 0 && typeof args[len - 1] === 'function') {
args[len - 1].call(this, paramMock.businessErrorMock, PermissionRequestResultMock);
args[len - 1].call(this, paramMock.businessErrorMock, new PermissionRequestResultClass());
} else {
return new Promise((resolve, reject) => {
resolve(PermissionRequestResultMock);
resolve( new PermissionRequestResultClass());
})
}
};
@@ -0,0 +1,39 @@
/*
* Copyright (c) 2022 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
const ElementName = {
deviceId: '[PC preview] unknow deviceId',
bundleName: '[PC preview] unknow bundleName',
abilityName: '[PC preview] unknow abilityName',
uri: '[PC preview] unknow uri',
shortName: '[PC preview] unknow shortName',
moduleName: '[PC preview] unknow moduleName'
}
const AbilityState = {
INITIAL: 0,
FOREGROUND: 9,
BACKGROUND: 10,
FOREGROUNDING: 11,
BACKGROUNDING: 12
}
export const AbilityRunningInfo = {
ability: ElementName,
pid: '[PC preview] unknow pid',
uid: '[PC preview] unknow uid',
processName: '[PC preview] unknow processName',
startTime: '[PC preview] unknow startTime',
abilityState: AbilityState
}
@@ -0,0 +1,28 @@
/*
* 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 { ContextClass } from "./Context"
import { HapModuleInfo } from "../bundle/hapModuleInfo"
import { Configuration } from "../ohos_application_Configuration"
export const AbilityStageContextClass = class AbilityStageContext extends ContextClass {
constructor() {
super();
console.warn("AbilityStageContext.constructor interface mocked in the Previewer. How this interface works on the Previewer" +
" may be different from that on a real device.")
this.currentHapModuleInfo = HapModuleInfo;
this.config = Configuration;
}
};
@@ -0,0 +1,28 @@
/*
* Copyright (c) 2022 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
export const AbilityStateDataClass = class AbilityStateData {
constructor() {
console.warn("AbilityStateData.constructor interface mocked in the Previewer. How this interface works on the Previewer" +
" may be different from that on a real device.")
this.moduleName = "[PC Preview] unknow moduleName",
this.bundleName = "[PC Preview] unknow bundleName",
this.abilityName = "[PC Preview] unknow abilityName",
this.pid = "[PC Preview] unknow pid",
this.uid = "[PC Preview] unknow uid",
this.state = "[PC Preview] unknow state",
this.abilityType = "[PC Preview] unknow abilityType"
}
};
@@ -0,0 +1,199 @@
/*
* Copyright (c) 2022 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import { paramMock } from '../../utils'
import { ExtensionContextClass } from './ExtensionContext'
const ElementAttributeNameMock = '[PC Preview] unknown element attribute name';
const ElementAttributeValuesMock = '[PC Preview] unknown element attribute value';
const Rect = {
left: '[PC Preview] unknown element left',
top: '[PC Preview] unknown element top',
width: '[PC Preview] unknown element width',
height: '[PC Preview] unknown element height'
};
const AccessibilityElement = {
attributeNames: function (...args) {
console.warn('AccessibilityElement.attributeNames interface mocked in the Previewer.' +
' How this interface works on the Previewer may be different from that on a real device.');
const len = args.length;
if (typeof args[len - 1] === 'function') {
args[len - 1].call(this, paramMock.businessErrorMock, [ElementAttributeNameMock]);
} else {
return new Promise((resolve, reject) => {
resolve([ElementAttributeNameMock]);
});
}
},
attributeValue: function (...args) {
console.warn('AccessibilityElement.attributeValue interface mocked in the Previewer.' +
' How this interface works on the Previewer may be different from that on a real device.');
let value = null;
switch (args[0]) {
case 'contents':
value = [ElementAttributeValuesMock];
break;
case 'rect':
case 'screenRect':
value = Rect;
break;
case 'parent':
case 'rootElement':
value = AccessibilityElement;
break;
case 'children':
value = [AccessibilityElement];
break;
default:
value = ElementAttributeValuesMock;
break;
}
const len = args.length;
if (typeof args[len - 1] === 'function') {
args[len - 1].call(this, paramMock.businessErrorMock, value);
} else {
return new Promise((resolve, reject) => {
resolve(value);
});
}
},
actionNames: function (...args) {
console.warn('AccessibilityElement.actionNames interface mocked in the Previewer.' +
' How this interface works on the Previewer may be different from that on a real device.');
const len = args.length;
if (typeof args[len - 1] === 'function') {
args[len - 1].call(this, paramMock.businessErrorMock, [param.paramStringMock]);
} else {
return new Promise((resolve, reject) => {
resolve([param.paramStringMock]);
});
}
},
performAction: function (...args) {
console.warn('AccessibilityElement.performAction interface mocked in the Previewer.' +
' How this interface works on the Previewer may be different 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);
});
}
},
findElement: function (...args) {
console.warn('AccessibilityElement.findElement interface mocked in the Previewer.' +
' How this interface works on the Previewer may be different from that on a real device.');
const result = (args[0] === 'content') ? [AccessibilityElement] : AccessibilityElement;
const len = args.length;
if (typeof args[len - 1] === 'function') {
args[len - 1].call(this, paramMock.businessErrorMock, result);
} else {
return new Promise((resolve, reject) => {
resolve(result);
});
}
},
};
export class AccessibilityExtensionContext extends ExtensionContextClass {
constructor(...args) {
super();
console.warn('AccessibilityExtensionContext.constructor interface mocked in the Previewer.' +
' How this interface works on the Previewer may be different from that on a real device.');
this.setEventTypeFilter = function (...args) {
console.warn('AccessibilityExtensionContext.setEventTypeFilter interface mocked in the Previewer.' +
' How this interface works on the Previewer may be 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();
});
}
};
this.setTargetBundleName = function (...args) {
console.warn('AccessibilityExtensionContext.setTargetBundleName interface mocked in the Previewer.' +
' How this interface works on the Previewer may be 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();
});
}
};
this.getFocusElement = function (...args) {
console.warn('AccessibilityExtensionContext.getFocusElement interface mocked in the Previewer.' +
' How this interface works on the Previewer may be different from that on a real device.');
const len = args.length;
if (typeof args[len - 1] === 'function') {
args[len - 1].call(this, paramMock.businessErrorMock, AccessibilityElement);
} else {
return new Promise((resolve, reject) => {
resolve(AccessibilityElement);
});
}
};
this.getWindowRootElement = function (...args) {
console.warn('AccessibilityExtensionContext.getWindowRootElement interface mocked in the Previewer.' +
' How this interface works on the Previewer may be different from that on a real device.');
const len = args.length;
if (typeof args[len - 1] === 'function') {
args[len - 1].call(this, paramMock.businessErrorMock, AccessibilityElement);
} else {
return new Promise((resolve, reject) => {
resolve(AccessibilityElement);
});
}
};
this.getWindows = function (...args) {
console.warn('AccessibilityExtensionContext.getWindows interface mocked in the Previewer.' +
' How this interface works on the Previewer may be different from that on a real device.');
const len = args.length;
if (typeof args[len - 1] === 'function') {
args[len - 1].call(this, paramMock.businessErrorMock, [AccessibilityElement]);
} else {
return new Promise((resolve, reject) => {
resolve([AccessibilityElement]);
});
}
};
this.injectGesture = function (...args) {
console.warn('AccessibilityExtensionContext.injectGesture interface mocked in the Previewer.' +
' How this interface works on the Previewer may be different from that on a real device.');
const len = args.length;
if (typeof args[len - 1] === 'function') {
args[len - 1].call(this, paramMock.businessErrorMock);
} else {
return new Promise((resolve, reject) => {
resolve();
});
}
};
}
};
@@ -0,0 +1,24 @@
/*
* Copyright (c) 2022 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
export const AppStateDataClass = class AppStateData {
constructor() {
console.warn("AppStateData.constructor interface mocked in the Previewer. How this interface works on the Previewer" +
" may be different from that on a real device.");
this.bundleName = "[PC Preview] unknow bundleName";
this.uid = "[PC Preview] unknow uid";
this.state = "[PC Preview] unknow state";
}
};
@@ -0,0 +1,59 @@
/*
* Copyright (c) 2022 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import { paramMock } from "../../utils"
import { ContextClass } from "./Context"
export const ApplicationContextClass = class ApplicationContext extends ContextClass {
constructor() {
super();
console.warn('ApplicationContext.constructor interface mocked in the Previewer. How this interface works on' +
' the Previewer may be different from that on a real device.');
this.registerAbilityLifecycleCallback = function (...args) {
console.warn("ApplicationContext.registerAbilityLifecycleCallback interface mocked in the Previewer." +
" How this interface works on the Previewer may be different from that on a real device.")
return paramMock.paramNumberMock
};
this.unregisterAbilityLifecycleCallback = function (...args) {
console.warn("ApplicationContext.unregisterAbilityLifecycleCallback interface mocked in the Previewer." +
" How this interface works on the Previewer may be different from that on a real device.")
const len = args.length
if (len > 0 && typeof args[len - 1] === 'function') {
args[len - 1].call(this, paramMock.businessErrorMock);
} else {
return new Promise((resolve, reject) => {
resolve();
})
}
};
this.registerEnvironmentCallback = function (...args) {
console.warn("ApplicationContext.registerEnvironmentCallback interface mocked in the Previewer." +
" How this interface works on the Previewer may be different from that on a real device.")
return paramMock.paramNumberMock
};
this.unregisterEnvironmentCallback = function (...args) {
console.warn("ApplicationContext.unregisterEnvironmentCallback interface mocked in the Previewer." +
" How this interface works on the Previewer may be different from that on a real device.")
const len = args.length
if (len > 0 && typeof args[len - 1] === 'function') {
args[len - 1].call(this, paramMock.businessErrorMock);
} else {
return new Promise((resolve, reject) => {
resolve();
})
}
};
}
}
@@ -0,0 +1,37 @@
/*
* Copyright (c) 2022 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
export const ApplicationStateObserverClass = class ApplicationStateObserver {
constructor() {
console.warn('ApplicationStateObserver.constructor interface mocked in the Previewer. How this interface works on' +
' the Previewer may be different from that on a real device.');
this.onForegroundApplicationChanged = function (...args) {
console.warn("ApplicationStateObserver.onForegroundApplicationChanged interface mocked in the Previewer." +
" How this interface works on the Previewer may be different from that on a real device.")
};
this.onAbilityStateChanged = function (...args) {
console.warn("ApplicationStateObserver.onAbilityStateChanged interface mocked in the Previewer." +
" How this interface works on the Previewer may be different from that on a real device.")
};
this.onProcessCreated = function (...args) {
console.warn("ApplicationStateObserver.onProcessCreated interface mocked in the Previewer." +
" How this interface works on the Previewer may be different from that on a real device.")
};
this.onProcessDied = function (...args) {
console.warn("ApplicationStateObserver.onProcessDied interface mocked in the Previewer." +
" How this interface works on the Previewer may be different from that on a real device.")
};
}
}
@@ -12,7 +12,10 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
export const BaseContext = {
stageMode: "[PC Preview] unknow stageMode",
}
export const BaseContextClass = class BaseContext {
constructor() {
console.warn("BaseContext.constructor interface mocked in the Previewer. How this interface works on the Previewer" +
" may be different from that on a real device.");
this.stageMode = "[PC Preview] unknow stageMode";
}
};
@@ -13,7 +13,8 @@
* limitations under the License.
*/
import { ApplicationInfo } from "../bundle/applicationInfo"
import { BaseContext } from "./BaseContext"
import { BaseContextClass as BaseContext } from "./BaseContext"
const ResourceManager = {
getString: function(...args) {
console.warn("ResourceManager.getString interface mocked in the Previewer. " +
@@ -280,10 +281,12 @@ export const ContextClass = class Context extends BaseContext {
this.tempDir = "[PC Preview] unknow tempDir";
this.filesDir = "[PC Preview] unknow filesDir";
this.databaseDir = "[PC Preview] unknow databaseDir";
this.preferencesDir = "[PC Preview] unknow preferencesDir";
this.storageDir = "[PC Preview] unknow storageDir";
this.bundleCodeDir = "[PC Preview] unknow bundleCodeDir";
this.distributedFilesDir = "[PC Preview] unknow distributedFilesDir";
this.eventHub = new EventHubClass();
this.area = AreaMode;
this.createBundleContext = function (...args) {
console.warn("Context.createBundleContext interface mocked in the Previewer. How this interface works on the Previewer" +
" may be different from that on a real device.")
@@ -0,0 +1,25 @@
/*
* Copyright (c) 2022 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
export const ErrorObserverClass = class ErrorObserver {
constructor() {
console.warn("ErrorObserver.constructor interface mocked in the Previewer. How this interface works on the Previewer" +
" may be different from that on a real device.")
this.onUnhandledException = function (...args) {
console.warn("ErrorObserver.onUnhandledException interface mocked in the Previewer. How this interface works on the Previewer" +
" may be different from that on a real device.")
};
}
};
@@ -0,0 +1,33 @@
/*
* Copyright (c) 2022 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
export const EventHubClass = class EventHub {
constructor() {
console.warn("EventHub.constructor interface mocked in the Previewer. How this interface works on the Previewer" +
" may be different from that on a real device.")
this.on = function (...args) {
console.warn("EventHub.on interface mocked in the Previewer. How this interface works on the Previewer" +
" may be different from that on a real device.")
};
this.off = function (...args) {
console.warn("EventHub.off interface mocked in the Previewer. How this interface works on the Previewer" +
" may be different from that on a real device.")
};
this.emit = function (...args) {
console.warn("EventHub.emit interface mocked in the Previewer. How this interface works on the Previewer" +
" may be different from that on a real device.")
};
}
};
@@ -0,0 +1,30 @@
/*
* 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 { HapModuleInfo } from "../bundle/hapModuleInfo";
import { Configuration } from "../ohos_application_Configuration"
import { ExtensionAbilityInfo } from "../bundle/extensionAbilityInfo"
import { ContextClass } from "./Context"
export const ExtensionContextClass = class ExtensionContext extends ContextClass {
constructor() {
super();
console.warn("ExtensionContext.constructor interface mocked in the Previewer. How this interface works on the Previewer" +
" may be different from that on a real device.")
this.currentHapModuleInfo = HapModuleInfo;
this.config = Configuration;
this.extensionAbilityInfo = ExtensionAbilityInfo;
}
};
@@ -0,0 +1,50 @@
/*
* Copyright (c) 2022 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import { paramMock } from "../../utils"
const ElementName = {
deviceId: '[PC preview] unknow deviceId',
bundleName: '[PC preview] unknow bundleName',
abilityName: '[PC preview] unknow abilityName',
uri: '[PC preview] unknow uri',
shortName: '[PC preview] unknow shortName',
moduleName: '[PC preview] unknow moduleName'
}
const ExtensionAbilityType = {
FORM: 0,
WORK_SCHEDULER: 1,
INPUT_METHOD: 2,
SERVICE: 3,
ACCESSIBILITY: 4,
DATA_SHARE: 5,
FILE_SHARE: 6,
STATIC_SUBSCRIBER: 7,
WALLPAPER: 8,
BACKUP: 9,
WINDOW: 10,
ENTERPRISE_ADMIN: 11,
UNSPECIFIED: 20
}
export const ExtensionRunningInfo = {
extension: ElementName,
pid: '[PC preview] unknow pid',
uid: '[PC preview] unknow uid',
processName: '[PC preview] unknow processName',
startTime: '[PC preview] unknow startTime',
clientPackage: [paramMock.paramStringMock],
abilityState: ExtensionAbilityType
}
@@ -12,14 +12,14 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import { ExtensionContextClass } from "./abilityContext"
export const formExtensionContextClass = class formExtensionContext extends ExtensionContextClass {
import { ExtensionContextClass } from "./ExtensionContext"
export const FormExtensionContextClass = class FormExtensionContext extends ExtensionContextClass {
constructor() {
super();
console.warn('formExtensionContext.constructor interface mocked in the Previewer. How this interface works on' +
console.warn('FormExtensionContext.constructor interface mocked in the Previewer. How this interface works on' +
' the Previewer may be different from that on a real device.');
this.startAbility = function (...args) {
console.warn("formExtensionContext.startAbility interface mocked in the Previewer." +
console.warn("FormExtensionContext.startAbility interface mocked in the Previewer." +
" How this interface works on the Previewer may be different from that on a real device.");
const len = args.length;
if (len > 0 && typeof args[len - 1] === 'function') {
@@ -0,0 +1,27 @@
/*
* Copyright (c) 2022 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import { WantClass } from "../ohos_application_Want"
export const MissionInfo = {
missionId: '[PC preview] unknow missionId',
runningState: '[PC preview] unknow runningState',
lockedState: '[PC preview] unknow lockedState',
timestamp: '[PC preview] unknow timestamp',
want: new WantClass(),
label: '[PC preview] unknow label',
iconPath: '[PC preview] unknow iconPath',
continuable: '[PC preview] unknow continuable'
}
@@ -0,0 +1,37 @@
/*
* Copyright (c) 2022 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
export const MissionListener = {
onMissionCreated: function(...args) {
console.warn("MissionListener.onMissionCreated interface mocked in the Previewer." +
" How this interface works on the Previewer may be different from that on a real device.")
},
onMissionDestroyed: function(...args) {
console.warn("MissionListener.onMissionDestroyed interface mocked in the Previewer." +
" How this interface works on the Previewer may be different from that on a real device.")
},
onMissionSnapshotChanged: function(...args) {
console.warn("MissionListener.onMissionSnapshotChanged interface mocked in the Previewer." +
" How this interface works on the Previewer may be different from that on a real device.")
},
onMissionMovedToFront: function(...args) {
console.warn("MissionListener.onMissionMovedToFront interface mocked in the Previewer." +
" How this interface works on the Previewer may be different from that on a real device.")
},
onMissionIconUpdated: function(...args) {
console.warn("MissionListener.onMissionIconUpdated interface mocked in the Previewer." +
" How this interface works on the Previewer may be different from that on a real device.")
}
}
@@ -0,0 +1,30 @@
/*
* 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 { PixelMapMock } from "../../multimedia"
const ElementName = {
deviceId: '[PC preview] unknown deviceId',
bundleName: '[PC preview] unknown bundleName',
abilityName: '[PC preview] unknown abilityName',
uri: '[PC preview] unknown uri',
shortName: '[PC preview] unknown shortName',
moduleName: '[PC preview] unknown moduleName'
}
export const MissionSnapshot = {
abality: ElementName,
snapshot: PixelMapMock
}
@@ -0,0 +1,25 @@
/*
* Copyright (c) 2022 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import { paramMock } from "../../utils"
export const PermissionRequestResultClass = class PermissionRequestResult {
constructor() {
console.warn("PermissionRequestResult.constructor interface mocked in the Previewer. How this interface works on the Previewer" +
" may be different from that on a real device.")
this.permissions = [paramMock.paramStringMock]
this.authResults = [paramMock.paramNumberMock]
}
};
@@ -0,0 +1,24 @@
/*
* Copyright (c) 2022 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
export const ProcessDataClass = class ProcessData {
constructor() {
console.warn("ProcessData.constructor interface mocked in the Previewer. How this interface works on the Previewer" +
" may be different from that on a real device.")
this.bundleName = "[PC Preview] unknow bundleName"
this.pid = "[PC Preview] unknow pid"
this.uid = "[PC Preview] unknow uid"
}
};
@@ -0,0 +1,23 @@
/*
* Copyright (c) 2022 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import { paramMock } from "../../utils"
export const ProcessRunningInfo = {
pid: "[PC Preview] unknow pid",
uid: "[PC Preview] unknow uid",
processName: "[PC Preview] unknow processName",
bundleNames: [paramMock.paramStringMock]
}
@@ -0,0 +1,131 @@
/*
* Copyright (c) 2022 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import { paramMock } from "../../utils"
import { ExtensionContextClass } from "./ExtensionContext"
export const ServiceExtensionContextClass = class ServiceExtensionContext extends ExtensionContextClass {
constructor() {
super();
console.warn("ServiceExtensionContext.constructor interface mocked in the Previewer. How this interface works on the Previewer" +
" may be different from that on a real device.")
this.startAbility = function (...args) {
console.warn("ServiceExtensionContext.startAbility interface mocked in the Previewer." +
" How this interface works on the Previewer may be different from that on a real device.")
const len = args.length
if (len > 0 && typeof args[len - 1] === 'function') {
args[len - 1].call(this, paramMock.businessErrorMock);
} else {
return new Promise((resolve, reject) => {
resolve();
})
}
};
this.startAbilityWithAccount = function (...args) {
console.warn("ServiceExtensionContext.startAbilityWithAccount interface mocked in the Previewer." +
" How this interface works on the Previewer may be different from that on a real device.")
const len = args.length
if (len > 0 && typeof args[len - 1] === 'function') {
args[len - 1].call(this, paramMock.businessErrorMock);
} else {
return new Promise((resolve, reject) => {
resolve();
})
}
};
this.startServiceExtensionAbility = function (...args) {
console.warn("ServiceExtensionContext.startServiceExtensionAbility interface mocked in the Previewer." +
" How this interface works on the Previewer may be different from that on a real device.")
const len = args.length
if (len > 0 && typeof args[len - 1] === 'function') {
args[len - 1].call(this, paramMock.businessErrorMock);
} else {
return new Promise((resolve, reject) => {
resolve();
})
}
};
this.startServiceExtensionAbilityWithAccount = function (...args) {
console.warn("ServiceExtensionContext.startServiceExtensionAbilityWithAccount interface mocked in the Previewer." +
" How this interface works on the Previewer may be different from that on a real device.")
const len = args.length
if (len > 0 && typeof args[len - 1] === 'function') {
args[len - 1].call(this, paramMock.businessErrorMock);
} else {
return new Promise((resolve, reject) => {
resolve();
})
}
};
this.stopServiceExtensionAbility = function (...args) {
console.warn("ServiceExtensionContext.stopServiceExtensionAbility interface mocked in the Previewer." +
" How this interface works on the Previewer may be different from that on a real device.")
const len = args.length
if (len > 0 && typeof args[len - 1] === 'function') {
args[len - 1].call(this, paramMock.businessErrorMock);
} else {
return new Promise((resolve, reject) => {
resolve();
})
}
};
this.stopServiceExtensionAbilityWithAccount = function (...args) {
console.warn("ServiceExtensionContext.stopServiceExtensionAbilityWithAccount interface mocked in the Previewer." +
" How this interface works on the Previewer may be different from that on a real device.")
const len = args.length
if (len > 0 && typeof args[len - 1] === 'function') {
args[len - 1].call(this, paramMock.businessErrorMock);
} else {
return new Promise((resolve, reject) => {
resolve();
})
}
};
this.terminateSelf = function (...args) {
console.warn("ServiceExtensionContext.terminateSelf interface mocked in the Previewer." +
" How this interface works on the Previewer may be different from that on a real device.")
const len = args.length
if (len > 0 && typeof args[len - 1] === 'function') {
args[len - 1].call(this, paramMock.businessErrorMock);
} else {
return new Promise((resolve, reject) => {
resolve();
})
}
};
this.connectAbility = function (...args) {
console.warn("ServiceExtensionContext.connectAbility interface mocked in the Previewer." +
" How this interface works on the Previewer may be different from that on a real device.")
return paramMock.paramNumberMock
};
this.connectAbilityWithAccount = function (...args) {
console.warn("ServiceExtensionContext.connectAbilityWithAccount interface mocked in the Previewer." +
" How this interface works on the Previewer may be different from that on a real device.")
return paramMock.paramNumberMock
};
this.disconnectAbility = function (...args) {
console.warn("ServiceExtensionContext.disconnectAbility interface mocked in the Previewer." +
" How this interface works on the Previewer may be different from that on a real device.")
const len = args.length
if (len > 0 && typeof args[len - 1] === 'function') {
args[len - 1].call(this, paramMock.businessErrorMock);
} else {
return new Promise((resolve, reject) => {
resolve();
})
}
};
}
};
@@ -14,7 +14,7 @@
*/
import { paramMock } from "../../utils"
import { AbilityClass } from "../ohos_application_Ability"
import { ContextClass } from "../ohos_application_ServiceExtAbility"
import { ContextClass } from "./Context"
import { ShellCmdResult } from "./shellCmdResult"
export const AbilityDelegator = {
@@ -41,6 +41,9 @@ export const AbilityInfo = {
appId: '[PC Preview] unknow appId',
label: "[PC preview] unknown label",
description: "[PC preview] unknown description",
icon: "[PC preview] unknown icon",
labelId: "[PC preview] unknown labelId",
iconId: "[PC preview] unknown iconId",
uid: '[PC Preview] unknow uid',
installTime: '[PC Preview] unknow installTime',
updateTime: '[PC Preview] unknow updateTime',
@@ -39,7 +39,7 @@ export const BundleInfo = {
installTime: "[PC preview] unknown installTime",
updateTime: "[PC preview] unknown updateTime",
appInfo: ApplicationInfo,
abilityInfo: [AbilityInfo],
abilityInfos: [AbilityInfo],
reqPermissions: [paramMock.paramStringMock],
reqPermissionDetails: [ReqPermissionDetail],
vendor: "[PC preview] unknown vendor",
@@ -24,6 +24,7 @@ export const HashParam = {
export const InstallParam = {
userId: "[PC preview] unknown userId",
installFlag: "[PC preview] unknown installFlag",
isKeepData: "[PC preview] unknown isKeepData",
hashParams: [HashParam],
crowdtestDeadline: "[PC preview] unknown crowdtestDeadline",
}
@@ -14,6 +14,6 @@
*/
export const DispatchInfo = {
verison: "[PC preview] unknown verison",
version: "[PC preview] unknown version",
dispatchAPI: "[PC preview] unknown dispatchAPI",
}
@@ -15,6 +15,8 @@
import { paramMock } from "../../utils"
import { AbilityInfo } from './abilityInfo';
import { ExtensionAbilityInfo } from './extensionAbilityInfo';
import { Metadata } from './metadata';
export const HapModuleInfo = {
@@ -33,4 +35,8 @@ export const HapModuleInfo = {
moduleName: "[PC preview] unknown moduleName",
mainAbilityName: "[PC preview] unknown mainAbilityName",
installationFree: "[PC preview] unknown installationFree",
mainElementName: "[PC preview] unknown mainElementName",
extensionAbilityInfo: [ExtensionAbilityInfo],
metadata: [Metadata],
hashValue: "[PC preview] unknown mainElementName",
}
@@ -18,8 +18,8 @@ import { ApplicationInfo } from './applicationInfo';
import { ElementName } from './elementName'
export const LauncherAbilityInfo = {
applicationInfo: {ApplicationInfo},
elementName: {ElementName},
applicationInfo: ApplicationInfo,
elementName: ElementName,
labelId: "[PC preview] unknown labelId",
iconId: "[PC preview] unknown iconId",
userId: "[PC preview] unknown userId",
@@ -33,7 +33,7 @@ export const ModuleDistroInfo = {
export const AbilityFormInfo = {
name: "[PC preview] unknown name",
type: "[PC preview] unknown type",
updateEnabledtype: "[PC preview] unknown updateEnabled",
updateEnabled: "[PC preview] unknown updateEnabled",
scheduledUpdateTime: "[PC preview] unknown scheduledUpdateTime",
updateDuration: "[PC preview] unknown updateDuration",
supportDimensions: [paramMock.paramNumberMock],
@@ -18,5 +18,5 @@ export const CommonEventData = {
bundleName: '[PC preview] unknow bundleName',
code: '[PC preview] unknow code',
data: '[PC preview] unknow data',
parameters: {}
}
parameters: {"key": "unknown any"},
}
@@ -21,5 +21,5 @@ export const CommonEventPublishData = {
subscriberPermissions: [paramMock.paramStringMock],
isOrdered: '[PC preview] unknow isOrdered',
isSticky: '[PC preview] unknow isSticky',
parameters: {}
}
parameters: {"key": "unknown any"},
}
@@ -23,5 +23,5 @@ export const ContinuationExtraParams = {
description: "[PC Preview] unknow description",
filter: "[PC Preview] unknow filter",
continuationMode: ContinuationMode,
authInfo: {}
}
authInfo: {"key":"unknow any"}
}
+70 -10
View File
@@ -15,23 +15,34 @@
import { mockSystemParameter } from './ohos_systemparameter'
import { mockAbility } from './ohos_application_Ability'
import { mockErrorCode } from './ohos_ability_errorCode'
import { mockFeatureAbility } from './ohos_ability_featureAbility'
import { mockDataUriUtils } from './ohos_ability_dataUriUtils'
import { mockWantConstant } from './ohos_ability_wantConstant'
import { mockAbilityConstant } from './ohos_application_AbilityConstant'
import { mockAbilityDelegatorRegistry } from './ohos_application_abilityDelegatorRegistry'
import { mockAbilityLifecycleCallback } from './ohos_application_AbilityLifecycleCallback'
import { mockFormExtension } from './ohos_application_FormExtension'
import { mockStaticSubscriberExtensionAbility } from './ohos_application_StaticSubscriberExtensionAbility'
import { mockFormHost } from './ohos_application_formHost'
import { mockFormInfo } from './ohos_application_formInfo'
import { mockErrorManager } from './ohos_application_errorManager'
import { mockTestRunner } from './ohos_application_testRunner'
import { mockWant } from './ohos_application_Want'
import { mockServiceExtensionAbility } from './ohos_application_ServiceExtensionAbility'
import { mockStartOptions } from './ohos_application_StartOptions'
import { mockAbilityStage } from './ohos_application_AbilityStage'
import { mockFormBindingData } from './ohos_application_formBindingData'
import { mockFormError } from './ohos_application_formError'
import { mockAbilityManager } from './ohos_application_abilityManager'
import { mockParticleAbility } from './ohos_ability_particleAbility'
import { mockAppManager } from './ohos_application_appManager'
import { mockConfiguration } from './ohos_application_Configuration'
import { mockConfigurationConstant } from './ohos_application_ConfigurationConstant'
import { mockContext } from './ohos_application_context'
import { mockDataShareExtensionAbility } from './ohos_application_DataShareExtensionAbility'
import { mockEnvironmentCallback } from './ohos_application_EnvironmentCallback'
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'
@@ -54,6 +65,7 @@ import { mockHilog } from './ohos_hilog'
import { mockHiSysEvent } from './ohos_hiSysEvent'
import { mockHiTraceChain } from './ohos_hiTraceChain'
import { mockHidebug } from './ohos_hidebug'
import { mockFaultLogger } from './ohos_faultLogger'
import { mockTv } from './tv'
import { mockDtv } from './dtv'
import { mockDistributedAccount } from './ohos_account_distributedAccount'
@@ -71,6 +83,7 @@ import { mockInputDevice } from './ohos_multimodalInput_inputDevice'
import { mockVibrator } from './ohos_vibrator'
import { mockSensor } from './ohos_sensor'
import { mockWifi } from './ohos_wifi'
import { mockWifiExt } from './ohos_wifiext'
import { mockUsb } from './ohos_usb'
import { mockBundle } from './ohos_bundle'
import { mockInnerBundle } from './ohos_bundle_innerBundleManager'
@@ -92,6 +105,7 @@ import { mockSecurityLabel } from './ohos_securitylabel'
import { mockWorkScheduler } from './ohos_workScheduler'
import { mockWorkSchedulerExtensionAbility } from './ohos_WorkSchedulerExtensionAbility'
import { mockUserAuth } from './ohos_userIAM_userAuth'
import { mockFaceAuth } from './ohos_userIAM_faceAuth'
import { mockArrayList } from './ohos_util_Arraylist'
import { mockDeque } from './ohos_util_Deque'
import { mockHashMap } from './ohos_util_HashMap'
@@ -106,6 +120,7 @@ import { mockStack } from './ohos_util_Stack'
import { mockTreeMap } from './ohos_util_TreeMap'
import { mockTreeSet } from './ohos_util_TreeSet'
import { mockVector } from './ohos_util_Vector'
import { mockMultimediaAVSession } from './ohos_multimedia_av_session'
import { mockMultimediaCamera } from './ohos_multimedia_camera'
import { mockMultimediaAudio } from './ohos_multimedia_audio'
import { mockMultimediaImage } from './ohos_multimedia_image'
@@ -172,6 +187,11 @@ import { mockMouseEvent } from './ohos_multimodalInput_mouseEvent'
import { mockTouchEvent } from './ohos_multimodalInput_touchEvent'
import { mockUiAppearance } from './ohos_uiAppearance'
import { mockContinationManager } from './ohos_continuation_continuationManager'
import { mockUiTest } from './ohos_uitest'
import { mockWindowAnimationManager } from './ohos_animation_windowAnimationManager'
import { mockAccessibility } from './ohos_accessibility'
import { mockAccessibilityConfig } from './ohos_accessibility_config'
import { mockAccessibilityExtensionAbility } from './ohos_application_AccessibilityExtensionAbility'
export function mockRequireNapiFun() {
global.requireNapi = function (...args) {
switch (args[0]) {
@@ -189,7 +209,7 @@ export function mockRequireNapiFun() {
return mockZlib();
case "screenshot":
return mockScreenshot();
case "WantAgent":
case "wantAgent":
return mockWantAgent();
case "wallpaper":
return mockWallpaper();
@@ -273,24 +293,38 @@ export function mockRequireNapiFun() {
return mockBatteryinfo();
case "systemParameter":
return mockSystemParameter();
case "ability.errorCode":
return mockErrorCode();
case "ability.dataUriUtils":
return mockDataUriUtils();
case "ability.particleAbility":
return mockParticleAbility();
case "ability.featureAbility":
return mockFeatureAbility();
case "ability.wantConstant":
return mockWantConstant();
case "application.Ability":
return mockAbility();
case "application.formHost":
return mockFormHost();
case "application.formInfo":
return mockFormInfo();
case "application.FormExtension":
return mockFormExtension();
case "application.ServiceExtensionAbility":
return mockServiceExtensionAbility();
case "application.StartOptions":
return mockStartOptions();
case "application.StaticSubscriberExtensionAbility":
return mockStaticSubscriberExtensionAbility()
case "application.errorManager":
return mockErrorManager();
case "application.testRunner":
return mockTestRunner();
case "application.StaticSubscriberExtensionAbility":
return mockStaticSubscriberExtensionAbility();
case "application.Want":
return mockWant();
case "application.AbilityConstant":
return mockAbilityConstant();
case "application.abilityDelegatorRegistry":
return mockAbilityDelegatorRegistry();
case "application.AbilityLifecycleCallback":
@@ -299,16 +333,24 @@ export function mockRequireNapiFun() {
return mockAbilityStage();
case "application.formBindingData":
return mockFormBindingData();
case "application.formError":
return mockFormError();
case "application.abilityManager":
return mockAbilityManager();
case "application.appManager":
return mockAppManager();
case "application.Configuration":
return mockConfiguration();
case "application.ConfigurationConstant":
return mockConfigurationConstant();
case "application.context":
return mockContext();
case "application.DataShareExtensionAbility":
return mockDataShareExtensionAbility();
case "application.EnvironmentCallback":
return mockEnvironmentCallback();
case "application.missionManager":
return mockMissionManager();
case "application.ServiceExtAbility":
return mockServiceExtAbility();
case "application.UriPermissionManager":
return mockUriPermissionManager();
case "commonEvent":
@@ -353,6 +395,8 @@ export function mockRequireNapiFun() {
return mockHidebug();
case "hiTraceChain":
return mockHiTraceChain();
case "faultLogger":
return mockFaultLogger();
case "tv":
return mockTv();
case "dtv":
@@ -387,6 +431,8 @@ export function mockRequireNapiFun() {
return mockSensor();
case "wifi":
return mockWifi();
case "wifiext":
return mockWifiExt();
case "usb":
return mockUsb();
case "bundle":
@@ -405,13 +451,13 @@ export function mockRequireNapiFun() {
return mockConvertXml();
case "statfs":
return mockStatfs();
case "filemanager":
case "fileManager":
return mockFileManager();
case "environment":
return mockEnvironment();
case "storagestatistics":
case "storageStatistics":
return mockStorageStatistics();
case "volumemanager":
case "volumeManager":
return mockVolumeManager();
case "settings":
return mockSettings();
@@ -425,7 +471,7 @@ export function mockRequireNapiFun() {
return mockBackgroundTaskManager();
case "bundleState":
return mockBundleState();
case "securitylabel":
case "securityLabel":
return mockSecurityLabel();
case "workScheduler":
return mockWorkScheduler();
@@ -433,6 +479,8 @@ export function mockRequireNapiFun() {
return mockWorkSchedulerExtensionAbility();
case "userIAM.userAuth":
return mockUserAuth();
case "userIAM.faceAuth":
return mockFaceAuth();
case "util.ArrayList":
return mockArrayList();
case "util.Deque":
@@ -467,6 +515,8 @@ export function mockRequireNapiFun() {
return mockMultimediaMedia();
case "multimedia.image":
return mockMultimediaImage();
case "multimedia.avsession":
return mockMultimediaAVSession();
case "multimedia.camera":
return mockMultimediaCamera();
case "multimedia.audio":
@@ -491,8 +541,18 @@ export function mockRequireNapiFun() {
return mockMouseEvent();
case "multimodalInput.touchEvent":
return mockTouchEvent();
case "accessibility":
return mockAccessibility();
case "accessibility.config":
return mockAccessibilityConfig();
case "application.AccessibilityExtensionAbility":
return mockAccessibilityExtensionAbility();
case "continuation.continuationManager":
return mockContinationManager();
case "uitest":
return mockUiTest();
case "animation.windowAnimationManager":
return mockWindowAnimationManager();
default:
return global.requireNapiPreview(...args);
}
@@ -17,6 +17,6 @@ import { NotificationUserInput } from "./notificationUserInput"
export const NotificationActionButton = {
title: '[PC preview] unknow title',
wantAgent: '[PC preview] unknow wantAgent',
extras: {},
extras: {"key": "unknown any"},
userInput: NotificationUserInput,
}
}
@@ -30,7 +30,7 @@ export const NotificationRequest = {
tapDismissed: '[PC preview] unknow tapDismissed',
autoDeletedTime: '[PC preview] unknow autoDeletedTime',
wantAgent: '[PC preview] unknow wantAgent',
extraInfo: {},
extraInfo: {"key": "unknown any"},
color: '[PC preview] unknow color',
colorEnabled: '[PC preview] unknow colorEnabled',
isAlertOnce: '[PC preview] unknow isAlertOnce',
@@ -64,4 +64,4 @@ export const DistributedOptions = {
supportDisplayDevices: [paramMock.paramStringMock],
supportOperateDevices: [paramMock.paramStringMock],
remindType: '[PC preview] unknow remindType',
}
}
@@ -15,6 +15,6 @@
import { paramMock } from "../../utils"
export const NotificationSortingMap = {
sortings: {},
sortings: {"key": "unknown any"},
sortedHashCode: [paramMock.paramStringMock],
};
};
@@ -14,5 +14,5 @@
*/
export const NotificationTemplate = {
name: '[PC preview] unknow name',
data: {},
}
data: {"key": "unknown any"},
}
@@ -17,4 +17,7 @@ export const ErrorCode = {
ABILITY_NOT_FOUND: -2,
INVALID_PARAMETER: -1,
NO_ERROR: 0,
}
export function mockErrorCode() {
return ErrorCode;
}
@@ -15,274 +15,13 @@
import { paramMock } from "../utils"
import { WantClass } from "./ohos_application_Want"
import { Context } from "./app/context"
import { Context as _Context } from "./app/context"
import { AbilityResult } from "./ability/abilityResult"
import { windowMock } from "./ohos_window"
import { DataAbilityHelper } from "./ability/dataAbilityHelper"
import { AppVersionInfo as _AppVersionInfo } from "./app/appVersionInfo"
import { ProcessInfo as _ProcessInfo } from "./app/processInfo"
const DataAbilityResult = {
uri: "[PC Preview] unknow uri",
count: "[PC Preview] unknow count"
}
const DataAbilityResultArray = [
DataAbilityResult
]
export const PacMapType = {
PacMap: {key:{}}
}
export const ResultSet = {
columnNames: [paramMock.paramStringMock],
columnCount: "[PC Preview] unknow columnCount",
rowCount: "[PC Preview] unknow rowCount",
rowIndex: "[PC Preview] unknow rowIndex",
isAtFirstRow: "[PC Preview] unknow isAtFirstRow",
isAtLastRow: "[PC Preview] unknow isAtLastRow",
isEnded: "[PC Preview] unknow isEnded",
isStarted: "[PC Preview] unknow isStarted",
isClose: "[PC Preview] unknow isClose",
getColumnIndex: function (...args) {
console.warn("ResultSet.getColumnIndex interface mocked in the Previewer. How this interface works on the Previewer" +
" may be different from that on a real device.")
return paramMock.paramNumberMock;
},
getColumnName: function (...args) {
console.warn("ResultSet.getColumnName interface mocked in the Previewer. How this interface works on the Previewer" +
" may be different from that on a real device.")
return paramMock.paramStringMock;
},
goTo: function (...args) {
console.warn("ResultSet.goTo interface mocked in the Previewer. How this interface works on the Previewer" +
" may be different from that on a real device.")
return paramMock.paramBooleanMock;
},
goToRow: function (...args) {
console.warn("ResultSet.goToRow interface mocked in the Previewer. How this interface works on the Previewer" +
" may be different from that on a real device.")
return paramMock.paramBooleanMock;
},
goToLastRow: function (...args) {
console.warn("ResultSet.goToLastRow interface mocked in the Previewer. How this interface works on the Previewer" +
" may be different from that on a real device.")
return paramMock.paramBooleanMock;
},
goToFirstRow: function (...args) {
console.warn("ResultSet.goToFirstRow interface mocked in the Previewer. How this interface works on the Previewer" +
" may be different from that on a real device.")
return paramMock.paramBooleanMock;
},
goToNextRow: function (...args) {
console.warn("ResultSet.goToNextRow interface mocked in the Previewer. How this interface works on the Previewer" +
" may be different from that on a real device.")
return paramMock.paramBooleanMock;
},
goToPreviousRow: function (...args) {
console.warn("ResultSet.goToPreviousRow interface mocked in the Previewer. How this interface works on the Previewer" +
" may be different from that on a real device.")
return paramMock.paramBooleanMock;
},
getBlob: function (...args) {
console.warn("ResultSet.getBlob interface mocked in the Previewer. How this interface works on the Previewer" +
" may be different from that on a real device.")
return paramMock.paramArrayMock;
},
getString: function (...args) {
console.warn("ResultSet.getString interface mocked in the Previewer. How this interface works on the Previewer" +
" may be different from that on a real device.")
return paramMock.paramStringMock;
},
getLong: function (...args) {
console.warn("ResultSet.getLong interface mocked in the Previewer. How this interface works on the Previewer" +
" may be different from that on a real device.")
return paramMock.paramNumberMock;
},
getDouble: function (...args) {
console.warn("ResultSet.getDouble interface mocked in the Previewer. How this interface works on the Previewer" +
" may be different from that on a real device.")
return paramMock.paramNumberMock;
},
isColumnNull: function (...args) {
console.warn("ResultSet.isColumnNull interface mocked in the Previewer. How this interface works on the Previewer" +
" may be different from that on a real device.")
return paramMock.paramBooleanMock;
},
close: function () {
console.warn("ResultSet.isColumnNull interface mocked in the Previewer. How this interface works on the Previewer" +
" may be different from that on a real device.")
}
}
const DataAbilityHelper = {
openFile: function (...args) {
console.warn("DataAbilityHelper.openFile interface mocked in the Previewer. How this interface works on the Previewer" +
" may be different from that on a real device.")
const len = args.length
if (typeof args[len - 1] === 'function') {
args[len - 1].call(this, paramMock.businessErrorMock, paramMock.paramNumberMock)
} else {
return new Promise((resolve) => {
resolve(paramMock.paramNumberMock);
})
}
},
on: function (...args) {
console.warn("DataAbilityHelper.on interface mocked in the Previewer. How this interface works on the Previewer" +
" may be different from that on a real device.")
const len = args.length
if (typeof args[len - 1] === 'function') {
args[len - 1].call(this, paramMock.businessErrorMock)
}
},
off: function (...args) {
console.warn("DataAbilityHelper.off interface mocked in the Previewer. How this interface works on the Previewer" +
" may be different from that on a real device.")
const len = args.length
if (typeof args[len - 1] === 'function') {
args[len - 1].call(this, paramMock.businessErrorMock)
}
},
getType: function (...args) {
console.warn("DataAbilityHelper.getType interface mocked in the Previewer. How this interface works on the Previewer" +
" may be different from that on a real device.")
const len = args.length
if (typeof args[len - 1] === 'function') {
args[len - 1].call(this, paramMock.businessErrorMock, paramMock.paramStringMock)
} else {
return new Promise((resolve) => {
resolve(paramMock.paramStringMock);
})
}
},
getFileTypes: function (...args) {
console.warn("DataAbilityHelper.getFileTypes interface mocked in the Previewer. How this interface works on the Previewer" +
" may be different from that on a real device.")
const len = args.length
if (typeof args[len - 1] === 'function') {
args[len - 1].call(this, paramMock.businessErrorMock, [paramMock.paramStringMock])
} else {
return new Promise((resolve) => {
resolve([paramMock.paramStringMock]);
})
}
},
normalizeUri: function (...args) {
console.warn("DataAbilityHelper.normalizeUri interface mocked in the Previewer. How this interface works on the Previewer" +
" may be different from that on a real device.")
const len = args.length
if (typeof args[len - 1] === 'function') {
args[len - 1].call(this, paramMock.businessErrorMock, paramMock.paramStringMock)
} else {
return new Promise((resolve) => {
resolve(paramMock.paramStringMock);
})
}
},
denormalizeUri: function (...args) {
console.warn("DataAbilityHelper.denormalizeUri interface mocked in the Previewer. How this interface works on the Previewer" +
" may be different from that on a real device.")
const len = args.length
if (typeof args[len - 1] === 'function') {
args[len - 1].call(this, paramMock.businessErrorMock, paramMock.paramStringMock)
} else {
return new Promise((resolve) => {
resolve(paramMock.paramStringMock);
})
}
},
notifyChange: function (...args) {
console.warn("DataAbilityHelper.notifyChange interface mocked in the Previewer. How this interface works on the Previewer" +
" may be different from that on a real device.")
const len = args.length
if (typeof args[len - 1] === 'function') {
args[len - 1].call(this, paramMock.businessErrorMock)
} else {
return new Promise((resolve) => {
resolve();
})
}
},
insert: function (...args) {
console.warn("DataAbilityHelper.insert interface mocked in the Previewer. How this interface works on the Previewer" +
" may be different from that on a real device.")
const len = args.length
if (typeof args[len - 1] === 'function') {
args[len - 1].call(this, paramMock.businessErrorMock, paramMock.paramNumberMock)
} else {
return new Promise((resolve) => {
resolve(paramMock.paramNumberMock);
})
}
},
batchInsert: function (...args) {
console.warn("DataAbilityHelper.batchInsert interface mocked in the Previewer. How this interface works on the Previewer" +
" may be different from that on a real device.")
const len = args.length
if (typeof args[len - 1] === 'function') {
args[len - 1].call(this, paramMock.businessErrorMock, paramMock.paramNumberMock)
} else {
return new Promise((resolve) => {
resolve(paramMock.paramNumberMock);
})
}
},
delete: function (...args) {
console.warn("DataAbilityHelper.delete interface mocked in the Previewer. How this interface works on the Previewer" +
" may be different from that on a real device.")
const len = args.length
if (typeof args[len - 1] === 'function') {
args[len - 1].call(this, paramMock.businessErrorMock, paramMock.paramNumberMock)
} else {
return new Promise((resolve) => {
resolve(paramMock.paramNumberMock);
})
}
},
update: function (...args) {
console.warn("DataAbilityHelper.update interface mocked in the Previewer. How this interface works on the Previewer" +
" may be different from that on a real device.")
const len = args.length
if (typeof args[len - 1] === 'function') {
args[len - 1].call(this, paramMock.businessErrorMock, paramMock.paramNumberMock)
} else {
return new Promise((resolve) => {
resolve(paramMock.paramNumberMock);
})
}
},
query: function (...args) {
console.warn("DataAbilityHelper.query interface mocked in the Previewer. How this interface works on the Previewer" +
" may be different from that on a real device.")
const len = args.length
if (typeof args[len - 1] === 'function') {
args[len - 1].call(this, paramMock.businessErrorMock, ResultSet)
} else {
return new Promise((resolve) => {
resolve(ResultSet);
})
}
},
call: function (...args) {
console.warn("DataAbilityHelper.call interface mocked in the Previewer. How this interface works on the Previewer" +
" may be different from that on a real device.")
const len = args.length
if (typeof args[len - 1] === 'function') {
args[len - 1].call(this, paramMock.businessErrorMock, PacMapType)
} else {
return new Promise((resolve) => {
resolve(PacMapType);
})
}
},
executeBatch: function (...args) {
console.warn("DataAbilityHelper.executeBatch interface mocked in the Previewer. How this interface works on the Previewer" +
" may be different from that on a real device.")
const len = args.length
if (typeof args[len - 1] === 'function') {
args[len - 1].call(this, paramMock.businessErrorMock, DataAbilityResultArray)
} else {
return new Promise((resolve) => {
resolve(DataAbilityResultArray);
})
}
}
}
export function mockFeatureAbility() {
const featureAbility = {
getWant: function (...args) {
@@ -312,7 +51,7 @@ export function mockFeatureAbility() {
getContext: function () {
console.warn("featureAbility.getContext interface mocked in the Previewer." +
" How this interface works on the Previewer may be different from that on a real device.")
return Context;
return _Context;
},
startAbilityForResult: function (...args) {
console.warn("featureAbility.startAbilityForResult interface mocked in the Previewer." +
@@ -396,6 +135,13 @@ export function mockFeatureAbility() {
})
}
},
AbilityWindowConfiguration,
AbilityStartSetting,
ErrorCode,
DataAbilityOperationType,
Context: _Context,
AppVersionInfo: _AppVersionInfo,
ProcessInfo: _ProcessInfo
}
return featureAbility;
}
@@ -0,0 +1,96 @@
/*
* Copyright (c) 2022 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import { paramMock } from "../utils"
import { DataAbilityHelper } from "./ability/dataAbilityHelper"
export function mockParticleAbility() {
const particleAbility = {
startAbility: function (...args) {
console.warn("ability.particleAbility.startAbility interface mocked in the Previewer. How this interface works" +
" on the Previewer may be different from that on a real device.")
const len = args.length
if (typeof args[len - 1] === 'function') {
args[len - 1].call(this, paramMock.businessErrorMock)
} else {
return new Promise((resolve) => {
resolve()
})
}
},
terminateSelf: function (...args) {
console.warn("ability.particleAbility.terminateSelf interface mocked in the Previewer. How this interface works" +
" on the Previewer may be different from that on a real device.")
const len = args.length
if (typeof args[len - 1] === 'function') {
args[len - 1].call(this, paramMock.businessErrorMock)
} else {
return new Promise((resolve) => {
resolve()
})
}
},
acquireDataAbilityHelper: function (...args) {
console.warn("ability.particleAbility.acquireDataAbilityHelper interface mocked in the Previewer. How this interface works" +
" on the Previewer may be different from that on a real device.")
return DataAbilityHelper;
},
connectAbility: function (...args) {
console.warn("ability.particleAbility.connectAbility interface mocked in the Previewer. How this interface works" +
" on the Previewer may be different from that on a real device.")
return paramMock.paramNumberMock;
},
disconnectAbility: function (...args) {
console.warn("ability.particleAbility.disconnectAbility interface mocked in the Previewer. How this interface works" +
" on the Previewer may be different from that on a real device.")
const len = args.length
if (typeof args[len - 1] === 'function') {
args[len - 1].call(this, paramMock.businessErrorMock)
} else {
return new Promise((resolve) => {
resolve()
})
}
},
startBackgroundRunning: function (...args) {
console.warn("ability.particleAbility.startBackgroundRunning interface mocked in the Previewer. How this interface works" +
" on the Previewer may be 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()
})
}
},
cancelBackgroundRunning: function (...args) {
console.warn("ability.particleAbility.cancelBackgroundRunning interface mocked in the Previewer. How this interface works" +
" on the Previewer may be 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()
})
}
},
ErrorCode : {
INVALID_PARAMETER: -1,
}
}
return particleAbility;
}
@@ -65,4 +65,12 @@ export const Flags = {
FLAG_ABILITY_CLEAR_MISSION: 0x00008000,
FLAG_ABILITY_NEW_MISSION: 0x10000000,
FLAG_ABILITY_MISSION_TOP: 0x20000000
}
export function mockWantConstant() {
const wantConstant = {
Action,
Entity,
Flags
}
return wantConstant;
}
@@ -0,0 +1,189 @@
/*
* Copyright (c) 2021-2022 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import { paramMock } from '../utils';
export function mockAccessibility() {
const AbilityTypeMock = '[PC Preview] unknown AbilityType';
const CapabilityMock = '[PC Preview] unknown Capability';
const EventTypeMock = '[PC Preview] unknown EventType';
const AccessibilityAbilityInfo = {
id: '[PC Preview] unknown id',
name: '[PC Preview] unknown name',
bundleName: '[PC Preview] unknown bundleName',
TargetBundleName: ['[PC Preview] unknown TargetBundleName'],
abilityTypes: [AbilityTypeMock],
capabilities: [CapabilityMock],
description: '[PC Preview] unknown description',
eventTypes: [EventTypeMock]
};
const CaptionsFontEdgeTypeMock = '[PC Preview] unknown CaptionsFontEdgeType';
const CaptionsFontFamilyMock = '[PC Preview] unknown CaptionsFontFamily';
const CaptionStyle = {
fontFamily: CaptionsFontFamilyMock,
fontScale: '[PC Preview] unknown fontScale',
fontColor: '[PC Preview] unknown fontColor',
fontEdgeType: CaptionsFontEdgeTypeMock,
backgroundColor: '[PC Preview] unknown backgroundColor',
windowColor: '[PC Preview] unknown windowColor'
};
const CaptionsManagerMock = {
enabled: '[PC Preview] unknown enabled',
style: CaptionStyle,
on: function (...args) {
console.warn('CaptionsManager.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 > 1 && typeof args[len - 1] === 'function') {
if (args[0] === 'enableChange') {
args[len - 1].call(this, paramMock.paramBooleanMock);
} else if (args[0] === 'styleChange') {
args[len - 1].call(this, CaptionStyle);
}
}
},
off: function (...args) {
console.warn('CaptionsManager.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 > 1 && typeof args[len - 1] === 'function') {
if (args[0] === 'enableChange') {
args[len - 1].call(this, paramMock.paramBooleanMock);
} else if (args[0] === 'styleChange') {
args[len - 1].call(this, CaptionStyle);
}
}
},
};
const WindowUpdateTypeMock = '[PC Preview] unknown WindowUpdateType';
const ActionMock = '[PC Preview] unknown Action';
const TextMoveUnitMock = '[PC Preview] unknown TextMoveUnit';
const EventInfoClass = class EventInfo {
constructor(...args) {
console.warn('accessibility.EventInfoClass.constructor interface mocked in the Previewer.' +
' How this interface works on the Previewer may be different from that on a real device.');
this.type = EventTypeMock;
this.windowUpdateType = WindowUpdateTypeMock;
this.bundleName = '[PC Preview] unknown bundleName';
this.componentType = '[PC Preview] unknown componentType';
this.pageId = '[PC Preview] unknown pageId';
this.description = '[PC Preview] unknown description';
this.triggerAction = ActionMock;
this.textMoveUnit = TextMoveUnitMock;
this.contents = ['[PC Preview] unknown content'];
this.lastContent = '[PC Preview] unknown lastContent';
this.beginIndex = '[PC Preview] unknown beginIndex';
this.currentIndex = '[PC Preview] unknown currentIndex';
this.endIndex = '[PC Preview] unknown endIndex';
this.itemCount = '[PC Preview] unknown itemCount';
}
};
const accessibility = {
EventInfo: EventInfoClass,
isOpenAccessibility: function (...args) {
console.warn('accessibility.isOpenAccessibility interface mocked in the Previewer.' +
' How this interface works on the Previewer may be different 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);
});
}
},
isOpenTouchGuide: function (...args) {
console.warn('accessibility.isOpenTouchGuide interface mocked in the Previewer.' +
' How this interface works on the Previewer may be different from that on a real device.');
const len = args.length;
if (typeof args[len - 1] === 'function') {
args[len - 1].call(this, paramMock.businessErrorMock, paramMock.paramBooleanMock);
} else {
return new Promise((resolve) => {
resolve(paramMock.paramBooleanMock);
});
}
},
on: function (...args) {
console.warn('accessibility.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] == 'accessibilityStateChange') {
args[len - 1].call(this, this, paramMock.paramBooleanMock);
} else if (args[0] == 'touchGuideStateChange') {
args[len - 1].call(this, paramMock.paramBooleanMock);
} else {
args[len - 1].call(this, this, paramMock.paramBooleanMock);
}
}
},
off: function (...args) {
console.warn('accessibility.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 > 1 && typeof args[len - 1] === 'function') {
if (args[0] === 'accessibilityStateChange') {
args[len - 1].call(this, paramMock.paramBooleanMock);
} else if (args[0] === 'touchGuideStateChange') {
args[len - 1].call(this, paramMock.paramBooleanMock);
}
}
},
getAbilityLists: function (...args) {
console.warn('accessibility.getAbilityLists interface mocked in the Previewer.' +
' How this interface works on the Previewer may be different from that on a real device.');
const len = args.length;
if (typeof args[len - 1] === 'function') {
args[len - 1].call(this, paramMock.businessErrorMock, [AccessibilityAbilityInfo]);
} else {
return new Promise((resolve, reject) => {
resolve([AccessibilityAbilityInfo]);
});
}
},
sendEvent: function (...args) {
console.warn('accessibility.sendEvent interface mocked in the Previewer.' +
' How this interface works on the Previewer may be 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();
});
}
},
getCaptionsManager: function () {
console.warn('accessibility.getCaptionsManager interface mocked in the Previewer. How this interface works on the' +
' Previewer may be different from that on a real device.');
return CaptionsManagerMock;
}
};
return accessibility;
}
@@ -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 mockAccessibilityConfig() {
const config = {
enableAbility: function (...args) {
console.warn('accessibilityConfig config.enableAbility interface mocked in the Previewer.' +
' How this interface works on the Previewer may be 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();
});
}
},
disableAbility: function (...args) {
console.warn('accessibilityConfig config.disableAbility interface mocked in the Previewer.' +
' How this interface works on the Previewer may be 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 config;
}
@@ -15,26 +15,65 @@
import { paramMock } from "../utils"
export const constraintSourceType = {
CONSTRAINT_NOT_EXIST: 0,
CONSTRAINT_TYPE_BASE: 1,
CONSTRAINT_TYPE_DEVICE_OWNER: 2,
CONSTRAINT_TYPE_PROFILE_OWNER: 3
};
export function mockOsAccount() {
const osAccountInfoMock = {
localId: "[PC Preview] unknown id",
localName: "[PC Preview] unknown name",
const OsAccountInfoMock = {
localId: "[PC Preview] unknown localId",
localName: "[PC Preview] unknown localName",
type: "[PC Preview] unknown type",
constraints: "[PC Preview] unknown constraints",
isVerified: "[PC Preview] unknown isVerified",
photo: "[PC Preview] unknown photo",
createTime: "[PC Preview] unknown createTime",
lastLoginTime: "[PC Preview] unknown lastLoginTime",
serialNumber: "[PC Preview] unknown serialNumber",
isActived: "[PC Preview] unknown isActived",
domainInfo: "[PC Preview] unknown domainInfo",
distributedInfo: "[PC Preview] unknown distributedInfo"
};
const constraintSourceTypeInfoMock = {
localId: "[PC Preview] unknown id",
type: constraintSourceType,
const DomainAccountInfoMock = {
domain: "[PC Preview] unknown domain",
accountName: "[PC Preview] unknown accountName"
};
const osAccountTypeMock = "[PC Preview] unknown type";
const accountManagerMock = {
const ConstraintSourceTypeInfoMock = {
localId: "[PC Preview] unknown localId",
type: "[PC Preview] unknown type"
};
const GetPropertyRequest = {
authType: "[PC Preview] unknown authType",
keys: "[PC Preview] unknown keys"
};
const SetPropertyRequest = {
authType: "[PC Preview] unknown authType",
key: "[PC Preview] unknown key",
setInfo: "[PC Preview] unknown setInfo"
};
const ExecutorProperty = {
result: "[PC Preview] unknown result",
authSubType: AuthSubType,
remainTimes: "[PC Preview] unknown remainTimes",
freezingTime: "[PC Preview] unknown freezingTime"
};
const AuthResult = {
token: "[PC Preview] unknown token",
remainTimes: "[PC Preview] unknown remainTimes",
ferezingTime: "[PC Preview] unknown freezingTime"
};
const CredentialInfo = {
credType: "[PC Preview] unknown credType",
credSubType: "[PC Preview] unknown credSubType",
token: "[PC Preview] unknown token"
};
const RequestResult = {
credentialId: "[PC Preview] unknown credentialId"
};
const EnrolledCredInfo = {
credentialId: "[PC Preview] unknown credentialId",
authType: "[PC Preview] unknown authType",
authSubType: "[PC Preview] unknown authSubType",
templateId: "[PC Preview] unknown templateId"
};
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.")
@@ -219,7 +258,7 @@ export function mockOsAccount() {
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);
osAccountInfoArrayMock.push(OsAccountInfoMock);
const len = args.length
if (len > 0 && typeof args[len - 1] === 'function') {
args[len - 1].call(this, paramMock.businessErrorMock, osAccountInfoArrayMock);
@@ -233,7 +272,7 @@ export function mockOsAccount() {
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);
osAccountIdsArrayMock.push(OsAccountInfoMock);
const len = args.length
if (len > 0 && typeof args[len - 1] === 'function') {
args[len - 1].call(this, paramMock.businessErrorMock, osAccountIdsArrayMock);
@@ -248,10 +287,10 @@ export function mockOsAccount() {
"How this interface works on the Previewer may be different from 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);
args[len - 1].call(this, paramMock.businessErrorMock, OsAccountInfoMock);
} else {
return new Promise((resolve, reject) => {
resolve(osAccountInfoMock);
resolve(OsAccountInfoMock);
})
}
},
@@ -260,10 +299,10 @@ export function mockOsAccount() {
"How this interface works on the Previewer may be different from 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);
args[len - 1].call(this, paramMock.businessErrorMock, OsAccountInfoMock);
} else {
return new Promise((resolve, reject) => {
resolve(osAccountInfoMock);
resolve(OsAccountInfoMock);
})
}
},
@@ -272,10 +311,10 @@ export function mockOsAccount() {
"How this interface works on the Previewer may be different from 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);
args[len - 1].call(this, paramMock.businessErrorMock, OsAccountInfoMock);
} else {
return new Promise((resolve, reject) => {
resolve(osAccountInfoMock);
resolve(OsAccountInfoMock);
})
}
},
@@ -284,10 +323,10 @@ export function mockOsAccount() {
"How this interface works on the Previewer may be different from 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);
args[len - 1].call(this, paramMock.businessErrorMock, OsAccountInfoMock);
} else {
return new Promise((resolve, reject) => {
resolve(osAccountInfoMock);
resolve(OsAccountInfoMock);
})
}
},
@@ -296,10 +335,10 @@ export function mockOsAccount() {
"How this interface works on the Previewer may be different from 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);
args[len - 1].call(this, paramMock.businessErrorMock, OsAccountTypeMock);
} else {
return new Promise((resolve, reject) => {
resolve(osAccountTypeMock);
resolve(OsAccountTypeMock);
})
}
},
@@ -415,7 +454,7 @@ export function mockOsAccount() {
console.warn("AccountManager.queryOsAccountConstraintSourceTypes interface mocked in the Previewer. " +
"How this interface works on the Previewer may be different from that on a real device.")
var constraintSourceTypeInfoArrayMock = new Array();
constraintSourceTypeInfoArrayMock.push(constraintSourceTypeInfoMock);
constraintSourceTypeInfoArrayMock.push(ConstraintSourceTypeInfoMock);
const len = args.length
if (len > 0 && typeof args[len - 1] === 'function') {
args[len - 1].call(this, paramMock.businessErrorMock, constraintSourceTypeInfoArrayMock);
@@ -426,18 +465,278 @@ export function mockOsAccount() {
}
},
};
const UserAuthClass = class UserAuth {
constructor() {
console.warn("osAccount.UserAuth.constructor interface mocked in the Previewer. " +
"How this interface works on the Previewer may be different from that on a real device.")
this.getVersion = function (...args) {
console.warn("UserAuth.getVersion interface mocked in the Previewer. " +
"How this interface works on the Previewer may be different from that on a real device.")
return paramMock.paramNumberMock;
};
this.getAvailableStatus = function (...args) {
console.warn("UserAuth.getAvailableStatus interface mocked in the Previewer. " +
"How this interface works on the Previewer may be different from that on a real device.")
return paramMock.paramNumberMock;
};
this.getProperty = function (...args) {
console.warn("UserAuth.getProperty interface mocked in the Previewer. " +
"How this interface works on the Previewer may be different from that on a real device.")
const len = args.length
if (len > 0 && typeof args[len - 1] === 'function') {
args[len - 1].call(this, paramMock.businessErrorMock, ExecutorProperty);
} else {
return new Promise((resolve, reject) => {
resolve(ExecutorProperty);
})
}
};
this.setProperty = function (...args) {
console.warn("UserAuth.setProperty interface mocked in the Previewer. " +
"How this interface works on the Previewer may be different from 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);
})
}
};
this.auth = function (...args) {
console.warn("UserAuth.auth interface mocked in the Previewer. " +
"How this interface works on the Previewer may be different from 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.paramArrayMock);
}
};
this.anthUser = function (...args) {
console.warn("UserAuth.anthUser interface mocked in the Previewer. " +
"How this interface works on the Previewer may be different from 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.paramArrayMock);
}
};
this.cancelAuth = function (...args) {
console.warn("UserAuth.cancelAuth interface mocked in the Previewer. " +
"How this interface works on the Previewer may be different from that on a real device.")
return paramMock.paramNumberMock;
};
};
};
const PINAuthClass = class PINAuth {
constructor() {
console.warn("osAccount.PINA.constructor interface mocked in the Previewer. " +
"How this interface works on the Previewer may be different from that on a real device.")
this.registerInputer = function (...args) {
console.warn("PINAuth.registerInputer interface mocked in the Previewer. " +
"How this interface works on the Previewer may be different from that on a real device.")
return paramMock.paramBooleanMock;
};
this.unregisterInputer = function (...args) {
console.warn("PINAuth.unregisterInputer interface mocked in the Previewer. " +
"How this interface works on the Previewer may be different from that on a real device.")
};
};
};
const UserIdentityManagerClass = class UserIdentityManager {
constructor() {
console.warn("osAccount.getAccountManager.constructor interface mocked in the Previewer. " +
"How this interface works on the Previewer may be different from that on a real device.")
this.openSession = function (...args) {
console.warn("UserIdentityManager.openSession interface mocked in the Previewer. " +
"How this interface works on the Previewer may be different from 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.paramArrayMock);
} else {
return new Promise((resolve, reject) => {
resolve(paramMock.paramArrayMock);
})
}
};
this.addCredential = function (...args) {
console.warn("AUserIdentityManager.addCredential interface mocked in the Previewer. " +
"How this interface works on the Previewer may be different from that on a real device.")
const len = args.length
if (len > 0 && typeof args[len - 1] === 'function') {
args[len - 1].call(this, paramMock.businessErrorMock, IIdmCallback);
}
};
this.updateCredential = function (...args) {
console.warn("AUserIdentityManager.updateCredential interface mocked in the Previewer. " +
"How this interface works on the Previewer may be different from that on a real device.")
const len = args.length
if (len > 0 && typeof args[len - 1] === 'function') {
args[len - 1].call(this, paramMock.businessErrorMock, IIdmCallback);
}
};
this.closeSession = function (...args) {
console.warn("AUserIdentityManager.closeSession interface mocked in the Previewer. " +
"How this interface works on the Previewer may be different from that on a real device.")
};
this.cancel = function (...args) {
console.warn("AUserIdentityManager.cancel interface mocked in the Previewer. " +
"How this interface works on the Previewer may be different from that on a real device.")
return paramMock.paramNumberMock;
};
this.delUser = function (...args) {
console.warn("AUserIdentityManager.delUser interface mocked in the Previewer. " +
"How this interface works on the Previewer may be different from that on a real device.")
const len = args.length
if (len > 0 && typeof args[len - 1] === 'function') {
args[len - 1].call(this, paramMock.businessErrorMock, IIdmCallback);
}
};
this.delCred = function (...args) {
console.warn("AUserIdentityManager.delCred interface mocked in the Previewer. " +
"How this interface works on the Previewer may be different from that on a real device.")
const len = args.length
if (len > 0 && typeof args[len - 1] === 'function') {
args[len - 1].call(this, paramMock.businessErrorMock, IIdmCallback);
}
};
this.getAuthInfo = function (...args) {
console.warn("AUserIdentityManager.getAuthInfo interface mocked in the Previewer. " +
"How this interface works on the Previewer may be different from 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(EnrolledCredInfo));
} else {
return new Promise((resolve, reject) => {
resolve(new Array(EnrolledCredInfo))
})
}
};
};
}
const IInputData = {
onSetData: function (...args) {
console.warn("IInputData.onSetData interface mocked in the Previewer. " +
"How this interface works on the Previewer may be different from that on a real device.")
},
};
const IInputer = {
onSetData: function (...args) {
console.warn("IInputer.onSetData interface mocked in the Previewer. " +
"How this interface works on the Previewer may be different from that on a real device.")
},
};
const IUserAuthCallback = {
onResult: function (...args) {
console.warn("IUserAuthCallback.onResult interface mocked in the Previewer. " +
"How this interface works on the Previewer may be different from that on a real device.")
},
onAcquireInfo: function (...args) {
console.warn("IUserAuthCallback.onAcquireInfo interface mocked in the Previewer. " +
"How this interface works on the Previewer may be different from that on a real device.")
},
};
const IIdmCallback = {
onResult: function (...args) {
console.warn("IIdmCallback.onResult interface mocked in the Previewer. " +
"How this interface works on the Previewer may be different from that on a real device.")
},
onAcquireInfo: function (...args) {
console.warn("IIdmCallback.onAcquireInfo interface mocked in the Previewer. " +
"How this interface works on the Previewer may be different from that on a real device.")
},
};
const ConstraintSourceType = {
CONSTRAINT_NOT_EXIST: 0,
CONSTRAINT_TYPE_BASE: 1,
CONSTRAINT_TYPE_DEVICE_OWNER: 2,
CONSTRAINT_TYPE_PROFILE_OWNER: 3
};
const OsAccountType = {
ADMIN: 0,
NORMAL: 1,
GUEST: 2
};
const FingerprintTips = {
FINGERPRINT_TIP_GOOD: 0,
FINGERPRINT_TIP_IMAGER_DIRTY: 1,
FINGERPRINT_TIP_INSUFFICIENT: 2,
FINGERPRINT_TIP_PARTIAL: 3,
FINGERPRINT_TIP_TOO_FAST: 4,
FINGERPRINT_TIP_TOO_SLOW: 5
};
const FaceTipsCode = {
FACE_AUTH_TIP_TOO_BRIGHT: 1,
FACE_AUTH_TIP_TOO_DARK: 2,
FACE_AUTH_TIP_TOO_CLOSE: 3,
FACE_AUTH_TIP_TOO_FAR: 4,
FACE_AUTH_TIP_TOO_HIGH: 5,
FACE_AUTH_TIP_TOO_LOW: 6,
FACE_AUTH_TIP_TOO_RIGHT: 7,
FACE_AUTH_TIP_TOO_LEFT: 8,
FACE_AUTH_TIP_TOO_MUCH_MOTION: 9,
FACE_AUTH_TIP_POOR_GAZE: 10,
FACE_AUTH_TIP_NOT_DETECTED: 11
};
const ResultCode = {
SUCCESS: 0,
FAIL: 1,
GENERAL_ERROR: 2,
CANCELED: 3,
TIMEOUT: 4,
TYPE_NOT_SUPPORT: 5,
TRUST_LEVEL_NOT_SUPPORT: 6,
BUSY: 7,
INVALID_PARAMETERS: 8,
LOCKED: 9,
NOT_ENROLLED: 10
};
const Module = {
FACE_AUTH: 1
};
const AuthTrustLevel = {
ATL1: 10000,
ATL2: 20000,
ATL3: 30000,
ATL4: 40000
};
const AuthSubType = {
PIN_SIX: 10000,
PIN_NUMBER: 10001,
PIN_MIXED: 10002,
FACE_2D: 20000,
FACE_3D: 20001
};
const GetPropertyType = {
AUTH_SUB_TYPE: 1,
REMAIN_TIMES: 2,
FREEZING_TIME: 3
};
const SetPropertyType = {
INIT_ALGORITHM: 1
};
const AuthType = {
PIN: 1,
FACE: 2
};
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;
return AccountManagerMock;
},
OsAccountType: {
ADMIN: "[PC Preview] unknown ADMIN",
NORMAL: "[PC Preview] unknown NORMAL",
GUEST: "[PC Preview] unknown GUEST"
},
constraintSourceType,
UserAuth: UserAuthClass,
PINAuth: PINAuthClass,
UserIdentityManager: UserIdentityManagerClass,
ConstraintSourceType,
OsAccountType,
FingerprintTips,
FaceTipsCode,
ResultCode,
Module,
AuthTrustLevel,
AuthSubType,
GetPropertyType,
SetPropertyType,
AuthType,
}
return osAccount
}
}
@@ -0,0 +1,79 @@
/*
* 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 mockWindowAnimationManager() {
const RRect = {
left: '[PC preview] unknow left',
top: '[PC preview] unknow top',
width: '[PC preview] unknow width',
height: '[PC preview] unknow height',
radius: '[PC preview] unknow radius',
}
const WindowAnimationTarget = {
bundleName: '[PC preview] unknow bundleName',
abilityName: '[PC preview] unknow abilityName',
windowBounds: RRect,
}
const WindowAnimationFinishedCallback = {
onAnimationFinish: function (...args) {
console.warn("WindowAnimationFinishedCallback.onAnimationFinish interface mocked in the Previewer. How this interface works on the" +
" Previewer may be different from that on a real device.")
},
}
const WindowAnimationController = {
onStartAppFromLauncher: function (...args) {
console.warn("WindowAnimationController.onStartAppFromLauncher interface mocked in the Previewer. How this interface works on the" +
" Previewer may be different from that on a real device.")
},
onStartAppFromRecent: function (...args) {
console.warn("WindowAnimationController.onStartAppFromRecent interface mocked in the Previewer. How this interface works on the" +
" Previewer may be different from that on a real device.")
},
onStartAppFromOther: function (...args) {
console.warn("WindowAnimationController.onStartAppFromOther interface mocked in the Previewer. How this interface works on the" +
" Previewer may be different from that on a real device.")
},
onAppTransition: function (...args) {
console.warn("WindowAnimationController.onAppTransition interface mocked in the Previewer. How this interface works on the" +
" Previewer may be different from that on a real device.")
},
onMinimizeWindow: function (...args) {
console.warn("WindowAnimationController.onMinimizeWindow interface mocked in the Previewer. How this interface works on the" +
" Previewer may be different from that on a real device.")
},
onCloseWindow: function (...args) {
console.warn("WindowAnimationController.onCloseWindow interface mocked in the Previewer. How this interface works on the" +
" Previewer may be different from that on a real device.")
},
onScreenUnlock: function (...args) {
console.warn("WindowAnimationController.onScreenUnlock interface mocked in the Previewer. How this interface works on the" +
" Previewer may be different from that on a real device.")
},
}
const windowAnimationManager = {
WindowAnimationController,
WindowAnimationFinishedCallback,
WindowAnimationTarget,
RRect,
setController: function (...args) {
console.warn("windowAnimationManager.setController interface mocked in the Previewer. How this interface works on the" +
" Previewer may be different from that on a real device.")
}
}
return windowAnimationManager
}
@@ -32,4 +32,13 @@ export const OnContinueResult = {
AGREE: 0,
REJECT: 1,
MISMATCH: 2,
}
export function mockAbilityConstant() {
const AbilityConstant = {
LaunchParam,
LaunchReason,
LastExitReason,
OnContinueResult
}
return AbilityConstant;
}
@@ -13,8 +13,6 @@
* limitations under the License.
*/
import { paramMock } from "../utils"
export function mockAbilityLifecycleCallback() {
const AbilityLifecycleCallbackClass = class AbilityLifecycleCallback {
constructor() {
@@ -13,7 +13,7 @@
* limitations under the License.
*/
import { abilityStageContextClass } from "./application/AbilityContext"
import { AbilityStageContextClass } from "./application/AbilityStageContext"
import { paramMock } from "../utils"
export function mockAbilityStage() {
@@ -21,7 +21,7 @@ export function mockAbilityStage() {
constructor() {
console.warn('application.AbilityStage.constructor interface mocked in the Previewer. How this interface works on' +
' the Previewer may be different from that on a real device.');
this.context = new abilityStageContextClass();
this.context = new AbilityStageContextClass();
this.onCreate = function () {
console.warn("application.AbilityStage.onCreate interface mocked in the Previewer. How this interface works on the Previewer" +
" may be different from that on a real device.")
@@ -0,0 +1,62 @@
/*
* Copyright (c) 2022 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import { paramMock } from '../utils';
import { AccessibilityExtensionContext } from './application/AccessibilityExtensionContext';
const AccessibilityEvent = {
eventType: '[PC Preview] unknown eventType',
target: '[PC Preview] unknown target',
timeStamp: '[PC Preview] unknown timeStamp'
};
const GesturePoint = {
positionX: '[PC Preview] unknown positionX',
positionY: '[PC Preview] unknown positionY'
};
const GesturePath = {
points: [GesturePoint],
durationTime: '[PC Preview] unknown durationTime'
};
export function mockAccessibilityExtensionAbility() {
const AccessibilityExtensionAbilityClass = class AccessibilityExtensionAbility {
constructor() {
console.warn('accessibilityExtensionAbility.constructor interface mocked in the Previewer.' +
' How this interface works on the Previewer may be different from that on a real device.');
this.context = new AccessibilityExtensionContext();
this.onConnect = function (...args) {
console.warn('accessibilityExtensionAbility.onConnect interface mocked in the Previewer.' +
' How this interface works on the Previewer may be different from that on a real device.');
};
this.onDisconnect = function (...args) {
console.warn('accessibilityExtensionAbility.onDisconnect interface mocked in the Previewer.' +
' How this interface works on the Previewer may be different from that on a real device.');
};
this.onAccessibilityEvent = function (...args) {
console.warn('accessibilityExtensionAbility.onAccessibilityEvent interface mocked in the Previewer.' +
' How this interface works on the Previewer may be different from that on a real device.');
};
this.onKeyEvent = function (...args) {
console.warn('accessibilityExtensionAbility.onKeyEvent interface mocked in the Previewer.' +
' How this interface works on the Previewer may be different from that on a real device.');
return paramMock.paramBooleanMock;
};
}
};
return AccessibilityExtensionAbilityClass;
}
@@ -19,4 +19,8 @@ export const Configuration = {
direction: Direction,
screenDensity: ScreenDensity,
displayId: '[PC preview] unknow displayId',
hasPointerDevice: '[PC preview] unknow hasPointerDevice',
}
export function mockConfiguration() {
return Configuration;
}
@@ -30,4 +30,12 @@ export const ScreenDensity = {
SCREEN_DENSITY_XLDPI: 320,
SCREEN_DENSITY_XXLDPI: 480,
SCREEN_DENSITY_XXXLDPI: 640,
}
export function mockConfigurationConstant() {
const ConfigurationConstant = {
ColorMode,
Direction,
ScreenDensity
}
return ConfigurationConstant;
}
@@ -14,8 +14,7 @@
*/
import { paramMock } from "../utils"
import { ExtensionContextClass } from "./application/AbilityContext"
import { DataShareResultSetMock } from "./ohos_data_DataShareResultSet"
import { ExtensionContextClass } from "./application/ExtensionContext"
export function mockDataShareExtensionAbility() {
const DataShareExtensionAbilityClass = class DataShareExtensionAbility {
@@ -0,0 +1,29 @@
/*
* Copyright (c) 2022 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
export const EnvironmentCallbackClass = class EnvironmentCallback {
constructor() {
console.warn('EnvironmentCallback.constructor interface mocked in the Previewer. How this interface works on' +
' the Previewer may be different from that on a real device.');
this.onConfigurationUpdated = function (...args) {
console.warn("EnvironmentCallback.onConfigurationUpdated interface mocked in the Previewer. How this interface works on the Previewer" +
" may be different from that on a real device.")
};
}
}
export function mockEnvironmentCallback() {
return new EnvironmentCallbackClass();
}
@@ -13,54 +13,20 @@
* limitations under the License.
*/
import { paramMock } from "../utils"
import { ExtensionContextClass } from "./application/AbilityContext"
import { FormState } from "./ohos_application_formInfo"
import { FormExtensionContextClass as FormExtensionContext } from "./application/FormExtensionContext"
import { FormBindingData } from "./ohos_application_formBindingData"
export function mockFormExtension() {
const formBindingDataMock = {
data: paramMock.paramObjectMock
}
const formExtensionContextClass = class formExtensionContext extends ExtensionContextClass {
constructor() {
super();
console.warn('formExtension.formExtensionContext.constructor interface mocked in the Previewer. How this interface works on' +
' the Previewer may be different from that on a real device.');
this.updateForm = function (...args) {
console.warn("formExtension.formExtensionContext.updateForm interface mocked in the Previewer." +
" How this interface works on the Previewer may be different from that on a real device.")
const len = args.length
if (len > 0 && typeof args[len - 1] === 'function') {
args[len - 1].call(this, paramMock.businessErrorMock);
} else {
return new Promise((resolve, reject) => {
resolve();
})
}
};
this.startAbility = function (...args) {
console.warn("formExtension.formExtensionContext.startAbility interface mocked in the Previewer." +
" How this interface works on the Previewer may be different from that on a real device.");
const len = args.length;
if (len > 0 && typeof args[len - 1] === 'function') {
args[len - 1].call(this, paramMock.businessErrorMock);
} else {
return new Promise((resolve, reject) => {
resolve();
})
}
};
}
}
const formExtensionClass = class formExtension {
constructor() {
console.warn('application.formExtension.constructor interface mocked in the Previewer. How this interface works on' +
' the Previewer may be different from that on a real device.');
this.context = new formExtensionContextClass();
this.context = new FormExtensionContext();
this.onCreate = function (...args) {
console.warn("application.formExtension.onCreate interface mocked in the Previewer. How this interface works on the Previewer" +
" may be different from that on a real device.")
return formBindingDataMock
return FormBindingData
};
this.onCastToNormal = function (...args) {
console.warn("application.formExtension.onCastToNormal interface mocked in the Previewer. How this interface works on the Previewer" +
@@ -1,224 +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"
import { RemoteObjectClass } from "./ohos_application_ServiceExtensionAbility"
const ApplicationInfoMock = {
name: '[PC preview] unknow name',
description: '[PC preview] unknow description',
descriptionId: '[PC preview] unknow descriptionId',
systemApp: '[PC preview] unknow systemApp',
enabled: '[PC preview] unknow enabled',
label: '[PC preview] unknow label',
labelId: '[PC preview] unknow labelId',
icon: '[PC preview] unknow icon',
iconId: '[PC preview] unknow iconId',
process: '[PC preview] unknow process',
supportedModes: '[PC preview] unknow supportedModes',
moduleSourceDirs: [paramMock.paramStringMock],
permissions: [paramMock.paramStringMock],
entryDir: '[PC preview] unknow entryDir',
codePath: '[PC preview] unknow codePath',
removable: '[PC preview] unknow removable',
accessTokenId: '[PC preview] unknow accessTokenId',
uid: '[PC preview] unknow uid',
entityType: '[PC preview] unknow entityType'
}
const EventHubClass = class EventHub {
constructor() {
console.warn('EventHub.constructor interface mocked in the Previewer. How this interface works on' +
' the Previewer may be different from that on a real device.');
this.on = function (...args) {
console.warn("EventHub.on interface mocked in the Previewer. How this interface works on the Previewer" +
" may be different from that on a real device.")
};
this.off = function (...args) {
console.warn("EventHub.off interface mocked in the Previewer. How this interface works on the Previewer" +
" may be different from that on a real device.")
};
this.emit = function (...args) {
console.warn("EventHub.emit interface mocked in the Previewer. How this interface works on the Previewer" +
" may be different from that on a real device.")
};
}
}
const BaseContextClass = class BaseContext {
constructor() {
console.warn('BaseContext.constructor interface mocked in the Previewer. How this interface works on' +
' the Previewer may be different from that on a real device.');
this.stageMode = "[PC Preview] unknow stageMode";
}
}
export const ContextClass = class Context extends BaseContextClass {
constructor() {
super();
console.warn('Context.constructor interface mocked in the Previewer. How this interface works on' +
' the Previewer may be different from that on a real device.');
this.applicationInfo = ApplicationInfoMock;
this.cacheDir = "[PC Preview] unknow cacheDir";
this.tempDir = "[PC Preview] unknow tempDir";
this.filesDir = "[PC Preview] unknow filesDir";
this.databaseDir = "[PC Preview] unknow databaseDir";
this.storageDir = "[PC Preview] unknow storageDir";
this.bundleCodeDir = "[PC Preview] unknow bundleCodeDir";
this.distributedFilesDir = "[PC Preview] unknow distributedFilesDir";
this.eventHub = new EventHubClass();
this.createBundleContext = function (...args) {
console.warn("Context.createBundleContext interface mocked in the Previewer. How this interface works on the Previewer" +
" may be different from that on a real device.")
return new ContextClass();
};
this.createModuleContext = function (...args) {
console.warn("Context.createModuleContext interface mocked in the Previewer. How this interface works on the Previewer" +
" may be different from that on a real device.")
return new ContextClass();
};
this.getApplicationContext = function () {
console.warn("Context.getApplicationContext interface mocked in the Previewer. How this interface works on the Previewer" +
" may be different from that on a real device.")
return new ContextClass();
};
this.switchArea = function (...args) {
console.warn("Context.switchArea interface mocked in the Previewer. How this interface works on the Previewer" +
" may be different from that on a real device.")
};
}
}
export function mockServiceExtAbility() {
const HapModuleInfoMock = {
name: '[PC preview] unknow name',
description: '[PC preview] unknow description',
descriptionId: '[PC preview] unknow descriptionId',
icon: '[PC preview] unknow icon',
label: '[PC preview] unknow label',
labelId: '[PC preview] unknow labelId',
iconId: '[PC preview] unknow iconId',
backgroundImg: '[PC preview] unknow backgroundImg',
supportedModes: '[PC preview] unknow supportedModes',
reqCapabilities: [paramMock.paramStringMock],
deviceTypes: [paramMock.paramStringMock],
moduleName: '[PC preview] unknow moduleName',
mainAbilityName: '[PC preview] unknow mainAbilityName',
installationFree: '[PC preview] unknow installationFree',
mainElementName: '[PC preview] unknow mainElementName',
}
const ExtAbilityContextClass = class ExtAbilityContext extends ContextClass {
constructor() {
super();
console.warn('ExtAbilityContext.constructor interface mocked in the Previewer. How this interface works on' +
' the Previewer may be different from that on a real device.');
this.currentHapModuleInfo = HapModuleInfoMock;
}
}
const ServiceExtAbilityContextClass = class ServiceExtAbilityContext extends ExtAbilityContextClass {
constructor() {
super();
console.warn('ServiceExtAbilityContext.constructor interface mocked in the Previewer. How this interface works on' +
' the Previewer may be different from that on a real device.');
this.startAbility = function (...args) {
console.warn("ServiceExtAbilityContext.startAbility interface mocked in the Previewer." +
" How this interface works on the Previewer may be different from that on a real device.")
const len = args.length
if (len > 0 && typeof args[len - 1] === 'function') {
args[len - 1].call(this, paramMock.businessErrorMock);
} else {
return new Promise((resolve, reject) => {
resolve();
})
}
};
this.startAbilityWithAccount = function (...args) {
console.warn("ServiceExtAbilityContext.startAbilityWithAccount interface mocked in the Previewer." +
" How this interface works on the Previewer may be different from that on a real device.")
const len = args.length
if (len > 0 && typeof args[len - 1] === 'function') {
args[len - 1].call(this, paramMock.businessErrorMock);
} else {
return new Promise((resolve, reject) => {
resolve();
})
}
};
this.terminateSelf = function (...args) {
console.warn("ServiceExtAbilityContext.terminateSelf interface mocked in the Previewer." +
" How this interface works on the Previewer may be different from that on a real device.")
const len = args.length
if (len > 0 && typeof args[len - 1] === 'function') {
args[len - 1].call(this, paramMock.businessErrorMock);
} else {
return new Promise((resolve, reject) => {
resolve();
})
}
};
this.connectAbility = function (...args) {
console.warn("ServiceExtAbilityContext.connectAbility interface mocked in the Previewer. How this interface works on the Previewer" +
" may be different from that on a real device.")
return paramMock.paramNumberMock;
};
this.connectAbilityWithAccount = function (...args) {
console.warn("ServiceExtAbilityContext.connectAbilityWithAccount interface mocked in the Previewer. How this interface works on the Previewer" +
" may be different from that on a real device.")
return paramMock.paramNumberMock;
};
this.disconnectAbility = function (...args) {
console.warn("ServiceExtAbilityContext.disconnectAbility interface mocked in the Previewer." +
" How this interface works on the Previewer may be different from that on a real device.")
const len = args.length
if (len > 0 && typeof args[len - 1] === 'function') {
args[len - 1].call(this, paramMock.businessErrorMock);
} else {
return new Promise((resolve, reject) => {
resolve();
})
}
};
}
}
const ServiceExtAbilityClass = class ServiceExtAbility {
constructor() {
console.warn('application.ServiceExtAbility.constructor interface mocked in the Previewer. How this interface works on' +
' the Previewer may be different from that on a real device.');
this.context = new ServiceExtAbilityContextClass();
this.onCreate = function (...args) {
console.warn("ServiceExtAbility.onCreate interface mocked in the Previewer. How this interface works on the Previewer" +
" may be different from that on a real device.")
};
this.onDestroy = function () {
console.warn("ServiceExtAbility.onDestroy interface mocked in the Previewer. How this interface works on the Previewer" +
" may be different from that on a real device.")
};
this.onRequest = function (...args) {
console.warn("ServiceExtAbility.onRequest interface mocked in the Previewer. How this interface works on the Previewer" +
" may be different from that on a real device.")
};
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();
};
this.onDisconnect = function (...args) {
console.warn("ServiceExtAbility.onDisconnect interface mocked in the Previewer. How this interface works on the Previewer" +
" may be different from that on a real device.")
};
this.onReconnect = function (...args) {
console.warn("ServiceExtAbility.onReconnect interface mocked in the Previewer. How this interface works on the Previewer" +
" may be different from that on a real device.")
};
}
}
return new ServiceExtAbilityClass();
}
@@ -14,194 +14,15 @@
*/
import { paramMock } from "../utils"
import { ExtensionContextClass } from "./application/AbilityContext"
import { ServiceExtensionContextClass } from "./application/ServiceExtensionContext"
import { RemoteObjectClass } from "./ohos_rpc"
export const RemoteObjectClass = class RemoteObject {
constructor() {
console.warn('RemoteObject.constructor interface mocked in the Previewer. How this interface works on' +
' the Previewer may be different from that on a real device.');
this.queryLocalInterface = function () {
console.warn("RemoteObject.queryLocalInterface interface mocked in the Previewer. How this interface works on the Previewer" +
" may be different from that on a real device.")
return IRemoteBrokerMock;
};
this.sendRequest = function (...args) {
console.warn("RemoteObject.sendRequest interface mocked in the Previewer." +
" How this interface works on the Previewer may be different from that on a real device.")
return new Promise((resolve, reject) => {
resolve();
})
};
this.addDeathRecipient = function () {
console.warn("RemoteObject.addDeathRecipient interface mocked in the Previewer. How this interface works on the Previewer" +
" may be different from that on a real device.")
return paramMock.paramBooleanMock;
};
this.removeDeathRecipient = function () {
console.warn("RemoteObject.removeDeathRecipient interface mocked in the Previewer. How this interface works on the Previewer" +
" may be different from that on a real device.")
return paramMock.paramBooleanMock;
};
this.getInterfaceDescriptor = function () {
console.warn("RemoteObject.getInterfaceDescriptor interface mocked in the Previewer. How this interface works on the Previewer" +
" may be different from that on a real device.")
return paramMock.paramStringMock;
};
this.isObjectDead = function () {
console.warn("RemoteObject.isObjectDead interface mocked in the Previewer. How this interface works on the Previewer" +
" may be different from that on a real device.")
return paramMock.paramBooleanMock;
};
this.queryLocalInterface = function (...args) {
console.warn("RemoteObject.queryLocalInterface interface mocked in the Previewer. How this interface works on the Previewer" +
" may be different from that on a real device.")
return IRemoteObjectMock
};
this.getInterfaceDescriptor = function () {
console.warn("RemoteObject.getInterfaceDescriptor interface mocked in the Previewer. How this interface works on the Previewer" +
" may be different from that on a real device.")
return paramMock.paramStringMock
};
this.onRemoteRequest = function (...args) {
console.warn("RemoteObject.onRemoteRequest interface mocked in the Previewer. How this interface works on the Previewer" +
" may be different from that on a real device.")
return paramMock.paramBooleanMock
};
this.sendRequest = function (...args) {
console.warn("RemoteObject.sendRequest interface mocked in the Previewer." +
" How this interface works on the Previewer may be different from that on a real device.")
return new Promise((resolve, reject) => {
resolve();
})
};
this.getCallingPid = function () {
console.warn("RemoteObject.getCallingPid interface mocked in the Previewer. How this interface works on the Previewer" +
" may be different from that on a real device.")
return paramMock.paramNumberMock
};
this.getCallingUid = function () {
console.warn("RemoteObject.getCallingUid interface mocked in the Previewer. How this interface works on the Previewer" +
" may be different from that on a real device.")
return paramMock.paramNumberMock
};
this.attachLocalInterface = function (...args) {
console.warn("RemoteObject.attachLocalInterface interface mocked in the Previewer. How this interface works on the Previewer" +
" may be different from that on a real device.")
};
}
}
export function mockServiceExtensionAbility() {
const IRemoteBrokerMock = {
asObject: function () {
console.warn("IRemoteBroker.asObject interface mocked in the Previewer. How this interface works on the Previewer" +
" may be different from that on a real device.")
return IRemoteObjectMock;
},
}
const IRemoteObjectMock = {
queryLocalInterface: function () {
console.warn("IRemoteObject.queryLocalInterface interface mocked in the Previewer. How this interface works on the Previewer" +
" may be different from that on a real device.")
return IRemoteBrokerMock;
},
sendRequest: function (...args) {
console.warn("IRemoteObject.sendRequest interface mocked in the Previewer." +
" How this interface works on the Previewer may be different from that on a real device.")
return new Promise((resolve, reject) => {
resolve();
})
},
addDeathRecipient: function () {
console.warn("IRemoteObject.addDeathRecipient interface mocked in the Previewer. How this interface works on the Previewer" +
" may be different from that on a real device.")
return paramMock.paramBooleanMock;
},
removeDeathRecipient: function () {
console.warn("IRemoteObject.removeDeathRecipient interface mocked in the Previewer. How this interface works on the Previewer" +
" may be different from that on a real device.")
return paramMock.paramBooleanMock;
},
getInterfaceDescriptor: function () {
console.warn("IRemoteObject.getInterfaceDescriptor interface mocked in the Previewer. How this interface works on the Previewer" +
" may be different from that on a real device.")
return paramMock.paramStringMock;
},
isObjectDead: function () {
console.warn("IRemoteObject.isObjectDead interface mocked in the Previewer. How this interface works on the Previewer" +
" may be different from that on a real device.")
return paramMock.paramBooleanMock;
}
}
const serviceExtensionContextClass = class serviceExtensionContext extends ExtensionContextClass {
constructor() {
super();
console.warn('ServiceExtensionAbility.serviceExtensionContext.constructor interface mocked in the Previewer. How this interface works on' +
' the Previewer may be different from that on a real device.');
this.startAbility = function (...args) {
console.warn("ServiceExtensionAbility.serviceExtensionContext.startAbility interface mocked in the Previewer." +
" How this interface works on the Previewer may be different from that on a real device.")
const len = args.length
if (len > 0 && typeof args[len - 1] === 'function') {
args[len - 1].call(this, paramMock.businessErrorMock);
} else {
return new Promise((resolve, reject) => {
resolve();
})
}
};
this.startAbilityWithAccount = function (...args) {
console.warn("ServiceExtensionAbility.serviceExtensionContext.startAbilityWithAccount interface mocked in the Previewer." +
" How this interface works on the Previewer may be different from that on a real device.")
const len = args.length
if (len > 0 && typeof args[len - 1] === 'function') {
args[len - 1].call(this, paramMock.businessErrorMock);
} else {
return new Promise((resolve, reject) => {
resolve();
})
}
};
this.terminateSelf = function (...args) {
console.warn("ServiceExtensionAbility.serviceExtensionContext.terminateSelf interface mocked in the Previewer." +
" How this interface works on the Previewer may be different from that on a real device.")
const len = args.length
if (len > 0 && typeof args[len - 1] === 'function') {
args[len - 1].call(this, paramMock.businessErrorMock);
} else {
return new Promise((resolve, reject) => {
resolve();
})
}
};
this.connectAbility = function (...args) {
console.warn("ServiceExtensionAbility.serviceExtensionContext.connectAbility interface mocked in the Previewer. How this interface works on the Previewer" +
" may be different from that on a real device.")
return paramMock.paramNumberMock
};
this.connectAbilityWithAccount = function (...args) {
console.warn("ServiceExtensionAbility.serviceExtensionContext.connectAbilityWithAccount interface mocked in the Previewer. How this interface works on the Previewer" +
" may be different from that on a real device.")
return paramMock.paramNumberMock
};
this.disconnectAbility = function (...args) {
console.warn("ServiceExtensionAbility.serviceExtensionContext.disconnectAbility interface mocked in the Previewer." +
" How this interface works on the Previewer may be different from that on a real device.")
const len = args.length
if (len > 0 && typeof args[len - 1] === 'function') {
args[len - 1].call(this, paramMock.businessErrorMock);
} else {
return new Promise((resolve, reject) => {
resolve();
})
}
}
}
}
const ServiceExtensionAbilityClass = class ServiceExtensionAbility {
constructor() {
console.warn('application.ServiceExtensionAbility.constructor interface mocked in the Previewer. How this interface works on' +
' the Previewer may be different from that on a real device.');
this.context = new serviceExtensionContextClass();
this.context = new ServiceExtensionContextClass();
this.onCreate = function (...args) {
console.warn("application.ServiceExtensionAbility.onCreate interface mocked in the Previewer. How this interface works on the Previewer" +
" may be different from that on a real device.")
@@ -19,4 +19,7 @@ export const StartOptionsClass = class StartOptions {
this.windowMode = "[PC Preview] unknow windowMode";
this.displayId = "[PC Preview] unknow displayId";
}
}
export function mockStartOptions() {
return new StartOptionsClass();
}
@@ -15,18 +15,20 @@
import { paramMock } from "../utils"
export const WantClass = class Want {
constructor() {
console.warn('Want.constructor interface mocked in the Previewer. How this interface works on' +
' the Previewer may be different from that on a real device.');
this.deviceId = "[PC Preview] unknow deviceId";
this.bundleName = "[PC Preview] unknow bundleName";
this.abilityName = "[PC Preview] unknow abilityName";
this.uri = "[PC Preview] unknow uri";
this.type = "[PC Preview] unknow type";
this.flag = "[PC Preview] unknow flag";
this.action = "[PC Preview] unknow action";
this.parameters = {};
this.entities = [paramMock.paramStringMock];
this.moduleName = "[PC Preview] unknow moduleName";
}
}
constructor() {
this.deviceId = "[PC Preview] unknow deviceId";
this.bundleName = "[PC Preview] unknow bundleName";
this.abilityName = "[PC Preview] unknow abilityName";
this.uri = "[PC Preview] unknow uri";
this.type = "[PC Preview] unknow type";
this.flags = "[PC Preview] unknow flags";
this.action = "[PC Preview] unknow action";
this.parameters = {};
this.entities = [paramMock.paramStringMock];
this.moduleName = "[PC Preview] unknow moduleName";
}
}
export function mockWant() {
return new WantClass();
}
@@ -13,8 +13,10 @@
* limitations under the License.
*/
import { AbilityDelegator } from "./application/abilityDelegator"
import { AbilityDelegatorArgs } from "./application/abilityDelegatorArgs"
import { AbilityDelegator as _AbilityDelegator} from "./application/abilityDelegator"
import { AbilityDelegatorArgs as _AbilityDelegatorArgs } from "./application/abilityDelegatorArgs"
import { AbilityMonitor as _AbilityMonitor } from "./application/abilityMonitor"
import { ShellCmdResult as _ShellCmdResult } from "./application/shellCmdResult"
export const AbilityLifecycleState = {
UNINITIALIZED: '[PC preview] unknow UNINITIALIZED',
@@ -29,13 +31,18 @@ export function mockAbilityDelegatorRegistry() {
getAbilityDelegator: function () {
console.warn('abilityDelegatorRegistry.getAbilityDelegator interface mocked in the Previewer. How this interface works on the' +
' Previewer may be different from that on a real device.');
return AbilityDelegator;
return _AbilityDelegator;
},
getArguments: function () {
console.warn('abilityDelegatorRegistry.getArguments interface mocked in the Previewer. How this interface works on the' +
' Previewer may be different from that on a real device.');
return AbilityDelegatorArgs;
return _AbilityDelegatorArgs;
},
AbilityLifecycleState,
AbilityDelegator: _AbilityDelegator,
AbilityDelegatorArgs: _AbilityDelegatorArgs,
AbilityMonitor: _AbilityMonitor,
ShellCmdResult: _ShellCmdResult
}
return abilityDelegatorRegistry
}
@@ -14,6 +14,9 @@
*/
import { paramMock } from "../utils"
import { AbilityRunningInfo as _AbilityRunningInfo } from "./application/AbilityRunningInfo"
import { ExtensionRunningInfo as _ExtensionRunningInfo } from "./application/ExtensionRunningInfo"
import { ElementName } from "./bundle/elementName"
export const AbilityState = {
INITIAL: 0,
@@ -23,39 +26,8 @@ export const AbilityState = {
BACKGROUNDING: 12
}
export function mockAbilityManager() {
const AbilityRunningInfoMock = {
ability: ElementNameMock,
pid: '[PC preview] unknow pid',
uid: '[PC preview] unknow uid',
processName: '[PC preview] unknow processName',
startTime: '[PC preview] unknow startTime',
AbilityStateMock: '[PC preview] unknow abilityStateMock'
}
const ElementNameMock = {
deviceId: '[PC preview] unknow deviceId',
bundleName: '[PC preview] unknow bundleName',
abilityName: '[PC preview] unknow abilityName',
uri: '[PC preview] unknow uri',
shortName: '[PC preview] unknow shortName'
}
const ExtensionRunningInfoMock = {
extension: ElementNameMock,
pid: '[PC preview] unknow pid',
uid: '[PC preview] unknow uid',
processName: '[PC preview] unknow processName',
startTime: '[PC preview] unknow startTime',
clientPackage: [paramMock.paramStringMock],
ExtensionAbilityTypeMock: '[PC preview] unknow ExtensionAbilityTypeMock',
}
const elementName = {
deviceId: "[PC preview] unknown deviceId",
bundleName: "[PC preview] unknown bundleName",
abilityName: "[PC preview] unknown abilityName",
uri: "[PC preview] unknown uri",
shortName: "[PC preview] unknown shortName",
moduleName: "[PC preview] unknown moduleName",
}
const abilityManager = {
AbilityState,
updateConfiguration: function (...args) {
console.warn('abilityManager.updateConfiguration interface mocked in the Previewer. How this interface works on the' +
' Previewer may be different from that on a real device.');
@@ -73,10 +45,10 @@ export function mockAbilityManager() {
' Previewer may be different from that on a real device.');
const len = args.length;
if (typeof args[len - 1] === 'function') {
args[len - 1].call(this, paramMock.businessErrorMock, [AbilityRunningInfoMock]);
args[len - 1].call(this, paramMock.businessErrorMock, [_AbilityRunningInfo]);
} else {
return new Promise((resolve) => {
resolve([AbilityRunningInfoMock]);
resolve([_AbilityRunningInfo]);
});
}
},
@@ -85,10 +57,10 @@ export function mockAbilityManager() {
' Previewer may be different from that on a real device.');
const len = args.length;
if (typeof args[len - 1] === 'function') {
args[len - 1].call(this, paramMock.businessErrorMock, [ExtensionRunningInfoMock]);
args[len - 1].call(this, paramMock.businessErrorMock, [_ExtensionRunningInfo]);
} else {
return new Promise((resolve) => {
resolve([ExtensionRunningInfoMock]);
resolve([_ExtensionRunningInfo]);
});
}
},
@@ -97,13 +69,15 @@ export function mockAbilityManager() {
' Previewer may be different from that on a real device.');
const len = args.length;
if (typeof args[len - 1] === 'function') {
args[len - 1].call(this, paramMock.businessErrorMock, elementName);
args[len - 1].call(this, paramMock.businessErrorMock, ElementName);
} else {
return new Promise((resolve) => {
resolve(elementName);
resolve(ElementName);
});
}
}
},
AbilityRunningInfo: _AbilityRunningInfo,
ExtensionRunningInfo: _ExtensionRunningInfo
}
return abilityManager
}
@@ -14,19 +14,13 @@
*/
import { paramMock } from "../utils"
import { AppStateDataClass as _AppStateData } from "./application/AppStateData"
import { ProcessRunningInfo } from "./application/ProcessRunningInfo"
import { AppStateDataClass as _AbilityStateData } from "./application/AppStateData"
import { ApplicationStateObserverClass as _ApplicationStateObserver } from "./application/ApplicationStateObserver"
import { ProcessDataClass as _ProcessData } from "./application/ProcessData"
export function mockAppManager() {
const AppStateDataMock = {
bundleName: '[PC preview] unknow bundleName',
uid: '[PC preview] unknow uid',
state: '[PC preview] unknow state'
}
const ProcessRunningInfoMock = {
pid: '[PC preview] unknow pid',
uid: '[PC preview] unknow uid',
processName: '[PC preview] unknow processName',
bundleNames: [paramMock.paramStringMock]
}
const appManager = {
registerApplicationStateObserver: function (...args) {
console.warn('appManager.registerApplicationStateObserver interface mocked in the Previewer. How this interface works on the' +
@@ -50,10 +44,10 @@ export function mockAppManager() {
' Previewer may be different from that on a real device.');
const len = args.length;
if (typeof args[len - 1] === 'function') {
args[len - 1].call(this, paramMock.businessErrorMock, [AppStateDataMock]);
args[len - 1].call(this, paramMock.businessErrorMock, [new _AppStateData()]);
} else {
return new Promise((resolve) => {
resolve([AppStateDataMock]);
resolve([new _AppStateData()]);
});
}
},
@@ -86,10 +80,10 @@ export function mockAppManager() {
' Previewer may be different from that on a real device.');
const len = args.length;
if (typeof args[len - 1] === 'function') {
args[len - 1].call(this, paramMock.businessErrorMock, [ProcessRunningInfoMock]);
args[len - 1].call(this, paramMock.businessErrorMock, [ProcessRunningInfo]);
} else {
return new Promise((resolve) => {
resolve([ProcessRunningInfoMock]);
resolve([ProcessRunningInfo]);
});
}
},
@@ -140,7 +134,12 @@ export function mockAppManager() {
resolve(paramMock.paramNumberMock);
});
}
}
},
AbilityStateData: new _AbilityStateData(),
AppStateData: new _AppStateData(),
ApplicationStateObserver: new _ApplicationStateObserver(),
ProcessData: new _ProcessData(),
ProcessRunningInfo
}
return appManager
}
@@ -0,0 +1,43 @@
/*
* 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 { AbilityContextClass as _AbilityContext } from "./application/AbilityContext"
import { AbilityStageContextClass as _AbilityStageContext } from "./application/AbilityStageContext"
import { ApplicationContextClass as _ApplicationContext } from "./application/ApplicationContext"
import { BaseContextClass as _BaseContext } from "./application/BaseContext"
import { ContextClass as _Context } from "./application/Context"
import { ExtensionContextClass as _ExtensionContext } from "./application/ExtensionContext"
import { FormExtensionContextClass as _FormExtensionContext } from "./application/FormExtensionContext"
import { EventHubClass as _EventHub } from "./application/EventHub"
import { PermissionRequestResultClass as _PermissionRequestResult } from "./application/PermissionRequestResult"
export const AreaMode = {
EL1: 0,
EL2: 1
}
export function mockContext() {
const Context = {
AbilityContext: new _AbilityContext(),
AbilityStageContext: new _AbilityStageContext(),
ApplicationContext: new _ApplicationContext(),
BaseContext: new _BaseContext(),
Context: new _Context(),
ExtensionContext: new _ExtensionContext(),
FormExtensionContext: new _FormExtensionContext(),
AreaMode,
EventHub: new _EventHub(),
PermissionRequestResult: new _PermissionRequestResult()
}
return Context;
}
+2
View File
@@ -13,6 +13,7 @@
* limitations under the License.
*/
import { paramMock } from "../utils"
import { ErrorObserverClass as _ErrorObserver } from "./application/ErrorObserver"
export function mockErrorManager() {
const errorManager = {
@@ -33,6 +34,7 @@ export function mockErrorManager() {
});
}
},
ErrorObserver: new _ErrorObserver()
}
return errorManager
}
@@ -24,6 +24,7 @@ export function mockFormBindingData() {
" may be different from that on a real device.")
return FormBindingData;
},
FormBindingData
}
return formBindingData;
}
@@ -36,4 +36,10 @@ export const FormError = {
ERR_SYSTEM_RESPONSES_FAILED: 30,
ERR_FORM_DUPLICATE_ADDED: 31,
ERR_IN_RECOVERY: 36
}
export function mockFormError() {
const formError = {
FormError
}
return formError;
}
@@ -63,4 +63,16 @@ export const FormParam = {
}
export const FormInfoFilter = {
moduleName: '[PC preview] unknow moduleName',
}
export function mockFormInfo() {
const formInfo = {
FormInfo,
FormType,
ColorMode,
FormStateInfo,
FormState,
FormParam,
FormInfoFilter
}
return formInfo;
}
@@ -14,30 +14,11 @@
*/
import { paramMock } from "../utils"
import { PixelMapMock } from "../multimedia"
import { MissionInfo as _MissionInfo } from "./application/MissionInfo"
import { MissionSnapshot as _MissionSnapshot } from "./application/MissionSnapshot"
import { MissionListener as _MissionListener } from "./application/MissionListener"
export function mockMissionManager() {
const MissionInfoMock = {
missionId: '[PC preview] unknown missionId',
runningState: '[PC preview] unknown runningState',
lockedState: '[PC preview] unknown lockedState',
timestamp: '[PC preview] unknown timestamp',
want: '[PC preview] unknown want',
label: '[PC preview] unknown label',
iconPath: '[PC preview] unknown iconPath',
continuable: '[PC preview] unknown continuable'
}
const ElementNameMock = {
deviceId: '[PC preview] unknown deviceId',
bundleName: '[PC preview] unknown bundleName',
abilityName: '[PC preview] unknown abilityName',
uri: '[PC preview] unknown uri',
shortName: '[PC preview] unknown shortName'
}
const MissionSnapshotMock = {
abality: ElementNameMock,
snapshot: PixelMapMock,
}
const missionManager = {
registerMissionListener: function (...args) {
console.warn("missionManager.registerMissionListener interface mocked in the Previewer. How this interface works on the Previewer" +
@@ -61,10 +42,10 @@ export function mockMissionManager() {
' Previewer may be different from that on a real device.');
const len = args.length;
if (typeof args[len - 1] === 'function') {
args[len - 1].call(this, paramMock.businessErrorMock, MissionInfoMock);
args[len - 1].call(this, paramMock.businessErrorMock, _MissionInfo);
} else {
return new Promise((resolve) => {
resolve(MissionInfoMock);
resolve(_MissionInfo);
});
}
},
@@ -73,10 +54,10 @@ export function mockMissionManager() {
' Previewer may be different from that on a real device.');
const len = args.length;
if (typeof args[len - 1] === 'function') {
args[len - 1].call(this, paramMock.businessErrorMock, [MissionInfoMock]);
args[len - 1].call(this, paramMock.businessErrorMock, [_MissionInfo]);
} else {
return new Promise((resolve) => {
resolve([MissionInfoMock]);
resolve([_MissionInfo]);
});
}
},
@@ -85,10 +66,22 @@ export function mockMissionManager() {
' Previewer may be different from that on a real device.');
const len = args.length;
if (typeof args[len - 1] === 'function') {
args[len - 1].call(this, paramMock.businessErrorMock, MissionSnapshotMock);
args[len - 1].call(this, paramMock.businessErrorMock, _MissionSnapshot);
} else {
return new Promise((resolve) => {
resolve(MissionSnapshotMock);
resolve(_MissionSnapshot);
});
}
},
getLowResolutionMissionSnapShot: function (...args) {
console.warn('missionManager.getLowResolutionMissionSnapShot interface mocked in the Previewer. How this interface works on the' +
' Previewer may be different from that on a real device.');
const len = args.length;
if (typeof args[len - 1] === 'function') {
args[len - 1].call(this, paramMock.businessErrorMock, _MissionSnapshot);
} else {
return new Promise((resolve) => {
resolve(_MissionSnapshot);
});
}
},
@@ -151,7 +144,10 @@ export function mockMissionManager() {
resolve();
});
}
}
},
MissionInfo: _MissionInfo,
MissionListener: _MissionListener,
MissionSnapshot: _MissionSnapshot
}
return missionManager
}
@@ -252,7 +252,8 @@ export function mockCommonEvent() {
if (typeof args[len - 1] === 'function') {
args[len - 1].call(this, paramMock.businessErrorMock);
}
}
},
Support
}
return commonEvent
}
@@ -39,6 +39,8 @@ export function mockContact() {
this.organization = "[PC Preview] unknow organization";
}
}
ContactClass.INVALID_CONTACT_ID = -1;
const ContactAttributesClass = class ContactAttributes {
constructor() {
console.warn('contact.ContactAttributes.constructor interface mocked in the Previewer. How this interface' +
@@ -122,6 +124,7 @@ export function mockContact() {
this.middleNamePhonetic = "[PC Preview] unknow middleNamePhonetic";
this.namePrefix = "[PC Preview] unknow namePrefix";
this.nameSuffix = "[PC Preview] unknow nameSuffix";
this.middleName = "[PC Preview] unknow middleName";
}
}
const NickNameClass = class NickName {
@@ -269,6 +272,22 @@ export function mockContact() {
Relation: RelationClass,
SipAddress: SipAddressClass,
Website: WebsiteClass,
Attribute:{
ATTR_CONTACT_EVENT: "[PC Preview] unknow ATTR_CONTACT_EVENT",
ATTR_EMAIL: "[PC Preview] unknow ATTR_EMAIL",
ATTR_GROUP_MEMBERSHIP: "[PC Preview] unknow ATTR_GROUP_MEMBERSHIP",
ATTR_IM: "[PC Preview] unknow ATTR_IM",
ATTR_NAME: "[PC Preview] unknow ATTR_NAME",
ATTR_NICKNAME: "[PC Preview] unknow ATTR_NICKNAME",
ATTR_NOTE: "[PC Preview] unknow ATTR_NOTE",
ATTR_ORGANIZATION: "[PC Preview] unknow ATTR_ORGANIZATION",
ATTR_PHONE: "[PC Preview] unknow ATTR_PHONE",
ATTR_PORTRAIT: "[PC Preview] unknow ATTR_PORTRAIT",
ATTR_POSTAL_ADDRESS: "[PC Preview] unknow ATTR_POSTAL_ADDRESS",
ATTR_RELATION: "[PC Preview] unknow ATTR_RELATION",
ATTR_SIP_ADDRESS: "[PC Preview] unknow ATTR_SIP_ADDRESS",
ATTR_WEBSITE: "[PC Preview] unknow ATTR_WEBSITE",
},
addContact: function (...args) {
console.warn("contact.addContact interface mocked in the Previewer. How this interface works on the" +
" Previewer may be different from that on a real device.")
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2021 Huawei Device Co., Ltd.
* 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
@@ -16,19 +16,42 @@
import { paramMock } from "../utils"
export function mockConvertXml() {
const result = {
ConvertXML: function (...args) {
console.warn("convertXml.ConvertXML interface mocked in the Previewer. How this interface works on the Previewer" +
" may be different from that on a real device.")
return ConvertXMLMock;
}
}
const ConvertXMLClass = class ConvertXML {
constructor(...args) {
console.warn("convertXml.ConvertXML.constructor interface mocked in the Previewer. How this interface works on the Previewer" +
" may be different from that on a real device.");
this.convert = function (...args) {
console.warn("ConvertXML.convert interface mocked in the Previewer. How this interface works on the Previewer" +
" may be different from that on a real device.");
return paramMock.paramObjectMock;
}
}
};
const ConvertXMLMock = {
convert: function (...args) {
console.warn("ConvertXML.convert interface mocked in the Previewer. How this interface works on the Previewer" +
" may be different from that on a real device.")
return paramMock.paramObjectMock;
}
}
return result;
ConvertXML : ConvertXMLClass
};
const ConvertOptionsMock = {
trim : '[PC preview] unknow trim',
ignoreDeclaration : '[PC preview] unknow ignoreDeclaration',
ignoreInstruction : '[PC preview] unknow ignoreInstruction',
ignoreAttributes : '[PC preview] unknow ignoreAttributes',
ignoreComment : '[PC preview] unknow ignoreComment',
ignoreCDATA : '[PC preview] unknow ignoreCDATA',
ignoreDoctype : '[PC preview] unknow ignoreDoctype',
ignoreText : '[PC preview] unknow ignoreText',
declarationKey : '[PC preview] unknow declarationKey',
instructionKey : '[PC preview] unknow instructionKey',
attributesKey : '[PC preview] unknow attributesKey',
textKey : '[PC preview] unknow textKey',
cdataKey : '[PC preview] unknow cdataKey',
doctypeKey : '[PC preview] unknow doctypeKey',
commentKey : '[PC preview] unknow commentKey',
parentKey : '[PC preview] unknow parentKey',
typeKey : '[PC preview] unknow typeKey',
nameKey : '[PC preview] unknow nameKey',
elementsKey : '[PC preview] unknow elementsKey'
};
return ConvertXMLMock;
}
@@ -15,6 +15,13 @@
import {paramMock} from "../utils"
export const DataType = {
TYPE_NULL: 0,
TYPE_LONG: 1,
TYPE_DOUBLE: 2,
TYPE_STRING: 3,
TYPE_BLOB: 4
};
export const DataShareResultSetMock = {
columnNames: "[PC Preview] unknow columnNames",
columnCount: "[PC Preview] unknow columnCount",
@@ -15,6 +15,15 @@
import { paramMock } from "../utils"
const ValueTypes = '[PC Preview] unknow value type'
const StorageObserver = {
key: '[PC Preview] unknown key'
};
const MAX_KEY_LENGTH = 80;
const MAX_VALUE_LENGTH = 8192;
export function mockDataStorage() {
const storage = {
storageMock,
@@ -72,17 +81,17 @@ export function mockDataStorage() {
getSync: function () {
console.warn("Storage.getSync interface mocked in the Previewer. How this interface works on the Previewer may" +
" be different from that on a real device.")
return paramValueTypeMock
return ValueTypes
},
get: function (...args) {
console.warn("Storage.get interface mocked in the Previewer. How this interface works on the Previewer may be" +
" different from that on a real device.")
const len = args.length
if (typeof args[len - 1] === 'function') {
args[len - 1].call(this, paramMock.businessErrorMock, paramValueTypeMock)
args[len - 1].call(this, paramMock.businessErrorMock, ValueTypes)
} else {
return new Promise((resolve) => {
resolve(paramValueTypeMock)
resolve(ValueTypes)
})
}
},
@@ -171,13 +180,13 @@ export function mockDataStorage() {
console.warn("Storage.on interface mocked in the Previewer. How this interface works on the Previewer may be" +
" different from that on a real device.")
const len = args.length
args[len - 1].call(this, storageObserverMock)
args[len - 1].call(this, StorageObserver)
},
off: function (...args) {
console.warn("Storage.off interface mocked in the Previewer. How this interface works on the Previewer may be" +
" different from that on a real device.")
const len = args.length
args[len - 1].call(this, storageObserverMock)
args[len - 1].call(this, storageObserver)
}
}
return storage
@@ -15,7 +15,7 @@
import { paramMock } from "../utils"
export function mockDataSharePredicates() {
const DataSharePredicatesClass = class DataSharePredicate {
const DataSharePredicatesClass = class DataSharePredicates {
constructor() {
this.equalTo = function (...args) {
console.warn("DataSharePredicates.equalTo interface mocked in the Previewer. How this interface works on the" +
@@ -62,7 +62,7 @@ export function mockDistributedObject() {
const RevokeSaveSuccessResponse = {
sessionId: "[[PC Preview] unknow sessionId]"
};
const distributedObjectMock = {
const distributedDataObject = {
createDistributedObject: function (...args) {
console.warn("distributedObject.createDistributedObject interface mocked in the Previewer." +
" How this interface works on the Previewer may be different from that on a real device.");
@@ -74,5 +74,5 @@ export function mockDistributedObject() {
return 'just test';
}
};
return distributedObjectMock;
}
return distributedDataObject;
}
@@ -205,6 +205,16 @@ export function mockRdb() {
const storeConfig = {
name: "[PC Preview] unknown name"
}
const SyncMode = {
SYNC_MODE_PUSH: 0,
SYNC_MODE_PULL: 1
}
const SubscribeType = {
SUBSCRIBE_TYPE_REMOTE: 0
}
const rdbStore = {
insert: function (...args) {
console.warn("RdbStore.insert interface mocked in the Previewer. How this interface works on the" +
@@ -55,6 +55,9 @@ export function mockEmitter() {
console.warn("emitter.emit interface mocked in the Previewer. How this interface works on the" +
" Previewer may be different from that on a real device.");
},
EventData,
InnerEvent,
EventPriority
}
return emitter
}
@@ -0,0 +1,58 @@
/*
* 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"
function buildMockInfo(interfaceName) {
return interfaceName + " interface mocked in the Previewer. How this interface works on the Previewer" +
" may be different from that on a real device."
}
export function mockFaultLogger() {
const FaultType = {
NO_SPECIFIC : 0,
CPP_CRASH : 2,
JS_CRASH : 3,
APP_FREEZE : 4
}
const FaultLogInfo = {
pid: "[PC Preview] unknow pid",
uid: "[PC Preview] unknow uid",
type: FaultType,
timestamp: "[PC Preview] unknow timestamp",
reason: "[PC Preview] unknow reason",
module: "[PC Preview] unknow module",
summary: "[PC Preview] unknow summary",
fullLog: "[PC Preview] unknow fullLog",
}
const FaultLogger = {
FaultType,
FaultLogInfo,
querySelfFaultLog: function(...args) {
console.warn(buildMockInfo("FaultLogger.querySelfFaultLog"))
var array = new Array()
array.push(FaultLogInfo)
const len = args.length
if (typeof args[len - 1] === 'function') {
args[len - 1].call(this, paramMock.businessErrorMock, array)
} else {
return new Promise((resolve) => {
resolve(array)
});
}
},
}
return FaultLogger
}
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2021 Huawei Device Co., Ltd.
* Copyright (c) 2021-2022 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
@@ -16,16 +16,29 @@
import { paramMock } from "../utils"
export function mockFileManager() {
const FileInfo = {
name: '[PC preview] unknow name',
path: '[PC preview] unknow path',
type: '[PC preview] unknow type',
size: '[PC preview] unknow size',
addedTime: '[PC preview] unknow addedTime',
modifiedTime: '[PC preview] unknow modifiedTime'
};
const DevInfo = {
name: '[PC preview] unknow name'
};
const filemanager = {
FileInfo: FileInfo,
DevInfo: DevInfo,
getRoot: function (...args) {
console.warn("filemanager.getRoot interface mocked in the Previewer. How this interface works on the" +
" Previewer may be different from that on a real device.")
const len = args.length
if (typeof args[len - 1] === 'function') {
args[len - 1].call(this, paramMock.businessErrorMock, paramMock.paramArrayMock)
args[len - 1].call(this, paramMock.businessErrorMock, new Array(FileInfo))
} else {
return new Promise((resolve, reject) => {
resolve(paramMock.paramArrayMock);
resolve(new Array(FileInfo));
})
}
},
@@ -34,10 +47,10 @@ export function mockFileManager() {
" Previewer may be different from that on a real device.")
const len = args.length
if (typeof args[len - 1] === 'function') {
args[len - 1].call(this, paramMock.businessErrorMock, paramMock.paramArrayMock)
args[len - 1].call(this, paramMock.businessErrorMock, new Array(FileInfo))
} else {
return new Promise((resolve, reject) => {
resolve(paramMock.paramArrayMock);
resolve(new Array(FileInfo));
})
}
},
@@ -52,7 +65,7 @@ export function mockFileManager() {
resolve(paramMock.paramStringMock);
})
}
},
}
}
return filemanager;
}
+239 -178
View File
@@ -16,7 +16,7 @@
import { paramMock } from "../utils"
export function mockI18N() {
const result = {
const i18n = {
getDisplayCountry: function(...args) {
console.warn("I18N.getDisplayCountry interface mocked in the Previewer. How this interface works on the Previewer" +
" may be different from that on a real device.")
@@ -75,7 +75,7 @@ export function mockI18N() {
getCalendar: function(...args) {
console.warn("I18N.getCalendar interface mocked in the Previewer. How this interface works on the Previewer" +
" may be different from that on a real device.")
return CalendarMock;
return new CalendarClass();
},
isRTL: function(...args) {
console.warn("I18N.isRTL interface mocked in the Previewer. How this interface works on the Previewer" +
@@ -85,73 +85,19 @@ export function mockI18N() {
getLineInstance: function(...args) {
console.warn("I18N.getLineInstance interface mocked in the Previewer. How this interface works on the Previewer" +
" may be different from that on a real device.")
return BreakIteratorMock;
return new BreakIteratorClass();
},
getTimeZone: function(...args) {
console.warn("I18N.getTimeZone interface mocked in the Previewer. How this interface works on the Previewer" +
" may be different from that on a real device.")
return new TimeZoneClass();
},
Util: {
unitConvert: function(...args) {
console.warn("I18N.Util.unitConvert interface mocked in the Previewer. How this interface works on the Previewer" +
" may be different from that on a real device.")
}
},
IndexUtil: {
getInstance: function() {
console.warn("I18N.IndexUtil.getInstance interface mocked in the Previewer. How this interface works on the Previewer" +
" may be different from that on a real device.")
return IndexUtilMock;
}
},
Character: {
isDigit: function(...args) {
console.warn("I18N.Character.isDigit interface mocked in the Previewer. How this interface works on the Previewer" +
" may be different from that on a real device.")
return paramMock.paramBooleanMock;
},
isSpaceChar: function(...args) {
console.warn("I18N.Character.isSpaceChar interface mocked in the Previewer. How this interface works on the Previewer" +
" may be different from that on a real device.")
return paramMock.paramBooleanMock;
},
isWhitespace: function(...args) {
console.warn("I18N.Character.isWhitespace interface mocked in the Previewer. How this interface works on the Previewer" +
" may be different from that on a real device.")
return paramMock.paramBooleanMock;
},
isRTL: function(...args) {
console.warn("I18N.Character.isRTL interface mocked in the Previewer. How this interface works on the Previewer" +
" may be different from that on a real device.")
return paramMock.paramBooleanMock;
},
isIdeograph: function(...args) {
console.warn("I18N.Character.isIdeograph interface mocked in the Previewer. How this interface works on the Previewer" +
" may be different from that on a real device.")
return paramMock.paramBooleanMock;
},
isLetter: function(...args) {
console.warn("I18N.Character.isLetter interface mocked in the Previewer. How this interface works on the Previewer" +
" may be different from that on a real device.")
return paramMock.paramBooleanMock;
},
isLowerCase: function(...args) {
console.warn("I18N.Character.isLowerCase interface mocked in the Previewer. How this interface works on the Previewer" +
" may be different from that on a real device.")
return paramMock.paramBooleanMock;
},
isUpperCase: function(...args) {
console.warn("I18N.Character.isUpperCase interface mocked in the Previewer. How this interface works on the Previewer" +
" may be different from that on a real device.")
return paramMock.paramBooleanMock;
},
getType: function(...args) {
console.warn("I18N.Character.getType interface mocked in the Previewer. How this interface works on the Previewer" +
" may be different from that on a real device.")
return paramMock.paramStringMock;
},
getInstance: function() {
console.warn("I18N.IndexUtil.getInstance interface mocked in the Previewer. How this interface works on the Previewer" +
" may be different from that on a real device.")
return new IndexUtilClass();
},
Character: CharacterClass,
is24HourClock: function() {
console.warn("I18N.is24HourClock interface mocked in the Previewer. How this interface works on the Previewer" +
" may be different from that on a real device.")
@@ -193,127 +139,28 @@ export function mockI18N() {
" may be different from that on a real device.")
return paramMock.paramBooleanMock;
},
PhoneNumberFormat: PhoneNumberFormatClass
}
const CalendarMock = {
setTime: function(...args) {
console.warn("I18N.Calendar.setTime interface mocked in the Previewer. How this interface works on the Previewer" +
" may be different from that on a real device.")
},
set: function(...args) {
console.warn("I18N.Calendar.set interface mocked in the Previewer. How this interface works on the Previewer" +
" may be different from that on a real device.")
},
setTimeZone: function(...args) {
console.warn("I18N.Calendar.setTimeZone interface mocked in the Previewer. How this interface works on the Previewer" +
" may be different from that on a real device.")
},
getTimeZone: function() {
console.warn("I18N.Calendar.getTimeZone interface mocked in the Previewer. How this interface works on the Previewer" +
PhoneNumberFormat: PhoneNumberFormatClass,
Transliterator: TransliteratorClass,
getAppPreferredLanguage: function() {
console.warn("I18N.getAppPreferredLanguage interface mocked in the Previewer. How this interface works on the Previewer" +
" may be different from that on a real device.")
return paramMock.paramStringMock;
},
getFirstDayOfWeek: function() {
console.warn("I18N.Calendar.getFirstDayOfWeek interface mocked in the Previewer. How this interface works on the Previewer" +
" may be different from that on a real device.")
return paramMock.paramNumberMock;
},
setFirstDayOfWeek: function(...args) {
console.warn("I18N.Calendar.setFirstDayOfWeek interface mocked in the Previewer. How this interface works on the Previewer" +
" may be different from that on a real device.")
},
getMinimalDaysInFirstWeek: function() {
console.warn("I18N.Calendar.getMinimalDaysInFirstWeek interface mocked in the Previewer. How this interface works on the Previewer" +
" may be different from that on a real device.")
return paramMock.paramNumberMock;
},
setMinimalDaysInFirstWeek: function(...args) {
console.warn("I18N.Calendar.setMinimalDaysInFirstWeek interface mocked in the Previewer. How this interface works on the Previewer" +
" may be different from that on a real device.")
},
get: function(...args) {
console.warn("I18N.Calendar.get interface mocked in the Previewer. How this interface works on the Previewer" +
" may be different from that on a real device.")
return paramMock.paramNumberMock;
},
getDisplayName: function(...args) {
console.warn("I18N.Calendar.getDisplayName interface mocked in the Previewer. How this interface works on the Previewer" +
" may be different from that on a real device.")
return paramMock.paramStringMock;
},
isWeekend: function(...args) {
console.warn("I18N.Calendar.isWeekend interface mocked in the Previewer. How this interface works on the Previewer" +
" may be different from that on a real device.")
return paramMock.paramBooleanMock;
},
}
const BreakIteratorMock = {
current: function() {
console.warn("I18N.BreakIterator.current interface mocked in the Previewer. How this interface works on the Previewer" +
" may be different from that on a real device.")
return paramMock.paramNumberMock;
},
first: function() {
console.warn("I18N.BreakIterator.first interface mocked in the Previewer. How this interface works on the Previewer" +
" may be different from that on a real device.")
return paramMock.paramNumberMock;
},
last: function() {
console.warn("I18N.BreakIterator.last interface mocked in the Previewer. How this interface works on the Previewer" +
" may be different from that on a real device.")
return paramMock.paramNumberMock;
},
next: function(...args) {
console.warn("I18N.BreakIterator.next interface mocked in the Previewer. How this interface works on the Previewer" +
" may be different from that on a real device.")
return paramMock.paramNumberMock;
},
previous: function() {
console.warn("I18N.BreakIterator.previous interface mocked in the Previewer. How this interface works on the Previewer" +
" may be different from that on a real device.")
return paramMock.paramNumberMock;
},
setLineBreakText: function() {
console.warn("I18N.BreakIterator.setLineBreakText interface mocked in the Previewer. How this interface works on the Previewer" +
" may be different from that on a real device.")
},
following: function() {
console.warn("I18N.BreakIterator.following interface mocked in the Previewer. How this interface works on the Previewer" +
" may be different from that on a real device.")
return paramMock.paramNumberMock;
},
getLineBreakText: function() {
console.warn("I18N.BreakIterator.getLineBreakText interface mocked in the Previewer. How this interface works on the Previewer" +
" may be different from that on a real device.")
return paramMock.paramStringMock;
},
isBoundary: function(...args) {
console.warn("I18N.BreakIterator.isBoundary interface mocked in the Previewer. How this interface works on the Previewer" +
" may be different from that on a real device.")
return paramMock.paramBooleanMock;
},
const PhoneNumberFormatOptions = {
type: '[PC preview] unknow type',
}
const IndexUtilMock = {
getIndexList: function() {
console.warn("I18N.IndexUtil.getIndexList interface mocked in the Previewer. How this interface works on the Previewer" +
" may be different from that on a real device.")
return new Array(paramMock.paramStringMock);
},
addLocale: function(...args) {
console.warn("I18N.IndexUtil.addLocale interface mocked in the Previewer. How this interface works on the Previewer" +
" may be different from that on a real device.")
},
getIndex: function(...args) {
console.warn("I18N.IndexUtil.getIndex interface mocked in the Previewer. How this interface works on the Previewer" +
" may be different from that on a real device.")
return paramMock.paramStringMock;
}
const UnitInfo = {
unit: '[PC preview] unknow unit',
measureSystem: '[PC preview] unknow measureSystem',
}
return result;
return i18n;
}
export const TimeZoneClass = class TimeZone{
constructor() {
console.warn("I18N.TimeZone interface mocked in the Previewer. How this interface works on the Previewer" +
" may be different from that on a real device.")
this.getID = function() {
console.warn("I18N.TimeZone.getID interface mocked in the Previewer. How this interface works on the Previewer" +
" may be different from that on a real device.")
@@ -356,7 +203,7 @@ TimeZoneClass.getTimezoneFromCity = function(...args) {
" may be different from that on a real device.")
return new TimeZoneClass();
};
const PhoneNumberFormatClass = class PhoneNumberFormat{
export const PhoneNumberFormatClass = class PhoneNumberFormat{
constructor(...args) {
console.warn("I18N.PhoneNumberFormat.constructor interface mocked in the Previewer. How this interface works on the Previewer" +
" may be different from that on a real device.")
@@ -370,10 +217,224 @@ const PhoneNumberFormatClass = class PhoneNumberFormat{
" may be different from that on a real device.")
return paramMock.paramStringMock;
};
this.getLocationName = function(...args) {
console.warn("I18N.PhoneNumberFormat.getLocationName interface mocked in the Previewer. How this interface works on the Previewer" +
" may be different from that on a real device.")
return paramMock.paramStringMock;
};
}
}
PhoneNumberFormatClass.getLocationName = function(...args) {
console.warn("I18N.PhoneNumberFormat.getLocationName interface mocked in the Previewer. How this interface works on the Previewer" +
" may be different from that on a real device.")
return paramMock.paramStringMock;
export const TransliteratorClass = class Transliterator {
constructor() {
console.warn("I18N.Transliterator interface mocked in the Previewer. How this interface works on the Previewer" +
" may be different from that on a real device.")
this.transform = function(...args) {
console.warn("I18N.Transliterator.transform interface mocked in the Previewer. How this interface works on the Previewer" +
" may be different from that on a real device.")
return paramMock.paramStringMock;
};
}
}
TransliteratorClass.getAvailableIDs = function() {
console.warn("I18N.Transliterator.getAvailableIDs interface mocked in the Previewer. How this interface works on the Previewer" +
"may be different from that on a real device.")
return new Array(paramMock.paramStringMock);
}
TransliteratorClass.getInstance = function(...args) {
console.warn("I18N.Transliterator.getInstance interface mocked in the Previewer. How this interface works on the Previewer" +
"may be different from that on a real device.")
return new TransliteratorClass();
}
const IndexUtilClass = class IndexUtil {
constructor() {
console.warn("I18N.IndexUtil interface mocked in the Previewer. How this interface works on the Previewer" +
" may be different from that on a real device.")
this.getIndexList = function() {
console.warn("I18N.IndexUtil.getIndexList interface mocked in the Previewer. How this interface works on the Previewer" +
" may be different from that on a real device.")
return new Array(paramMock.paramStringMock);
};
this.addLocale = function(...args) {
console.warn("I18N.IndexUtil.addLocale interface mocked in the Previewer. How this interface works on the Previewer" +
" may be different from that on a real device.")
};
this.getIndex = function(...args) {
console.warn("I18N.IndexUtil.getIndex interface mocked in the Previewer. How this interface works on the Previewer" +
" may be different from that on a real device.")
return paramMock.paramStringMock;
};
}
}
const BreakIteratorClass = class BreakIterator {
constructor() {
console.warn("I18N.BreakIterator interface mocked in the Previewer. How this interface works on the Previewer" +
" may be different from that on a real device.")
this.current = function() {
console.warn("I18N.BreakIterator.current interface mocked in the Previewer. How this interface works on the Previewer" +
" may be different from that on a real device.")
return paramMock.paramNumberMock;
};
this.first = function() {
console.warn("I18N.BreakIterator.first interface mocked in the Previewer. How this interface works on the Previewer" +
" may be different from that on a real device.")
return paramMock.paramNumberMock;
};
this.last = function() {
console.warn("I18N.BreakIterator.last interface mocked in the Previewer. How this interface works on the Previewer" +
" may be different from that on a real device.")
return paramMock.paramNumberMock;
};
this.next = function(...args) {
console.warn("I18N.BreakIterator.next interface mocked in the Previewer. How this interface works on the Previewer" +
" may be different from that on a real device.")
return paramMock.paramNumberMock;
};
this.previous = function() {
console.warn("I18N.BreakIterator.previous interface mocked in the Previewer. How this interface works on the Previewer" +
" may be different from that on a real device.")
return paramMock.paramNumberMock;
};
this.setLineBreakText = function() {
console.warn("I18N.BreakIterator.setLineBreakText interface mocked in the Previewer. How this interface works on the Previewer" +
" may be different from that on a real device.")
};
this.following = function() {
console.warn("I18N.BreakIterator.following interface mocked in the Previewer. How this interface works on the Previewer" +
" may be different from that on a real device.")
return paramMock.paramNumberMock;
};
this.getLineBreakText = function() {
console.warn("I18N.BreakIterator.getLineBreakText interface mocked in the Previewer. How this interface works on the Previewer" +
" may be different from that on a real device.")
return paramMock.paramStringMock;
};
this.isBoundary = function(...args) {
console.warn("I18N.BreakIterator.isBoundary interface mocked in the Previewer. How this interface works on the Previewer" +
" may be different from that on a real device.")
return paramMock.paramBooleanMock;
};
}
}
const CalendarClass = class Calendar {
constructor() {
console.warn("I18N.Calendar interface mocked in the Previewer. How this interface works on the Previewer" +
" may be different from that on a real device.")
this.setTime = function(...args) {
console.warn("I18N.Calendar.setTime interface mocked in the Previewer. How this interface works on the Previewer" +
" may be different from that on a real device.")
};
this.set = function(...args) {
console.warn("I18N.Calendar.set interface mocked in the Previewer. How this interface works on the Previewer" +
" may be different from that on a real device.")
};
this.setTimeZone = function(...args) {
console.warn("I18N.Calendar.setTimeZone interface mocked in the Previewer. How this interface works on the Previewer" +
" may be different from that on a real device.")
};
this.getTimeZone = function() {
console.warn("I18N.Calendar.getTimeZone interface mocked in the Previewer. How this interface works on the Previewer" +
" may be different from that on a real device.")
return paramMock.paramStringMock;
};
this.getFirstDayOfWeek = function() {
console.warn("I18N.Calendar.getFirstDayOfWeek interface mocked in the Previewer. How this interface works on the Previewer" +
" may be different from that on a real device.")
return paramMock.paramNumberMock;
};
this.setFirstDayOfWeek = function(...args) {
console.warn("I18N.Calendar.setFirstDayOfWeek interface mocked in the Previewer. How this interface works on the Previewer" +
" may be different from that on a real device.")
};
this.getMinimalDaysInFirstWeek = function() {
console.warn("I18N.Calendar.getMinimalDaysInFirstWeek interface mocked in the Previewer. How this interface works on the Previewer" +
" may be different from that on a real device.")
return paramMock.paramNumberMock;
};
this.setMinimalDaysInFirstWeek = function(...args) {
console.warn("I18N.Calendar.setMinimalDaysInFirstWeek interface mocked in the Previewer. How this interface works on the Previewer" +
" may be different from that on a real device.")
};
this.get = function(...args) {
console.warn("I18N.Calendar.get interface mocked in the Previewer. How this interface works on the Previewer" +
" may be different from that on a real device.")
return paramMock.paramNumberMock;
};
this.getDisplayName = function(...args) {
console.warn("I18N.Calendar.getDisplayName interface mocked in the Previewer. How this interface works on the Previewer" +
" may be different from that on a real device.")
return paramMock.paramStringMock;
};
this.isWeekend = function(...args) {
console.warn("I18N.Calendar.isWeekend interface mocked in the Previewer. How this interface works on the Previewer" +
" may be different from that on a real device.")
return paramMock.paramBooleanMock;
};
}
}
export const UtilClass = class Util {
constructor() {
console.warn("I18N.Util interface mocked in the Previewer. How this interface works on the Previewer" +
" may be different from that on a real device.")
this.unitConvert = function(...args) {
console.warn("I18N.Util.unitConvert interface mocked in the Previewer. How this interface works on the Previewer" +
" may be different from that on a real device.")
return paramMock.paramStringMock;
};
this.getDateOrder = function(...args) {
console.warn("I18N.Util.getDateOrder interface mocked in the Previewer. How this interface works on the Previewer" +
" may be different from that on a real device.")
return paramMock.paramStringMock;
}
}
}
export const CharacterClass = class Character {
constructor() {
console.warn("I18N.Character interface mocked in the Previewer. How this interface works on the Previewer" +
" may be different from that on a real device.")
this.isDigit = function(...args) {
console.warn("I18N.Character.isDigit interface mocked in the Previewer. How this interface works on the Previewer" +
" may be different from that on a real device.")
return paramMock.paramBooleanMock;
};
this.isSpaceChar = function(...args) {
console.warn("I18N.Character.isSpaceChar interface mocked in the Previewer. How this interface works on the Previewer" +
" may be different from that on a real device.")
return paramMock.paramBooleanMock;
};
this.isWhitespace = function(...args) {
console.warn("I18N.Character.isWhitespace interface mocked in the Previewer. How this interface works on the Previewer" +
" may be different from that on a real device.")
return paramMock.paramBooleanMock;
};
this.isRTL = function(...args) {
console.warn("I18N.Character.isRTL interface mocked in the Previewer. How this interface works on the Previewer" +
" may be different from that on a real device.")
return paramMock.paramBooleanMock;
};
this.isIdeograph = function(...args) {
console.warn("I18N.Character.isIdeograph interface mocked in the Previewer. How this interface works on the Previewer" +
" may be different from that on a real device.")
return paramMock.paramBooleanMock;
};
this.isLetter = function(...args) {
console.warn("I18N.Character.isLetter interface mocked in the Previewer. How this interface works on the Previewer" +
" may be different from that on a real device.")
return paramMock.paramBooleanMock;
};
this.isLowerCase = function(...args) {
console.warn("I18N.Character.isLowerCase interface mocked in the Previewer. How this interface works on the Previewer" +
" may be different from that on a real device.")
return paramMock.paramBooleanMock;
};
this.isUpperCase = function(...args) {
console.warn("I18N.Character.isUpperCase interface mocked in the Previewer. How this interface works on the Previewer" +
" may be different from that on a real device.")
return paramMock.paramBooleanMock;
};
this.getType = function(...args) {
console.warn("I18N.Character.getType interface mocked in the Previewer. How this interface works on the Previewer" +
" may be different from that on a real device.")
return paramMock.paramStringMock;
};
}
}
@@ -39,14 +39,8 @@ export function mockInputMethod() {
}
]
const InputMethodProperty = {
methodId: "[PC Preview] unknow method id",
bundleName: "[PC Preview] unknow bundle name",
abilityName: "[PC Preview] unknow ability name",
configurationPage: "[PC Preview] unknow configuration page",
isSystemIme: true,
typeCount: 1,
defaultImeId: 2,
keyboardTypes: KeyboardTypeArry
packageName :"[PC Preview] unknow packageName",
methodId: "[PC Preview] unknow method id"
}
const InputMethodPropertyArry = [
{
@@ -137,7 +131,7 @@ export function mockInputMethod() {
},
}
const inputMethod = {
MAX_TYPE_MUN: 128,
MAX_TYPE_NUM: 128,
getInputMethodController: function () {
console.warn("inputmethod.getInputMethodController interface mocked in the Previewer. How this interface works" +
" on the Previewer may be different from that on a real device.")
@@ -147,7 +141,24 @@ export function mockInputMethod() {
console.warn("inputmethod.getInputMethodSetting interface mocked in the Previewer. How this interface works" +
" on the Previewer may be different from that on a real device.")
return InputMethodSettingMock;
}
},
getCurrentInputMethod: function () {
console.warn("inputmethod.getCurrentInputMethod interface mocked in the Previewer. How this interface works" +
" on the Previewer may be different from that on a real device.")
return InputMethodProperty;
},
switchInputMethod: function (...args) {
console.warn("inputMethod.switchInputMethod interface mocked in the Previewer. How this interface works on" +
" the Previewer may be different from that on a real device.")
const len = args.length
if (typeof args[len - 1] === 'function') {
args[len - 1].call(this, paramMock.businessErrorMock, paramMock.paramBooleanMock);
} else {
return new Promise((resolve, reject) => {
resolve(paramMock.paramBooleanMock);
})
}
},
}
return inputMethod
}
@@ -15,36 +15,6 @@
import { paramMock } from "../utils"
const NOTIFY = "[PC Preview] unknow"
const Properties = [
'ENTER_KEY_TYPE_NEXT',
'ENTER_KEY_TYPE_PREVIOUS',
'ENTER_KEY_TYPE_UNSPECIFIED',
'ENTER_KEY_TYPE_SEARCH',
'ENTER_KEY_TYPE_GO',
'ENTER_KEY_TYPE_SEND',
'ENTER_KEY_TYPE_DONE',
'DISPLAY_MODE_PART',
'DISPLAY_MODE_FULL',
'OPTION_AUTO_CAP_CHARACTERS',
'OPTION_AUTO_CAP_WORDS',
'OPTION_AUTO_CAP_SENTENCES',
'OPTION_NO_FULLSCREEN',
'OPTION_ASCII',
'OPTION_NONE',
'OPTION_MULTI_LINE',
'FLAG_SINGLE_LINE',
'FLAG_SELECTING',
'PATTERN_TEXT',
'PATTERN_NUMBER',
'PATTERN_NULL',
'PATTERN_PHONE',
'PATTERN_DATETIME',
'PATTERN_URI',
'PATTERN_EMAIL',
'PATTERN_PASSWORD'
]
export function mockInputMethodEngine() {
const EditingText = {
textContent: "[PC Preview] unknow textContent",
@@ -65,6 +35,10 @@ export function mockInputMethodEngine() {
enterKeyType: 2,
inputOption: 3
}
const KeyEvent = {
keyCode: "[PC Preview] unknow keyCode",
keyAction: "[PC Preview] unknow keyAction"
}
const RichContent = {
contentURI: "[PC Preview] unknow contentURI",
linkURI: "[PC Preview] unknow linkURI",
@@ -376,7 +350,7 @@ export function mockInputMethodEngine() {
const len = args.length
if (typeof args[len - 1] === 'function') {
if (args[0] == 'keyDown' || args[0] == 'keyUp') {
args[len - 1].call(this, paramMock.paramObjectMock);
args[len - 1].call(this, KeyEvent);
} else if (args[0] == 'selectionChange') {
args[len - 1].call(this, paramMock.paramNumberMock, paramMock.paramNumberMock, paramMock.paramNumberMock, paramMock.paramNumberMock);
} else if (args[0] == 'cursorContextChange') {
@@ -413,11 +387,33 @@ export function mockInputMethodEngine() {
console.warn("inputMethodEngine.createKeyboardDelegate interface mocked in the Previewer. How this interface works" +
" on the Previewer may be different from that on a real device.")
return KeyboardDelegateMock;
}
}
for (let Property of Properties) {
inputMethodEngine[Property] = NOTIFY + " " + Property
},
ENTER_KEY_TYPE_UNSPECIFIED: "[PC Preview] unknow ENTER_KEY_TYPE_UNSPECIFIED",
ENTER_KEY_TYPE_GO: "[PC Preview] unknow ENTER_KEY_TYPE_GO",
ENTER_KEY_TYPE_SEARCH: "[PC Preview] unknow ENTER_KEY_TYPE_SEARCH",
ENTER_KEY_TYPE_SEND: "[PC Preview] unknow ENTER_KEY_TYPE_SEND",
ENTER_KEY_TYPE_NEXT: "[PC Preview] unknow ENTER_KEY_TYPE_NEXT",
ENTER_KEY_TYPE_DONE: "[PC Preview] unknow ENTER_KEY_TYPE_DONE",
ENTER_KEY_TYPE_PREVIOUS: "[PC Preview] unknow ENTER_KEY_TYPE_PREVIOUS",
PATTERN_NULL: "[PC Preview] unknow PATTERN_NULL",
PATTERN_TEXT: "[PC Preview] unknow PATTERN_TEXT",
PATTERN_NUMBER: "[PC Preview] unknow PATTERN_NUMBER",
PATTERN_PHONE: "[PC Preview] unknow PATTERN_PHONE",
PATTERN_DATETIME: "[PC Preview] unknow PATTERN_DATETIME",
PATTERN_EMAIL: "[PC Preview] unknow PATTERN_EMAIL",
PATTERN_URI: "[PC Preview] unknow PATTERN_URI",
PATTERN_PASSWORD: "[PC Preview] unknow PATTERN_PASSWORD",
FLAG_SELECTING: "[PC Preview] unknow FLAG_SELECTING",
FLAG_SINGLE_LINE: "[PC Preview] unknow FLAG_SINGLE_LINE",
DISPLAY_MODE_PART: "[PC Preview] unknow DISPLAY_MODE_PART",
DISPLAY_MODE_FULL: "[PC Preview] unknow DISPLAY_MODE_FULL",
OPTION_ASCII: "[PC Preview] unknow OPTION_ASCII",
OPTION_NONE: "[PC Preview] unknow OPTION_NONE",
OPTION_AUTO_CAP_CHARACTERS: "[PC Preview] unknow OPTION_AUTO_CAP_CHARACTERS",
OPTION_AUTO_CAP_SENTENCES: "[PC Preview] unknow OPTION_AUTO_CAP_SENTENCES",
OPTION_AUTO_WORDS: "[PC Preview] unknow OPTION_AUTO_WORDS",
OPTION_MULTI_LINE: "[PC Preview] unknow OPTION_MULTI_LINE",
OPTION_NO_FULLSCREEN: "[PC Preview] unknow OPTION_NO_FULLSCREEN"
}
return inputMethodEngine
}
@@ -168,6 +168,7 @@ export function mockIntl() {
currencyDisplay: '[PC preview] unknow currencyDisplay',
unit: '[PC preview] unknow unit',
unitDisplay: '[PC preview] unknow unitDisplay',
unitUsage: '[PC preview] unknow unitUsage',
signDisplay: '[PC preview] unknow signDisplay',
compactDisplay: '[PC preview] unknow compactDisplay',
notation: '[PC preview] unknow notation',
@@ -199,10 +200,24 @@ export function mockIntl() {
minimumSignificantDigits: '[PC preview] unknow minimumSignificantDigits',
maximumSignificantDigits: '[PC preview] unknow maximumSignificantDigits',
}
const RelativeTimeFormatResolvedOptionsMock = {
const RelativeTimeFormatResolvedOptions = {
locale: '[PC preview] unknow locale',
style: '[PC preview] unknow style',
numeric: '[PC preview] unknow numeric',
numberingSystem: '[PC preview] unknow numberingSystem',
}
const RelativeTimeFormatInputOptions = {
localeMatcher: '[PC preview] unknow localeMatcher',
numeric: '[PC preview] unknow numeric',
style: '[PC preview] unknow style',
}
const LocaleOptions = {
calendar: '[PC preview] unknow calendar',
collation: '[PC preview] unknow collation',
hourCycle: '[PC preview] unknow hourCycle',
numberingSystem: '[PC preview] unknow numberingSystem',
numeric: '[PC preview] unknow numeric',
caseFirst: '[PC preview] unknow caseFirst',
}
return result;
}
@@ -792,6 +792,37 @@ export function mockMultimediaAudio() {
SHARE_MODE: 0,
INDEPENDENT_MODE: 1
},
DeviceRole: {
INPUT_DEVICE: 1,
OUTPUT_DEVICE: 2
},
DeviceType: {
INVALID: 0,
EARPIECE: 1,
SPEAKER: 2,
WIRED_HEADSET: 3,
WIRED_HEADPHONES: 4,
BLUETOOTH_SCO: 7,
BLUETOOTH_A2DP: 8,
MIC: 15,
USB_HEADSET: 22
},
InterruptHint: {
INTERRUPT_HINT_NONE: 0,
INTERRUPT_HINT_RESUME: 1,
INTERRUPT_HINT_PAUSE: 2,
INTERRUPT_HINT_STOP: 3,
INTERRUPT_HINT_DUCK: 4,
INTERRUPT_HINT_UNDUCK: 5
},
InterruptActionType: {
TYPE_ACTIVATED: 0,
TYPE_INTERRUPT: 1
},
DeviceChangeType: {
CONNECT: 0,
DISCONNECT: 1
},
getAudioManager: function () {
console.warn("audio.getAudioManager interface mocked in the Previewer." +
" How this interface works on the Previewer may be different from that on a real device.")
@@ -0,0 +1,436 @@
/*
* Copyright (c) 2022 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import { paramMock } from "../utils"
export function mockMultimediaAVSession() {
const AVMetadata = {
assetId: "[PC Preview] unknow assetId",
title: "[PC Preview] unknow title",
artist: "[PC Preview] unknow artist",
author: "[PC Preview] unknow author",
album: "[PC Preview] unknow album",
writer: "[PC Preview] unknow writer",
composer: "[PC Preview] unknow composer",
duration: "[PC Preview] unknow duration",
mediaImage: "[PC Preview] unknow mediaImage",
publishDate: "[PC Preview] unknow publishDate",
subtitle: "[PC Preview] unknow subtitle",
description: "[PC Preview] unknow description",
lyric: "[PC Preview] unknow lyric",
previousAssetId: "[PC Preview] unknow previousAssetId",
nextAssetId: "[PC Preview] unknow nextAssetId"
}
const AVPlaybackState = {
state: "[PC Preview] unknow state",
speed: "[PC Preview] unknow speed",
position: PlaybackPosition,
bufferedTime: "[PC Preview] unknow bufferedTime",
loopMode: "[PC Preview] unknow loopMode",
isFavorite: "[PC Preview] unknow isFavorite"
}
const PlaybackPosition = {
elapsedTime: "[PC Preview] unknow elapsedTime",
updateTime: "[PC Preview] unknow updateTime"
}
const OutputDeviceInfo = {
isRemote: "[PC Preview] unknow isRemote",
deviceId: [paramMock.paramStringMock],
deviceName: [paramMock.paramStringMock]
}
const AVSessionDescriptor = {
sessionId: "[PC Preview] unknow sessionId",
type: "[PC Preview] unknow type",
sessionTag: "[PC Preview] unknow sessionTag",
elementName: "[PC Preview] unknow elementName",
isActive: "[PC Preview] unknow isActive",
isTopSession: "[PC Preview] unknow isTopSession",
outputDevice:
"[PC Preview] unknow outputDevice"
}
const AVControlCommandType = ['play', 'pause', 'stop', 'playNext', 'playPrevious', 'fastForward', 'rewind', 'seek', 'setSpeed', 'setLoopMode', 'toggleFavorite'];
const AVSession = {
sessionId: "[PC Preview] unknow sessionId",
setAVMetadata: function (...args) {
console.warn("AVSession.setAVMetadata interface mocked in the Previewer. How this interface works on the Previewer" +
" may be different from that on a real device.")
const len = args.length
if (typeof args[len - 1] === 'function') {
args[len - 1].call(this, paramMock.businessErrorMock);
} else {
return new Promise((resolve, reject) => {
resolve();
})
}
},
setAVPlaybackState: function (...args) {
console.warn("AVSession.setAVPlaybackState interface mocked in the Previewer. How this interface works on the Previewer" +
" may be different from that on a real device.")
const len = args.length
if (typeof args[len - 1] === 'function') {
args[len - 1].call(this, paramMock.businessErrorMock);
} else {
return new Promise((resolve, reject) => {
resolve();
})
}
},
setLaunchAbility: function (...args) {
console.warn("AVSession.setLaunchAbility interface mocked in the Previewer. How this interface works on the Previewer" +
" may be different from that on a real device.")
const len = args.length
if (typeof args[len - 1] === 'function') {
args[len - 1].call(this, paramMock.businessErrorMock);
} else {
return new Promise((resolve, reject) => {
resolve();
})
}
},
setAudioStreamId: function (...args) {
console.warn("AVSession.setAudioStreamId interface mocked in the Previewer. How this interface works on the Previewer" +
" may be different from that on a real device.")
const len = args.length
if (typeof args[len - 1] === 'function') {
args[len - 1].call(this, paramMock.businessErrorMock);
} else {
return new Promise((resolve, reject) => {
resolve();
})
}
},
getController: function (...args) {
console.warn("AVSession.getController interface mocked in the Previewer. How this interface works on the Previewer" +
" may be different from that on a real device.")
const len = args.length
if (typeof args[len - 1] === 'function') {
args[len - 1].call(this, paramMock.businessErrorMock, AVSessionController);
} else {
return new Promise((resolve, reject) => {
resolve(AVSessionController);
})
}
},
getOutputDevice: function (...args) {
console.warn("AVSession.getOutputDevice interface mocked in the Previewer. How this interface works on the Previewer" +
" may be different from that on a real device.")
const len = args.length
if (typeof args[len - 1] === 'function') {
args[len - 1].call(this, paramMock.businessErrorMock, OutputDeviceInfo);
} else {
return new Promise((resolve, reject) => {
resolve(OutputDeviceInfo);
})
}
},
on: function (...args) {
console.warn("AVSession.on interface mocked in the Previewer. How this interface works on the Previewer" +
" may be different from that on a real device.")
const len = args.length
if (args[0] == 'play' || args[0] == 'pause' ||args[0] == 'stop' ||args[0] == 'playNext'
||args[0] == 'playPrevious' ||args[0] == 'fastForward' ||args[0] == 'rewind') {
args[len - 1].call(this);
} else if(args[0] == 'seek' || args[0] == 'setSpeed') {
args[len - 1].call(this, paramMock.paramNumberMock);
} else if(args[0] == 'setLoopMode') {
var loopMode = "[PC Preview] unknow LoopMode";
args[len - 1].call(this, loopMode);
} else if(args[0] == 'toggleFavorite') {
args[len - 1].call(this, paramMock.paramStringMock);
} else if(args[0] == 'handleKeyEvent') {
args[len - 1].call(this, paramMock.paramObjectMock);
} else if(args[0] == 'outputDeviceChanged') {
args[len - 1].call(this, OutputDeviceInfo);
}
},
off: function (...args) {
console.warn("AVSession.off interface mocked in the Previewer. How this interface works on the Previewer" +
" may be different from that on a real device.")
},
activate: function (...args) {
console.warn("AVSession.activate interface mocked in the Previewer. How this interface works on the Previewer" +
" may be different from that on a real device.")
const len = args.length
if (typeof args[len - 1] === 'function') {
args[len - 1].call(this, paramMock.businessErrorMock);
} else {
return new Promise((resolve, reject) => {
resolve();
})
}
},
deactivate: function (...args) {
console.warn("AVSession.deactivate interface mocked in the Previewer. How this interface works on the Previewer" +
" may be different from that on a real device.")
const len = args.length
if (typeof args[len - 1] === 'function') {
args[len - 1].call(this, paramMock.businessErrorMock);
} else {
return new Promise((resolve, reject) => {
resolve();
})
}
},
destroy: function (...args) {
console.warn("AVSession.destroy interface mocked in the Previewer. How this interface works on the Previewer" +
" may be different from that on a real device.")
const len = args.length
if (typeof args[len - 1] === 'function') {
args[len - 1].call(this, paramMock.businessErrorMock);
} else {
return new Promise((resolve, reject) => {
resolve();
})
}
}
}
const AVSessionController = {
sessionId: "[PC Preview] unknow sessionId",
getAVPlaybackState: function (...args) {
console.warn("AVSessionController.getAVPlaybackState interface mocked in the Previewer. How this interface works on the Previewer" +
" may be different from that on a real device.")
const len = args.length
if (typeof args[len - 1] === 'function') {
args[len - 1].call(this, paramMock.businessErrorMock, AVPlaybackState);
} else {
return new Promise((resolve, reject) => {
resolve(AVPlaybackState);
})
}
},
getAVMetadata: function (...args) {
console.warn("AVSessionController.getAVMetadata interface mocked in the Previewer. How this interface works on the Previewer" +
" may be different from that on a real device.")
const len = args.length
if (typeof args[len - 1] === 'function') {
args[len - 1].call(this, paramMock.businessErrorMock, AVMetadata);
} else {
return new Promise((resolve, reject) => {
resolve(AVMetadata);
})
}
},
getOutputDevice: function (...args) {
console.warn("AVSessionController.getOutputDevice interface mocked in the Previewer. How this interface works on the Previewer" +
" may be different from that on a real device.")
const len = args.length
if (typeof args[len - 1] === 'function') {
args[len - 1].call(this, paramMock.businessErrorMock, OutputDeviceInfo);
} else {
return new Promise((resolve, reject) => {
resolve(OutputDeviceInfo);
})
}
},
sendAVKeyEvent: function (...args) {
console.warn("AVSessionController.sendAVKeyEvent interface mocked in the Previewer. How this interface works on the Previewer" +
" may be different from that on a real device.")
const len = args.length
if (typeof args[len - 1] === 'function') {
args[len - 1].call(this, paramMock.businessErrorMock);
} else {
return new Promise((resolve, reject) => {
resolve();
})
}
},
getLaunchAbility: function (...args) {
console.warn("AVSessionController.getLaunchAbility interface mocked in the Previewer. How this interface works on the Previewer" +
" may be different from that on a real device.")
const len = args.length
if (typeof args[len - 1] === 'function') {
args[len - 1].call(this, paramMock.businessErrorMock, paramMock.paramObjectMock);
} else {
return new Promise((resolve, reject) => {
resolve(paramMock.paramObjectMock);
})
}
},
getRealPlaybackPositionSync: function (...args) {
console.warn("AVSessionController.getRealPlaybackPositionSync interface mocked in the Previewer. How this interface works on the Previewer" +
" may be different from that on a real device.")
return paramMock.paramNumberMock;
},
isActive: function (...args) {
console.warn("AVSessionController.isActive interface mocked in the Previewer. How this interface works on the Previewer" +
" may be different from that on a real device.")
const len = args.length
if (typeof args[len - 1] === 'function') {
args[len - 1].call(this, paramMock.businessErrorMock, paramMock.paramBooleanMock);
} else {
return new Promise((resolve, reject) => {
resolve(paramMock.paramBooleanMock);
})
}
},
destroy: function (...args) {
console.warn("AVSessionController.destroy interface mocked in the Previewer. How this interface works on the Previewer" +
" may be different from that on a real device.")
const len = args.length
if (typeof args[len - 1] === 'function') {
args[len - 1].call(this, paramMock.businessErrorMock);
} else {
return new Promise((resolve, reject) => {
resolve();
})
}
},
getValidCommands: function (...args) {
console.warn("AVSessionController.getValidCommands interface mocked in the Previewer. How this interface works on the Previewer" +
" may be different from that on a real device.")
const len = args.length
if (typeof args[len - 1] === 'function') {
args[len - 1].call(this, paramMock.businessErrorMock, AVControlCommandType);
} else {
return new Promise((resolve, reject) => {
resolve(AVControlCommandType);
})
}
},
sendControlCommand: function (...args) {
console.warn("AVSessionController.sendControlCommand interface mocked in the Previewer. How this interface works on the Previewer" +
" may be different from that on a real device.")
const len = args.length
if (typeof args[len - 1] === 'function') {
args[len - 1].call(this, paramMock.businessErrorMock);
} else {
return new Promise((resolve, reject) => {
resolve();
})
}
},
on: function (...args) {
console.warn("AVSessionController.on interface mocked in the Previewer. How this interface works on the Previewer" +
" may be different from that on a real device.")
const len = args.length
if (args[0] == 'metadataChanged') {
args[len-1].call(this, AVMetadata);
} else if (args[0] == 'playbackStateChanged') {
args[len-1].call(this, AVPlaybackState);
} else if (args[0] == 'sessionDestroyed') {
args[len-1].call(this);
} else if (args[0] == 'activeStateChanged') {
args[len-1].call(this, paramMock.paramBooleanMock);
} else if (args[0] == 'validCommandChanged') {
args[len-1].call(this, AVControlCommandType);
} else if (args[0] == 'outputDeviceChanged') {
args[len-1].call(this, OutputDeviceInfo);
}
},
off: function (...args) {
console.warn("AVSessionController.off interface mocked in the Previewer. How this interface works on the Previewer" +
" may be different from that on a real device.")
}
}
const avsession = {
createAVSession: function (...args) {
console.warn("AVSession.createAVSession interface mocked in the Previewer. How this interface works on the Previewer" +
" may be different from that on a real device.")
const len = args.length
if (typeof args[len - 1] === 'function') {
args[len - 1].call(this, paramMock.businessErrorMock, AVSession);
} else {
return new Promise((resolve, reject) => {
resolve(AVSession);
})
}
},
getAllSessionDescriptors: function (...args) {
console.warn("AVSession.getAllSessionDescriptors interface mocked in the Previewer. How this interface works on the Previewer" +
" may be different from that on a real device.")
const len = args.length
var desArr = Array(AVSessionDescriptor);
if (typeof args[len - 1] === 'function') {
args[len - 1].call(this, paramMock.businessErrorMock, desArr);
} else {
return new Promise((resolve, reject) => {
resolve(desArr);
})
}
},
createController: function (...args) {
console.warn("AVSession.createController interface mocked in the Previewer. How this interface works on the Previewer" +
" may be different from that on a real device.")
const len = args.length
if (typeof args[len - 1] === 'function') {
args[len - 1].call(this, paramMock.businessErrorMock, AVSessionController);
} else {
return new Promise((resolve, reject) => {
resolve(AVSessionController);
})
}
},
castAudio: function (...args) {
console.warn("AVSession.castAudio interface mocked in the Previewer. How this interface works on the Previewer" +
" may be different from that on a real device.")
const len = args.length
if (typeof args[len - 1] === 'function') {
args[len - 1].call(this, paramMock.businessErrorMock);
} else {
return new Promise((resolve, reject) => {
resolve();
})
}
},
on: function (...args) {
console.warn("AVSession.on interface mocked in the Previewer. How this interface works on the Previewer" +
" may be different from that on a real device.")
const len = args.length
if (args[0] == 'sessionCreated' || args[0] == 'sessionDestroyed' || args[0] == 'topSessionChanged') {
args[len - 1].call(this, AVSessionDescriptor);
} else if (args[0] == 'sessionServiceDied') {
args[len - 1].call(this);
}
},
off: function (...args) {
console.warn("AVSession.off interface mocked in the Previewer. How this interface works on the Previewer" +
" may be different from that on a real device.")
},
sendSystemAVKeyEvent: function (...args) {
console.warn("AVSession.sendSystemAVKeyEvent interface mocked in the Previewer. How this interface works on the Previewer" +
" may be different from that on a real device.")
const len = args.length
if (typeof args[len - 1] === 'function') {
args[len - 1].call(this, paramMock.businessErrorMock);
} else {
return new Promise((resolve, reject) => {
resolve();
})
}
},
sendSystemControlCommand: function (...args) {
console.warn("AVSession.sendSystemControlCommand interface mocked in the Previewer. How this interface works on the Previewer" +
" may be different from that on a real device.")
const len = args.length
if (typeof args[len - 1] === 'function') {
args[len - 1].call(this, paramMock.businessErrorMock);
} else {
return new Promise((resolve, reject) => {
resolve();
})
}
}
}
return avsession
}
@@ -18,12 +18,10 @@ import { paramMock } from "../utils"
export function mockMultimediaCamera() {
const Camera = {
cameraId: '[PC preview] unknow pid',
cameraPosition: '[PC preview] unknow cameraPosition',
cameraType: '[PC preview] unknow cameraType',
connectionType: '[PC preview] unknow connectionType'
cameraPosition: CameraPosition,
cameraType: CameraType,
connectionType: ConnectionType
}
const FlashMode = '[PC preview] unknow flashMode'
const FocusMode = '[PC preview] unknow focusMode'
const multimediaCameraMock = {
getCameraManager: function (...args) {
console.warn('camera.getCameraManager interface mocked in the Previewer. How this interface works on the' +
@@ -62,7 +60,7 @@ export function mockMultimediaCamera() {
}
},
createPhotoOutput: function (...args) {
console.warn('camera.createPreviewOutput interface mocked in the Previewer. How this interface works on the' +
console.warn('camera.createPhotoOutput interface mocked in the Previewer. How this interface works on the' +
' Previewer may be different from that on a real device.');
const len = args.length;
if (typeof args[len - 1] === 'function') {
@@ -86,6 +84,16 @@ export function mockMultimediaCamera() {
}
},
}
const CameraStatus = {
CAMERA_STATUS_APPEAR: 0,
CAMERA_STATUS_DISAPPEAR: 1,
CAMERA_STATUS_AVAILABLE: 2,
CAMERA_STATUS_UNAVAILABLE: 3
}
const CameraStatusInfo = {
camera: Camera,
status: CameraStatus
}
const CameraManager = {
getCameras: function (...args) {
console.warn('CameraManager.getCameras interface mocked in the Previewer. How this interface works on the' +
@@ -114,8 +122,58 @@ export function mockMultimediaCamera() {
on: function (...args) {
console.warn('CameraManager.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] == 'cameraStatus'){
args[len - 1].call(this, paramMock.businessErrorMock, CameraStatusInfo);
}
}
}
}
const CameraPosition = {
CAMERA_POSITION_UNSPECIFIED: 0,
CAMERA_POSITION_BACK: 1,
CAMERA_POSITION_FRONT: 2
}
const CameraType = {
CAMERA_TYPE_UNSPECIFIED: 0,
CAMERA_TYPE_WIDE_ANGLE: 1,
CAMERA_TYPE_ULTRA_WIDE: 2,
CAMERA_TYPE_TELEPHOTO: 3,
CAMERA_TYPE_TRUE_DEPTH: 4
}
const ConnectionType = {
CAMERA_CONNECTION_BUILT_IN: 0,
CAMERA_CONNECTION_USB_PLUGIN: 1,
CAMERA_CONNECTION_REMOTE: 2
}
const Size = {
height: '[PC preview] unknow height',
width: '[PC preview] unknow width'
}
const CameraInputErrorCode = {
ERROR_UNKNOWN: -1
}
const CameraInputError = {
code: CameraInputErrorCode
}
const FlashMode = {
FLASH_MODE_CLOSE: 0,
FLASH_MODE_OPEN: 1,
FLASH_MODE_AUTO: 2,
FLASH_MODE_ALWAYS_OPEN: 3
}
const FocusMode = {
FOCUS_MODE_MANUAL: 0,
FOCUS_MODE_CONTINUOUS_AUTO: 1,
FOCUS_MODE_AUTO: 2,
FOCUS_MODE_LOCKED: 3
}
const FocusState = {
FOCUS_STATE_SCAN: 0,
FOCUS_STATE_FOCUSED: 1,
FOCUS_STATE_UNFOCUSED: 2
}
const CameraInput = {
getCameraId: function (...args) {
console.warn('CameraInput.getCameraId interface mocked in the Previewer. How this interface works on the' +
@@ -226,7 +284,7 @@ export function mockMultimediaCamera() {
}
},
getZoomRatio: function (...args) {
console.warn('CameraInput.getZoomRatioRange interface mocked in the Previewer. How this interface works on the' +
console.warn('CameraInput.getZoomRatio interface mocked in the Previewer. How this interface works on the' +
' Previewer may be different from that on a real device.');
const len = args.length;
if (typeof args[len - 1] === 'function') {
@@ -264,8 +322,22 @@ export function mockMultimediaCamera() {
on: function (...args) {
console.warn('CameraInput.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] == 'focusStateChange'){
args[len - 1].call(this, paramMock.businessErrorMock, FocusState);
} else if (args[0] == 'error') {
args[len - 1].call(this, paramMock.businessErrorMock, CameraInputError);
}
}
}
}
const CaptureSessionErrorCode = {
ERROR_UNKNOWN: -1
}
const CaptureSessionError = {
code: CaptureSessionErrorCode
}
const CaptureSession = {
beginConfig: function (...args) {
console.warn('CaptureSession.beginConfig interface mocked in the Previewer. How this interface works on the' +
@@ -328,7 +400,7 @@ export function mockMultimediaCamera() {
}
},
removeOutput: function (...args) {
console.warn('CaptureSession.removeInput interface mocked in the Previewer. How this interface works on the' +
console.warn('CaptureSession.removeOutput interface mocked in the Previewer. How this interface works on the' +
' Previewer may be different from that on a real device.');
const len = args.length;
if (typeof args[len - 1] === 'function') {
@@ -378,8 +450,20 @@ export function mockMultimediaCamera() {
on: function (...args) {
console.warn('CaptureSession.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] == 'error'){
args[len - 1].call(this, paramMock.businessErrorMock, CaptureSessionError);
}
}
}
}
const PreviewOutputErrorCode = {
ERROR_UNKNOWN: -1
}
const PreviewOutputError = {
code: PreviewOutputErrorCode
}
const PreviewOutput = {
release: function (...args) {
console.warn('PreviewOutput.release interface mocked in the Previewer. How this interface works on the' +
@@ -394,10 +478,49 @@ export function mockMultimediaCamera() {
}
},
on: function (...args) {
console.warn('PreviewOutput.release interface mocked in the Previewer. How this interface works on the' +
console.warn('PreviewOutput.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] == 'frameStart'){
args[len - 1].call(this, paramMock.businessErrorMock);
} else if (args[0] == 'frameEnd') {
args[len - 1].call(this, paramMock.businessErrorMock);
} else if (args[0] == 'error') {
args[len - 1].call(this, paramMock.businessErrorMock, PreviewOutputError);
}
}
},
}
const ImageRotation = {
ROTATION_0: 0,
ROTATION_90: 90,
ROTATION_180: 180,
ROTATION_270: 270
}
const QualityLevel = {
QUALITY_LEVEL_HIGH: 0,
QUALITY_LEVEL_MEDIUM: 1,
QUALITY_LEVEL_LOW: 2
}
const PhotoCaptureSetting = {
quality:QualityLevel,
rotation: ImageRotation
}
const FrameShutterInfo = {
captureId: '[PC preview] unknow captureId',
timestamp: '[PC preview] unknow timestamp'
}
const CaptureEndInfo = {
captureId: '[PC preview] unknow captureId',
frameCount: '[PC preview] unknow frameCount'
}
const PhotoOutputErrorCode = {
ERROR_UNKNOWN: -1
}
const PhotoOutputError = {
code: PhotoOutputErrorCode
}
const PhotoOutput = {
capture: function (...args) {
console.warn('PhotoOutput.capture interface mocked in the Previewer. How this interface works on the' +
@@ -426,8 +549,26 @@ export function mockMultimediaCamera() {
on: function (...args) {
console.warn('PhotoOutput.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] == 'captureStart'){
args[len - 1].call(this, paramMock.businessErrorMock, paramMock.paramNumberMock);
} else if (args[0] == 'frameShutter') {
args[len - 1].call(this, paramMock.businessErrorMock, FrameShutterInfo);
} else if (args[0] == 'captureEnd') {
args[len - 1].call(this, paramMock.businessErrorMock, CaptureEndInfo);
} else if (args[0] == 'error') {
args[len - 1].call(this, paramMock.businessErrorMock, PhotoOutputError);
}
}
}
}
const VideoOutputErrorCode = {
ERROR_UNKNOWN: -1
}
const VideoOutputError = {
code: VideoOutputErrorCode
}
const VideoOutput = {
start: function (...args) {
console.warn('VideoOutput.start interface mocked in the Previewer. How this interface works on the' +
@@ -468,6 +609,16 @@ export function mockMultimediaCamera() {
on: function (...args) {
console.warn('VideoOutput.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] == 'frameStart'){
args[len - 1].call(this, paramMock.businessErrorMock);
} else if (args[0] == 'frameEnd') {
args[len - 1].call(this, paramMock.businessErrorMock);
} else if (args[0] == 'error') {
args[len - 1].call(this, paramMock.businessErrorMock, VideoOutputError);
}
}
}
}
return multimediaCameraMock
@@ -95,6 +95,95 @@ export const PixelMapMock = {
" may be different from that on a real device.")
return paramMock.paramNumberMock
},
getDensity: function (...args) {
console.warn("PixelMap.getDensity interface mocked in the Previewer. How this interface works on the Previewer" +
" may be different from that on a real device.")
return paramMock.paramNumberMock
},
opacity: function (...args) {
console.warn("PixelMap.opacity interface mocked in the Previewer. How this interface works on the Previewer" +
" may be different from 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();
})
}
},
createAlphaPixelmap: function (...args) {
console.warn("PixelMap.createAlphaPixelmap interface mocked in the Previewer. How this interface works on the Previewer" +
" may be different from that on a real device.")
const len = args.length
if (len > 0 && typeof args[len - 1] === 'function') {
args[len - 1].call(this, paramMock.businessErrorMock,PixelMapMock);
} else {
return new Promise((resolve, reject) => {
resolve(PixelMapMock);
})
}
},
scale: function (...args) {
console.warn("PixelMap.scale interface mocked in the Previewer. How this interface works on the Previewer" +
" may be different from 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();
})
}
},
translate: function (...args) {
console.warn("PixelMap.translate interface mocked in the Previewer. How this interface works on the Previewer" +
" may be different from 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();
})
}
},
rotate: function (...args) {
console.warn("PixelMap.rotate interface mocked in the Previewer. How this interface works on the Previewer" +
" may be different from 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();
})
}
},
flip: function (...args) {
console.warn("PixelMap.flip interface mocked in the Previewer. How this interface works on the Previewer" +
" may be different from 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();
})
}
},
crop: function (...args) {
console.warn("PixelMap.flip interface mocked in the Previewer. How this interface works on the Previewer" +
" may be different from 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();
})
}
},
release: function (...args) {
console.warn("PixelMap.release interface mocked in the Previewer. How this interface works on the Previewer" +
" may be different from that on a real device.")
@@ -151,6 +240,11 @@ export function mockMultimediaImage() {
alphaType: "[PC Preview] unknow alphaType",
scaleMode: "[PC Preview] unknow scaleMode"
}
const SourceOptionsMock = {
sourceDensity:"[PC Preview] unknow sourceDensity",
sourcePixelFormat:"[PC Preview] unknow sourcePixelFormat",
sourceSize:SizeMock
}
const ImageSourceMock = {
getImageInfo: function (...args) {
@@ -201,17 +295,41 @@ export function mockMultimediaImage() {
})
}
},
release: function (...args) {
console.warn("ImageSource.release interface mocked in the Previewer. How this interface works on the Previewer" +
" may be different from that on a real device.")
const len = args.length
if (len > 0 && typeof args[len - 1] === 'function') {
args[len - 1].call(this, paramMock.businessErrorMock);
} else {
return new Promise((resolve, reject) => {
resolve();
})
}
modifyImageProperty: function (...args) {
console.warn("ImageSource.modifyImageProperty interface mocked in the Previewer. How this interface works on the Previewer" +
" may be different from 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();
})
}
},
updateData: function (...args) {
console.warn("ImageSource.updateData interface mocked in the Previewer. How this interface works on the Previewer" +
" may be different from 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();
})
}
},
release: function (...args) {
console.warn("ImageSource.release interface mocked in the Previewer. How this interface works on the Previewer" +
" may be different from that on a real device.")
const len = args.length
if (len > 0 && typeof args[len - 1] === 'function') {
args[len - 1].call(this, paramMock.businessErrorMock);
} else {
return new Promise((resolve, reject) => {
resolve();
})
}
},
supportedFormats: "[PC Preview] unknow supportedFormats"
}
@@ -299,8 +417,8 @@ export function mockMultimediaImage() {
})
}
},
readLatestImage: function (...args) {
console.warn("ImageReceiver.readLatestImage interface mocked in the Previewer. How this interface works on the Previewer" +
readNextImage: function (...args) {
console.warn("ImageReceiver.readNextImage interface mocked in the Previewer. How this interface works on the Previewer" +
" may be different from that on a real device.")
const len = args.length
if (len > 0 && typeof args[len - 1] === 'function') {
@@ -355,8 +473,8 @@ export function mockMultimediaImage() {
UNPREMUL: 3,
},
ScaleMode: {
FIT_TARGET_SIZE: 0,
CENTER_CROP: 1,
FIT_TARGET_SIZE: 2,
},
ComponentType: {
YUV_Y: 1,
@@ -381,6 +499,11 @@ export function mockMultimediaImage() {
" on the Previewer may be different from that on a real device.")
return ImageSourceMock;
},
CreateIncrementalSource: function () {
console.warn("image.CreateIncrementalSource interface mocked in the Previewer. How this interface works" +
" on the Previewer may be different from that on a real device.")
return ImageSourceMock;
},
createImagePacker: function () {
console.warn("image.createImagePacker interface mocked in the Previewer. How this interface works" +
" on the Previewer may be different from that on a real device.")
@@ -58,7 +58,9 @@ export function mockMultimediaMedia() {
}
},
src: '[PC Preview] unknow src',
fdSrc: AVFileDescriptor,
loop: '[PC Preview] unknow loop',
audioInterruptMode: InterruptMode,
currentTime: '[PC Preview] unknow currentTime',
duration: '[PC Preview] unknow duration',
state: '[PC Preview] unknow state',
@@ -221,12 +223,15 @@ export function mockMultimediaMedia() {
}
const videoPlayerMock = {
url: '[PC Preview] unknow url',
fdSrc: AVFileDescriptor,
loop: '[PC Preview] unknow loop',
currentTime: '[PC Preview] unknow currentTime',
duration: '[PC Preview] unknow duration',
state: '[PC Preview] unknow state',
width: '[PC Preview] unknow width',
height: '[PC Preview] unknow height',
audioInterruptMode: InterruptMode,
videoScaleType: mediaMock.VideoScaleType,
setDisplaySurface: function (...args) {
console.warn("VideoPlayer.setDisplaySurface interface mocked in the Previewer. How this interface works on the Previewer" +
" may be different from that on a real device.")
@@ -359,11 +364,28 @@ export function mockMultimediaMedia() {
});
}
},
selectBitrate: function (...args) {
console.warn("VideoPlayer.selectBitrate interface mocked in the Previewer. How this interface works on the Previewer" +
" may be different from that on a real device.")
const len = args.length;
if (typeof args[len - 1] === 'function') {
args[len - 1].call(this, paramMock.paramNumberMock, paramMock.paramNumberMock);
} else {
return new Promise((resolve) => {
resolve(paramMock.paramNumberMock);
});
}
},
on: function (...args) {
console.warn("VideoPlayer.on interface mocked in the Previewer. How this interface works on the Previewer" +
" may be different from that on a real device.")
},
}
const AVFileDescriptorMock = {
fd: '[PC Preview] unknow fd',
offset: '[PC Preview] unknow audioChannels',
length: '[PC Preview] unknow audioCodec',
}
const videoRecorderProfileMock = {
audioBitrate: '[PC Preview] unknow audioBitrate',
audioChannels: '[PC Preview] unknow audioChannels',
@@ -385,9 +407,13 @@ export function mockMultimediaMedia() {
location: locationMock,
}
const mediaDescriptionMock = {
key: '[PC Preview] unknow key',
"key": 'paramMock.paramObjectMock',
}
const multimediaMediaMock = {
const InterruptModeMock = {
SHARE_MODE: 0,
INDEPENDENT_MODE: 1
}
const mediaMock = {
MediaErrorCode : {
MSERR_OK: 0,
MSERR_NO_MEMORY: 1,
@@ -437,6 +463,10 @@ export function mockMultimediaMedia() {
SPEED_FORWARD_1_75_X: 3,
SPEED_FORWARD_2_00_X: 4,
},
VideoScaleType : {
VIDEO_SCALE_TYPE_FIT: 0,
VIDEO_SCALE_TYPE_FIT_CROP: 1,
},
ContainerFormatType : {
CFT_MPEG_4: "mp4",
CFT_MPEG_4A: "m4a",
@@ -507,5 +537,5 @@ export function mockMultimediaMedia() {
}
},
}
return multimediaMediaMock;
return mediaMock;
}
@@ -1,387 +1,288 @@
/*
* 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
}
/*
* Copyright (c) 2021-2022 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import { paramMock } from "../utils"
export const NetCap = {
NET_CAPABILITY_MMS: 0,
NET_CAPABILITY_NOT_METERED: 11,
NET_CAPABILITY_INTERNET: 12,
NET_CAPABILITY_NOT_VPN: 15,
NET_CAPABILITY_VALIDATED: 16
};
export const NetBearType = {
BEARER_CELLULAR: 0,
BEARER_WIFI: 1,
BEARER_ETHERNET: 3
};
export function mockConnection() {
const NetSpecifier = {
netCapabilities: NetCapabilities,
bearerPrivateIdentifier: '[PC preview] unknow bearerPrivateIdentifier'
}
const NetCapabilities = {
linkUpBandwidthKbps: '[PC preview] unknow linkUpBandwidthKbps',
linkDownBandwidthKbps: '[PC preview] unknow linkDownBandwidthKbps',
networkCap:[NetCap],
bearerTypes:[NetBearType]
}
const ConnectionProperties = {
interfaceName: '[PC preview] unknow interfaceName',
domains: '[PC preview] unknow domains',
linkAddresses: [LinkAddress],
dnses: [NetAddress],
routes: [RouteInfo],
mtu: '[PC preview] unknow mtu'
}
const LinkAddress = {
address: NetAddress,
prefixLength: '[PC preview] unknow prefixLength'
}
const NetAddress = {
address: '[PC preview] unknow address',
family: '[PC preview] unknow family',
port: '[PC preview] unknow port'
}
const RouteInfo = {
interface: '[PC preview] unknow interface',
destination: LinkAddress,
gateway: NetAddress,
hasGateway: '[PC preview] unknow hasGateway',
isDefaultRoute: '[PC preview] unknow isDefaultRoute'
}
const NetConnection = {
on: function (...args) {
console.warn("NetConnection.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, NetHandle);
} else if (args[0] === 'netBlockStatusChange') {
var array = new Array(NetHandle, paramMock.paramBooleanMock);
args[len - 1].call(this, array);
} else if (args[0] === 'netCapabilitiesChange') {
var array = new Array(NetHandle, NetCapabilities);
args[len - 1].call(this, array);
} else if (args[0] === 'netConnectionPropertiesChange') {
var array = new Array(NetHandle, ConnectionProperties);
args[len - 1].call(this, array);
} else if (args[0] === 'netLost') {
args[len - 1].call(this, NetHandle);
} else if (args[0] === 'netUnavailable') {
args[len - 1].call(this);
}
}
},
register: function (...args) {
console.warn("NetConnection.register interface mocked in the Previewer. How this interface works on the Previewer" +
" may be different from that on a real device.")
const len = args.length
if (len > 0 && typeof args[len - 1] === 'function') {
args[len - 1].call(this, paramMock.businessErrorMock)
}
},
unregister: function (...args) {
console.warn("NetConnection.unregister interface mocked in the Previewer. How this interface works on the Previewer" +
" may be different from that on a real device.")
const len = args.length
if (len > 0 && typeof args[len - 1] === 'function') {
args[len - 1].call(this, paramMock.businessErrorMock)
}
}
}
const NetHandle = {
netId: '[PC preview] unknow netId',
getAddressesByName: function (...args) {
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 (len > 0 && typeof args[len - 1] === 'function') {
args[len - 1].call(this, paramMock.businessErrorMock, [NetAddress])
} else {
return new Promise((resolve, reject) => {
resolve([NetAddress])
})
}
},
getAddressByName: function (...args) {
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 (len > 0 && typeof args[len - 1] === 'function') {
args[len - 1].call(this, paramMock.businessErrorMock, NetAddress)
} else {
return new Promise((resolve, reject) => {
resolve(NetAddress)
})
}
}
}
const connection = {
NetCap,
NetBearType,
createNetConnection: function () {
console.warn("connection.createNetConnection interface mocked in the Previewer. How this interface works on the Previewer" +
" may be different from that on a real device.")
return NetConnection;
},
getDefaultNet: function (...args) {
console.warn("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) => {
resolve(NetHandle)
})
}
},
getAllNets: function (...args) {
console.warn("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) => {
resolve([NetHandle])
})
}
},
getConnectionProperties: function (...args) {
console.warn("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) => {
resolve(ConnectionProperties)
})
}
},
getNetCapabilities: function (...args) {
console.warn("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) => {
resolve(NetCapabilities)
})
}
},
hasDefaultNet: function (...args) {
console.warn("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) => {
resolve(paramMock.paramBooleanMock)
})
}
},
enableAirplaneMode: function (...args) {
console.warn("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) => {
resolve()
})
}
},
disableAirplaneMode: function (...args) {
console.warn("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) => {
resolve()
})
}
},
reportNetConnected: function (...args) {
console.warn("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) => {
resolve()
})
}
},
reportNetDisconnected: function (...args) {
console.warn("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) => {
resolve()
})
}
},
getAddressesByName: function (...args) {
console.warn("connection.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) => {
resolve([NetAddress])
})
}
},
};
return connection;
}
@@ -15,65 +15,72 @@
import { paramMock } from "../utils"
export const RequestMethod = {
OPTIONS: "OPTIONS",
GET: "GET",
HEAD: "HEAD",
POST: "POST",
PUT: "PUT",
DELETE: "DELETE",
TRACE: "TRACE",
CONNECT: "CONNECT"
};
export const ResponseCode = {
OK: 200,
CREATED: 201,
ACCEPTED: 202,
NOT_AUTHORITATIVE: 203,
NO_CONTENT: 204,
RESET: 205,
PARTIAL: 206,
MULT_CHOICE: 300,
MOVED_PERM: 301,
MOVED_TEMP: 302,
SEE_OTHER: 303,
NOT_MODIFIED: 304,
USE_PROXY: 305,
BAD_REQUEST: 400,
UNAUTHORIZED: 401,
PAYMENT_REQUIRED: 402,
FORBIDDEN: 403,
NOT_FOUND: 404,
BAD_METHOD: 405,
NOT_ACCEPTABLE: 406,
PROXY_AUTH: 407,
CLIENT_TIMEOUT: 408,
CONFLICT: 409,
GONE: 410,
LENGTH_REQUIRED: 411,
PRECON_FAILED: 412,
ENTITY_TOO_LARGE: 413,
REQ_TOO_LONG: 414,
UNSUPPORTED_TYPE: 415,
INTERNAL_ERROR: 500,
NOT_IMPLEMENTED: 501,
BAD_GATEWAY: 502,
UNAVAILABLE: 503,
GATEWAY_TIMEOUT: 504,
VERSION: 505
};
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 = {
const HttpResponse = {
result: "[PC Preview] unknow result",
responseCode: "[PC Preview] unknow responseCode",
header: "[PC Preview] unknow header"
responseCode: ResponseCode,
header: "[PC Preview] unknow header",
cookies: "[PC Preview] unknow cookies"
}
const HttpRequestMock = {
const HttpRequest = {
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);
args[len - 1].call(this, paramMock.businessErrorMock, HttpResponse);
} else {
return new Promise((resolve, reject) => {
resolve(HttpResponseMock);
resolve(HttpResponse);
})
}
},
@@ -86,7 +93,11 @@ export function mockHttp() {
" be different 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);
if (args[0] === 'headerReceive') {
args[len - 1].call(this, paramMock.businessErrorMock, paramMock.paramObjectMock);
} else if (args[0] === 'headersReceive') {
args[len - 1].call(this, paramMock.paramObjectMock);
}
}
},
off: function (...args) {
@@ -94,40 +105,40 @@ export function mockHttp() {
" be different 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);
if (args[0] === 'headerReceive') {
args[len - 1].call(this, paramMock.businessErrorMock, paramMock.paramObjectMock);
} else if (args[0] === 'headersReceive') {
args[len - 1].call(this, paramMock.paramObjectMock);
}
}
},
once: function (...args) {
console.warn("HttpRequest.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') {
args[len - 1].call(this, paramMock.paramObjectMock);
}
}
}
const HttpRequestOptions = {
method: RequestMethod,
extraData: "[PC Preview] unknow extraData",
header: "[PC Preview] unknow header",
readTimeout: "[PC Preview] unknow readTimeout",
connectTimeout: "[PC Preview] unknow connectTimeout"
}
const http = {
RequestMethod,
ResponseCode,
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;
return HttpRequest;
},
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
return http;
}
@@ -21,17 +21,20 @@ export function mockSocket() {
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" +
@@ -99,12 +102,11 @@ export function mockSocket() {
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
});
args[len - 1].call(this, {ArrayBuffer, SocketRemoteInfo});
} else if (args[0] === 'listening') {
args[len - 1].call(this, paramMock.businessErrorMock);
args[len - 1].call(this);
} else if (args[0] === 'close') {
args[len - 1].call(this);
} else if (args[0] === 'error') {
args[len - 1].call(this, paramMock.businessErrorMock);
}
@@ -116,12 +118,11 @@ export function mockSocket() {
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
});
args[len - 1].call(this, {ArrayBuffer, SocketRemoteInfo});
} else if (args[0] === 'listening') {
args[len - 1].call(this, paramMock.businessErrorMock);
args[len - 1].call(this);
} else if (args[0] === 'close') {
args[len - 1].call(this);
} else if (args[0] === 'error') {
args[len - 1].call(this, paramMock.businessErrorMock);
}
@@ -220,12 +221,11 @@ export function mockSocket() {
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);
args[len - 1].call(this, {ArrayBuffer, SocketRemoteInfo});
} else if (args[0] === 'connect') {
args[len - 1].call(this);
} else if (args[0] === 'close') {
args[len - 1].call(this);
} else if (args[0] === 'error') {
args[len - 1].call(this, paramMock.businessErrorMock);
}
@@ -237,18 +237,53 @@ export function mockSocket() {
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);
args[len - 1].call(this, {ArrayBuffer, SocketRemoteInfo});
} else if (args[0] === 'connect') {
args[len - 1].call(this);
} else if (args[0] === 'close') {
args[len - 1].call(this);
} else if (args[0] === 'error') {
args[len - 1].call(this, paramMock.businessErrorMock);
}
}
}
}
const UDPSendOptions = {
data: "[PC Preview] unknow data",
address: NetAddress
}
const ExtraOptionsBase = {
receiveBufferSize: "[PC Preview] unknow receiveBufferSize",
sendBufferSize: "[PC Preview] unknow sendBufferSize",
reuseAddress: "[PC Preview] unknow reuseAddress",
socketTimeout: "[PC Preview] unknow socketTimeout"
}
const UDPExtraOptions = {
broadcast: "[PC Preview] unknow broadcast"
}
const TCPConnectOptions = {
address: NetAddress,
timeout: "[PC Preivew] unknow timeout",
}
const TCPSendOptions = {
data: "[PC Preview] unknow data",
encoding: "[PC Preview] unknow encoding",
}
const TCPExtraOptions = {
keepAlive: "[PC Preview] unknow keepAlive",
OOBInline: "[PC Preview] unknow OOBInline",
TCPNoDelay: "[PC Preview] unknow TCPNoDelay",
socketLinger: {
on: "[PC Preview] unknow on",
linger: "[PC Preview] unknow linger"
}
}
const socket = {
constructUDPSocketInstance: function () {
console.warn("net.socket.constructUDPSocketInstance interface mocked in the Previewer. How this interface works on the Previewer" +
@@ -261,5 +296,6 @@ export function mockSocket() {
return TCPSocket;
}
}
return socket
}
return socket;
}
@@ -16,7 +16,13 @@
import { paramMock } from "../utils"
export function mockWebSocket() {
global.systemplugin.net = {}
const WebSocketRequestOptions = {
header: "[PC Preview] unknow header"
}
const WebSocketCloseOptions = {
code: "[PC Preview] unknow code",
reason: "[PC Preview] unknow reason"
}
const WebSocketMock = {
connect: function (...args) {
console.warn("WebSocket.connect interface mocked in the Previewer. How this interface works on the Previewer" +
@@ -101,4 +107,4 @@ export function mockWebSocket() {
}
}
return webSocket
}
}
@@ -419,6 +419,9 @@ export function mockNotification() {
});
}
},
SlotType,
ContentType,
SlotLevel,
subscribe: function (...args) {
console.warn('notification.subscribe interface mocked in the Previewer. How this interface works on the' +
' Previewer may be different from that on a real device.');
@@ -778,7 +781,13 @@ export function mockNotification() {
resolve(paramMock.paramBooleanMock);
})
}
}
},
BundleOption,
NotificationKey,
DoNotDisturbType,
DoNotDisturbDate,
DeviceRemindType,
SourceType
}
return notification
}
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2021 Huawei Device Co., Ltd.
* Copyright (c) 2021-2022 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
@@ -20,10 +20,160 @@ export function mockPasteBoard() {
getPrimaryText: function () {
console.warn("PasteData.getPrimaryText interface mocked in the Previewer. How this interface works on the" +
" Previewer may be different from that on a real device.")
return "[PC Preview] unknow primarytext"
return paramMock.paramStringMock
},
addHtmlRecord: function (...args) {
console.warn("PasteData.addHtmlRecord interface mocked in the Previewer. How this interface works on the" +
" Previewer may be different from that on a real device.")
},
addWantRecord: function (...args) {
console.warn("PasteData.addWantRecord interface mocked in the Previewer. How this interface works on the" +
" Previewer may be different from that on a real device.")
},
addRecord: function (...args) {
console.warn("PasteData.addRecord interface mocked in the Previewer. How this interface works on the" +
" Previewer may be different from that on a real device.")
},
addTextRecord: function (...args) {
console.warn("PasteData.addTextRecord interface mocked in the Previewer. How this interface works on the" +
" Previewer may be different from that on a real device.")
},
addUriRecord: function (...args) {
console.warn("PasteData.addUriRecord interface mocked in the Previewer. How this interface works on the" +
" Previewer may be different from that on a real device.")
},
getMimeTypes: function () {
console.warn("PasteData.getMimeTypes interface mocked in the Previewer. How this interface works on the" +
" Previewer may be different from that on a real device.");
return new Array(paramMock.paramStringMock);
},
getPrimaryHtml: function () {
console.warn("PasteData.getPrimaryHtml interface mocked in the Previewer. How this interface works on the" +
" Previewer may be different from that on a real device.")
return paramMock.paramStringMock
},
getPrimaryWant: function () {
console.warn("PasteData.getPrimaryWant interface mocked in the Previewer. How this interface works on the" +
" Previewer may be different from that on a real device.")
return "[PC Preview] unknow getPrimaryWant"
},
getPrimaryMimeType: function () {
console.warn("PasteData.getPrimaryMimeType interface mocked in the Previewer. How this interface works on the" +
" Previewer may be different from that on a real device.")
return paramMock.paramStringMock
},
getPrimaryUri: function () {
console.warn("PasteData.getPrimaryUri interface mocked in the Previewer. How this interface works on the" +
" Previewer may be different from that on a real device.")
return paramMock.paramStringMock
},
getProperty: function () {
console.warn("PasteData.getProperty interface mocked in the Previewer. How this interface works on the" +
" Previewer may be different from that on a real device.")
return PasteDataPropertyMock;
},
getRecordAt: function (...args) {
console.warn("PasteData.getRecordAt interface mocked in the Previewer. How this interface works on the" +
" Previewer may be different from that on a real device.")
return PasteDataRecordMock;
},
getRecordCount: function () {
console.warn("PasteData.getRecordCount interface mocked in the Previewer. How this interface works on the" +
" Previewer may be different from that on a real device.")
return paramMock.paramNumberMock
},
getTag: function () {
console.warn("PasteData.getTag interface mocked in the Previewer. How this interface works on the" +
" Previewer may be different from that on a real device.")
return paramMock.paramStringMock
},
hasMimeType: function (...args) {
console.warn("PasteData.hasMimeType interface mocked in the Previewer. How this interface works on the" +
" Previewer may be different from that on a real device.")
return paramMock.paramBooleanMock
},
removeRecordAt: function (...args) {
console.warn("PasteData.removeRecordAt interface mocked in the Previewer. How this interface works on the" +
" Previewer may be different from that on a real device.")
return paramMock.paramBooleanMock
},
replaceRecordAt: function (...args) {
console.warn("PasteData.replaceRecordAt interface mocked in the Previewer. How this interface works on the" +
" Previewer may be different from that on a real device.")
return paramMock.paramBooleanMock
}
}
const PasteDataRecordMock = {
htmlText: '[PC preview] unknow htmlText',
want: '[PC preview] unknow want',
mimeType: '[PC preview] unknow mimeType',
plainText: '[PC preview] unknow plainText',
uri: '[PC preview] unknow uri',
convertToText: function (...args) {
console.warn("PasteDataRecord.convertToText interface mocked in the Previewer. How this interface works on the" +
" Previewer may be different 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);
})
}
}
}
const PasteDataPropertyMock = {
additions: '[PC preview] unknow additions',
mimeTypes: new Array('[PC preview] unknow MIMETYPE_TEXT_PLAIN'),
tag: '[PC preview] unknow tag',
timestamp: '[PC preview] unknow timestamp',
localOnly: '[PC preview] unknow localOnly',
}
const SystemPasteboardMock = {
on: function (...args) {
console.warn("SystemPasteboard.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] == 'update') {
args[len - 1].call(this);
}
}
},
off: function (...args) {
console.warn("SystemPasteboard.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] == 'update') {
args[len - 1].call(this);
}
}
},
clear: function (...args) {
console.warn("SystemPasteboard.clear interface mocked in the Previewer. How this interface works on the" +
" Previewer may be 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();
})
}
},
hasPasteData: function (...args) {
console.warn("SystemPasteboard.hasPasteData interface mocked in the Previewer. How this interface works on the" +
" Previewer may be different 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);
})
}
},
getPasteData: function (...args) {
console.warn("SystemPasteboard.getPasteData interface mocked in the Previewer. How this interface works on the" +
" Previewer may be different from that on a real device.")
@@ -50,11 +200,51 @@ export function mockPasteBoard() {
}
}
const pasteboard = {
createPlainTextData: function () {
MAX_RECORD_NUM: '[PC preview] unknow MAX_RECORD_NUM',
MIMETYPE_TEXT_HTML: '[PC preview] unknow MIMETYPE_TEXT_HTML',
MIMETYPE_TEXT_WANT: '[PC preview] unknow MIMETYPE_TEXT_WANT',
MIMETYPE_TEXT_PLAIN: '[PC preview] unknow MIMETYPE_TEXT_PLAIN',
MIMETYPE_TEXT_URI: '[PC preview] unknow MIMETYPE_TEXT_URI',
createPlainTextData: function (...args) {
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.")
return PasteDataMock;
},
createHtmlData: function (...args) {
console.warn("pasteboard.createHtmlData interface mocked in the Previewer. How this interface works on" +
" the Previewer may be different from that on a real device.")
return PasteDataMock;
},
createUriData: function (...args) {
console.warn("pasteboard.createUriData interface mocked in the Previewer. How this interface works on" +
" the Previewer may be different from that on a real device.")
return PasteDataMock;
},
createWantData: function (...args) {
console.warn("pasteboard.createWantData interface mocked in the Previewer. How this interface works on" +
" the Previewer may be different from that on a real device.")
return PasteDataMock;
},
createHtmlTextRecord: function (...args) {
console.warn("pasteboard.createHtmlTextRecord interface mocked in the Previewer. How this interface works on" +
" the Previewer may be different from that on a real device.")
return PasteDataRecordMock;
},
createWantRecord: function (...args) {
console.warn("pasteboard.createWantRecord interface mocked in the Previewer. How this interface works on" +
" the Previewer may be different from that on a real device.")
return PasteDataRecordMock;
},
createUriRecord: function (...args) {
console.warn("pasteboard.createUriRecord interface mocked in the Previewer. How this interface works on" +
" the Previewer may be different from that on a real device.")
return PasteDataRecordMock;
},
createPlainTextRecord: function (...args) {
console.warn("pasteboard.createPlainTextRecord interface mocked in the Previewer. How this interface works on" +
" the Previewer may be different from that on a real device.")
return PasteDataRecordMock;
},
getSystemPasteboard: function () {
console.warn("pasteboard.getSystemPasteboard interface mocked in the Previewer. How this interface works on" +
" the Previewer may be different from that on a real device.")
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2021 Huawei Device Co., Ltd.
* 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
@@ -16,7 +16,7 @@
import { paramMock } from "../utils"
export function mockProcess() {
const result = {
const process = {
runCmd: function (...args) {
console.warn("process.runCmd interface mocked in the Previewer. How this interface works on the Previewer" +
" may be different from that on a real device.")
@@ -155,5 +155,5 @@ export function mockProcess() {
" may be different from that on a real device.")
}
}
return result;
return process;
}

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