mirror of
https://github.com/openharmony/third_party_jsframework.git
synced 2026-07-19 14:33:33 -04:00
@@ -1,3 +1,18 @@
|
||||
/*
|
||||
* 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"
|
||||
import { windowMock } from "./window"
|
||||
|
||||
@@ -1258,11 +1273,11 @@ export function mockAbilityContinuationRegisterManager() {
|
||||
console.warn("ability.ContinuationRegisterManager.on interface mocked in the Previewer. How this interface works on the Previewer" +
|
||||
" may be different from that on a real device.")
|
||||
const len = args.length
|
||||
if(typeof args[len -1]==='function'){
|
||||
if(args[0] ==='deviceConnect'){
|
||||
args[len-1].call(this,ContinuationResultMock)
|
||||
}else{
|
||||
args[len-1].call(this,paramMock.paramStringMock)
|
||||
if (typeof args[len - 1] === 'function') {
|
||||
if (args[0] === 'deviceConnect') {
|
||||
args[len - 1].call(this, ContinuationResultMock)
|
||||
} else {
|
||||
args[len - 1].call(this, paramMock.paramStringMock)
|
||||
}
|
||||
}
|
||||
},
|
||||
@@ -1270,11 +1285,11 @@ export function mockAbilityContinuationRegisterManager() {
|
||||
console.warn("ability.ContinuationRegisterManager.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] ==='deviceConnect'){
|
||||
args[len-1].call(this,ContinuationResultMock)
|
||||
}else{
|
||||
args[len-1].call(this,paramMock.paramStringMock)
|
||||
if (typeof args[len - 1] === 'function') {
|
||||
if (args[0] === 'deviceConnect') {
|
||||
args[len - 1].call(this, ContinuationResultMock)
|
||||
} else {
|
||||
args[len - 1].call(this, paramMock.paramStringMock)
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
@@ -1,4 +1,19 @@
|
||||
import {paramMock} from './utils';
|
||||
/*
|
||||
* 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 AbilitySubTypeMock = {
|
||||
@@ -131,7 +146,7 @@ export function mockAccessibility() {
|
||||
|
||||
global.systemplugin.accessibility = {
|
||||
EventInfo: EventInfoClass,
|
||||
isOpenAccessibility: function(...args) {
|
||||
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;
|
||||
@@ -143,7 +158,7 @@ export function mockAccessibility() {
|
||||
});
|
||||
}
|
||||
},
|
||||
isOpenTouchGuide: function(...args) {
|
||||
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;
|
||||
@@ -155,13 +170,13 @@ export function mockAccessibility() {
|
||||
});
|
||||
}
|
||||
},
|
||||
on: function(...args) {
|
||||
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) {
|
||||
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;
|
||||
@@ -169,7 +184,7 @@ export function mockAccessibility() {
|
||||
args[len - 1].call(this, paramMock.businessErrorMock, StateEventMock);
|
||||
}
|
||||
},
|
||||
getAbilityLists: function(...args) {
|
||||
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;
|
||||
@@ -181,7 +196,7 @@ export function mockAccessibility() {
|
||||
});
|
||||
}
|
||||
},
|
||||
sendEvent: function(...args) {
|
||||
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;
|
||||
|
||||
@@ -1,87 +1,102 @@
|
||||
import {paramMock} from "./utils"
|
||||
/*
|
||||
* 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 mockAI() {
|
||||
const TTSCallBackMock = {
|
||||
key: "[PC preview] unknow key"
|
||||
};
|
||||
global.systemplugin.ai = {};
|
||||
global.systemplugin.ai.TTS = {
|
||||
getTTSClient: function () {
|
||||
console.warn("ai.TTS.getTTSClient interface mocked in the Previewer. How this interface works on the" +
|
||||
" Previewer may be different from that on a real device.")
|
||||
return TTSClient
|
||||
},
|
||||
};
|
||||
const TTSClient = {
|
||||
init: function (...args) {
|
||||
console.warn("TTSClient.init interface mocked in the Previewer. How this interface works on the Previewer may" +
|
||||
" be different from that on a real device.")
|
||||
return paramMock.paramBooleanMock
|
||||
},
|
||||
isSpeaking: function () {
|
||||
console.warn("TTSClient.isSpeaking interface mocked in the Previewer. How this interface works on the Previewer may" +
|
||||
" be different from that on a real device.")
|
||||
return paramMock.paramBooleanMock
|
||||
},
|
||||
setAudioType: function (...args) {
|
||||
console.warn("TTSClient.setAudioType interface mocked in the Previewer. How this interface works on the Previewer may" +
|
||||
" be different from that on a real device.")
|
||||
return paramMock.paramBooleanMock
|
||||
},
|
||||
setParams: function (...args) {
|
||||
console.warn("TTSClient.setParams interface mocked in the Previewer. How this interface works on the Previewer may" +
|
||||
" be different from that on a real device.")
|
||||
return paramMock.paramBooleanMock
|
||||
},
|
||||
connectService: function () {
|
||||
console.warn("TTSClient.connectService interface mocked in the Previewer. How this interface works on the Previewer may" +
|
||||
" be different from that on a real device.")
|
||||
},
|
||||
setIsSaveTtsData: function (...args) {
|
||||
console.warn("TTSClient.setIsSaveTtsData interface mocked in the Previewer. How this interface works on the Previewer may" +
|
||||
" be different from that on a real device.")
|
||||
args[0].success()
|
||||
hasComplete(args[0].complete)
|
||||
},
|
||||
release: function () {
|
||||
console.warn("TTSClient.release interface mocked in the Previewer. How this interface works on the Previewer may" +
|
||||
" be different from that on a real device.")
|
||||
},
|
||||
speakLongText: function (...args) {
|
||||
console.warn("TTSClient.speakLongText interface mocked in the Previewer. How this interface works on the Previewer may" +
|
||||
" be different from that on a real device.")
|
||||
args[0].success()
|
||||
hasComplete(args[0].complete)
|
||||
},
|
||||
speakText: function (...args) {
|
||||
console.warn("TTSClient.speakText interface mocked in the Previewer. How this interface works on the Previewer may" +
|
||||
" be different from that on a real device.")
|
||||
args[0].success()
|
||||
hasComplete(args[0].complete)
|
||||
},
|
||||
stopSpeak: function () {
|
||||
console.warn("TTSClient.stopSpeak interface mocked in the Previewer. How this interface works on the Previewer may" +
|
||||
" be different from that on a real device.")
|
||||
},
|
||||
destroy: function () {
|
||||
console.warn("TTSClient.destroy interface mocked in the Previewer. How this interface works on the Previewer may" +
|
||||
" be different from that on a real device.")
|
||||
},
|
||||
on: function (...args) {
|
||||
console.warn("TTSClient.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, TTSCallBackMock)
|
||||
},
|
||||
getSupportMaxLength: function () {
|
||||
console.warn("TTSClient.getSupportMaxLength interface mocked in the Previewer. How this interface works on the Previewer may" +
|
||||
" be different from that on a real device.")
|
||||
return paramMock.paramNumberMock
|
||||
},
|
||||
getVersion: function () {
|
||||
console.warn("TTSClient.getVersion 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 TTSCallBackMock = {
|
||||
key: "[PC preview] unknow key"
|
||||
};
|
||||
global.systemplugin.ai = {};
|
||||
global.systemplugin.ai.TTS = {
|
||||
getTTSClient: function () {
|
||||
console.warn("ai.TTS.getTTSClient interface mocked in the Previewer. How this interface works on the" +
|
||||
" Previewer may be different from that on a real device.")
|
||||
return TTSClient
|
||||
},
|
||||
};
|
||||
const TTSClient = {
|
||||
init: function (...args) {
|
||||
console.warn("TTSClient.init interface mocked in the Previewer. How this interface works on the Previewer may" +
|
||||
" be different from that on a real device.")
|
||||
return paramMock.paramBooleanMock
|
||||
},
|
||||
isSpeaking: function () {
|
||||
console.warn("TTSClient.isSpeaking interface mocked in the Previewer. How this interface works on the Previewer may" +
|
||||
" be different from that on a real device.")
|
||||
return paramMock.paramBooleanMock
|
||||
},
|
||||
setAudioType: function (...args) {
|
||||
console.warn("TTSClient.setAudioType interface mocked in the Previewer. How this interface works on the Previewer may" +
|
||||
" be different from that on a real device.")
|
||||
return paramMock.paramBooleanMock
|
||||
},
|
||||
setParams: function (...args) {
|
||||
console.warn("TTSClient.setParams interface mocked in the Previewer. How this interface works on the Previewer may" +
|
||||
" be different from that on a real device.")
|
||||
return paramMock.paramBooleanMock
|
||||
},
|
||||
connectService: function () {
|
||||
console.warn("TTSClient.connectService interface mocked in the Previewer. How this interface works on the Previewer may" +
|
||||
" be different from that on a real device.")
|
||||
},
|
||||
setIsSaveTtsData: function (...args) {
|
||||
console.warn("TTSClient.setIsSaveTtsData interface mocked in the Previewer. How this interface works on the Previewer may" +
|
||||
" be different from that on a real device.")
|
||||
args[0].success()
|
||||
hasComplete(args[0].complete)
|
||||
},
|
||||
release: function () {
|
||||
console.warn("TTSClient.release interface mocked in the Previewer. How this interface works on the Previewer may" +
|
||||
" be different from that on a real device.")
|
||||
},
|
||||
speakLongText: function (...args) {
|
||||
console.warn("TTSClient.speakLongText interface mocked in the Previewer. How this interface works on the Previewer may" +
|
||||
" be different from that on a real device.")
|
||||
args[0].success()
|
||||
hasComplete(args[0].complete)
|
||||
},
|
||||
speakText: function (...args) {
|
||||
console.warn("TTSClient.speakText interface mocked in the Previewer. How this interface works on the Previewer may" +
|
||||
" be different from that on a real device.")
|
||||
args[0].success()
|
||||
hasComplete(args[0].complete)
|
||||
},
|
||||
stopSpeak: function () {
|
||||
console.warn("TTSClient.stopSpeak interface mocked in the Previewer. How this interface works on the Previewer may" +
|
||||
" be different from that on a real device.")
|
||||
},
|
||||
destroy: function () {
|
||||
console.warn("TTSClient.destroy interface mocked in the Previewer. How this interface works on the Previewer may" +
|
||||
" be different from that on a real device.")
|
||||
},
|
||||
on: function (...args) {
|
||||
console.warn("TTSClient.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, TTSCallBackMock)
|
||||
},
|
||||
getSupportMaxLength: function () {
|
||||
console.warn("TTSClient.getSupportMaxLength interface mocked in the Previewer. How this interface works on the Previewer may" +
|
||||
" be different from that on a real device.")
|
||||
return paramMock.paramNumberMock
|
||||
},
|
||||
getVersion: function () {
|
||||
console.warn("TTSClient.getVersion interface mocked in the Previewer. How this interface works on the Previewer may" +
|
||||
" be different from that on a real device.")
|
||||
return paramMock.paramStringMock
|
||||
},
|
||||
};
|
||||
}
|
||||
@@ -1,3 +1,18 @@
|
||||
/*
|
||||
* 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 { hasComplete } from "./utils"
|
||||
|
||||
export function mockBattery() {
|
||||
|
||||
@@ -1,3 +1,18 @@
|
||||
/*
|
||||
* Copyright (c) 2021 Huawei Device Co., Ltd.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
export function mockOhosBatteryinfo() {
|
||||
const BatteryPluggedType = {
|
||||
NONE: '[PC preview] unknow NONE',
|
||||
|
||||
@@ -1,45 +1,59 @@
|
||||
/*
|
||||
* 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 { hasComplete } from "./utils"
|
||||
|
||||
export function mockBluetooth() {
|
||||
global.systemplugin.bluetooth = {
|
||||
startBLEScan: function (...args) {
|
||||
console.warn("bluetooth.startBLEScan interface mocked in the Previewer. How this interface works on the" +
|
||||
" Previewer may be different from that on a real device.")
|
||||
args[0].success()
|
||||
hasComplete(args[0].complete)
|
||||
},
|
||||
stopBLEScan: function (...args) {
|
||||
console.warn("bluetooth.stopBLEScan interface mocked in the Previewer. How this interface works on the" +
|
||||
" Previewer may be different from that on a real device.")
|
||||
args[0].success()
|
||||
hasComplete(args[0].complete)
|
||||
},
|
||||
subscribeBLEFound: function (...args) {
|
||||
console.warn("bluetooth.subscribeBLEFound interface mocked in the Previewer. How this interface works on the" +
|
||||
" Previewer may be different from that on a real device.")
|
||||
const options = {
|
||||
addrType: 'public',
|
||||
addr: 'xx:xx:xx:xx',
|
||||
rssi: 123,
|
||||
txpower: 'xxx',
|
||||
data: 'xxx'
|
||||
}
|
||||
const min = 1
|
||||
const max = 6
|
||||
clearInterval(this.unsubscribeBLE)
|
||||
delete this.unsubscribeBLE
|
||||
this.unsubscribeBLE = setInterval(() => {
|
||||
const randomAddr = Math.floor(Math.random() * (max - min)) + min
|
||||
const optionsArr = Array(randomAddr).fill(options)
|
||||
args[0].success(optionsArr)
|
||||
}, 1000)
|
||||
},
|
||||
unsubscribeBLEFound: function () {
|
||||
console.warn("bluetooth.unsubscribeBLEFound interface mocked in the Previewer. How this interface works on the" +
|
||||
" Previewer may be different from that on a real device.")
|
||||
clearInterval(this.unsubscribeBLE)
|
||||
delete this.unsubscribeBLE
|
||||
global.systemplugin.bluetooth = {
|
||||
startBLEScan: function (...args) {
|
||||
console.warn("bluetooth.startBLEScan interface mocked in the Previewer. How this interface works on the" +
|
||||
" Previewer may be different from that on a real device.")
|
||||
args[0].success()
|
||||
hasComplete(args[0].complete)
|
||||
},
|
||||
stopBLEScan: function (...args) {
|
||||
console.warn("bluetooth.stopBLEScan interface mocked in the Previewer. How this interface works on the" +
|
||||
" Previewer may be different from that on a real device.")
|
||||
args[0].success()
|
||||
hasComplete(args[0].complete)
|
||||
},
|
||||
subscribeBLEFound: function (...args) {
|
||||
console.warn("bluetooth.subscribeBLEFound interface mocked in the Previewer. How this interface works on the" +
|
||||
" Previewer may be different from that on a real device.")
|
||||
const options = {
|
||||
addrType: 'public',
|
||||
addr: 'xx:xx:xx:xx',
|
||||
rssi: 123,
|
||||
txpower: 'xxx',
|
||||
data: 'xxx'
|
||||
}
|
||||
const min = 1
|
||||
const max = 6
|
||||
clearInterval(this.unsubscribeBLE)
|
||||
delete this.unsubscribeBLE
|
||||
this.unsubscribeBLE = setInterval(() => {
|
||||
const randomAddr = Math.floor(Math.random() * (max - min)) + min
|
||||
const optionsArr = Array(randomAddr).fill(options)
|
||||
args[0].success(optionsArr)
|
||||
}, 1000)
|
||||
},
|
||||
unsubscribeBLEFound: function () {
|
||||
console.warn("bluetooth.unsubscribeBLEFound interface mocked in the Previewer. How this interface works on the" +
|
||||
" Previewer may be different from that on a real device.")
|
||||
clearInterval(this.unsubscribeBLE)
|
||||
delete this.unsubscribeBLE
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,3 +1,18 @@
|
||||
/*
|
||||
* 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 { hasComplete } from "./utils"
|
||||
|
||||
export function mockBrightness() {
|
||||
|
||||
@@ -1,3 +1,18 @@
|
||||
/*
|
||||
* Copyright (c) 2021 Huawei Device Co., Ltd.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import { paramMock } from "./utils"
|
||||
|
||||
export function mockBytrace() {
|
||||
|
||||
@@ -1,4 +1,19 @@
|
||||
import {paramMock} from './utils';
|
||||
/*
|
||||
* 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 mockCalendar() {
|
||||
const CalendarEntityClass = class CalendarEntity {
|
||||
|
||||
@@ -1,20 +1,35 @@
|
||||
/*
|
||||
* 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 { hasComplete } from "./utils"
|
||||
|
||||
export function mockCipher() {
|
||||
global.systemplugin.cipher = {
|
||||
rsa: function(...args) {
|
||||
console.warn("cipher.rsa interface mocked in the Previewer. How this interface works on the Previewer may be" +
|
||||
" different from that on a real device.")
|
||||
const result = '[PC preview] rsa xxxxxxxxxxxxx'
|
||||
args[0].success(result)
|
||||
hasComplete(args[0].complete)
|
||||
},
|
||||
aes: function(...args) {
|
||||
console.warn("cipher.aes interface mocked in the Previewer. How this interface works on the Previewer may be" +
|
||||
" different from that on a real device.")
|
||||
const result = '[PC preview] aes xxxxxxxxxxxxx'
|
||||
args[0].success(result)
|
||||
hasComplete(args[0].complete)
|
||||
}
|
||||
global.systemplugin.cipher = {
|
||||
rsa: function (...args) {
|
||||
console.warn("cipher.rsa interface mocked in the Previewer. How this interface works on the Previewer may be" +
|
||||
" different from that on a real device.")
|
||||
const result = '[PC preview] rsa xxxxxxxxxxxxx'
|
||||
args[0].success(result)
|
||||
hasComplete(args[0].complete)
|
||||
},
|
||||
aes: function (...args) {
|
||||
console.warn("cipher.aes interface mocked in the Previewer. How this interface works on the Previewer may be" +
|
||||
" different from that on a real device.")
|
||||
const result = '[PC preview] aes xxxxxxxxxxxxx'
|
||||
args[0].success(result)
|
||||
hasComplete(args[0].complete)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,4 +1,19 @@
|
||||
import {paramMock} from "./utils"
|
||||
/*
|
||||
* 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 mockContact() {
|
||||
const ContactClass = class Contact {
|
||||
|
||||
@@ -1,3 +1,18 @@
|
||||
/*
|
||||
* 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 mockDataStorage() {
|
||||
@@ -60,7 +75,6 @@ export function mockDataStorage() {
|
||||
deleteSync: function () {
|
||||
console.warn("Storage.deleteSync interface mocked in the Previewer. How this interface works on the Previewer" +
|
||||
" may be different from that on a real device.")
|
||||
return
|
||||
},
|
||||
delete: function (...args) {
|
||||
console.warn("Storage.delete interface mocked in the Previewer. How this interface works on the Previewer may" +
|
||||
|
||||
@@ -1,3 +1,18 @@
|
||||
/*
|
||||
* Copyright (c) 2021 Huawei Device Co., Ltd.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
export function mockDeviceInfo() {
|
||||
global.systemplugin.deviceInfo = {
|
||||
deviceType: '[PC preview] unknow type',
|
||||
|
||||
@@ -1,129 +1,144 @@
|
||||
import {paramMock} from "./utils"
|
||||
/*
|
||||
* 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 mockDeviceManager() {
|
||||
const deviceInfoMock = {
|
||||
deviceId: "[PC Preview] unknow mDeviceId",
|
||||
deviceName: "[PC Preview] unknow mDeviceName",
|
||||
deviceType: 0x0E,
|
||||
networkId: "[PC Preview] unknow mNetworkId"
|
||||
}
|
||||
const deviceStateChangeMock = {
|
||||
action: 0,
|
||||
device: deviceInfoMock
|
||||
}
|
||||
const deviceManagerMock = {
|
||||
release: function () {
|
||||
console.warn("DeviceManager.release interface mocked in the Previewer. How this interface works on the Previewer" +
|
||||
" may be different from that on a real device.")
|
||||
},
|
||||
getTrustedDeviceListSync: function () {
|
||||
console.warn("DeviceManager.getTrustedDeviceListSync interface mocked in the Previewer. How this interface works on the" +
|
||||
" Previewer may be different from that on a real device.")
|
||||
var array = new Array();
|
||||
array.push(deviceInfoMock);
|
||||
return array ;
|
||||
},
|
||||
getTrustedDeviceList: function (...args) {
|
||||
console.warn("DeviceManager.getTrustedDeviceList interface mocked in the Previewer. How this interface works on the" +
|
||||
" Previewer may be different from that on a real device.")
|
||||
var array = new Array();
|
||||
array.push(deviceInfoMock);
|
||||
const len = args.length
|
||||
if (typeof args[len - 1] === 'function') {
|
||||
args[len - 1].call(this, paramMock.businessErrorMock, array);
|
||||
} else {
|
||||
return new Promise((resolve, reject) => {
|
||||
resolve(array);
|
||||
})
|
||||
}
|
||||
},
|
||||
getLocalDeviceInfoSync: function () {
|
||||
console.warn("DeviceManager.getLocalDeviceInfoSync interface mocked in the Previewer. How this interface works on the" +
|
||||
" Previewer may be different from that on a real device.")
|
||||
return deviceInfoMock;
|
||||
},
|
||||
getLocalDeviceInfo: function (...args) {
|
||||
console.warn("DeviceManager.getLocalDeviceInfo interface mocked in the Previewer. How this interface works on the" +
|
||||
" Previewer may be different from that on a real device.")
|
||||
const len = args.length
|
||||
if (typeof args[len - 1] === 'function') {
|
||||
args[len - 1].call(this, paramMock.businessErrorMock, deviceInfoMock);
|
||||
} else {
|
||||
return new Promise((resolve, reject) => {
|
||||
resolve(deviceInfoMock);
|
||||
})
|
||||
}
|
||||
},
|
||||
startDeviceDiscovery: function (...args) {
|
||||
console.warn("DeviceManager.startDeviceDiscovery interface mocked in the Previewer. How this interface works on the" +
|
||||
" Previewer may be different from that on a real device.")
|
||||
},
|
||||
stopDeviceDiscovery: function (...args) {
|
||||
console.warn("DeviceManager.stopDeviceDiscovery interface mocked in the Previewer. How this interface works on the" +
|
||||
" Previewer may be different from that on a real device.")
|
||||
},
|
||||
authenticateDevice: function (...args) {
|
||||
console.warn("DeviceManager.authenticateDevice interface mocked in the Previewer. How this interface works on the" +
|
||||
" Previewer may be different from that on a real device.")
|
||||
const len = args.length
|
||||
if (typeof args[len - 1] === 'function') {
|
||||
args[len - 1].call(this, paramMock.businessErrorMock, {
|
||||
deviceId: "[PC Preview] unknow deviceId",
|
||||
pinToken: "[PC Preview] unknow pinToken"
|
||||
});
|
||||
}
|
||||
},
|
||||
unAuthenticateDevice: function (...args) {
|
||||
console.warn("DeviceManager.unAuthenticateDevice interface mocked in the Previewer. How this interface works on the" +
|
||||
" Previewer may be different from that on a real device.")
|
||||
},
|
||||
verifyAuthInfo: function (...args) {
|
||||
console.warn("DeviceManager.verifyAuthInfo interface mocked in the Previewer. How this interface works on the" +
|
||||
" Previewer may be different from that on a real device.")
|
||||
const len = args.length
|
||||
if (typeof args[len - 1] === 'function') {
|
||||
args[len - 1].call(this, paramMock.businessErrorMock, {
|
||||
deviceId: "[PC Preview] unknow deviceId",
|
||||
level: "[PC Preview] unknow level"
|
||||
});
|
||||
}
|
||||
},
|
||||
on: function (...args) {
|
||||
console.warn("DeviceManager.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] == 'deviceStateChange') {
|
||||
args[len - 1].call(this, paramMock.businessErrorMock, deviceStateChangeMock);
|
||||
} else if (args[0] == 'deviceFound') {
|
||||
args[len - 1].call(this, paramMock.businessErrorMock, {
|
||||
subscribeId: "[PC Preview] unknow subscribeId",
|
||||
device: deviceInfoMock
|
||||
});
|
||||
} else if (args[0] == 'discoverFail') {
|
||||
args[len - 1].call(this, paramMock.businessErrorMock, {
|
||||
subscribeId: "[PC Preview] unknow subscribeId",
|
||||
reason: "[PC Preview] unknow reason"
|
||||
});
|
||||
} else {
|
||||
args[len - 1].call(this);
|
||||
}
|
||||
}
|
||||
},
|
||||
off: function (...args) {
|
||||
console.warn("DeviceManager.off interface mocked in the Previewer. How this interface works on the Previewer may" +
|
||||
" be different from that on a real device.")
|
||||
const deviceInfoMock = {
|
||||
deviceId: "[PC Preview] unknow mDeviceId",
|
||||
deviceName: "[PC Preview] unknow mDeviceName",
|
||||
deviceType: 0x0E,
|
||||
networkId: "[PC Preview] unknow mNetworkId"
|
||||
}
|
||||
const deviceStateChangeMock = {
|
||||
action: 0,
|
||||
device: deviceInfoMock
|
||||
}
|
||||
const deviceManagerMock = {
|
||||
release: function () {
|
||||
console.warn("DeviceManager.release interface mocked in the Previewer. How this interface works on the Previewer" +
|
||||
" may be different from that on a real device.")
|
||||
},
|
||||
getTrustedDeviceListSync: function () {
|
||||
console.warn("DeviceManager.getTrustedDeviceListSync interface mocked in the Previewer. How this interface works on the" +
|
||||
" Previewer may be different from that on a real device.")
|
||||
var array = new Array();
|
||||
array.push(deviceInfoMock);
|
||||
return array;
|
||||
},
|
||||
getTrustedDeviceList: function (...args) {
|
||||
console.warn("DeviceManager.getTrustedDeviceList interface mocked in the Previewer. How this interface works on the" +
|
||||
" Previewer may be different from that on a real device.")
|
||||
var array = new Array();
|
||||
array.push(deviceInfoMock);
|
||||
const len = args.length
|
||||
if (typeof args[len - 1] === 'function') {
|
||||
args[len - 1].call(this, paramMock.businessErrorMock, array);
|
||||
} else {
|
||||
return new Promise((resolve, reject) => {
|
||||
resolve(array);
|
||||
})
|
||||
}
|
||||
},
|
||||
getLocalDeviceInfoSync: function () {
|
||||
console.warn("DeviceManager.getLocalDeviceInfoSync interface mocked in the Previewer. How this interface works on the" +
|
||||
" Previewer may be different from that on a real device.")
|
||||
return deviceInfoMock;
|
||||
},
|
||||
getLocalDeviceInfo: function (...args) {
|
||||
console.warn("DeviceManager.getLocalDeviceInfo interface mocked in the Previewer. How this interface works on the" +
|
||||
" Previewer may be different from that on a real device.")
|
||||
const len = args.length
|
||||
if (typeof args[len - 1] === 'function') {
|
||||
args[len - 1].call(this, paramMock.businessErrorMock, deviceInfoMock);
|
||||
} else {
|
||||
return new Promise((resolve, reject) => {
|
||||
resolve(deviceInfoMock);
|
||||
})
|
||||
}
|
||||
},
|
||||
startDeviceDiscovery: function (...args) {
|
||||
console.warn("DeviceManager.startDeviceDiscovery interface mocked in the Previewer. How this interface works on the" +
|
||||
" Previewer may be different from that on a real device.")
|
||||
},
|
||||
stopDeviceDiscovery: function (...args) {
|
||||
console.warn("DeviceManager.stopDeviceDiscovery interface mocked in the Previewer. How this interface works on the" +
|
||||
" Previewer may be different from that on a real device.")
|
||||
},
|
||||
authenticateDevice: function (...args) {
|
||||
console.warn("DeviceManager.authenticateDevice interface mocked in the Previewer. How this interface works on the" +
|
||||
" Previewer may be different from that on a real device.")
|
||||
const len = args.length
|
||||
if (typeof args[len - 1] === 'function') {
|
||||
args[len - 1].call(this, paramMock.businessErrorMock, {
|
||||
deviceId: "[PC Preview] unknow deviceId",
|
||||
pinToken: "[PC Preview] unknow pinToken"
|
||||
});
|
||||
}
|
||||
},
|
||||
unAuthenticateDevice: function (...args) {
|
||||
console.warn("DeviceManager.unAuthenticateDevice interface mocked in the Previewer. How this interface works on the" +
|
||||
" Previewer may be different from that on a real device.")
|
||||
},
|
||||
verifyAuthInfo: function (...args) {
|
||||
console.warn("DeviceManager.verifyAuthInfo interface mocked in the Previewer. How this interface works on the" +
|
||||
" Previewer may be different from that on a real device.")
|
||||
const len = args.length
|
||||
if (typeof args[len - 1] === 'function') {
|
||||
args[len - 1].call(this, paramMock.businessErrorMock, {
|
||||
deviceId: "[PC Preview] unknow deviceId",
|
||||
level: "[PC Preview] unknow level"
|
||||
});
|
||||
}
|
||||
},
|
||||
on: function (...args) {
|
||||
console.warn("DeviceManager.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] == 'deviceStateChange') {
|
||||
args[len - 1].call(this, paramMock.businessErrorMock, deviceStateChangeMock);
|
||||
} else if (args[0] == 'deviceFound') {
|
||||
args[len - 1].call(this, paramMock.businessErrorMock, {
|
||||
subscribeId: "[PC Preview] unknow subscribeId",
|
||||
device: deviceInfoMock
|
||||
});
|
||||
} else if (args[0] == 'discoverFail') {
|
||||
args[len - 1].call(this, paramMock.businessErrorMock, {
|
||||
subscribeId: "[PC Preview] unknow subscribeId",
|
||||
reason: "[PC Preview] unknow reason"
|
||||
});
|
||||
} else {
|
||||
args[len - 1].call(this);
|
||||
}
|
||||
}
|
||||
},
|
||||
off: function (...args) {
|
||||
console.warn("DeviceManager.off interface mocked in the Previewer. How this interface works on the Previewer may" +
|
||||
" be different from that on a real device.")
|
||||
}
|
||||
global.systemplugin.distributedHardware = global.systemplugin.distributedHardware || {};
|
||||
global.systemplugin.distributedHardware.deviceManager = {
|
||||
createDeviceManager: function (...args) {
|
||||
console.warn("distributedHardware.deviceManager.createDeviceManager interface mocked in the Previewer. How this interface works on the Previewer" +
|
||||
" may be different from that on a real device.")
|
||||
const len = args.length
|
||||
if (typeof args[len - 1] === 'function') {
|
||||
args[len - 1].call(this, paramMock.businessErrorMock, deviceManagerMock)
|
||||
}
|
||||
}
|
||||
}
|
||||
global.systemplugin.distributedHardware = global.systemplugin.distributedHardware || {};
|
||||
global.systemplugin.distributedHardware.deviceManager = {
|
||||
createDeviceManager: function (...args) {
|
||||
console.warn("distributedHardware.deviceManager.createDeviceManager interface mocked in the Previewer. How this interface works on the Previewer" +
|
||||
" may be different from that on a real device.")
|
||||
const len = args.length
|
||||
if (typeof args[len - 1] === 'function') {
|
||||
args[len - 1].call(this, paramMock.businessErrorMock, deviceManagerMock)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,72 +1,87 @@
|
||||
/*
|
||||
* Copyright (c) 2021 Huawei Device Co., Ltd.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import { paramMock } from "./utils"
|
||||
|
||||
export function mockDisplay() {
|
||||
const displayMock = {
|
||||
densityDPI: '[PC preview] unknow densityDPI',
|
||||
densityPixels: '[PC preview] unknow densityPixels',
|
||||
scaledDensity: '[PC preview] unknow scaledDensity',
|
||||
xDPI: '[PC preview] unknow xDPI',
|
||||
yDPI: '[PC preview] unknow yDPI',
|
||||
width: '[PC preview] unknow width',
|
||||
height: '[PC preview] unknow height',
|
||||
alive: '[PC preview] unknow alive',
|
||||
refreshRate: '[PC preview] unknow refreshRate',
|
||||
id: '[PC preview] unknow id',
|
||||
state: '[PC preview] unknow state',
|
||||
rotation: '[PC preview] unknow rotation',
|
||||
name: '[PC preview] unknow name'
|
||||
}
|
||||
const allDisplayMock = [{
|
||||
densityDPI: '[PC preview] unknow densityDPI',
|
||||
densityPixels: '[PC preview] unknow densityPixels',
|
||||
scaledDensity: '[PC preview] unknow scaledDensity',
|
||||
xDPI: '[PC preview] unknow xDPI',
|
||||
yDPI: '[PC preview] unknow yDPI',
|
||||
width: '[PC preview] unknow width',
|
||||
height: '[PC preview] unknow height',
|
||||
alive: '[PC preview] unknow alive',
|
||||
refreshRate: '[PC preview] unknow refreshRate',
|
||||
id: '[PC preview] unknow id',
|
||||
state: '[PC preview] unknow state',
|
||||
rotation: '[PC preview] unknow rotation',
|
||||
name: '[PC preview] unknow name'
|
||||
}]
|
||||
global.systemplugin.display = {
|
||||
getDefaultDisplay: function (...args) {
|
||||
console.warn("display.getDefaultDisplay interface mocked in the Previewer. How this interface works on the Previewer" +
|
||||
" may be different from that on a real device.")
|
||||
const len = args.length
|
||||
if (typeof args[len - 1] === 'function') {
|
||||
args[len - 1].call(this, paramMock.businessErrorMock, displayMock)
|
||||
} else {
|
||||
return new Promise((resolve, reject) => {
|
||||
resolve(displayMock)
|
||||
})
|
||||
}
|
||||
},
|
||||
getAllDisplay: function (...args) {
|
||||
console.warn("display.getAllDisplay interface mocked in the Previewer. How this interface works on the Previewer" +
|
||||
" may be different from that on a real device.")
|
||||
const len = args.length
|
||||
if (typeof args[len - 1] === 'function') {
|
||||
args[len - 1].call(this, paramMock.businessErrorMock, allDisplayMock)
|
||||
} else {
|
||||
return new Promise((resolve, reject) => {
|
||||
resolve(allDisplayMock)
|
||||
})
|
||||
}
|
||||
},
|
||||
on: function (...args) {
|
||||
console.warn("display.on interface mocked in the Previewer. How this interface works on the Previewer may be" +
|
||||
" different from that on a real device.")
|
||||
const len = args.length
|
||||
args[len - 1].call(this, paramMock.businessErrorMock, paramMock.paramNumberMock)
|
||||
},
|
||||
off: function (...args) {
|
||||
console.warn("display.off interface mocked in the Previewer. How this interface works on the Previewer may be" +
|
||||
" different from that on a real device.")
|
||||
const len = args.length
|
||||
args[len - 1].call(this, paramMock.businessErrorMock, paramMock.paramNumberMock)
|
||||
},
|
||||
}
|
||||
const displayMock = {
|
||||
densityDPI: '[PC preview] unknow densityDPI',
|
||||
densityPixels: '[PC preview] unknow densityPixels',
|
||||
scaledDensity: '[PC preview] unknow scaledDensity',
|
||||
xDPI: '[PC preview] unknow xDPI',
|
||||
yDPI: '[PC preview] unknow yDPI',
|
||||
width: '[PC preview] unknow width',
|
||||
height: '[PC preview] unknow height',
|
||||
alive: '[PC preview] unknow alive',
|
||||
refreshRate: '[PC preview] unknow refreshRate',
|
||||
id: '[PC preview] unknow id',
|
||||
state: '[PC preview] unknow state',
|
||||
rotation: '[PC preview] unknow rotation',
|
||||
name: '[PC preview] unknow name'
|
||||
}
|
||||
const allDisplayMock = [{
|
||||
densityDPI: '[PC preview] unknow densityDPI',
|
||||
densityPixels: '[PC preview] unknow densityPixels',
|
||||
scaledDensity: '[PC preview] unknow scaledDensity',
|
||||
xDPI: '[PC preview] unknow xDPI',
|
||||
yDPI: '[PC preview] unknow yDPI',
|
||||
width: '[PC preview] unknow width',
|
||||
height: '[PC preview] unknow height',
|
||||
alive: '[PC preview] unknow alive',
|
||||
refreshRate: '[PC preview] unknow refreshRate',
|
||||
id: '[PC preview] unknow id',
|
||||
state: '[PC preview] unknow state',
|
||||
rotation: '[PC preview] unknow rotation',
|
||||
name: '[PC preview] unknow name'
|
||||
}]
|
||||
global.systemplugin.display = {
|
||||
getDefaultDisplay: function (...args) {
|
||||
console.warn("display.getDefaultDisplay interface mocked in the Previewer. How this interface works on the Previewer" +
|
||||
" may be different from that on a real device.")
|
||||
const len = args.length
|
||||
if (typeof args[len - 1] === 'function') {
|
||||
args[len - 1].call(this, paramMock.businessErrorMock, displayMock)
|
||||
} else {
|
||||
return new Promise((resolve, reject) => {
|
||||
resolve(displayMock)
|
||||
})
|
||||
}
|
||||
},
|
||||
getAllDisplay: function (...args) {
|
||||
console.warn("display.getAllDisplay interface mocked in the Previewer. How this interface works on the Previewer" +
|
||||
" may be different from that on a real device.")
|
||||
const len = args.length
|
||||
if (typeof args[len - 1] === 'function') {
|
||||
args[len - 1].call(this, paramMock.businessErrorMock, allDisplayMock)
|
||||
} else {
|
||||
return new Promise((resolve, reject) => {
|
||||
resolve(allDisplayMock)
|
||||
})
|
||||
}
|
||||
},
|
||||
on: function (...args) {
|
||||
console.warn("display.on interface mocked in the Previewer. How this interface works on the Previewer may be" +
|
||||
" different from that on a real device.")
|
||||
const len = args.length
|
||||
args[len - 1].call(this, paramMock.businessErrorMock, paramMock.paramNumberMock)
|
||||
},
|
||||
off: function (...args) {
|
||||
console.warn("display.off interface mocked in the Previewer. How this interface works on the Previewer may be" +
|
||||
" different from that on a real device.")
|
||||
const len = args.length
|
||||
args[len - 1].call(this, paramMock.businessErrorMock, paramMock.paramNumberMock)
|
||||
},
|
||||
}
|
||||
}
|
||||
@@ -1,3 +1,18 @@
|
||||
/*
|
||||
* 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 mockDistributedSchedule() {
|
||||
@@ -25,7 +40,7 @@ export function mockDistributedSchedule() {
|
||||
permissions: ["[PC Preview] unknow permission", "[PC Preview] unknow permission"],
|
||||
moduleInfo: [ModuleInfoMock],
|
||||
entryDir: "[PC Preview] unknow entryDir",
|
||||
customizeData:new Map([["[PC Preview] unknow customizeDataKey", CustomizeDataMock]])
|
||||
customizeData: new Map([["[PC Preview] unknow customizeDataKey", CustomizeDataMock]])
|
||||
}
|
||||
const AbilityInfoMock = {
|
||||
bundleName: "[PC Preview] unknow bundleName",
|
||||
|
||||
@@ -1,3 +1,18 @@
|
||||
/*
|
||||
* 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 mockDocument() {
|
||||
|
||||
@@ -1,3 +1,18 @@
|
||||
/*
|
||||
* 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 { mockSystemPlugin } from './index';
|
||||
|
||||
mockSystemPlugin()
|
||||
@@ -1,3 +1,26 @@
|
||||
/*
|
||||
* @Author: your name
|
||||
* @Date: 2022-01-20 21:27:31
|
||||
* @LastEditTime: 2022-01-20 21:27:33
|
||||
* @LastEditors: your name
|
||||
* @Description: 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
|
||||
* @FilePath: \third_party_jsframework\runtime\main\extend\systemplugin\featureAbility.js
|
||||
*/
|
||||
/*
|
||||
* Copyright (c) 2021 Huawei Device Co., Ltd.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
export function mockFeatureAbility() {
|
||||
let FeatureAbilityObject = {
|
||||
getFeatureAbility: function () {
|
||||
|
||||
@@ -1,3 +1,18 @@
|
||||
/*
|
||||
* Copyright (c) 2021 Huawei Device Co., Ltd.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
export function mockFetch() {
|
||||
global.sendGroupMessage = global.group.sendGroupMessage;
|
||||
let GroupMessenger = {
|
||||
@@ -45,7 +60,7 @@ export function mockFetch() {
|
||||
return messenger;
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
let CommonCallback = {
|
||||
commonCallback: function commonCallback(callback, flag, data, code) {
|
||||
if (typeof callback === 'function') {
|
||||
@@ -102,7 +117,7 @@ export function mockFetch() {
|
||||
};
|
||||
global.commonCallbackEx = CommonCallbackEx.commonCallbackEx;
|
||||
global.systemplugin.catching = CommonCallbackEx.catching;
|
||||
|
||||
|
||||
let FetchObject = {
|
||||
getFetch: function () {
|
||||
let fetch = {}
|
||||
@@ -113,6 +128,6 @@ export function mockFetch() {
|
||||
return fetch
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
global.systemplugin.fetch = FetchObject.getFetch();
|
||||
}
|
||||
@@ -1,95 +1,110 @@
|
||||
/*
|
||||
* 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 { hasComplete } from "./utils"
|
||||
|
||||
export function mockFile() {
|
||||
global.systemplugin.file = {
|
||||
move: function(...args) {
|
||||
console.warn("file.move interface mocked in the Previewer. How this interface works on the Previewer may be" +
|
||||
" different from that on a real device.")
|
||||
args[0].success(args[0].dstUri)
|
||||
hasComplete(args[0].complete)
|
||||
},
|
||||
copy: function(...args) {
|
||||
console.warn("file.copy interface mocked in the Previewer. How this interface works on the Previewer may be" +
|
||||
" different from that on a real device.")
|
||||
args[0].success(args[0].dstUri)
|
||||
hasComplete(args[0].complete)
|
||||
},
|
||||
list: function(...args) {
|
||||
console.warn("file.list interface mocked in the Previewer. How this interface works on the Previewer may be" +
|
||||
" different from that on a real device.")
|
||||
const data = {
|
||||
fileList: [{
|
||||
uri: '[PC Preview]: no file',
|
||||
lastModifiedTime: "[PC Preview]: no file",
|
||||
length: "[PC Preview]: no file",
|
||||
type: 'file'
|
||||
}]
|
||||
}
|
||||
args[0].success(data)
|
||||
hasComplete(args[0].complete)
|
||||
},
|
||||
get: function(...args) {
|
||||
console.warn("file.get interface mocked in the Previewer. How this interface works on the Previewer may be" +
|
||||
" different from that on a real device.")
|
||||
const data = {
|
||||
global.systemplugin.file = {
|
||||
move: function (...args) {
|
||||
console.warn("file.move interface mocked in the Previewer. How this interface works on the Previewer may be" +
|
||||
" different from that on a real device.")
|
||||
args[0].success(args[0].dstUri)
|
||||
hasComplete(args[0].complete)
|
||||
},
|
||||
copy: function (...args) {
|
||||
console.warn("file.copy interface mocked in the Previewer. How this interface works on the Previewer may be" +
|
||||
" different from that on a real device.")
|
||||
args[0].success(args[0].dstUri)
|
||||
hasComplete(args[0].complete)
|
||||
},
|
||||
list: function (...args) {
|
||||
console.warn("file.list interface mocked in the Previewer. How this interface works on the Previewer may be" +
|
||||
" different from that on a real device.")
|
||||
const data = {
|
||||
fileList: [{
|
||||
uri: '[PC Preview]: no file',
|
||||
lastModifiedTime: "[PC Preview]: no file",
|
||||
length: "[PC Preview]: no file",
|
||||
type: 'file',
|
||||
subFiles: ["[PC Preview]: no file", "[PC Preview]: no file"]
|
||||
}
|
||||
args[0].success(data)
|
||||
hasComplete(args[0].complete)
|
||||
},
|
||||
delete: function(...args) {
|
||||
console.warn("file.delete interface mocked in the Previewer. How this interface works on the Previewer may be" +
|
||||
" different from that on a real device.")
|
||||
args[0].success()
|
||||
hasComplete(args[0].complete)
|
||||
},
|
||||
writeText: function(...args) {
|
||||
console.warn("file.writeText interface mocked in the Previewer. How this interface works on the Previewer may" +
|
||||
" be different from that on a real device.")
|
||||
args[0].success()
|
||||
hasComplete(args[0].complete)
|
||||
},
|
||||
writeArrayBuffer: function(...args) {
|
||||
console.warn("file.writeArrayBuffer interface mocked in the Previewer. How this interface works on the" +
|
||||
" Previewer may be different from that on a real device.")
|
||||
args[0].success()
|
||||
hasComplete(args[0].complete)
|
||||
},
|
||||
readText: function(...args) {
|
||||
console.warn("file.readText interface mocked in the Previewer. How this interface works on the Previewer may" +
|
||||
" be different from that on a real device.")
|
||||
const data = {text: "[PC Preview]: success default"}
|
||||
args[0].success(data)
|
||||
hasComplete(args[0].complete)
|
||||
},
|
||||
readArrayBuffer: function(...args) {
|
||||
console.warn("file.readArrayBuffer interface mocked in the Previewer. How this interface works on the" +
|
||||
" Previewer may be different from that on a real device.")
|
||||
const data = {buffer: ["[PC Preview]: default", "[PC Preview]: default", "[PC Preview]: default"]}
|
||||
args[0].success(data)
|
||||
hasComplete(args[0].complete)
|
||||
},
|
||||
access: function(...args) {
|
||||
console.warn("file.access interface mocked in the Previewer. How this interface works on the Previewer may be" +
|
||||
" different from that on a real device.")
|
||||
args[0].success()
|
||||
hasComplete(args[0].complete)
|
||||
},
|
||||
mkdir: function(...args) {
|
||||
console.warn("file.mkdir interface mocked in the Previewer. How this interface works on the Previewer may be" +
|
||||
" different from that on a real device.")
|
||||
args[0].success()
|
||||
hasComplete(args[0].complete)
|
||||
},
|
||||
rmdir: function(...args) {
|
||||
console.warn("file.rmdir interface mocked in the Previewer. How this interface works on the Previewer may be" +
|
||||
" different from that on a real device.")
|
||||
args[0].success()
|
||||
hasComplete(args[0].complete)
|
||||
type: 'file'
|
||||
}]
|
||||
}
|
||||
args[0].success(data)
|
||||
hasComplete(args[0].complete)
|
||||
},
|
||||
get: function (...args) {
|
||||
console.warn("file.get interface mocked in the Previewer. How this interface works on the Previewer may be" +
|
||||
" different from that on a real device.")
|
||||
const data = {
|
||||
uri: '[PC Preview]: no file',
|
||||
lastModifiedTime: "[PC Preview]: no file",
|
||||
length: "[PC Preview]: no file",
|
||||
type: 'file',
|
||||
subFiles: ["[PC Preview]: no file", "[PC Preview]: no file"]
|
||||
}
|
||||
args[0].success(data)
|
||||
hasComplete(args[0].complete)
|
||||
},
|
||||
delete: function (...args) {
|
||||
console.warn("file.delete interface mocked in the Previewer. How this interface works on the Previewer may be" +
|
||||
" different from that on a real device.")
|
||||
args[0].success()
|
||||
hasComplete(args[0].complete)
|
||||
},
|
||||
writeText: function (...args) {
|
||||
console.warn("file.writeText interface mocked in the Previewer. How this interface works on the Previewer may" +
|
||||
" be different from that on a real device.")
|
||||
args[0].success()
|
||||
hasComplete(args[0].complete)
|
||||
},
|
||||
writeArrayBuffer: function (...args) {
|
||||
console.warn("file.writeArrayBuffer interface mocked in the Previewer. How this interface works on the" +
|
||||
" Previewer may be different from that on a real device.")
|
||||
args[0].success()
|
||||
hasComplete(args[0].complete)
|
||||
},
|
||||
readText: function (...args) {
|
||||
console.warn("file.readText interface mocked in the Previewer. How this interface works on the Previewer may" +
|
||||
" be different from that on a real device.")
|
||||
const data = { text: "[PC Preview]: success default" }
|
||||
args[0].success(data)
|
||||
hasComplete(args[0].complete)
|
||||
},
|
||||
readArrayBuffer: function (...args) {
|
||||
console.warn("file.readArrayBuffer interface mocked in the Previewer. How this interface works on the" +
|
||||
" Previewer may be different from that on a real device.")
|
||||
const data = { buffer: ["[PC Preview]: default", "[PC Preview]: default", "[PC Preview]: default"] }
|
||||
args[0].success(data)
|
||||
hasComplete(args[0].complete)
|
||||
},
|
||||
access: function (...args) {
|
||||
console.warn("file.access interface mocked in the Previewer. How this interface works on the Previewer may be" +
|
||||
" different from that on a real device.")
|
||||
args[0].success()
|
||||
hasComplete(args[0].complete)
|
||||
},
|
||||
mkdir: function (...args) {
|
||||
console.warn("file.mkdir interface mocked in the Previewer. How this interface works on the Previewer may be" +
|
||||
" different from that on a real device.")
|
||||
args[0].success()
|
||||
hasComplete(args[0].complete)
|
||||
},
|
||||
rmdir: function (...args) {
|
||||
console.warn("file.rmdir interface mocked in the Previewer. How this interface works on the Previewer may be" +
|
||||
" different from that on a real device.")
|
||||
args[0].success()
|
||||
hasComplete(args[0].complete)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,48 +1,63 @@
|
||||
import {hasComplete, getRandomArbitrary} from "./utils"
|
||||
/*
|
||||
* 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 { hasComplete, getRandomArbitrary } from "./utils"
|
||||
|
||||
export function mockGeolocation() {
|
||||
const data = {
|
||||
latitude: '121.61934',
|
||||
longitude: '31.257907',
|
||||
accuracy: '15',
|
||||
time: '160332896544'
|
||||
}
|
||||
global.systemplugin.geolocation = {
|
||||
getLocation: function (...args) {
|
||||
console.warn("geolocation.getLocation interface mocked in the Previewer. How this interface works on the" +
|
||||
" Previewer may be different from that on a real device.")
|
||||
args[0].success(data)
|
||||
hasComplete(args[0].complete)
|
||||
},
|
||||
getLocationType: function(...args) {
|
||||
console.warn("geolocation.getLocationType interface mocked in the Previewer. How this interface works on the" +
|
||||
" Previewer may be different from that on a real device.")
|
||||
const info = {types: ['gps', 'network']}
|
||||
args[0].success(info)
|
||||
hasComplete(args[0].complete)
|
||||
},
|
||||
getSupportedCoordTypes() {
|
||||
console.warn("geolocation.getSupportedCoordTypes interface mocked in the Previewer. How this interface works" +
|
||||
" on the Previewer may be different from that on a real device.")
|
||||
return ["wgs84"]
|
||||
},
|
||||
subscribe: function(...args) {
|
||||
console.warn("geolocation.subscribe interface mocked in the Previewer. How this interface works on the" +
|
||||
" Previewer may be different from that on a real device.")
|
||||
if (!this.unsubscribeLocation) {
|
||||
this.unsubscribeLocation = setInterval(() => {
|
||||
data.latitude = getRandomArbitrary(121, 122)
|
||||
data.longitude = getRandomArbitrary(31, 32)
|
||||
data.accuracy = getRandomArbitrary(14, 18)
|
||||
args[0].success(data)
|
||||
}, 1000)
|
||||
}
|
||||
},
|
||||
unsubscribe: function() {
|
||||
console.warn("geolocation.unsubscribe interface mocked in the Previewer. How this interface works on the" +
|
||||
" Previewer may be different from that on a real device.")
|
||||
clearInterval(this.unsubscribeLocation)
|
||||
delete this.unsubscribeLocation
|
||||
const data = {
|
||||
latitude: '121.61934',
|
||||
longitude: '31.257907',
|
||||
accuracy: '15',
|
||||
time: '160332896544'
|
||||
}
|
||||
global.systemplugin.geolocation = {
|
||||
getLocation: function (...args) {
|
||||
console.warn("geolocation.getLocation interface mocked in the Previewer. How this interface works on the" +
|
||||
" Previewer may be different from that on a real device.")
|
||||
args[0].success(data)
|
||||
hasComplete(args[0].complete)
|
||||
},
|
||||
getLocationType: function (...args) {
|
||||
console.warn("geolocation.getLocationType interface mocked in the Previewer. How this interface works on the" +
|
||||
" Previewer may be different from that on a real device.")
|
||||
const info = { types: ['gps', 'network'] }
|
||||
args[0].success(info)
|
||||
hasComplete(args[0].complete)
|
||||
},
|
||||
getSupportedCoordTypes() {
|
||||
console.warn("geolocation.getSupportedCoordTypes interface mocked in the Previewer. How this interface works" +
|
||||
" on the Previewer may be different from that on a real device.")
|
||||
return ["wgs84"]
|
||||
},
|
||||
subscribe: function (...args) {
|
||||
console.warn("geolocation.subscribe interface mocked in the Previewer. How this interface works on the" +
|
||||
" Previewer may be different from that on a real device.")
|
||||
if (!this.unsubscribeLocation) {
|
||||
this.unsubscribeLocation = setInterval(() => {
|
||||
data.latitude = getRandomArbitrary(121, 122)
|
||||
data.longitude = getRandomArbitrary(31, 32)
|
||||
data.accuracy = getRandomArbitrary(14, 18)
|
||||
args[0].success(data)
|
||||
}, 1000)
|
||||
}
|
||||
},
|
||||
unsubscribe: function () {
|
||||
console.warn("geolocation.unsubscribe interface mocked in the Previewer. How this interface works on the" +
|
||||
" Previewer may be different from that on a real device.")
|
||||
clearInterval(this.unsubscribeLocation)
|
||||
delete this.unsubscribeLocation
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,3 +1,18 @@
|
||||
/*
|
||||
* 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 regeneratorRuntime from 'babel-runtime/regenerator'
|
||||
|
||||
import {
|
||||
@@ -9,7 +24,7 @@ import {
|
||||
mockAbilityAbilityAgent,
|
||||
mockAbilityFormBindingData
|
||||
} from './ability'
|
||||
import {mockAppAbilityManager} from './ohos/app'
|
||||
import { mockAppAbilityManager } from './ohos/app'
|
||||
|
||||
import { mockBackgroundTaskManager } from './ohos/backgroundTaskManager'
|
||||
import { mockBattery } from './battery'
|
||||
@@ -54,7 +69,7 @@ import { mockResourceManager } from './resourceManager'
|
||||
|
||||
import { mockSensor } from './sensor'
|
||||
import { mockStorage } from './storage'
|
||||
import { mockStorageInfoManager} from './ohos/storageInfoManager'
|
||||
import { mockStorageInfoManager } from './ohos/storageInfoManager'
|
||||
import { mockSystemPackage } from './systemPackage'
|
||||
|
||||
import { mockUserauth } from './userIAM'
|
||||
@@ -70,17 +85,17 @@ import { mockAI } from './ai'
|
||||
import { mockDisplay } from './display'
|
||||
import { mockDeviceManager } from './deviceManager'
|
||||
import { mockScreenshot } from './screenshot'
|
||||
import {mockContact} from './contact'
|
||||
import {mockScreenLock} from "./screenLock"
|
||||
import { mockAppAccount} from './ohos/appAccount'
|
||||
import { mockOsAccount} from './ohos/osAccount'
|
||||
import { mockContact } from './contact'
|
||||
import { mockScreenLock } from "./screenLock"
|
||||
import { mockAppAccount } from './ohos/appAccount'
|
||||
import { mockOsAccount } from './ohos/osAccount'
|
||||
import { mockOhosGeolocation } from './ohos/geolocation'
|
||||
import { mockInputMonitor} from './ohos/inputMonitor'
|
||||
import {mockUserIAMUserAuth} from './ohos/userIAMuserAuth.js'
|
||||
import { mockInputMonitor } from './ohos/inputMonitor'
|
||||
import { mockUserIAMUserAuth } from './ohos/userIAMuserAuth.js'
|
||||
import { mockBundleManager } from './ohos/bundleManager'
|
||||
import { mockPackageManager } from './ohos/packageManager'
|
||||
import { mockZlib } from './napi/zlib'
|
||||
import {mockCalendar} from "./calendar"
|
||||
import { mockCalendar } from "./calendar"
|
||||
|
||||
export function mockSystemPlugin() {
|
||||
global.regeneratorRuntime = regeneratorRuntime
|
||||
|
||||
@@ -1,3 +1,18 @@
|
||||
/*
|
||||
* 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 mockInputMethod() {
|
||||
|
||||
@@ -1,407 +1,422 @@
|
||||
/*
|
||||
* Copyright (c) 2021 Huawei Device Co., Ltd.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import { paramMock } from "./utils"
|
||||
|
||||
const 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'
|
||||
'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",
|
||||
offset: 1,
|
||||
changedStart: 2,
|
||||
changedEnd: 3,
|
||||
selectionStart: 4,
|
||||
selectionEnd: 5,
|
||||
additionalBitFlags: 6,
|
||||
prompt: "[PC Preview] unknow prompt"
|
||||
const EditingText = {
|
||||
textContent: "[PC Preview] unknow textContent",
|
||||
offset: 1,
|
||||
changedStart: 2,
|
||||
changedEnd: 3,
|
||||
selectionStart: 4,
|
||||
selectionEnd: 5,
|
||||
additionalBitFlags: 6,
|
||||
prompt: "[PC Preview] unknow prompt"
|
||||
}
|
||||
const EditingCapability = {
|
||||
maxLines: 1,
|
||||
maxChars: 2
|
||||
}
|
||||
const EditorAttribute = {
|
||||
inputPattern: 1,
|
||||
enterKeyType: 2,
|
||||
inputOption: 3
|
||||
}
|
||||
const RichContent = {
|
||||
contentURI: "[PC Preview] unknow contentURI",
|
||||
linkURI: "[PC Preview] unknow linkURI",
|
||||
mimeTypes: "[PC Preview] unknow mimeTypes",
|
||||
detail: "[PC Preview] unknow detail"
|
||||
}
|
||||
const KeyboardControllerMock = {
|
||||
setDisplayMode: function (...args) {
|
||||
console.warn("KeyboardController.setDisplayMode interface mocked in the Previewer. How this interface works on" +
|
||||
" the Previewer may be different from that on a 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();
|
||||
})
|
||||
}
|
||||
},
|
||||
getDisplayMode: function (...args) {
|
||||
console.warn("KeyboardController.getDisplayMode interface mocked in the Previewer. How this interface works on" +
|
||||
" the Previewer may be different from that on a real device.")
|
||||
const len = args.length
|
||||
if (typeof args[len - 1] === 'function') {
|
||||
args[len - 1].call(this, paramMock.businessErrorMock, paramMock.paramNumberMock);
|
||||
} else {
|
||||
return new Promise((resolve, reject) => {
|
||||
resolve(paramMock.paramNumberMock);
|
||||
})
|
||||
}
|
||||
},
|
||||
hideKeyboard: function (...args) {
|
||||
console.warn("KeyboardController.hideKeyboard interface mocked in the Previewer. How this interface works on" +
|
||||
" the Previewer may be different from that on a 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();
|
||||
})
|
||||
}
|
||||
},
|
||||
toNextInputMethod: function (...args) {
|
||||
console.warn("KeyboardController.toNextInputMethod interface mocked in the Previewer. How this interface works on" +
|
||||
" the Previewer may be different from that on a 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();
|
||||
})
|
||||
}
|
||||
},
|
||||
getScreenOrientation: function (...args) {
|
||||
console.warn("KeyboardController.getScreenOrientation interface mocked in the Previewer. How this interface works on" +
|
||||
" the Previewer may be different from that on a real device.")
|
||||
const len = args.length
|
||||
if (typeof args[len - 1] === 'function') {
|
||||
args[len - 1].call(this, paramMock.businessErrorMock, paramMock.paramNumberMock);
|
||||
} else {
|
||||
return new Promise((resolve, reject) => {
|
||||
resolve(paramMock.paramNumberMock);
|
||||
})
|
||||
}
|
||||
}
|
||||
const EditingCapability = {
|
||||
maxLines: 1,
|
||||
maxChars:2
|
||||
}
|
||||
const TextInputClientMock = {
|
||||
getEditorAttribute: function (...args) {
|
||||
console.warn("TextInputClientMock.getEditorAttribute interface mocked in the Previewer. How this interface works on" +
|
||||
" the Previewer may be different from that on a real device.")
|
||||
const len = args.length
|
||||
if (typeof args[len - 1] === 'function') {
|
||||
args[len - 1].call(this, paramMock.businessErrorMock, EditorAttribute);
|
||||
} else {
|
||||
return new Promise((resolve, reject) => {
|
||||
resolve(EditorAttribute);
|
||||
})
|
||||
}
|
||||
},
|
||||
insertText: function (...args) {
|
||||
console.warn("TextInputClientMock.insertText interface mocked in the Previewer. How this interface works on" +
|
||||
" the Previewer may be different from that on a 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();
|
||||
})
|
||||
}
|
||||
},
|
||||
insertRichContent: function (...args) {
|
||||
console.warn("TextInputClientMock.insertRichContent interface mocked in the Previewer. How this interface works on" +
|
||||
" the Previewer may be different from that on a 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();
|
||||
})
|
||||
}
|
||||
},
|
||||
deleteBackward: function (...args) {
|
||||
console.warn("TextInputClientMock.deleteBackward interface mocked in the Previewer. How this interface works on" +
|
||||
" the Previewer may be different from that on a 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();
|
||||
})
|
||||
}
|
||||
},
|
||||
deleteForward: function (...args) {
|
||||
console.warn("TextInputClientMock.deleteForward interface mocked in the Previewer. How this interface works on" +
|
||||
" the Previewer may be different from that on a 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();
|
||||
})
|
||||
}
|
||||
},
|
||||
getForward: function (...args) {
|
||||
console.warn("TextInputClientMock.getForward interface mocked in the Previewer. How this interface works on" +
|
||||
" the Previewer may be different 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);
|
||||
})
|
||||
}
|
||||
},
|
||||
getBackward: function (...args) {
|
||||
console.warn("TextInputClientMock.getBackward interface mocked in the Previewer. How this interface works on" +
|
||||
" the Previewer may be different 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);
|
||||
})
|
||||
}
|
||||
},
|
||||
getEditingText: function (...args) {
|
||||
console.warn("TextInputClientMock.getEditingText interface mocked in the Previewer. How this interface works on" +
|
||||
" the Previewer may be different from that on a real device.")
|
||||
const len = args.length
|
||||
if (typeof args[len - 1] === 'function') {
|
||||
args[len - 1].call(this, paramMock.businessErrorMock, EditingText);
|
||||
} else {
|
||||
return new Promise((resolve, reject) => {
|
||||
resolve(EditingText);
|
||||
})
|
||||
}
|
||||
},
|
||||
sendKeyEvent: function (...args) {
|
||||
console.warn("TextInputClientMock.sendKeyEvent interface mocked in the Previewer. How this interface works on" +
|
||||
" the Previewer may be different from that on a 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();
|
||||
})
|
||||
}
|
||||
},
|
||||
sendKeyFunction: function (...args) {
|
||||
console.warn("TextInputClientMock.sendKeyFunction interface mocked in the Previewer. How this interface works on" +
|
||||
" the Previewer may be different from that on a 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();
|
||||
})
|
||||
}
|
||||
},
|
||||
selectText: function (...args) {
|
||||
console.warn("TextInputClientMock.selectText interface mocked in the Previewer. How this interface works on" +
|
||||
" the Previewer may be different from that on a 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();
|
||||
})
|
||||
}
|
||||
},
|
||||
requestCurrentCursorContext: function (...args) {
|
||||
console.warn("TextInputClientMock.requestCurrentCursorContext interface mocked in the Previewer. How this interface works on" +
|
||||
" the Previewer may be different from that on a 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();
|
||||
})
|
||||
}
|
||||
},
|
||||
getAutoCapitalizeMode: function (...args) {
|
||||
console.warn("TextInputClientMock.getAutoCapitalizeMode interface mocked in the Previewer. How this interface works on" +
|
||||
" the Previewer may be different from that on a real device.")
|
||||
const len = args.length
|
||||
if (typeof args[len - 1] === 'function') {
|
||||
args[len - 1].call(this, paramMock.businessErrorMock, paramMock.paramNumberMock);
|
||||
} else {
|
||||
return new Promise((resolve, reject) => {
|
||||
resolve(paramMock.paramNumberMock);
|
||||
})
|
||||
}
|
||||
},
|
||||
reviseText: function (...args) {
|
||||
console.warn("TextInputClientMock.reviseText interface mocked in the Previewer. How this interface works on" +
|
||||
" the Previewer may be different from that on a 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();
|
||||
})
|
||||
}
|
||||
},
|
||||
markText: function (...args) {
|
||||
console.warn("TextInputClientMock.markText interface mocked in the Previewer. How this interface works on" +
|
||||
" the Previewer may be different from that on a 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();
|
||||
})
|
||||
}
|
||||
},
|
||||
unmarkText: function (...args) {
|
||||
console.warn("TextInputClientMock.unmarkText interface mocked in the Previewer. How this interface works on" +
|
||||
" the Previewer may be different from that on a 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();
|
||||
})
|
||||
}
|
||||
},
|
||||
replaceMarkedText: function (...args) {
|
||||
console.warn("TextInputClientMock.replaceMarkedText interface mocked in the Previewer. How this interface works on" +
|
||||
" the Previewer may be different from that on a 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 EditorAttribute = {
|
||||
inputPattern: 1,
|
||||
enterKeyType: 2,
|
||||
inputOption: 3
|
||||
}
|
||||
const RichContent = {
|
||||
contentURI: "[PC Preview] unknow contentURI",
|
||||
linkURI: "[PC Preview] unknow linkURI",
|
||||
mimeTypes: "[PC Preview] unknow mimeTypes",
|
||||
detail: "[PC Preview] unknow detail"
|
||||
}
|
||||
const KeyboardControllerMock = {
|
||||
setDisplayMode: function (...args) {
|
||||
console.warn("KeyboardController.setDisplayMode interface mocked in the Previewer. How this interface works on" +
|
||||
" the Previewer may be different from that on a 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();
|
||||
})
|
||||
}
|
||||
},
|
||||
getDisplayMode: function (...args) {
|
||||
console.warn("KeyboardController.getDisplayMode interface mocked in the Previewer. How this interface works on" +
|
||||
" the Previewer may be different from that on a real device.")
|
||||
const len = args.length
|
||||
if (typeof args[len - 1] === 'function') {
|
||||
args[len - 1].call(this, paramMock.businessErrorMock, paramMock.paramNumberMock);
|
||||
} else {
|
||||
return new Promise((resolve, reject) => {
|
||||
resolve(paramMock.paramNumberMock);
|
||||
})
|
||||
}
|
||||
},
|
||||
hideKeyboard: function (...args) {
|
||||
console.warn("KeyboardController.hideKeyboard interface mocked in the Previewer. How this interface works on" +
|
||||
" the Previewer may be different from that on a 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();
|
||||
})
|
||||
}
|
||||
},
|
||||
toNextInputMethod: function (...args) {
|
||||
console.warn("KeyboardController.toNextInputMethod interface mocked in the Previewer. How this interface works on" +
|
||||
" the Previewer may be different from that on a 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();
|
||||
})
|
||||
}
|
||||
},
|
||||
getScreenOrientation: function (...args) {
|
||||
console.warn("KeyboardController.getScreenOrientation interface mocked in the Previewer. How this interface works on" +
|
||||
" the Previewer may be different from that on a real device.")
|
||||
const len = args.length
|
||||
if (typeof args[len - 1] === 'function') {
|
||||
args[len - 1].call(this, paramMock.businessErrorMock, paramMock.paramNumberMock);
|
||||
} else {
|
||||
return new Promise((resolve, reject) => {
|
||||
resolve(paramMock.paramNumberMock);
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
const TextInputClientMock = {
|
||||
getEditorAttribute: function (...args) {
|
||||
console.warn("TextInputClientMock.getEditorAttribute interface mocked in the Previewer. How this interface works on" +
|
||||
" the Previewer may be different from that on a real device.")
|
||||
const len = args.length
|
||||
if (typeof args[len - 1] === 'function') {
|
||||
args[len - 1].call(this, paramMock.businessErrorMock, EditorAttribute);
|
||||
} else {
|
||||
return new Promise((resolve, reject) => {
|
||||
resolve(EditorAttribute);
|
||||
})
|
||||
}
|
||||
},
|
||||
insertText: function (...args) {
|
||||
console.warn("TextInputClientMock.insertText interface mocked in the Previewer. How this interface works on" +
|
||||
" the Previewer may be different from that on a 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();
|
||||
})
|
||||
}
|
||||
},
|
||||
insertRichContent: function (...args) {
|
||||
console.warn("TextInputClientMock.insertRichContent interface mocked in the Previewer. How this interface works on" +
|
||||
" the Previewer may be different from that on a 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();
|
||||
})
|
||||
}
|
||||
},
|
||||
deleteBackward: function (...args) {
|
||||
console.warn("TextInputClientMock.deleteBackward interface mocked in the Previewer. How this interface works on" +
|
||||
" the Previewer may be different from that on a 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();
|
||||
})
|
||||
}
|
||||
},
|
||||
deleteForward: function (...args) {
|
||||
console.warn("TextInputClientMock.deleteForward interface mocked in the Previewer. How this interface works on" +
|
||||
" the Previewer may be different from that on a 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();
|
||||
})
|
||||
}
|
||||
},
|
||||
getForward: function (...args) {
|
||||
console.warn("TextInputClientMock.getForward interface mocked in the Previewer. How this interface works on" +
|
||||
" the Previewer may be different 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);
|
||||
})
|
||||
}
|
||||
},
|
||||
getBackward: function (...args) {
|
||||
console.warn("TextInputClientMock.getBackward interface mocked in the Previewer. How this interface works on" +
|
||||
" the Previewer may be different 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);
|
||||
})
|
||||
}
|
||||
},
|
||||
getEditingText: function (...args) {
|
||||
console.warn("TextInputClientMock.getEditingText interface mocked in the Previewer. How this interface works on" +
|
||||
" the Previewer may be different from that on a real device.")
|
||||
const len = args.length
|
||||
if (typeof args[len - 1] === 'function') {
|
||||
args[len - 1].call(this, paramMock.businessErrorMock, EditingText);
|
||||
} else {
|
||||
return new Promise((resolve, reject) => {
|
||||
resolve(EditingText);
|
||||
})
|
||||
}
|
||||
},
|
||||
sendKeyEvent: function (...args) {
|
||||
console.warn("TextInputClientMock.sendKeyEvent interface mocked in the Previewer. How this interface works on" +
|
||||
" the Previewer may be different from that on a 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();
|
||||
})
|
||||
}
|
||||
},
|
||||
sendKeyFunction: function (...args) {
|
||||
console.warn("TextInputClientMock.sendKeyFunction interface mocked in the Previewer. How this interface works on" +
|
||||
" the Previewer may be different from that on a 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();
|
||||
})
|
||||
}
|
||||
},
|
||||
selectText: function (...args) {
|
||||
console.warn("TextInputClientMock.selectText interface mocked in the Previewer. How this interface works on" +
|
||||
" the Previewer may be different from that on a 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();
|
||||
})
|
||||
}
|
||||
},
|
||||
requestCurrentCursorContext: function (...args) {
|
||||
console.warn("TextInputClientMock.requestCurrentCursorContext interface mocked in the Previewer. How this interface works on" +
|
||||
" the Previewer may be different from that on a 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();
|
||||
})
|
||||
}
|
||||
},
|
||||
getAutoCapitalizeMode: function (...args) {
|
||||
console.warn("TextInputClientMock.getAutoCapitalizeMode interface mocked in the Previewer. How this interface works on" +
|
||||
" the Previewer may be different from that on a real device.")
|
||||
const len = args.length
|
||||
if (typeof args[len - 1] === 'function') {
|
||||
args[len - 1].call(this, paramMock.businessErrorMock, paramMock.paramNumberMock);
|
||||
} else {
|
||||
return new Promise((resolve, reject) => {
|
||||
resolve(paramMock.paramNumberMock);
|
||||
})
|
||||
}
|
||||
},
|
||||
reviseText: function (...args) {
|
||||
console.warn("TextInputClientMock.reviseText interface mocked in the Previewer. How this interface works on" +
|
||||
" the Previewer may be different from that on a 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();
|
||||
})
|
||||
}
|
||||
},
|
||||
markText: function (...args) {
|
||||
console.warn("TextInputClientMock.markText interface mocked in the Previewer. How this interface works on" +
|
||||
" the Previewer may be different from that on a 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();
|
||||
})
|
||||
}
|
||||
},
|
||||
unmarkText: function (...args) {
|
||||
console.warn("TextInputClientMock.unmarkText interface mocked in the Previewer. How this interface works on" +
|
||||
" the Previewer may be different from that on a 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();
|
||||
})
|
||||
}
|
||||
},
|
||||
replaceMarkedText: function (...args) {
|
||||
console.warn("TextInputClientMock.replaceMarkedText interface mocked in the Previewer. How this interface works on" +
|
||||
" the Previewer may be different from that on a 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 InputMethodEngineMock = {
|
||||
on: function (...args) {
|
||||
console.warn("InputMethodEngine.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] == 'configurationUpdate') {
|
||||
args[len - 1].call(this, paramMock.paramObjectMock);
|
||||
} else if (args[0] == 'inputStart') {
|
||||
args[len - 1].call(this, KeyboardControllerMock, TextInputClientMock);
|
||||
} else if (args[0] == 'inputStop' || args[0] == 'keyboardShow' || args[0] == 'directionChange' || args[0] == 'keyboardHide') {
|
||||
args[len - 1].call(this);
|
||||
}
|
||||
}
|
||||
},
|
||||
off: function (...args) {
|
||||
console.warn("InputMethodEngine.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] == 'configurationUpdate') {
|
||||
args[len - 1].call(this, paramMock.paramObjectMock);
|
||||
} else if (args[0] == 'inputStart') {
|
||||
args[len - 1].call(this, KeyboardControllerMock, TextInputClientMock);
|
||||
} else if (args[0] == 'inputStop' || args[0] == 'keyboardShow' || args[0] == 'directionChange' || args[0] == 'keyboardHide') {
|
||||
args[len - 1].call(this);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
const KeyboardDelegateMock = {
|
||||
on: function (...args) {
|
||||
console.warn("KeyboardDelegate.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] == 'keyDown' || args[0] == 'keyUp') {
|
||||
args[len - 1].call(this, paramMock.paramObjectMock);
|
||||
} else if (args[0] == 'selectionChange') {
|
||||
args[len - 1].call(this, paramMock.paramNumberMock, paramMock.paramNumberMock, paramMock.paramNumberMock, paramMock.paramNumberMock);
|
||||
} else if (args[0] == 'cursorContextChange') {
|
||||
args[len - 1].call(this, paramMock.paramNumberMock, paramMock.paramNumberMock, paramMock.paramNumberMock);
|
||||
} else if (args[0] == 'textChange') {
|
||||
args[len - 1].call(this, paramMock.paramStringMock);
|
||||
}
|
||||
}
|
||||
},
|
||||
off: function (...args) {
|
||||
console.warn("KeyboardDelegate.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] == 'keyDown' || args[0] == 'keyUp') {
|
||||
args[len - 1].call(this, paramMock.paramObjectMock);
|
||||
} else if (args[0] == 'selectionChange') {
|
||||
args[len - 1].call(this, paramMock.paramNumberMock, paramMock.paramNumberMock, paramMock.paramNumberMock, paramMock.paramNumberMock);
|
||||
} else if (args[0] == 'cursorContextChange') {
|
||||
args[len - 1].call(this, paramMock.paramNumberMock, paramMock.paramNumberMock, paramMock.paramNumberMock);
|
||||
} else if (args[0] == 'textChange') {
|
||||
args[len - 1].call(this, paramMock.paramStringMock);
|
||||
}
|
||||
}
|
||||
},
|
||||
}
|
||||
global.systemplugin.inputMethodEngine = {
|
||||
getInputMethodEngine: function () {
|
||||
console.warn("inputMethodEngine.getInputMethodEngine interface mocked in the Previewer. How this interface works" +
|
||||
" on the Previewer may be different from that on a real device.")
|
||||
return InputMethodEngineMock;
|
||||
},
|
||||
createKeyboardDelegate: function () {
|
||||
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;
|
||||
}
|
||||
const InputMethodEngineMock = {
|
||||
on: function (...args) {
|
||||
console.warn("InputMethodEngine.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] == 'configurationUpdate') {
|
||||
args[len - 1].call(this, paramMock.paramObjectMock);
|
||||
} else if (args[0] == 'inputStart') {
|
||||
args[len - 1].call(this, KeyboardControllerMock, TextInputClientMock);
|
||||
} else if (args[0] == 'inputStop' || args[0] == 'keyboardShow' || args[0] == 'directionChange' || args[0] == 'keyboardHide') {
|
||||
args[len - 1].call(this);
|
||||
}
|
||||
}
|
||||
},
|
||||
off: function (...args) {
|
||||
console.warn("InputMethodEngine.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] == 'configurationUpdate') {
|
||||
args[len - 1].call(this, paramMock.paramObjectMock);
|
||||
} else if (args[0] == 'inputStart') {
|
||||
args[len - 1].call(this, KeyboardControllerMock, TextInputClientMock);
|
||||
} else if (args[0] == 'inputStop' || args[0] == 'keyboardShow' || args[0] == 'directionChange' || args[0] == 'keyboardHide') {
|
||||
args[len - 1].call(this);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
const KeyboardDelegateMock = {
|
||||
on: function (...args) {
|
||||
console.warn("KeyboardDelegate.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] == 'keyDown' || args[0] == 'keyUp') {
|
||||
args[len - 1].call(this, paramMock.paramObjectMock);
|
||||
} else if (args[0] == 'selectionChange') {
|
||||
args[len - 1].call(this, paramMock.paramNumberMock, paramMock.paramNumberMock, paramMock.paramNumberMock, paramMock.paramNumberMock);
|
||||
} else if (args[0] == 'cursorContextChange') {
|
||||
args[len - 1].call(this, paramMock.paramNumberMock, paramMock.paramNumberMock, paramMock.paramNumberMock);
|
||||
} else if (args[0] == 'textChange') {
|
||||
args[len - 1].call(this, paramMock.paramStringMock);
|
||||
}
|
||||
}
|
||||
},
|
||||
off: function (...args) {
|
||||
console.warn("KeyboardDelegate.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] == 'keyDown' || args[0] == 'keyUp') {
|
||||
args[len - 1].call(this, paramMock.paramObjectMock);
|
||||
} else if (args[0] == 'selectionChange') {
|
||||
args[len - 1].call(this, paramMock.paramNumberMock, paramMock.paramNumberMock, paramMock.paramNumberMock, paramMock.paramNumberMock);
|
||||
} else if (args[0] == 'cursorContextChange') {
|
||||
args[len - 1].call(this, paramMock.paramNumberMock, paramMock.paramNumberMock, paramMock.paramNumberMock);
|
||||
} else if (args[0] == 'textChange') {
|
||||
args[len - 1].call(this, paramMock.paramStringMock);
|
||||
}
|
||||
}
|
||||
},
|
||||
}
|
||||
global.systemplugin.inputMethodEngine = {
|
||||
getInputMethodEngine: function () {
|
||||
console.warn("inputMethodEngine.getInputMethodEngine interface mocked in the Previewer. How this interface works" +
|
||||
" on the Previewer may be different from that on a real device.")
|
||||
return InputMethodEngineMock;
|
||||
},
|
||||
createKeyboardDelegate: function () {
|
||||
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) {
|
||||
global.systemplugin.inputMethodEngine[Property] = NOTIFY + " " + Property
|
||||
}
|
||||
for (let Property of Properties) {
|
||||
global.systemplugin.inputMethodEngine[Property] = NOTIFY + " " + Property
|
||||
}
|
||||
}
|
||||
@@ -1,3 +1,18 @@
|
||||
/*
|
||||
* Copyright (c) 2021 Huawei Device Co., Ltd.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import { paramMock } from "./utils"
|
||||
|
||||
const sizeMock = {
|
||||
|
||||
@@ -1,3 +1,18 @@
|
||||
/*
|
||||
* Copyright (c) 2021 Huawei Device Co., Ltd.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import { paramMock } from "../../utils"
|
||||
|
||||
const ModuleInfoMock = {
|
||||
|
||||
@@ -1,54 +1,69 @@
|
||||
/*
|
||||
* 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"
|
||||
import { AbilityContextClass } from "./application/abilityContext"
|
||||
|
||||
const WantClass = class Want {
|
||||
constructor() {
|
||||
console.warn('Ability.Want.constructor interface mocked in the Previewer. How this interface works on' +
|
||||
' the Previewer may be different from that on a real device.');
|
||||
this.deviceId = "[PC Preview] unknow deviceId";
|
||||
this.bundleName = "[PC Preview] unknow bundleName";
|
||||
this.abilityName = "[PC Preview] unknow abilityName";
|
||||
this.uri = "[PC Preview] unknow uri";
|
||||
this.type = "[PC Preview] unknow type";
|
||||
this.flag = "[PC Preview] unknow flag";
|
||||
this.action = "[PC Preview] unknow action";
|
||||
this.parameters = {};
|
||||
this.entities = [paramMock.paramStringMock];
|
||||
}
|
||||
constructor() {
|
||||
console.warn('Ability.Want.constructor interface mocked in the Previewer. How this interface works on' +
|
||||
' the Previewer may be different from that on a real device.');
|
||||
this.deviceId = "[PC Preview] unknow deviceId";
|
||||
this.bundleName = "[PC Preview] unknow bundleName";
|
||||
this.abilityName = "[PC Preview] unknow abilityName";
|
||||
this.uri = "[PC Preview] unknow uri";
|
||||
this.type = "[PC Preview] unknow type";
|
||||
this.flag = "[PC Preview] unknow flag";
|
||||
this.action = "[PC Preview] unknow action";
|
||||
this.parameters = {};
|
||||
this.entities = [paramMock.paramStringMock];
|
||||
}
|
||||
}
|
||||
export function mockAbility() {
|
||||
const AbilityClass = class Ability {
|
||||
constructor() {
|
||||
console.warn('application.Ability.constructor interface mocked in the Previewer. How this interface works on' +
|
||||
' the Previewer may be different from that on a real device.');
|
||||
this.context = new AbilityContextClass();
|
||||
this.launchWant = new WantClass();
|
||||
this.lastRequestWant = new WantClass();
|
||||
this.onCreate = function (...args) {
|
||||
console.warn("application.Ability.onCreate interface mocked in the Previewer. How this interface works on the Previewer" +
|
||||
" may be different from that on a real device.")
|
||||
};
|
||||
this.onWindowStageCreate = function (...args) {
|
||||
console.warn("application.Ability.onWindowStageCreate interface mocked in the Previewer. How this interface works on the Previewer" +
|
||||
" may be different from that on a real device.")
|
||||
};
|
||||
this.onWindowStageDestroy = function () {
|
||||
console.warn("application.Ability.onWindowStageDestroy interface mocked in the Previewer. How this interface works on the Previewer" +
|
||||
" may be different from that on a real device.")
|
||||
};
|
||||
this.onDestroy = function () {
|
||||
console.warn("application.Ability.onDestroy interface mocked in the Previewer. How this interface works on the Previewer" +
|
||||
" may be different from that on a real device.")
|
||||
};
|
||||
this.onForeground = function () {
|
||||
console.warn("application.Ability.onForeground interface mocked in the Previewer. How this interface works on the Previewer" +
|
||||
" may be different from that on a real device.")
|
||||
};
|
||||
this.onBackground = function () {
|
||||
console.warn("application.Ability.onBackground interface mocked in the Previewer. How this interface works on the Previewer" +
|
||||
" may be different from that on a real device.")
|
||||
};
|
||||
}
|
||||
const AbilityClass = class Ability {
|
||||
constructor() {
|
||||
console.warn('application.Ability.constructor interface mocked in the Previewer. How this interface works on' +
|
||||
' the Previewer may be different from that on a real device.');
|
||||
this.context = new AbilityContextClass();
|
||||
this.launchWant = new WantClass();
|
||||
this.lastRequestWant = new WantClass();
|
||||
this.onCreate = function (...args) {
|
||||
console.warn("application.Ability.onCreate interface mocked in the Previewer. How this interface works on the Previewer" +
|
||||
" may be different from that on a real device.")
|
||||
};
|
||||
this.onWindowStageCreate = function (...args) {
|
||||
console.warn("application.Ability.onWindowStageCreate interface mocked in the Previewer. How this interface works on the Previewer" +
|
||||
" may be different from that on a real device.")
|
||||
};
|
||||
this.onWindowStageDestroy = function () {
|
||||
console.warn("application.Ability.onWindowStageDestroy interface mocked in the Previewer. How this interface works on the Previewer" +
|
||||
" may be different from that on a real device.")
|
||||
};
|
||||
this.onDestroy = function () {
|
||||
console.warn("application.Ability.onDestroy interface mocked in the Previewer. How this interface works on the Previewer" +
|
||||
" may be different from that on a real device.")
|
||||
};
|
||||
this.onForeground = function () {
|
||||
console.warn("application.Ability.onForeground interface mocked in the Previewer. How this interface works on the Previewer" +
|
||||
" may be different from that on a real device.")
|
||||
};
|
||||
this.onBackground = function () {
|
||||
console.warn("application.Ability.onBackground interface mocked in the Previewer. How this interface works on the Previewer" +
|
||||
" may be different from that on a real device.")
|
||||
};
|
||||
}
|
||||
return new AbilityClass();
|
||||
}
|
||||
return new AbilityClass();
|
||||
}
|
||||
|
||||
@@ -1,16 +1,31 @@
|
||||
/*
|
||||
* 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 { abilityStageContextClass } from "./application/abilityContext"
|
||||
|
||||
export function mockAbilityStage(){
|
||||
const AbilityStageClass = class AbilityStage{
|
||||
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.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.")
|
||||
}
|
||||
}
|
||||
export function mockAbilityStage() {
|
||||
const AbilityStageClass = class AbilityStage {
|
||||
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.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.")
|
||||
}
|
||||
}
|
||||
return new AbilityStageClass();
|
||||
}
|
||||
return new AbilityStageClass();
|
||||
}
|
||||
@@ -1,15 +1,30 @@
|
||||
/*
|
||||
* 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 mockFormBindingData(){
|
||||
const formBindingDatasMock = {
|
||||
data: paramMock.paramObjectMock
|
||||
}
|
||||
const formBindingDataMock = {
|
||||
createFormBindingData: function (...args) {
|
||||
console.warn("formBindingData.createFormBindingData interface mocked in the Previewer. How this interface works on the Previewer" +
|
||||
" may be different from that on a real device.")
|
||||
return formBindingDatasMock;
|
||||
},
|
||||
}
|
||||
return formBindingDataMock;
|
||||
export function mockFormBindingData() {
|
||||
const formBindingDatasMock = {
|
||||
data: paramMock.paramObjectMock
|
||||
}
|
||||
const formBindingDataMock = {
|
||||
createFormBindingData: function (...args) {
|
||||
console.warn("formBindingData.createFormBindingData interface mocked in the Previewer. How this interface works on the Previewer" +
|
||||
" may be different from that on a real device.")
|
||||
return formBindingDatasMock;
|
||||
},
|
||||
}
|
||||
return formBindingDataMock;
|
||||
}
|
||||
@@ -1,3 +1,18 @@
|
||||
/*
|
||||
* 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"
|
||||
import { ExtensionContextClass } from "./application/abilityContext"
|
||||
|
||||
|
||||
@@ -1,3 +1,18 @@
|
||||
/*
|
||||
* 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"
|
||||
import { ExtensionContextClass } from "./application/abilityContext"
|
||||
|
||||
|
||||
@@ -1,3 +1,18 @@
|
||||
/*
|
||||
* Copyright (c) 2021 Huawei Device Co., Ltd.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import { paramMock } from "../utils"
|
||||
|
||||
export function mockBytrace() {
|
||||
|
||||
@@ -1,19 +1,34 @@
|
||||
/*
|
||||
* 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 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 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 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;
|
||||
}
|
||||
}
|
||||
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;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
@@ -1,5 +1,20 @@
|
||||
import {paramMock} from '../utils';
|
||||
import {RdbPredicatesClass} from './rdb'
|
||||
/*
|
||||
* 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';
|
||||
import { RdbPredicatesClass } from './rdb'
|
||||
|
||||
export function mockDataAbility() {
|
||||
const DataAbilityPredicatesClass = class DataAbilityPredicates {
|
||||
|
||||
@@ -1,44 +1,59 @@
|
||||
import {paramMock} from "../utils"
|
||||
/*
|
||||
* 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 mockDistributedAccount() {
|
||||
const distributedInfoMock = {
|
||||
name: "[PC Preview] unknown name",
|
||||
id: "[PC Preview] unknown id",
|
||||
event: "[PC Preview] unknown event",
|
||||
scalableData: "[PC Preview] unknown scalableData"
|
||||
const distributedInfoMock = {
|
||||
name: "[PC Preview] unknown name",
|
||||
id: "[PC Preview] unknown id",
|
||||
event: "[PC Preview] unknown event",
|
||||
scalableData: "[PC Preview] unknown scalableData"
|
||||
}
|
||||
const distributedAccountAbilityMock = {
|
||||
queryOsAccountDistributedInfo: function (...args) {
|
||||
console.warn("DistributedAccountAbility.queryOsAccountDistributedInfo interface mocked in the Previewer." +
|
||||
" How this interface works on the Previewer may be different from that on a real device.")
|
||||
const len = args.length
|
||||
if (len > 0 && typeof args[len - 1] === 'function') {
|
||||
args[len - 1].call(this, paramMock.businessErrorMock, distributedInfoMock);
|
||||
} else {
|
||||
return new Promise((resolve, reject) => {
|
||||
resolve(distributedInfoMock);
|
||||
})
|
||||
}
|
||||
},
|
||||
updateOsAccountDistributedInfo: function (...args) {
|
||||
console.warn("DistributedAccountAbility.updateOsAccountDistributedInfo interface mocked in the Previewer." +
|
||||
" How this interface works on the Previewer may be different from 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 distributedAccountAbilityMock = {
|
||||
queryOsAccountDistributedInfo: function (...args) {
|
||||
console.warn("DistributedAccountAbility.queryOsAccountDistributedInfo interface mocked in the Previewer." +
|
||||
" How this interface works on the Previewer may be different from that on a real device.")
|
||||
const len = args.length
|
||||
if (len > 0 && typeof args[len - 1] === 'function') {
|
||||
args[len - 1].call(this, paramMock.businessErrorMock, distributedInfoMock);
|
||||
} else {
|
||||
return new Promise((resolve, reject) => {
|
||||
resolve(distributedInfoMock);
|
||||
})
|
||||
}
|
||||
},
|
||||
updateOsAccountDistributedInfo: function (...args) {
|
||||
console.warn("DistributedAccountAbility.updateOsAccountDistributedInfo interface mocked in the Previewer." +
|
||||
" How this interface works on the Previewer may be different from 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 distributedAccount = {
|
||||
getDistributedAccountAbility : function (...args) {
|
||||
console.warn("distributedAccount.getDistributedAccountAbility interface mocked in the Previewer." +
|
||||
" How this interface works on the Previewer may be different from that on a real device.")
|
||||
return distributedAccountAbilityMock;
|
||||
}
|
||||
};
|
||||
const distributedAccount = {
|
||||
getDistributedAccountAbility: function (...args) {
|
||||
console.warn("distributedAccount.getDistributedAccountAbility interface mocked in the Previewer." +
|
||||
" How this interface works on the Previewer may be different from that on a real device.")
|
||||
return distributedAccountAbilityMock;
|
||||
}
|
||||
return distributedAccount;
|
||||
}
|
||||
return distributedAccount;
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@@ -1,34 +1,49 @@
|
||||
import {paramMock} from "../utils"
|
||||
/*
|
||||
* 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 mockEmitter() {
|
||||
const EventDataMock = {
|
||||
data: '[PC preview] unknow data',
|
||||
};
|
||||
const emitter = {
|
||||
on: function (...args) {
|
||||
console.warn("emitter.on interface mocked in the Previewer. How this interface works on the" +
|
||||
" Previewer may be different from that on a real device.");
|
||||
const len = args.length;
|
||||
if (typeof args[len - 1] === 'function') {
|
||||
args[len - 1].call(this, EventDataMock);
|
||||
}
|
||||
},
|
||||
once: function (...args) {
|
||||
console.warn("emitter.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, EventDataMock);
|
||||
}
|
||||
},
|
||||
off: function (...args) {
|
||||
console.warn("emitter.off interface mocked in the Previewer. How this interface works on the" +
|
||||
" Previewer may be different from that on a real device.");
|
||||
},
|
||||
emit: function (...args) {
|
||||
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.");
|
||||
},
|
||||
}
|
||||
return emitter
|
||||
const EventDataMock = {
|
||||
data: '[PC preview] unknow data',
|
||||
};
|
||||
const emitter = {
|
||||
on: function (...args) {
|
||||
console.warn("emitter.on interface mocked in the Previewer. How this interface works on the" +
|
||||
" Previewer may be different from that on a real device.");
|
||||
const len = args.length;
|
||||
if (typeof args[len - 1] === 'function') {
|
||||
args[len - 1].call(this, EventDataMock);
|
||||
}
|
||||
},
|
||||
once: function (...args) {
|
||||
console.warn("emitter.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, EventDataMock);
|
||||
}
|
||||
},
|
||||
off: function (...args) {
|
||||
console.warn("emitter.off interface mocked in the Previewer. How this interface works on the" +
|
||||
" Previewer may be different from that on a real device.");
|
||||
},
|
||||
emit: function (...args) {
|
||||
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.");
|
||||
},
|
||||
}
|
||||
return emitter
|
||||
}
|
||||
|
||||
@@ -1,3 +1,18 @@
|
||||
/*
|
||||
* 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 mockFileio() {
|
||||
@@ -200,7 +215,6 @@ export function mockFileio() {
|
||||
stop: function () {
|
||||
console.warn("Watcher.stop interface mocked in the Previewer. How this interface works on the Previewer" +
|
||||
" may be different from that on a real device.")
|
||||
return
|
||||
}
|
||||
};
|
||||
const fileioMock = {
|
||||
@@ -241,7 +255,6 @@ export function mockFileio() {
|
||||
chmodSync: function (...args) {
|
||||
console.warn("fileio.chmodSync interface mocked in the Previewer. How this interface works on the Previewer" +
|
||||
" may be different from that on a real device.")
|
||||
return
|
||||
},
|
||||
chown: function (...args) {
|
||||
console.warn("fileio.chown interface mocked in the Previewer. How this interface works on the Previewer may" +
|
||||
@@ -258,7 +271,6 @@ export function mockFileio() {
|
||||
chownSync: function (...args) {
|
||||
console.warn("fileio.chownSync interface mocked in the Previewer. How this interface works on the Previewer" +
|
||||
" may be different from that on a real device.")
|
||||
return
|
||||
},
|
||||
close: function (...args) {
|
||||
console.warn("fileio.close interface mocked in the Previewer. How this interface works on the Previewer may" +
|
||||
@@ -275,7 +287,6 @@ export function mockFileio() {
|
||||
closeSync: function (...args) {
|
||||
console.warn("fileio.closeSync interface mocked in the Previewer. How this interface works on the Previewer" +
|
||||
" may be different from that on a real device.")
|
||||
return
|
||||
},
|
||||
copyFile: function (...args) {
|
||||
console.warn("fileio.copyFile interface mocked in the Previewer. How this interface works on the Previewer may" +
|
||||
@@ -335,7 +346,6 @@ export function mockFileio() {
|
||||
fchmodSync: function (...args) {
|
||||
console.warn("fileio.fchmodSync interface mocked in the Previewer. How this interface works on the Previewer" +
|
||||
" may be different from that on a real device.")
|
||||
return
|
||||
},
|
||||
fchown: function (...args) {
|
||||
console.warn("fileio.fchown interface mocked in the Previewer. How this interface works on the Previewer may" +
|
||||
@@ -352,7 +362,6 @@ export function mockFileio() {
|
||||
fchownSync: function (...args) {
|
||||
console.warn("fileio.fchownSync interface mocked in the Previewer. How this interface works on the Previewer" +
|
||||
" may be different from that on a real device.")
|
||||
return
|
||||
},
|
||||
fdatasync: function (...args) {
|
||||
console.warn("fileio.fdatasync interface mocked in the Previewer. How this interface works on the Previewer may" +
|
||||
@@ -369,7 +378,6 @@ export function mockFileio() {
|
||||
fdatasyncSync: function (...args) {
|
||||
console.warn("fileio.fdatasyncSync interface mocked in the Previewer. How this interface works on the Previewer" +
|
||||
" may be different from that on a real device.")
|
||||
return
|
||||
},
|
||||
fdopenStream: function (...args) {
|
||||
console.warn("fileio.fdopenStream interface mocked in the Previewer. How this interface works on the Previewer may be" +
|
||||
@@ -420,7 +428,6 @@ export function mockFileio() {
|
||||
fsyncSync: function (...args) {
|
||||
console.warn("fileio.fsyncSync interface mocked in the Previewer. How this interface works on the Previewer" +
|
||||
" may be different from that on a real device.")
|
||||
return
|
||||
},
|
||||
ftruncate: function (...args) {
|
||||
console.warn("fileio.ftruncate interface mocked in the Previewer. How this interface works on the Previewer may" +
|
||||
@@ -437,7 +444,6 @@ export function mockFileio() {
|
||||
ftruncateSync: function (...args) {
|
||||
console.warn("fileio.ftruncateSync interface mocked in the Previewer. How this interface works on the Previewer" +
|
||||
" may be different from that on a real device.")
|
||||
return
|
||||
},
|
||||
hash: function (...args) {
|
||||
console.warn("fileio.hash interface mocked in the Previewer. How this interface works on the Previewer may be" +
|
||||
@@ -466,7 +472,6 @@ export function mockFileio() {
|
||||
lchownSync: function (...args) {
|
||||
console.warn("fileio.lchownSync interface mocked in the Previewer. How this interface works on the Previewer" +
|
||||
" may be different from that on a real device.")
|
||||
return
|
||||
},
|
||||
lstat: function (...args) {
|
||||
console.warn("fileio.lstat interface mocked in the Previewer. How this interface works on the Previewer may be" +
|
||||
@@ -601,7 +606,6 @@ export function mockFileio() {
|
||||
renameSync: function (...args) {
|
||||
console.warn("fileio.renameSync interface mocked in the Previewer. How this interface works on the Previewer" +
|
||||
" may be different from that on a real device.")
|
||||
return
|
||||
},
|
||||
rmdir: function (...args) {
|
||||
console.warn("fileio.rmdir interface mocked in the Previewer. How this interface works on the Previewer may" +
|
||||
@@ -651,7 +655,6 @@ export function mockFileio() {
|
||||
symlinkSync: function (...args) {
|
||||
console.warn("fileio.symlinkSync interface mocked in the Previewer. How this interface works on the Previewer" +
|
||||
" may be different from that on a real device.")
|
||||
return
|
||||
},
|
||||
truncate: function (...args) {
|
||||
console.warn("fileio.truncate interface mocked in the Previewer. How this interface works on the Previewer may" +
|
||||
@@ -668,7 +671,6 @@ export function mockFileio() {
|
||||
truncateSync: function (...args) {
|
||||
console.warn("fileio.truncateSync interface mocked in the Previewer. How this interface works on the Previewer" +
|
||||
" may be different from that on a real device.")
|
||||
return
|
||||
},
|
||||
unlink: function (...args) {
|
||||
console.warn("fileio.unlink interface mocked in the Previewer. How this interface works on the Previewer may" +
|
||||
|
||||
@@ -1,3 +1,18 @@
|
||||
/*
|
||||
* Copyright (c) 2021 Huawei Device Co., Ltd.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import { paramMock } from "../utils"
|
||||
|
||||
export function mockFileManager() {
|
||||
|
||||
@@ -1,47 +1,62 @@
|
||||
/*
|
||||
* 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"
|
||||
|
||||
function buildMockInfo(interfaceName) {
|
||||
return interfaceName + " interface mocked in the Previewer. How this interface works on the Previewer" +
|
||||
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 mockHiAppEvent() {
|
||||
const EventTypeMock = {
|
||||
FAULT: paramMock.paramNumberMock,
|
||||
STATISTIC: paramMock.paramNumberMock,
|
||||
SECURITY: paramMock.paramNumberMock,
|
||||
BEHAVIOR: paramMock.paramNumberMock
|
||||
}
|
||||
const EventMock = {
|
||||
USER_LOGIN: paramMock.paramStringMock,
|
||||
USER_LOGOUT: paramMock.paramStringMock,
|
||||
DISTRIBUTED_SERVICE_START: paramMock.paramStringMock
|
||||
}
|
||||
const ParamMock = {
|
||||
USER_ID: paramMock.paramStringMock,
|
||||
DISTRIBUTED_SERVICE_NAME: paramMock.paramStringMock,
|
||||
DISTRIBUTED_SERVICE_INSTANCE_ID: paramMock.paramStringMock
|
||||
}
|
||||
const EventTypeMock = {
|
||||
FAULT: paramMock.paramNumberMock,
|
||||
STATISTIC: paramMock.paramNumberMock,
|
||||
SECURITY: paramMock.paramNumberMock,
|
||||
BEHAVIOR: paramMock.paramNumberMock
|
||||
}
|
||||
const EventMock = {
|
||||
USER_LOGIN: paramMock.paramStringMock,
|
||||
USER_LOGOUT: paramMock.paramStringMock,
|
||||
DISTRIBUTED_SERVICE_START: paramMock.paramStringMock
|
||||
}
|
||||
const ParamMock = {
|
||||
USER_ID: paramMock.paramStringMock,
|
||||
DISTRIBUTED_SERVICE_NAME: paramMock.paramStringMock,
|
||||
DISTRIBUTED_SERVICE_INSTANCE_ID: paramMock.paramStringMock
|
||||
}
|
||||
|
||||
const hiAppEvent = {
|
||||
EventType: EventTypeMock,
|
||||
Event: EventMock,
|
||||
Param: ParamMock,
|
||||
write: function (...args) {
|
||||
console.warn(buildMockInfo("hiAppEvent.write"))
|
||||
const len = args.length
|
||||
if (typeof args[len - 1] === 'function') {
|
||||
args[len - 1].call(this, paramMock.businessErrorMock)
|
||||
} else {
|
||||
return new Promise((resolve) => {
|
||||
resolve()
|
||||
})
|
||||
}
|
||||
},
|
||||
configure: function (...args) {
|
||||
console.warn(buildMockInfo("hiAppEvent.configure"));
|
||||
return paramMock.paramBooleanMock
|
||||
}
|
||||
const hiAppEvent = {
|
||||
EventType: EventTypeMock,
|
||||
Event: EventMock,
|
||||
Param: ParamMock,
|
||||
write: function (...args) {
|
||||
console.warn(buildMockInfo("hiAppEvent.write"))
|
||||
const len = args.length
|
||||
if (typeof args[len - 1] === 'function') {
|
||||
args[len - 1].call(this, paramMock.businessErrorMock)
|
||||
} else {
|
||||
return new Promise((resolve) => {
|
||||
resolve()
|
||||
})
|
||||
}
|
||||
},
|
||||
configure: function (...args) {
|
||||
console.warn(buildMockInfo("hiAppEvent.configure"));
|
||||
return paramMock.paramBooleanMock
|
||||
}
|
||||
return hiAppEvent
|
||||
}
|
||||
return hiAppEvent
|
||||
}
|
||||
@@ -1,4 +1,19 @@
|
||||
import {paramMock} from "../utils"
|
||||
/*
|
||||
* 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 mockHilog() {
|
||||
const hilog = {
|
||||
|
||||
@@ -1,3 +1,18 @@
|
||||
/*
|
||||
* 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 { mockSystemParameter } from './systemParameter'
|
||||
import { mockAbility } from './applicationAbility'
|
||||
import { mockFormExtension } from './applicationFormExtension'
|
||||
|
||||
@@ -1,21 +1,36 @@
|
||||
/*
|
||||
* 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 mockInputDevice() {
|
||||
const AxisRange = {
|
||||
source: '[PC preview] unknow source',
|
||||
axis : '[PC preview] unknow axis',
|
||||
max : '[PC preview] unknow max',
|
||||
min: '[PC preview] unknow min'
|
||||
source: '[PC preview] unknow source',
|
||||
axis: '[PC preview] unknow axis',
|
||||
max: '[PC preview] unknow max',
|
||||
min: '[PC preview] unknow min'
|
||||
}
|
||||
const InputDeviceData = {
|
||||
id: '[PC preview] unknow id',
|
||||
name: '[PC preview] unknow name',
|
||||
sources : ['[PC preview] unknow sources'],
|
||||
axisRanges : [AxisRange]
|
||||
id: '[PC preview] unknow id',
|
||||
name: '[PC preview] unknow name',
|
||||
sources: ['[PC preview] unknow sources'],
|
||||
axisRanges: [AxisRange]
|
||||
}
|
||||
|
||||
const EventType = ['add', 'remove', 'update']
|
||||
const DeviceIds = [-1,0,1,2,3,4,5,6,7]
|
||||
const DeviceIds = [-1, 0, 1, 2, 3, 4, 5, 6, 7]
|
||||
const inputDevice = {
|
||||
on: function (...args) {
|
||||
console.warn("inputDevice.on interface mocked in the Previewer. How this interface works on the" +
|
||||
@@ -36,7 +51,7 @@ export function mockInputDevice() {
|
||||
console.warn("inputDevice.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 || len >2) {
|
||||
if (len < 1 || len > 2) {
|
||||
console.warn("the number of parameter must be one or two")
|
||||
} else if (len === 1) {
|
||||
if (EventType.indexOf(args[0]) === -1) {
|
||||
|
||||
@@ -1,193 +1,208 @@
|
||||
/*
|
||||
* 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 mockIntl() {
|
||||
const result = {
|
||||
DateTimeFormat: function(...args) {
|
||||
console.warn("Intl.DateTimeFormat interface mocked in the Previewer. How this interface works on the Previewer" +
|
||||
" may be different from that on a real device.")
|
||||
return DateTimeFormatMock;
|
||||
},
|
||||
NumberFormat: function(...args) {
|
||||
console.warn("Intl.NumberFormat interface mocked in the Previewer. How this interface works on the Previewer" +
|
||||
" may be different from that on a real device.")
|
||||
return NumberFormatMock;
|
||||
},
|
||||
Locale: function(locale) {
|
||||
console.warn("Intl.Locale interface mocked in the Previewer. How this interface works on the Previewer" +
|
||||
" may be different from that on a real device.")
|
||||
return LocaleMock;
|
||||
},
|
||||
Collator: function(...args) {
|
||||
console.warn("Intl.Collator interface mocked in the Previewer. How this interface works on the Previewer" +
|
||||
" may be different from that on a real device.")
|
||||
return CollatorMock;
|
||||
},
|
||||
PluralRules: function(...args) {
|
||||
console.warn("Intl.PluralRules interface mocked in the Previewer. How this interface works on the Previewer" +
|
||||
" may be different from that on a real device.")
|
||||
return PluralRulesMock;
|
||||
},
|
||||
RelativeTimeFormat: function(...args) {
|
||||
console.warn("Intl.RelativeTimeFormat interface mocked in the Previewer. How this interface works on the Previewer" +
|
||||
" may be different from that on a real device.")
|
||||
return RelativeTimeFormatMock;
|
||||
}
|
||||
const result = {
|
||||
DateTimeFormat: function (...args) {
|
||||
console.warn("Intl.DateTimeFormat interface mocked in the Previewer. How this interface works on the Previewer" +
|
||||
" may be different from that on a real device.")
|
||||
return DateTimeFormatMock;
|
||||
},
|
||||
NumberFormat: function (...args) {
|
||||
console.warn("Intl.NumberFormat interface mocked in the Previewer. How this interface works on the Previewer" +
|
||||
" may be different from that on a real device.")
|
||||
return NumberFormatMock;
|
||||
},
|
||||
Locale: function (locale) {
|
||||
console.warn("Intl.Locale interface mocked in the Previewer. How this interface works on the Previewer" +
|
||||
" may be different from that on a real device.")
|
||||
return LocaleMock;
|
||||
},
|
||||
Collator: function (...args) {
|
||||
console.warn("Intl.Collator interface mocked in the Previewer. How this interface works on the Previewer" +
|
||||
" may be different from that on a real device.")
|
||||
return CollatorMock;
|
||||
},
|
||||
PluralRules: function (...args) {
|
||||
console.warn("Intl.PluralRules interface mocked in the Previewer. How this interface works on the Previewer" +
|
||||
" may be different from that on a real device.")
|
||||
return PluralRulesMock;
|
||||
},
|
||||
RelativeTimeFormat: function (...args) {
|
||||
console.warn("Intl.RelativeTimeFormat interface mocked in the Previewer. How this interface works on the Previewer" +
|
||||
" may be different from that on a real device.")
|
||||
return RelativeTimeFormatMock;
|
||||
}
|
||||
const DateTimeFormatMock = {
|
||||
format: function(date) {
|
||||
console.warn("Intl.DateTimeFormat.format interface mocked in the Previewer. How this interface works on the" +
|
||||
" Previewer may be different from that on a real device.");
|
||||
return paramMock.paramStringMock;
|
||||
},
|
||||
formatRange: function(startDate, endDate) {
|
||||
console.warn("Intl.DateTimeFormat.format interface mocked in the Previewer. How this interface works on the" +
|
||||
" Previewer may be different from that on a real device.");
|
||||
return paramMock.paramStringMock;
|
||||
},
|
||||
resolvedOptions: function() {
|
||||
console.warn("Intl.DateTimeFormat.resolvedOptions interface mocked in the Previewer. How this interface works on the" +
|
||||
" Previewer may be different from that on a real device.");
|
||||
return DateTimeOptionsMock;
|
||||
}
|
||||
}
|
||||
const DateTimeFormatMock = {
|
||||
format: function (date) {
|
||||
console.warn("Intl.DateTimeFormat.format interface mocked in the Previewer. How this interface works on the" +
|
||||
" Previewer may be different from that on a real device.");
|
||||
return paramMock.paramStringMock;
|
||||
},
|
||||
formatRange: function (startDate, endDate) {
|
||||
console.warn("Intl.DateTimeFormat.format interface mocked in the Previewer. How this interface works on the" +
|
||||
" Previewer may be different from that on a real device.");
|
||||
return paramMock.paramStringMock;
|
||||
},
|
||||
resolvedOptions: function () {
|
||||
console.warn("Intl.DateTimeFormat.resolvedOptions interface mocked in the Previewer. How this interface works on the" +
|
||||
" Previewer may be different from that on a real device.");
|
||||
return DateTimeOptionsMock;
|
||||
}
|
||||
const NumberFormatMock = {
|
||||
format: function(number) {
|
||||
console.warn("Intl.NumberFormat.format interface mocked in the Previewer. How this interface works on the" +
|
||||
" Previewer may be different from that on a real device.");
|
||||
return paramMock.paramStringMock;
|
||||
},
|
||||
resolvedOptions: function() {
|
||||
console.warn("Intl.NumberFormat.resolvedOptions interface mocked in the Previewer. How this interface works on the" +
|
||||
" Previewer may be different from that on a real device.");
|
||||
return NumberOptionsMock;
|
||||
}
|
||||
}
|
||||
const NumberFormatMock = {
|
||||
format: function (number) {
|
||||
console.warn("Intl.NumberFormat.format interface mocked in the Previewer. How this interface works on the" +
|
||||
" Previewer may be different from that on a real device.");
|
||||
return paramMock.paramStringMock;
|
||||
},
|
||||
resolvedOptions: function () {
|
||||
console.warn("Intl.NumberFormat.resolvedOptions interface mocked in the Previewer. How this interface works on the" +
|
||||
" Previewer may be different from that on a real device.");
|
||||
return NumberOptionsMock;
|
||||
}
|
||||
const LocaleMock = {
|
||||
language: '[PC preview] unknow language',
|
||||
script: '[PC preview] unknow script',
|
||||
region: '[PC preview] unknow region',
|
||||
baseName: '[PC preview] unknow baseName',
|
||||
caseFirst: '[PC preview] unknow caseFirst',
|
||||
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',
|
||||
toString: function() {
|
||||
console.warn("Intl.Locale.toString interface mocked in the Previewer. How this interface works on the" +
|
||||
" Previewer may be different from that on a real device.");
|
||||
return paramMock.paramStringMock;
|
||||
},
|
||||
maximize: function() {
|
||||
console.warn("Intl.Locale.maximize interface mocked in the Previewer. How this interface works on the" +
|
||||
" Previewer may be different from that on a real device.");
|
||||
return LocaleMock;
|
||||
},
|
||||
minimize: function() {
|
||||
console.warn("Intl.Locale.minimize interface mocked in the Previewer. How this interface works on the" +
|
||||
" Previewer may be different from that on a real device.");
|
||||
return LocaleMock;
|
||||
}
|
||||
}
|
||||
const LocaleMock = {
|
||||
language: '[PC preview] unknow language',
|
||||
script: '[PC preview] unknow script',
|
||||
region: '[PC preview] unknow region',
|
||||
baseName: '[PC preview] unknow baseName',
|
||||
caseFirst: '[PC preview] unknow caseFirst',
|
||||
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',
|
||||
toString: function () {
|
||||
console.warn("Intl.Locale.toString interface mocked in the Previewer. How this interface works on the" +
|
||||
" Previewer may be different from that on a real device.");
|
||||
return paramMock.paramStringMock;
|
||||
},
|
||||
maximize: function () {
|
||||
console.warn("Intl.Locale.maximize interface mocked in the Previewer. How this interface works on the" +
|
||||
" Previewer may be different from that on a real device.");
|
||||
return LocaleMock;
|
||||
},
|
||||
minimize: function () {
|
||||
console.warn("Intl.Locale.minimize interface mocked in the Previewer. How this interface works on the" +
|
||||
" Previewer may be different from that on a real device.");
|
||||
return LocaleMock;
|
||||
}
|
||||
const CollatorMock = {
|
||||
compare: function(firstString, secondString) {
|
||||
console.warn("Intl.Collator.compare interface mocked in the Previewer. How this interface works on the" +
|
||||
" Previewer may be different from that on a real device.");
|
||||
return paramMock.paramNumberMock;
|
||||
},
|
||||
resolvedOptions: function() {
|
||||
console.warn("Intl.Collator.resolvedOptions interface mocked in the Previewer. How this interface works on the" +
|
||||
" Previewer may be different from that on a real device.");
|
||||
return CollatorOptionsMock;
|
||||
}
|
||||
}
|
||||
const CollatorMock = {
|
||||
compare: function (firstString, secondString) {
|
||||
console.warn("Intl.Collator.compare interface mocked in the Previewer. How this interface works on the" +
|
||||
" Previewer may be different from that on a real device.");
|
||||
return paramMock.paramNumberMock;
|
||||
},
|
||||
resolvedOptions: function () {
|
||||
console.warn("Intl.Collator.resolvedOptions interface mocked in the Previewer. How this interface works on the" +
|
||||
" Previewer may be different from that on a real device.");
|
||||
return CollatorOptionsMock;
|
||||
}
|
||||
const PluralRulesMock = {
|
||||
select: function(number) {
|
||||
console.warn("Intl.PluralRules.select 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 PluralRulesMock = {
|
||||
select: function (number) {
|
||||
console.warn("Intl.PluralRules.select 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 RelativeTimeFormatMock = {
|
||||
format: function(value, unit) {
|
||||
console.warn("Intl.RelativeTimeFormat.format interface mocked in the Previewer. How this interface works on the" +
|
||||
" Previewer may be different from that on a real device.");
|
||||
return paramMock.paramStringMock;
|
||||
},
|
||||
formatToParts: function(value, unit) {
|
||||
console.warn("Intl.RelativeTimeFormat.formatToParts interface mocked in the Previewer. How this interface works on the" +
|
||||
" Previewer may be different from that on a real device.");
|
||||
return paramMock.paramArrayMock;
|
||||
},
|
||||
resolvedOptions: function() {
|
||||
console.warn("Intl.RelativeTimeFormat.resolvedOptions interface mocked in the Previewer. How this interface works on the" +
|
||||
" Previewer may be different from that on a real device.");
|
||||
return RelativeTimeFormatResolvedOptionsMock;
|
||||
}
|
||||
}
|
||||
const RelativeTimeFormatMock = {
|
||||
format: function (value, unit) {
|
||||
console.warn("Intl.RelativeTimeFormat.format interface mocked in the Previewer. How this interface works on the" +
|
||||
" Previewer may be different from that on a real device.");
|
||||
return paramMock.paramStringMock;
|
||||
},
|
||||
formatToParts: function (value, unit) {
|
||||
console.warn("Intl.RelativeTimeFormat.formatToParts interface mocked in the Previewer. How this interface works on the" +
|
||||
" Previewer may be different from that on a real device.");
|
||||
return paramMock.paramArrayMock;
|
||||
},
|
||||
resolvedOptions: function () {
|
||||
console.warn("Intl.RelativeTimeFormat.resolvedOptions interface mocked in the Previewer. How this interface works on the" +
|
||||
" Previewer may be different from that on a real device.");
|
||||
return RelativeTimeFormatResolvedOptionsMock;
|
||||
}
|
||||
const DateTimeOptionsMock = {
|
||||
locale: '[PC preview] unknow locale',
|
||||
dateStyle: '[PC preview] unknow dateStyle',
|
||||
timeStyle: '[PC preview] unknow timeStyle',
|
||||
hourCycle: '[PC preview] unknow hourCycle',
|
||||
timeZone: '[PC preview] unknow timeZone',
|
||||
numberingSystem: '[PC preview] unknow numberingSystem',
|
||||
hour12: '[PC preview] unknow hour12',
|
||||
weekday: '[PC preview] unknow weekday',
|
||||
era: '[PC preview] unknow era',
|
||||
year: '[PC preview] unknow year',
|
||||
month: '[PC preview] unknow month',
|
||||
day: '[PC preview] unknow day',
|
||||
hour: '[PC preview] unknow hour',
|
||||
minute: '[PC preview] unknow minute',
|
||||
second: '[PC preview] unknow second',
|
||||
timeZoneName: '[PC preview] unknow timeZoneName',
|
||||
dayPeriod: '[PC preview] unknow dayPeriod',
|
||||
localeMatcher: '[PC preview] unknow localeMatcher',
|
||||
formatMatcher: '[PC preview] unknow formatMatcher',
|
||||
}
|
||||
const NumberOptionsMock = {
|
||||
locale: '[PC preview] unknow locale',
|
||||
currency: '[PC preview] unknow currency',
|
||||
currencySign: '[PC preview] unknow currencySign',
|
||||
currencyDisplay: '[PC preview] unknow currencyDisplay',
|
||||
unit: '[PC preview] unknow unit',
|
||||
unitDisplay: '[PC preview] unknow unitDisplay',
|
||||
signDisplay: '[PC preview] unknow signDisplay',
|
||||
compactDisplay: '[PC preview] unknow compactDisplay',
|
||||
notation: '[PC preview] unknow notation',
|
||||
localeMatcher: '[PC preview] unknow localeMatcher',
|
||||
style: '[PC preview] unknow style',
|
||||
numberingSystem: '[PC preview] unknow numberingSystem',
|
||||
useGrouping: '[PC preview] unknow useGrouping',
|
||||
minimumIntegerDigits: '[PC preview] unknow minimumIntegerDigits',
|
||||
minimumFractionDigits: '[PC preview] unknow minimumFractionDigits',
|
||||
maximumFractionDigits: '[PC preview] unknow maximumFractionDigits',
|
||||
minimumSignificantDigits: '[PC preview] unknow minimumSignificantDigits',
|
||||
maximumSignificantDigits: '[PC preview] unknow maximumSignificantDigits',
|
||||
}
|
||||
const CollatorOptionsMock = {
|
||||
localeMatcher: '[PC preview] unknow localeMatcher',
|
||||
usage: '[PC preview] unknow usage',
|
||||
sensitivity: '[PC preview] unknow sensitivity',
|
||||
ignorePunctuation: '[PC preview] unknow ignorePunctuation',
|
||||
collation: '[PC preview] unknow collation',
|
||||
numeric: '[PC preview] unknow numeric',
|
||||
caseFirst: '[PC preview] unknow caseFirst',
|
||||
}
|
||||
const PluralRulesOptionsMock = {
|
||||
localeMatcher: '[PC preview] unknow localeMatcher',
|
||||
type: '[PC preview] unknow type',
|
||||
minimumIntegerDigits: '[PC preview] unknow minimumIntegerDigits',
|
||||
minimumFractionDigits: '[PC preview] unknow minimumFractionDigits',
|
||||
maximumFractionDigits: '[PC preview] unknow maximumFractionDigits',
|
||||
minimumSignificantDigits: '[PC preview] unknow minimumSignificantDigits',
|
||||
maximumSignificantDigits: '[PC preview] unknow maximumSignificantDigits',
|
||||
}
|
||||
const RelativeTimeFormatResolvedOptionsMock = {
|
||||
localeMatcher: '[PC preview] unknow localeMatcher',
|
||||
numeric: '[PC preview] unknow numeric',
|
||||
style: '[PC preview] unknow style',
|
||||
}
|
||||
return result;
|
||||
}
|
||||
const DateTimeOptionsMock = {
|
||||
locale: '[PC preview] unknow locale',
|
||||
dateStyle: '[PC preview] unknow dateStyle',
|
||||
timeStyle: '[PC preview] unknow timeStyle',
|
||||
hourCycle: '[PC preview] unknow hourCycle',
|
||||
timeZone: '[PC preview] unknow timeZone',
|
||||
numberingSystem: '[PC preview] unknow numberingSystem',
|
||||
hour12: '[PC preview] unknow hour12',
|
||||
weekday: '[PC preview] unknow weekday',
|
||||
era: '[PC preview] unknow era',
|
||||
year: '[PC preview] unknow year',
|
||||
month: '[PC preview] unknow month',
|
||||
day: '[PC preview] unknow day',
|
||||
hour: '[PC preview] unknow hour',
|
||||
minute: '[PC preview] unknow minute',
|
||||
second: '[PC preview] unknow second',
|
||||
timeZoneName: '[PC preview] unknow timeZoneName',
|
||||
dayPeriod: '[PC preview] unknow dayPeriod',
|
||||
localeMatcher: '[PC preview] unknow localeMatcher',
|
||||
formatMatcher: '[PC preview] unknow formatMatcher',
|
||||
}
|
||||
const NumberOptionsMock = {
|
||||
locale: '[PC preview] unknow locale',
|
||||
currency: '[PC preview] unknow currency',
|
||||
currencySign: '[PC preview] unknow currencySign',
|
||||
currencyDisplay: '[PC preview] unknow currencyDisplay',
|
||||
unit: '[PC preview] unknow unit',
|
||||
unitDisplay: '[PC preview] unknow unitDisplay',
|
||||
signDisplay: '[PC preview] unknow signDisplay',
|
||||
compactDisplay: '[PC preview] unknow compactDisplay',
|
||||
notation: '[PC preview] unknow notation',
|
||||
localeMatcher: '[PC preview] unknow localeMatcher',
|
||||
style: '[PC preview] unknow style',
|
||||
numberingSystem: '[PC preview] unknow numberingSystem',
|
||||
useGrouping: '[PC preview] unknow useGrouping',
|
||||
minimumIntegerDigits: '[PC preview] unknow minimumIntegerDigits',
|
||||
minimumFractionDigits: '[PC preview] unknow minimumFractionDigits',
|
||||
maximumFractionDigits: '[PC preview] unknow maximumFractionDigits',
|
||||
minimumSignificantDigits: '[PC preview] unknow minimumSignificantDigits',
|
||||
maximumSignificantDigits: '[PC preview] unknow maximumSignificantDigits',
|
||||
}
|
||||
const CollatorOptionsMock = {
|
||||
localeMatcher: '[PC preview] unknow localeMatcher',
|
||||
usage: '[PC preview] unknow usage',
|
||||
sensitivity: '[PC preview] unknow sensitivity',
|
||||
ignorePunctuation: '[PC preview] unknow ignorePunctuation',
|
||||
collation: '[PC preview] unknow collation',
|
||||
numeric: '[PC preview] unknow numeric',
|
||||
caseFirst: '[PC preview] unknow caseFirst',
|
||||
}
|
||||
const PluralRulesOptionsMock = {
|
||||
localeMatcher: '[PC preview] unknow localeMatcher',
|
||||
type: '[PC preview] unknow type',
|
||||
minimumIntegerDigits: '[PC preview] unknow minimumIntegerDigits',
|
||||
minimumFractionDigits: '[PC preview] unknow minimumFractionDigits',
|
||||
maximumFractionDigits: '[PC preview] unknow maximumFractionDigits',
|
||||
minimumSignificantDigits: '[PC preview] unknow minimumSignificantDigits',
|
||||
maximumSignificantDigits: '[PC preview] unknow maximumSignificantDigits',
|
||||
}
|
||||
const RelativeTimeFormatResolvedOptionsMock = {
|
||||
localeMatcher: '[PC preview] unknow localeMatcher',
|
||||
numeric: '[PC preview] unknow numeric',
|
||||
style: '[PC preview] unknow style',
|
||||
}
|
||||
return result;
|
||||
}
|
||||
@@ -1,3 +1,18 @@
|
||||
/*
|
||||
* Copyright (c) 2021 Huawei Device Co., Ltd.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
export function mockMediaQuery() {
|
||||
const mediaquery = {
|
||||
matchMediaSync: function (...args) {
|
||||
@@ -12,8 +27,8 @@ export function mockMediaQuery() {
|
||||
console.warn("listener.off interface mocked in the Previewer." +
|
||||
" How this interface works on the Previewer may be different from that on a real device.")
|
||||
},
|
||||
matches:false,
|
||||
media:String
|
||||
matches: false,
|
||||
media: String
|
||||
};
|
||||
if (args.length === 1 && typeof args[0] === 'string') {
|
||||
listener.media = args[0];
|
||||
|
||||
@@ -1,225 +1,240 @@
|
||||
/*
|
||||
* 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 mockNotification() {
|
||||
const DateMock = {
|
||||
toString: function () {
|
||||
console.warn("Date.toString interface mocked in the Previewer. How this interface works on the Previewer" +
|
||||
" may be different from that on a real device.")
|
||||
" may be different from that on a real device.")
|
||||
return paramMock.paramStringMock
|
||||
},
|
||||
toDateString: function () {
|
||||
console.warn("Date.toDateString interface mocked in the Previewer. How this interface works on the Previewer" +
|
||||
" may be different from that on a real device.")
|
||||
" may be different from that on a real device.")
|
||||
return paramMock.paramStringMock
|
||||
},
|
||||
toTimeString: function () {
|
||||
console.warn("Date.toTimeString interface mocked in the Previewer. How this interface works on the Previewer" +
|
||||
" may be different from that on a real device.")
|
||||
" may be different from that on a real device.")
|
||||
return paramMock.paramStringMock
|
||||
},
|
||||
toLocaleString: function () {
|
||||
console.warn("Date.toLocaleString interface mocked in the Previewer. How this interface works on the Previewer" +
|
||||
" may be different from that on a real device.")
|
||||
" may be different from that on a real device.")
|
||||
return paramMock.paramStringMock
|
||||
},
|
||||
toLocaleDateString: function () {
|
||||
console.warn("Date.toLocaleDateString interface mocked in the Previewer. How this interface works on the Previewer" +
|
||||
" may be different from that on a real device.")
|
||||
" may be different from that on a real device.")
|
||||
return paramMock.paramStringMock
|
||||
},
|
||||
toLocaleTimeString: function () {
|
||||
console.warn("Date.toLocaleTimeString interface mocked in the Previewer. How this interface works on the Previewer" +
|
||||
" may be different from that on a real device.")
|
||||
" may be different from that on a real device.")
|
||||
return paramMock.paramStringMock
|
||||
},
|
||||
valueOf: function () {
|
||||
console.warn("Date.valueOf interface mocked in the Previewer. How this interface works on the Previewer" +
|
||||
" may be different from that on a real device.")
|
||||
" may be different from that on a real device.")
|
||||
return paramMock.paramNumberMock
|
||||
},
|
||||
getTime: function () {
|
||||
console.warn("Date.getTime interface mocked in the Previewer. How this interface works on the Previewer" +
|
||||
" may be different from that on a real device.")
|
||||
" may be different from that on a real device.")
|
||||
return paramMock.paramNumberMock
|
||||
},
|
||||
getFullYear: function () {
|
||||
console.warn("Date.getFullYear interface mocked in the Previewer. How this interface works on the Previewer" +
|
||||
" may be different from that on a real device.")
|
||||
" may be different from that on a real device.")
|
||||
return paramMock.paramNumberMock
|
||||
},
|
||||
getUTCFullYear: function () {
|
||||
console.warn("Date.getUTCFullYear interface mocked in the Previewer. How this interface works on the Previewer" +
|
||||
" may be different from that on a real device.")
|
||||
" may be different from that on a real device.")
|
||||
return paramMock.paramNumberMock
|
||||
},
|
||||
getMonth: function () {
|
||||
console.warn("Date.getMonth interface mocked in the Previewer. How this interface works on the Previewer" +
|
||||
" may be different from that on a real device.")
|
||||
" may be different from that on a real device.")
|
||||
return paramMock.paramNumberMock
|
||||
},
|
||||
getUTCMonth: function () {
|
||||
console.warn("Date.getUTCMonth interface mocked in the Previewer. How this interface works on the Previewer" +
|
||||
" may be different from that on a real device.")
|
||||
" may be different from that on a real device.")
|
||||
return paramMock.paramNumberMock
|
||||
},
|
||||
getDate: function () {
|
||||
console.warn("Date.getDate interface mocked in the Previewer. How this interface works on the Previewer" +
|
||||
" may be different from that on a real device.")
|
||||
" may be different from that on a real device.")
|
||||
return paramMock.paramNumberMock
|
||||
},
|
||||
getUTCDate: function () {
|
||||
console.warn("Date.getUTCDate interface mocked in the Previewer. How this interface works on the Previewer" +
|
||||
" may be different from that on a real device.")
|
||||
" may be different from that on a real device.")
|
||||
return paramMock.paramNumberMock
|
||||
},
|
||||
getDay: function () {
|
||||
console.warn("Date.getDay interface mocked in the Previewer. How this interface works on the Previewer" +
|
||||
" may be different from that on a real device.")
|
||||
" may be different from that on a real device.")
|
||||
return paramMock.paramNumberMock
|
||||
},
|
||||
getUTCDay: function () {
|
||||
console.warn("Date.getUTCDay interface mocked in the Previewer. How this interface works on the Previewer" +
|
||||
" may be different from that on a real device.")
|
||||
" may be different from that on a real device.")
|
||||
return paramMock.paramNumberMock
|
||||
},
|
||||
getHours: function () {
|
||||
console.warn("Date.getHours interface mocked in the Previewer. How this interface works on the Previewer" +
|
||||
" may be different from that on a real device.")
|
||||
" may be different from that on a real device.")
|
||||
return paramMock.paramNumberMock
|
||||
},
|
||||
getUTCHours: function () {
|
||||
console.warn("Date.getUTCHours interface mocked in the Previewer. How this interface works on the Previewer" +
|
||||
" may be different from that on a real device.")
|
||||
" may be different from that on a real device.")
|
||||
return paramMock.paramNumberMock
|
||||
},
|
||||
getMinutes: function () {
|
||||
console.warn("Date.getMinutes interface mocked in the Previewer. How this interface works on the Previewer" +
|
||||
" may be different from that on a real device.")
|
||||
" may be different from that on a real device.")
|
||||
return paramMock.paramNumberMock
|
||||
},
|
||||
getUTCMinutes: function () {
|
||||
console.warn("Date.getUTCMinutes interface mocked in the Previewer. How this interface works on the Previewer" +
|
||||
" may be different from that on a real device.")
|
||||
" may be different from that on a real device.")
|
||||
return paramMock.paramNumberMock
|
||||
},
|
||||
getSeconds: function () {
|
||||
console.warn("Date.getSeconds interface mocked in the Previewer. How this interface works on the Previewer" +
|
||||
" may be different from that on a real device.")
|
||||
" may be different from that on a real device.")
|
||||
return paramMock.paramNumberMock
|
||||
},
|
||||
getUTCSeconds: function () {
|
||||
console.warn("Date.getUTCSeconds interface mocked in the Previewer. How this interface works on the Previewer" +
|
||||
" may be different from that on a real device.")
|
||||
" may be different from that on a real device.")
|
||||
return paramMock.paramNumberMock
|
||||
},
|
||||
getMilliseconds: function () {
|
||||
console.warn("Date.getMilliseconds interface mocked in the Previewer. How this interface works on the Previewer" +
|
||||
" may be different from that on a real device.")
|
||||
" may be different from that on a real device.")
|
||||
return paramMock.paramNumberMock
|
||||
},
|
||||
getUTCMilliseconds: function () {
|
||||
console.warn("Date.getUTCMilliseconds interface mocked in the Previewer. How this interface works on the Previewer" +
|
||||
" may be different from that on a real device.")
|
||||
" may be different from that on a real device.")
|
||||
return paramMock.paramNumberMock
|
||||
},
|
||||
getTimezoneOffset: function () {
|
||||
console.warn("Date.getTimezoneOffset interface mocked in the Previewer. How this interface works on the Previewer" +
|
||||
" may be different from that on a real device.")
|
||||
" may be different from that on a real device.")
|
||||
return paramMock.paramNumberMock
|
||||
},
|
||||
setTime: function (...args) {
|
||||
console.warn("Date.setTime interface mocked in the Previewer. How this interface works on the Previewer" +
|
||||
" may be different from that on a real device.")
|
||||
" may be different from that on a real device.")
|
||||
return paramMock.paramNumberMock
|
||||
},
|
||||
setMilliseconds: function (...args) {
|
||||
console.warn("Date.setMilliseconds interface mocked in the Previewer. How this interface works on the Previewer" +
|
||||
" may be different from that on a real device.")
|
||||
" may be different from that on a real device.")
|
||||
return paramMock.paramNumberMock
|
||||
},
|
||||
setUTCMilliseconds: function (...args) {
|
||||
console.warn("Date.setUTCMilliseconds interface mocked in the Previewer. How this interface works on the Previewer" +
|
||||
" may be different from that on a real device.")
|
||||
" may be different from that on a real device.")
|
||||
return paramMock.paramNumberMock
|
||||
},
|
||||
setSeconds: function (...args) {
|
||||
console.warn("Date.setSeconds interface mocked in the Previewer. How this interface works on the Previewer" +
|
||||
" may be different from that on a real device.")
|
||||
" may be different from that on a real device.")
|
||||
return paramMock.paramNumberMock
|
||||
},
|
||||
setUTCSeconds: function (...args) {
|
||||
console.warn("Date.setUTCSeconds interface mocked in the Previewer. How this interface works on the Previewer" +
|
||||
" may be different from that on a real device.")
|
||||
" may be different from that on a real device.")
|
||||
return paramMock.paramNumberMock
|
||||
},
|
||||
setMinutes: function (...args) {
|
||||
console.warn("Date.setMinutes interface mocked in the Previewer. How this interface works on the Previewer" +
|
||||
" may be different from that on a real device.")
|
||||
" may be different from that on a real device.")
|
||||
return paramMock.paramNumberMock
|
||||
},
|
||||
setUTCMinutes: function (...args) {
|
||||
console.warn("Date.setUTCMinutes interface mocked in the Previewer. How this interface works on the Previewer" +
|
||||
" may be different from that on a real device.")
|
||||
" may be different from that on a real device.")
|
||||
return paramMock.paramNumberMock
|
||||
},
|
||||
setHours: function (...args) {
|
||||
console.warn("Date.setHours interface mocked in the Previewer. How this interface works on the Previewer" +
|
||||
" may be different from that on a real device.")
|
||||
" may be different from that on a real device.")
|
||||
return paramMock.paramNumberMock
|
||||
},
|
||||
setUTCHours: function (...args) {
|
||||
console.warn("Date.setUTCHours interface mocked in the Previewer. How this interface works on the Previewer" +
|
||||
" may be different from that on a real device.")
|
||||
" may be different from that on a real device.")
|
||||
return paramMock.paramNumberMock
|
||||
},
|
||||
setDate: function (...args) {
|
||||
console.warn("Date.setDate interface mocked in the Previewer. How this interface works on the Previewer" +
|
||||
" may be different from that on a real device.")
|
||||
" may be different from that on a real device.")
|
||||
return paramMock.paramNumberMock
|
||||
},
|
||||
setUTCDate: function (...args) {
|
||||
console.warn("Date.setUTCDate interface mocked in the Previewer. How this interface works on the Previewer" +
|
||||
" may be different from that on a real device.")
|
||||
" may be different from that on a real device.")
|
||||
return paramMock.paramNumberMock
|
||||
},
|
||||
setMonth: function (...args) {
|
||||
console.warn("Date.setMonth interface mocked in the Previewer. How this interface works on the Previewer" +
|
||||
" may be different from that on a real device.")
|
||||
" may be different from that on a real device.")
|
||||
return paramMock.paramNumberMock
|
||||
},
|
||||
setUTCMonth: function (...args) {
|
||||
console.warn("Date.setUTCMonth interface mocked in the Previewer. How this interface works on the Previewer" +
|
||||
" may be different from that on a real device.")
|
||||
" may be different from that on a real device.")
|
||||
return paramMock.paramNumberMock
|
||||
},
|
||||
setFullYear: function (...args) {
|
||||
console.warn("Date.setFullYear interface mocked in the Previewer. How this interface works on the Previewer" +
|
||||
" may be different from that on a real device.")
|
||||
" may be different from that on a real device.")
|
||||
return paramMock.paramNumberMock
|
||||
},
|
||||
setUTCFullYear: function (...args) {
|
||||
console.warn("Date.setUTCFullYear interface mocked in the Previewer. How this interface works on the Previewer" +
|
||||
" may be different from that on a real device.")
|
||||
" may be different from that on a real device.")
|
||||
return paramMock.paramNumberMock
|
||||
},
|
||||
toUTCString: function () {
|
||||
console.warn("Date.toUTCString interface mocked in the Previewer. How this interface works on the Previewer" +
|
||||
" may be different from that on a real device.")
|
||||
" may be different from that on a real device.")
|
||||
return paramMock.paramStringMock
|
||||
},
|
||||
toISOString: function () {
|
||||
console.warn("Date.toISOString interface mocked in the Previewer. How this interface works on the Previewer" +
|
||||
" may be different from that on a real device.")
|
||||
" may be different from that on a real device.")
|
||||
return paramMock.paramStringMock
|
||||
},
|
||||
toJSON: function (...args) {
|
||||
console.warn("Date.toJSON interface mocked in the Previewer. How this interface works on the Previewer" +
|
||||
" may be different from that on a real device.")
|
||||
" may be different from that on a real device.")
|
||||
return paramMock.paramStringMock
|
||||
},
|
||||
}
|
||||
const DoNotDisturbDateMock = {
|
||||
DoNotDisturbTypeMock:'[PC preview] unknow DoNotDisturbTypeMock',
|
||||
DoNotDisturbTypeMock: '[PC preview] unknow DoNotDisturbTypeMock',
|
||||
begin: DateMock,
|
||||
end: DateMock
|
||||
}
|
||||
@@ -277,7 +292,7 @@ export function mockNotification() {
|
||||
};
|
||||
const notification = {
|
||||
SlotType: {
|
||||
UNKNOWN_TYPE : 0,
|
||||
UNKNOWN_TYPE: 0,
|
||||
SOCIAL_COMMUNICATION: 1,
|
||||
SERVICE_INFORMATION: 2,
|
||||
CONTENT_INFORMATION: 3,
|
||||
@@ -290,7 +305,7 @@ export function mockNotification() {
|
||||
NOTIFICATION_CONTENT_CONVERSATION: 3,
|
||||
NOTIFICATION_CONTENT_MULTILINE: 4,
|
||||
},
|
||||
publish: function(...args) {
|
||||
publish: function (...args) {
|
||||
console.warn('notification.publish interface mocked in the Previewer. How this interface works on the' +
|
||||
' Previewer may be different from that on a real device.');
|
||||
const len = args.length;
|
||||
@@ -302,7 +317,7 @@ export function mockNotification() {
|
||||
});
|
||||
}
|
||||
},
|
||||
cancel: function(...args) {
|
||||
cancel: function (...args) {
|
||||
console.warn('notification.cancel interface mocked in the Previewer. How this interface works on the' +
|
||||
' Previewer may be different from that on a real device.');
|
||||
const len = args.length;
|
||||
@@ -314,7 +329,7 @@ export function mockNotification() {
|
||||
});
|
||||
}
|
||||
},
|
||||
cancelAll: function(...args) {
|
||||
cancelAll: function (...args) {
|
||||
console.warn('notification.cancelAll interface mocked in the Previewer. How this interface works on the' +
|
||||
' Previewer may be different from that on a real device.');
|
||||
const len = args.length;
|
||||
@@ -326,7 +341,7 @@ export function mockNotification() {
|
||||
});
|
||||
}
|
||||
},
|
||||
addSlot: function(...args) {
|
||||
addSlot: function (...args) {
|
||||
console.warn('notification.addSlot interface mocked in the Previewer. How this interface works on the' +
|
||||
' Previewer may be different from that on a real device.');
|
||||
const len = args.length;
|
||||
@@ -338,7 +353,7 @@ export function mockNotification() {
|
||||
});
|
||||
}
|
||||
},
|
||||
addSlots: function(...args) {
|
||||
addSlots: function (...args) {
|
||||
console.warn('notification.addSlots interface mocked in the Previewer. How this interface works on the' +
|
||||
' Previewer may be different from that on a real device.');
|
||||
const len = args.length;
|
||||
@@ -350,7 +365,7 @@ export function mockNotification() {
|
||||
});
|
||||
}
|
||||
},
|
||||
getSlot: function(...args) {
|
||||
getSlot: function (...args) {
|
||||
console.warn('notification.getSlot interface mocked in the Previewer. How this interface works on the' +
|
||||
' Previewer may be different from that on a real device.');
|
||||
const len = args.length;
|
||||
@@ -362,7 +377,7 @@ export function mockNotification() {
|
||||
});
|
||||
}
|
||||
},
|
||||
getSlots: function(...args) {
|
||||
getSlots: function (...args) {
|
||||
console.warn('notification.getSlots interface mocked in the Previewer. How this interface works on the' +
|
||||
' Previewer may be different from that on a real device.');
|
||||
const len = args.length;
|
||||
@@ -374,7 +389,7 @@ export function mockNotification() {
|
||||
});
|
||||
}
|
||||
},
|
||||
removeSlot: function(...args) {
|
||||
removeSlot: function (...args) {
|
||||
console.warn('notification.removeSlot interface mocked in the Previewer. How this interface works on the' +
|
||||
' Previewer may be different from that on a real device.');
|
||||
const len = args.length;
|
||||
@@ -386,7 +401,7 @@ export function mockNotification() {
|
||||
});
|
||||
}
|
||||
},
|
||||
removeAllSlots: function(...args) {
|
||||
removeAllSlots: function (...args) {
|
||||
console.warn('notification.removeAllSlots interface mocked in the Previewer. How this interface works on the' +
|
||||
' Previewer may be different from that on a real device.');
|
||||
const len = args.length;
|
||||
@@ -398,7 +413,7 @@ export function mockNotification() {
|
||||
});
|
||||
}
|
||||
},
|
||||
subscribe: function(...args) {
|
||||
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.');
|
||||
const len = args.length;
|
||||
@@ -410,7 +425,7 @@ export function mockNotification() {
|
||||
});
|
||||
}
|
||||
},
|
||||
unsubscribe: function(...args) {
|
||||
unsubscribe: function (...args) {
|
||||
console.warn('notification.unsubscribe interface mocked in the Previewer. How this interface works on the' +
|
||||
' Previewer may be different from that on a real device.');
|
||||
const len = args.length;
|
||||
@@ -422,7 +437,7 @@ export function mockNotification() {
|
||||
});
|
||||
}
|
||||
},
|
||||
enableNotification: function(...args) {
|
||||
enableNotification: function (...args) {
|
||||
console.warn('notification.enableNotification interface mocked in the Previewer. How this interface works on the' +
|
||||
' Previewer may be different from that on a real device.');
|
||||
const len = args.length;
|
||||
@@ -434,7 +449,7 @@ export function mockNotification() {
|
||||
});
|
||||
}
|
||||
},
|
||||
isNotificationEnabled: function(...args) {
|
||||
isNotificationEnabled: function (...args) {
|
||||
console.warn('notification.isNotificationEnabled interface mocked in the Previewer. How this interface works on the' +
|
||||
' Previewer may be different from that on a real device.');
|
||||
const len = args.length;
|
||||
@@ -446,7 +461,7 @@ export function mockNotification() {
|
||||
});
|
||||
}
|
||||
},
|
||||
displayBadge: function(...args) {
|
||||
displayBadge: function (...args) {
|
||||
console.warn('notification.displayBadge interface mocked in the Previewer. How this interface works on the' +
|
||||
' Previewer may be different from that on a real device.');
|
||||
const len = args.length;
|
||||
@@ -458,7 +473,7 @@ export function mockNotification() {
|
||||
});
|
||||
}
|
||||
},
|
||||
isBadgeDisplayed: function(...args) {
|
||||
isBadgeDisplayed: function (...args) {
|
||||
console.warn('notification.isBadgeDisplayed interface mocked in the Previewer. How this interface works on the' +
|
||||
' Previewer may be different from that on a real device.');
|
||||
const len = args.length;
|
||||
@@ -470,7 +485,7 @@ export function mockNotification() {
|
||||
});
|
||||
}
|
||||
},
|
||||
setSlotByBundle: function(...args) {
|
||||
setSlotByBundle: function (...args) {
|
||||
console.warn('notification.setSlotByBundle interface mocked in the Previewer. How this interface works on the' +
|
||||
' Previewer may be different from that on a real device.');
|
||||
const len = args.length;
|
||||
@@ -482,7 +497,7 @@ export function mockNotification() {
|
||||
});
|
||||
}
|
||||
},
|
||||
getSlotsByBundle: function(...args) {
|
||||
getSlotsByBundle: function (...args) {
|
||||
console.warn('notification.getSlotsByBundle interface mocked in the Previewer. How this interface works on the' +
|
||||
' Previewer may be different from that on a real device.');
|
||||
const len = args.length;
|
||||
@@ -494,7 +509,7 @@ export function mockNotification() {
|
||||
});
|
||||
}
|
||||
},
|
||||
getSlotNumByBundle: function(...args) {
|
||||
getSlotNumByBundle: function (...args) {
|
||||
console.warn('notification.getSlotNumByBundle interface mocked in the Previewer. How this interface works on the' +
|
||||
' Previewer may be different from that on a real device.');
|
||||
const len = args.length;
|
||||
@@ -506,7 +521,7 @@ export function mockNotification() {
|
||||
});
|
||||
}
|
||||
},
|
||||
remove: function(...args) {
|
||||
remove: function (...args) {
|
||||
console.warn('notification.remove interface mocked in the Previewer. How this interface works on the' +
|
||||
' Previewer may be different from that on a real device.');
|
||||
const len = args.length;
|
||||
@@ -518,7 +533,7 @@ export function mockNotification() {
|
||||
});
|
||||
}
|
||||
},
|
||||
removeAll: function(...args) {
|
||||
removeAll: function (...args) {
|
||||
console.warn('notification.removeAll interface mocked in the Previewer. How this interface works on the' +
|
||||
' Previewer may be different from that on a real device.');
|
||||
const len = args.length;
|
||||
@@ -530,7 +545,7 @@ export function mockNotification() {
|
||||
});
|
||||
}
|
||||
},
|
||||
getAllActiveNotifications: function(...args) {
|
||||
getAllActiveNotifications: function (...args) {
|
||||
console.warn('notification.getAllActiveNotifications interface mocked in the Previewer. How this interface works on the' +
|
||||
' Previewer may be different from that on a real device.');
|
||||
const len = args.length;
|
||||
@@ -542,7 +557,7 @@ export function mockNotification() {
|
||||
});
|
||||
}
|
||||
},
|
||||
getActiveNotificationCount: function(...args) {
|
||||
getActiveNotificationCount: function (...args) {
|
||||
console.warn('notification.getActiveNotificationCount interface mocked in the Previewer. How this interface works on the' +
|
||||
' Previewer may be different from that on a real device.');
|
||||
const len = args.length;
|
||||
@@ -554,7 +569,7 @@ export function mockNotification() {
|
||||
});
|
||||
}
|
||||
},
|
||||
getActiveNotifications: function(...args) {
|
||||
getActiveNotifications: function (...args) {
|
||||
console.warn('notification.getActiveNotifications interface mocked in the Previewer. How this interface works on the' +
|
||||
' Previewer may be different from that on a real device.');
|
||||
const len = args.length;
|
||||
@@ -604,14 +619,14 @@ export function mockNotification() {
|
||||
},
|
||||
getDoNotDisturbDate: function (...args) {
|
||||
console.warn("notification.getDoNotDisturbDate interface mocked in the Previewer." +
|
||||
" How this interface works on the Previewer may be different from that on a real device.")
|
||||
" How this interface works on the Previewer may be different from that on a real device.")
|
||||
const len = args.length
|
||||
if (len > 0 && typeof args[len - 1] === 'function') {
|
||||
args[len - 1].call(this, paramMock.businessErrorMock, DoNotDisturbDateMock);
|
||||
args[len - 1].call(this, paramMock.businessErrorMock, DoNotDisturbDateMock);
|
||||
} else {
|
||||
return new Promise((resolve, reject) => {
|
||||
resolve(DoNotDisturbDateMock);
|
||||
})
|
||||
return new Promise((resolve, reject) => {
|
||||
resolve(DoNotDisturbDateMock);
|
||||
})
|
||||
}
|
||||
},
|
||||
supportDoNotDisturbMode: function (...args) {
|
||||
|
||||
@@ -1,3 +1,18 @@
|
||||
/*
|
||||
* 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 mockPower() {
|
||||
|
||||
@@ -1,144 +1,159 @@
|
||||
/*
|
||||
* 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 mockProcess() {
|
||||
const result = {
|
||||
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.")
|
||||
return ChildProcessMock;
|
||||
},
|
||||
abort: function(...args) {
|
||||
console.warn("process.abort interface mocked in the Previewer. How this interface works on the Previewer" +
|
||||
" may be different from that on a real device.")
|
||||
},
|
||||
on: function(...args) {
|
||||
console.warn("process.on interface mocked in the Previewer. How this interface works on the Previewer" +
|
||||
" may be different from that on a real device.")
|
||||
},
|
||||
off: function(...args) {
|
||||
console.warn("process.off interface mocked in the Previewer. How this interface works on the Previewer" +
|
||||
" may be different from that on a real device.")
|
||||
return paramMock.paramBooleanMock;
|
||||
},
|
||||
exit: function(...args) {
|
||||
console.warn("process.exit interface mocked in the Previewer. How this interface works on the Previewer" +
|
||||
" may be different from that on a real device.")
|
||||
},
|
||||
cwd: function(...args) {
|
||||
console.warn("process.cwd interface mocked in the Previewer. How this interface works on the Previewer" +
|
||||
" may be different from that on a real device.")
|
||||
return paramMock.paramStringMock;
|
||||
},
|
||||
chdir: function(...args) {
|
||||
console.warn("process.chdir interface mocked in the Previewer. How this interface works on the Previewer" +
|
||||
" may be different from that on a real device.")
|
||||
},
|
||||
uptime: function(...args) {
|
||||
console.warn("process.uptime interface mocked in the Previewer. How this interface works on the Previewer" +
|
||||
" may be different from that on a real device.")
|
||||
return paramMock.paramNumberMock;
|
||||
},
|
||||
kill: function(...args) {
|
||||
console.warn("process.kill interface mocked in the Previewer. How this interface works on the Previewer" +
|
||||
" may be different from that on a real device.")
|
||||
return paramMock.paramBooleanMock;
|
||||
},
|
||||
getStartRealtime: function(...args) {
|
||||
console.warn("process.getStartRealtime interface mocked in the Previewer. How this interface works on the Previewer" +
|
||||
" may be different from that on a real device.")
|
||||
return paramMock.paramNumberMock;
|
||||
},
|
||||
getPastCputime: function(...args) {
|
||||
console.warn("process.getPastCputime interface mocked in the Previewer. How this interface works on the Previewer" +
|
||||
" may be different from that on a real device.")
|
||||
return paramMock.paramNumberMock;
|
||||
},
|
||||
getAvailableCores: function(...args) {
|
||||
console.warn("process.getAvailableCores interface mocked in the Previewer. How this interface works on the Previewer" +
|
||||
" may be different from that on a real device.")
|
||||
return paramMock.paramArrayMock;
|
||||
},
|
||||
isIsolatedProcess: function(...args) {
|
||||
console.warn("process.isIsolatedProcess interface mocked in the Previewer. How this interface works on the Previewer" +
|
||||
" may be different from that on a real device.")
|
||||
return paramMock.paramBooleanMock;
|
||||
},
|
||||
is64Bit: function(...args) {
|
||||
console.warn("process.is64Bit interface mocked in the Previewer. How this interface works on the Previewer" +
|
||||
" may be different from that on a real device.")
|
||||
return paramMock.paramBooleanMock;
|
||||
},
|
||||
isAppUid: function(...args) {
|
||||
console.warn("process.isAppUid interface mocked in the Previewer. How this interface works on the Previewer" +
|
||||
" may be different from that on a real device.")
|
||||
return paramMock.paramBooleanMock;
|
||||
},
|
||||
getUidForName: function(...args) {
|
||||
console.warn("process.getUidForName interface mocked in the Previewer. How this interface works on the Previewer" +
|
||||
" may be different from that on a real device.")
|
||||
return paramMock.paramNumberMock;
|
||||
},
|
||||
getThreadPriority: function(...args) {
|
||||
console.warn("process.getThreadPriority interface mocked in the Previewer. How this interface works on the Previewer" +
|
||||
" may be different from that on a real device.")
|
||||
return paramMock.paramNumberMock;
|
||||
},
|
||||
getSystemConfig: function(...args) {
|
||||
console.warn("process.getSystemConfig interface mocked in the Previewer. How this interface works on the Previewer" +
|
||||
" may be different from that on a real device.")
|
||||
return paramMock.paramNumberMock;
|
||||
},
|
||||
getEnvironmentVar: function(...args) {
|
||||
console.warn("process.getEnvironmentVar interface mocked in the Previewer. How this interface works on the Previewer" +
|
||||
" may be different from that on a real device.")
|
||||
return paramMock.paramStringMock;
|
||||
},
|
||||
egid: '[PC preview] unknow egid',
|
||||
euid: '[PC preview] unknow euid',
|
||||
gid: '[PC preview] unknow gid',
|
||||
uid: '[PC preview] unknow uid',
|
||||
groups: '[PC preview] unknow groups',
|
||||
pid: '[PC preview] unknow pid',
|
||||
ppid: '[PC preview] unknow ppid',
|
||||
tid: '[PC preview] unknow tid',
|
||||
}
|
||||
const result = {
|
||||
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.")
|
||||
return ChildProcessMock;
|
||||
},
|
||||
abort: function (...args) {
|
||||
console.warn("process.abort interface mocked in the Previewer. How this interface works on the Previewer" +
|
||||
" may be different from that on a real device.")
|
||||
},
|
||||
on: function (...args) {
|
||||
console.warn("process.on interface mocked in the Previewer. How this interface works on the Previewer" +
|
||||
" may be different from that on a real device.")
|
||||
},
|
||||
off: function (...args) {
|
||||
console.warn("process.off interface mocked in the Previewer. How this interface works on the Previewer" +
|
||||
" may be different from that on a real device.")
|
||||
return paramMock.paramBooleanMock;
|
||||
},
|
||||
exit: function (...args) {
|
||||
console.warn("process.exit interface mocked in the Previewer. How this interface works on the Previewer" +
|
||||
" may be different from that on a real device.")
|
||||
},
|
||||
cwd: function (...args) {
|
||||
console.warn("process.cwd interface mocked in the Previewer. How this interface works on the Previewer" +
|
||||
" may be different from that on a real device.")
|
||||
return paramMock.paramStringMock;
|
||||
},
|
||||
chdir: function (...args) {
|
||||
console.warn("process.chdir interface mocked in the Previewer. How this interface works on the Previewer" +
|
||||
" may be different from that on a real device.")
|
||||
},
|
||||
uptime: function (...args) {
|
||||
console.warn("process.uptime interface mocked in the Previewer. How this interface works on the Previewer" +
|
||||
" may be different from that on a real device.")
|
||||
return paramMock.paramNumberMock;
|
||||
},
|
||||
kill: function (...args) {
|
||||
console.warn("process.kill interface mocked in the Previewer. How this interface works on the Previewer" +
|
||||
" may be different from that on a real device.")
|
||||
return paramMock.paramBooleanMock;
|
||||
},
|
||||
getStartRealtime: function (...args) {
|
||||
console.warn("process.getStartRealtime interface mocked in the Previewer. How this interface works on the Previewer" +
|
||||
" may be different from that on a real device.")
|
||||
return paramMock.paramNumberMock;
|
||||
},
|
||||
getPastCputime: function (...args) {
|
||||
console.warn("process.getPastCputime interface mocked in the Previewer. How this interface works on the Previewer" +
|
||||
" may be different from that on a real device.")
|
||||
return paramMock.paramNumberMock;
|
||||
},
|
||||
getAvailableCores: function (...args) {
|
||||
console.warn("process.getAvailableCores interface mocked in the Previewer. How this interface works on the Previewer" +
|
||||
" may be different from that on a real device.")
|
||||
return paramMock.paramArrayMock;
|
||||
},
|
||||
isIsolatedProcess: function (...args) {
|
||||
console.warn("process.isIsolatedProcess interface mocked in the Previewer. How this interface works on the Previewer" +
|
||||
" may be different from that on a real device.")
|
||||
return paramMock.paramBooleanMock;
|
||||
},
|
||||
is64Bit: function (...args) {
|
||||
console.warn("process.is64Bit interface mocked in the Previewer. How this interface works on the Previewer" +
|
||||
" may be different from that on a real device.")
|
||||
return paramMock.paramBooleanMock;
|
||||
},
|
||||
isAppUid: function (...args) {
|
||||
console.warn("process.isAppUid interface mocked in the Previewer. How this interface works on the Previewer" +
|
||||
" may be different from that on a real device.")
|
||||
return paramMock.paramBooleanMock;
|
||||
},
|
||||
getUidForName: function (...args) {
|
||||
console.warn("process.getUidForName interface mocked in the Previewer. How this interface works on the Previewer" +
|
||||
" may be different from that on a real device.")
|
||||
return paramMock.paramNumberMock;
|
||||
},
|
||||
getThreadPriority: function (...args) {
|
||||
console.warn("process.getThreadPriority interface mocked in the Previewer. How this interface works on the Previewer" +
|
||||
" may be different from that on a real device.")
|
||||
return paramMock.paramNumberMock;
|
||||
},
|
||||
getSystemConfig: function (...args) {
|
||||
console.warn("process.getSystemConfig interface mocked in the Previewer. How this interface works on the Previewer" +
|
||||
" may be different from that on a real device.")
|
||||
return paramMock.paramNumberMock;
|
||||
},
|
||||
getEnvironmentVar: function (...args) {
|
||||
console.warn("process.getEnvironmentVar interface mocked in the Previewer. How this interface works on the Previewer" +
|
||||
" may be different from that on a real device.")
|
||||
return paramMock.paramStringMock;
|
||||
},
|
||||
egid: '[PC preview] unknow egid',
|
||||
euid: '[PC preview] unknow euid',
|
||||
gid: '[PC preview] unknow gid',
|
||||
uid: '[PC preview] unknow uid',
|
||||
groups: '[PC preview] unknow groups',
|
||||
pid: '[PC preview] unknow pid',
|
||||
ppid: '[PC preview] unknow ppid',
|
||||
tid: '[PC preview] unknow tid',
|
||||
}
|
||||
|
||||
const ChildProcessMock = {
|
||||
pid: '[PC preview] unknow pid',
|
||||
ppid: '[PC preview] unknow ppid',
|
||||
exitCode: '[PC preview] unknow exitCode',
|
||||
killed: '[PC preview] unknow killed',
|
||||
wait: function(...args) {
|
||||
console.warn("ChildProcess.wait interface mocked in the Previewer. How this interface works on the Previewer" +
|
||||
" may be different from that on a real device.")
|
||||
return new Promise((resolve, reject) => {
|
||||
resolve(paramMock.paramNumberMock);
|
||||
})
|
||||
},
|
||||
getOutput: function(...args) {
|
||||
console.warn("ChildProcess.getOutput interface mocked in the Previewer. How this interface works on the Previewer" +
|
||||
" may be different from that on a real device.")
|
||||
const arr = new Uint8Array()
|
||||
return new Promise((resolve, reject) => {
|
||||
resolve(arr);
|
||||
})
|
||||
},
|
||||
getErrorOutput: function(...args) {
|
||||
console.warn("ChildProcess.getErrorOutput interface mocked in the Previewer. How this interface works on the Previewer" +
|
||||
" may be different from that on a real device.")
|
||||
const arr = new Uint8Array()
|
||||
return new Promise((resolve, reject) => {
|
||||
resolve(arr);
|
||||
})
|
||||
},
|
||||
close: function (...args) {
|
||||
console.warn("ChildProcess.close interface mocked in the Previewer. How this interface works on the Previewer" +
|
||||
" may be different from that on a real device.")
|
||||
},
|
||||
kill: function (...args) {
|
||||
console.warn("ChildProcess.kill interface mocked in the Previewer. How this interface works on the Previewer" +
|
||||
" may be different from that on a real device.")
|
||||
}
|
||||
const ChildProcessMock = {
|
||||
pid: '[PC preview] unknow pid',
|
||||
ppid: '[PC preview] unknow ppid',
|
||||
exitCode: '[PC preview] unknow exitCode',
|
||||
killed: '[PC preview] unknow killed',
|
||||
wait: function (...args) {
|
||||
console.warn("ChildProcess.wait interface mocked in the Previewer. How this interface works on the Previewer" +
|
||||
" may be different from that on a real device.")
|
||||
return new Promise((resolve, reject) => {
|
||||
resolve(paramMock.paramNumberMock);
|
||||
})
|
||||
},
|
||||
getOutput: function (...args) {
|
||||
console.warn("ChildProcess.getOutput interface mocked in the Previewer. How this interface works on the Previewer" +
|
||||
" may be different from that on a real device.")
|
||||
const arr = new Uint8Array()
|
||||
return new Promise((resolve, reject) => {
|
||||
resolve(arr);
|
||||
})
|
||||
},
|
||||
getErrorOutput: function (...args) {
|
||||
console.warn("ChildProcess.getErrorOutput interface mocked in the Previewer. How this interface works on the Previewer" +
|
||||
" may be different from that on a real device.")
|
||||
const arr = new Uint8Array()
|
||||
return new Promise((resolve, reject) => {
|
||||
resolve(arr);
|
||||
})
|
||||
},
|
||||
close: function (...args) {
|
||||
console.warn("ChildProcess.close interface mocked in the Previewer. How this interface works on the Previewer" +
|
||||
" may be different from that on a real device.")
|
||||
},
|
||||
kill: function (...args) {
|
||||
console.warn("ChildProcess.kill interface mocked in the Previewer. How this interface works on the Previewer" +
|
||||
" may be different from that on a real device.")
|
||||
}
|
||||
return result;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
@@ -1,4 +1,19 @@
|
||||
import {paramMock} from "../utils"
|
||||
/*
|
||||
* 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 const RdbPredicatesClass = class RdbPredicates {
|
||||
constructor(...args) {
|
||||
|
||||
@@ -1,3 +1,18 @@
|
||||
/*
|
||||
* 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 const MessageParcelClass = class MessageParcel {
|
||||
@@ -78,11 +93,11 @@ export const MessageParcelClass = class MessageParcel {
|
||||
" Previewer may be different from that on a real device.")
|
||||
return paramMock.paramBooleanMock
|
||||
};
|
||||
this.writeNoException = function() {
|
||||
this.writeNoException = function () {
|
||||
console.warn("MessageParcel.writeNoException interface mocked in the Previewer. How this interface works on the" +
|
||||
" Previewer may be different from that on a real device.")
|
||||
};
|
||||
this.readException = function() {
|
||||
this.readException = function () {
|
||||
console.warn("MessageParcel.readException interface mocked in the Previewer. How this interface works on the" +
|
||||
" Previewer may be different from that on a real device.")
|
||||
};
|
||||
@@ -377,16 +392,16 @@ export const MessageParcelClass = class MessageParcel {
|
||||
};
|
||||
}
|
||||
};
|
||||
MessageParcelClass.create = function() {
|
||||
MessageParcelClass.create = function () {
|
||||
console.warn("MessageParcel.create interface mocked in the Previewer. How this interface works on the" +
|
||||
" Previewer may be different from that on a real device.")
|
||||
return new MessageParcelClass()
|
||||
};
|
||||
MessageParcelClass.closeFileDescriptor = function(...args) {
|
||||
MessageParcelClass.closeFileDescriptor = function (...args) {
|
||||
console.warn("MessageParcel.closeFileDescriptor interface mocked in the Previewer. How this interface works on the" +
|
||||
" Previewer may be different from that on a real device.")
|
||||
};
|
||||
MessageParcelClass.dupFileDescriptor = function(...args) {
|
||||
MessageParcelClass.dupFileDescriptor = function (...args) {
|
||||
console.warn("MessageParcel.dupFileDescriptor interface mocked in the Previewer. How this interface works on the" +
|
||||
" Previewer may be different from that on a real device.")
|
||||
return paramMock.paramNumberMock
|
||||
@@ -395,21 +410,21 @@ export const MessageOptionClass = class MessageOption {
|
||||
constructor(...args) {
|
||||
console.warn('rpc.MessageOption constructor interface mocked in the Previewer. How this interface works on the' +
|
||||
' Previewer may be different from that on a real device.')
|
||||
this.getFlags = function() {
|
||||
this.getFlags = function () {
|
||||
console.warn("MessageOption.getFlags 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.setFlags = function(...args) {
|
||||
this.setFlags = function (...args) {
|
||||
console.warn("MessageOption.setFlags interface mocked in the Previewer. How this interface works on the" +
|
||||
" Previewer may be different from that on a real device.")
|
||||
};
|
||||
this.getWaitTime = function() {
|
||||
this.getWaitTime = function () {
|
||||
console.warn("MessageOption.getWaitTime 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.setWaitTime = function(...args) {
|
||||
this.setWaitTime = function (...args) {
|
||||
console.warn("MessageOption.setWaitTime interface mocked in the Previewer. How this interface works on the" +
|
||||
" Previewer may be different from that on a real device.")
|
||||
};
|
||||
@@ -423,57 +438,57 @@ export const AshmemClass = class Ashmem {
|
||||
constructor() {
|
||||
console.warn('rpc.Ashmem constructor interface mocked in the Previewer. How this interface works on the' +
|
||||
' Previewer may be different from that on a real device.')
|
||||
this.closeAshmem = function() {
|
||||
this.closeAshmem = function () {
|
||||
console.warn('Ashmem.closeAshmem interface mocked in the Previewer. How this interface works on the' +
|
||||
' Previewer may be different from that on a real device.')
|
||||
};
|
||||
this.unmapAshmem = function() {
|
||||
this.unmapAshmem = function () {
|
||||
console.warn('Ashmem.unmapAshmem interface mocked in the Previewer. How this interface works on the' +
|
||||
' Previewer may be different from that on a real device.')
|
||||
};
|
||||
this.getAshmemSize = function() {
|
||||
this.getAshmemSize = function () {
|
||||
console.warn('Ashmem.getAshmemSize 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.mapAshmem = function(...args) {
|
||||
this.mapAshmem = function (...args) {
|
||||
console.warn('Ashmem.mapAshmem 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.mapReadAndWriteAshmem = function() {
|
||||
this.mapReadAndWriteAshmem = function () {
|
||||
console.warn('Ashmem.mapReadAndWriteAshmem 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.mapReadOnlyAshmem = function() {
|
||||
this.mapReadOnlyAshmem = function () {
|
||||
console.warn('Ashmem.mapReadOnlyAshmem 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.setProtection = function(...args) {
|
||||
this.setProtection = function (...args) {
|
||||
console.warn('Ashmem.setProtection 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.writeToAshmem = function(...args) {
|
||||
this.writeToAshmem = function (...args) {
|
||||
console.warn('Ashmem.writeToAshmem 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.readFromAshmem = function(...args) {
|
||||
this.readFromAshmem = function (...args) {
|
||||
console.warn('Ashmem.readFromAshmem interface mocked in the Previewer. How this interface works on the' +
|
||||
' Previewer may be different from that on a real device.')
|
||||
return paramMock.paramArrayMock
|
||||
};
|
||||
}
|
||||
};
|
||||
AshmemClass.createAshmem = function(...args) {
|
||||
AshmemClass.createAshmem = function (...args) {
|
||||
console.warn('Ashmem.createAshmem interface mocked in the Previewer. How this interface works on the' +
|
||||
' Previewer may be different from that on a real device.')
|
||||
return new AshmemClass()
|
||||
};
|
||||
AshmemClass.createAshmemFromExisting = function(...args) {
|
||||
AshmemClass.createAshmemFromExisting = function (...args) {
|
||||
console.warn('Ashmem.createAshmemFromExisting interface mocked in the Previewer. How this interface works on the' +
|
||||
' Previewer may be different from that on a real device.')
|
||||
return new AshmemClass()
|
||||
@@ -486,22 +501,22 @@ export const RemoteObjectClass = class RemoteObject {
|
||||
constructor(...args) {
|
||||
console.warn("rpc.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(...args) {
|
||||
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 IRemoteBrokerMock
|
||||
};
|
||||
this.getInterfaceDescriptor = function() {
|
||||
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) {
|
||||
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) {
|
||||
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.")
|
||||
const len = args.length
|
||||
@@ -513,17 +528,17 @@ export const RemoteObjectClass = class RemoteObject {
|
||||
})
|
||||
}
|
||||
};
|
||||
this.getCallingPid = function() {
|
||||
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() {
|
||||
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) {
|
||||
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.")
|
||||
};
|
||||
@@ -548,12 +563,12 @@ export const RemoteProxyClass = class RemoteProxy {
|
||||
constructor() {
|
||||
console.warn("rpc.RemoteProxy 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(...args) {
|
||||
this.queryLocalInterface = function (...args) {
|
||||
console.warn("RemoteProxy.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.getInterfaceDescriptor = function() {
|
||||
this.getInterfaceDescriptor = function () {
|
||||
console.warn("RemoteProxy.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
|
||||
@@ -573,7 +588,7 @@ export const RemoteProxyClass = class RemoteProxy {
|
||||
" Previewer may be different from that on a real device.")
|
||||
return paramMock.paramBooleanMock
|
||||
};
|
||||
this.sendRequest = function(...args) {
|
||||
this.sendRequest = function (...args) {
|
||||
console.warn("RemoteProxy.sendRequest mocked in the Previewer. How this interface works on the" +
|
||||
" Previewer may be different from that on a real device.")
|
||||
const len = args.length
|
||||
@@ -645,20 +660,20 @@ export const SendRequestResultMock = {
|
||||
reply: "[PC Preview]: unknow reply",
|
||||
};
|
||||
export const SequenceableMock = {
|
||||
marshalling: function(...args) {
|
||||
marshalling: function (...args) {
|
||||
console.warn("Sequenceable.marshalling interface mocked in the Previewer. How this interface works on the" +
|
||||
" Previewer may be different from that on a real device.")
|
||||
return paramMock.paramBooleanMock
|
||||
},
|
||||
|
||||
unmarshalling: function(...args) {
|
||||
unmarshalling: function (...args) {
|
||||
console.warn("Sequenceable.unmarshalling 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 DeathRecipientMock = {
|
||||
onRemoteDied: function() {
|
||||
onRemoteDied: function () {
|
||||
console.warn("DeathRecipient.onRemoteDied interface mocked in the Previewer. How this interface works on the" +
|
||||
" Previewer may be different from that on a real device.")
|
||||
}
|
||||
|
||||
@@ -1,3 +1,18 @@
|
||||
/*
|
||||
* 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 mockRunningLock() {
|
||||
@@ -17,8 +32,8 @@ export function mockRunningLock() {
|
||||
}
|
||||
};
|
||||
const RunningLockType = {
|
||||
BACKGROUND : '[PC Preview] unknow BACKGROUND',
|
||||
PROXIMITY_SCREEN_CONTROL : '[PC Preview] unknow PROXIMITY_SCREEN_CONTROL'
|
||||
BACKGROUND: '[PC Preview] unknow BACKGROUND',
|
||||
PROXIMITY_SCREEN_CONTROL: '[PC Preview] unknow PROXIMITY_SCREEN_CONTROL'
|
||||
};
|
||||
const runningLock = {
|
||||
RunningLockType,
|
||||
|
||||
@@ -1,3 +1,18 @@
|
||||
/*
|
||||
* 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 mockSettings() {
|
||||
|
||||
@@ -1,3 +1,18 @@
|
||||
/*
|
||||
* 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 mockStatfs() {
|
||||
|
||||
@@ -1,170 +1,185 @@
|
||||
/*
|
||||
* Copyright (c) 2021 Huawei Device Co., Ltd.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import { paramMock } from "../utils"
|
||||
|
||||
export function mockStorage() {
|
||||
const storageMock = {
|
||||
getStorageSync: function (...args) {
|
||||
console.warn("Storage.getStorageSync interface mocked in the Previewer. How this interface works on the" +
|
||||
" Previewer may be different from that on a real device.")
|
||||
return storage;
|
||||
},
|
||||
getStorage: function (...args) {
|
||||
console.warn("Storage.getStorage interface mocked in the Previewer. How this interface works on the" +
|
||||
" Previewer may be different from that on a real device.")
|
||||
const len = args.length
|
||||
if (len > 0 && typeof args[len - 1] === 'function') {
|
||||
args[len - 1].call(this, paramMock.businessErrorMock, storage);
|
||||
} else {
|
||||
return new Promise((resolve, reject) => {
|
||||
resolve(storage);
|
||||
})
|
||||
}
|
||||
},
|
||||
deleteStorageSync: function (...args) {
|
||||
console.warn("Storage.deleteStorageSync interface mocked in the Previewer. How this interface works on the" +
|
||||
" Previewer may be different from that on a real device.")
|
||||
},
|
||||
deleteStorage: function (...args) {
|
||||
console.warn("Storage.deleteStorage interface mocked in the Previewer. How this interface works on the" +
|
||||
" Previewer may be different from that on a real device.")
|
||||
const len = args.length
|
||||
if (len > 0 && typeof args[len - 1] === 'function') {
|
||||
args[len - 1].call(this, paramMock.businessErrorMock);
|
||||
} else {
|
||||
return new Promise((resolve, reject) => {
|
||||
resolve();
|
||||
})
|
||||
}
|
||||
},
|
||||
removeStorageFromCacheSync: function (...args) {
|
||||
console.warn("Storage.removeStorageFromCacheSync interface mocked in the Previewer. How this interface works on the" +
|
||||
" Previewer may be different from that on a real device.")
|
||||
},
|
||||
removeStorageFromCache: function (...args) {
|
||||
console.warn("Storage.removeStorageFromCache interface mocked in the Previewer. How this interface works on the" +
|
||||
" Previewer may be different from that on a real device.")
|
||||
const len = args.length
|
||||
if (len > 0 && typeof args[len - 1] === 'function') {
|
||||
args[len - 1].call(this, paramMock.businessErrorMock);
|
||||
} else {
|
||||
return new Promise((resolve, reject) => {
|
||||
resolve();
|
||||
})
|
||||
}
|
||||
},
|
||||
};
|
||||
const storageObserver = {
|
||||
key: "[PC Preview] unknown key",
|
||||
};
|
||||
const storage = {
|
||||
getSync: function (...args) {
|
||||
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 paramMock.paramNumberMock;
|
||||
},
|
||||
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 (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);
|
||||
})
|
||||
}
|
||||
},
|
||||
hasSync: function (...args) {
|
||||
console.warn("Storage.hasSync interface mocked in the Previewer. How this interface works on the" +
|
||||
" Previewer may be different from that on a real device.")
|
||||
return paramMock.paramBooleanMock;
|
||||
},
|
||||
has: function (...args) {
|
||||
console.warn("Storage.has interface mocked in the Previewer. How this interface works on the" +
|
||||
" Previewer may be different from that on a real device.")
|
||||
const len = args.length
|
||||
if (len > 0 && typeof args[len - 1] === 'function') {
|
||||
args[len - 1].call(this, paramMock.businessErrorMock, paramMock.paramBooleanMock);
|
||||
} else {
|
||||
return new Promise((resolve, reject) => {
|
||||
resolve(paramMock.paramBooleanMock);
|
||||
})
|
||||
}
|
||||
},
|
||||
putSync: function (...args) {
|
||||
console.warn("Storage.putSync interface mocked in the Previewer. How this interface works on the" +
|
||||
" Previewer may be different from that on a real device.")
|
||||
},
|
||||
put: function (...args) {
|
||||
console.warn("Storage.put interface mocked in the Previewer. How this interface works on the" +
|
||||
" Previewer may be different from 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();
|
||||
})
|
||||
}
|
||||
},
|
||||
deleteSync: function (...args) {
|
||||
console.warn("Storage.deleteSync interface mocked in the Previewer. How this interface works on the" +
|
||||
" Previewer may be different from that on a real device.")
|
||||
},
|
||||
delete: function (...args) {
|
||||
console.warn("Storage.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 (len > 0 && typeof args[len - 1] === 'function') {
|
||||
args[len - 1].call(this, paramMock.businessErrorMock);
|
||||
} else {
|
||||
return new Promise((resolve, reject) => {
|
||||
resolve();
|
||||
})
|
||||
}
|
||||
},
|
||||
clearSync: function (...args) {
|
||||
console.warn("Storage.clearSync interface mocked in the Previewer. How this interface works on the" +
|
||||
" Previewer may be different from that on a real device.")
|
||||
},
|
||||
clear: function (...args) {
|
||||
console.warn("Storage.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 (len > 0 && typeof args[len - 1] === 'function') {
|
||||
args[len - 1].call(this, paramMock.businessErrorMock);
|
||||
} else {
|
||||
return new Promise((resolve, reject) => {
|
||||
resolve();
|
||||
})
|
||||
}
|
||||
},
|
||||
flushSync: function (...args) {
|
||||
console.warn("Storage.flushSync interface mocked in the Previewer. How this interface works on the" +
|
||||
" Previewer may be different from that on a real device.")
|
||||
},
|
||||
flush: function (...args) {
|
||||
console.warn("Storage.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 (len > 0 && typeof args[len - 1] === 'function') {
|
||||
args[len - 1].call(this, paramMock.businessErrorMock);
|
||||
} else {
|
||||
return new Promise((resolve, reject) => {
|
||||
resolve();
|
||||
})
|
||||
}
|
||||
},
|
||||
on: function (...args) {
|
||||
console.warn("Storage.on interface mocked in the Previewer. How this interface works on the" +
|
||||
" Previewer may be different from that on a real device.")
|
||||
return 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.")
|
||||
return storageObserver;
|
||||
},
|
||||
};
|
||||
return storageMock;
|
||||
const storageMock = {
|
||||
getStorageSync: function (...args) {
|
||||
console.warn("Storage.getStorageSync interface mocked in the Previewer. How this interface works on the" +
|
||||
" Previewer may be different from that on a real device.")
|
||||
return storage;
|
||||
},
|
||||
getStorage: function (...args) {
|
||||
console.warn("Storage.getStorage interface mocked in the Previewer. How this interface works on the" +
|
||||
" Previewer may be different from that on a real device.")
|
||||
const len = args.length
|
||||
if (len > 0 && typeof args[len - 1] === 'function') {
|
||||
args[len - 1].call(this, paramMock.businessErrorMock, storage);
|
||||
} else {
|
||||
return new Promise((resolve, reject) => {
|
||||
resolve(storage);
|
||||
})
|
||||
}
|
||||
},
|
||||
deleteStorageSync: function (...args) {
|
||||
console.warn("Storage.deleteStorageSync interface mocked in the Previewer. How this interface works on the" +
|
||||
" Previewer may be different from that on a real device.")
|
||||
},
|
||||
deleteStorage: function (...args) {
|
||||
console.warn("Storage.deleteStorage interface mocked in the Previewer. How this interface works on the" +
|
||||
" Previewer may be different from that on a real device.")
|
||||
const len = args.length
|
||||
if (len > 0 && typeof args[len - 1] === 'function') {
|
||||
args[len - 1].call(this, paramMock.businessErrorMock);
|
||||
} else {
|
||||
return new Promise((resolve, reject) => {
|
||||
resolve();
|
||||
})
|
||||
}
|
||||
},
|
||||
removeStorageFromCacheSync: function (...args) {
|
||||
console.warn("Storage.removeStorageFromCacheSync interface mocked in the Previewer. How this interface works on the" +
|
||||
" Previewer may be different from that on a real device.")
|
||||
},
|
||||
removeStorageFromCache: function (...args) {
|
||||
console.warn("Storage.removeStorageFromCache interface mocked in the Previewer. How this interface works on the" +
|
||||
" Previewer may be different from that on a real device.")
|
||||
const len = args.length
|
||||
if (len > 0 && typeof args[len - 1] === 'function') {
|
||||
args[len - 1].call(this, paramMock.businessErrorMock);
|
||||
} else {
|
||||
return new Promise((resolve, reject) => {
|
||||
resolve();
|
||||
})
|
||||
}
|
||||
},
|
||||
};
|
||||
const storageObserver = {
|
||||
key: "[PC Preview] unknown key",
|
||||
};
|
||||
const storage = {
|
||||
getSync: function (...args) {
|
||||
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 paramMock.paramNumberMock;
|
||||
},
|
||||
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 (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);
|
||||
})
|
||||
}
|
||||
},
|
||||
hasSync: function (...args) {
|
||||
console.warn("Storage.hasSync interface mocked in the Previewer. How this interface works on the" +
|
||||
" Previewer may be different from that on a real device.")
|
||||
return paramMock.paramBooleanMock;
|
||||
},
|
||||
has: function (...args) {
|
||||
console.warn("Storage.has interface mocked in the Previewer. How this interface works on the" +
|
||||
" Previewer may be different from that on a real device.")
|
||||
const len = args.length
|
||||
if (len > 0 && typeof args[len - 1] === 'function') {
|
||||
args[len - 1].call(this, paramMock.businessErrorMock, paramMock.paramBooleanMock);
|
||||
} else {
|
||||
return new Promise((resolve, reject) => {
|
||||
resolve(paramMock.paramBooleanMock);
|
||||
})
|
||||
}
|
||||
},
|
||||
putSync: function (...args) {
|
||||
console.warn("Storage.putSync interface mocked in the Previewer. How this interface works on the" +
|
||||
" Previewer may be different from that on a real device.")
|
||||
},
|
||||
put: function (...args) {
|
||||
console.warn("Storage.put interface mocked in the Previewer. How this interface works on the" +
|
||||
" Previewer may be different from 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();
|
||||
})
|
||||
}
|
||||
},
|
||||
deleteSync: function (...args) {
|
||||
console.warn("Storage.deleteSync interface mocked in the Previewer. How this interface works on the" +
|
||||
" Previewer may be different from that on a real device.")
|
||||
},
|
||||
delete: function (...args) {
|
||||
console.warn("Storage.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 (len > 0 && typeof args[len - 1] === 'function') {
|
||||
args[len - 1].call(this, paramMock.businessErrorMock);
|
||||
} else {
|
||||
return new Promise((resolve, reject) => {
|
||||
resolve();
|
||||
})
|
||||
}
|
||||
},
|
||||
clearSync: function (...args) {
|
||||
console.warn("Storage.clearSync interface mocked in the Previewer. How this interface works on the" +
|
||||
" Previewer may be different from that on a real device.")
|
||||
},
|
||||
clear: function (...args) {
|
||||
console.warn("Storage.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 (len > 0 && typeof args[len - 1] === 'function') {
|
||||
args[len - 1].call(this, paramMock.businessErrorMock);
|
||||
} else {
|
||||
return new Promise((resolve, reject) => {
|
||||
resolve();
|
||||
})
|
||||
}
|
||||
},
|
||||
flushSync: function (...args) {
|
||||
console.warn("Storage.flushSync interface mocked in the Previewer. How this interface works on the" +
|
||||
" Previewer may be different from that on a real device.")
|
||||
},
|
||||
flush: function (...args) {
|
||||
console.warn("Storage.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 (len > 0 && typeof args[len - 1] === 'function') {
|
||||
args[len - 1].call(this, paramMock.businessErrorMock);
|
||||
} else {
|
||||
return new Promise((resolve, reject) => {
|
||||
resolve();
|
||||
})
|
||||
}
|
||||
},
|
||||
on: function (...args) {
|
||||
console.warn("Storage.on interface mocked in the Previewer. How this interface works on the" +
|
||||
" Previewer may be different from that on a real device.")
|
||||
return 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.")
|
||||
return storageObserver;
|
||||
},
|
||||
};
|
||||
return storageMock;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,3 +1,18 @@
|
||||
/*
|
||||
* 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 mockSystemParameter() {
|
||||
|
||||
+2484
-2469
File diff suppressed because it is too large
Load Diff
@@ -1,43 +1,58 @@
|
||||
/*
|
||||
* Copyright (c) 2021 Huawei Device Co., Ltd.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import { paramMock } from "../utils"
|
||||
|
||||
export function mockUri() {
|
||||
const result = {
|
||||
URI: function(...args) {
|
||||
console.warn("uri.URI interface mocked in the Previewer. How this interface works on the Previewer" +
|
||||
" may be different from that on a real device.")
|
||||
return URIMock;
|
||||
}
|
||||
const result = {
|
||||
URI: function (...args) {
|
||||
console.warn("uri.URI interface mocked in the Previewer. How this interface works on the Previewer" +
|
||||
" may be different from that on a real device.")
|
||||
return URIMock;
|
||||
}
|
||||
const URIMock = {
|
||||
toString: function(...args) {
|
||||
console.warn("URI.toString interface mocked in the Previewer. How this interface works on the Previewer" +
|
||||
" may be different from that on a real device.")
|
||||
return paramMock.paramStringMock;
|
||||
},
|
||||
equals: function(...args) {
|
||||
console.warn("URI.equals interface mocked in the Previewer. How this interface works on the Previewer" +
|
||||
" may be different from that on a real device.")
|
||||
return paramMock.paramBooleanMock;
|
||||
},
|
||||
checkIsAbsolute: function(...args) {
|
||||
console.warn("URI.checkIsAbsolute interface mocked in the Previewer. How this interface works on the Previewer" +
|
||||
" may be different from that on a real device.")
|
||||
return paramMock.paramBooleanMock;
|
||||
},
|
||||
normalize: function(...args) {
|
||||
console.warn("URI.normalize interface mocked in the Previewer. How this interface works on the Previewer" +
|
||||
" may be different from that on a real device.")
|
||||
return paramMock.paramObjectMock;
|
||||
},
|
||||
scheme: '[PC preview] unknow scheme',
|
||||
userinfo: '[PC preview] unknow userinfo',
|
||||
host: '[PC preview] unknow host',
|
||||
port: '[PC preview] unknow port',
|
||||
path: '[PC preview] unknow path',
|
||||
query: '[PC preview] unknow query',
|
||||
fragment: '[PC preview] unknow fragment',
|
||||
authority: '[PC preview] unknow authority',
|
||||
ssp: '[PC preview] unknow ssp'
|
||||
}
|
||||
return result;
|
||||
}
|
||||
const URIMock = {
|
||||
toString: function (...args) {
|
||||
console.warn("URI.toString interface mocked in the Previewer. How this interface works on the Previewer" +
|
||||
" may be different from that on a real device.")
|
||||
return paramMock.paramStringMock;
|
||||
},
|
||||
equals: function (...args) {
|
||||
console.warn("URI.equals interface mocked in the Previewer. How this interface works on the Previewer" +
|
||||
" may be different from that on a real device.")
|
||||
return paramMock.paramBooleanMock;
|
||||
},
|
||||
checkIsAbsolute: function (...args) {
|
||||
console.warn("URI.checkIsAbsolute interface mocked in the Previewer. How this interface works on the Previewer" +
|
||||
" may be different from that on a real device.")
|
||||
return paramMock.paramBooleanMock;
|
||||
},
|
||||
normalize: function (...args) {
|
||||
console.warn("URI.normalize interface mocked in the Previewer. How this interface works on the Previewer" +
|
||||
" may be different from that on a real device.")
|
||||
return paramMock.paramObjectMock;
|
||||
},
|
||||
scheme: '[PC preview] unknow scheme',
|
||||
userinfo: '[PC preview] unknow userinfo',
|
||||
host: '[PC preview] unknow host',
|
||||
port: '[PC preview] unknow port',
|
||||
path: '[PC preview] unknow path',
|
||||
query: '[PC preview] unknow query',
|
||||
fragment: '[PC preview] unknow fragment',
|
||||
authority: '[PC preview] unknow authority',
|
||||
ssp: '[PC preview] unknow ssp'
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
@@ -1,4 +1,19 @@
|
||||
import {paramMock} from '../utils';
|
||||
/*
|
||||
* 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 mockUrl() {
|
||||
const URLSearchParamsClass = class URLSearchParams {
|
||||
@@ -6,20 +21,20 @@ export function mockUrl() {
|
||||
console.warn('url.URLSearchParams.constructor interface mocked in the Previewer. How this interface works on' +
|
||||
' the Previewer' +
|
||||
' may be different from that on a real device.');
|
||||
this.append = function(...args) {
|
||||
this.append = function (...args) {
|
||||
console.warn('url.URLSearchParams.append interface mocked in the Previewer. How this interface works on the Previewer' +
|
||||
' may be different from that on a real device.');
|
||||
};
|
||||
this.delete = function(...args) {
|
||||
this.delete = function (...args) {
|
||||
console.warn('url.URLSearchParams.delete interface mocked in the Previewer. How this interface works on the Previewer' +
|
||||
' may be different from that on a real device.');
|
||||
};
|
||||
this.getAll = function(...args) {
|
||||
this.getAll = function (...args) {
|
||||
console.warn('url.URLSearchParams.getAll 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.entries = function(...args) {
|
||||
this.entries = function (...args) {
|
||||
console.warn('url.URLSearchParams.entries interface mocked in the Previewer. How this interface works on the Previewer' +
|
||||
' may be different from that on a real device.');
|
||||
const IteratorTwoStringMock = {
|
||||
@@ -29,29 +44,29 @@ export function mockUrl() {
|
||||
};
|
||||
return IteratorTwoStringMock;
|
||||
};
|
||||
this.forEach = function(...args) {
|
||||
this.forEach = function (...args) {
|
||||
console.warn('url.URLSearchParams.forEach 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) {
|
||||
this.get = function (...args) {
|
||||
console.warn('url.URLSearchParams.get 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.has = function(...args) {
|
||||
this.has = function (...args) {
|
||||
console.warn('url.URLSearchParams.has 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.set = function(...args) {
|
||||
this.set = function (...args) {
|
||||
console.warn('url.URLSearchParams.set interface mocked in the Previewer. How this interface works on the Previewer' +
|
||||
' may be different from that on a real device.');
|
||||
};
|
||||
this.sort = function(...args) {
|
||||
this.sort = function (...args) {
|
||||
console.warn('url.URLSearchParams.sort interface mocked in the Previewer. How this interface works on the Previewer' +
|
||||
' may be different from that on a real device.');
|
||||
};
|
||||
this.keys = function(...args) {
|
||||
this.keys = function (...args) {
|
||||
console.warn('url.URLSearchParams.keys interface mocked in the Previewer. How this interface works on the Previewer' +
|
||||
' may be different from that on a real device.');
|
||||
const IteratorStringMock = {
|
||||
@@ -61,7 +76,7 @@ export function mockUrl() {
|
||||
};
|
||||
return IteratorStringMock;
|
||||
};
|
||||
this.values = function(...args) {
|
||||
this.values = function (...args) {
|
||||
console.warn('url.URLSearchParams.values interface mocked in the Previewer. How this interface works on the Previewer' +
|
||||
' may be different from that on a real device.');
|
||||
const IteratorStringMock = {
|
||||
@@ -71,7 +86,7 @@ export function mockUrl() {
|
||||
};
|
||||
return IteratorStringMock;
|
||||
};
|
||||
this.toString = function(...args) {
|
||||
this.toString = function (...args) {
|
||||
console.warn('url.URLSearchParams.toString interface mocked in the Previewer. How this interface works on the Previewer' +
|
||||
' may be different from that on a real device.');
|
||||
return paramMock.paramStringMock;
|
||||
@@ -104,12 +119,12 @@ export function mockUrl() {
|
||||
constructor(...args) {
|
||||
console.warn('url.URL.constructor interface mocked in the Previewer. How this interface works on the Previewer' +
|
||||
' may be different from that on a real device.');
|
||||
this.toString = function(...args) {
|
||||
this.toString = function (...args) {
|
||||
console.warn('URL.toString interface mocked in the Previewer. How this interface works on the Previewer' +
|
||||
' may be different from that on a real device.');
|
||||
return paramMock.paramStringMock;
|
||||
};
|
||||
this.toJSON = function(...args) {
|
||||
this.toJSON = function (...args) {
|
||||
console.warn('URL.toJSON interface mocked in the Previewer. How this interface works on the Previewer' +
|
||||
' may be different from that on a real device.');
|
||||
return paramMock.paramStringMock;
|
||||
|
||||
@@ -1,271 +1,286 @@
|
||||
import {paramMock} from '../utils';
|
||||
/*
|
||||
* 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 mockUsb() {
|
||||
const USBDevice = {
|
||||
busNum: '[PC Preview] unknow busNum',
|
||||
devAddress: '[PC Preview] unknow devAddress',
|
||||
serial: '[PC Preview] unknow serial',
|
||||
name: '[PC Preview] unknow name',
|
||||
manufacturerName: '[PC Preview] unknow maunfactureName',
|
||||
productName: '[PC Preview] unknow productName',
|
||||
version: '[PC Preview] unknow version',
|
||||
vendorId: '[PC Preview] unknow vendorId',
|
||||
productId: '[PC Preview] unknow productId',
|
||||
clazz: '[PC Preview] unknow clazz',
|
||||
subClass: '[PC Preview] unknow subClass',
|
||||
protocol: '[PC Preview] unknow protocol',
|
||||
configs: '[PC Preview] unknow configs',
|
||||
};
|
||||
const USBDevice = {
|
||||
busNum: '[PC Preview] unknow busNum',
|
||||
devAddress: '[PC Preview] unknow devAddress',
|
||||
serial: '[PC Preview] unknow serial',
|
||||
name: '[PC Preview] unknow name',
|
||||
manufacturerName: '[PC Preview] unknow maunfactureName',
|
||||
productName: '[PC Preview] unknow productName',
|
||||
version: '[PC Preview] unknow version',
|
||||
vendorId: '[PC Preview] unknow vendorId',
|
||||
productId: '[PC Preview] unknow productId',
|
||||
clazz: '[PC Preview] unknow clazz',
|
||||
subClass: '[PC Preview] unknow subClass',
|
||||
protocol: '[PC Preview] unknow protocol',
|
||||
configs: '[PC Preview] unknow configs',
|
||||
};
|
||||
|
||||
const USBConfig = {
|
||||
id: '[PC Preview] unknow id',
|
||||
attributes: '[PC Preview] unknow attributes',
|
||||
maxPower: '[PC Preview] unknow maxPower',
|
||||
name: '[PC Preview] unknow name',
|
||||
isRemoteWakeup: '[PC Preview] unknow isRemoteWakeup',
|
||||
isSelfPowered: '[PC Preview] unknow isSelfPowered',
|
||||
interfaces: '[PC Preview] unknow interfaces',
|
||||
};
|
||||
const USBConfig = {
|
||||
id: '[PC Preview] unknow id',
|
||||
attributes: '[PC Preview] unknow attributes',
|
||||
maxPower: '[PC Preview] unknow maxPower',
|
||||
name: '[PC Preview] unknow name',
|
||||
isRemoteWakeup: '[PC Preview] unknow isRemoteWakeup',
|
||||
isSelfPowered: '[PC Preview] unknow isSelfPowered',
|
||||
interfaces: '[PC Preview] unknow interfaces',
|
||||
};
|
||||
|
||||
const USBInterface = {
|
||||
id: '[PC Preview] unknow id',
|
||||
protocol: '[PC Preview] unknow protocol',
|
||||
clazz: '[PC Preview] unknow clazz',
|
||||
subClass: '[PC Preview] unknow subClass',
|
||||
alternateSetting: '[PC Preview] unknow alternateSetting',
|
||||
name: '[PC Preview] unknow name',
|
||||
endpoints: '[PC Preview] unknow endpoints',
|
||||
};
|
||||
const USBInterface = {
|
||||
id: '[PC Preview] unknow id',
|
||||
protocol: '[PC Preview] unknow protocol',
|
||||
clazz: '[PC Preview] unknow clazz',
|
||||
subClass: '[PC Preview] unknow subClass',
|
||||
alternateSetting: '[PC Preview] unknow alternateSetting',
|
||||
name: '[PC Preview] unknow name',
|
||||
endpoints: '[PC Preview] unknow endpoints',
|
||||
};
|
||||
|
||||
const USBEndpoint = {
|
||||
address: '[PC Preview] unknow address',
|
||||
attributes: '[PC Preview] unknow attributes',
|
||||
interval: '[PC Preview] unknow interval',
|
||||
maxPacketSize: '[PC Preview] unknow maxPacketSize',
|
||||
direction: '[PC Preview] unknow direction',
|
||||
number: '[PC Preview] unknow number',
|
||||
type: '[PC Preview] unknow type',
|
||||
interfaceId: '[PC Preview] unknow interfaceId',
|
||||
};
|
||||
const USBEndpoint = {
|
||||
address: '[PC Preview] unknow address',
|
||||
attributes: '[PC Preview] unknow attributes',
|
||||
interval: '[PC Preview] unknow interval',
|
||||
maxPacketSize: '[PC Preview] unknow maxPacketSize',
|
||||
direction: '[PC Preview] unknow direction',
|
||||
number: '[PC Preview] unknow number',
|
||||
type: '[PC Preview] unknow type',
|
||||
interfaceId: '[PC Preview] unknow interfaceId',
|
||||
};
|
||||
|
||||
const USBDevicePipe = {
|
||||
busNum: '[PC Preview] unknow busNum',
|
||||
devAddress: '[PC Preview] unknow devAddress',
|
||||
};
|
||||
const USBDevicePipe = {
|
||||
busNum: '[PC Preview] unknow busNum',
|
||||
devAddress: '[PC Preview] unknow devAddress',
|
||||
};
|
||||
|
||||
const PowerRoleType = {
|
||||
NONE: '[PC Preview] unknow NONE',
|
||||
SOURCE: '[PC Preview] unknow SOURCE',
|
||||
SINK: '[PC Preview] unknow SINK',
|
||||
};
|
||||
const PowerRoleType = {
|
||||
NONE: '[PC Preview] unknow NONE',
|
||||
SOURCE: '[PC Preview] unknow SOURCE',
|
||||
SINK: '[PC Preview] unknow SINK',
|
||||
};
|
||||
|
||||
const DataRoleType = {
|
||||
NONE: '[PC Preview] unknow NONE',
|
||||
HOST: '[PC Preview] unknow HOST',
|
||||
DEVICE: '[PC Preview] unknow DEVICE',
|
||||
};
|
||||
const DataRoleType = {
|
||||
NONE: '[PC Preview] unknow NONE',
|
||||
HOST: '[PC Preview] unknow HOST',
|
||||
DEVICE: '[PC Preview] unknow DEVICE',
|
||||
};
|
||||
|
||||
const USBPort = {
|
||||
id: '[PC Preview] unknow id',
|
||||
supportedModes: '[PC Preview] unknow supportedModes',
|
||||
status: '[PC Preview] unknow status',
|
||||
};
|
||||
const USBPort = {
|
||||
id: '[PC Preview] unknow id',
|
||||
supportedModes: '[PC Preview] unknow supportedModes',
|
||||
status: '[PC Preview] unknow status',
|
||||
};
|
||||
|
||||
const PortModeType = {
|
||||
NONE: '[PC Preview] unknow NONE',
|
||||
DFP: '[PC Preview] unknow DFP',
|
||||
UFP: '[PC Preview] unknow UFP',
|
||||
};
|
||||
const PortModeType = {
|
||||
NONE: '[PC Preview] unknow NONE',
|
||||
DFP: '[PC Preview] unknow DFP',
|
||||
UFP: '[PC Preview] unknow UFP',
|
||||
};
|
||||
|
||||
const USBPortStatus = {
|
||||
currentMode: '[PC Preview] unknow currentMode',
|
||||
currentPowerRole: '[PC Preview] unknow currentPowerRole',
|
||||
currentDataRole: '[PC Preview] unknow currentDataRole',
|
||||
};
|
||||
const USBPortStatus = {
|
||||
currentMode: '[PC Preview] unknow currentMode',
|
||||
currentPowerRole: '[PC Preview] unknow currentPowerRole',
|
||||
currentDataRole: '[PC Preview] unknow currentDataRole',
|
||||
};
|
||||
|
||||
const USBControlParams = {
|
||||
request: '[PC Preview] unknow request',
|
||||
target: '[PC Preview] unknow target',
|
||||
reqType: '[PC Preview] unknow reqType',
|
||||
direction: '[PC Preview] unknow direction',
|
||||
value: '[PC Preview] unknow value',
|
||||
index: '[PC Preview] unknow index',
|
||||
data: '[PC Preview] unknow data',
|
||||
};
|
||||
const USBControlParams = {
|
||||
request: '[PC Preview] unknow request',
|
||||
target: '[PC Preview] unknow target',
|
||||
reqType: '[PC Preview] unknow reqType',
|
||||
direction: '[PC Preview] unknow direction',
|
||||
value: '[PC Preview] unknow value',
|
||||
index: '[PC Preview] unknow index',
|
||||
data: '[PC Preview] unknow data',
|
||||
};
|
||||
|
||||
const USBRequestTargetType = {
|
||||
USB_REQUEST_TARGET_DEVICE: '[PC Preview] unknow USB_REQUEST_TARGET_DEVICE',
|
||||
USB_REQUEST_TARGET_INTERFACE: '[PC Preview] unknow USB_REQUEST_TARGET_INTERFACE',
|
||||
USB_REQUEST_TARGET_ENDPOINT: '[PC Preview] unknow USB_REQUEST_TARGET_ENDPOINT',
|
||||
USB_REQUEST_TARGET_OTHER: '[PC Preview] unknow USB_REQUEST_TARGET_OTHER',
|
||||
};
|
||||
const USBRequestTargetType = {
|
||||
USB_REQUEST_TARGET_DEVICE: '[PC Preview] unknow USB_REQUEST_TARGET_DEVICE',
|
||||
USB_REQUEST_TARGET_INTERFACE: '[PC Preview] unknow USB_REQUEST_TARGET_INTERFACE',
|
||||
USB_REQUEST_TARGET_ENDPOINT: '[PC Preview] unknow USB_REQUEST_TARGET_ENDPOINT',
|
||||
USB_REQUEST_TARGET_OTHER: '[PC Preview] unknow USB_REQUEST_TARGET_OTHER',
|
||||
};
|
||||
|
||||
const USBControlRequestType = {
|
||||
USB_REQUEST_TYPE_STANDARD: '[PC Preview] unknow USB_REQUEST_TYPE_STANDARD',
|
||||
USB_REQUEST_TYPE_CLASS: '[PC Preview] unknow USB_REQUEST_TYPE_CLASS',
|
||||
USB_REQUEST_TYPE_VENDOR: '[PC Preview] unknow USB_REQUEST_TYPE_VENDOR',
|
||||
};
|
||||
const USBControlRequestType = {
|
||||
USB_REQUEST_TYPE_STANDARD: '[PC Preview] unknow USB_REQUEST_TYPE_STANDARD',
|
||||
USB_REQUEST_TYPE_CLASS: '[PC Preview] unknow USB_REQUEST_TYPE_CLASS',
|
||||
USB_REQUEST_TYPE_VENDOR: '[PC Preview] unknow USB_REQUEST_TYPE_VENDOR',
|
||||
};
|
||||
|
||||
const USBRequestDirection = {
|
||||
USB_REQUEST_DIR_TO_DEVICE: '[PC Preview] unknow USB_REQUEST_DIR_TO_DEVICE',
|
||||
USB_REQUEST_DIR_FROM_DEVICE: '[PC Preview] unknow USB_REQUEST_DIR_FROM_DEVICE',
|
||||
};
|
||||
const USBRequestDirection = {
|
||||
USB_REQUEST_DIR_TO_DEVICE: '[PC Preview] unknow USB_REQUEST_DIR_TO_DEVICE',
|
||||
USB_REQUEST_DIR_FROM_DEVICE: '[PC Preview] unknow USB_REQUEST_DIR_FROM_DEVICE',
|
||||
};
|
||||
|
||||
const FunctionType = {
|
||||
NONE: '[PC Preview] unknow NONE',
|
||||
ACM: '[PC Preview] unknow ACM',
|
||||
ECM: '[PC Preview] unknow ECM',
|
||||
HDC: '[PC Preview] unknow HDC',
|
||||
MTP: '[PC Preview] unknow MTP',
|
||||
PTP: '[PC Preview] unknow PTP',
|
||||
RNDIS: '[PC Preview] unknow RNDIS',
|
||||
MIDI: '[PC Preview] unknow MIDI',
|
||||
AUDIO_SOURCE: '[PC Preview] unknow AUDIO_SOURCE',
|
||||
NCM: '[PC Preview] unknow NCM',
|
||||
};
|
||||
const FunctionType = {
|
||||
NONE: '[PC Preview] unknow NONE',
|
||||
ACM: '[PC Preview] unknow ACM',
|
||||
ECM: '[PC Preview] unknow ECM',
|
||||
HDC: '[PC Preview] unknow HDC',
|
||||
MTP: '[PC Preview] unknow MTP',
|
||||
PTP: '[PC Preview] unknow PTP',
|
||||
RNDIS: '[PC Preview] unknow RNDIS',
|
||||
MIDI: '[PC Preview] unknow MIDI',
|
||||
AUDIO_SOURCE: '[PC Preview] unknow AUDIO_SOURCE',
|
||||
NCM: '[PC Preview] unknow NCM',
|
||||
};
|
||||
|
||||
const usb = {
|
||||
getVersion: function (...args) {
|
||||
console.warn('usb.getVersion interface mocked in the Previewer. How this interface works on the'
|
||||
+ ' Previewer may be different from that on a real device.');
|
||||
return paramMock.paramStringMock;
|
||||
},
|
||||
getDevices: function (...args) {
|
||||
console.warn('usb.getDevices interface mocked in the Previewer. How this interface works on the'
|
||||
+ ' Previewer may be different from that on a real device.');
|
||||
return [USBDevice];
|
||||
},
|
||||
connectDevice: function (...args) {
|
||||
console.warn('usb.connectDevice interface mocked in the Previewer. How this interface works on the'
|
||||
+ ' Previewer may be different from that on a real device.');
|
||||
return USBDevicePipe;
|
||||
},
|
||||
getPorts: function (...args) {
|
||||
console.warn('usb.getPorts interface mocked in the Previewer. How this interface works on the'
|
||||
+ ' Previewer may be different from that on a real device.');
|
||||
return [USBPort];
|
||||
},
|
||||
getSupportedModes: function (...args) {
|
||||
console.warn('usb.getSupportedModes interface mocked in the Previewer. How this interface works on the'
|
||||
+ ' Previewer may be different from that on a real device.');
|
||||
return PortModeType;
|
||||
},
|
||||
requestRight: function (...args) {
|
||||
console.warn('usb.requestRight interface mocked in the Previewer. How this interface works on the'
|
||||
+ ' Previewer may be different from 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(paramMock.paramBooleanMock);
|
||||
});
|
||||
}
|
||||
},
|
||||
getCurrentFunctions: function (...args) {
|
||||
console.warn('usb.getCurrentFunctions interface mocked in the Previewer. How this interface works on the'
|
||||
+ ' Previewer may be different from that on a real device.');
|
||||
return FunctionType;
|
||||
},
|
||||
setCurrentFunctions: function (...args) {
|
||||
console.warn('usb.setCurrentFunctions interface mocked in the Previewer. How this interface works on the'
|
||||
+ ' Previewer may be different from 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(paramMock.paramBooleanMock);
|
||||
});
|
||||
}
|
||||
},
|
||||
hasRight: function (...args) {
|
||||
console.warn('usb.hasRight interface mocked in the Previewer. How this interface works on the'
|
||||
+ ' Previewer may be different from that on a real device.');
|
||||
return paramMock.paramBooleanMock;
|
||||
},
|
||||
setPortRoles: function (...args) {
|
||||
console.warn('usb.setPortRoles interface mocked in the Previewer. How this interface works on the'
|
||||
+ ' Previewer may be different from 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(paramMock.paramBooleanMock);
|
||||
});
|
||||
}
|
||||
},
|
||||
getRawDescriptor: function (...args) {
|
||||
console.warn('usb.getRawDescriptor interface mocked in the Previewer. How this interface works on the'
|
||||
+ ' Previewer may be different from that on a real device.');
|
||||
return paramMock.paramArrayMock;
|
||||
},
|
||||
closePipe: function (...args) {
|
||||
console.warn('usb.closePipe interface mocked in the Previewer. How this interface works on the'
|
||||
+ ' Previewer may be different from that on a real device.');
|
||||
return paramMock.paramNumberMock;
|
||||
},
|
||||
claimInterface: function (...args) {
|
||||
console.warn('usb.claimInterface interface mocked in the Previewer. How this interface works on the'
|
||||
+ ' Previewer may be different from that on a real device.');
|
||||
return paramMock.paramNumberMock;
|
||||
},
|
||||
releaseInterface: function (...args) {
|
||||
console.warn('usb.releaseInterface interface mocked in the Previewer. How this interface works on the'
|
||||
+ ' Previewer may be different from that on a real device.');
|
||||
return paramMock.paramNumberMock;
|
||||
},
|
||||
setInterface: function (...args) {
|
||||
console.warn('usb.setInterface interface mocked in the Previewer. How this interface works on the'
|
||||
+ ' Previewer may be different from that on a real device.');
|
||||
return paramMock.paramNumberMock;
|
||||
},
|
||||
getFileDescriptor: function (...args) {
|
||||
console.warn('usb.getFileDescriptor interface mocked in the Previewer. How this interface works on the'
|
||||
+ ' Previewer may be different from that on a real device.');
|
||||
return paramMock.paramNumberMock;
|
||||
},
|
||||
usbFunctionsFromString: function (...args) {
|
||||
console.warn('usb.usbFunctionsFromString interface mocked in the Previewer. How this interface works on the'
|
||||
+ ' Previewer may be different from that on a real device.');
|
||||
return paramMock.paramNumberMock;
|
||||
},
|
||||
usbFunctionsToString: function (...args) {
|
||||
console.warn('usb.usbFunctionsToString interface mocked in the Previewer. How this interface works on the'
|
||||
+ ' Previewer may be different from that on a real device.');
|
||||
return paramMock.paramStringMock;
|
||||
},
|
||||
controlTransfer: function (...args) {
|
||||
console.warn('usb.controlTransfer interface mocked in the Previewer. How this interface works on the'
|
||||
+ ' Previewer may be different from 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(paramMock.paramNumberMock);
|
||||
});
|
||||
}
|
||||
},
|
||||
setConfiguration: function (...args) {
|
||||
console.warn('usb.setConfiguration interface mocked in the Previewer. How this interface works on the'
|
||||
+ ' Previewer may be different from that on a real device.');
|
||||
return paramMock.paramNumberMock;
|
||||
},
|
||||
bulkTransfer: function (...args) {
|
||||
console.warn('usb.bulkTransfer interface mocked in the Previewer. How this interface works on the'
|
||||
+ ' Previewer may be different from 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(paramMock.paramNumberMock);
|
||||
});
|
||||
}
|
||||
},
|
||||
};
|
||||
return usb;
|
||||
const usb = {
|
||||
getVersion: function (...args) {
|
||||
console.warn('usb.getVersion interface mocked in the Previewer. How this interface works on the'
|
||||
+ ' Previewer may be different from that on a real device.');
|
||||
return paramMock.paramStringMock;
|
||||
},
|
||||
getDevices: function (...args) {
|
||||
console.warn('usb.getDevices interface mocked in the Previewer. How this interface works on the'
|
||||
+ ' Previewer may be different from that on a real device.');
|
||||
return [USBDevice];
|
||||
},
|
||||
connectDevice: function (...args) {
|
||||
console.warn('usb.connectDevice interface mocked in the Previewer. How this interface works on the'
|
||||
+ ' Previewer may be different from that on a real device.');
|
||||
return USBDevicePipe;
|
||||
},
|
||||
getPorts: function (...args) {
|
||||
console.warn('usb.getPorts interface mocked in the Previewer. How this interface works on the'
|
||||
+ ' Previewer may be different from that on a real device.');
|
||||
return [USBPort];
|
||||
},
|
||||
getSupportedModes: function (...args) {
|
||||
console.warn('usb.getSupportedModes interface mocked in the Previewer. How this interface works on the'
|
||||
+ ' Previewer may be different from that on a real device.');
|
||||
return PortModeType;
|
||||
},
|
||||
requestRight: function (...args) {
|
||||
console.warn('usb.requestRight interface mocked in the Previewer. How this interface works on the'
|
||||
+ ' Previewer may be different from 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(paramMock.paramBooleanMock);
|
||||
});
|
||||
}
|
||||
},
|
||||
getCurrentFunctions: function (...args) {
|
||||
console.warn('usb.getCurrentFunctions interface mocked in the Previewer. How this interface works on the'
|
||||
+ ' Previewer may be different from that on a real device.');
|
||||
return FunctionType;
|
||||
},
|
||||
setCurrentFunctions: function (...args) {
|
||||
console.warn('usb.setCurrentFunctions interface mocked in the Previewer. How this interface works on the'
|
||||
+ ' Previewer may be different from 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(paramMock.paramBooleanMock);
|
||||
});
|
||||
}
|
||||
},
|
||||
hasRight: function (...args) {
|
||||
console.warn('usb.hasRight interface mocked in the Previewer. How this interface works on the'
|
||||
+ ' Previewer may be different from that on a real device.');
|
||||
return paramMock.paramBooleanMock;
|
||||
},
|
||||
setPortRoles: function (...args) {
|
||||
console.warn('usb.setPortRoles interface mocked in the Previewer. How this interface works on the'
|
||||
+ ' Previewer may be different from 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(paramMock.paramBooleanMock);
|
||||
});
|
||||
}
|
||||
},
|
||||
getRawDescriptor: function (...args) {
|
||||
console.warn('usb.getRawDescriptor interface mocked in the Previewer. How this interface works on the'
|
||||
+ ' Previewer may be different from that on a real device.');
|
||||
return paramMock.paramArrayMock;
|
||||
},
|
||||
closePipe: function (...args) {
|
||||
console.warn('usb.closePipe interface mocked in the Previewer. How this interface works on the'
|
||||
+ ' Previewer may be different from that on a real device.');
|
||||
return paramMock.paramNumberMock;
|
||||
},
|
||||
claimInterface: function (...args) {
|
||||
console.warn('usb.claimInterface interface mocked in the Previewer. How this interface works on the'
|
||||
+ ' Previewer may be different from that on a real device.');
|
||||
return paramMock.paramNumberMock;
|
||||
},
|
||||
releaseInterface: function (...args) {
|
||||
console.warn('usb.releaseInterface interface mocked in the Previewer. How this interface works on the'
|
||||
+ ' Previewer may be different from that on a real device.');
|
||||
return paramMock.paramNumberMock;
|
||||
},
|
||||
setInterface: function (...args) {
|
||||
console.warn('usb.setInterface interface mocked in the Previewer. How this interface works on the'
|
||||
+ ' Previewer may be different from that on a real device.');
|
||||
return paramMock.paramNumberMock;
|
||||
},
|
||||
getFileDescriptor: function (...args) {
|
||||
console.warn('usb.getFileDescriptor interface mocked in the Previewer. How this interface works on the'
|
||||
+ ' Previewer may be different from that on a real device.');
|
||||
return paramMock.paramNumberMock;
|
||||
},
|
||||
usbFunctionsFromString: function (...args) {
|
||||
console.warn('usb.usbFunctionsFromString interface mocked in the Previewer. How this interface works on the'
|
||||
+ ' Previewer may be different from that on a real device.');
|
||||
return paramMock.paramNumberMock;
|
||||
},
|
||||
usbFunctionsToString: function (...args) {
|
||||
console.warn('usb.usbFunctionsToString interface mocked in the Previewer. How this interface works on the'
|
||||
+ ' Previewer may be different from that on a real device.');
|
||||
return paramMock.paramStringMock;
|
||||
},
|
||||
controlTransfer: function (...args) {
|
||||
console.warn('usb.controlTransfer interface mocked in the Previewer. How this interface works on the'
|
||||
+ ' Previewer may be different from 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(paramMock.paramNumberMock);
|
||||
});
|
||||
}
|
||||
},
|
||||
setConfiguration: function (...args) {
|
||||
console.warn('usb.setConfiguration interface mocked in the Previewer. How this interface works on the'
|
||||
+ ' Previewer may be different from that on a real device.');
|
||||
return paramMock.paramNumberMock;
|
||||
},
|
||||
bulkTransfer: function (...args) {
|
||||
console.warn('usb.bulkTransfer interface mocked in the Previewer. How this interface works on the'
|
||||
+ ' Previewer may be different from 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(paramMock.paramNumberMock);
|
||||
});
|
||||
}
|
||||
},
|
||||
};
|
||||
return usb;
|
||||
}
|
||||
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@@ -1,3 +1,18 @@
|
||||
/*
|
||||
* 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 mockWifi() {
|
||||
@@ -66,12 +81,10 @@ export function mockWifi() {
|
||||
this.on = function (...args) {
|
||||
console.warn("wifi.on interface mocked in the Previewer. How this interface works on the Previewer" +
|
||||
" may be different from that on a real device.")
|
||||
return;
|
||||
}
|
||||
this.off = function (...args) {
|
||||
console.warn("wifi.off interface mocked in the Previewer. How this interface works on the Previewer" +
|
||||
" may be different from that on a real device.")
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -80,75 +93,75 @@ export function mockWifi() {
|
||||
enableWifi: function (...args) {
|
||||
console.warn("wifi.enableWifi 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 paramMock.paramBooleanMock;
|
||||
},
|
||||
|
||||
disableWifi: function (...args) {
|
||||
console.warn("wifi.disableWifi 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 paramMock.paramBooleanMock;
|
||||
},
|
||||
|
||||
isWifiActive: function (...args) {
|
||||
console.warn("wifi.isWifiActive 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 paramMock.paramBooleanMock;
|
||||
},
|
||||
|
||||
scan: function (...args) {
|
||||
console.warn("wifi.scan 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 paramMock.paramBooleanMock;
|
||||
},
|
||||
|
||||
getScanInfos: function (...args) {
|
||||
console.warn("wifi.getScanInfos interface mocked in the Previewer. How this interface works on the Previewer" +
|
||||
" may be different from that on a real device.")
|
||||
const len = args.length
|
||||
if (typeof args[len - 1] === 'function') {
|
||||
args[len - 1].call(this, paramMock.businessErrorMock, [wifiScanInfoMock])
|
||||
} else {
|
||||
return new Promise((resolve) => {
|
||||
resolve([wifiScanInfoMock])
|
||||
})
|
||||
}
|
||||
const len = args.length
|
||||
if (typeof args[len - 1] === 'function') {
|
||||
args[len - 1].call(this, paramMock.businessErrorMock, [wifiScanInfoMock])
|
||||
} else {
|
||||
return new Promise((resolve) => {
|
||||
resolve([wifiScanInfoMock])
|
||||
})
|
||||
}
|
||||
},
|
||||
|
||||
addDeviceConfig: function (...args) {
|
||||
console.warn("wifi.addDeviceConfig interface mocked in the Previewer." +
|
||||
" How this interface works on the Previewer may be different 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)
|
||||
})
|
||||
}
|
||||
" How this interface works on the Previewer may be different 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)
|
||||
})
|
||||
}
|
||||
},
|
||||
|
||||
connectToNetwork: function (...args) {
|
||||
console.warn("wifi.connectToNetwork 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 paramMock.paramBooleanMock;
|
||||
},
|
||||
|
||||
connectToDevice: function (...args) {
|
||||
console.warn("wifi.connectToDevice 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 paramMock.paramBooleanMock;
|
||||
},
|
||||
|
||||
disconnect: function (...args) {
|
||||
console.warn("wifi.disconnect 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 paramMock.paramBooleanMock;
|
||||
},
|
||||
|
||||
getSignalLevel: function (...args) {
|
||||
console.warn("wifi.getSignalLevel interface mocked in the Previewer. How this interface works on the Previewer" +
|
||||
" may be different from that on a real device.")
|
||||
return paramMock.paramNumberMock;
|
||||
return paramMock.paramNumberMock;
|
||||
},
|
||||
|
||||
getLinkedInfo: function (...args) {
|
||||
@@ -167,115 +180,115 @@ export function mockWifi() {
|
||||
isConnected: function (...args) {
|
||||
console.warn("wifi.isConnected 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 paramMock.paramBooleanMock;
|
||||
},
|
||||
|
||||
getSupportedFeatures: function (...args) {
|
||||
console.warn("wifi.getSupportedFeatures interface mocked in the Previewer." +
|
||||
" How this interface works on the Previewer may be different from that on a real device.")
|
||||
return paramMock.paramNumberMock;
|
||||
" How this interface works on the Previewer may be different from that on a real device.")
|
||||
return paramMock.paramNumberMock;
|
||||
},
|
||||
|
||||
isFeatureSupported: function (...args) {
|
||||
console.warn("wifi.isFeatureSupported interface mocked in the Previewer." +
|
||||
" How this interface works on the Previewer may be different from that on a real device.")
|
||||
return paramMock.paramBooleanMock;
|
||||
" How this interface works on the Previewer may be different from that on a real device.")
|
||||
return paramMock.paramBooleanMock;
|
||||
},
|
||||
|
||||
getDeviceMacAddress: function (...args) {
|
||||
console.warn("wifi.getDeviceMacAddress interface mocked in the Previewer." +
|
||||
" How this interface works on the Previewer may be different from that on a real device.")
|
||||
return [paramMock.paramArrayMock];
|
||||
" How this interface works on the Previewer may be different from that on a real device.")
|
||||
return [paramMock.paramArrayMock];
|
||||
},
|
||||
|
||||
getIpInfo: function (...args) {
|
||||
console.warn("wifi.getIpInfo interface mocked in the Previewer. How this interface works on the Previewer" +
|
||||
" may be different from that on a real device.")
|
||||
return ipInfoMock;
|
||||
return ipInfoMock;
|
||||
},
|
||||
|
||||
getCountryCode: function (...args) {
|
||||
console.warn("wifi.getCountryCode interface mocked in the Previewer. How this interface works on the Previewer" +
|
||||
" may be different from that on a real device.")
|
||||
return paramMock.paramStringMock;
|
||||
return paramMock.paramStringMock;
|
||||
},
|
||||
|
||||
reassociate: function (...args) {
|
||||
console.warn("wifi.reassociate interface mocked in the Previewer." +
|
||||
" How this interface works on the Previewer may be different from that on a real device.")
|
||||
return paramMock.paramBooleanMock;
|
||||
" How this interface works on the Previewer may be different from that on a real device.")
|
||||
return paramMock.paramBooleanMock;
|
||||
},
|
||||
|
||||
reconnect: function (...args) {
|
||||
console.warn("wifi.reconnect interface mocked in the Previewer." +
|
||||
" How this interface works on the Previewer may be different from that on a real device.")
|
||||
return paramMock.paramBooleanMock;
|
||||
" How this interface works on the Previewer may be different from that on a real device.")
|
||||
return paramMock.paramBooleanMock;
|
||||
},
|
||||
|
||||
getDeviceConfigs: function (...args) {
|
||||
console.warn("wifi.getDeviceConfigs interface mocked in the Previewer." +
|
||||
" How this interface works on the Previewer may be different from that on a real device.")
|
||||
return [wifiDeviceConfigMock];
|
||||
" How this interface works on the Previewer may be different from that on a real device.")
|
||||
return [wifiDeviceConfigMock];
|
||||
},
|
||||
|
||||
updateNetwork: function (...args) {
|
||||
console.warn("wifi.updateNetwork interface mocked in the Previewer." +
|
||||
" How this interface works on the Previewer may be different from that on a real device.")
|
||||
return paramMock.paramNumberMock;
|
||||
" How this interface works on the Previewer may be different from that on a real device.")
|
||||
return paramMock.paramNumberMock;
|
||||
},
|
||||
|
||||
disableNetwork: function (...args) {
|
||||
console.warn("wifi.disableNetwork interface mocked in the Previewer." +
|
||||
" How this interface works on the Previewer may be different from that on a real device.")
|
||||
return paramMock.paramBooleanMock;
|
||||
" How this interface works on the Previewer may be different from that on a real device.")
|
||||
return paramMock.paramBooleanMock;
|
||||
},
|
||||
|
||||
removeAllNetwork: function (...args) {
|
||||
console.warn("wifi.removeAllNetwork interface mocked in the Previewer." +
|
||||
" How this interface works on the Previewer may be different from that on a real device.")
|
||||
return paramMock.paramBooleanMock;
|
||||
" How this interface works on the Previewer may be different from that on a real device.")
|
||||
return paramMock.paramBooleanMock;
|
||||
},
|
||||
|
||||
removeDevice: function (...args) {
|
||||
console.warn("wifi.removeDevice interface mocked in the Previewer." +
|
||||
" How this interface works on the Previewer may be different from that on a real device.")
|
||||
return paramMock.paramBooleanMock;
|
||||
" How this interface works on the Previewer may be different from that on a real device.")
|
||||
return paramMock.paramBooleanMock;
|
||||
},
|
||||
|
||||
enableHotspot: function (...args) {
|
||||
console.warn("wifi.enableHotspot interface mocked in the Previewer." +
|
||||
" How this interface works on the Previewer may be different from that on a real device.")
|
||||
return paramMock.paramBooleanMock;
|
||||
" How this interface works on the Previewer may be different from that on a real device.")
|
||||
return paramMock.paramBooleanMock;
|
||||
},
|
||||
|
||||
disableHotspot: function (...args) {
|
||||
console.warn("wifi.disableHotspot interface mocked in the Previewer." +
|
||||
" How this interface works on the Previewer may be different from that on a real device.")
|
||||
return paramMock.paramBooleanMock;
|
||||
" How this interface works on the Previewer may be different from that on a real device.")
|
||||
return paramMock.paramBooleanMock;
|
||||
},
|
||||
|
||||
isHotspotActive: function (...args) {
|
||||
console.warn("wifi.isHotspotActive interface mocked in the Previewer." +
|
||||
" How this interface works on the Previewer may be different from that on a real device.")
|
||||
return paramMock.paramBooleanMock;
|
||||
" How this interface works on the Previewer may be different from that on a real device.")
|
||||
return paramMock.paramBooleanMock;
|
||||
},
|
||||
|
||||
setHotspotConfig: function (...args) {
|
||||
console.warn("wifi.setHotspotConfig interface mocked in the Previewer." +
|
||||
" How this interface works on the Previewer may be different from that on a real device.")
|
||||
return paramMock.paramBooleanMock;
|
||||
" How this interface works on the Previewer may be different from that on a real device.")
|
||||
return paramMock.paramBooleanMock;
|
||||
},
|
||||
|
||||
getHotspotConfig: function (...args) {
|
||||
console.warn("wifi.getHotspotConfig interface mocked in the Previewer." +
|
||||
" How this interface works on the Previewer may be different from that on a real device.")
|
||||
return wifiHotspotConfigMock;
|
||||
" How this interface works on the Previewer may be different from that on a real device.")
|
||||
return wifiHotspotConfigMock;
|
||||
},
|
||||
|
||||
getStations: function (...args) {
|
||||
console.warn("wifi.getStations interface mocked in the Previewer." +
|
||||
" How this interface works on the Previewer may be different from that on a real device.")
|
||||
return [wifiStationInfoMock];
|
||||
" How this interface works on the Previewer may be different from that on a real device.")
|
||||
return [wifiStationInfoMock];
|
||||
},
|
||||
|
||||
EventListener: EventListenerClass
|
||||
|
||||
@@ -1,3 +1,18 @@
|
||||
/*
|
||||
* 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 mockWorker() {
|
||||
|
||||
@@ -1,65 +1,80 @@
|
||||
/*
|
||||
* 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 mockXml() {
|
||||
const result = {
|
||||
XmlSerializer: function(...args) {
|
||||
console.warn("xml.XmlSerializer interface mocked in the Previewer. How this interface works on the Previewer" +
|
||||
" may be different from that on a real device.")
|
||||
return XmlSerializerMock;
|
||||
},
|
||||
XmlPullParser: function(...args) {
|
||||
console.warn("xml.XmlPullParser interface mocked in the Previewer. How this interface works on the Previewer" +
|
||||
" may be different from that on a real device.")
|
||||
return XmlPullParserMock;
|
||||
}
|
||||
const result = {
|
||||
XmlSerializer: function (...args) {
|
||||
console.warn("xml.XmlSerializer interface mocked in the Previewer. How this interface works on the Previewer" +
|
||||
" may be different from that on a real device.")
|
||||
return XmlSerializerMock;
|
||||
},
|
||||
XmlPullParser: function (...args) {
|
||||
console.warn("xml.XmlPullParser interface mocked in the Previewer. How this interface works on the Previewer" +
|
||||
" may be different from that on a real device.")
|
||||
return XmlPullParserMock;
|
||||
}
|
||||
const XmlSerializerMock = {
|
||||
setAttributes: function(...args) {
|
||||
console.warn("XmlSerializer.setAttributes interface mocked in the Previewer. How this interface works on the Previewer" +
|
||||
" may be different from that on a real device.")
|
||||
},
|
||||
addEmptyElement: function(...args) {
|
||||
console.warn("XmlSerializer.addEmptyElement interface mocked in the Previewer. How this interface works on the Previewer" +
|
||||
" may be different from that on a real device.")
|
||||
},
|
||||
setDeclaration: function(...args) {
|
||||
console.warn("XmlSerializer.setDeclaration interface mocked in the Previewer. How this interface works on the Previewer" +
|
||||
" may be different from that on a real device.")
|
||||
},
|
||||
startElement: function(...args) {
|
||||
console.warn("XmlSerializer.startElement interface mocked in the Previewer. How this interface works on the Previewer" +
|
||||
" may be different from that on a real device.")
|
||||
},
|
||||
endElement: function(...args) {
|
||||
console.warn("XmlSerializer.endElement interface mocked in the Previewer. How this interface works on the Previewer" +
|
||||
" may be different from that on a real device.")
|
||||
},
|
||||
setNamespace: function(...args) {
|
||||
console.warn("XmlSerializer.setNamespace interface mocked in the Previewer. How this interface works on the Previewer" +
|
||||
" may be different from that on a real device.")
|
||||
},
|
||||
setCommnet: function(...args) {
|
||||
console.warn("XmlSerializer.setCommnet interface mocked in the Previewer. How this interface works on the Previewer" +
|
||||
" may be different from that on a real device.")
|
||||
},
|
||||
setCData: function(...args) {
|
||||
console.warn("XmlSerializer.setCData interface mocked in the Previewer. How this interface works on the Previewer" +
|
||||
" may be different from that on a real device.")
|
||||
},
|
||||
setText: function(...args) {
|
||||
console.warn("XmlSerializer.setText interface mocked in the Previewer. How this interface works on the Previewer" +
|
||||
" may be different from that on a real device.")
|
||||
},
|
||||
setDocType: function(...args) {
|
||||
console.warn("XmlSerializer.setDocType interface mocked in the Previewer. How this interface works on the Previewer" +
|
||||
" may be different from that on a real device.")
|
||||
}
|
||||
}
|
||||
const XmlSerializerMock = {
|
||||
setAttributes: function (...args) {
|
||||
console.warn("XmlSerializer.setAttributes interface mocked in the Previewer. How this interface works on the Previewer" +
|
||||
" may be different from that on a real device.")
|
||||
},
|
||||
addEmptyElement: function (...args) {
|
||||
console.warn("XmlSerializer.addEmptyElement interface mocked in the Previewer. How this interface works on the Previewer" +
|
||||
" may be different from that on a real device.")
|
||||
},
|
||||
setDeclaration: function (...args) {
|
||||
console.warn("XmlSerializer.setDeclaration interface mocked in the Previewer. How this interface works on the Previewer" +
|
||||
" may be different from that on a real device.")
|
||||
},
|
||||
startElement: function (...args) {
|
||||
console.warn("XmlSerializer.startElement interface mocked in the Previewer. How this interface works on the Previewer" +
|
||||
" may be different from that on a real device.")
|
||||
},
|
||||
endElement: function (...args) {
|
||||
console.warn("XmlSerializer.endElement interface mocked in the Previewer. How this interface works on the Previewer" +
|
||||
" may be different from that on a real device.")
|
||||
},
|
||||
setNamespace: function (...args) {
|
||||
console.warn("XmlSerializer.setNamespace interface mocked in the Previewer. How this interface works on the Previewer" +
|
||||
" may be different from that on a real device.")
|
||||
},
|
||||
setCommnet: function (...args) {
|
||||
console.warn("XmlSerializer.setCommnet interface mocked in the Previewer. How this interface works on the Previewer" +
|
||||
" may be different from that on a real device.")
|
||||
},
|
||||
setCData: function (...args) {
|
||||
console.warn("XmlSerializer.setCData interface mocked in the Previewer. How this interface works on the Previewer" +
|
||||
" may be different from that on a real device.")
|
||||
},
|
||||
setText: function (...args) {
|
||||
console.warn("XmlSerializer.setText interface mocked in the Previewer. How this interface works on the Previewer" +
|
||||
" may be different from that on a real device.")
|
||||
},
|
||||
setDocType: function (...args) {
|
||||
console.warn("XmlSerializer.setDocType interface mocked in the Previewer. How this interface works on the Previewer" +
|
||||
" may be different from that on a real device.")
|
||||
}
|
||||
const XmlPullParserMock = {
|
||||
parse: function(...args) {
|
||||
console.warn("XmlPullParser.parse interface mocked in the Previewer. How this interface works on the Previewer" +
|
||||
" may be different from that on a real device.")
|
||||
}
|
||||
}
|
||||
const XmlPullParserMock = {
|
||||
parse: function (...args) {
|
||||
console.warn("XmlPullParser.parse interface mocked in the Previewer. How this interface works on the Previewer" +
|
||||
" may be different from that on a real device.")
|
||||
}
|
||||
return result;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
@@ -1,18 +1,33 @@
|
||||
export function mockZlib(){
|
||||
const zlib = {
|
||||
zipFile(...args) {
|
||||
console.warn("zlib.zipFile interface mocked in the Previewer. How this interface works on the Previewer may be different from that on a real device.")
|
||||
return new Promise((resolve, reject) => {
|
||||
resolve()
|
||||
})
|
||||
},
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
unzipFile(...args){
|
||||
console.warn("zlib.unzipFile interface mocked in the Previewer. How this interface works on the Previewer may be different from that on a real device.")
|
||||
return new Promise((resolve, reject) => {
|
||||
resolve()
|
||||
})
|
||||
}
|
||||
export function mockZlib() {
|
||||
const zlib = {
|
||||
zipFile(...args) {
|
||||
console.warn("zlib.zipFile interface mocked in the Previewer. How this interface works on the Previewer may be different from that on a real device.")
|
||||
return new Promise((resolve, reject) => {
|
||||
resolve()
|
||||
})
|
||||
},
|
||||
|
||||
unzipFile(...args) {
|
||||
console.warn("zlib.unzipFile interface mocked in the Previewer. How this interface works on the Previewer may be different from that on a real device.")
|
||||
return new Promise((resolve, reject) => {
|
||||
resolve()
|
||||
})
|
||||
}
|
||||
global.ohosplugin.zlib = zlib
|
||||
}
|
||||
global.ohosplugin.zlib = zlib
|
||||
}
|
||||
@@ -1,3 +1,18 @@
|
||||
/*
|
||||
* Copyright (c) 2021 Huawei Device Co., Ltd.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import { paramMock } from "./utils"
|
||||
|
||||
export function mockWebSocket() {
|
||||
|
||||
@@ -1,3 +1,18 @@
|
||||
/*
|
||||
* Copyright (c) 2021 Huawei Device Co., Ltd.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
export function mockNetwork() {
|
||||
const data = {
|
||||
metered: true,
|
||||
|
||||
@@ -1,3 +1,18 @@
|
||||
/*
|
||||
* 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 mockNfcCardEmulation() {
|
||||
|
||||
@@ -1,3 +1,18 @@
|
||||
/*
|
||||
* Copyright (c) 2021 Huawei Device Co., Ltd.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
export function mockNotification() {
|
||||
global.systemplugin.notification = {
|
||||
show: function () {
|
||||
|
||||
@@ -1,287 +1,302 @@
|
||||
import {paramMock} from "../utils"
|
||||
import {PixelMapMock} from "../multimedia"
|
||||
/*
|
||||
* 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"
|
||||
import { PixelMapMock } from "../multimedia"
|
||||
|
||||
export function mockAppAbilityManager() {
|
||||
global.ohosplugin.app = {}
|
||||
const ActiveProcessInfoMock = {
|
||||
pid: "[PC Preview] unknow pid",
|
||||
uid: "[PC Preview] unknow uid",
|
||||
processName: "[PC Preview] unknow processName",
|
||||
bundleNames: ["[PC Preview] unknow bundleNames", "[PC Preview] unknow bundleNames"]
|
||||
}
|
||||
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 AbilityMissionInfoMock = {
|
||||
missionId: "[PC Preview] unknow missionId",
|
||||
bottomAbility: {
|
||||
abilityName: ElementNameMock.abilityName,
|
||||
bundleName: ElementNameMock.bundleName,
|
||||
deviceId: ElementNameMock.deviceId
|
||||
},
|
||||
topAbility: {
|
||||
abilityName: ElementNameMock.abilityName,
|
||||
bundleName: ElementNameMock.bundleName,
|
||||
deviceId: ElementNameMock.deviceId
|
||||
},
|
||||
windowMode: "[PC Preview] unknow windowMode"
|
||||
}
|
||||
global.ohosplugin.app = {}
|
||||
const ActiveProcessInfoMock = {
|
||||
pid: "[PC Preview] unknow pid",
|
||||
uid: "[PC Preview] unknow uid",
|
||||
processName: "[PC Preview] unknow processName",
|
||||
bundleNames: ["[PC Preview] unknow bundleNames", "[PC Preview] unknow bundleNames"]
|
||||
}
|
||||
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 AbilityMissionInfoMock = {
|
||||
missionId: "[PC Preview] unknow missionId",
|
||||
bottomAbility: {
|
||||
abilityName: ElementNameMock.abilityName,
|
||||
bundleName: ElementNameMock.bundleName,
|
||||
deviceId: ElementNameMock.deviceId
|
||||
},
|
||||
topAbility: {
|
||||
abilityName: ElementNameMock.abilityName,
|
||||
bundleName: ElementNameMock.bundleName,
|
||||
deviceId: ElementNameMock.deviceId
|
||||
},
|
||||
windowMode: "[PC Preview] unknow windowMode"
|
||||
}
|
||||
|
||||
const ActiveServiceAbilityInfoMock = {
|
||||
pid: "[PC Preview] unknow pid",
|
||||
uid: "[PC Preview] unknow uid",
|
||||
processName: "[PC Preview] unknow processName",
|
||||
serviceAbility: {
|
||||
abilityName: ElementNameMock.abilityName,
|
||||
bundleName: ElementNameMock.bundleName,
|
||||
deviceId: ElementNameMock.deviceId
|
||||
}
|
||||
const ActiveServiceAbilityInfoMock = {
|
||||
pid: "[PC Preview] unknow pid",
|
||||
uid: "[PC Preview] unknow uid",
|
||||
processName: "[PC Preview] unknow processName",
|
||||
serviceAbility: {
|
||||
abilityName: ElementNameMock.abilityName,
|
||||
bundleName: ElementNameMock.bundleName,
|
||||
deviceId: ElementNameMock.deviceId
|
||||
}
|
||||
}
|
||||
|
||||
const ProcessErrorInfoMock = {
|
||||
errStatus: "[PC Preview] unknow errStatus",
|
||||
processName: "[PC Preview] unknow processName",
|
||||
pid: "[PC Preview] unknow pid",
|
||||
uid: "[PC Preview] unknow uid",
|
||||
abilityName: "[PC Preview] unknow abilityName",
|
||||
errMsg: "[PC Preview] unknow errMsg",
|
||||
backTrace: "[PC Preview] unknow backTrace"
|
||||
}
|
||||
const SystemMemoryAttrMock = {
|
||||
availSysMem: "[PC Preview] unknow availSysMem",
|
||||
totalSysMem: "[PC Preview] unknow totalSysMem",
|
||||
threshold: "[PC Preview] unknow threshold",
|
||||
isSysInlowMem: "[PC Preview] unknow isSysInlowMem"
|
||||
}
|
||||
const MissionSnapshotMock = {
|
||||
topAbility: {
|
||||
abilityName: ElementNameMock.abilityName,
|
||||
bundleName: ElementNameMock.bundleName,
|
||||
deviceId: ElementNameMock.deviceId
|
||||
},
|
||||
snapshot: PixelMapMock
|
||||
}
|
||||
const MemoryMapInfoMock = {
|
||||
vmPss: "[PC Preview] unknow vmPss",
|
||||
vmPrivateDirty: "[PC Preview] unknow vmPrivateDirty",
|
||||
vmSharedDirty: "[PC Preview] unknow vmSharedDirty",
|
||||
nativePss: "[PC Preview] unknow nativePss",
|
||||
nativePrivateDirty: "[PC Preview] unknow nativePrivateDirty",
|
||||
nativeSharedDirty: "[PC Preview] unknow nativeSharedDirty",
|
||||
otherPss: "[PC Preview] unknow otherPss",
|
||||
otherPrivateDirty: "[PC Preview] unknow otherPrivateDirty",
|
||||
otherSharedDirty: "[PC Preview] unknow otherSharedDirty"
|
||||
}
|
||||
const ProcessErrorInfoMock = {
|
||||
errStatus: "[PC Preview] unknow errStatus",
|
||||
processName: "[PC Preview] unknow processName",
|
||||
pid: "[PC Preview] unknow pid",
|
||||
uid: "[PC Preview] unknow uid",
|
||||
abilityName: "[PC Preview] unknow abilityName",
|
||||
errMsg: "[PC Preview] unknow errMsg",
|
||||
backTrace: "[PC Preview] unknow backTrace"
|
||||
}
|
||||
const SystemMemoryAttrMock = {
|
||||
availSysMem: "[PC Preview] unknow availSysMem",
|
||||
totalSysMem: "[PC Preview] unknow totalSysMem",
|
||||
threshold: "[PC Preview] unknow threshold",
|
||||
isSysInlowMem: "[PC Preview] unknow isSysInlowMem"
|
||||
}
|
||||
const MissionSnapshotMock = {
|
||||
topAbility: {
|
||||
abilityName: ElementNameMock.abilityName,
|
||||
bundleName: ElementNameMock.bundleName,
|
||||
deviceId: ElementNameMock.deviceId
|
||||
},
|
||||
snapshot: PixelMapMock
|
||||
}
|
||||
const MemoryMapInfoMock = {
|
||||
vmPss: "[PC Preview] unknow vmPss",
|
||||
vmPrivateDirty: "[PC Preview] unknow vmPrivateDirty",
|
||||
vmSharedDirty: "[PC Preview] unknow vmSharedDirty",
|
||||
nativePss: "[PC Preview] unknow nativePss",
|
||||
nativePrivateDirty: "[PC Preview] unknow nativePrivateDirty",
|
||||
nativeSharedDirty: "[PC Preview] unknow nativeSharedDirty",
|
||||
otherPss: "[PC Preview] unknow otherPss",
|
||||
otherPrivateDirty: "[PC Preview] unknow otherPrivateDirty",
|
||||
otherSharedDirty: "[PC Preview] unknow otherSharedDirty"
|
||||
}
|
||||
|
||||
global.ohosplugin.app.abilityManager = {
|
||||
getCurrentUserId: function (...args) {
|
||||
console.warn("app.abilityManager.getCurrentUserId interface mocked in the Previewer. How this interface works" +
|
||||
" on the Previewer may be different 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)
|
||||
})
|
||||
}
|
||||
},
|
||||
getActiveProcessInfos: function (...args) {
|
||||
console.warn("app.abilityManager.getActiveProcessInfos interface mocked in the Previewer. How this interface works" +
|
||||
" on the Previewer may be different from that on a real device.")
|
||||
const len = args.length
|
||||
if (typeof args[len - 1] === 'function') {
|
||||
args[len - 1].call(this, paramMock.businessErrorMock, [ActiveProcessInfoMock])
|
||||
} else {
|
||||
return new Promise((resolve) => {
|
||||
resolve([ActiveProcessInfoMock])
|
||||
})
|
||||
}
|
||||
},
|
||||
getActiveAbilityMissionInfos: function (...args) {
|
||||
console.warn("app.abilityManager.getActiveAbilityMissionInfos interface mocked in the Previewer. How this interface works" +
|
||||
" on the Previewer may be different from that on a real device.")
|
||||
const len = args.length
|
||||
if (typeof args[len - 1] === 'function') {
|
||||
args[len - 1].call(this, paramMock.businessErrorMock, [AbilityMissionInfoMock])
|
||||
} else {
|
||||
return new Promise((resolve) => {
|
||||
resolve([AbilityMissionInfoMock])
|
||||
})
|
||||
}
|
||||
},
|
||||
getPreviousAbilityMissionInfos: function (...args) {
|
||||
console.warn("app.abilityManager.getPreviousAbilityMissionInfos interface mocked in the Previewer. How this interface works" +
|
||||
" on the Previewer may be different from that on a real device.")
|
||||
const len = args.length
|
||||
if (typeof args[len - 1] === 'function') {
|
||||
args[len - 1].call(this, paramMock.businessErrorMock, [AbilityMissionInfoMock])
|
||||
} else {
|
||||
return new Promise((resolve) => {
|
||||
resolve([AbilityMissionInfoMock])
|
||||
})
|
||||
}
|
||||
},
|
||||
deleteMissions: function (...args) {
|
||||
console.warn("app.abilityManager.deleteMissions interface mocked in the Previewer. How this interface works" +
|
||||
" on the Previewer may be different from that on a 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()
|
||||
})
|
||||
}
|
||||
},
|
||||
isUserATestUser: function (...args) {
|
||||
console.warn("app.abilityManager.isUserATestUser interface mocked in the Previewer. How this interface works on" +
|
||||
" the Previewer may be different 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)
|
||||
})
|
||||
}
|
||||
},
|
||||
getActiveServiceAbilityInfos: function (...args) {
|
||||
console.warn("app.abilityManager.getActiveServiceAbilityInfos interface mocked in the Previewer. How this interface works" +
|
||||
" on the Previewer may be different from that on a real device.")
|
||||
const len = args.length
|
||||
if (typeof args[len - 1] === 'function') {
|
||||
args[len - 1].call(this, paramMock.businessErrorMock, [ActiveServiceAbilityInfoMock])
|
||||
} else {
|
||||
return new Promise((resolve) => {
|
||||
resolve([ActiveServiceAbilityInfoMock])
|
||||
})
|
||||
}
|
||||
},
|
||||
getHomeScreenIconDenseness: function (...args) {
|
||||
console.warn("app.abilityManager.getHomeScreenIconDenseness interface mocked in the Previewer. How this interface works" +
|
||||
" on the Previewer may be different 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)
|
||||
})
|
||||
}
|
||||
},
|
||||
getHomeScreenIconSize: function (...args) {
|
||||
console.warn("app.abilityManager.getHomeScreenIconSize interface mocked in the Previewer. How this interface works" +
|
||||
" on the Previewer may be different 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)
|
||||
})
|
||||
}
|
||||
},
|
||||
isMultiWindowAllowed: function (...args) {
|
||||
console.warn("app.abilityManager.isMultiWindowAllowed interface mocked in the Previewer. How this interface works" +
|
||||
" on the Previewer may be different 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)
|
||||
})
|
||||
}
|
||||
},
|
||||
moveMissionToFirstSplitScreen: function (...args) {
|
||||
console.warn("app.abilityManager.moveMissionToFirstSplitScreen interface mocked in the Previewer. How this interface works" +
|
||||
" on the Previewer may be different from that on a 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()
|
||||
})
|
||||
}
|
||||
},
|
||||
isRamConstrainedDevice: function (...args) {
|
||||
console.warn("app.abilityManager.isRamConstrainedDevice interface mocked in the Previewer. How this interface works" +
|
||||
" on the Previewer may be different from that on a real device.")
|
||||
const len = args.length
|
||||
if (typeof args[len - 1] === 'function') {
|
||||
args[len - 1].call(this, paramMock.businessErrorMock, paramMock.paramBooleanMock)
|
||||
} else {
|
||||
return new Promise((resolve) => {
|
||||
resolve(paramMock.paramBooleanMock)
|
||||
})
|
||||
}
|
||||
},
|
||||
getAppMemorySize: function (...args) {
|
||||
console.warn("app.abilityManager.getAppMemorySize interface mocked in the Previewer. How this interface works" +
|
||||
" on the Previewer may be different from that on a real device.")
|
||||
const len = args.length
|
||||
if (typeof args[len - 1] === 'function') {
|
||||
args[len - 1].call(this, paramMock.businessErrorMock, paramMock.paramNumberMock)
|
||||
} else {
|
||||
return new Promise((resolve) => {
|
||||
resolve(paramMock.paramNumberMock)
|
||||
})
|
||||
}
|
||||
},
|
||||
getProcessMemoryMapInfos: function (...args) {
|
||||
console.warn("app.abilityManager.getProcessMemoryMapInfos interface mocked in the Previewer. How this interface works" +
|
||||
" on the Previewer may be different from that on a real device.")
|
||||
const len = args.length
|
||||
if (typeof args[len - 1] === 'function') {
|
||||
args[len - 1].call(this, paramMock.businessErrorMock, [MemoryMapInfoMock])
|
||||
} else {
|
||||
return new Promise((resolve) => {
|
||||
resolve([MemoryMapInfoMock])
|
||||
})
|
||||
}
|
||||
},
|
||||
global.ohosplugin.app.abilityManager = {
|
||||
getCurrentUserId: function (...args) {
|
||||
console.warn("app.abilityManager.getCurrentUserId interface mocked in the Previewer. How this interface works" +
|
||||
" on the Previewer may be different 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)
|
||||
})
|
||||
}
|
||||
},
|
||||
getActiveProcessInfos: function (...args) {
|
||||
console.warn("app.abilityManager.getActiveProcessInfos interface mocked in the Previewer. How this interface works" +
|
||||
" on the Previewer may be different from that on a real device.")
|
||||
const len = args.length
|
||||
if (typeof args[len - 1] === 'function') {
|
||||
args[len - 1].call(this, paramMock.businessErrorMock, [ActiveProcessInfoMock])
|
||||
} else {
|
||||
return new Promise((resolve) => {
|
||||
resolve([ActiveProcessInfoMock])
|
||||
})
|
||||
}
|
||||
},
|
||||
getActiveAbilityMissionInfos: function (...args) {
|
||||
console.warn("app.abilityManager.getActiveAbilityMissionInfos interface mocked in the Previewer. How this interface works" +
|
||||
" on the Previewer may be different from that on a real device.")
|
||||
const len = args.length
|
||||
if (typeof args[len - 1] === 'function') {
|
||||
args[len - 1].call(this, paramMock.businessErrorMock, [AbilityMissionInfoMock])
|
||||
} else {
|
||||
return new Promise((resolve) => {
|
||||
resolve([AbilityMissionInfoMock])
|
||||
})
|
||||
}
|
||||
},
|
||||
getPreviousAbilityMissionInfos: function (...args) {
|
||||
console.warn("app.abilityManager.getPreviousAbilityMissionInfos interface mocked in the Previewer. How this interface works" +
|
||||
" on the Previewer may be different from that on a real device.")
|
||||
const len = args.length
|
||||
if (typeof args[len - 1] === 'function') {
|
||||
args[len - 1].call(this, paramMock.businessErrorMock, [AbilityMissionInfoMock])
|
||||
} else {
|
||||
return new Promise((resolve) => {
|
||||
resolve([AbilityMissionInfoMock])
|
||||
})
|
||||
}
|
||||
},
|
||||
deleteMissions: function (...args) {
|
||||
console.warn("app.abilityManager.deleteMissions interface mocked in the Previewer. How this interface works" +
|
||||
" on the Previewer may be different from that on a 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()
|
||||
})
|
||||
}
|
||||
},
|
||||
isUserATestUser: function (...args) {
|
||||
console.warn("app.abilityManager.isUserATestUser interface mocked in the Previewer. How this interface works on" +
|
||||
" the Previewer may be different 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)
|
||||
})
|
||||
}
|
||||
},
|
||||
getActiveServiceAbilityInfos: function (...args) {
|
||||
console.warn("app.abilityManager.getActiveServiceAbilityInfos interface mocked in the Previewer. How this interface works" +
|
||||
" on the Previewer may be different from that on a real device.")
|
||||
const len = args.length
|
||||
if (typeof args[len - 1] === 'function') {
|
||||
args[len - 1].call(this, paramMock.businessErrorMock, [ActiveServiceAbilityInfoMock])
|
||||
} else {
|
||||
return new Promise((resolve) => {
|
||||
resolve([ActiveServiceAbilityInfoMock])
|
||||
})
|
||||
}
|
||||
},
|
||||
getHomeScreenIconDenseness: function (...args) {
|
||||
console.warn("app.abilityManager.getHomeScreenIconDenseness interface mocked in the Previewer. How this interface works" +
|
||||
" on the Previewer may be different 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)
|
||||
})
|
||||
}
|
||||
},
|
||||
getHomeScreenIconSize: function (...args) {
|
||||
console.warn("app.abilityManager.getHomeScreenIconSize interface mocked in the Previewer. How this interface works" +
|
||||
" on the Previewer may be different 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)
|
||||
})
|
||||
}
|
||||
},
|
||||
isMultiWindowAllowed: function (...args) {
|
||||
console.warn("app.abilityManager.isMultiWindowAllowed interface mocked in the Previewer. How this interface works" +
|
||||
" on the Previewer may be different 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)
|
||||
})
|
||||
}
|
||||
},
|
||||
moveMissionToFirstSplitScreen: function (...args) {
|
||||
console.warn("app.abilityManager.moveMissionToFirstSplitScreen interface mocked in the Previewer. How this interface works" +
|
||||
" on the Previewer may be different from that on a 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()
|
||||
})
|
||||
}
|
||||
},
|
||||
isRamConstrainedDevice: function (...args) {
|
||||
console.warn("app.abilityManager.isRamConstrainedDevice interface mocked in the Previewer. How this interface works" +
|
||||
" on the Previewer may be different from that on a real device.")
|
||||
const len = args.length
|
||||
if (typeof args[len - 1] === 'function') {
|
||||
args[len - 1].call(this, paramMock.businessErrorMock, paramMock.paramBooleanMock)
|
||||
} else {
|
||||
return new Promise((resolve) => {
|
||||
resolve(paramMock.paramBooleanMock)
|
||||
})
|
||||
}
|
||||
},
|
||||
getAppMemorySize: function (...args) {
|
||||
console.warn("app.abilityManager.getAppMemorySize interface mocked in the Previewer. How this interface works" +
|
||||
" on the Previewer may be different from that on a real device.")
|
||||
const len = args.length
|
||||
if (typeof args[len - 1] === 'function') {
|
||||
args[len - 1].call(this, paramMock.businessErrorMock, paramMock.paramNumberMock)
|
||||
} else {
|
||||
return new Promise((resolve) => {
|
||||
resolve(paramMock.paramNumberMock)
|
||||
})
|
||||
}
|
||||
},
|
||||
getProcessMemoryMapInfos: function (...args) {
|
||||
console.warn("app.abilityManager.getProcessMemoryMapInfos interface mocked in the Previewer. How this interface works" +
|
||||
" on the Previewer may be different from that on a real device.")
|
||||
const len = args.length
|
||||
if (typeof args[len - 1] === 'function') {
|
||||
args[len - 1].call(this, paramMock.businessErrorMock, [MemoryMapInfoMock])
|
||||
} else {
|
||||
return new Promise((resolve) => {
|
||||
resolve([MemoryMapInfoMock])
|
||||
})
|
||||
}
|
||||
},
|
||||
|
||||
getSystemMemoryAttr: function (...args) {
|
||||
console.warn("app.abilityManager.getSystemMemoryAttr interface mocked in the Previewer. How this interface works" +
|
||||
" on the Previewer may be different from that on a real device.")
|
||||
const len = args.length
|
||||
if (typeof args[len - 1] === 'function') {
|
||||
args[len - 1].call(this, paramMock.businessErrorMock, SystemMemoryAttrMock)
|
||||
} else {
|
||||
return new Promise((resolve) => {
|
||||
resolve(SystemMemoryAttrMock)
|
||||
})
|
||||
}
|
||||
},
|
||||
getProcessErrorInfos: function (...args) {
|
||||
console.warn("app.abilityManager.getProcessErrorInfos interface mocked in the Previewer. How this interface works" +
|
||||
" on the Previewer may be different from that on a real device.")
|
||||
const len = args.length
|
||||
if (typeof args[len - 1] === 'function') {
|
||||
args[len - 1].call(this, paramMock.businessErrorMock, [ProcessErrorInfoMock])
|
||||
} else {
|
||||
return new Promise((resolve) => {
|
||||
resolve([ProcessErrorInfoMock])
|
||||
})
|
||||
}
|
||||
},
|
||||
getAbilityMissionSnapshot: function (...args) {
|
||||
console.warn("app.abilityManager.getAbilityMissionSnapshot interface mocked in the Previewer. How this interface works" +
|
||||
" on the Previewer may be 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)
|
||||
} else {
|
||||
return new Promise((resolve) => {
|
||||
resolve(MissionSnapshotMock)
|
||||
})
|
||||
}
|
||||
}
|
||||
getSystemMemoryAttr: function (...args) {
|
||||
console.warn("app.abilityManager.getSystemMemoryAttr interface mocked in the Previewer. How this interface works" +
|
||||
" on the Previewer may be different from that on a real device.")
|
||||
const len = args.length
|
||||
if (typeof args[len - 1] === 'function') {
|
||||
args[len - 1].call(this, paramMock.businessErrorMock, SystemMemoryAttrMock)
|
||||
} else {
|
||||
return new Promise((resolve) => {
|
||||
resolve(SystemMemoryAttrMock)
|
||||
})
|
||||
}
|
||||
},
|
||||
getProcessErrorInfos: function (...args) {
|
||||
console.warn("app.abilityManager.getProcessErrorInfos interface mocked in the Previewer. How this interface works" +
|
||||
" on the Previewer may be different from that on a real device.")
|
||||
const len = args.length
|
||||
if (typeof args[len - 1] === 'function') {
|
||||
args[len - 1].call(this, paramMock.businessErrorMock, [ProcessErrorInfoMock])
|
||||
} else {
|
||||
return new Promise((resolve) => {
|
||||
resolve([ProcessErrorInfoMock])
|
||||
})
|
||||
}
|
||||
},
|
||||
getAbilityMissionSnapshot: function (...args) {
|
||||
console.warn("app.abilityManager.getAbilityMissionSnapshot interface mocked in the Previewer. How this interface works" +
|
||||
" on the Previewer may be 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)
|
||||
} else {
|
||||
return new Promise((resolve) => {
|
||||
resolve(MissionSnapshotMock)
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,218 +1,233 @@
|
||||
import {paramMock} from "../utils"
|
||||
/*
|
||||
* Copyright (c) 2021 Huawei Device Co., Ltd.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import { paramMock } from "../utils"
|
||||
|
||||
export function mockAppAccount() {
|
||||
const appAccountInfoMock = {
|
||||
owner: "[PC Preview] unknown owner",
|
||||
name: "[PC Preview] unknown name"
|
||||
};
|
||||
const appAccountManagerMock = {
|
||||
addAccount: function (...args) {
|
||||
console.warn("AppAccountManager.addAccount interface mocked in the Previewer. " +
|
||||
"How this interface works on the Previewer may be different from that on a real device.")
|
||||
const len = args.length
|
||||
if (len > 0 && typeof args[len - 1] === 'function') {
|
||||
args[len - 1].call(this, paramMock.businessErrorMock);
|
||||
} else {
|
||||
return new Promise((resolve, reject) => {
|
||||
resolve();
|
||||
})
|
||||
}
|
||||
},
|
||||
deleteAccount: function (...args) {
|
||||
console.warn("AppAccountManager.deleteAccount interface mocked in the Previewer. " +
|
||||
"How this interface works on the Previewer may be different from that on a real device.")
|
||||
const len = args.length
|
||||
if (len > 0 && typeof args[len - 1] === 'function') {
|
||||
args[len - 1].call(this, paramMock.businessErrorMock);
|
||||
} else {
|
||||
return new Promise((resolve, reject) => {
|
||||
resolve();
|
||||
})
|
||||
}
|
||||
},
|
||||
disableAppAccess: function (...args) {
|
||||
console.warn("AppAccountManager.disableAppAccess interface mocked in the Previewer. " +
|
||||
"How this interface works on the Previewer may be different from that on a real device.")
|
||||
const len = args.length
|
||||
if (len > 0 && typeof args[len - 1] === 'function') {
|
||||
args[len - 1].call(this, paramMock.businessErrorMock);
|
||||
} else {
|
||||
return new Promise((resolve, reject) => {
|
||||
resolve();
|
||||
})
|
||||
}
|
||||
},
|
||||
enableAppAccess: function (...args) {
|
||||
console.warn("AppAccountManager.enableAppAccess interface mocked in the Previewer. " +
|
||||
"How this interface works on the Previewer may be different from that on a real device.")
|
||||
const len = args.length
|
||||
if (len > 0 && typeof args[len - 1] === 'function') {
|
||||
args[len - 1].call(this, paramMock.businessErrorMock);
|
||||
} else {
|
||||
return new Promise((resolve, reject) => {
|
||||
resolve();
|
||||
})
|
||||
}
|
||||
},
|
||||
checkAppAccountSyncEnable: function (...args) {
|
||||
console.warn("AppAccountManager.checkAppAccountSyncEnable interface mocked in the Previewer. " +
|
||||
"How this interface works on the Previewer may be different from that on a real device.")
|
||||
const len = args.length
|
||||
if (len > 0 && typeof args[len - 1] === 'function') {
|
||||
args[len - 1].call(this, paramMock.businessErrorMock, paramMock.paramBooleanMock);
|
||||
} else {
|
||||
return new Promise((resolve, reject) => {
|
||||
resolve(paramMock.paramBooleanMock);
|
||||
})
|
||||
}
|
||||
},
|
||||
setAccountCredential: function (...args) {
|
||||
console.warn("AppAccountManager.setAccountCredential interface mocked in the Previewer. " +
|
||||
"How this interface works on the Previewer may be different from that on a real device.")
|
||||
const len = args.length
|
||||
if (len > 0 && typeof args[len - 1] === 'function') {
|
||||
args[len - 1].call(this, paramMock.businessErrorMock);
|
||||
} else {
|
||||
return new Promise((resolve, reject) => {
|
||||
resolve();
|
||||
})
|
||||
}
|
||||
},
|
||||
setAccountExtraInfo: function (...args) {
|
||||
console.warn("AppAccountManager.setAccountExtraInfo interface mocked in the Previewer. " +
|
||||
"How this interface works on the Previewer may be different from that on a real device.")
|
||||
const len = args.length
|
||||
if (len > 0 && typeof args[len - 1] === 'function') {
|
||||
args[len - 1].call(this, paramMock.businessErrorMock);
|
||||
} else {
|
||||
return new Promise((resolve, reject) => {
|
||||
resolve();
|
||||
})
|
||||
}
|
||||
},
|
||||
setAppAccountSyncEnable: function (...args) {
|
||||
console.warn("AppAccountManager.setAppAccountSyncEnable interface mocked in the Previewer. " +
|
||||
"How this interface works on the Previewer may be different from that on a real device.")
|
||||
const len = args.length
|
||||
if (len > 0 && typeof args[len - 1] === 'function') {
|
||||
args[len - 1].call(this, paramMock.businessErrorMock);
|
||||
} else {
|
||||
return new Promise((resolve, reject) => {
|
||||
resolve();
|
||||
})
|
||||
}
|
||||
},
|
||||
setAssociatedData: function (...args) {
|
||||
console.warn("AppAccountManager.setAssociatedData interface mocked in the Previewer. " +
|
||||
"How this interface works on the Previewer may be different from that on a real device.")
|
||||
const len = args.length
|
||||
if (len > 0 && typeof args[len - 1] === 'function') {
|
||||
args[len - 1].call(this, paramMock.businessErrorMock);
|
||||
} else {
|
||||
return new Promise((resolve, reject) => {
|
||||
resolve();
|
||||
})
|
||||
}
|
||||
},
|
||||
getAllAccessibleAccounts: function (...args) {
|
||||
console.warn("AppAccountManager.getAllAccessibleAccounts interface mocked in the Previewer. " +
|
||||
"How this interface works on the Previewer may be different from that on a real device.")
|
||||
var appAccountInfoArrayMock = new Array();
|
||||
appAccountInfoArrayMock.push(appAccountInfoMock);
|
||||
const len = args.length
|
||||
if (len > 0 && typeof args[len - 1] === 'function') {
|
||||
args[len - 1].call(this, paramMock.businessErrorMock, appAccountInfoArrayMock);
|
||||
} else {
|
||||
return new Promise((resolve, reject) => {
|
||||
resolve(appAccountInfoArrayMock);
|
||||
})
|
||||
}
|
||||
},
|
||||
getAllAccounts: function (...args) {
|
||||
console.warn("AppAccountManager.getAllAccounts interface mocked in the Previewer. " +
|
||||
"How this interface works on the Previewer may be different from that on a real device.")
|
||||
var appAccountInfoArrayMock = new Array();
|
||||
appAccountInfoArrayMock.push(appAccountInfoMock);
|
||||
const len = args.length
|
||||
if (len > 0 && typeof args[len - 1] === 'function') {
|
||||
args[len - 1].call(this, paramMock.businessErrorMock, appAccountInfoArrayMock);
|
||||
} else {
|
||||
return new Promise((resolve, reject) => {
|
||||
resolve(appAccountInfoArrayMock);
|
||||
})
|
||||
}
|
||||
},
|
||||
getAccountCredential: function (...args) {
|
||||
console.warn("AppAccountManager.getAccountCredential interface mocked in the Previewer. " +
|
||||
"How this interface works on the Previewer may be different from that on a real device.")
|
||||
const len = args.length
|
||||
if (len > 0 && typeof args[len - 1] === 'function') {
|
||||
args[len - 1].call(this, paramMock.businessErrorMock, paramMock.paramStringMock);
|
||||
} else {
|
||||
return new Promise((resolve, reject) => {
|
||||
resolve(paramMock.paramStringMock);
|
||||
})
|
||||
}
|
||||
},
|
||||
getAccountExtraInfo: function (...args) {
|
||||
console.warn("AppAccountManager.getAccountExtraInfo interface mocked in the Previewer. " +
|
||||
"How this interface works on the Previewer may be different from that on a real device.")
|
||||
const len = args.length
|
||||
if (len > 0 && typeof args[len - 1] === 'function') {
|
||||
args[len - 1].call(this, paramMock.businessErrorMock, paramMock.paramStringMock);
|
||||
} else {
|
||||
return new Promise((resolve, reject) => {
|
||||
resolve(paramMock.paramStringMock);
|
||||
})
|
||||
}
|
||||
},
|
||||
getAssociatedData: function (...args) {
|
||||
console.warn("AppAccountManager.getAssociatedData interface mocked in the Previewer. " +
|
||||
"How this interface works on the Previewer may be different from that on a real device.")
|
||||
const len = args.length
|
||||
if (len > 0 && typeof args[len - 1] === 'function') {
|
||||
args[len - 1].call(this, paramMock.businessErrorMock, paramMock.paramStringMock);
|
||||
} else {
|
||||
return new Promise((resolve, reject) => {
|
||||
resolve(paramMock.paramStringMock);
|
||||
})
|
||||
}
|
||||
},
|
||||
on: function (...args) {
|
||||
console.warn("AppAccountManager.on interface mocked in the Previewer. " +
|
||||
"How this interface works on the Previewer may be different from that on a real device.")
|
||||
var appAccountInfoArrayMock = new Array();
|
||||
appAccountInfoArrayMock.push(appAccountInfoMock);
|
||||
const len = args.length
|
||||
if (len > 0 && typeof args[len - 1] === 'function') {
|
||||
args[len - 1].call(this, appAccountInfoArrayMock);
|
||||
} else {
|
||||
return new Promise((resolve, reject) => {
|
||||
resolve(appAccountInfoArrayMock);
|
||||
})
|
||||
}
|
||||
},
|
||||
off: function (...args) {
|
||||
console.warn("AppAccountManager.off interface mocked in the Previewer. " +
|
||||
"How this interface works on the Previewer may be different from that on a real device.")
|
||||
var appAccountInfoArrayMock = new Array();
|
||||
appAccountInfoArrayMock.push(appAccountInfoMock);
|
||||
const len = args.length
|
||||
if (len > 0 && typeof args[len - 1] === 'function') {
|
||||
args[len - 1].call(this, appAccountInfoArrayMock);
|
||||
} else {
|
||||
return new Promise((resolve, reject) => {
|
||||
resolve(appAccountInfoArrayMock);
|
||||
})
|
||||
}
|
||||
}
|
||||
const appAccountInfoMock = {
|
||||
owner: "[PC Preview] unknown owner",
|
||||
name: "[PC Preview] unknown name"
|
||||
};
|
||||
const appAccountManagerMock = {
|
||||
addAccount: function (...args) {
|
||||
console.warn("AppAccountManager.addAccount interface mocked in the Previewer. " +
|
||||
"How this interface works on the Previewer may be different from that on a real device.")
|
||||
const len = args.length
|
||||
if (len > 0 && typeof args[len - 1] === 'function') {
|
||||
args[len - 1].call(this, paramMock.businessErrorMock);
|
||||
} else {
|
||||
return new Promise((resolve, reject) => {
|
||||
resolve();
|
||||
})
|
||||
}
|
||||
},
|
||||
deleteAccount: function (...args) {
|
||||
console.warn("AppAccountManager.deleteAccount interface mocked in the Previewer. " +
|
||||
"How this interface works on the Previewer may be different from that on a real device.")
|
||||
const len = args.length
|
||||
if (len > 0 && typeof args[len - 1] === 'function') {
|
||||
args[len - 1].call(this, paramMock.businessErrorMock);
|
||||
} else {
|
||||
return new Promise((resolve, reject) => {
|
||||
resolve();
|
||||
})
|
||||
}
|
||||
},
|
||||
disableAppAccess: function (...args) {
|
||||
console.warn("AppAccountManager.disableAppAccess interface mocked in the Previewer. " +
|
||||
"How this interface works on the Previewer may be different from that on a real device.")
|
||||
const len = args.length
|
||||
if (len > 0 && typeof args[len - 1] === 'function') {
|
||||
args[len - 1].call(this, paramMock.businessErrorMock);
|
||||
} else {
|
||||
return new Promise((resolve, reject) => {
|
||||
resolve();
|
||||
})
|
||||
}
|
||||
},
|
||||
enableAppAccess: function (...args) {
|
||||
console.warn("AppAccountManager.enableAppAccess interface mocked in the Previewer. " +
|
||||
"How this interface works on the Previewer may be different from that on a real device.")
|
||||
const len = args.length
|
||||
if (len > 0 && typeof args[len - 1] === 'function') {
|
||||
args[len - 1].call(this, paramMock.businessErrorMock);
|
||||
} else {
|
||||
return new Promise((resolve, reject) => {
|
||||
resolve();
|
||||
})
|
||||
}
|
||||
},
|
||||
checkAppAccountSyncEnable: function (...args) {
|
||||
console.warn("AppAccountManager.checkAppAccountSyncEnable interface mocked in the Previewer. " +
|
||||
"How this interface works on the Previewer may be different from that on a real device.")
|
||||
const len = args.length
|
||||
if (len > 0 && typeof args[len - 1] === 'function') {
|
||||
args[len - 1].call(this, paramMock.businessErrorMock, paramMock.paramBooleanMock);
|
||||
} else {
|
||||
return new Promise((resolve, reject) => {
|
||||
resolve(paramMock.paramBooleanMock);
|
||||
})
|
||||
}
|
||||
},
|
||||
setAccountCredential: function (...args) {
|
||||
console.warn("AppAccountManager.setAccountCredential interface mocked in the Previewer. " +
|
||||
"How this interface works on the Previewer may be different from that on a real device.")
|
||||
const len = args.length
|
||||
if (len > 0 && typeof args[len - 1] === 'function') {
|
||||
args[len - 1].call(this, paramMock.businessErrorMock);
|
||||
} else {
|
||||
return new Promise((resolve, reject) => {
|
||||
resolve();
|
||||
})
|
||||
}
|
||||
},
|
||||
setAccountExtraInfo: function (...args) {
|
||||
console.warn("AppAccountManager.setAccountExtraInfo interface mocked in the Previewer. " +
|
||||
"How this interface works on the Previewer may be different from that on a real device.")
|
||||
const len = args.length
|
||||
if (len > 0 && typeof args[len - 1] === 'function') {
|
||||
args[len - 1].call(this, paramMock.businessErrorMock);
|
||||
} else {
|
||||
return new Promise((resolve, reject) => {
|
||||
resolve();
|
||||
})
|
||||
}
|
||||
},
|
||||
setAppAccountSyncEnable: function (...args) {
|
||||
console.warn("AppAccountManager.setAppAccountSyncEnable interface mocked in the Previewer. " +
|
||||
"How this interface works on the Previewer may be different from that on a real device.")
|
||||
const len = args.length
|
||||
if (len > 0 && typeof args[len - 1] === 'function') {
|
||||
args[len - 1].call(this, paramMock.businessErrorMock);
|
||||
} else {
|
||||
return new Promise((resolve, reject) => {
|
||||
resolve();
|
||||
})
|
||||
}
|
||||
},
|
||||
setAssociatedData: function (...args) {
|
||||
console.warn("AppAccountManager.setAssociatedData interface mocked in the Previewer. " +
|
||||
"How this interface works on the Previewer may be different from that on a real device.")
|
||||
const len = args.length
|
||||
if (len > 0 && typeof args[len - 1] === 'function') {
|
||||
args[len - 1].call(this, paramMock.businessErrorMock);
|
||||
} else {
|
||||
return new Promise((resolve, reject) => {
|
||||
resolve();
|
||||
})
|
||||
}
|
||||
},
|
||||
getAllAccessibleAccounts: function (...args) {
|
||||
console.warn("AppAccountManager.getAllAccessibleAccounts interface mocked in the Previewer. " +
|
||||
"How this interface works on the Previewer may be different from that on a real device.")
|
||||
var appAccountInfoArrayMock = new Array();
|
||||
appAccountInfoArrayMock.push(appAccountInfoMock);
|
||||
const len = args.length
|
||||
if (len > 0 && typeof args[len - 1] === 'function') {
|
||||
args[len - 1].call(this, paramMock.businessErrorMock, appAccountInfoArrayMock);
|
||||
} else {
|
||||
return new Promise((resolve, reject) => {
|
||||
resolve(appAccountInfoArrayMock);
|
||||
})
|
||||
}
|
||||
},
|
||||
getAllAccounts: function (...args) {
|
||||
console.warn("AppAccountManager.getAllAccounts interface mocked in the Previewer. " +
|
||||
"How this interface works on the Previewer may be different from that on a real device.")
|
||||
var appAccountInfoArrayMock = new Array();
|
||||
appAccountInfoArrayMock.push(appAccountInfoMock);
|
||||
const len = args.length
|
||||
if (len > 0 && typeof args[len - 1] === 'function') {
|
||||
args[len - 1].call(this, paramMock.businessErrorMock, appAccountInfoArrayMock);
|
||||
} else {
|
||||
return new Promise((resolve, reject) => {
|
||||
resolve(appAccountInfoArrayMock);
|
||||
})
|
||||
}
|
||||
},
|
||||
getAccountCredential: function (...args) {
|
||||
console.warn("AppAccountManager.getAccountCredential interface mocked in the Previewer. " +
|
||||
"How this interface works on the Previewer may be different from that on a real device.")
|
||||
const len = args.length
|
||||
if (len > 0 && typeof args[len - 1] === 'function') {
|
||||
args[len - 1].call(this, paramMock.businessErrorMock, paramMock.paramStringMock);
|
||||
} else {
|
||||
return new Promise((resolve, reject) => {
|
||||
resolve(paramMock.paramStringMock);
|
||||
})
|
||||
}
|
||||
},
|
||||
getAccountExtraInfo: function (...args) {
|
||||
console.warn("AppAccountManager.getAccountExtraInfo interface mocked in the Previewer. " +
|
||||
"How this interface works on the Previewer may be different from that on a real device.")
|
||||
const len = args.length
|
||||
if (len > 0 && typeof args[len - 1] === 'function') {
|
||||
args[len - 1].call(this, paramMock.businessErrorMock, paramMock.paramStringMock);
|
||||
} else {
|
||||
return new Promise((resolve, reject) => {
|
||||
resolve(paramMock.paramStringMock);
|
||||
})
|
||||
}
|
||||
},
|
||||
getAssociatedData: function (...args) {
|
||||
console.warn("AppAccountManager.getAssociatedData interface mocked in the Previewer. " +
|
||||
"How this interface works on the Previewer may be different from that on a real device.")
|
||||
const len = args.length
|
||||
if (len > 0 && typeof args[len - 1] === 'function') {
|
||||
args[len - 1].call(this, paramMock.businessErrorMock, paramMock.paramStringMock);
|
||||
} else {
|
||||
return new Promise((resolve, reject) => {
|
||||
resolve(paramMock.paramStringMock);
|
||||
})
|
||||
}
|
||||
},
|
||||
on: function (...args) {
|
||||
console.warn("AppAccountManager.on interface mocked in the Previewer. " +
|
||||
"How this interface works on the Previewer may be different from that on a real device.")
|
||||
var appAccountInfoArrayMock = new Array();
|
||||
appAccountInfoArrayMock.push(appAccountInfoMock);
|
||||
const len = args.length
|
||||
if (len > 0 && typeof args[len - 1] === 'function') {
|
||||
args[len - 1].call(this, appAccountInfoArrayMock);
|
||||
} else {
|
||||
return new Promise((resolve, reject) => {
|
||||
resolve(appAccountInfoArrayMock);
|
||||
})
|
||||
}
|
||||
},
|
||||
off: function (...args) {
|
||||
console.warn("AppAccountManager.off interface mocked in the Previewer. " +
|
||||
"How this interface works on the Previewer may be different from that on a real device.")
|
||||
var appAccountInfoArrayMock = new Array();
|
||||
appAccountInfoArrayMock.push(appAccountInfoMock);
|
||||
const len = args.length
|
||||
if (len > 0 && typeof args[len - 1] === 'function') {
|
||||
args[len - 1].call(this, appAccountInfoArrayMock);
|
||||
} else {
|
||||
return new Promise((resolve, reject) => {
|
||||
resolve(appAccountInfoArrayMock);
|
||||
})
|
||||
}
|
||||
}
|
||||
global.ohosplugin.account = global.ohosplugin.account || {};
|
||||
global.ohosplugin.account.appAccount = {
|
||||
createAppAccountManager : function (...args) {
|
||||
console.warn("appAccount.createAppAccountManager interface mocked in the Previewer. " +
|
||||
"How this interface works on the Previewer may be different from that on a real device.")
|
||||
return appAccountManagerMock;
|
||||
}
|
||||
}
|
||||
global.ohosplugin.account = global.ohosplugin.account || {};
|
||||
global.ohosplugin.account.appAccount = {
|
||||
createAppAccountManager: function (...args) {
|
||||
console.warn("appAccount.createAppAccountManager interface mocked in the Previewer. " +
|
||||
"How this interface works on the Previewer may be different from that on a real device.")
|
||||
return appAccountManagerMock;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,35 +1,50 @@
|
||||
/*
|
||||
* 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 mockBackgroundTaskManager () {
|
||||
const DelaySuspendInfoMock = {
|
||||
requestId : '[PC preview] unknown requestId',
|
||||
actualDelayTime: '[PC preview] unknown actualDelayTime',
|
||||
}
|
||||
global.ohosplugin.backgroundTaskManager = {
|
||||
requestSuspendDelay: function (...args) {
|
||||
console.warn("backgroundTaskManager.requestSuspendDelay interface mocked in the Previewer. How this interface works on the" +
|
||||
" Previewer may be different from that on a real device.")
|
||||
const len = args.length;
|
||||
if (typeof args[len - 1] === 'function') {
|
||||
args[len - 1].call(this, paramMock.businessErrorMock)
|
||||
return DelaySuspendInfoMock;
|
||||
}
|
||||
},
|
||||
cancelSuspendDelay: function (...args) {
|
||||
console.warn("backgroundTaskManager.cancelSuspendDelay interface mocked in the Previewer. How this interface works on the" +
|
||||
" Previewer may be different from that on a real device.")
|
||||
},
|
||||
getRemainingDelayTime: function (...args) {
|
||||
console.warn("backgroundTaskManager.getRemainingDelayTime interface mocked in the Previewer. How this interface works on the" +
|
||||
" Previewer may be different from that on a real device.")
|
||||
const len = args.length
|
||||
if (typeof args[len - 1] === 'function') {
|
||||
args[len - 1].call(this, paramMock.businessErrorMock, DelaySuspendInfoMock.actualDelayTime)
|
||||
} else {
|
||||
return new Promise((resolve) => {
|
||||
resolve(DelaySuspendInfoMock.actualDelayTime)
|
||||
});
|
||||
}
|
||||
}
|
||||
export function mockBackgroundTaskManager() {
|
||||
const DelaySuspendInfoMock = {
|
||||
requestId: '[PC preview] unknown requestId',
|
||||
actualDelayTime: '[PC preview] unknown actualDelayTime',
|
||||
}
|
||||
global.ohosplugin.backgroundTaskManager = {
|
||||
requestSuspendDelay: function (...args) {
|
||||
console.warn("backgroundTaskManager.requestSuspendDelay interface mocked in the Previewer. How this interface works on the" +
|
||||
" Previewer may be different from that on a real device.")
|
||||
const len = args.length;
|
||||
if (typeof args[len - 1] === 'function') {
|
||||
args[len - 1].call(this, paramMock.businessErrorMock)
|
||||
return DelaySuspendInfoMock;
|
||||
}
|
||||
},
|
||||
cancelSuspendDelay: function (...args) {
|
||||
console.warn("backgroundTaskManager.cancelSuspendDelay interface mocked in the Previewer. How this interface works on the" +
|
||||
" Previewer may be different from that on a real device.")
|
||||
},
|
||||
getRemainingDelayTime: function (...args) {
|
||||
console.warn("backgroundTaskManager.getRemainingDelayTime interface mocked in the Previewer. How this interface works on the" +
|
||||
" Previewer may be different from that on a real device.")
|
||||
const len = args.length
|
||||
if (typeof args[len - 1] === 'function') {
|
||||
args[len - 1].call(this, paramMock.businessErrorMock, DelaySuspendInfoMock.actualDelayTime)
|
||||
} else {
|
||||
return new Promise((resolve) => {
|
||||
resolve(DelaySuspendInfoMock.actualDelayTime)
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,3 +1,18 @@
|
||||
/*
|
||||
* 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 mockOhosBluetooth() {
|
||||
@@ -351,13 +366,13 @@ export function mockOhosBluetooth() {
|
||||
if (args[0] == 'bluetoothDeviceFind') {
|
||||
args[len - 1].call(this, ArrayStringMock);
|
||||
} else if (args[0] == 'bondStateChange') {
|
||||
args[len - 1].call(this, paramMock.paramNumberMock);
|
||||
args[len - 1].call(this, paramMock.paramNumberMock);
|
||||
} else if (args[0] == 'pinRequired') {
|
||||
args[len - 1].call(this, pinRequiredParamMock);
|
||||
args[len - 1].call(this, pinRequiredParamMock);
|
||||
} else if (args[0] == 'stateChange') {
|
||||
args[len - 1].call(this, paramMock.paramNumberMock);
|
||||
args[len - 1].call(this, paramMock.paramNumberMock);
|
||||
} else if (args[0] == 'sppRead') {
|
||||
args[len - 1].call(this, sppReadMock.ArrayBuffer);
|
||||
args[len - 1].call(this, sppReadMock.ArrayBuffer);
|
||||
}
|
||||
}
|
||||
},
|
||||
@@ -369,13 +384,13 @@ export function mockOhosBluetooth() {
|
||||
if (args[0] == 'bluetoothDeviceFind') {
|
||||
args[len - 1].call(this, ArrayStringMock);
|
||||
} else if (args[0] == 'bondStateChange') {
|
||||
args[len - 1].call(this, paramMock.paramNumberMock);
|
||||
args[len - 1].call(this, paramMock.paramNumberMock);
|
||||
} else if (args[0] == 'pinRequired') {
|
||||
args[len - 1].call(this, pinRequiredParamMock);
|
||||
args[len - 1].call(this, pinRequiredParamMock);
|
||||
} else if (args[0] == 'stateChange') {
|
||||
args[len - 1].call(this, paramMock.paramNumberMock);
|
||||
args[len - 1].call(this, paramMock.paramNumberMock);
|
||||
} else if (args[0] == 'sppRead') {
|
||||
args[len - 1].call(this, sppReadMock.ArrayBuffer);
|
||||
args[len - 1].call(this, sppReadMock.ArrayBuffer);
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,113 +1,128 @@
|
||||
/*
|
||||
* 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 mockBundleState () {
|
||||
const bundleStateInfomMock = [{
|
||||
abilityInFgTotalTime: '[PC preview] unknown abilityInFgTotalTime',
|
||||
abilityPrevAccessTime: '[PC preview] unknown abilityPrevAccessTime',
|
||||
abilityPrevSeenTime: '[PC preview] unknown abilityPrevSeenTime',
|
||||
abilitySeenTotalTime: '[PC preview] unknown abilitySeenTotalTime',
|
||||
bundleName: "[PC preview] unknown bundle name",
|
||||
fgAbilityAccessTotalTime: '[PC preview] unknown fgAbilityAccessTotalTime',
|
||||
fgAbilityPrevAccessTime: '[PC preview] unknown fgAbilityPrevAccessTime',
|
||||
id: '[PC preview] unknown id',
|
||||
infosBeginTime: '[PC preview] unknown infosBeginTime',
|
||||
infosEndTime: '[PC preview] unknown infosEndTime',
|
||||
export function mockBundleState() {
|
||||
const bundleStateInfomMock = [{
|
||||
abilityInFgTotalTime: '[PC preview] unknown abilityInFgTotalTime',
|
||||
abilityPrevAccessTime: '[PC preview] unknown abilityPrevAccessTime',
|
||||
abilityPrevSeenTime: '[PC preview] unknown abilityPrevSeenTime',
|
||||
abilitySeenTotalTime: '[PC preview] unknown abilitySeenTotalTime',
|
||||
bundleName: "[PC preview] unknown bundle name",
|
||||
fgAbilityAccessTotalTime: '[PC preview] unknown fgAbilityAccessTotalTime',
|
||||
fgAbilityPrevAccessTime: '[PC preview] unknown fgAbilityPrevAccessTime',
|
||||
id: '[PC preview] unknown id',
|
||||
infosBeginTime: '[PC preview] unknown infosBeginTime',
|
||||
infosEndTime: '[PC preview] unknown infosEndTime',
|
||||
|
||||
merge: function (...args) {
|
||||
console.warn("bundleState.merge interface mocked in the Previewer. How this interface works on the" +
|
||||
" Previewer may be different from that on a real device.");
|
||||
},
|
||||
}]
|
||||
const bundleActiveStateMock = [{
|
||||
appUsagePriorityGroup: '[PC preview] unknown appUsagePriorityGroup',
|
||||
bundleName: '[PC preview] unknown bundleName',
|
||||
indexOfLink: '[PC preview] unknown indexOfLink',
|
||||
nameOfClass: '[PC preview] unknown nameOfClass',
|
||||
stateOccurredTime: '[PC preview] unknown stateOccurredTime',
|
||||
stateType: '[PC preview] unknown stateType',
|
||||
}]
|
||||
const bundleActiveInfoResponseMock = {
|
||||
"key" : bundleStateInfomMock
|
||||
}
|
||||
const intervalTypeMock = {
|
||||
BY_OPTIMIZED: 0,
|
||||
BY_DAILY: 1,
|
||||
BY_WEEKLY: 2,
|
||||
BY_MONTHLY: 3,
|
||||
BY_ANNUALLY:4
|
||||
}
|
||||
global.ohosplugin.bundleState = {
|
||||
isIdleState: function (...args) {
|
||||
console.warn("bundleState.isIdleState interface mocked in the Previewer. How this interface works on the" +
|
||||
" Previewer may be different from that on a real device.");
|
||||
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)
|
||||
});
|
||||
}
|
||||
},
|
||||
queryAppUsagePriorityGroup: function (...args) {
|
||||
console.warn("bundleState.queryAppUsagePriorityGroup interface mocked in the Previewer. How this interface works on the" +
|
||||
" Previewer may be different 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)
|
||||
});
|
||||
}
|
||||
},
|
||||
queryBundleStateInfos: function (...args) {
|
||||
console.warn("bundleState.queryBundleStateInfos interface mocked in the Previewer. How this interface works on the" +
|
||||
" Previewer may be different from that on a real device.");
|
||||
const len = args.length;
|
||||
if(typeof args[len - 1] === 'function') {
|
||||
args[len - 1].call(this, paramMock.businessErrorMock, bundleActiveInfoResponseMock);
|
||||
} else {
|
||||
return new Promise((resolve) => {
|
||||
resolve(bundleActiveInfoResponseMock)
|
||||
});
|
||||
}
|
||||
},
|
||||
queryBundleStateInfoByInterval: function (...args) {
|
||||
console.warn("bundleState.queryBundleStateInfoByInterval interface mocked in the Previewer. How this interface works on the" +
|
||||
" Previewer may be different from that on a real device.");
|
||||
const len = args.length;
|
||||
if(typeof args[len - 1] === 'function') {
|
||||
args[len - 1].call(this, paramMock.businessErrorMock, bundleStateInfomMock);
|
||||
} else {
|
||||
return new Promise((resolve) => {
|
||||
resolve(bundleStateInfomMock)
|
||||
});
|
||||
}
|
||||
},
|
||||
queryBundleActiveStates: function (...args) {
|
||||
console.warn("bundleState.queryBundleActiveStates interface mocked in the Previewer. How this interface works on the" +
|
||||
" Previewer may be different from that on a real device.");
|
||||
const len = args.length;
|
||||
if(typeof args[len - 1] === 'function') {
|
||||
args[len - 1].call(this, paramMock.businessErrorMock, bundleActiveStateMock);
|
||||
} else {
|
||||
return new Promise((resolve) => {
|
||||
resolve(bundleActiveStateMock)
|
||||
});
|
||||
}
|
||||
},
|
||||
queryCurrentBundleActiveStates: function (...args) {
|
||||
console.warn("bundleState.queryCurrentBundleActiveStates interface mocked in the Previewer. How this interface works on the" +
|
||||
" Previewer may be different from that on a real device.");
|
||||
const len = args.length;
|
||||
if(typeof args[len - 1] === 'function') {
|
||||
args[len - 1].call(this, paramMock.businessErrorMock, bundleActiveStateMock);
|
||||
} else {
|
||||
return new Promise((resolve) => {
|
||||
resolve(bundleActiveStateMock)
|
||||
});
|
||||
}
|
||||
}
|
||||
merge: function (...args) {
|
||||
console.warn("bundleState.merge interface mocked in the Previewer. How this interface works on the" +
|
||||
" Previewer may be different from that on a real device.");
|
||||
},
|
||||
}]
|
||||
const bundleActiveStateMock = [{
|
||||
appUsagePriorityGroup: '[PC preview] unknown appUsagePriorityGroup',
|
||||
bundleName: '[PC preview] unknown bundleName',
|
||||
indexOfLink: '[PC preview] unknown indexOfLink',
|
||||
nameOfClass: '[PC preview] unknown nameOfClass',
|
||||
stateOccurredTime: '[PC preview] unknown stateOccurredTime',
|
||||
stateType: '[PC preview] unknown stateType',
|
||||
}]
|
||||
const bundleActiveInfoResponseMock = {
|
||||
"key": bundleStateInfomMock
|
||||
}
|
||||
const intervalTypeMock = {
|
||||
BY_OPTIMIZED: 0,
|
||||
BY_DAILY: 1,
|
||||
BY_WEEKLY: 2,
|
||||
BY_MONTHLY: 3,
|
||||
BY_ANNUALLY: 4
|
||||
}
|
||||
global.ohosplugin.bundleState = {
|
||||
isIdleState: function (...args) {
|
||||
console.warn("bundleState.isIdleState interface mocked in the Previewer. How this interface works on the" +
|
||||
" Previewer may be different from that on a real device.");
|
||||
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)
|
||||
});
|
||||
}
|
||||
},
|
||||
queryAppUsagePriorityGroup: function (...args) {
|
||||
console.warn("bundleState.queryAppUsagePriorityGroup interface mocked in the Previewer. How this interface works on the" +
|
||||
" Previewer may be different 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)
|
||||
});
|
||||
}
|
||||
},
|
||||
queryBundleStateInfos: function (...args) {
|
||||
console.warn("bundleState.queryBundleStateInfos interface mocked in the Previewer. How this interface works on the" +
|
||||
" Previewer may be different from that on a real device.");
|
||||
const len = args.length;
|
||||
if (typeof args[len - 1] === 'function') {
|
||||
args[len - 1].call(this, paramMock.businessErrorMock, bundleActiveInfoResponseMock);
|
||||
} else {
|
||||
return new Promise((resolve) => {
|
||||
resolve(bundleActiveInfoResponseMock)
|
||||
});
|
||||
}
|
||||
},
|
||||
queryBundleStateInfoByInterval: function (...args) {
|
||||
console.warn("bundleState.queryBundleStateInfoByInterval interface mocked in the Previewer. How this interface works on the" +
|
||||
" Previewer may be different from that on a real device.");
|
||||
const len = args.length;
|
||||
if (typeof args[len - 1] === 'function') {
|
||||
args[len - 1].call(this, paramMock.businessErrorMock, bundleStateInfomMock);
|
||||
} else {
|
||||
return new Promise((resolve) => {
|
||||
resolve(bundleStateInfomMock)
|
||||
});
|
||||
}
|
||||
},
|
||||
queryBundleActiveStates: function (...args) {
|
||||
console.warn("bundleState.queryBundleActiveStates interface mocked in the Previewer. How this interface works on the" +
|
||||
" Previewer may be different from that on a real device.");
|
||||
const len = args.length;
|
||||
if (typeof args[len - 1] === 'function') {
|
||||
args[len - 1].call(this, paramMock.businessErrorMock, bundleActiveStateMock);
|
||||
} else {
|
||||
return new Promise((resolve) => {
|
||||
resolve(bundleActiveStateMock)
|
||||
});
|
||||
}
|
||||
},
|
||||
queryCurrentBundleActiveStates: function (...args) {
|
||||
console.warn("bundleState.queryCurrentBundleActiveStates interface mocked in the Previewer. How this interface works on the" +
|
||||
" Previewer may be different from that on a real device.");
|
||||
const len = args.length;
|
||||
if (typeof args[len - 1] === 'function') {
|
||||
args[len - 1].call(this, paramMock.businessErrorMock, bundleActiveStateMock);
|
||||
} else {
|
||||
return new Promise((resolve) => {
|
||||
resolve(bundleActiveStateMock)
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,191 +1,206 @@
|
||||
/*
|
||||
* 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 mockCommonEvent() {
|
||||
const CommonEventSubscriberMock = {
|
||||
getCode: function (...args) {
|
||||
console.warn("CommonEventSubscriber.getCode interface mocked in the Previewer. How this interface works on the" +
|
||||
" Previewer may be different from that on a real device.");
|
||||
const len = args.length;
|
||||
if (typeof args[len - 1] === 'function') {
|
||||
args[len - 1].call(this, paramMock.businessErrorMock, paramMock.paramNumberMock);
|
||||
} else {
|
||||
return new Promise((resolve) => {
|
||||
resolve(paramMock.paramNumberMock);
|
||||
});
|
||||
}
|
||||
},
|
||||
setCode: function (...args) {
|
||||
console.warn("CommonEventSubscriber.setCode interface mocked in the Previewer. How this interface works on the" +
|
||||
" Previewer may be different from that on a real device.");
|
||||
const len = args.length;
|
||||
if (typeof args[len - 1] === 'function') {
|
||||
args[len - 1].call(this, paramMock.businessErrorMock);
|
||||
} else {
|
||||
return new Promise((resolve) => {
|
||||
resolve();
|
||||
});
|
||||
}
|
||||
},
|
||||
getData: function (...args) {
|
||||
console.warn("CommonEventSubscriber.getData interface mocked in the Previewer. How this interface works on the" +
|
||||
" Previewer may be different from that on a real device.");
|
||||
const len = args.length;
|
||||
if (typeof args[len - 1] === 'function') {
|
||||
args[len - 1].call(this, paramMock.businessErrorMock, paramMock.paramStringMock);
|
||||
} else {
|
||||
return new Promise((resolve) => {
|
||||
resolve(paramMock.paramStringMock);
|
||||
});
|
||||
}
|
||||
},
|
||||
setData: function (...args) {
|
||||
console.warn("CommonEventSubscriber.setData interface mocked in the Previewer. How this interface works on the" +
|
||||
" Previewer may be different from that on a real device.");
|
||||
const len = args.length;
|
||||
if (typeof args[len - 1] === 'function') {
|
||||
args[len - 1].call(this, paramMock.businessErrorMock);
|
||||
} else {
|
||||
return new Promise((resolve) => {
|
||||
resolve();
|
||||
});
|
||||
}
|
||||
},
|
||||
setCodeAndData: function (...args) {
|
||||
console.warn("CommonEventSubscriber.setCodeAndData interface mocked in the Previewer. How this interface works on the" +
|
||||
" Previewer may be different from that on a real device.");
|
||||
const len = args.length;
|
||||
if (typeof args[len - 1] === 'function') {
|
||||
args[len - 1].call(this, paramMock.businessErrorMock);
|
||||
} else {
|
||||
return new Promise((resolve) => {
|
||||
resolve();
|
||||
});
|
||||
}
|
||||
},
|
||||
isOrderedCommonEvent: function (...args) {
|
||||
console.warn("CommonEventSubscriber.isOrderedCommonEvent interface mocked in the Previewer. How this interface works on the" +
|
||||
" Previewer may be different from that on a real device.");
|
||||
const len = args.length;
|
||||
if (typeof args[len - 1] === 'function') {
|
||||
args[len - 1].call(this, paramMock.businessErrorMock, paramMock.paramBooleanMock);
|
||||
} else {
|
||||
return new Promise((resolve) => {
|
||||
resolve(paramMock.paramBooleanMock);
|
||||
});
|
||||
}
|
||||
},
|
||||
isStickyCommonEvent: function (...args) {
|
||||
console.warn("CommonEventSubscriber.isStickyCommonEvent interface mocked in the Previewer. How this interface works on the" +
|
||||
" Previewer may be different from that on a real device.");
|
||||
const len = args.length;
|
||||
if (typeof args[len - 1] === 'function') {
|
||||
args[len - 1].call(this, paramMock.businessErrorMock, paramMock.paramBooleanMock);
|
||||
} else {
|
||||
return new Promise((resolve) => {
|
||||
resolve(paramMock.paramBooleanMock);
|
||||
});
|
||||
}
|
||||
},
|
||||
abortCommonEvent: function (...args) {
|
||||
console.warn("CommonEventSubscriber.abortCommonEvent interface mocked in the Previewer. How this interface works on the" +
|
||||
" Previewer may be different from that on a real device.");
|
||||
const len = args.length;
|
||||
if (typeof args[len - 1] === 'function') {
|
||||
args[len - 1].call(this, paramMock.businessErrorMock);
|
||||
} else {
|
||||
return new Promise((resolve) => {
|
||||
resolve();
|
||||
});
|
||||
}
|
||||
},
|
||||
clearAbortCommonEvent: function (...args) {
|
||||
console.warn("CommonEventSubscriber.clearAbortCommonEvent interface mocked in the Previewer. How this interface works on the" +
|
||||
" Previewer may be different from that on a real device.");
|
||||
const len = args.length;
|
||||
if (typeof args[len - 1] === 'function') {
|
||||
args[len - 1].call(this, paramMock.businessErrorMock);
|
||||
} else {
|
||||
return new Promise((resolve) => {
|
||||
resolve();
|
||||
});
|
||||
}
|
||||
},
|
||||
getAbortCommonEvent: function (...args) {
|
||||
console.warn("CommonEventSubscriber.getAbortCommonEvent interface mocked in the Previewer. How this interface works on the" +
|
||||
" Previewer may be different from that on a real device.");
|
||||
const len = args.length;
|
||||
if (typeof args[len - 1] === 'function') {
|
||||
args[len - 1].call(this, paramMock.businessErrorMock, paramMock.paramBooleanMock);
|
||||
} else {
|
||||
return new Promise((resolve) => {
|
||||
resolve(paramMock.paramBooleanMock);
|
||||
});
|
||||
}
|
||||
},
|
||||
getSubscribeInfo: function (...args) {
|
||||
console.warn("CommonEventSubscriber.getSubscribeInfo interface mocked in the Previewer. How this interface works on the" +
|
||||
" Previewer may be different from that on a real device.");
|
||||
const len = args.length;
|
||||
if (typeof args[len - 1] === 'function') {
|
||||
args[len - 1].call(this, paramMock.businessErrorMock, CommonEventSubscribeInfoMock);
|
||||
} else {
|
||||
return new Promise((resolve) => {
|
||||
resolve(CommonEventSubscribeInfoMock);
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
const CommonEventDataMock = {
|
||||
event: '[PC preview] unknow event',
|
||||
bundleName: '[PC preview] unknow bundleName',
|
||||
code: '[PC preview] unknow code',
|
||||
data: '[PC preview] unknow data',
|
||||
parameters: '[PC preview] unknow parameters',
|
||||
}
|
||||
const CommonEventSubscribeInfoMock = {
|
||||
events: '[PC preview] unknow events',
|
||||
publisherPermission: '[PC preview] unknow publisherPermission',
|
||||
publisherDeviceId: '[PC preview] unknow publisherDeviceId',
|
||||
userId: '[PC preview] unknow userId',
|
||||
priority: '[PC preview] unknow priority',
|
||||
}
|
||||
global.ohosplugin.commonEvent = {
|
||||
publish: function (...args) {
|
||||
console.warn("commonEvent.publish interface mocked in the Previewer. How this interface works on the" +
|
||||
" Previewer may be different from that on a real device.");
|
||||
const len = args.length;
|
||||
if (typeof args[len - 1] === 'function') {
|
||||
args[len - 1].call(this, paramMock.businessErrorMock);
|
||||
}
|
||||
},
|
||||
createSubscriber: function (...args) {
|
||||
console.warn("commonEvent.createSubscriber interface mocked in the Previewer. How this interface works on the" +
|
||||
" Previewer may be different from that on a real device.");
|
||||
const len = args.length;
|
||||
if (typeof args[len - 1] === 'function') {
|
||||
args[len - 1].call(this, paramMock.businessErrorMock, CommonEventSubscriberMock);
|
||||
} else {
|
||||
return new Promise((resolve) => {
|
||||
resolve(CommonEventSubscriberMock);
|
||||
});
|
||||
}
|
||||
},
|
||||
subscribe: function (...args) {
|
||||
console.warn("commonEvent.subscribe interface mocked in the Previewer. How this interface works on the" +
|
||||
" Previewer may be different from that on a real device.");
|
||||
const len = args.length;
|
||||
if (typeof args[len - 1] === 'function') {
|
||||
args[len - 1].call(this, paramMock.businessErrorMock, CommonEventDataMock);
|
||||
}
|
||||
},
|
||||
unsubscribe: function (...args) {
|
||||
console.warn("commonEvent.unsubscribe interface mocked in the Previewer. How this interface works on the" +
|
||||
" Previewer may be different from that on a real device.");
|
||||
const len = args.length;
|
||||
if (typeof args[len - 1] === 'function') {
|
||||
args[len - 1].call(this, paramMock.businessErrorMock);
|
||||
}
|
||||
},
|
||||
const CommonEventSubscriberMock = {
|
||||
getCode: function (...args) {
|
||||
console.warn("CommonEventSubscriber.getCode interface mocked in the Previewer. How this interface works on the" +
|
||||
" Previewer may be different from that on a real device.");
|
||||
const len = args.length;
|
||||
if (typeof args[len - 1] === 'function') {
|
||||
args[len - 1].call(this, paramMock.businessErrorMock, paramMock.paramNumberMock);
|
||||
} else {
|
||||
return new Promise((resolve) => {
|
||||
resolve(paramMock.paramNumberMock);
|
||||
});
|
||||
}
|
||||
},
|
||||
setCode: function (...args) {
|
||||
console.warn("CommonEventSubscriber.setCode interface mocked in the Previewer. How this interface works on the" +
|
||||
" Previewer may be different from that on a real device.");
|
||||
const len = args.length;
|
||||
if (typeof args[len - 1] === 'function') {
|
||||
args[len - 1].call(this, paramMock.businessErrorMock);
|
||||
} else {
|
||||
return new Promise((resolve) => {
|
||||
resolve();
|
||||
});
|
||||
}
|
||||
},
|
||||
getData: function (...args) {
|
||||
console.warn("CommonEventSubscriber.getData interface mocked in the Previewer. How this interface works on the" +
|
||||
" Previewer may be different from that on a real device.");
|
||||
const len = args.length;
|
||||
if (typeof args[len - 1] === 'function') {
|
||||
args[len - 1].call(this, paramMock.businessErrorMock, paramMock.paramStringMock);
|
||||
} else {
|
||||
return new Promise((resolve) => {
|
||||
resolve(paramMock.paramStringMock);
|
||||
});
|
||||
}
|
||||
},
|
||||
setData: function (...args) {
|
||||
console.warn("CommonEventSubscriber.setData interface mocked in the Previewer. How this interface works on the" +
|
||||
" Previewer may be different from that on a real device.");
|
||||
const len = args.length;
|
||||
if (typeof args[len - 1] === 'function') {
|
||||
args[len - 1].call(this, paramMock.businessErrorMock);
|
||||
} else {
|
||||
return new Promise((resolve) => {
|
||||
resolve();
|
||||
});
|
||||
}
|
||||
},
|
||||
setCodeAndData: function (...args) {
|
||||
console.warn("CommonEventSubscriber.setCodeAndData interface mocked in the Previewer. How this interface works on the" +
|
||||
" Previewer may be different from that on a real device.");
|
||||
const len = args.length;
|
||||
if (typeof args[len - 1] === 'function') {
|
||||
args[len - 1].call(this, paramMock.businessErrorMock);
|
||||
} else {
|
||||
return new Promise((resolve) => {
|
||||
resolve();
|
||||
});
|
||||
}
|
||||
},
|
||||
isOrderedCommonEvent: function (...args) {
|
||||
console.warn("CommonEventSubscriber.isOrderedCommonEvent interface mocked in the Previewer. How this interface works on the" +
|
||||
" Previewer may be different from that on a real device.");
|
||||
const len = args.length;
|
||||
if (typeof args[len - 1] === 'function') {
|
||||
args[len - 1].call(this, paramMock.businessErrorMock, paramMock.paramBooleanMock);
|
||||
} else {
|
||||
return new Promise((resolve) => {
|
||||
resolve(paramMock.paramBooleanMock);
|
||||
});
|
||||
}
|
||||
},
|
||||
isStickyCommonEvent: function (...args) {
|
||||
console.warn("CommonEventSubscriber.isStickyCommonEvent interface mocked in the Previewer. How this interface works on the" +
|
||||
" Previewer may be different from that on a real device.");
|
||||
const len = args.length;
|
||||
if (typeof args[len - 1] === 'function') {
|
||||
args[len - 1].call(this, paramMock.businessErrorMock, paramMock.paramBooleanMock);
|
||||
} else {
|
||||
return new Promise((resolve) => {
|
||||
resolve(paramMock.paramBooleanMock);
|
||||
});
|
||||
}
|
||||
},
|
||||
abortCommonEvent: function (...args) {
|
||||
console.warn("CommonEventSubscriber.abortCommonEvent interface mocked in the Previewer. How this interface works on the" +
|
||||
" Previewer may be different from that on a real device.");
|
||||
const len = args.length;
|
||||
if (typeof args[len - 1] === 'function') {
|
||||
args[len - 1].call(this, paramMock.businessErrorMock);
|
||||
} else {
|
||||
return new Promise((resolve) => {
|
||||
resolve();
|
||||
});
|
||||
}
|
||||
},
|
||||
clearAbortCommonEvent: function (...args) {
|
||||
console.warn("CommonEventSubscriber.clearAbortCommonEvent interface mocked in the Previewer. How this interface works on the" +
|
||||
" Previewer may be different from that on a real device.");
|
||||
const len = args.length;
|
||||
if (typeof args[len - 1] === 'function') {
|
||||
args[len - 1].call(this, paramMock.businessErrorMock);
|
||||
} else {
|
||||
return new Promise((resolve) => {
|
||||
resolve();
|
||||
});
|
||||
}
|
||||
},
|
||||
getAbortCommonEvent: function (...args) {
|
||||
console.warn("CommonEventSubscriber.getAbortCommonEvent interface mocked in the Previewer. How this interface works on the" +
|
||||
" Previewer may be different from that on a real device.");
|
||||
const len = args.length;
|
||||
if (typeof args[len - 1] === 'function') {
|
||||
args[len - 1].call(this, paramMock.businessErrorMock, paramMock.paramBooleanMock);
|
||||
} else {
|
||||
return new Promise((resolve) => {
|
||||
resolve(paramMock.paramBooleanMock);
|
||||
});
|
||||
}
|
||||
},
|
||||
getSubscribeInfo: function (...args) {
|
||||
console.warn("CommonEventSubscriber.getSubscribeInfo interface mocked in the Previewer. How this interface works on the" +
|
||||
" Previewer may be different from that on a real device.");
|
||||
const len = args.length;
|
||||
if (typeof args[len - 1] === 'function') {
|
||||
args[len - 1].call(this, paramMock.businessErrorMock, CommonEventSubscribeInfoMock);
|
||||
} else {
|
||||
return new Promise((resolve) => {
|
||||
resolve(CommonEventSubscribeInfoMock);
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
const CommonEventDataMock = {
|
||||
event: '[PC preview] unknow event',
|
||||
bundleName: '[PC preview] unknow bundleName',
|
||||
code: '[PC preview] unknow code',
|
||||
data: '[PC preview] unknow data',
|
||||
parameters: '[PC preview] unknow parameters',
|
||||
}
|
||||
const CommonEventSubscribeInfoMock = {
|
||||
events: '[PC preview] unknow events',
|
||||
publisherPermission: '[PC preview] unknow publisherPermission',
|
||||
publisherDeviceId: '[PC preview] unknow publisherDeviceId',
|
||||
userId: '[PC preview] unknow userId',
|
||||
priority: '[PC preview] unknow priority',
|
||||
}
|
||||
global.ohosplugin.commonEvent = {
|
||||
publish: function (...args) {
|
||||
console.warn("commonEvent.publish interface mocked in the Previewer. How this interface works on the" +
|
||||
" Previewer may be different from that on a real device.");
|
||||
const len = args.length;
|
||||
if (typeof args[len - 1] === 'function') {
|
||||
args[len - 1].call(this, paramMock.businessErrorMock);
|
||||
}
|
||||
},
|
||||
createSubscriber: function (...args) {
|
||||
console.warn("commonEvent.createSubscriber interface mocked in the Previewer. How this interface works on the" +
|
||||
" Previewer may be different from that on a real device.");
|
||||
const len = args.length;
|
||||
if (typeof args[len - 1] === 'function') {
|
||||
args[len - 1].call(this, paramMock.businessErrorMock, CommonEventSubscriberMock);
|
||||
} else {
|
||||
return new Promise((resolve) => {
|
||||
resolve(CommonEventSubscriberMock);
|
||||
});
|
||||
}
|
||||
},
|
||||
subscribe: function (...args) {
|
||||
console.warn("commonEvent.subscribe interface mocked in the Previewer. How this interface works on the" +
|
||||
" Previewer may be different from that on a real device.");
|
||||
const len = args.length;
|
||||
if (typeof args[len - 1] === 'function') {
|
||||
args[len - 1].call(this, paramMock.businessErrorMock, CommonEventDataMock);
|
||||
}
|
||||
},
|
||||
unsubscribe: function (...args) {
|
||||
console.warn("commonEvent.unsubscribe interface mocked in the Previewer. How this interface works on the" +
|
||||
" Previewer may be different from that on a real device.");
|
||||
const len = args.length;
|
||||
if (typeof args[len - 1] === 'function') {
|
||||
args[len - 1].call(this, paramMock.businessErrorMock);
|
||||
}
|
||||
},
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,170 +1,185 @@
|
||||
import {paramMock} from "../utils"
|
||||
/*
|
||||
* 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 mockOhosGeolocation() {
|
||||
const LocationMock = {
|
||||
latitude: '[PC preview] unknow latitude',
|
||||
longitude: '[PC preview] unknow longitude',
|
||||
altitude: '[PC preview] unknow altitude',
|
||||
accuracy: '[PC preview] unknow accuracy',
|
||||
speed: '[PC preview] unknow speed',
|
||||
timeStamp: '[PC preview] unknow timeStamp',
|
||||
direction: '[PC preview] unknow direction',
|
||||
timeSinceBoot: '[PC preview] unknow timeSinceBoot',
|
||||
additions: '[PC preview] unknow additions',
|
||||
additionSize: '[PC preview] unknow additionSize',
|
||||
}
|
||||
const GeoAddressMock = {
|
||||
latitude: '[PC preview] unknow latitude',
|
||||
longitude: '[PC preview] unknow longitude',
|
||||
locale: '[PC preview] unknow locale',
|
||||
placeName: '[PC preview] unknow placeName',
|
||||
countryCode: '[PC preview] unknow countryCode',
|
||||
countryName: '[PC preview] unknow countryName',
|
||||
administrativeArea: '[PC preview] unknow administrativeArea',
|
||||
subAdministrativeArea: '[PC preview] unknow subAdministrativeArea',
|
||||
locality: '[PC preview] unknow locality',
|
||||
subLocality: '[PC preview] unknow subLocality',
|
||||
roadName: '[PC preview] unknow roadName',
|
||||
subRoadName: '[PC preview] unknow subRoadName',
|
||||
premises: '[PC preview] unknow premises',
|
||||
postalCode: '[PC preview] unknow postalCode',
|
||||
phoneNumber: '[PC preview] unknow phoneNumber',
|
||||
addressUrl: '[PC preview] unknow addressUrl',
|
||||
descriptions: '[PC preview] unknow descriptions',
|
||||
descriptionsSize: '[PC preview] unknow descriptionsSize',
|
||||
}
|
||||
global.ohosplugin.geolocation = {
|
||||
on: function (...args) {
|
||||
console.warn("geolocation.on interface mocked in the Previewer. How this interface works on the" +
|
||||
" Previewer may be different from that on a real device.");
|
||||
const len = args.length;
|
||||
if (typeof args[len - 1] === 'function') {
|
||||
if (args[0] == 'locationChange') {
|
||||
args[len - 1].call(this, LocationMock);
|
||||
} else if (args[0] == 'locationServiceState') {
|
||||
args[len - 1].call(this, paramMock.paramBooleanMock);
|
||||
}
|
||||
}
|
||||
},
|
||||
off: function (...args) {
|
||||
console.warn("geolocation.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] == 'locationChange') {
|
||||
args[len - 1].call(this, LocationMock);
|
||||
} else if (args[0] == 'locationServiceState') {
|
||||
args[len - 1].call(this, paramMock.paramBooleanMock);
|
||||
}
|
||||
}
|
||||
},
|
||||
getCurrentLocation: function (...args) {
|
||||
console.warn("geolocation.getCurrentLocation interface mocked in the Previewer. How this interface works on the" +
|
||||
" Previewer may be different from that on a real device.");
|
||||
const len = args.length;
|
||||
if (typeof args[len - 1] === 'function') {
|
||||
args[len - 1].call(this, paramMock.businessErrorMock, LocationMock);
|
||||
} else {
|
||||
return new Promise((resolve) => {
|
||||
resolve(LocationMock);
|
||||
});
|
||||
}
|
||||
},
|
||||
getLastLocation: function (...args) {
|
||||
console.warn("geolocation.getLastLocation interface mocked in the Previewer. How this interface works on the" +
|
||||
" Previewer may be different from that on a real device.");
|
||||
const len = args.length;
|
||||
if (typeof args[len - 1] === 'function') {
|
||||
args[len - 1].call(this, paramMock.businessErrorMock, LocationMock);
|
||||
} else {
|
||||
return new Promise((resolve) => {
|
||||
resolve(LocationMock);
|
||||
});
|
||||
}
|
||||
},
|
||||
isLocationEnabled: function (...args) {
|
||||
console.warn("geolocation.isLocationEnabled interface mocked in the Previewer. How this interface works on the" +
|
||||
" Previewer may be different 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);
|
||||
});
|
||||
}
|
||||
},
|
||||
requestEnableLocation: function (...args) {
|
||||
console.warn("geolocation.requestEnableLocation interface mocked in the Previewer. How this interface works on the" +
|
||||
" Previewer may be different 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);
|
||||
});
|
||||
}
|
||||
},
|
||||
enableLocation: function (...args) {
|
||||
console.warn("geolocation.enableLocation interface mocked in the Previewer. How this interface works on the" +
|
||||
" Previewer may be different 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);
|
||||
});
|
||||
}
|
||||
},
|
||||
disableLocation: function (...args) {
|
||||
console.warn("geolocation.disableLocation interface mocked in the Previewer. How this interface works on the" +
|
||||
" Previewer may be different 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);
|
||||
});
|
||||
}
|
||||
},
|
||||
getAddressesFromLocation: function (...args) {
|
||||
console.warn("geolocation.getAddressesFromLocation interface mocked in the Previewer. How this interface works on the" +
|
||||
" Previewer may be different from that on a real device.");
|
||||
const len = args.length;
|
||||
if (typeof args[len - 1] === 'function') {
|
||||
args[len - 1].call(this, paramMock.businessErrorMock, [GeoAddressMock]);
|
||||
} else {
|
||||
return new Promise((resolve) => {
|
||||
resolve([GeoAddressMock]);
|
||||
});
|
||||
}
|
||||
},
|
||||
getAddressesFromLocationName: function (...args) {
|
||||
console.warn("geolocation.getAddressesFromLocationName interface mocked in the Previewer. How this interface works on the" +
|
||||
" Previewer may be different from that on a real device.");
|
||||
const len = args.length;
|
||||
if (typeof args[len - 1] === 'function') {
|
||||
args[len - 1].call(this, paramMock.businessErrorMock, [GeoAddressMock]);
|
||||
} else {
|
||||
return new Promise((resolve) => {
|
||||
resolve([GeoAddressMock]);
|
||||
});
|
||||
}
|
||||
},
|
||||
isGeoServiceAvailable: function (...args) {
|
||||
console.warn("geolocation.isGeoServiceAvailable interface mocked in the Previewer. How this interface works on the" +
|
||||
" Previewer may be different 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);
|
||||
});
|
||||
}
|
||||
},
|
||||
}
|
||||
const LocationMock = {
|
||||
latitude: '[PC preview] unknow latitude',
|
||||
longitude: '[PC preview] unknow longitude',
|
||||
altitude: '[PC preview] unknow altitude',
|
||||
accuracy: '[PC preview] unknow accuracy',
|
||||
speed: '[PC preview] unknow speed',
|
||||
timeStamp: '[PC preview] unknow timeStamp',
|
||||
direction: '[PC preview] unknow direction',
|
||||
timeSinceBoot: '[PC preview] unknow timeSinceBoot',
|
||||
additions: '[PC preview] unknow additions',
|
||||
additionSize: '[PC preview] unknow additionSize',
|
||||
}
|
||||
const GeoAddressMock = {
|
||||
latitude: '[PC preview] unknow latitude',
|
||||
longitude: '[PC preview] unknow longitude',
|
||||
locale: '[PC preview] unknow locale',
|
||||
placeName: '[PC preview] unknow placeName',
|
||||
countryCode: '[PC preview] unknow countryCode',
|
||||
countryName: '[PC preview] unknow countryName',
|
||||
administrativeArea: '[PC preview] unknow administrativeArea',
|
||||
subAdministrativeArea: '[PC preview] unknow subAdministrativeArea',
|
||||
locality: '[PC preview] unknow locality',
|
||||
subLocality: '[PC preview] unknow subLocality',
|
||||
roadName: '[PC preview] unknow roadName',
|
||||
subRoadName: '[PC preview] unknow subRoadName',
|
||||
premises: '[PC preview] unknow premises',
|
||||
postalCode: '[PC preview] unknow postalCode',
|
||||
phoneNumber: '[PC preview] unknow phoneNumber',
|
||||
addressUrl: '[PC preview] unknow addressUrl',
|
||||
descriptions: '[PC preview] unknow descriptions',
|
||||
descriptionsSize: '[PC preview] unknow descriptionsSize',
|
||||
}
|
||||
global.ohosplugin.geolocation = {
|
||||
on: function (...args) {
|
||||
console.warn("geolocation.on interface mocked in the Previewer. How this interface works on the" +
|
||||
" Previewer may be different from that on a real device.");
|
||||
const len = args.length;
|
||||
if (typeof args[len - 1] === 'function') {
|
||||
if (args[0] == 'locationChange') {
|
||||
args[len - 1].call(this, LocationMock);
|
||||
} else if (args[0] == 'locationServiceState') {
|
||||
args[len - 1].call(this, paramMock.paramBooleanMock);
|
||||
}
|
||||
}
|
||||
},
|
||||
off: function (...args) {
|
||||
console.warn("geolocation.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] == 'locationChange') {
|
||||
args[len - 1].call(this, LocationMock);
|
||||
} else if (args[0] == 'locationServiceState') {
|
||||
args[len - 1].call(this, paramMock.paramBooleanMock);
|
||||
}
|
||||
}
|
||||
},
|
||||
getCurrentLocation: function (...args) {
|
||||
console.warn("geolocation.getCurrentLocation interface mocked in the Previewer. How this interface works on the" +
|
||||
" Previewer may be different from that on a real device.");
|
||||
const len = args.length;
|
||||
if (typeof args[len - 1] === 'function') {
|
||||
args[len - 1].call(this, paramMock.businessErrorMock, LocationMock);
|
||||
} else {
|
||||
return new Promise((resolve) => {
|
||||
resolve(LocationMock);
|
||||
});
|
||||
}
|
||||
},
|
||||
getLastLocation: function (...args) {
|
||||
console.warn("geolocation.getLastLocation interface mocked in the Previewer. How this interface works on the" +
|
||||
" Previewer may be different from that on a real device.");
|
||||
const len = args.length;
|
||||
if (typeof args[len - 1] === 'function') {
|
||||
args[len - 1].call(this, paramMock.businessErrorMock, LocationMock);
|
||||
} else {
|
||||
return new Promise((resolve) => {
|
||||
resolve(LocationMock);
|
||||
});
|
||||
}
|
||||
},
|
||||
isLocationEnabled: function (...args) {
|
||||
console.warn("geolocation.isLocationEnabled interface mocked in the Previewer. How this interface works on the" +
|
||||
" Previewer may be different 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);
|
||||
});
|
||||
}
|
||||
},
|
||||
requestEnableLocation: function (...args) {
|
||||
console.warn("geolocation.requestEnableLocation interface mocked in the Previewer. How this interface works on the" +
|
||||
" Previewer may be different 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);
|
||||
});
|
||||
}
|
||||
},
|
||||
enableLocation: function (...args) {
|
||||
console.warn("geolocation.enableLocation interface mocked in the Previewer. How this interface works on the" +
|
||||
" Previewer may be different 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);
|
||||
});
|
||||
}
|
||||
},
|
||||
disableLocation: function (...args) {
|
||||
console.warn("geolocation.disableLocation interface mocked in the Previewer. How this interface works on the" +
|
||||
" Previewer may be different 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);
|
||||
});
|
||||
}
|
||||
},
|
||||
getAddressesFromLocation: function (...args) {
|
||||
console.warn("geolocation.getAddressesFromLocation interface mocked in the Previewer. How this interface works on the" +
|
||||
" Previewer may be different from that on a real device.");
|
||||
const len = args.length;
|
||||
if (typeof args[len - 1] === 'function') {
|
||||
args[len - 1].call(this, paramMock.businessErrorMock, [GeoAddressMock]);
|
||||
} else {
|
||||
return new Promise((resolve) => {
|
||||
resolve([GeoAddressMock]);
|
||||
});
|
||||
}
|
||||
},
|
||||
getAddressesFromLocationName: function (...args) {
|
||||
console.warn("geolocation.getAddressesFromLocationName interface mocked in the Previewer. How this interface works on the" +
|
||||
" Previewer may be different from that on a real device.");
|
||||
const len = args.length;
|
||||
if (typeof args[len - 1] === 'function') {
|
||||
args[len - 1].call(this, paramMock.businessErrorMock, [GeoAddressMock]);
|
||||
} else {
|
||||
return new Promise((resolve) => {
|
||||
resolve([GeoAddressMock]);
|
||||
});
|
||||
}
|
||||
},
|
||||
isGeoServiceAvailable: function (...args) {
|
||||
console.warn("geolocation.isGeoServiceAvailable interface mocked in the Previewer. How this interface works on the" +
|
||||
" Previewer may be different 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);
|
||||
});
|
||||
}
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,3 +1,18 @@
|
||||
/*
|
||||
* Copyright (c) 2021 Huawei Device Co., Ltd.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
export function mockInputMonitor() {
|
||||
const touches = [{
|
||||
force: 1.67,
|
||||
@@ -17,7 +32,7 @@ export function mockInputMonitor() {
|
||||
}];
|
||||
global.systemplugin.multimodalInput = {};
|
||||
global.systemplugin.multimodalInput.inputMonitor = {
|
||||
on: function(...args) {
|
||||
on: function (...args) {
|
||||
console.warn('multimodalInput.inputMonitor.on interface mocked in the Previewer. How this interface works on the' +
|
||||
' Previewer may be different from that on a real device.');
|
||||
clearInterval(this.offInputMonitor);
|
||||
@@ -37,7 +52,7 @@ export function mockInputMonitor() {
|
||||
}, 1000);
|
||||
},
|
||||
|
||||
off: function(...args) {
|
||||
off: function (...args) {
|
||||
console.warn('multimodalInput.inputMonitor.off interface mocked in the Previewer. How this interface works on the' +
|
||||
' Previewer may be different from that on a real device.');
|
||||
clearInterval(this.offInputMonitor);
|
||||
|
||||
@@ -1,3 +1,18 @@
|
||||
/*
|
||||
* 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 mockOhosNfc() {
|
||||
@@ -38,14 +53,14 @@ export function mockOhosNfc() {
|
||||
sendData: function (...args) {
|
||||
console.warn("NfcATag.sendData interface mocked in the Previewer." +
|
||||
"How this interface works on the Previewer may be different from that on a real device.")
|
||||
const len = args.length
|
||||
if (typeof args[len - 1] === 'function') {
|
||||
args[len - 1].call(this, paramMock.businessErrorMock, [paramMock.paramNumberMock]);
|
||||
} else {
|
||||
return new Promise((resolve, reject) => {
|
||||
resolve([paramMock.paramNumberMock]);
|
||||
})
|
||||
}
|
||||
const len = args.length
|
||||
if (typeof args[len - 1] === 'function') {
|
||||
args[len - 1].call(this, paramMock.businessErrorMock, [paramMock.paramNumberMock]);
|
||||
} else {
|
||||
return new Promise((resolve, reject) => {
|
||||
resolve([paramMock.paramNumberMock]);
|
||||
})
|
||||
}
|
||||
},
|
||||
getMaxSendLength: function (...args) {
|
||||
console.warn("NfcATag.getMaxSendLength interface mocked in the Previewer." +
|
||||
@@ -96,14 +111,14 @@ export function mockOhosNfc() {
|
||||
sendData: function (...args) {
|
||||
console.warn("NfcBTag.sendData interface mocked in the Previewer." +
|
||||
"How this interface works on the Previewer may be different from that on a real device.")
|
||||
const len = args.length
|
||||
if (typeof args[len - 1] === 'function') {
|
||||
args[len - 1].call(this, paramMock.businessErrorMock, [paramMock.paramNumberMock]);
|
||||
} else {
|
||||
return new Promise((resolve, reject) => {
|
||||
resolve([paramMock.paramNumberMock]);
|
||||
})
|
||||
}
|
||||
const len = args.length
|
||||
if (typeof args[len - 1] === 'function') {
|
||||
args[len - 1].call(this, paramMock.businessErrorMock, [paramMock.paramNumberMock]);
|
||||
} else {
|
||||
return new Promise((resolve, reject) => {
|
||||
resolve([paramMock.paramNumberMock]);
|
||||
})
|
||||
}
|
||||
},
|
||||
getMaxSendLength: function (...args) {
|
||||
console.warn("NfcBTag.getMaxSendLength interface mocked in the Previewer." +
|
||||
@@ -154,14 +169,14 @@ export function mockOhosNfc() {
|
||||
sendData: function (...args) {
|
||||
console.warn("NfcFTag.sendData interface mocked in the Previewer." +
|
||||
"How this interface works on the Previewer may be different from that on a real device.")
|
||||
const len = args.length
|
||||
if (typeof args[len - 1] === 'function') {
|
||||
args[len - 1].call(this, paramMock.businessErrorMock, [paramMock.paramNumberMock]);
|
||||
} else {
|
||||
return new Promise((resolve, reject) => {
|
||||
resolve([paramMock.paramNumberMock]);
|
||||
})
|
||||
}
|
||||
const len = args.length
|
||||
if (typeof args[len - 1] === 'function') {
|
||||
args[len - 1].call(this, paramMock.businessErrorMock, [paramMock.paramNumberMock]);
|
||||
} else {
|
||||
return new Promise((resolve, reject) => {
|
||||
resolve([paramMock.paramNumberMock]);
|
||||
})
|
||||
}
|
||||
},
|
||||
getMaxSendLength: function (...args) {
|
||||
console.warn("NfcFTag.getMaxSendLength interface mocked in the Previewer." +
|
||||
@@ -212,14 +227,14 @@ export function mockOhosNfc() {
|
||||
sendData: function (...args) {
|
||||
console.warn("NfcVTag.sendData interface mocked in the Previewer." +
|
||||
"How this interface works on the Previewer may be different from that on a real device.")
|
||||
const len = args.length
|
||||
if (typeof args[len - 1] === 'function') {
|
||||
args[len - 1].call(this, paramMock.businessErrorMock, [paramMock.paramNumberMock]);
|
||||
} else {
|
||||
return new Promise((resolve, reject) => {
|
||||
resolve([paramMock.paramNumberMock]);
|
||||
})
|
||||
}
|
||||
const len = args.length
|
||||
if (typeof args[len - 1] === 'function') {
|
||||
args[len - 1].call(this, paramMock.businessErrorMock, [paramMock.paramNumberMock]);
|
||||
} else {
|
||||
return new Promise((resolve, reject) => {
|
||||
resolve([paramMock.paramNumberMock]);
|
||||
})
|
||||
}
|
||||
},
|
||||
getMaxSendLength: function (...args) {
|
||||
console.warn("NfcVTag.getMaxSendLength interface mocked in the Previewer." +
|
||||
@@ -248,7 +263,7 @@ export function mockOhosNfc() {
|
||||
isNfcAvailable: function (...args) {
|
||||
console.warn("nfc.controller.isNfcAvailable interface mocked in the Previewer." +
|
||||
"How this interface works on the Previewer may be different from that on a real device.")
|
||||
return paramMock.paramBooleanMock;
|
||||
return paramMock.paramBooleanMock;
|
||||
},
|
||||
isNfcOpen: function (...args) {
|
||||
console.warn("nfc.controller.isNfcOpen interface mocked in the Previewer." +
|
||||
@@ -258,12 +273,10 @@ export function mockOhosNfc() {
|
||||
on: function (...args) {
|
||||
console.warn("nfc.controller.on interface mocked in the Previewer." +
|
||||
"How this interface works on the Previewer may be different from that on a real device.")
|
||||
return;
|
||||
},
|
||||
off: function (...args) {
|
||||
console.warn("nfc.controller.off interface mocked in the Previewer." +
|
||||
"How this interface works on the Previewer may be different from that on a real device.")
|
||||
return;
|
||||
},
|
||||
getNfcState: function (...args) {
|
||||
console.warn("nfc.controller.getNfcState interface mocked in the Previewer." +
|
||||
|
||||
@@ -1,317 +1,332 @@
|
||||
import {paramMock} from "../utils"
|
||||
/*
|
||||
* Copyright (c) 2021 Huawei Device Co., Ltd.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import { paramMock } from "../utils"
|
||||
|
||||
export function mockOsAccount() {
|
||||
const osAccountInfoMock = {
|
||||
localId: "[PC Preview] unknown id",
|
||||
localName: "[PC Preview] unknown name",
|
||||
type: "[PC Preview] unknown type",
|
||||
constraints: "[PC Preview] unknown constraints",
|
||||
distributedInfo: "[PC Preview] unknown distributedInfo"
|
||||
};
|
||||
const osAccountTypeMock = "[PC Preview] unknown type";
|
||||
const accountManagerMock = {
|
||||
activateOsAccount: function (...args) {
|
||||
console.warn("AccountManager.activateOsAccount interface mocked in the Previewer. " +
|
||||
"How this interface works on the Previewer may be different from that on a real device.")
|
||||
const len = args.length
|
||||
if (len > 0 && typeof args[len - 1] === 'function') {
|
||||
args[len - 1].call(this, paramMock.businessErrorMock);
|
||||
} else {
|
||||
return new Promise((resolve, reject) => {
|
||||
resolve();
|
||||
})
|
||||
}
|
||||
},
|
||||
isMultiOsAccountEnable: function (...args) {
|
||||
console.warn("AccountManager.isMultiOsAccountEnable interface mocked in the Previewer. " +
|
||||
"How this interface works on the Previewer may be different from that on a real device.")
|
||||
const len = args.length
|
||||
if (len > 0 && typeof args[len - 1] === 'function') {
|
||||
args[len - 1].call(this, paramMock.businessErrorMock, paramMock.paramBooleanMock);
|
||||
} else {
|
||||
return new Promise((resolve, reject) => {
|
||||
resolve(paramMock.paramBooleanMock);
|
||||
})
|
||||
}
|
||||
},
|
||||
isOsAccountActived: function (...args) {
|
||||
console.warn("AccountManager.isOsAccountActived interface mocked in the Previewer. " +
|
||||
"How this interface works on the Previewer may be different from that on a real device.")
|
||||
const len = args.length
|
||||
if (len > 0 && typeof args[len - 1] === 'function') {
|
||||
args[len - 1].call(this, paramMock.businessErrorMock, paramMock.paramBooleanMock);
|
||||
} else {
|
||||
return new Promise((resolve, reject) => {
|
||||
resolve(paramMock.paramBooleanMock);
|
||||
})
|
||||
}
|
||||
},
|
||||
isOsAccountConstraintEnable: function (...args) {
|
||||
console.warn("AccountManager.isOsAccountConstraintEnable interface mocked in the Previewer. " +
|
||||
"How this interface works on the Previewer may be different from that on a real device.")
|
||||
const len = args.length
|
||||
if (len > 0 && typeof args[len - 1] === 'function') {
|
||||
args[len - 1].call(this, paramMock.businessErrorMock, paramMock.paramBooleanMock);
|
||||
} else {
|
||||
return new Promise((resolve, reject) => {
|
||||
resolve(paramMock.paramBooleanMock);
|
||||
})
|
||||
}
|
||||
},
|
||||
isTestOsAccount: function (...args) {
|
||||
console.warn("AccountManager.isTestOsAccount interface mocked in the Previewer. " +
|
||||
"How this interface works on the Previewer may be different from that on a real device.")
|
||||
const len = args.length
|
||||
if (len > 0 && typeof args[len - 1] === 'function') {
|
||||
args[len - 1].call(this, paramMock.businessErrorMock, paramMock.paramBooleanMock);
|
||||
} else {
|
||||
return new Promise((resolve, reject) => {
|
||||
resolve(paramMock.paramBooleanMock);
|
||||
})
|
||||
}
|
||||
},
|
||||
isOsAccountVerified: function (...args) {
|
||||
console.warn("AccountManager.isOsAccountVerified interface mocked in the Previewer. " +
|
||||
"How this interface works on the Previewer may be different from that on a real device.")
|
||||
const len = args.length
|
||||
if (len > 0 && typeof args[len - 1] === 'function') {
|
||||
args[len - 1].call(this, paramMock.businessErrorMock, paramMock.paramBooleanMock);
|
||||
} else {
|
||||
return new Promise((resolve, reject) => {
|
||||
resolve(paramMock.paramBooleanMock);
|
||||
})
|
||||
}
|
||||
},
|
||||
removeOsAccount: function (...args) {
|
||||
console.warn("AccountManager.removeOsAccount interface mocked in the Previewer. " +
|
||||
"How this interface works on the Previewer may be different from that on a real device.")
|
||||
const len = args.length
|
||||
if (len > 0 && typeof args[len - 1] === 'function') {
|
||||
args[len - 1].call(this, paramMock.businessErrorMock);
|
||||
} else {
|
||||
return new Promise((resolve, reject) => {
|
||||
resolve();
|
||||
})
|
||||
}
|
||||
},
|
||||
setOsAccountConstraints: function (...args) {
|
||||
console.warn("AccountManager.setOsAccountConstraints interface mocked in the Previewer. " +
|
||||
"How this interface works on the Previewer may be different from that on a real device.")
|
||||
const len = args.length
|
||||
if (len > 0 && typeof args[len - 1] === 'function') {
|
||||
args[len - 1].call(this, paramMock.businessErrorMock);
|
||||
} else {
|
||||
return new Promise((resolve, reject) => {
|
||||
resolve();
|
||||
})
|
||||
}
|
||||
},
|
||||
setOsAccountName: function (...args) {
|
||||
console.warn("AccountManager.setOsAccountName interface mocked in the Previewer. " +
|
||||
"How this interface works on the Previewer may be different from that on a real device.")
|
||||
const len = args.length
|
||||
if (len > 0 && typeof args[len - 1] === 'function') {
|
||||
args[len - 1].call(this, paramMock.businessErrorMock);
|
||||
} else {
|
||||
return new Promise((resolve, reject) => {
|
||||
resolve();
|
||||
})
|
||||
}
|
||||
},
|
||||
getCreatedOsAccountsCount: function (...args) {
|
||||
console.warn("AccountManager.getCreatedOsAccountsCount interface mocked in the Previewer. " +
|
||||
"How this interface works on the Previewer may be different from that on a real device.")
|
||||
const len = args.length
|
||||
if (len > 0 && typeof args[len - 1] === 'function') {
|
||||
args[len - 1].call(this, paramMock.businessErrorMock, paramMock.paramNumberMock);
|
||||
} else {
|
||||
return new Promise((resolve, reject) => {
|
||||
resolve(paramMock.paramNumberMock);
|
||||
})
|
||||
}
|
||||
},
|
||||
getOsAccountLocalIdFromProcess: function (...args) {
|
||||
console.warn("AccountManager.getOsAccountLocalIdFromProcess interface mocked in the Previewer. " +
|
||||
"How this interface works on the Previewer may be different from that on a real device.")
|
||||
const len = args.length
|
||||
if (len > 0 && typeof args[len - 1] === 'function') {
|
||||
args[len - 1].call(this, paramMock.businessErrorMock, paramMock.paramNumberMock);
|
||||
} else {
|
||||
return new Promise((resolve, reject) => {
|
||||
resolve(paramMock.paramNumberMock);
|
||||
})
|
||||
}
|
||||
},
|
||||
getOsAccountLocalIdFromUid: function (...args) {
|
||||
console.warn("AccountManager.getOsAccountLocalIdFromUid interface mocked in the Previewer. " +
|
||||
"How this interface works on the Previewer may be different from that on a real device.")
|
||||
const len = args.length
|
||||
if (len > 0 && typeof args[len - 1] === 'function') {
|
||||
args[len - 1].call(this, paramMock.businessErrorMock, paramMock.paramNumberMock);
|
||||
} else {
|
||||
return new Promise((resolve, reject) => {
|
||||
resolve(paramMock.paramNumberMock);
|
||||
})
|
||||
}
|
||||
},
|
||||
queryMaxOsAccountNumber: function (...args) {
|
||||
console.warn("AccountManager.queryMaxOsAccountNumber interface mocked in the Previewer. " +
|
||||
"How this interface works on the Previewer may be different from that on a real device.")
|
||||
const len = args.length
|
||||
if (len > 0 && typeof args[len - 1] === 'function') {
|
||||
args[len - 1].call(this, paramMock.businessErrorMock, paramMock.paramNumberMock);
|
||||
} else {
|
||||
return new Promise((resolve, reject) => {
|
||||
resolve(paramMock.paramNumberMock);
|
||||
})
|
||||
}
|
||||
},
|
||||
getOsAccountAllConstraints: function (...args) {
|
||||
console.warn("AccountManager.getOsAccountAllConstraints interface mocked in the Previewer. " +
|
||||
"How this interface works on the Previewer may be different from that on a real device.")
|
||||
const len = args.length
|
||||
if (len > 0 && typeof args[len - 1] === 'function') {
|
||||
args[len - 1].call(this, paramMock.businessErrorMock, paramMock.paramStringMock);
|
||||
} else {
|
||||
return new Promise((resolve, reject) => {
|
||||
resolve(paramMock.paramStringMock);
|
||||
})
|
||||
}
|
||||
},
|
||||
queryAllCreatedOsAccounts: function (...args) {
|
||||
console.warn("AccountManager.queryAllCreatedOsAccounts interface mocked in the Previewer. " +
|
||||
"How this interface works on the Previewer may be different from that on a real device.")
|
||||
var osAccountInfoArrayMock = new Array();
|
||||
osAccountInfoArrayMock.push(osAccountInfoMock);
|
||||
const len = args.length
|
||||
if (len > 0 && typeof args[len - 1] === 'function') {
|
||||
args[len - 1].call(this, paramMock.businessErrorMock, osAccountInfoArrayMock);
|
||||
} else {
|
||||
return new Promise((resolve, reject) => {
|
||||
resolve(osAccountInfoArrayMock);
|
||||
})
|
||||
}
|
||||
},
|
||||
createOsAccount: function (...args) {
|
||||
console.warn("AccountManager.createOsAccount interface mocked in the Previewer. " +
|
||||
"How this interface works on the Previewer may be different from that on a real device.")
|
||||
const len = args.length
|
||||
if (len > 0 && typeof args[len - 1] === 'function') {
|
||||
args[len - 1].call(this, paramMock.businessErrorMock, osAccountInfoMock);
|
||||
} else {
|
||||
return new Promise((resolve, reject) => {
|
||||
resolve(osAccountInfoMock);
|
||||
})
|
||||
}
|
||||
},
|
||||
queryCurrentOsAccount: function (...args) {
|
||||
console.warn("AccountManager.queryCurrentOsAccount interface mocked in the Previewer. " +
|
||||
"How this interface works on the Previewer may be different from that on a real device.")
|
||||
const len = args.length
|
||||
if (len > 0 && typeof args[len - 1] === 'function') {
|
||||
args[len - 1].call(this, paramMock.businessErrorMock, osAccountInfoMock);
|
||||
} else {
|
||||
return new Promise((resolve, reject) => {
|
||||
resolve(osAccountInfoMock);
|
||||
})
|
||||
}
|
||||
},
|
||||
queryOsAccountById: function (...args) {
|
||||
console.warn("AccountManager.queryOsAccountById interface mocked in the Previewer. " +
|
||||
"How this interface works on the Previewer may be different from that on a real device.")
|
||||
const len = args.length
|
||||
if (len > 0 && typeof args[len - 1] === 'function') {
|
||||
args[len - 1].call(this, paramMock.businessErrorMock, osAccountInfoMock);
|
||||
} else {
|
||||
return new Promise((resolve, reject) => {
|
||||
resolve(osAccountInfoMock);
|
||||
})
|
||||
}
|
||||
},
|
||||
getOsAccountTypeFromProcess: function (...args) {
|
||||
console.warn("AccountManager.getOsAccountTypeFromProcess interface mocked in the Previewer. " +
|
||||
"How this interface works on the Previewer may be different from that on a real device.")
|
||||
const len = args.length
|
||||
if (len > 0 && typeof args[len - 1] === 'function') {
|
||||
args[len - 1].call(this, paramMock.businessErrorMock, osAccountTypeMock);
|
||||
} else {
|
||||
return new Promise((resolve, reject) => {
|
||||
resolve(osAccountTypeMock);
|
||||
})
|
||||
}
|
||||
},
|
||||
getDistributedVirtualDeviceId: function (...args) {
|
||||
console.warn("AccountManager.getDistributedVirtualDeviceId interface mocked in the Previewer. " +
|
||||
"How this interface works on the Previewer may be different from that on a real device.")
|
||||
const len = args.length
|
||||
if (len > 0 && typeof args[len - 1] === 'function') {
|
||||
args[len - 1].call(this, paramMock.businessErrorMock, paramMock.paramStringMock);
|
||||
} else {
|
||||
return new Promise((resolve, reject) => {
|
||||
resolve(paramMock.paramStringMock);
|
||||
})
|
||||
}
|
||||
},
|
||||
getOsAccountProfilePhoto: function (...args) {
|
||||
console.warn("AccountManager.getOsAccountProfilePhoto interface mocked in the Previewer. " +
|
||||
"How this interface works on the Previewer may be different from that on a real device.")
|
||||
const len = args.length
|
||||
if (len > 0 && typeof args[len - 1] === 'function') {
|
||||
args[len - 1].call(this, paramMock.businessErrorMock, paramMock.paramStringMock);
|
||||
} else {
|
||||
return new Promise((resolve, reject) => {
|
||||
resolve(paramMock.paramStringMock);
|
||||
})
|
||||
}
|
||||
},
|
||||
setOsAccountProfilePhoto: function (...args) {
|
||||
console.warn("AccountManager.setOsAccountProfilePhoto interface mocked in the Previewer. " +
|
||||
"How this interface works on the Previewer may be different from that on a real device.")
|
||||
const len = args.length
|
||||
if (len > 0 && typeof args[len - 1] === 'function') {
|
||||
args[len - 1].call(this, paramMock.businessErrorMock);
|
||||
} else {
|
||||
return new Promise((resolve, reject) => {
|
||||
resolve();
|
||||
})
|
||||
}
|
||||
},
|
||||
on: function (...args) {
|
||||
console.warn("AccountManager.on interface mocked in the Previewer. " +
|
||||
"How this interface works on the Previewer may be different from that on a real device.")
|
||||
const len = args.length
|
||||
if (len > 0 && typeof args[len - 1] === 'function') {
|
||||
args[len - 1].call(this, paramMock.paramNumberMock);
|
||||
} else {
|
||||
return new Promise((resolve, reject) => {
|
||||
resolve(paramMock.paramNumberMock);
|
||||
})
|
||||
}
|
||||
},
|
||||
off: function (...args) {
|
||||
console.warn("AccountManager.off interface mocked in the Previewer. " +
|
||||
"How this interface works on the Previewer may be different from that on a real device.")
|
||||
const len = args.length
|
||||
if (len > 0 && typeof args[len - 1] === 'function') {
|
||||
args[len - 1].call(this, paramMock.paramNumberMock);
|
||||
} else {
|
||||
return new Promise((resolve, reject) => {
|
||||
resolve(paramMock.paramNumberMock);
|
||||
})
|
||||
}
|
||||
}
|
||||
};
|
||||
global.ohosplugin.account = global.ohosplugin.account || {};
|
||||
global.ohosplugin.account.osAccount = {
|
||||
getAccountManager : function (...args) {
|
||||
console.warn("osAccount.getAccountManager interface mocked in the Previewer. " +
|
||||
"How this interface works on the Previewer may be different from that on a real device.")
|
||||
return accountManagerMock;
|
||||
},
|
||||
OsAccountType : {
|
||||
ADMIN: "[PC Preview] unknown ADMIN",
|
||||
NORMAL: "[PC Preview] unknown NORMAL",
|
||||
GUEST: "[PC Preview] unknown GUEST"
|
||||
}
|
||||
};
|
||||
const osAccountInfoMock = {
|
||||
localId: "[PC Preview] unknown id",
|
||||
localName: "[PC Preview] unknown name",
|
||||
type: "[PC Preview] unknown type",
|
||||
constraints: "[PC Preview] unknown constraints",
|
||||
distributedInfo: "[PC Preview] unknown distributedInfo"
|
||||
};
|
||||
const osAccountTypeMock = "[PC Preview] unknown type";
|
||||
const accountManagerMock = {
|
||||
activateOsAccount: function (...args) {
|
||||
console.warn("AccountManager.activateOsAccount interface mocked in the Previewer. " +
|
||||
"How this interface works on the Previewer may be different from that on a real device.")
|
||||
const len = args.length
|
||||
if (len > 0 && typeof args[len - 1] === 'function') {
|
||||
args[len - 1].call(this, paramMock.businessErrorMock);
|
||||
} else {
|
||||
return new Promise((resolve, reject) => {
|
||||
resolve();
|
||||
})
|
||||
}
|
||||
},
|
||||
isMultiOsAccountEnable: function (...args) {
|
||||
console.warn("AccountManager.isMultiOsAccountEnable interface mocked in the Previewer. " +
|
||||
"How this interface works on the Previewer may be different from that on a real device.")
|
||||
const len = args.length
|
||||
if (len > 0 && typeof args[len - 1] === 'function') {
|
||||
args[len - 1].call(this, paramMock.businessErrorMock, paramMock.paramBooleanMock);
|
||||
} else {
|
||||
return new Promise((resolve, reject) => {
|
||||
resolve(paramMock.paramBooleanMock);
|
||||
})
|
||||
}
|
||||
},
|
||||
isOsAccountActived: function (...args) {
|
||||
console.warn("AccountManager.isOsAccountActived interface mocked in the Previewer. " +
|
||||
"How this interface works on the Previewer may be different from that on a real device.")
|
||||
const len = args.length
|
||||
if (len > 0 && typeof args[len - 1] === 'function') {
|
||||
args[len - 1].call(this, paramMock.businessErrorMock, paramMock.paramBooleanMock);
|
||||
} else {
|
||||
return new Promise((resolve, reject) => {
|
||||
resolve(paramMock.paramBooleanMock);
|
||||
})
|
||||
}
|
||||
},
|
||||
isOsAccountConstraintEnable: function (...args) {
|
||||
console.warn("AccountManager.isOsAccountConstraintEnable interface mocked in the Previewer. " +
|
||||
"How this interface works on the Previewer may be different from that on a real device.")
|
||||
const len = args.length
|
||||
if (len > 0 && typeof args[len - 1] === 'function') {
|
||||
args[len - 1].call(this, paramMock.businessErrorMock, paramMock.paramBooleanMock);
|
||||
} else {
|
||||
return new Promise((resolve, reject) => {
|
||||
resolve(paramMock.paramBooleanMock);
|
||||
})
|
||||
}
|
||||
},
|
||||
isTestOsAccount: function (...args) {
|
||||
console.warn("AccountManager.isTestOsAccount interface mocked in the Previewer. " +
|
||||
"How this interface works on the Previewer may be different from that on a real device.")
|
||||
const len = args.length
|
||||
if (len > 0 && typeof args[len - 1] === 'function') {
|
||||
args[len - 1].call(this, paramMock.businessErrorMock, paramMock.paramBooleanMock);
|
||||
} else {
|
||||
return new Promise((resolve, reject) => {
|
||||
resolve(paramMock.paramBooleanMock);
|
||||
})
|
||||
}
|
||||
},
|
||||
isOsAccountVerified: function (...args) {
|
||||
console.warn("AccountManager.isOsAccountVerified interface mocked in the Previewer. " +
|
||||
"How this interface works on the Previewer may be different from that on a real device.")
|
||||
const len = args.length
|
||||
if (len > 0 && typeof args[len - 1] === 'function') {
|
||||
args[len - 1].call(this, paramMock.businessErrorMock, paramMock.paramBooleanMock);
|
||||
} else {
|
||||
return new Promise((resolve, reject) => {
|
||||
resolve(paramMock.paramBooleanMock);
|
||||
})
|
||||
}
|
||||
},
|
||||
removeOsAccount: function (...args) {
|
||||
console.warn("AccountManager.removeOsAccount interface mocked in the Previewer. " +
|
||||
"How this interface works on the Previewer may be different from that on a real device.")
|
||||
const len = args.length
|
||||
if (len > 0 && typeof args[len - 1] === 'function') {
|
||||
args[len - 1].call(this, paramMock.businessErrorMock);
|
||||
} else {
|
||||
return new Promise((resolve, reject) => {
|
||||
resolve();
|
||||
})
|
||||
}
|
||||
},
|
||||
setOsAccountConstraints: function (...args) {
|
||||
console.warn("AccountManager.setOsAccountConstraints interface mocked in the Previewer. " +
|
||||
"How this interface works on the Previewer may be different from that on a real device.")
|
||||
const len = args.length
|
||||
if (len > 0 && typeof args[len - 1] === 'function') {
|
||||
args[len - 1].call(this, paramMock.businessErrorMock);
|
||||
} else {
|
||||
return new Promise((resolve, reject) => {
|
||||
resolve();
|
||||
})
|
||||
}
|
||||
},
|
||||
setOsAccountName: function (...args) {
|
||||
console.warn("AccountManager.setOsAccountName interface mocked in the Previewer. " +
|
||||
"How this interface works on the Previewer may be different from that on a real device.")
|
||||
const len = args.length
|
||||
if (len > 0 && typeof args[len - 1] === 'function') {
|
||||
args[len - 1].call(this, paramMock.businessErrorMock);
|
||||
} else {
|
||||
return new Promise((resolve, reject) => {
|
||||
resolve();
|
||||
})
|
||||
}
|
||||
},
|
||||
getCreatedOsAccountsCount: function (...args) {
|
||||
console.warn("AccountManager.getCreatedOsAccountsCount interface mocked in the Previewer. " +
|
||||
"How this interface works on the Previewer may be different from that on a real device.")
|
||||
const len = args.length
|
||||
if (len > 0 && typeof args[len - 1] === 'function') {
|
||||
args[len - 1].call(this, paramMock.businessErrorMock, paramMock.paramNumberMock);
|
||||
} else {
|
||||
return new Promise((resolve, reject) => {
|
||||
resolve(paramMock.paramNumberMock);
|
||||
})
|
||||
}
|
||||
},
|
||||
getOsAccountLocalIdFromProcess: function (...args) {
|
||||
console.warn("AccountManager.getOsAccountLocalIdFromProcess interface mocked in the Previewer. " +
|
||||
"How this interface works on the Previewer may be different from that on a real device.")
|
||||
const len = args.length
|
||||
if (len > 0 && typeof args[len - 1] === 'function') {
|
||||
args[len - 1].call(this, paramMock.businessErrorMock, paramMock.paramNumberMock);
|
||||
} else {
|
||||
return new Promise((resolve, reject) => {
|
||||
resolve(paramMock.paramNumberMock);
|
||||
})
|
||||
}
|
||||
},
|
||||
getOsAccountLocalIdFromUid: function (...args) {
|
||||
console.warn("AccountManager.getOsAccountLocalIdFromUid interface mocked in the Previewer. " +
|
||||
"How this interface works on the Previewer may be different from that on a real device.")
|
||||
const len = args.length
|
||||
if (len > 0 && typeof args[len - 1] === 'function') {
|
||||
args[len - 1].call(this, paramMock.businessErrorMock, paramMock.paramNumberMock);
|
||||
} else {
|
||||
return new Promise((resolve, reject) => {
|
||||
resolve(paramMock.paramNumberMock);
|
||||
})
|
||||
}
|
||||
},
|
||||
queryMaxOsAccountNumber: function (...args) {
|
||||
console.warn("AccountManager.queryMaxOsAccountNumber interface mocked in the Previewer. " +
|
||||
"How this interface works on the Previewer may be different from that on a real device.")
|
||||
const len = args.length
|
||||
if (len > 0 && typeof args[len - 1] === 'function') {
|
||||
args[len - 1].call(this, paramMock.businessErrorMock, paramMock.paramNumberMock);
|
||||
} else {
|
||||
return new Promise((resolve, reject) => {
|
||||
resolve(paramMock.paramNumberMock);
|
||||
})
|
||||
}
|
||||
},
|
||||
getOsAccountAllConstraints: function (...args) {
|
||||
console.warn("AccountManager.getOsAccountAllConstraints interface mocked in the Previewer. " +
|
||||
"How this interface works on the Previewer may be different from that on a real device.")
|
||||
const len = args.length
|
||||
if (len > 0 && typeof args[len - 1] === 'function') {
|
||||
args[len - 1].call(this, paramMock.businessErrorMock, paramMock.paramStringMock);
|
||||
} else {
|
||||
return new Promise((resolve, reject) => {
|
||||
resolve(paramMock.paramStringMock);
|
||||
})
|
||||
}
|
||||
},
|
||||
queryAllCreatedOsAccounts: function (...args) {
|
||||
console.warn("AccountManager.queryAllCreatedOsAccounts interface mocked in the Previewer. " +
|
||||
"How this interface works on the Previewer may be different from that on a real device.")
|
||||
var osAccountInfoArrayMock = new Array();
|
||||
osAccountInfoArrayMock.push(osAccountInfoMock);
|
||||
const len = args.length
|
||||
if (len > 0 && typeof args[len - 1] === 'function') {
|
||||
args[len - 1].call(this, paramMock.businessErrorMock, osAccountInfoArrayMock);
|
||||
} else {
|
||||
return new Promise((resolve, reject) => {
|
||||
resolve(osAccountInfoArrayMock);
|
||||
})
|
||||
}
|
||||
},
|
||||
createOsAccount: function (...args) {
|
||||
console.warn("AccountManager.createOsAccount interface mocked in the Previewer. " +
|
||||
"How this interface works on the Previewer may be different from that on a real device.")
|
||||
const len = args.length
|
||||
if (len > 0 && typeof args[len - 1] === 'function') {
|
||||
args[len - 1].call(this, paramMock.businessErrorMock, osAccountInfoMock);
|
||||
} else {
|
||||
return new Promise((resolve, reject) => {
|
||||
resolve(osAccountInfoMock);
|
||||
})
|
||||
}
|
||||
},
|
||||
queryCurrentOsAccount: function (...args) {
|
||||
console.warn("AccountManager.queryCurrentOsAccount interface mocked in the Previewer. " +
|
||||
"How this interface works on the Previewer may be different from that on a real device.")
|
||||
const len = args.length
|
||||
if (len > 0 && typeof args[len - 1] === 'function') {
|
||||
args[len - 1].call(this, paramMock.businessErrorMock, osAccountInfoMock);
|
||||
} else {
|
||||
return new Promise((resolve, reject) => {
|
||||
resolve(osAccountInfoMock);
|
||||
})
|
||||
}
|
||||
},
|
||||
queryOsAccountById: function (...args) {
|
||||
console.warn("AccountManager.queryOsAccountById interface mocked in the Previewer. " +
|
||||
"How this interface works on the Previewer may be different from that on a real device.")
|
||||
const len = args.length
|
||||
if (len > 0 && typeof args[len - 1] === 'function') {
|
||||
args[len - 1].call(this, paramMock.businessErrorMock, osAccountInfoMock);
|
||||
} else {
|
||||
return new Promise((resolve, reject) => {
|
||||
resolve(osAccountInfoMock);
|
||||
})
|
||||
}
|
||||
},
|
||||
getOsAccountTypeFromProcess: function (...args) {
|
||||
console.warn("AccountManager.getOsAccountTypeFromProcess interface mocked in the Previewer. " +
|
||||
"How this interface works on the Previewer may be different from that on a real device.")
|
||||
const len = args.length
|
||||
if (len > 0 && typeof args[len - 1] === 'function') {
|
||||
args[len - 1].call(this, paramMock.businessErrorMock, osAccountTypeMock);
|
||||
} else {
|
||||
return new Promise((resolve, reject) => {
|
||||
resolve(osAccountTypeMock);
|
||||
})
|
||||
}
|
||||
},
|
||||
getDistributedVirtualDeviceId: function (...args) {
|
||||
console.warn("AccountManager.getDistributedVirtualDeviceId interface mocked in the Previewer. " +
|
||||
"How this interface works on the Previewer may be different from that on a real device.")
|
||||
const len = args.length
|
||||
if (len > 0 && typeof args[len - 1] === 'function') {
|
||||
args[len - 1].call(this, paramMock.businessErrorMock, paramMock.paramStringMock);
|
||||
} else {
|
||||
return new Promise((resolve, reject) => {
|
||||
resolve(paramMock.paramStringMock);
|
||||
})
|
||||
}
|
||||
},
|
||||
getOsAccountProfilePhoto: function (...args) {
|
||||
console.warn("AccountManager.getOsAccountProfilePhoto interface mocked in the Previewer. " +
|
||||
"How this interface works on the Previewer may be different from that on a real device.")
|
||||
const len = args.length
|
||||
if (len > 0 && typeof args[len - 1] === 'function') {
|
||||
args[len - 1].call(this, paramMock.businessErrorMock, paramMock.paramStringMock);
|
||||
} else {
|
||||
return new Promise((resolve, reject) => {
|
||||
resolve(paramMock.paramStringMock);
|
||||
})
|
||||
}
|
||||
},
|
||||
setOsAccountProfilePhoto: function (...args) {
|
||||
console.warn("AccountManager.setOsAccountProfilePhoto interface mocked in the Previewer. " +
|
||||
"How this interface works on the Previewer may be different from that on a real device.")
|
||||
const len = args.length
|
||||
if (len > 0 && typeof args[len - 1] === 'function') {
|
||||
args[len - 1].call(this, paramMock.businessErrorMock);
|
||||
} else {
|
||||
return new Promise((resolve, reject) => {
|
||||
resolve();
|
||||
})
|
||||
}
|
||||
},
|
||||
on: function (...args) {
|
||||
console.warn("AccountManager.on interface mocked in the Previewer. " +
|
||||
"How this interface works on the Previewer may be different from that on a real device.")
|
||||
const len = args.length
|
||||
if (len > 0 && typeof args[len - 1] === 'function') {
|
||||
args[len - 1].call(this, paramMock.paramNumberMock);
|
||||
} else {
|
||||
return new Promise((resolve, reject) => {
|
||||
resolve(paramMock.paramNumberMock);
|
||||
})
|
||||
}
|
||||
},
|
||||
off: function (...args) {
|
||||
console.warn("AccountManager.off interface mocked in the Previewer. " +
|
||||
"How this interface works on the Previewer may be different from that on a real device.")
|
||||
const len = args.length
|
||||
if (len > 0 && typeof args[len - 1] === 'function') {
|
||||
args[len - 1].call(this, paramMock.paramNumberMock);
|
||||
} else {
|
||||
return new Promise((resolve, reject) => {
|
||||
resolve(paramMock.paramNumberMock);
|
||||
})
|
||||
}
|
||||
}
|
||||
};
|
||||
global.ohosplugin.account = global.ohosplugin.account || {};
|
||||
global.ohosplugin.account.osAccount = {
|
||||
getAccountManager: function (...args) {
|
||||
console.warn("osAccount.getAccountManager interface mocked in the Previewer. " +
|
||||
"How this interface works on the Previewer may be different from that on a real device.")
|
||||
return accountManagerMock;
|
||||
},
|
||||
OsAccountType: {
|
||||
ADMIN: "[PC Preview] unknown ADMIN",
|
||||
NORMAL: "[PC Preview] unknown NORMAL",
|
||||
GUEST: "[PC Preview] unknown GUEST"
|
||||
}
|
||||
};
|
||||
}
|
||||
@@ -1,37 +1,104 @@
|
||||
import {paramMock} from "../utils"
|
||||
/*
|
||||
* 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 mockPackageManager() {
|
||||
const PackageFlagMock = {
|
||||
DEFAULT: 0x00000000,
|
||||
GET_ACTIVITIES: 0x00000001,
|
||||
GET_META_DATA: 0x00000080,
|
||||
MATCH_UNINSTALLED_PACKAGES: 0x00002000,
|
||||
MATCH_ALL: 0x00020000
|
||||
}
|
||||
const PackageErrorMock = {
|
||||
NAME_NOT_FOUND_EXCEPTION: 0
|
||||
}
|
||||
const ApplicationInfosMock = [
|
||||
{
|
||||
packageName: "[PC preview] unknown package name",
|
||||
className: "[PC preview] unknown class name",
|
||||
const PackageFlagMock = {
|
||||
DEFAULT: 0x00000000,
|
||||
GET_ACTIVITIES: 0x00000001,
|
||||
GET_META_DATA: 0x00000080,
|
||||
MATCH_UNINSTALLED_PACKAGES: 0x00002000,
|
||||
MATCH_ALL: 0x00020000
|
||||
}
|
||||
const PackageErrorMock = {
|
||||
NAME_NOT_FOUND_EXCEPTION: 0
|
||||
}
|
||||
const ApplicationInfosMock = [
|
||||
{
|
||||
packageName: "[PC preview] unknown package name",
|
||||
className: "[PC preview] unknown class name",
|
||||
name: "[PC preview] unknown name",
|
||||
labelId: "[PC preview] unknown label id",
|
||||
iconId: "[PC preview] unknown icon id",
|
||||
sourceDir: "[PC preview] unknown source dir",
|
||||
flags: "[PC preview] unknown flags",
|
||||
customizeData: {
|
||||
key: "[PC preview] unknown key",
|
||||
value: {
|
||||
CustomizeData: {
|
||||
name: "[PC preview] unknown name",
|
||||
labelId: "[PC preview] unknown label id",
|
||||
iconId: "[PC preview] unknown icon id",
|
||||
sourceDir: "[PC preview] unknown source dir",
|
||||
flags: "[PC preview] unknown flags",
|
||||
customizeData: {
|
||||
key: "[PC preview] unknown key",
|
||||
value: {
|
||||
CustomizeData: {
|
||||
name: "[PC preview] unknown name",
|
||||
value: "[PC preview] unknown value",
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
]
|
||||
const ApplicationInfoMock = {
|
||||
value: "[PC preview] unknown value",
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
]
|
||||
const ApplicationInfoMock = {
|
||||
packageName: "[PC preview] unknown package name",
|
||||
className: "[PC preview] unknown class name",
|
||||
name: "[PC preview] unknown name",
|
||||
labelId: "[PC preview] unknown label id",
|
||||
iconId: "[PC preview] unknown icon id",
|
||||
sourceDir: "[PC preview] unknown source dir",
|
||||
flags: "[PC preview] unknown flags",
|
||||
customizeData: {
|
||||
key: "[PC preview] unknown key",
|
||||
value: {
|
||||
CustomizeData: {
|
||||
name: "[PC preview] unknown name",
|
||||
value: "[PC preview] unknown value",
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
const ApplicationFlagMock = {
|
||||
FLAG_SYSTEM: 0x0000000001,
|
||||
FLAG_IS_DATA_ONLY: 0x1000000000,
|
||||
}
|
||||
const PackageInfoMock = {
|
||||
packageName: "[PC preview] unknown package name",
|
||||
name: "[PC preview] unknown name ",
|
||||
lastUpdateTime: "[PC preview] unknown last update time",
|
||||
versionCode: "[PC preview] unknown version code",
|
||||
appInfo: {
|
||||
packageName: "[PC preview] unknown package name",
|
||||
className: "[PC preview] unknown class name",
|
||||
name: "[PC preview] unknown name",
|
||||
labelId: "[PC preview] unknown label id",
|
||||
iconId: "[PC preview] unknown icon id",
|
||||
sourceDir: "[PC preview] unknown source dir",
|
||||
flags: "[PC preview] unknown flags",
|
||||
customizeData: {
|
||||
key: "[PC preview] unknown key",
|
||||
value: {
|
||||
CustomizeData: {
|
||||
name: "[PC preview] unknown name",
|
||||
value: "[PC preview] unknown value",
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
const PackageInfosMock = [
|
||||
{
|
||||
packageName: "[PC preview] unknown package name",
|
||||
name: "[PC preview] unknown name ",
|
||||
lastUpdateTime: "[PC preview] unknown last update time",
|
||||
versionCode: "[PC preview] unknown version code",
|
||||
appInfo: {
|
||||
packageName: "[PC preview] unknown package name",
|
||||
className: "[PC preview] unknown class name",
|
||||
name: "[PC preview] unknown name",
|
||||
@@ -40,186 +107,134 @@ export function mockPackageManager() {
|
||||
sourceDir: "[PC preview] unknown source dir",
|
||||
flags: "[PC preview] unknown flags",
|
||||
customizeData: {
|
||||
key: "[PC preview] unknown key",
|
||||
value: {
|
||||
CustomizeData: {
|
||||
name: "[PC preview] unknown name",
|
||||
value: "[PC preview] unknown value",
|
||||
}
|
||||
key: "[PC preview] unknown key",
|
||||
value: {
|
||||
CustomizeData: {
|
||||
name: "[PC preview] unknown name",
|
||||
value: "[PC preview] unknown value",
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
const ApplicationFlagMock = {
|
||||
FLAG_SYSTEM: 0x0000000001,
|
||||
FLAG_IS_DATA_ONLY: 0x1000000000,
|
||||
}
|
||||
const PackageInfoMock = {
|
||||
packageName: "[PC preview] unknown package name",
|
||||
name: "[PC preview] unknown name ",
|
||||
lastUpdateTime: "[PC preview] unknown last update time",
|
||||
versionCode: "[PC preview] unknown version code",
|
||||
appInfo: {
|
||||
packageName: "[PC preview] unknown package name",
|
||||
className: "[PC preview] unknown class name",
|
||||
name: "[PC preview] unknown name",
|
||||
labelId: "[PC preview] unknown label id",
|
||||
iconId: "[PC preview] unknown icon id",
|
||||
sourceDir: "[PC preview] unknown source dir",
|
||||
flags: "[PC preview] unknown flags",
|
||||
customizeData: {
|
||||
key: "[PC preview] unknown key",
|
||||
value: {
|
||||
CustomizeData: {
|
||||
name: "[PC preview] unknown name",
|
||||
value: "[PC preview] unknown value",
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
const PackageInfosMock = [
|
||||
{
|
||||
packageName: "[PC preview] unknown package name",
|
||||
name: "[PC preview] unknown name ",
|
||||
lastUpdateTime: "[PC preview] unknown last update time",
|
||||
versionCode: "[PC preview] unknown version code",
|
||||
appInfo: {
|
||||
packageName: "[PC preview] unknown package name",
|
||||
className: "[PC preview] unknown class name",
|
||||
name: "[PC preview] unknown name",
|
||||
labelId: "[PC preview] unknown label id",
|
||||
iconId: "[PC preview] unknown icon id",
|
||||
sourceDir: "[PC preview] unknown source dir",
|
||||
flags: "[PC preview] unknown flags",
|
||||
customizeData: {
|
||||
key: "[PC preview] unknown key",
|
||||
value: {
|
||||
CustomizeData: {
|
||||
name: "[PC preview] unknown name",
|
||||
value: "[PC preview] unknown value",
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
]
|
||||
}
|
||||
},
|
||||
]
|
||||
|
||||
const CustomizeDataMock = {
|
||||
name: "[PC preview] unknown name",
|
||||
value: "[PC preview] unknown value",
|
||||
}
|
||||
const BundleErrorMock = {
|
||||
REMOTE_EXCEPTION: 0,
|
||||
SECURITY_EXCEPTION: 1
|
||||
}
|
||||
const ActivityInfoMock = {
|
||||
packageName: "[PC preview] unknown package name",
|
||||
name: "[PC preview] unknown name",
|
||||
iconId: "[PC preview] unknown icon id",
|
||||
labelId: "[PC preview] unknown label id",
|
||||
customizeData: {
|
||||
key: "[PC preview] unknown key",
|
||||
value: {
|
||||
CustomizeData: {
|
||||
name: "[PC preview] unknown name",
|
||||
value: "[PC preview] unknown value",
|
||||
}
|
||||
}
|
||||
const CustomizeDataMock = {
|
||||
name: "[PC preview] unknown name",
|
||||
value: "[PC preview] unknown value",
|
||||
}
|
||||
const BundleErrorMock = {
|
||||
REMOTE_EXCEPTION: 0,
|
||||
SECURITY_EXCEPTION: 1
|
||||
}
|
||||
const ActivityInfoMock = {
|
||||
packageName: "[PC preview] unknown package name",
|
||||
name: "[PC preview] unknown name",
|
||||
iconId: "[PC preview] unknown icon id",
|
||||
labelId: "[PC preview] unknown label id",
|
||||
customizeData: {
|
||||
key: "[PC preview] unknown key",
|
||||
value: {
|
||||
CustomizeData: {
|
||||
name: "[PC preview] unknown name",
|
||||
value: "[PC preview] unknown value",
|
||||
}
|
||||
}
|
||||
}
|
||||
const ActivityInfosMock = [
|
||||
{
|
||||
packageName: "[PC preview] unknown package name",
|
||||
}
|
||||
const ActivityInfosMock = [
|
||||
{
|
||||
packageName: "[PC preview] unknown package name",
|
||||
name: "[PC preview] unknown name",
|
||||
iconId: "[PC preview] unknown icon id",
|
||||
labelId: "[PC preview] unknown label id",
|
||||
customizeData: {
|
||||
key: "[PC preview] unknown key",
|
||||
value: {
|
||||
CustomizeData: {
|
||||
name: "[PC preview] unknown name",
|
||||
iconId: "[PC preview] unknown icon id",
|
||||
labelId: "[PC preview] unknown label id",
|
||||
customizeData: {
|
||||
key: "[PC preview] unknown key",
|
||||
value: {
|
||||
CustomizeData: {
|
||||
name: "[PC preview] unknown name",
|
||||
value: "[PC preview] unknown value",
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
]
|
||||
const ComponentNameMock = {
|
||||
package: "[PC preview] unknown package",
|
||||
name: "[PC preview] unknown name",
|
||||
}
|
||||
global.ohosplugin.package = {
|
||||
getApplicationInfo: function (...args) {
|
||||
console.warn("PackageManger.getApplicationInfo interface mocked in the Previewer. How this interface works on the" +
|
||||
" Previewer may be different from that on a real device.")
|
||||
const len = args.length
|
||||
if (typeof args[len - 1] === 'function') {
|
||||
args[len - 1].call(this, paramMock.businessErrorMock, ApplicationInfoMock)
|
||||
} else {
|
||||
return new Promise((resolve) => {
|
||||
resolve(ApplicationInfoMock)
|
||||
});
|
||||
}
|
||||
},
|
||||
getInstalledApplications: function (...args) {
|
||||
console.warn("PackageManger.getInstalledApplications interface mocked in the Previewer. How this interface works on the" +
|
||||
" Previewer may be different from that on a real device.")
|
||||
const len = args.length
|
||||
if (typeof args[len - 1] === 'function') {
|
||||
args[len - 1].call(this, paramMock.businessErrorMock, ApplicationInfosMock)
|
||||
} else {
|
||||
return new Promise((resolve) => {
|
||||
resolve(ApplicationInfosMock)
|
||||
});
|
||||
}
|
||||
},
|
||||
getPackageInfo: function (...args) {
|
||||
console.warn("PackageManger.getPackageInfo interface mocked in the Previewer. How this interface works on the" +
|
||||
" Previewer may be different from that on a real device.")
|
||||
const len = args.length
|
||||
if (typeof args[len - 1] === 'function') {
|
||||
args[len - 1].call(this, paramMock.businessErrorMock, PackageInfoMock)
|
||||
} else {
|
||||
return new Promise((resolve) => {
|
||||
resolve(PackageInfoMock)
|
||||
});
|
||||
}
|
||||
},
|
||||
getInstalledPackages: function (...args) {
|
||||
console.warn("PackageManger.getInstalledPackages interface mocked in the Previewer. How this interface works on the" +
|
||||
" Previewer may be different from that on a real device.")
|
||||
const len = args.length
|
||||
if (typeof args[len - 1] === 'function') {
|
||||
args[len - 1].call(this, paramMock.businessErrorMock, PackageInfosMock)
|
||||
} else {
|
||||
return new Promise((resolve) => {
|
||||
resolve(PackageInfosMock)
|
||||
});
|
||||
}
|
||||
},
|
||||
getActivityInfo: function (...args) {
|
||||
console.warn("PackageManger.getActivityInfo interface mocked in the Previewer. How this interface works on the" +
|
||||
" Previewer may be different from that on a real device.")
|
||||
const len = args.length
|
||||
if (typeof args[len - 1] === 'function') {
|
||||
args[len - 1].call(this, paramMock.businessErrorMock, ActivityInfoMock)
|
||||
} else {
|
||||
return new Promise((resolve) => {
|
||||
resolve(ActivityInfoMock)
|
||||
});
|
||||
}
|
||||
},
|
||||
getActivityList: function (...args) {
|
||||
console.warn("PackageManger.getActivityList interface mocked in the Previewer. How this interface works on the" +
|
||||
" Previewer may be different from that on a real device.")
|
||||
const len = args.length
|
||||
if (typeof args[len - 1] === 'function') {
|
||||
args[len - 1].call(this, paramMock.businessErrorMock, ActivityInfosMock)
|
||||
} else {
|
||||
return new Promise((resolve) => {
|
||||
resolve(ActivityInfosMock)
|
||||
});
|
||||
}
|
||||
},
|
||||
}
|
||||
value: "[PC preview] unknown value",
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
]
|
||||
const ComponentNameMock = {
|
||||
package: "[PC preview] unknown package",
|
||||
name: "[PC preview] unknown name",
|
||||
}
|
||||
global.ohosplugin.package = {
|
||||
getApplicationInfo: function (...args) {
|
||||
console.warn("PackageManger.getApplicationInfo interface mocked in the Previewer. How this interface works on the" +
|
||||
" Previewer may be different from that on a real device.")
|
||||
const len = args.length
|
||||
if (typeof args[len - 1] === 'function') {
|
||||
args[len - 1].call(this, paramMock.businessErrorMock, ApplicationInfoMock)
|
||||
} else {
|
||||
return new Promise((resolve) => {
|
||||
resolve(ApplicationInfoMock)
|
||||
});
|
||||
}
|
||||
},
|
||||
getInstalledApplications: function (...args) {
|
||||
console.warn("PackageManger.getInstalledApplications interface mocked in the Previewer. How this interface works on the" +
|
||||
" Previewer may be different from that on a real device.")
|
||||
const len = args.length
|
||||
if (typeof args[len - 1] === 'function') {
|
||||
args[len - 1].call(this, paramMock.businessErrorMock, ApplicationInfosMock)
|
||||
} else {
|
||||
return new Promise((resolve) => {
|
||||
resolve(ApplicationInfosMock)
|
||||
});
|
||||
}
|
||||
},
|
||||
getPackageInfo: function (...args) {
|
||||
console.warn("PackageManger.getPackageInfo interface mocked in the Previewer. How this interface works on the" +
|
||||
" Previewer may be different from that on a real device.")
|
||||
const len = args.length
|
||||
if (typeof args[len - 1] === 'function') {
|
||||
args[len - 1].call(this, paramMock.businessErrorMock, PackageInfoMock)
|
||||
} else {
|
||||
return new Promise((resolve) => {
|
||||
resolve(PackageInfoMock)
|
||||
});
|
||||
}
|
||||
},
|
||||
getInstalledPackages: function (...args) {
|
||||
console.warn("PackageManger.getInstalledPackages interface mocked in the Previewer. How this interface works on the" +
|
||||
" Previewer may be different from that on a real device.")
|
||||
const len = args.length
|
||||
if (typeof args[len - 1] === 'function') {
|
||||
args[len - 1].call(this, paramMock.businessErrorMock, PackageInfosMock)
|
||||
} else {
|
||||
return new Promise((resolve) => {
|
||||
resolve(PackageInfosMock)
|
||||
});
|
||||
}
|
||||
},
|
||||
getActivityInfo: function (...args) {
|
||||
console.warn("PackageManger.getActivityInfo interface mocked in the Previewer. How this interface works on the" +
|
||||
" Previewer may be different from that on a real device.")
|
||||
const len = args.length
|
||||
if (typeof args[len - 1] === 'function') {
|
||||
args[len - 1].call(this, paramMock.businessErrorMock, ActivityInfoMock)
|
||||
} else {
|
||||
return new Promise((resolve) => {
|
||||
resolve(ActivityInfoMock)
|
||||
});
|
||||
}
|
||||
},
|
||||
getActivityList: function (...args) {
|
||||
console.warn("PackageManger.getActivityList interface mocked in the Previewer. How this interface works on the" +
|
||||
" Previewer may be different from that on a real device.")
|
||||
const len = args.length
|
||||
if (typeof args[len - 1] === 'function') {
|
||||
args[len - 1].call(this, paramMock.businessErrorMock, ActivityInfosMock)
|
||||
} else {
|
||||
return new Promise((resolve) => {
|
||||
resolve(ActivityInfosMock)
|
||||
});
|
||||
}
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,247 +1,257 @@
|
||||
import {paramMock} from "../utils";
|
||||
/*
|
||||
* 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 mockPasteBoard() {
|
||||
const PasteDataMock = {
|
||||
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"
|
||||
},
|
||||
addHtmlRecord: function () {
|
||||
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.")
|
||||
return;
|
||||
},
|
||||
addWantRecord: function () {
|
||||
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.")
|
||||
return;
|
||||
},
|
||||
addRecord: function () {
|
||||
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.")
|
||||
return;
|
||||
},
|
||||
addTextRecord: function () {
|
||||
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.")
|
||||
return;
|
||||
},
|
||||
addUriRecord: function () {
|
||||
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.")
|
||||
return;
|
||||
},
|
||||
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.");
|
||||
let mimeTypes = new Array();
|
||||
mimeTypes.push('[PC preview] unknow MIMETYPE_TEXT_HTML');
|
||||
mimeTypes.push('[PC preview] unknow MIMETYPE_TEXT_PLAIN');
|
||||
return mimeTypes;
|
||||
},
|
||||
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 "[PC Preview] unknow getPrimaryHtml"
|
||||
},
|
||||
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 "[PC Preview] unknow getPrimaryMimeType"
|
||||
},
|
||||
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 "[PC Preview] unknow getPrimaryUri"
|
||||
},
|
||||
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 () {
|
||||
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 "[PC Preview] unknow getRecordCount"
|
||||
},
|
||||
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 "[PC Preview] unknow getTag"
|
||||
},
|
||||
hasMimeType: function () {
|
||||
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 "[PC Preview] unknow hasMimeType"
|
||||
},
|
||||
removeRecordAt: function () {
|
||||
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 "[PC Preview] unknow removeRecordAt"
|
||||
},
|
||||
replaceRecordAt: function () {
|
||||
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 "[PC Preview] unknow replaceRecordAt"
|
||||
const PasteDataMock = {
|
||||
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"
|
||||
},
|
||||
addHtmlRecord: function () {
|
||||
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 () {
|
||||
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 () {
|
||||
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 () {
|
||||
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 () {
|
||||
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.");
|
||||
let mimeTypes = new Array();
|
||||
mimeTypes.push('[PC preview] unknow MIMETYPE_TEXT_HTML');
|
||||
mimeTypes.push('[PC preview] unknow MIMETYPE_TEXT_PLAIN');
|
||||
return mimeTypes;
|
||||
},
|
||||
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 "[PC Preview] unknow getPrimaryHtml"
|
||||
},
|
||||
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 "[PC Preview] unknow getPrimaryMimeType"
|
||||
},
|
||||
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 "[PC Preview] unknow getPrimaryUri"
|
||||
},
|
||||
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 () {
|
||||
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 "[PC Preview] unknow getRecordCount"
|
||||
},
|
||||
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 "[PC Preview] unknow getTag"
|
||||
},
|
||||
hasMimeType: function () {
|
||||
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 "[PC Preview] unknow hasMimeType"
|
||||
},
|
||||
removeRecordAt: function () {
|
||||
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 "[PC Preview] unknow removeRecordAt"
|
||||
},
|
||||
replaceRecordAt: function () {
|
||||
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 "[PC Preview] unknow replaceRecordAt"
|
||||
}
|
||||
}
|
||||
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);
|
||||
}
|
||||
}
|
||||
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);
|
||||
})
|
||||
}
|
||||
}
|
||||
},
|
||||
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.")
|
||||
const len = args.length
|
||||
if (typeof args[len - 1] === 'function') {
|
||||
args[len - 1].call(this, paramMock.businessErrorMock, PasteDataMock)
|
||||
} else {
|
||||
return new Promise((resolve, reject) => {
|
||||
resolve(PasteDataMock);
|
||||
})
|
||||
}
|
||||
},
|
||||
setPasteData: function (...args) {
|
||||
console.warn("SystemPasteboard.setPasteData interface mocked in the Previewer. How this interface works on the" +
|
||||
" Previewer may be different from that on a 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 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.")
|
||||
const len = args.length
|
||||
if (typeof args[len - 1] === 'function') {
|
||||
args[len - 1].call(this, paramMock.businessErrorMock, PasteDataMock)
|
||||
} else {
|
||||
return new Promise((resolve, reject) => {
|
||||
resolve(PasteDataMock);
|
||||
})
|
||||
}
|
||||
},
|
||||
setPasteData: function (...args) {
|
||||
console.warn("SystemPasteboard.setPasteData interface mocked in the Previewer. How this interface works on the" +
|
||||
" Previewer may be different from that on a 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();
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
global.ohosplugin.pasteboard = {
|
||||
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 () {
|
||||
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 () {
|
||||
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 () {
|
||||
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 () {
|
||||
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 () {
|
||||
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 () {
|
||||
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 () {
|
||||
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 () {
|
||||
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.")
|
||||
return SystemPasteboardMock;
|
||||
}
|
||||
}
|
||||
global.ohosplugin.pasteboard = {
|
||||
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 () {
|
||||
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 () {
|
||||
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 () {
|
||||
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 () {
|
||||
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 () {
|
||||
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 () {
|
||||
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 () {
|
||||
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 () {
|
||||
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.")
|
||||
return SystemPasteboardMock;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,111 +1,126 @@
|
||||
/*
|
||||
* 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 mockReminderAgent() {
|
||||
const infoMock = {
|
||||
reminderId: 1,
|
||||
info: "[PC preview] unknown info"
|
||||
}
|
||||
const reminderReq = {
|
||||
reminderType: 1,
|
||||
actionButton: [
|
||||
{
|
||||
title: "[PC preview] unknown title",
|
||||
type: 0
|
||||
}
|
||||
],
|
||||
wantAgent: {
|
||||
pkgName: "[PC preview] unknown pkg nam",
|
||||
abilityName: "[PC preview] unknown ability name"
|
||||
},
|
||||
maxScreenWantAgent: {
|
||||
pkgName: "[PC preview] unknown pkg name",
|
||||
abilityName: "[PC preview] unknown ability name"
|
||||
},
|
||||
ringDuration: 1,
|
||||
snoozeTimes: 1,
|
||||
timeInterval: 1,
|
||||
const infoMock = {
|
||||
reminderId: 1,
|
||||
info: "[PC preview] unknown info"
|
||||
}
|
||||
const reminderReq = {
|
||||
reminderType: 1,
|
||||
actionButton: [
|
||||
{
|
||||
title: "[PC preview] unknown title",
|
||||
content: "[PC preview] unknown content",
|
||||
expiredContent: "[PC preview] unknown expiredContent",
|
||||
snoozeContent: "[PC preview] unknown snoozeContent",
|
||||
notificationId: 1,
|
||||
slotType: 3
|
||||
}
|
||||
const reminderReqs = [
|
||||
reminderReq
|
||||
]
|
||||
global.ohosplugin.reminderAgent = {
|
||||
publishReminder: function (...args) {
|
||||
console.warn("reminderAgent.publishReminder interface mocked in the Previewer." +
|
||||
"How this interface works on the Previewer may be different from that on a real device.")
|
||||
const len = args.length
|
||||
if (typeof args[len - 1] === 'function') {
|
||||
args[len - 1].call(this, paramMock.businessErrorMock, infoMock.reminderId)
|
||||
} else {
|
||||
return new Promise((resolve) => {
|
||||
resolve(infoMock.reminderId)
|
||||
});
|
||||
}
|
||||
},
|
||||
getValidReminders: function (...args) {
|
||||
console.warn("reminderAgent.getValidReminders interface mocked in the Previewer." +
|
||||
"How this interface works on the Previewer may be different from that on a real device.")
|
||||
const len = args.length
|
||||
if (typeof args[len - 1] === 'function') {
|
||||
args[len - 1].call(this, paramMock.businessErrorMock, reminderReqs)
|
||||
} else {
|
||||
return new Promise((resolve) => {
|
||||
resolve(reminderReqs)
|
||||
});
|
||||
}
|
||||
},
|
||||
cancelReminder: function (...args) {
|
||||
console.warn("reminderAgent.cancelReminder interface mocked in the Previewer." +
|
||||
"How this interface works on the Previewer may be different from that on a 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()
|
||||
});
|
||||
}
|
||||
},
|
||||
cancelAllReminders: function (...args) {
|
||||
console.warn("reminderAgent.cancelAllReminders interface mocked in the Previewer." +
|
||||
"How this interface works on the Previewer may be different from that on a 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()
|
||||
});
|
||||
}
|
||||
},
|
||||
addNotificationSlot: function (...args) {
|
||||
console.warn("reminderAgent.addNotificationSlot interface mocked in the Previewer." +
|
||||
"How this interface works on the Previewer may be different from that on a 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()
|
||||
});
|
||||
}
|
||||
},
|
||||
removeNotificationSlot: function (...args) {
|
||||
console.warn("reminderAgent.removeNotificationSlot interface mocked in the Previewer." +
|
||||
"How this interface works on the Previewer may be different from that on a 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()
|
||||
});
|
||||
}
|
||||
}
|
||||
type: 0
|
||||
}
|
||||
],
|
||||
wantAgent: {
|
||||
pkgName: "[PC preview] unknown pkg nam",
|
||||
abilityName: "[PC preview] unknown ability name"
|
||||
},
|
||||
maxScreenWantAgent: {
|
||||
pkgName: "[PC preview] unknown pkg name",
|
||||
abilityName: "[PC preview] unknown ability name"
|
||||
},
|
||||
ringDuration: 1,
|
||||
snoozeTimes: 1,
|
||||
timeInterval: 1,
|
||||
title: "[PC preview] unknown title",
|
||||
content: "[PC preview] unknown content",
|
||||
expiredContent: "[PC preview] unknown expiredContent",
|
||||
snoozeContent: "[PC preview] unknown snoozeContent",
|
||||
notificationId: 1,
|
||||
slotType: 3
|
||||
}
|
||||
const reminderReqs = [
|
||||
reminderReq
|
||||
]
|
||||
global.ohosplugin.reminderAgent = {
|
||||
publishReminder: function (...args) {
|
||||
console.warn("reminderAgent.publishReminder interface mocked in the Previewer." +
|
||||
"How this interface works on the Previewer may be different from that on a real device.")
|
||||
const len = args.length
|
||||
if (typeof args[len - 1] === 'function') {
|
||||
args[len - 1].call(this, paramMock.businessErrorMock, infoMock.reminderId)
|
||||
} else {
|
||||
return new Promise((resolve) => {
|
||||
resolve(infoMock.reminderId)
|
||||
});
|
||||
}
|
||||
},
|
||||
getValidReminders: function (...args) {
|
||||
console.warn("reminderAgent.getValidReminders interface mocked in the Previewer." +
|
||||
"How this interface works on the Previewer may be different from that on a real device.")
|
||||
const len = args.length
|
||||
if (typeof args[len - 1] === 'function') {
|
||||
args[len - 1].call(this, paramMock.businessErrorMock, reminderReqs)
|
||||
} else {
|
||||
return new Promise((resolve) => {
|
||||
resolve(reminderReqs)
|
||||
});
|
||||
}
|
||||
},
|
||||
cancelReminder: function (...args) {
|
||||
console.warn("reminderAgent.cancelReminder interface mocked in the Previewer." +
|
||||
"How this interface works on the Previewer may be different from that on a 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()
|
||||
});
|
||||
}
|
||||
},
|
||||
cancelAllReminders: function (...args) {
|
||||
console.warn("reminderAgent.cancelAllReminders interface mocked in the Previewer." +
|
||||
"How this interface works on the Previewer may be different from that on a 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()
|
||||
});
|
||||
}
|
||||
},
|
||||
addNotificationSlot: function (...args) {
|
||||
console.warn("reminderAgent.addNotificationSlot interface mocked in the Previewer." +
|
||||
"How this interface works on the Previewer may be different from that on a 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()
|
||||
});
|
||||
}
|
||||
},
|
||||
removeNotificationSlot: function (...args) {
|
||||
console.warn("reminderAgent.removeNotificationSlot interface mocked in the Previewer." +
|
||||
"How this interface works on the Previewer may be different from that on a 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()
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,4 +1,20 @@
|
||||
import {paramMock} from "../utils";
|
||||
/*
|
||||
* Copyright (c) 2021 Huawei Device Co., Ltd.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import { paramMock } from "../utils";
|
||||
|
||||
const NOTIFY = "[PC Preview] unknow"
|
||||
const Properties = [
|
||||
'NETWORK_MOBILE',
|
||||
@@ -45,7 +61,7 @@ export function mockOhosRequest() {
|
||||
SESSION_PENDING: 1,
|
||||
SESSION_RUNNING: 2,
|
||||
SESSION_PAUSED: 4,
|
||||
SESSION_SUCCESSFUL:8,
|
||||
SESSION_SUCCESSFUL: 8,
|
||||
SESSION_FAILED: 16,
|
||||
}
|
||||
const downloadInfo = {
|
||||
@@ -62,35 +78,35 @@ export function mockOhosRequest() {
|
||||
downloadedBytes: 1
|
||||
}
|
||||
const DownloadTaskMock = {
|
||||
on: function(...args) {
|
||||
on: function (...args) {
|
||||
console.warn("DownloadTask.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] == 'progress') {
|
||||
args[len - 1].call(this, paramMock.paramNumberMock, paramMock.paramNumberMock);
|
||||
} else if (args[0] == 'complete' || args[0] == 'pause' || args[0] == 'remove') {
|
||||
args[len - 1].call(this, paramMock.businessErrorMock);
|
||||
} else if (args[0] == 'fail') {
|
||||
args[len - 1].call(this, paramMock.businessErrorMock, ErrorMock);
|
||||
}
|
||||
if (args[0] == 'progress') {
|
||||
args[len - 1].call(this, paramMock.paramNumberMock, paramMock.paramNumberMock);
|
||||
} else if (args[0] == 'complete' || args[0] == 'pause' || args[0] == 'remove') {
|
||||
args[len - 1].call(this, paramMock.businessErrorMock);
|
||||
} else if (args[0] == 'fail') {
|
||||
args[len - 1].call(this, paramMock.businessErrorMock, ErrorMock);
|
||||
}
|
||||
}
|
||||
},
|
||||
off: function(...args) {
|
||||
off: function (...args) {
|
||||
console.warn("DownloadTask.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] == 'progress') {
|
||||
args[len - 1].call(this, paramMock.paramNumberMock, paramMock.paramNumberMock);
|
||||
} else if (args[0] == 'complete' || args[0] == 'pause' || args[0] == 'remove') {
|
||||
args[len - 1].call(this, paramMock.businessErrorMock);
|
||||
} else if (args[0] == 'fail') {
|
||||
args[len - 1].call(this, paramMock.businessErrorMock, ErrorMock);
|
||||
}
|
||||
if (args[0] == 'progress') {
|
||||
args[len - 1].call(this, paramMock.paramNumberMock, paramMock.paramNumberMock);
|
||||
} else if (args[0] == 'complete' || args[0] == 'pause' || args[0] == 'remove') {
|
||||
args[len - 1].call(this, paramMock.businessErrorMock);
|
||||
} else if (args[0] == 'fail') {
|
||||
args[len - 1].call(this, paramMock.businessErrorMock, ErrorMock);
|
||||
}
|
||||
}
|
||||
},
|
||||
remove: function(...args) {
|
||||
remove: function (...args) {
|
||||
console.warn("DownloadTask.remove interface mocked in the Previewer. How this interface works on the Previewer" +
|
||||
" may be different from that on a real device.")
|
||||
const len = args.length
|
||||
@@ -102,7 +118,7 @@ export function mockOhosRequest() {
|
||||
})
|
||||
}
|
||||
},
|
||||
pause: function(...args) {
|
||||
pause: function (...args) {
|
||||
console.warn("DownloadTask.pause interface mocked in the Previewer. How this interface works on the Previewer" +
|
||||
" may be different from that on a real device.")
|
||||
const len = args.length
|
||||
@@ -114,7 +130,7 @@ export function mockOhosRequest() {
|
||||
})
|
||||
}
|
||||
},
|
||||
resume: function(...args) {
|
||||
resume: function (...args) {
|
||||
console.warn("DownloadTask.resume interface mocked in the Previewer. How this interface works on the Previewer" +
|
||||
" may be different from that on a real device.")
|
||||
const len = args.length
|
||||
@@ -126,7 +142,7 @@ export function mockOhosRequest() {
|
||||
})
|
||||
}
|
||||
},
|
||||
queryMimeType: function(...args) {
|
||||
queryMimeType: function (...args) {
|
||||
console.warn("DownloadTask.queryMimeType interface mocked in the Previewer. How this interface works on the Previewer" +
|
||||
" may be different from that on a real device.")
|
||||
const len = args.length
|
||||
@@ -138,7 +154,7 @@ export function mockOhosRequest() {
|
||||
})
|
||||
}
|
||||
},
|
||||
query: function(...args) {
|
||||
query: function (...args) {
|
||||
console.warn("DownloadTask.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
|
||||
@@ -152,31 +168,31 @@ export function mockOhosRequest() {
|
||||
}
|
||||
}
|
||||
const UploadTaskMock = {
|
||||
on: function(...args) {
|
||||
on: function (...args) {
|
||||
console.warn("UploadTask.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] == 'progress') {
|
||||
args[len - 1].call(this, paramMock.paramNumberMock, paramMock.paramNumberMock);
|
||||
} else if (args[0] == 'headerReceive') {
|
||||
args[len - 1].call(this, paramMock.paramObjectMock);
|
||||
}
|
||||
if (args[0] == 'progress') {
|
||||
args[len - 1].call(this, paramMock.paramNumberMock, paramMock.paramNumberMock);
|
||||
} else if (args[0] == 'headerReceive') {
|
||||
args[len - 1].call(this, paramMock.paramObjectMock);
|
||||
}
|
||||
}
|
||||
},
|
||||
off: function(...args) {
|
||||
off: function (...args) {
|
||||
console.warn("UploadTask.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] == 'progress') {
|
||||
args[len - 1].call(this, paramMock.paramNumberMock, paramMock.paramNumberMock);
|
||||
} else if (args[0] == 'headerReceive') {
|
||||
args[len - 1].call(this, paramMock.paramObjectMock);
|
||||
}
|
||||
if (args[0] == 'progress') {
|
||||
args[len - 1].call(this, paramMock.paramNumberMock, paramMock.paramNumberMock);
|
||||
} else if (args[0] == 'headerReceive') {
|
||||
args[len - 1].call(this, paramMock.paramObjectMock);
|
||||
}
|
||||
}
|
||||
},
|
||||
remove: function(...args) {
|
||||
remove: function (...args) {
|
||||
console.warn("UploadTask.remove interface mocked in the Previewer. How this interface works on the Previewer" +
|
||||
" may be different from that on a real device.")
|
||||
const len = args.length
|
||||
@@ -216,7 +232,7 @@ export function mockOhosRequest() {
|
||||
}
|
||||
}
|
||||
|
||||
for(let property of Properties) {
|
||||
for (let property of Properties) {
|
||||
global.ohosplugin.request[property] = NOTIFY + " " + property
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,63 +1,78 @@
|
||||
/*
|
||||
* 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 mockStorageInfoManager () {
|
||||
const infoMock = {
|
||||
storageInfo: {
|
||||
appSize: 472897,
|
||||
cacheSize: 483,
|
||||
dataSize: 32543
|
||||
},
|
||||
totalSize: 12800000,
|
||||
freeSize: 23700000,
|
||||
}
|
||||
global.ohosplugin.storageInfoManager = {
|
||||
queryInfoByPackageName: function (...args) {
|
||||
console.warn("storageInfoManager.queryInfoByPackageName interface mocked in the Previewer. How this interface works on the" +
|
||||
" Previewer may be different from that on a real device.");
|
||||
const len = args.length;
|
||||
if (typeof args[len - 1] === 'function') {
|
||||
args[len - 1].call(this, paramMock.businessErrorMock, infoMock.storageInfo);
|
||||
} else {
|
||||
return new Promise((resolve) => {
|
||||
resolve(infoMock.storageInfo);
|
||||
})
|
||||
}
|
||||
},
|
||||
getTotalSize: function (...args) {
|
||||
console.warn("storageInfoManager.getTotalSize interface mocked in the Previewer. How this interface works on the" +
|
||||
" Previewer may be different from that on a real device.")
|
||||
const len = args.length;
|
||||
if (typeof args[len - 1] === 'function') {
|
||||
args[len - 1].call(this, paramMock.businessErrorMock, infoMock.totalSize);
|
||||
} else {
|
||||
return new Promise((resolve) => {
|
||||
resolve(infoMock.totalSize);
|
||||
})
|
||||
}
|
||||
},
|
||||
getFreeSize: function (...args) {
|
||||
console.warn("storageInfoManager.getFreeSize interface mocked in the Previewer. How this interface works on the" +
|
||||
" Previewer may be different from that on a real device.")
|
||||
const len = args.length;
|
||||
if (typeof args[len - 1] === 'function') {
|
||||
args[len - 1].call(this, paramMock.businessErrorMock, infoMock.freeSize);
|
||||
} else {
|
||||
return new Promise((resolve) => {
|
||||
resolve(infoMock.freeSize);
|
||||
})
|
||||
}
|
||||
},
|
||||
queryInfoByUid: function (...args) {
|
||||
console.warn("storageInfoManager.queryInfoByUid interface mocked in the Previewer. How this interface works on the" +
|
||||
" Previewer may be different from that on a real device.")
|
||||
const len = args.length;
|
||||
if (typeof args[len - 1] === 'function') {
|
||||
args[len - 1].call(this, paramMock.businessErrorMock, infoMock.storageInfo);
|
||||
} else {
|
||||
return new Promise((resolve) => {
|
||||
resolve(infoMock.storageInfo);
|
||||
})
|
||||
}
|
||||
},
|
||||
}
|
||||
export function mockStorageInfoManager() {
|
||||
const infoMock = {
|
||||
storageInfo: {
|
||||
appSize: 472897,
|
||||
cacheSize: 483,
|
||||
dataSize: 32543
|
||||
},
|
||||
totalSize: 12800000,
|
||||
freeSize: 23700000,
|
||||
}
|
||||
global.ohosplugin.storageInfoManager = {
|
||||
queryInfoByPackageName: function (...args) {
|
||||
console.warn("storageInfoManager.queryInfoByPackageName interface mocked in the Previewer. How this interface works on the" +
|
||||
" Previewer may be different from that on a real device.");
|
||||
const len = args.length;
|
||||
if (typeof args[len - 1] === 'function') {
|
||||
args[len - 1].call(this, paramMock.businessErrorMock, infoMock.storageInfo);
|
||||
} else {
|
||||
return new Promise((resolve) => {
|
||||
resolve(infoMock.storageInfo);
|
||||
})
|
||||
}
|
||||
},
|
||||
getTotalSize: function (...args) {
|
||||
console.warn("storageInfoManager.getTotalSize interface mocked in the Previewer. How this interface works on the" +
|
||||
" Previewer may be different from that on a real device.")
|
||||
const len = args.length;
|
||||
if (typeof args[len - 1] === 'function') {
|
||||
args[len - 1].call(this, paramMock.businessErrorMock, infoMock.totalSize);
|
||||
} else {
|
||||
return new Promise((resolve) => {
|
||||
resolve(infoMock.totalSize);
|
||||
})
|
||||
}
|
||||
},
|
||||
getFreeSize: function (...args) {
|
||||
console.warn("storageInfoManager.getFreeSize interface mocked in the Previewer. How this interface works on the" +
|
||||
" Previewer may be different from that on a real device.")
|
||||
const len = args.length;
|
||||
if (typeof args[len - 1] === 'function') {
|
||||
args[len - 1].call(this, paramMock.businessErrorMock, infoMock.freeSize);
|
||||
} else {
|
||||
return new Promise((resolve) => {
|
||||
resolve(infoMock.freeSize);
|
||||
})
|
||||
}
|
||||
},
|
||||
queryInfoByUid: function (...args) {
|
||||
console.warn("storageInfoManager.queryInfoByUid interface mocked in the Previewer. How this interface works on the" +
|
||||
" Previewer may be different from that on a real device.")
|
||||
const len = args.length;
|
||||
if (typeof args[len - 1] === 'function') {
|
||||
args[len - 1].call(this, paramMock.businessErrorMock, infoMock.storageInfo);
|
||||
} else {
|
||||
return new Promise((resolve) => {
|
||||
resolve(infoMock.storageInfo);
|
||||
})
|
||||
}
|
||||
},
|
||||
}
|
||||
}
|
||||
@@ -1,138 +1,153 @@
|
||||
import {paramMock} from "../utils"
|
||||
/*
|
||||
* 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 mockSystemTime() {
|
||||
global.ohosplugin.systemTime = {
|
||||
setTime: function (...args) {
|
||||
console.warn('systemTime.setTime interface mocked in the Previewer. How this interface works on the'
|
||||
+ 'Previewer may be different from that on a real device.');
|
||||
const len = args.length;
|
||||
if (typeof args[len - 1] === 'function') {
|
||||
args[len - 1].call(this, paramMock.businessErrorMock);
|
||||
} else {
|
||||
return new Promise((resolve, reject) => {
|
||||
resolve();
|
||||
});
|
||||
}
|
||||
},
|
||||
getCurrentTime: function (...args) {
|
||||
console.warn('systemTime.getCurrentTime interface mocked in the Previewer. How this interface works on the'
|
||||
+ 'Previewer may be different from that on a real device.');
|
||||
const len = args.length;
|
||||
if (typeof args[len - 1] === 'function') {
|
||||
args[len - 1].call(this, paramMock.businessErrorMock, paramMock.paramNumberMock);
|
||||
} else {
|
||||
return new Promise((resolve, reject) => {
|
||||
resolve(paramMock.paramNumberMock);
|
||||
});
|
||||
}
|
||||
},
|
||||
getCurrentTimeNs: function (...args) {
|
||||
console.warn('systemTime.getCurrentTimeNs interface mocked in the Previewer.'
|
||||
+ 'How this interface works on the Previewer may be different from that on a real device.');
|
||||
const len = args.length;
|
||||
if (typeof args[len - 1] === 'function') {
|
||||
args[len - 1].call(this, paramMock.businessErrorMock, paramMock.paramNumberMock);
|
||||
} else {
|
||||
return new Promise((resolve, reject) => {
|
||||
resolve(paramMock.paramNumberMock);
|
||||
});
|
||||
}
|
||||
},
|
||||
getRealActiveTime: function (...args) {
|
||||
console.warn('systemTime.getRealActiveTime interface mocked in the Previewer.'
|
||||
+ 'How this interface works on the Previewer may be different from that on a real device.');
|
||||
const len = args.length;
|
||||
if (typeof args[len - 1] === 'function') {
|
||||
args[len - 1].call(this, paramMock.businessErrorMock, paramMock.paramNumberMock);
|
||||
} else {
|
||||
return new Promise((resolve, reject) => {
|
||||
resolve(paramMock.paramNumberMock);
|
||||
});
|
||||
}
|
||||
},
|
||||
getRealActiveTimeNs: function (...args) {
|
||||
console.warn('systemTime.getRealActiveTimeNs interface mocked in the Previewer.'
|
||||
+ 'How this interface works on the Previewer may be different from that on a real device.');
|
||||
const len = args.length;
|
||||
if (typeof args[len - 1] === 'function') {
|
||||
args[len - 1].call(this, paramMock.businessErrorMock, paramMock.paramNumberMock);
|
||||
} else {
|
||||
return new Promise((resolve, reject) => {
|
||||
resolve(paramMock.paramNumberMock);
|
||||
});
|
||||
}
|
||||
},
|
||||
getRealTime: function (...args) {
|
||||
console.warn('systemTime.getRealTime interface mocked in the Previewer. How this interface works on the'
|
||||
+ 'Previewer may be different from that on a real device.');
|
||||
const len = args.length;
|
||||
if (typeof args[len - 1] === 'function') {
|
||||
args[len - 1].call(this, paramMock.businessErrorMock, paramMock.paramNumberMock);
|
||||
} else {
|
||||
return new Promise((resolve, reject) => {
|
||||
resolve(paramMock.paramNumberMock);
|
||||
});
|
||||
}
|
||||
},
|
||||
getRealTimeNs: function (...args) {
|
||||
console.warn('systemTime.getRealTimeNs interface mocked in the Previewer. How this interface works on the'
|
||||
+ 'Previewer may be different from that on a real device.');
|
||||
const len = args.length;
|
||||
if (typeof args[len - 1] === 'function') {
|
||||
args[len - 1].call(this, paramMock.businessErrorMock, paramMock.paramNumberMock);
|
||||
} else {
|
||||
return new Promise((resolve, reject) => {
|
||||
resolve(paramMock.paramNumberMock);
|
||||
});
|
||||
}
|
||||
},
|
||||
setDate: function (...args) {
|
||||
console.warn('systemTime.setDate interface mocked in the Previewer. How this interface works on the'
|
||||
+ 'Previewer may be different from that on a 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();
|
||||
});
|
||||
}
|
||||
},
|
||||
getDate: function (...args) {
|
||||
console.warn('systemTime.getDate interface mocked in the Previewer. How this interface works on the'
|
||||
+ 'Previewer may be different 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);
|
||||
});
|
||||
}
|
||||
},
|
||||
setTimezone: function (...args) {
|
||||
console.warn('systemTime.setTimezone interface mocked in the Previewer. How this interface works on the'
|
||||
+ 'Previewer may be different from that on a 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();
|
||||
});
|
||||
}
|
||||
},
|
||||
getTimeZone: function (...args) {
|
||||
console.warn('systemTime.getTimeZone interface mocked in the Previewer. How this interface works on the'
|
||||
+ 'Previewer may be different 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);
|
||||
});
|
||||
}
|
||||
},
|
||||
};
|
||||
global.ohosplugin.systemTime = {
|
||||
setTime: function (...args) {
|
||||
console.warn('systemTime.setTime interface mocked in the Previewer. How this interface works on the'
|
||||
+ 'Previewer may be different from that on a real device.');
|
||||
const len = args.length;
|
||||
if (typeof args[len - 1] === 'function') {
|
||||
args[len - 1].call(this, paramMock.businessErrorMock);
|
||||
} else {
|
||||
return new Promise((resolve, reject) => {
|
||||
resolve();
|
||||
});
|
||||
}
|
||||
},
|
||||
getCurrentTime: function (...args) {
|
||||
console.warn('systemTime.getCurrentTime interface mocked in the Previewer. How this interface works on the'
|
||||
+ 'Previewer may be different from that on a real device.');
|
||||
const len = args.length;
|
||||
if (typeof args[len - 1] === 'function') {
|
||||
args[len - 1].call(this, paramMock.businessErrorMock, paramMock.paramNumberMock);
|
||||
} else {
|
||||
return new Promise((resolve, reject) => {
|
||||
resolve(paramMock.paramNumberMock);
|
||||
});
|
||||
}
|
||||
},
|
||||
getCurrentTimeNs: function (...args) {
|
||||
console.warn('systemTime.getCurrentTimeNs interface mocked in the Previewer.'
|
||||
+ 'How this interface works on the Previewer may be different from that on a real device.');
|
||||
const len = args.length;
|
||||
if (typeof args[len - 1] === 'function') {
|
||||
args[len - 1].call(this, paramMock.businessErrorMock, paramMock.paramNumberMock);
|
||||
} else {
|
||||
return new Promise((resolve, reject) => {
|
||||
resolve(paramMock.paramNumberMock);
|
||||
});
|
||||
}
|
||||
},
|
||||
getRealActiveTime: function (...args) {
|
||||
console.warn('systemTime.getRealActiveTime interface mocked in the Previewer.'
|
||||
+ 'How this interface works on the Previewer may be different from that on a real device.');
|
||||
const len = args.length;
|
||||
if (typeof args[len - 1] === 'function') {
|
||||
args[len - 1].call(this, paramMock.businessErrorMock, paramMock.paramNumberMock);
|
||||
} else {
|
||||
return new Promise((resolve, reject) => {
|
||||
resolve(paramMock.paramNumberMock);
|
||||
});
|
||||
}
|
||||
},
|
||||
getRealActiveTimeNs: function (...args) {
|
||||
console.warn('systemTime.getRealActiveTimeNs interface mocked in the Previewer.'
|
||||
+ 'How this interface works on the Previewer may be different from that on a real device.');
|
||||
const len = args.length;
|
||||
if (typeof args[len - 1] === 'function') {
|
||||
args[len - 1].call(this, paramMock.businessErrorMock, paramMock.paramNumberMock);
|
||||
} else {
|
||||
return new Promise((resolve, reject) => {
|
||||
resolve(paramMock.paramNumberMock);
|
||||
});
|
||||
}
|
||||
},
|
||||
getRealTime: function (...args) {
|
||||
console.warn('systemTime.getRealTime interface mocked in the Previewer. How this interface works on the'
|
||||
+ 'Previewer may be different from that on a real device.');
|
||||
const len = args.length;
|
||||
if (typeof args[len - 1] === 'function') {
|
||||
args[len - 1].call(this, paramMock.businessErrorMock, paramMock.paramNumberMock);
|
||||
} else {
|
||||
return new Promise((resolve, reject) => {
|
||||
resolve(paramMock.paramNumberMock);
|
||||
});
|
||||
}
|
||||
},
|
||||
getRealTimeNs: function (...args) {
|
||||
console.warn('systemTime.getRealTimeNs interface mocked in the Previewer. How this interface works on the'
|
||||
+ 'Previewer may be different from that on a real device.');
|
||||
const len = args.length;
|
||||
if (typeof args[len - 1] === 'function') {
|
||||
args[len - 1].call(this, paramMock.businessErrorMock, paramMock.paramNumberMock);
|
||||
} else {
|
||||
return new Promise((resolve, reject) => {
|
||||
resolve(paramMock.paramNumberMock);
|
||||
});
|
||||
}
|
||||
},
|
||||
setDate: function (...args) {
|
||||
console.warn('systemTime.setDate interface mocked in the Previewer. How this interface works on the'
|
||||
+ 'Previewer may be different from that on a 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();
|
||||
});
|
||||
}
|
||||
},
|
||||
getDate: function (...args) {
|
||||
console.warn('systemTime.getDate interface mocked in the Previewer. How this interface works on the'
|
||||
+ 'Previewer may be different 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);
|
||||
});
|
||||
}
|
||||
},
|
||||
setTimezone: function (...args) {
|
||||
console.warn('systemTime.setTimezone interface mocked in the Previewer. How this interface works on the'
|
||||
+ 'Previewer may be different from that on a 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();
|
||||
});
|
||||
}
|
||||
},
|
||||
getTimeZone: function (...args) {
|
||||
console.warn('systemTime.getTimeZone interface mocked in the Previewer. How this interface works on the'
|
||||
+ 'Previewer may be different 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);
|
||||
});
|
||||
}
|
||||
},
|
||||
};
|
||||
}
|
||||
@@ -1,58 +1,73 @@
|
||||
import {paramMock} from "../utils"
|
||||
/*
|
||||
* 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 mockSystemTimer() {
|
||||
global.ohosplugin.systemTimer = {
|
||||
TIMER_TYPE_REALTIME: '[PC preview] unknow TIMER_TYPE_REALTIME',
|
||||
TIMER_TYPE_WAKEUP: '[PC preview] unknow TIMER_TYPE_WAKEUP',
|
||||
TIMER_TYPE_EXACT: '[PC preview] unknow TIMER_TYPE_EXACT',
|
||||
TIMER_TYPE_IDLE: '[PC preview] unknow TIMER_TYPE_IDLE',
|
||||
createTimer: function (...args) {
|
||||
console.warn("systemTimer.createTimer interface mocked in the Previewer. How this interface works on the" +
|
||||
" Previewer may be different from that on a real device.")
|
||||
const len = args.length
|
||||
if (typeof args[len - 1] === 'function') {
|
||||
args[len - 1].call(this, paramMock.businessErrorMock, paramMock.paramNumberMock)
|
||||
} else {
|
||||
return new Promise((resolve, reject) => {
|
||||
resolve(paramMock.paramNumberMock);
|
||||
})
|
||||
}
|
||||
},
|
||||
startTimer: function (...args) {
|
||||
console.warn("systemTimer.startTimer interface mocked in the Previewer. How this interface works on the" +
|
||||
" Previewer may be different from that on a 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();
|
||||
})
|
||||
}
|
||||
},
|
||||
stopTimer: function (...args) {
|
||||
console.warn("systemTimer.stopTimer interface mocked in the Previewer. How this interface works on the" +
|
||||
" Previewer may be different from that on a 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();
|
||||
})
|
||||
}
|
||||
},
|
||||
destroyTimer: function (...args) {
|
||||
console.warn("systemTimer.destroyTimer interface mocked in the Previewer. How this interface works on the" +
|
||||
" Previewer may be different from that on a 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();
|
||||
})
|
||||
}
|
||||
}
|
||||
global.ohosplugin.systemTimer = {
|
||||
TIMER_TYPE_REALTIME: '[PC preview] unknow TIMER_TYPE_REALTIME',
|
||||
TIMER_TYPE_WAKEUP: '[PC preview] unknow TIMER_TYPE_WAKEUP',
|
||||
TIMER_TYPE_EXACT: '[PC preview] unknow TIMER_TYPE_EXACT',
|
||||
TIMER_TYPE_IDLE: '[PC preview] unknow TIMER_TYPE_IDLE',
|
||||
createTimer: function (...args) {
|
||||
console.warn("systemTimer.createTimer interface mocked in the Previewer. How this interface works on the" +
|
||||
" Previewer may be different from that on a real device.")
|
||||
const len = args.length
|
||||
if (typeof args[len - 1] === 'function') {
|
||||
args[len - 1].call(this, paramMock.businessErrorMock, paramMock.paramNumberMock)
|
||||
} else {
|
||||
return new Promise((resolve, reject) => {
|
||||
resolve(paramMock.paramNumberMock);
|
||||
})
|
||||
}
|
||||
},
|
||||
startTimer: function (...args) {
|
||||
console.warn("systemTimer.startTimer interface mocked in the Previewer. How this interface works on the" +
|
||||
" Previewer may be different from that on a 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();
|
||||
})
|
||||
}
|
||||
},
|
||||
stopTimer: function (...args) {
|
||||
console.warn("systemTimer.stopTimer interface mocked in the Previewer. How this interface works on the" +
|
||||
" Previewer may be different from that on a 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();
|
||||
})
|
||||
}
|
||||
},
|
||||
destroyTimer: function (...args) {
|
||||
console.warn("systemTimer.destroyTimer interface mocked in the Previewer. How this interface works on the" +
|
||||
" Previewer may be different from that on a 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();
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,213 +1,228 @@
|
||||
/*
|
||||
* Copyright (c) 2021 Huawei Device Co., Ltd.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
export function mockUserIAMUserAuth() {
|
||||
const AuthenticationResult = {
|
||||
NO_SUPPORT : -1,
|
||||
SUCCESS : 0,
|
||||
COMPARE_FAILURE : 1,
|
||||
CANCELED : 2,
|
||||
TIMEOUT : 3,
|
||||
CAMERA_FAIL : 4,
|
||||
BUSY : 5,
|
||||
INVALID_PARAMETERS : 6,
|
||||
LOCKED : 7,
|
||||
NOT_ENROLLED : 8,
|
||||
GENERAL_ERROR : 100,
|
||||
const AuthenticationResult = {
|
||||
NO_SUPPORT: -1,
|
||||
SUCCESS: 0,
|
||||
COMPARE_FAILURE: 1,
|
||||
CANCELED: 2,
|
||||
TIMEOUT: 3,
|
||||
CAMERA_FAIL: 4,
|
||||
BUSY: 5,
|
||||
INVALID_PARAMETERS: 6,
|
||||
LOCKED: 7,
|
||||
NOT_ENROLLED: 8,
|
||||
GENERAL_ERROR: 100,
|
||||
}
|
||||
|
||||
const CheckAvailabilityResult = {
|
||||
SUPPORTED: 0,
|
||||
AUTH_TYPE_NOT_SUPPORT: 1,
|
||||
SECURE_LEVEL_NOT_SUPPORT: 2,
|
||||
DISTRIBUTED_AUTH_NOT_SUPPORT: 3,
|
||||
NOT_ENROLLED: 4,
|
||||
PARAM_NUM_ERROR: 5,
|
||||
}
|
||||
|
||||
const TipEvent = {
|
||||
RESULT: 1,
|
||||
CANCEL: 2,
|
||||
ACQUIRE: 3,
|
||||
BUSY: 4,
|
||||
OUT_OF_MEM: 5,
|
||||
FACE_ID: 6,
|
||||
}
|
||||
|
||||
const TipCode = {
|
||||
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 Result = {
|
||||
SUCCESS: 0,
|
||||
FAILED: 1,
|
||||
}
|
||||
|
||||
function checkAuthParam(authType, secureLevel) {
|
||||
if ((typeof authType !== 'string') || (["ALL", "FACE_ONLY"].indexOf(authType) < 0)) {
|
||||
console.error('invalid authType');
|
||||
return CheckAvailabilityResult.AUTH_TYPE_NOT_SUPPORT;
|
||||
}
|
||||
|
||||
const CheckAvailabilityResult = {
|
||||
SUPPORTED : 0,
|
||||
AUTH_TYPE_NOT_SUPPORT : 1,
|
||||
SECURE_LEVEL_NOT_SUPPORT : 2,
|
||||
DISTRIBUTED_AUTH_NOT_SUPPORT : 3,
|
||||
NOT_ENROLLED : 4,
|
||||
PARAM_NUM_ERROR : 5,
|
||||
if ((typeof secureLevel !== 'string') || (["S1", "S2", "S3", "S4"].indexOf(secureLevel) < 0)) {
|
||||
console.error('invalid secureLevel');
|
||||
return CheckAvailabilityResult.SECURE_LEVEL_NOT_SUPPORT;
|
||||
}
|
||||
|
||||
const TipEvent = {
|
||||
RESULT : 1,
|
||||
CANCEL : 2,
|
||||
ACQUIRE : 3,
|
||||
BUSY : 4,
|
||||
OUT_OF_MEM : 5,
|
||||
FACE_ID : 6,
|
||||
return Result.SUCCESS;
|
||||
}
|
||||
|
||||
let Authenticator = class {
|
||||
constructor() {
|
||||
}
|
||||
|
||||
const TipCode = {
|
||||
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,
|
||||
async execute(authType, secureLevel, callback) {
|
||||
console.warn("Authenticator.execute interface mocked in the Previewer. How this interface works on the" +
|
||||
" Previewer may be different from that on a real device.")
|
||||
function handleCallback(callback, ret) {
|
||||
if (typeof callback === 'function') {
|
||||
callback(ret);
|
||||
} else {
|
||||
if (ret === 0) {
|
||||
return ret;
|
||||
} else {
|
||||
throw ret;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (checkAuthParam(authType, secureLevel) != Result.SUCCESS) {
|
||||
return handleCallback(callback, AuthenticationResult.INVALID_PARAMETERS);
|
||||
}
|
||||
|
||||
let successTip = {
|
||||
"errorCode": Result.FAILED,
|
||||
"tipEvent": TipEvent.RESULT,
|
||||
"tipCode": AuthenticationResult.SUCCESS,
|
||||
"tipInfo": "success",
|
||||
};
|
||||
|
||||
for (let localCallback of userAuth.subscribeTipSet.values()) {
|
||||
localCallback(successTip);
|
||||
}
|
||||
|
||||
// mock
|
||||
return handleCallback(callback, AuthenticationResult.SUCCESS);
|
||||
}
|
||||
|
||||
const Result = {
|
||||
SUCCESS: 0,
|
||||
FAILED: 1,
|
||||
checkAvailability(authType, secureLevel) {
|
||||
console.warn("Authenticator.checkAvailability interface mocked in the Previewer. How this interface works" +
|
||||
" on the Previewer may be different from that on a real device.")
|
||||
let result = checkAuthParam(authType, secureLevel);
|
||||
if (result != Result.SUCCESS) {
|
||||
return result;
|
||||
}
|
||||
|
||||
// mock
|
||||
return CheckAvailabilityResult.SUPPORTED;
|
||||
}
|
||||
|
||||
function checkAuthParam(authType, secureLevel) {
|
||||
if ((typeof authType !== 'string') || (["ALL", "FACE_ONLY"].indexOf(authType) < 0)) {
|
||||
console.error('invalid authType');
|
||||
return CheckAvailabilityResult.AUTH_TYPE_NOT_SUPPORT;
|
||||
}
|
||||
cancel() {
|
||||
console.warn("Authenticator.cancel interface mocked in the Previewer. How this interface works on the" +
|
||||
" Previewer may be different from that on a real device.")
|
||||
|
||||
if ((typeof secureLevel !== 'string') || ([ "S1", "S2", "S3", "S4"].indexOf(secureLevel) < 0)) {
|
||||
console.error('invalid secureLevel');
|
||||
return CheckAvailabilityResult.SECURE_LEVEL_NOT_SUPPORT;
|
||||
}
|
||||
|
||||
return Result.SUCCESS;
|
||||
// mock
|
||||
return Result.SUCCESS;
|
||||
}
|
||||
|
||||
let Authenticator = class {
|
||||
constructor() {
|
||||
}
|
||||
async on(type, callback) {
|
||||
console.warn("Authenticator.on interface mocked in the Previewer. How this interface works on the" +
|
||||
" Previewer may be different from that on a real device.")
|
||||
let errorTip = {
|
||||
"errorCode": Result.FAILED,
|
||||
"tipEvent": 0,
|
||||
"tipCode": 0,
|
||||
"tipInfo": "",
|
||||
};
|
||||
|
||||
async execute(authType, secureLevel, callback) {
|
||||
console.warn("Authenticator.execute interface mocked in the Previewer. How this interface works on the" +
|
||||
" Previewer may be different from that on a real device.")
|
||||
function handleCallback(callback, ret) {
|
||||
if (typeof callback === 'function') {
|
||||
callback(ret);
|
||||
} else {
|
||||
if (ret === 0) {
|
||||
return ret;
|
||||
} else {
|
||||
throw ret;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (type !== 'tip') {
|
||||
console.error('type is invalid')
|
||||
callback(errorTip);
|
||||
return;
|
||||
}
|
||||
|
||||
if (checkAuthParam(authType, secureLevel) != Result.SUCCESS) {
|
||||
return handleCallback(callback, AuthenticationResult.INVALID_PARAMETERS);
|
||||
}
|
||||
if (typeof callback !== 'function') {
|
||||
console.error('callback parameter is invalid');
|
||||
callback(errorTip);
|
||||
return;
|
||||
}
|
||||
|
||||
let successTip = {
|
||||
"errorCode" : Result.FAILED,
|
||||
"tipEvent" : TipEvent.RESULT,
|
||||
"tipCode" : AuthenticationResult.SUCCESS,
|
||||
"tipInfo" : "success",
|
||||
};
|
||||
userAuth.subscribeTipSet.add(callback);
|
||||
if (userAuth.subscribeToTip) {
|
||||
console.log('already subscribe to event');
|
||||
return;
|
||||
}
|
||||
|
||||
for(let localCallback of userAuth.subscribeTipSet.values()) {
|
||||
localCallback(successTip);
|
||||
}
|
||||
|
||||
// mock
|
||||
return handleCallback(callback, AuthenticationResult.SUCCESS);
|
||||
}
|
||||
|
||||
checkAvailability(authType, secureLevel) {
|
||||
console.warn("Authenticator.checkAvailability interface mocked in the Previewer. How this interface works" +
|
||||
" on the Previewer may be different from that on a real device.")
|
||||
let result = checkAuthParam(authType, secureLevel);
|
||||
if (result != Result.SUCCESS) {
|
||||
return result;
|
||||
}
|
||||
|
||||
// mock
|
||||
return CheckAvailabilityResult.SUPPORTED;
|
||||
}
|
||||
|
||||
cancel() {
|
||||
console.warn("Authenticator.cancel interface mocked in the Previewer. How this interface works on the" +
|
||||
" Previewer may be different from that on a real device.")
|
||||
|
||||
// mock
|
||||
return Result.SUCCESS;
|
||||
}
|
||||
|
||||
async on(type, callback) {
|
||||
console.warn("Authenticator.on interface mocked in the Previewer. How this interface works on the" +
|
||||
" Previewer may be different from that on a real device.")
|
||||
let errorTip = {
|
||||
"errorCode" : Result.FAILED,
|
||||
"tipEvent" : 0,
|
||||
"tipCode" : 0,
|
||||
"tipInfo" : "",
|
||||
};
|
||||
|
||||
if (type !== 'tip') {
|
||||
console.error('type is invalid')
|
||||
callback(errorTip);
|
||||
return;
|
||||
}
|
||||
|
||||
if (typeof callback !== 'function') {
|
||||
console.error('callback parameter is invalid');
|
||||
callback(errorTip);
|
||||
return;
|
||||
}
|
||||
|
||||
userAuth.subscribeTipSet.add(callback);
|
||||
if (userAuth.subscribeToTip) {
|
||||
console.log('already subscribe to event');
|
||||
return;
|
||||
}
|
||||
|
||||
// mock
|
||||
userAuth.subscribeToTip = true;
|
||||
console.info('subscribe success');
|
||||
}
|
||||
|
||||
async off(type, optCallback) {
|
||||
console.warn("Authenticator.off interface mocked in the Previewer. How this interface works on the" +
|
||||
" Previewer may be different from that on a real device.")
|
||||
if (type !== 'tip') {
|
||||
console.error('type is invalid')
|
||||
return;
|
||||
}
|
||||
|
||||
if (typeof optCallback === 'function') {
|
||||
userAuth.subscribeTipSet.delete(optCallback);
|
||||
} else {
|
||||
userAuth.subscribeTipSet.clear();
|
||||
}
|
||||
|
||||
if (!userAuth.subscribeToTip) {
|
||||
console.info('not subscribing event, no need unsubscribe');
|
||||
return;
|
||||
}
|
||||
|
||||
if (userAuth.subscribeTipSet.size !== 0) {
|
||||
console.info('subscriber is not 0, no need unsubscribe');
|
||||
return;
|
||||
}
|
||||
|
||||
// mock
|
||||
userAuth.subscribeToTip = false;
|
||||
console.info('unsubscribe success');
|
||||
}
|
||||
// mock
|
||||
userAuth.subscribeToTip = true;
|
||||
console.info('subscribe success');
|
||||
}
|
||||
|
||||
var userAuth = {
|
||||
moduleGroup: null,
|
||||
eventGroup: null,
|
||||
authenticator: null,
|
||||
subscribeToTip : false,
|
||||
subscribeTipSet: new Set([]),
|
||||
getAuthenticator : function getAuthenticator() {
|
||||
console.warn("userAuth.getAuthenticator interface mocked in the Previewer. How this interface works" +
|
||||
" on the Previewer may be different from that on a real device.")
|
||||
if (this.authenticator == null) {
|
||||
this.authenticator = new Authenticator()
|
||||
}
|
||||
return this.authenticator;
|
||||
}
|
||||
}
|
||||
async off(type, optCallback) {
|
||||
console.warn("Authenticator.off interface mocked in the Previewer. How this interface works on the" +
|
||||
" Previewer may be different from that on a real device.")
|
||||
if (type !== 'tip') {
|
||||
console.error('type is invalid')
|
||||
return;
|
||||
}
|
||||
|
||||
global.systemplugin.userIAM = global.systemplugin.userIAM || {};
|
||||
global.systemplugin.userIAM.userAuth = {
|
||||
getAuthenticator : userAuth.getAuthenticator,
|
||||
AuthenticationResult : AuthenticationResult,
|
||||
CheckAvailabilityResult : CheckAvailabilityResult,
|
||||
TipEvent : TipEvent,
|
||||
TipCode : TipCode,
|
||||
Result : Result,
|
||||
};
|
||||
if (typeof optCallback === 'function') {
|
||||
userAuth.subscribeTipSet.delete(optCallback);
|
||||
} else {
|
||||
userAuth.subscribeTipSet.clear();
|
||||
}
|
||||
|
||||
if (!userAuth.subscribeToTip) {
|
||||
console.info('not subscribing event, no need unsubscribe');
|
||||
return;
|
||||
}
|
||||
|
||||
if (userAuth.subscribeTipSet.size !== 0) {
|
||||
console.info('subscriber is not 0, no need unsubscribe');
|
||||
return;
|
||||
}
|
||||
|
||||
// mock
|
||||
userAuth.subscribeToTip = false;
|
||||
console.info('unsubscribe success');
|
||||
}
|
||||
}
|
||||
|
||||
var userAuth = {
|
||||
moduleGroup: null,
|
||||
eventGroup: null,
|
||||
authenticator: null,
|
||||
subscribeToTip: false,
|
||||
subscribeTipSet: new Set([]),
|
||||
getAuthenticator: function getAuthenticator() {
|
||||
console.warn("userAuth.getAuthenticator interface mocked in the Previewer. How this interface works" +
|
||||
" on the Previewer may be different from that on a real device.")
|
||||
if (this.authenticator == null) {
|
||||
this.authenticator = new Authenticator()
|
||||
}
|
||||
return this.authenticator;
|
||||
}
|
||||
}
|
||||
|
||||
global.systemplugin.userIAM = global.systemplugin.userIAM || {};
|
||||
global.systemplugin.userIAM.userAuth = {
|
||||
getAuthenticator: userAuth.getAuthenticator,
|
||||
AuthenticationResult: AuthenticationResult,
|
||||
CheckAvailabilityResult: CheckAvailabilityResult,
|
||||
TipEvent: TipEvent,
|
||||
TipCode: TipCode,
|
||||
Result: Result,
|
||||
};
|
||||
}
|
||||
@@ -1,163 +1,178 @@
|
||||
import {paramMock} from "../utils"
|
||||
import {PixelMapMock} from "../multimedia"
|
||||
/*
|
||||
* 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"
|
||||
import { PixelMapMock } from "../multimedia"
|
||||
|
||||
export function mockWallpaper() {
|
||||
global.ohosplugin.wallpaper = {
|
||||
WallpaperType: {
|
||||
WALLPAPER_SYSTEM: '[PC preview] unknow WALLPAPER_SYSTEM',
|
||||
WALLPAPER_LOCKSCREEN: '[PC preview] unknow WALLPAPER_LOCKSCREEN'
|
||||
},
|
||||
getColors: function (...args) {
|
||||
console.warn("wallpaper.getColors interface mocked in the Previewer. How this interface works on the" +
|
||||
" Previewer may be different from that on a real device.")
|
||||
const len = args.length;
|
||||
let colors = new Array();
|
||||
colors.push(RgbaColorMock);
|
||||
if (typeof args[len - 1] === 'function') {
|
||||
args[len - 1].call(this, paramMock.businessErrorMock, colors);
|
||||
} else {
|
||||
return new Promise((resolve, reject) => {
|
||||
resolve(colors);
|
||||
})
|
||||
}
|
||||
},
|
||||
getId: function (...args) {
|
||||
console.warn("wallpaper.getId interface mocked in the Previewer. How this interface works on the" +
|
||||
" Previewer may be different from that on a real device.")
|
||||
const len = args.length
|
||||
if (typeof args[len - 1] === 'function') {
|
||||
args[len - 1].call(this, paramMock.businessErrorMock, paramMock.paramNumberMock)
|
||||
} else {
|
||||
return new Promise((resolve, reject) => {
|
||||
resolve(paramMock.paramNumberMock);
|
||||
})
|
||||
}
|
||||
},
|
||||
getMinHeight: function (...args) {
|
||||
console.warn("wallpaper.getMinHeight interface mocked in the Previewer. How this interface works on the" +
|
||||
" Previewer may be different from that on a real device.")
|
||||
const len = args.length
|
||||
if (typeof args[len - 1] === 'function') {
|
||||
args[len - 1].call(this, paramMock.businessErrorMock, paramMock.paramNumberMock)
|
||||
} else {
|
||||
return new Promise((resolve, reject) => {
|
||||
resolve(paramMock.paramNumberMock);
|
||||
})
|
||||
}
|
||||
},
|
||||
getMinWidth: function (...args) {
|
||||
console.warn("wallpaper.getMinWidth interface mocked in the Previewer. How this interface works on the" +
|
||||
" Previewer may be different from that on a real device.")
|
||||
const len = args.length
|
||||
if (typeof args[len - 1] === 'function') {
|
||||
args[len - 1].call(this, paramMock.businessErrorMock, paramMock.paramNumberMock)
|
||||
} else {
|
||||
return new Promise((resolve, reject) => {
|
||||
resolve(paramMock.paramNumberMock);
|
||||
})
|
||||
}
|
||||
},
|
||||
isChangePermitted: function (...args) {
|
||||
console.warn("wallpaper.isChangePermitted interface mocked in the Previewer. How this interface works on the" +
|
||||
" Previewer may be different 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);
|
||||
})
|
||||
}
|
||||
},
|
||||
isOperationAllowed: function (...args) {
|
||||
console.warn("wallpaper.isOperationAllowed interface mocked in the Previewer. How this interface works on the" +
|
||||
" Previewer may be different 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);
|
||||
})
|
||||
}
|
||||
},
|
||||
reset: function (...args) {
|
||||
console.warn("wallpaper.reset interface mocked in the Previewer. How this interface works on the" +
|
||||
" Previewer may be different from that on a 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();
|
||||
})
|
||||
}
|
||||
},
|
||||
setWallpaper: function (...args) {
|
||||
console.warn("wallpaper.setWallpaper interface mocked in the Previewer. How this interface works on the" +
|
||||
" Previewer may be different from that on a 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();
|
||||
})
|
||||
}
|
||||
},
|
||||
getPixelMap: function (...args) {
|
||||
console.warn("wallpaper.getPixelMap interface mocked in the Previewer. How this interface works on the" +
|
||||
" Previewer may be different from that on a real device.")
|
||||
const len = args.length
|
||||
if (typeof args[len - 1] === 'function') {
|
||||
args[len - 1].call(this, paramMock.businessErrorMock, PixelMapMock)
|
||||
} else {
|
||||
return new Promise((resolve, reject) => {
|
||||
resolve(PixelMapMock);
|
||||
})
|
||||
}
|
||||
},
|
||||
screenshotLiveWallpaper: function (...args) {
|
||||
console.warn("wallpaper.screenshotLiveWallpaper interface mocked in the Previewer. How this interface works on the" +
|
||||
" Previewer may be different from that on a real device.")
|
||||
const len = args.length
|
||||
if (typeof args[len - 1] === 'function') {
|
||||
args[len - 1].call(this, paramMock.businessErrorMock, PixelMapMock)
|
||||
} else {
|
||||
return new Promise((resolve, reject) => {
|
||||
resolve(PixelMapMock);
|
||||
})
|
||||
}
|
||||
},
|
||||
on: function (...args) {
|
||||
console.warn("wallpaper.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] == 'colorChange') {
|
||||
let colors = new Array();
|
||||
colors.push(RgbaColorMock);
|
||||
args[len - 1].call(this, colors, global.ohosplugin.wallpaper.WallpaperType.WALLPAPER_SYSTEM);
|
||||
}
|
||||
}
|
||||
},
|
||||
off: function (...args) {
|
||||
console.warn("wallpaper.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] == 'colorChange') {
|
||||
let colors = new Array();
|
||||
colors.push(RgbaColorMock);
|
||||
args[len - 1].call(this, colors, global.ohosplugin.wallpaper.WallpaperType.WALLPAPER_SYSTEM);
|
||||
}
|
||||
}
|
||||
global.ohosplugin.wallpaper = {
|
||||
WallpaperType: {
|
||||
WALLPAPER_SYSTEM: '[PC preview] unknow WALLPAPER_SYSTEM',
|
||||
WALLPAPER_LOCKSCREEN: '[PC preview] unknow WALLPAPER_LOCKSCREEN'
|
||||
},
|
||||
getColors: function (...args) {
|
||||
console.warn("wallpaper.getColors interface mocked in the Previewer. How this interface works on the" +
|
||||
" Previewer may be different from that on a real device.")
|
||||
const len = args.length;
|
||||
let colors = new Array();
|
||||
colors.push(RgbaColorMock);
|
||||
if (typeof args[len - 1] === 'function') {
|
||||
args[len - 1].call(this, paramMock.businessErrorMock, colors);
|
||||
} else {
|
||||
return new Promise((resolve, reject) => {
|
||||
resolve(colors);
|
||||
})
|
||||
}
|
||||
},
|
||||
getId: function (...args) {
|
||||
console.warn("wallpaper.getId interface mocked in the Previewer. How this interface works on the" +
|
||||
" Previewer may be different from that on a real device.")
|
||||
const len = args.length
|
||||
if (typeof args[len - 1] === 'function') {
|
||||
args[len - 1].call(this, paramMock.businessErrorMock, paramMock.paramNumberMock)
|
||||
} else {
|
||||
return new Promise((resolve, reject) => {
|
||||
resolve(paramMock.paramNumberMock);
|
||||
})
|
||||
}
|
||||
},
|
||||
getMinHeight: function (...args) {
|
||||
console.warn("wallpaper.getMinHeight interface mocked in the Previewer. How this interface works on the" +
|
||||
" Previewer may be different from that on a real device.")
|
||||
const len = args.length
|
||||
if (typeof args[len - 1] === 'function') {
|
||||
args[len - 1].call(this, paramMock.businessErrorMock, paramMock.paramNumberMock)
|
||||
} else {
|
||||
return new Promise((resolve, reject) => {
|
||||
resolve(paramMock.paramNumberMock);
|
||||
})
|
||||
}
|
||||
},
|
||||
getMinWidth: function (...args) {
|
||||
console.warn("wallpaper.getMinWidth interface mocked in the Previewer. How this interface works on the" +
|
||||
" Previewer may be different from that on a real device.")
|
||||
const len = args.length
|
||||
if (typeof args[len - 1] === 'function') {
|
||||
args[len - 1].call(this, paramMock.businessErrorMock, paramMock.paramNumberMock)
|
||||
} else {
|
||||
return new Promise((resolve, reject) => {
|
||||
resolve(paramMock.paramNumberMock);
|
||||
})
|
||||
}
|
||||
},
|
||||
isChangePermitted: function (...args) {
|
||||
console.warn("wallpaper.isChangePermitted interface mocked in the Previewer. How this interface works on the" +
|
||||
" Previewer may be different 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);
|
||||
})
|
||||
}
|
||||
},
|
||||
isOperationAllowed: function (...args) {
|
||||
console.warn("wallpaper.isOperationAllowed interface mocked in the Previewer. How this interface works on the" +
|
||||
" Previewer may be different 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);
|
||||
})
|
||||
}
|
||||
},
|
||||
reset: function (...args) {
|
||||
console.warn("wallpaper.reset interface mocked in the Previewer. How this interface works on the" +
|
||||
" Previewer may be different from that on a 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();
|
||||
})
|
||||
}
|
||||
},
|
||||
setWallpaper: function (...args) {
|
||||
console.warn("wallpaper.setWallpaper interface mocked in the Previewer. How this interface works on the" +
|
||||
" Previewer may be different from that on a 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();
|
||||
})
|
||||
}
|
||||
},
|
||||
getPixelMap: function (...args) {
|
||||
console.warn("wallpaper.getPixelMap interface mocked in the Previewer. How this interface works on the" +
|
||||
" Previewer may be different from that on a real device.")
|
||||
const len = args.length
|
||||
if (typeof args[len - 1] === 'function') {
|
||||
args[len - 1].call(this, paramMock.businessErrorMock, PixelMapMock)
|
||||
} else {
|
||||
return new Promise((resolve, reject) => {
|
||||
resolve(PixelMapMock);
|
||||
})
|
||||
}
|
||||
},
|
||||
screenshotLiveWallpaper: function (...args) {
|
||||
console.warn("wallpaper.screenshotLiveWallpaper interface mocked in the Previewer. How this interface works on the" +
|
||||
" Previewer may be different from that on a real device.")
|
||||
const len = args.length
|
||||
if (typeof args[len - 1] === 'function') {
|
||||
args[len - 1].call(this, paramMock.businessErrorMock, PixelMapMock)
|
||||
} else {
|
||||
return new Promise((resolve, reject) => {
|
||||
resolve(PixelMapMock);
|
||||
})
|
||||
}
|
||||
},
|
||||
on: function (...args) {
|
||||
console.warn("wallpaper.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] == 'colorChange') {
|
||||
let colors = new Array();
|
||||
colors.push(RgbaColorMock);
|
||||
args[len - 1].call(this, colors, global.ohosplugin.wallpaper.WallpaperType.WALLPAPER_SYSTEM);
|
||||
}
|
||||
}
|
||||
},
|
||||
off: function (...args) {
|
||||
console.warn("wallpaper.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] == 'colorChange') {
|
||||
let colors = new Array();
|
||||
colors.push(RgbaColorMock);
|
||||
args[len - 1].call(this, colors, global.ohosplugin.wallpaper.WallpaperType.WALLPAPER_SYSTEM);
|
||||
}
|
||||
}
|
||||
}
|
||||
const RgbaColorMock = {
|
||||
red: '[PC preview] unknow red',
|
||||
green: '[PC preview] unknow green',
|
||||
blue: '[PC preview] unknow blue',
|
||||
alpha: '[PC preview] unknow alpha'
|
||||
}
|
||||
}
|
||||
const RgbaColorMock = {
|
||||
red: '[PC preview] unknow red',
|
||||
green: '[PC preview] unknow green',
|
||||
blue: '[PC preview] unknow blue',
|
||||
alpha: '[PC preview] unknow alpha'
|
||||
}
|
||||
}
|
||||
@@ -1,125 +1,140 @@
|
||||
/*
|
||||
* 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 mockWantAgent() {
|
||||
const WantMock = {
|
||||
deviceId: '[PC preview] unknow deviceId',
|
||||
bundleName: '[PC preview] unknow bundleName',
|
||||
abilityName: '[PC preview] unknow abilityName',
|
||||
uri: '[PC preview] unknow uri',
|
||||
type: '[PC preview] unknow type',
|
||||
flags: '[PC preview] unknow flags',
|
||||
action: '[PC preview] unknow action',
|
||||
parameters: '[PC preview] unknow parameters',
|
||||
entities: '[PC preview] unknow entities',
|
||||
}
|
||||
const CompleteDataMock = {
|
||||
info: '[PC preview] unknow info',
|
||||
want: '[PC preview] unknow want',
|
||||
finalCode: '[PC preview] unknow finalCode',
|
||||
finalData: '[PC preview] unknow finalData',
|
||||
extraInfo: '[PC preview] unknow extraInfo',
|
||||
}
|
||||
const WantAgentMock = {}
|
||||
global.ohosplugin.wantAgent = {
|
||||
OperationType: {
|
||||
UNKNOWN_TYPE: 0,
|
||||
START_ABILITY: 1,
|
||||
START_ABILITIES: 2,
|
||||
START_SERVICE: 3,
|
||||
SEND_COMMON_EVENT: 4
|
||||
},
|
||||
WantAgentFlags: {
|
||||
ONE_TIME_FLAG: 0,
|
||||
NO_BUILD_FLAG: 1,
|
||||
CANCEL_PRESENT_FLAG: 2,
|
||||
UPDATE_PRESENT_FLAG: 3,
|
||||
CONSTANT_FLAG: 4,
|
||||
REPLACE_ELEMENT: 5,
|
||||
REPLACE_ACTION: 6,
|
||||
REPLACE_URI: 7,
|
||||
REPLACE_ENTITIES: 8,
|
||||
REPLACE_BUNDLE: 9
|
||||
},
|
||||
getBundleName: function (...args) {
|
||||
console.warn("wantAgent.getBundleName interface mocked in the Previewer. How this interface works on the" +
|
||||
" Previewer may be different from that on a real device.");
|
||||
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);
|
||||
});
|
||||
}
|
||||
},
|
||||
getUid: function (...args) {
|
||||
console.warn("wantAgent.getUid interface mocked in the Previewer. How this interface works on the" +
|
||||
" Previewer may be different 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);
|
||||
});
|
||||
}
|
||||
},
|
||||
getWant: function (...args) {
|
||||
console.warn("wantAgent.getWant interface mocked in the Previewer. How this interface works on the" +
|
||||
" Previewer may be different from that on a real device.");
|
||||
const len = args.length;
|
||||
if (typeof args[len - 1] === 'function') {
|
||||
args[len - 1].call(this, paramMock.businessErrorMock, WantMock);
|
||||
} else {
|
||||
return new Promise((resolve) => {
|
||||
resolve(WantMock);
|
||||
});
|
||||
}
|
||||
},
|
||||
cancel: function (...args) {
|
||||
console.warn("wantAgent.cancel interface mocked in the Previewer. How this interface works on the" +
|
||||
" Previewer may be different from that on a 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();
|
||||
});
|
||||
}
|
||||
},
|
||||
trigger: function (...args) {
|
||||
console.warn("wantAgent.trigger interface mocked in the Previewer. How this interface works on the" +
|
||||
" Previewer may be different from that on a real device.");
|
||||
const len = args.length;
|
||||
if (typeof args[len - 1] === 'function') {
|
||||
args[len - 1].call(this, paramMock.businessErrorMock, CompleteDataMock);
|
||||
}
|
||||
},
|
||||
equal: function (...args) {
|
||||
console.warn("wantAgent.equal interface mocked in the Previewer. How this interface works on the" +
|
||||
" Previewer may be different 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);
|
||||
});
|
||||
}
|
||||
},
|
||||
getWantAgent: function (...args) {
|
||||
console.warn("wantAgent.getWantAgent interface mocked in the Previewer. How this interface works on the" +
|
||||
" Previewer may be different from that on a real device.");
|
||||
const len = args.length;
|
||||
if (typeof args[len - 1] === 'function') {
|
||||
args[len - 1].call(this, paramMock.businessErrorMock, WantAgentMock);
|
||||
} else {
|
||||
return new Promise((resolve) => {
|
||||
resolve(WantAgentMock);
|
||||
});
|
||||
}
|
||||
},
|
||||
}
|
||||
const WantMock = {
|
||||
deviceId: '[PC preview] unknow deviceId',
|
||||
bundleName: '[PC preview] unknow bundleName',
|
||||
abilityName: '[PC preview] unknow abilityName',
|
||||
uri: '[PC preview] unknow uri',
|
||||
type: '[PC preview] unknow type',
|
||||
flags: '[PC preview] unknow flags',
|
||||
action: '[PC preview] unknow action',
|
||||
parameters: '[PC preview] unknow parameters',
|
||||
entities: '[PC preview] unknow entities',
|
||||
}
|
||||
const CompleteDataMock = {
|
||||
info: '[PC preview] unknow info',
|
||||
want: '[PC preview] unknow want',
|
||||
finalCode: '[PC preview] unknow finalCode',
|
||||
finalData: '[PC preview] unknow finalData',
|
||||
extraInfo: '[PC preview] unknow extraInfo',
|
||||
}
|
||||
const WantAgentMock = {}
|
||||
global.ohosplugin.wantAgent = {
|
||||
OperationType: {
|
||||
UNKNOWN_TYPE: 0,
|
||||
START_ABILITY: 1,
|
||||
START_ABILITIES: 2,
|
||||
START_SERVICE: 3,
|
||||
SEND_COMMON_EVENT: 4
|
||||
},
|
||||
WantAgentFlags: {
|
||||
ONE_TIME_FLAG: 0,
|
||||
NO_BUILD_FLAG: 1,
|
||||
CANCEL_PRESENT_FLAG: 2,
|
||||
UPDATE_PRESENT_FLAG: 3,
|
||||
CONSTANT_FLAG: 4,
|
||||
REPLACE_ELEMENT: 5,
|
||||
REPLACE_ACTION: 6,
|
||||
REPLACE_URI: 7,
|
||||
REPLACE_ENTITIES: 8,
|
||||
REPLACE_BUNDLE: 9
|
||||
},
|
||||
getBundleName: function (...args) {
|
||||
console.warn("wantAgent.getBundleName interface mocked in the Previewer. How this interface works on the" +
|
||||
" Previewer may be different from that on a real device.");
|
||||
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);
|
||||
});
|
||||
}
|
||||
},
|
||||
getUid: function (...args) {
|
||||
console.warn("wantAgent.getUid interface mocked in the Previewer. How this interface works on the" +
|
||||
" Previewer may be different 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);
|
||||
});
|
||||
}
|
||||
},
|
||||
getWant: function (...args) {
|
||||
console.warn("wantAgent.getWant interface mocked in the Previewer. How this interface works on the" +
|
||||
" Previewer may be different from that on a real device.");
|
||||
const len = args.length;
|
||||
if (typeof args[len - 1] === 'function') {
|
||||
args[len - 1].call(this, paramMock.businessErrorMock, WantMock);
|
||||
} else {
|
||||
return new Promise((resolve) => {
|
||||
resolve(WantMock);
|
||||
});
|
||||
}
|
||||
},
|
||||
cancel: function (...args) {
|
||||
console.warn("wantAgent.cancel interface mocked in the Previewer. How this interface works on the" +
|
||||
" Previewer may be different from that on a 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();
|
||||
});
|
||||
}
|
||||
},
|
||||
trigger: function (...args) {
|
||||
console.warn("wantAgent.trigger interface mocked in the Previewer. How this interface works on the" +
|
||||
" Previewer may be different from that on a real device.");
|
||||
const len = args.length;
|
||||
if (typeof args[len - 1] === 'function') {
|
||||
args[len - 1].call(this, paramMock.businessErrorMock, CompleteDataMock);
|
||||
}
|
||||
},
|
||||
equal: function (...args) {
|
||||
console.warn("wantAgent.equal interface mocked in the Previewer. How this interface works on the" +
|
||||
" Previewer may be different 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);
|
||||
});
|
||||
}
|
||||
},
|
||||
getWantAgent: function (...args) {
|
||||
console.warn("wantAgent.getWantAgent interface mocked in the Previewer. How this interface works on the" +
|
||||
" Previewer may be different from that on a real device.");
|
||||
const len = args.length;
|
||||
if (typeof args[len - 1] === 'function') {
|
||||
args[len - 1].call(this, paramMock.businessErrorMock, WantAgentMock);
|
||||
} else {
|
||||
return new Promise((resolve) => {
|
||||
resolve(WantAgentMock);
|
||||
});
|
||||
}
|
||||
},
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,98 +1,113 @@
|
||||
/*
|
||||
* 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 mockWorkScheduler () {
|
||||
const workInfoMock = {
|
||||
workId: '[PC preview] unknown workId',
|
||||
networkType: '[PC preview] unknown networkType',
|
||||
isDeepIdle: '[PC preview] unknown isDeepIdle',
|
||||
idleWaitTime: '[PC preview] unknown idleWaitTime',
|
||||
isCharging: '[PC preview] unknown isCharging',
|
||||
chargerType: '[PC preview] unknown chargerType',
|
||||
batteryLevel: '[PC preview] unknown batteryLevel',
|
||||
batteryStatus: '[PC preview] unknown batteryStatus',
|
||||
storageRequest: '[PC preview] unknown storageRequest',
|
||||
isRepeat: '[PC preview] unknown isRepeat',
|
||||
isPersisted: '[PC preview] unknown isPersisted',
|
||||
repeatCycleTime: '[PC preview] unknown repeatCycleTime',
|
||||
repeatCount: '[PC preview] unknown repeatCount',
|
||||
bundleName: '[PC preview] unknown bundleName',
|
||||
abilityName: '[PC preview] unknown abilityName',
|
||||
}
|
||||
const workInfoArrayMock = [workInfoMock]
|
||||
const NetworkTypeMock = {
|
||||
NETWORK_TYPE_AN: 0,
|
||||
NETWORK_TYPE_MOBILE: 1,
|
||||
NETWORK_TYPE_WIFI: 2,
|
||||
NETWORK_TYPE_BLUETOOTH: 3,
|
||||
NETWORK_TYPE_WIFI_P2P: 4,
|
||||
NETWORK_TYPE_ETHERNET: 5,
|
||||
}
|
||||
const ChargingType = {
|
||||
CHARGING_PLUGGED_ANY: 0,
|
||||
CHARGING_PLUGGED_AC: 1,
|
||||
CHARGING_PLUGGED_USB: 2,
|
||||
CHARGING_PLUGGED_WIRELESS: 3,
|
||||
}
|
||||
const BatteryStatus = {
|
||||
BATTERY_STATUS_LOW: 0,
|
||||
BATTERY_STATUS_OKAY: 1,
|
||||
BATTERY_STATUS_LOW_OR_OKAY: 2,
|
||||
}
|
||||
const StorageRequest = {
|
||||
STORAGE_LEVEL_LOW: 0,
|
||||
STORAGE_LEVEL_OKAY: 1,
|
||||
STORAGE_LEVEL_LOW_OR_OKAY: 2
|
||||
}
|
||||
global.ohosplugin.workScheduler = {
|
||||
startWork: function (...args) {
|
||||
console.warn("workScheduler.startWork interface mocked in the Previewer. How this interface works on the" +
|
||||
" Previewer may be different from that on a real device.")
|
||||
return paramMock.paramBooleanMock;
|
||||
},
|
||||
stopWork: function (...args) {
|
||||
console.warn("workScheduler.stopWork interface mocked in the Previewer. How this interface works on the" +
|
||||
" Previewer may be different from that on a real device.")
|
||||
return paramMock.paramBooleanMock;
|
||||
},
|
||||
getWorkStatus: function (...args) {
|
||||
console.warn("workScheduler.getWorkStatus interface mocked in the Previewer. How this interface works on the" +
|
||||
" Previewer may be different from that on a real device.")
|
||||
const len = args.length;
|
||||
if (typeof args[len - 1] === 'function') {
|
||||
args[len - 1].call(this, paramMock.businessErrorMock, workInfoMock)
|
||||
} else {
|
||||
return new Promise(resolve => {
|
||||
resolve(workInfoMock);
|
||||
})
|
||||
}
|
||||
},
|
||||
obtainAllWorks: function (...args) {
|
||||
console.warn("workScheduler.obtainAllWorks interface mocked in the Previewer. How this interface works on the" +
|
||||
" Previewer may be different from that on a real device.")
|
||||
const len = args.length;
|
||||
if (typeof args[len - 1] === 'function') {
|
||||
args[len - 1].call(this, paramMock.businessErrorMock, workInfoArrayMock)
|
||||
} else {
|
||||
return new Promise(resolve => {
|
||||
resolve(workInfoArrayMock);
|
||||
})
|
||||
}
|
||||
},
|
||||
stopAndClearWorks: function (...args) {
|
||||
console.warn("workScheduler.stopAndClearWorks interface mocked in the Previewer. How this interface works on the" +
|
||||
" Previewer may be different from that on a real device.")
|
||||
},
|
||||
isLastWorkTimeOut: function (...args) {
|
||||
console.warn("workScheduler.isLastWorkTimeOut interface mocked in the Previewer. How this interface works on the" +
|
||||
" Previewer may be different from that on a real device.")
|
||||
const len = args.length;
|
||||
if (typeof args[len - 1] === 'function') {
|
||||
args[len - 1].call(this, paramMock.businessErrorMock, paramMock.paramBooleanMock)
|
||||
} else {
|
||||
return new Promise(resolve => {
|
||||
resolve(paramMock.paramBooleanMock);
|
||||
})
|
||||
}
|
||||
}
|
||||
export function mockWorkScheduler() {
|
||||
const workInfoMock = {
|
||||
workId: '[PC preview] unknown workId',
|
||||
networkType: '[PC preview] unknown networkType',
|
||||
isDeepIdle: '[PC preview] unknown isDeepIdle',
|
||||
idleWaitTime: '[PC preview] unknown idleWaitTime',
|
||||
isCharging: '[PC preview] unknown isCharging',
|
||||
chargerType: '[PC preview] unknown chargerType',
|
||||
batteryLevel: '[PC preview] unknown batteryLevel',
|
||||
batteryStatus: '[PC preview] unknown batteryStatus',
|
||||
storageRequest: '[PC preview] unknown storageRequest',
|
||||
isRepeat: '[PC preview] unknown isRepeat',
|
||||
isPersisted: '[PC preview] unknown isPersisted',
|
||||
repeatCycleTime: '[PC preview] unknown repeatCycleTime',
|
||||
repeatCount: '[PC preview] unknown repeatCount',
|
||||
bundleName: '[PC preview] unknown bundleName',
|
||||
abilityName: '[PC preview] unknown abilityName',
|
||||
}
|
||||
const workInfoArrayMock = [workInfoMock]
|
||||
const NetworkTypeMock = {
|
||||
NETWORK_TYPE_AN: 0,
|
||||
NETWORK_TYPE_MOBILE: 1,
|
||||
NETWORK_TYPE_WIFI: 2,
|
||||
NETWORK_TYPE_BLUETOOTH: 3,
|
||||
NETWORK_TYPE_WIFI_P2P: 4,
|
||||
NETWORK_TYPE_ETHERNET: 5,
|
||||
}
|
||||
const ChargingType = {
|
||||
CHARGING_PLUGGED_ANY: 0,
|
||||
CHARGING_PLUGGED_AC: 1,
|
||||
CHARGING_PLUGGED_USB: 2,
|
||||
CHARGING_PLUGGED_WIRELESS: 3,
|
||||
}
|
||||
const BatteryStatus = {
|
||||
BATTERY_STATUS_LOW: 0,
|
||||
BATTERY_STATUS_OKAY: 1,
|
||||
BATTERY_STATUS_LOW_OR_OKAY: 2,
|
||||
}
|
||||
const StorageRequest = {
|
||||
STORAGE_LEVEL_LOW: 0,
|
||||
STORAGE_LEVEL_OKAY: 1,
|
||||
STORAGE_LEVEL_LOW_OR_OKAY: 2
|
||||
}
|
||||
global.ohosplugin.workScheduler = {
|
||||
startWork: function (...args) {
|
||||
console.warn("workScheduler.startWork interface mocked in the Previewer. How this interface works on the" +
|
||||
" Previewer may be different from that on a real device.")
|
||||
return paramMock.paramBooleanMock;
|
||||
},
|
||||
stopWork: function (...args) {
|
||||
console.warn("workScheduler.stopWork interface mocked in the Previewer. How this interface works on the" +
|
||||
" Previewer may be different from that on a real device.")
|
||||
return paramMock.paramBooleanMock;
|
||||
},
|
||||
getWorkStatus: function (...args) {
|
||||
console.warn("workScheduler.getWorkStatus interface mocked in the Previewer. How this interface works on the" +
|
||||
" Previewer may be different from that on a real device.")
|
||||
const len = args.length;
|
||||
if (typeof args[len - 1] === 'function') {
|
||||
args[len - 1].call(this, paramMock.businessErrorMock, workInfoMock)
|
||||
} else {
|
||||
return new Promise(resolve => {
|
||||
resolve(workInfoMock);
|
||||
})
|
||||
}
|
||||
},
|
||||
obtainAllWorks: function (...args) {
|
||||
console.warn("workScheduler.obtainAllWorks interface mocked in the Previewer. How this interface works on the" +
|
||||
" Previewer may be different from that on a real device.")
|
||||
const len = args.length;
|
||||
if (typeof args[len - 1] === 'function') {
|
||||
args[len - 1].call(this, paramMock.businessErrorMock, workInfoArrayMock)
|
||||
} else {
|
||||
return new Promise(resolve => {
|
||||
resolve(workInfoArrayMock);
|
||||
})
|
||||
}
|
||||
},
|
||||
stopAndClearWorks: function (...args) {
|
||||
console.warn("workScheduler.stopAndClearWorks interface mocked in the Previewer. How this interface works on the" +
|
||||
" Previewer may be different from that on a real device.")
|
||||
},
|
||||
isLastWorkTimeOut: function (...args) {
|
||||
console.warn("workScheduler.isLastWorkTimeOut interface mocked in the Previewer. How this interface works on the" +
|
||||
" Previewer may be different 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);
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,3 +1,18 @@
|
||||
/*
|
||||
* 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 mockPasteBoard() {
|
||||
|
||||
@@ -1,3 +1,18 @@
|
||||
/*
|
||||
* 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 { hasComplete } from "./utils"
|
||||
|
||||
export function mockRequest() {
|
||||
|
||||
@@ -1,42 +1,57 @@
|
||||
/*
|
||||
* 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 mockScreenLock () {
|
||||
global.systemplugin.screenLock = {
|
||||
isScreenLocked: function (...args) {
|
||||
console.warn("screenLock.isScreenLocked interface mocked in the Previewer. How this interface works on the" +
|
||||
" Previewer may be different from that on a real device.")
|
||||
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);
|
||||
})
|
||||
}
|
||||
},
|
||||
isSecureMode: function (...args) {
|
||||
console.warn("screenLock.isSecureMode interface mocked in the Previewer. How this interface works on the" +
|
||||
" Previewer may be different 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);
|
||||
})
|
||||
}
|
||||
},
|
||||
unlockScreen: function (...args) {
|
||||
console.warn("screenLock.unlockScreen interface mocked in the Previewer. How this interface works on the" +
|
||||
" Previewer may be different from that on a real device.")
|
||||
const len = args.length
|
||||
if (typeof args[len - 1] === 'function') {
|
||||
args[len - 1].call(this, paramMock.businessErrorMock)
|
||||
} else {
|
||||
return new Promise((resolve) => {
|
||||
resolve();
|
||||
})
|
||||
}
|
||||
}
|
||||
export function mockScreenLock() {
|
||||
global.systemplugin.screenLock = {
|
||||
isScreenLocked: function (...args) {
|
||||
console.warn("screenLock.isScreenLocked interface mocked in the Previewer. How this interface works on the" +
|
||||
" Previewer may be different from that on a real device.")
|
||||
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);
|
||||
})
|
||||
}
|
||||
},
|
||||
isSecureMode: function (...args) {
|
||||
console.warn("screenLock.isSecureMode interface mocked in the Previewer. How this interface works on the" +
|
||||
" Previewer may be different 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);
|
||||
})
|
||||
}
|
||||
},
|
||||
unlockScreen: function (...args) {
|
||||
console.warn("screenLock.unlockScreen interface mocked in the Previewer. How this interface works on the" +
|
||||
" Previewer may be different from that on a 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();
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,22 +1,37 @@
|
||||
/*
|
||||
* 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 mockScreenshot() {
|
||||
const screenshotMock = {
|
||||
ImageSource: '[PC preview] unknow ImageSource'
|
||||
}
|
||||
const screenshotMock = {
|
||||
ImageSource: '[PC preview] unknow ImageSource'
|
||||
}
|
||||
|
||||
global.systemplugin.screenshot = {
|
||||
save: function (...args) {
|
||||
console.warn("screenshot.save interface mocked in the Previewer. How this interface works on the Previewer" +
|
||||
" may be different from that on a real device.")
|
||||
const len = args.length
|
||||
if (typeof args[len - 1] === 'function') {
|
||||
args[len - 1].call(this, paramMock.businessErrorMock, screenshotMock)
|
||||
} else {
|
||||
return new Promise((resolve, reject) => {
|
||||
resolve(screenshotMock)
|
||||
})
|
||||
}
|
||||
}
|
||||
global.systemplugin.screenshot = {
|
||||
save: function (...args) {
|
||||
console.warn("screenshot.save interface mocked in the Previewer. How this interface works on the Previewer" +
|
||||
" may be different from that on a real device.")
|
||||
const len = args.length
|
||||
if (typeof args[len - 1] === 'function') {
|
||||
args[len - 1].call(this, paramMock.businessErrorMock, screenshotMock)
|
||||
} else {
|
||||
return new Promise((resolve, reject) => {
|
||||
resolve(screenshotMock)
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,4 +1,19 @@
|
||||
import {getRandomArbitrary, hasComplete, paramMock} from './utils'
|
||||
/*
|
||||
* 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 { getRandomArbitrary, hasComplete, paramMock } from './utils'
|
||||
|
||||
export function mockSensor() {
|
||||
global.systemplugin.sensor = {}
|
||||
@@ -18,7 +33,7 @@ export function mockSensor() {
|
||||
}
|
||||
|
||||
function mockAccelerometer() {
|
||||
global.systemplugin.sensor.subscribeAccelerometer = function(...args) {
|
||||
global.systemplugin.sensor.subscribeAccelerometer = function (...args) {
|
||||
console.warn("sensor.subscribeAccelerometer interface mocked in the Previewer. How this interface works on the" +
|
||||
" Previewer may be different from that on a real device.")
|
||||
const time = {
|
||||
@@ -42,7 +57,7 @@ function mockAccelerometer() {
|
||||
args[0].success(ret)
|
||||
}, timer)
|
||||
}
|
||||
global.systemplugin.sensor.unsubscribeAccelerometer = function() {
|
||||
global.systemplugin.sensor.unsubscribeAccelerometer = function () {
|
||||
console.warn("sensor.unsubscribeAccelerometer interface mocked in the Previewer. How this interface works on" +
|
||||
" the Previewer may be different from that on a real device.")
|
||||
clearInterval(this.unsubscribeAcc)
|
||||
@@ -51,7 +66,7 @@ function mockAccelerometer() {
|
||||
}
|
||||
|
||||
function mockBarometer() {
|
||||
global.systemplugin.sensor.subscribeBarometer = function(...args) {
|
||||
global.systemplugin.sensor.subscribeBarometer = function (...args) {
|
||||
console.warn("sensor.subscribeBarometer interface mocked in the Previewer. How this interface works on the" +
|
||||
" Previewer may be different from that on a real device.")
|
||||
if (!this.unsubscribePressure) {
|
||||
@@ -62,7 +77,7 @@ function mockBarometer() {
|
||||
}, 500)
|
||||
}
|
||||
}
|
||||
global.systemplugin.sensor.unsubscribeBarometer = function() {
|
||||
global.systemplugin.sensor.unsubscribeBarometer = function () {
|
||||
console.warn("sensor.unsubscribeBarometer interface mocked in the Previewer. How this interface works on the" +
|
||||
" Previewer may be different from that on a real device.")
|
||||
clearInterval(this.unsubscribePressure)
|
||||
@@ -71,7 +86,7 @@ function mockBarometer() {
|
||||
}
|
||||
|
||||
function mockCompass() {
|
||||
global.systemplugin.sensor.subscribeCompass = function(...args) {
|
||||
global.systemplugin.sensor.subscribeCompass = function (...args) {
|
||||
console.warn("sensor.subscribeCompass interface mocked in the Previewer. How this interface works on the" +
|
||||
" Previewer may be different from that on a real device.")
|
||||
if (!this.unsubscribeDirection) {
|
||||
@@ -82,7 +97,7 @@ function mockCompass() {
|
||||
}, 100)
|
||||
}
|
||||
}
|
||||
global.systemplugin.sensor.unsubscribeCompass = function() {
|
||||
global.systemplugin.sensor.unsubscribeCompass = function () {
|
||||
console.warn("sensor.unsubscribeCompass interface mocked in the Previewer. How this interface works on the" +
|
||||
" Previewer may be different from that on a real device.")
|
||||
clearInterval(this.unsubscribeDirection)
|
||||
@@ -91,7 +106,7 @@ function mockCompass() {
|
||||
}
|
||||
|
||||
function mockGyroscope() {
|
||||
global.systemplugin.sensor.subscribeGyroscope = function(...args) {
|
||||
global.systemplugin.sensor.subscribeGyroscope = function (...args) {
|
||||
console.warn("sensor.subscribeGyroscope interface mocked in the Previewer. How this interface works on the" +
|
||||
" Previewer may be different from that on a real device.")
|
||||
const time = {
|
||||
@@ -115,7 +130,7 @@ function mockGyroscope() {
|
||||
args[0].success(ret)
|
||||
}, timer)
|
||||
}
|
||||
global.systemplugin.sensor.unsubscribeGyroscope = function() {
|
||||
global.systemplugin.sensor.unsubscribeGyroscope = function () {
|
||||
console.warn("sensor.unsubscribeGyroscope interface mocked in the Previewer. How this interface works on the" +
|
||||
" Previewer may be different from that on a real device.")
|
||||
clearInterval(this.unsubscribeGyr)
|
||||
@@ -124,7 +139,7 @@ function mockGyroscope() {
|
||||
}
|
||||
|
||||
function mockDeviceOrientation() {
|
||||
global.systemplugin.sensor.subscribeDeviceOrientation = function(...args) {
|
||||
global.systemplugin.sensor.subscribeDeviceOrientation = function (...args) {
|
||||
console.warn("sensor.subscribeDeviceOrientation interface mocked in the Previewer. How this interface works on" +
|
||||
" the Previewer may be different from that on a real device.")
|
||||
const time = {
|
||||
@@ -148,7 +163,7 @@ function mockDeviceOrientation() {
|
||||
args[0].success(ret)
|
||||
}, timer)
|
||||
}
|
||||
global.systemplugin.sensor.unsubscribeDeviceOrientation = function() {
|
||||
global.systemplugin.sensor.unsubscribeDeviceOrientation = function () {
|
||||
console.warn("sensor.unsubscribeDeviceOrientation interface mocked in the Previewer. How this interface works" +
|
||||
" on the Previewer may be different from that on a real device.")
|
||||
clearInterval(this.unsubscribeDevOri)
|
||||
@@ -157,7 +172,7 @@ function mockDeviceOrientation() {
|
||||
}
|
||||
|
||||
function mockHeartRate() {
|
||||
global.systemplugin.sensor.subscribeHeartRate = function(...args) {
|
||||
global.systemplugin.sensor.subscribeHeartRate = function (...args) {
|
||||
console.warn("sensor.subscribeHeartRate interface mocked in the Previewer. How this interface works on the" +
|
||||
" Previewer may be different from that on a real device.")
|
||||
if (!this.unsubscribeRate) {
|
||||
@@ -167,8 +182,8 @@ function mockHeartRate() {
|
||||
args[0].success(ret)
|
||||
}, 500)
|
||||
}
|
||||
},
|
||||
global.systemplugin.sensor.unsubscribeHeartRate = function() {
|
||||
}
|
||||
global.systemplugin.sensor.unsubscribeHeartRate = function () {
|
||||
console.warn("sensor.unsubscribeHeartRate interface mocked in the Previewer. How this interface works on the" +
|
||||
" Previewer may be different from that on a real device.")
|
||||
clearInterval(this.unsubscribeRate)
|
||||
@@ -177,7 +192,7 @@ function mockHeartRate() {
|
||||
}
|
||||
|
||||
function mockLight() {
|
||||
global.systemplugin.sensor.subscribeLight = function(...args) {
|
||||
global.systemplugin.sensor.subscribeLight = function (...args) {
|
||||
console.warn("sensor.subscribeLight interface mocked in the Previewer. How this interface works on the" +
|
||||
" Previewer may be different from that on a real device.")
|
||||
if (!this.unsubscribeIntensity) {
|
||||
@@ -188,7 +203,7 @@ function mockLight() {
|
||||
}, 500)
|
||||
}
|
||||
}
|
||||
global.systemplugin.sensor.unsubscribeLight = function() {
|
||||
global.systemplugin.sensor.unsubscribeLight = function () {
|
||||
console.warn("sensor.unsubscribeLight interface mocked in the Previewer. How this interface works on the" +
|
||||
" Previewer may be different from that on a real device.")
|
||||
clearInterval(this.unsubscribeIntensity)
|
||||
@@ -197,7 +212,7 @@ function mockLight() {
|
||||
}
|
||||
|
||||
function mockOnBodyState() {
|
||||
global.systemplugin.sensor.subscribeOnBodyState = function(...args) {
|
||||
global.systemplugin.sensor.subscribeOnBodyState = function (...args) {
|
||||
console.warn("sensor.subscribeOnBodyState interface mocked in the Previewer. How this interface works on the" +
|
||||
" Previewer may be different from that on a real device.")
|
||||
if (!this.unsubscribeBodyState) {
|
||||
@@ -208,7 +223,7 @@ function mockOnBodyState() {
|
||||
}, 500)
|
||||
}
|
||||
}
|
||||
global.systemplugin.sensor.unsubscribeOnBodyState = function() {
|
||||
global.systemplugin.sensor.unsubscribeOnBodyState = function () {
|
||||
console.warn("sensor.unsubscribeOnBodyState interface mocked in the Previewer. How this interface works on the" +
|
||||
" Previewer may be different from that on a real device.")
|
||||
clearInterval(this.unsubscribeBodyState)
|
||||
@@ -226,7 +241,7 @@ function mockOnBodyState() {
|
||||
}
|
||||
|
||||
function mockProximity() {
|
||||
global.systemplugin.sensor.subscribeProximity = function(...args) {
|
||||
global.systemplugin.sensor.subscribeProximity = function (...args) {
|
||||
console.warn("sensor.subscribeProximity interface mocked in the Previewer. How this interface works on the" +
|
||||
" Previewer may be different from that on a real device.")
|
||||
if (!this.unsubscribeDistance) {
|
||||
@@ -237,7 +252,7 @@ function mockProximity() {
|
||||
}, 1000)
|
||||
}
|
||||
}
|
||||
global.systemplugin.sensor.unsubscribeProximity = function() {
|
||||
global.systemplugin.sensor.unsubscribeProximity = function () {
|
||||
console.warn("sensor.unsubscribeProximity interface mocked in the Previewer. How this interface works on the" +
|
||||
" Previewer may be different from that on a real device.")
|
||||
clearInterval(this.unsubscribeDistance)
|
||||
@@ -246,18 +261,18 @@ function mockProximity() {
|
||||
}
|
||||
|
||||
function mockStepCounter() {
|
||||
global.systemplugin.sensor.subscribeStepCounter = function(...args) {
|
||||
global.systemplugin.sensor.subscribeStepCounter = function (...args) {
|
||||
console.warn("sensor.subscribeStepCounter interface mocked in the Previewer. How this interface works on the" +
|
||||
" Previewer may be different from that on a real device.")
|
||||
if (!this.unsubscribeSteps) {
|
||||
let ret = {steps: 0}
|
||||
let ret = { steps: 0 }
|
||||
this.unsubscribeSteps = setInterval(() => {
|
||||
ret.steps += 1
|
||||
args[0].success(ret)
|
||||
}, 1000)
|
||||
}
|
||||
}
|
||||
global.systemplugin.sensor.unsubscribeStepCounter = function() {
|
||||
global.systemplugin.sensor.unsubscribeStepCounter = function () {
|
||||
console.warn("sensor.unsubscribeStepCounter interface mocked in the Previewer. How this interface works on the" +
|
||||
" Previewer may be different from that on a real device.")
|
||||
clearInterval(this.unsubscribeSteps)
|
||||
@@ -266,7 +281,7 @@ function mockStepCounter() {
|
||||
}
|
||||
|
||||
function mockGravity() {
|
||||
global.systemplugin.sensor.subscribeGravity = function(...args) {
|
||||
global.systemplugin.sensor.subscribeGravity = function (...args) {
|
||||
console.warn("sensor.subscribeGravity interface mocked in the Previewer. How this interface works on" +
|
||||
" the Previewer may be different from that on a real device.")
|
||||
const time = {
|
||||
@@ -290,7 +305,7 @@ function mockGravity() {
|
||||
args[0].success(ret)
|
||||
}, timer)
|
||||
}
|
||||
global.systemplugin.sensor.unsubscribeGravity = function() {
|
||||
global.systemplugin.sensor.unsubscribeGravity = function () {
|
||||
console.warn("sensor.unsubscribeGravity interface mocked in the Previewer. How this interface works" +
|
||||
" on the Previewer may be different from that on a real device.")
|
||||
clearInterval(this.unsubscribeGrav)
|
||||
@@ -299,7 +314,7 @@ function mockGravity() {
|
||||
}
|
||||
|
||||
function mockMagnetic() {
|
||||
global.systemplugin.sensor.subscribeMagnetic = function(...args) {
|
||||
global.systemplugin.sensor.subscribeMagnetic = function (...args) {
|
||||
console.warn("sensor.subscribeMagnetic interface mocked in the Previewer. How this interface works on" +
|
||||
" the Previewer may be different from that on a real device.")
|
||||
const time = {
|
||||
@@ -323,7 +338,7 @@ function mockMagnetic() {
|
||||
args[0].success(ret)
|
||||
}, timer)
|
||||
}
|
||||
global.systemplugin.sensor.unsubscribeMagnetic = function() {
|
||||
global.systemplugin.sensor.unsubscribeMagnetic = function () {
|
||||
console.warn("sensor.unsubscribeMagnetic interface mocked in the Previewer. How this interface works" +
|
||||
" on the Previewer may be different from that on a real device.")
|
||||
clearInterval(this.unsubscribeMag)
|
||||
@@ -332,7 +347,7 @@ function mockMagnetic() {
|
||||
}
|
||||
|
||||
function mockHall() {
|
||||
global.systemplugin.sensor.subscribeHall = function(...args) {
|
||||
global.systemplugin.sensor.subscribeHall = function (...args) {
|
||||
console.warn("sensor.subscribeHall interface mocked in the Previewer. How this interface works on" +
|
||||
" the Previewer may be different from that on a real device.")
|
||||
const time = {
|
||||
@@ -354,7 +369,7 @@ function mockHall() {
|
||||
args[0].success(ret)
|
||||
}, timer)
|
||||
}
|
||||
global.systemplugin.sensor.unsubscribeHall = function() {
|
||||
global.systemplugin.sensor.unsubscribeHall = function () {
|
||||
console.warn("sensor.unsubscribeHall interface mocked in the Previewer. How this interface works" +
|
||||
" on the Previewer may be different from that on a real device.")
|
||||
clearInterval(this.unsubscribeHal)
|
||||
|
||||
@@ -1,30 +1,45 @@
|
||||
/*
|
||||
* Copyright (c) 2021 Huawei Device Co., Ltd.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import { hasComplete } from "./utils"
|
||||
|
||||
export function mockStorage() {
|
||||
global.systemplugin.storage = {
|
||||
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.")
|
||||
args[0].success("[PC Preview]: no system")
|
||||
hasComplete(args[0].complete)
|
||||
},
|
||||
set: function(...args) {
|
||||
console.warn("storage.set interface mocked in the Previewer. How this interface works on the Previewer may be" +
|
||||
" different from that on a real device.")
|
||||
args[0].success("[PC Preview]: no system")
|
||||
hasComplete(args[0].complete)
|
||||
},
|
||||
clear: function(...args) {
|
||||
console.warn("storage.clear interface mocked in the Previewer. How this interface works on the Previewer may be" +
|
||||
" different from that on a real device.")
|
||||
args[0].success("[PC Preview]: no system")
|
||||
hasComplete(args[0].complete)
|
||||
},
|
||||
delete: function(...args) {
|
||||
console.warn("storage.delete interface mocked in the Previewer. How this interface works on the Previewer may be" +
|
||||
" different from that on a real device.")
|
||||
args[0].success("[PC Preview]: no system")
|
||||
hasComplete(args[0].complete)
|
||||
}
|
||||
global.systemplugin.storage = {
|
||||
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.")
|
||||
args[0].success("[PC Preview]: no system")
|
||||
hasComplete(args[0].complete)
|
||||
},
|
||||
set: function (...args) {
|
||||
console.warn("storage.set interface mocked in the Previewer. How this interface works on the Previewer may be" +
|
||||
" different from that on a real device.")
|
||||
args[0].success("[PC Preview]: no system")
|
||||
hasComplete(args[0].complete)
|
||||
},
|
||||
clear: function (...args) {
|
||||
console.warn("storage.clear interface mocked in the Previewer. How this interface works on the Previewer may be" +
|
||||
" different from that on a real device.")
|
||||
args[0].success("[PC Preview]: no system")
|
||||
hasComplete(args[0].complete)
|
||||
},
|
||||
delete: function (...args) {
|
||||
console.warn("storage.delete interface mocked in the Previewer. How this interface works on the Previewer may be" +
|
||||
" different from that on a real device.")
|
||||
args[0].success("[PC Preview]: no system")
|
||||
hasComplete(args[0].complete)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user