mirror of
https://github.com/openharmony/third_party_jsframework.git
synced 2026-07-19 14:33:33 -04:00
Merge code to master
Signed-off-by: sunfei <sunfei.sun@huawei.com> Change-Id: I5a1d9297c3236ecdd06304d1efcac2b37647ee14
This commit is contained in:
@@ -17,6 +17,8 @@ import("//foundation/ace/ace_engine/ace_config.gni")
|
||||
|
||||
prebuilt_js_path =
|
||||
get_label_info(":gen_jsf_c", "target_out_dir") + "/dist/strip.native.min.js"
|
||||
prebuilt_js_api_mock_path = get_label_info(":gen_jsf_c", "target_out_dir") +
|
||||
"/dist/jsMockSystemPlugin.js"
|
||||
|
||||
#snapshot_path =
|
||||
# get_label_info(":gen_snapshot", "target_out_dir") + "/strip.native.min.js"
|
||||
@@ -158,7 +160,10 @@ action("gen_snapshot") {
|
||||
"tsconfig.json",
|
||||
"tslint.json",
|
||||
]
|
||||
outputs = [ prebuilt_js_path ]
|
||||
outputs = [
|
||||
prebuilt_js_path,
|
||||
prebuilt_js_api_mock_path,
|
||||
]
|
||||
}
|
||||
|
||||
jsfc_path = get_label_info(":jsf", "target_out_dir") + "/src/jsf.c"
|
||||
|
||||
@@ -91,6 +91,7 @@ export function appCreate(page: Page, options: Options, data: object, services:
|
||||
return;
|
||||
}
|
||||
if (options.pcPreview && options.pcPreview === 'enable') {
|
||||
global.pcPreview = true;
|
||||
mockSystemPlugin();
|
||||
}
|
||||
const packageName: string = page.packageName;
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,12 +1,35 @@
|
||||
export function mockOhosBatteryinfo() {
|
||||
global.systemplugin.batteryInfo = {
|
||||
batterySOC: "[PC Preview] unknow batterySOC",
|
||||
chargingStatus: "[PC Preview] unknow chargingStatus",
|
||||
healthStatus: "[PC Preview] unknow healthStatus",
|
||||
pluggedType: "[PC Preview] unknow pluggedType",
|
||||
voltage: "[PC Preview] unknow voltage",
|
||||
technology: "[PC Preview] unknow technology",
|
||||
batteryTemperature: "[PC Preview] unknow batteryTemperature",
|
||||
isBatteryPresent: "[PC Preview] unknow isBatteryPresent"
|
||||
}
|
||||
}
|
||||
export function mockOhosBatteryinfo() {
|
||||
const BatteryPluggedType = {
|
||||
NONE: '[PC preview] unknow NONE',
|
||||
AC: '[PC preview] unknow AC',
|
||||
USB: '[PC preview] unknow USB',
|
||||
WIRELESS: '[PC preview] unknow WIRELESS'
|
||||
}
|
||||
const BatteryChargeState = {
|
||||
NONE: '[PC preview] unknow NONE',
|
||||
ENABLE: '[PC preview] unknow ENABLE',
|
||||
DISABLE: '[PC preview] unknow DISABLE',
|
||||
FULL: '[PC preview] unknow FULL'
|
||||
}
|
||||
const BatteryHealthState = {
|
||||
UNKNOWN: '[PC preview] unknow UNKNOWN',
|
||||
GOOD: '[PC preview] unknow GOOD',
|
||||
OVERHEAT: '[PC preview] unknow OVERHEAT',
|
||||
OVERVOLTAGE: '[PC preview] unknow OVERVOLTAGE',
|
||||
COLD: '[PC preview] unknow COLD',
|
||||
DEAD: '[PC preview] unknow DEAD'
|
||||
}
|
||||
global.systemplugin.batteryInfo = {
|
||||
BatteryPluggedType,
|
||||
BatteryChargeState,
|
||||
BatteryHealthState,
|
||||
batterySOC: "[PC Preview] unknow batterySOC",
|
||||
chargingStatus: "[PC Preview] unknow chargingStatus",
|
||||
healthStatus: "[PC Preview] unknow healthStatus",
|
||||
pluggedType: "[PC Preview] unknow pluggedType",
|
||||
voltage: "[PC Preview] unknow voltage",
|
||||
technology: "[PC Preview] unknow technology",
|
||||
batteryTemperature: "[PC Preview] unknow batteryTemperature",
|
||||
isBatteryPresent: "[PC Preview] unknow isBatteryPresent"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,216 @@
|
||||
import { paramMock } from "./utils"
|
||||
|
||||
export function mockContact () {
|
||||
const contactMock = {
|
||||
contactAttributes:"[PC Preview] unknow contactAttributes",
|
||||
id:"[PC Preview] unknow id",
|
||||
key:"[PC Preview] unknow key",
|
||||
emails:"[PC Preview] unknow emails",
|
||||
events:"[PC Preview] unknow events",
|
||||
groups:"[PC Preview] unknow groups",
|
||||
imAddresses:"[PC Preview] unknow imAddresses",
|
||||
phoneNumbers:"[PC Preview] unknow phoneNumbers",
|
||||
portrait:"[PC Preview] unknow portrait",
|
||||
postalAddresses:"[PC Preview] unknow postalAddresses",
|
||||
relations:"[PC Preview] unknow relations",
|
||||
sipAddresses:"[PC Preview] unknow sipAddresses",
|
||||
websites:"[PC Preview] unknow websites",
|
||||
name:"[PC Preview] unknow name",
|
||||
nickName:"[PC Preview] unknow nickName",
|
||||
note:"[PC Preview] unknow note",
|
||||
organization:"[PC Preview] unknow organization",
|
||||
}
|
||||
const holderMock = {
|
||||
holderId:"[PC Preview] unknow holderId",
|
||||
bundleName:"[PC Preview] unknow bundleName",
|
||||
displayName:"[PC Preview] unknow displayName",
|
||||
}
|
||||
const groupMock = {
|
||||
groupId:"[PC Preview] unknow groupId",
|
||||
title:"[PC Preview] unknow title"
|
||||
}
|
||||
global.systemplugin.contact = {
|
||||
addContact: function (...args) {
|
||||
console.warn("contact.addContact interface mocked in the Previewer. How this interface works on the" +
|
||||
" Previewer may be different from that on a real device.")
|
||||
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)
|
||||
});
|
||||
}
|
||||
},
|
||||
selectContact: function (...args) {
|
||||
console.warn("contact.selectContact 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(contactMock);
|
||||
const len = args.length
|
||||
if (typeof args[len - 1] === 'function') {
|
||||
args[len - 1].call(this, paramMock.businessErrorMock, array)
|
||||
} else {
|
||||
return new Promise((resolve) => {
|
||||
resolve(array)
|
||||
});
|
||||
}
|
||||
},
|
||||
deleteContact: function (...args) {
|
||||
console.warn("contact.deleteContact interface mocked in the Previewer. How this interface works on the" +
|
||||
" Previewer may be different from that on a 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()
|
||||
});
|
||||
}
|
||||
},
|
||||
queryContact: function (...args) {
|
||||
console.warn("contact.queryContact interface mocked in the Previewer. How this interface works on the" +
|
||||
" Previewer may be different from that on a real device.")
|
||||
const len = args.length
|
||||
if (typeof args[len - 1] === 'function') {
|
||||
args[len - 1].call(this, paramMock.businessErrorMock, contactMock)
|
||||
} else {
|
||||
return new Promise((resolve) => {
|
||||
resolve(contactMock)
|
||||
});
|
||||
}
|
||||
},
|
||||
queryContacts: function (...args) {
|
||||
console.warn("contact.queryContacts 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(contactMock);
|
||||
const len = args.length
|
||||
if (typeof args[len - 1] === 'function') {
|
||||
args[len - 1].call(this, paramMock.businessErrorMock, array)
|
||||
} else {
|
||||
return new Promise((resolve) => {
|
||||
resolve(array)
|
||||
});
|
||||
}
|
||||
},
|
||||
queryContactsByEmail: function (...args) {
|
||||
console.warn("contact.queryContactsByEmail 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(contactMock);
|
||||
const len = args.length
|
||||
if (typeof args[len - 1] === 'function') {
|
||||
args[len - 1].call(this, paramMock.businessErrorMock, array)
|
||||
} else {
|
||||
return new Promise((resolve) => {
|
||||
resolve(array)
|
||||
});
|
||||
}
|
||||
},
|
||||
queryContactsByPhoneNumber: function (...args) {
|
||||
console.warn("contact.queryContactsByPhoneNumber 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(contactMock);
|
||||
const len = args.length
|
||||
if (typeof args[len - 1] === 'function') {
|
||||
args[len - 1].call(this, paramMock.businessErrorMock, array)
|
||||
} else {
|
||||
return new Promise((resolve) => {
|
||||
resolve(array)
|
||||
});
|
||||
}
|
||||
},
|
||||
queryGroups: function (...args) {
|
||||
console.warn("contact.queryGroups 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(groupMock);
|
||||
const len = args.length
|
||||
if (typeof args[len - 1] === 'function') {
|
||||
args[len - 1].call(this, paramMock.businessErrorMock, array)
|
||||
} else {
|
||||
return new Promise((resolve) => {
|
||||
resolve(array)
|
||||
});
|
||||
}
|
||||
},
|
||||
queryHolders: function (...args) {
|
||||
console.warn("contact.queryHolders 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(holderMock);
|
||||
const len = args.length
|
||||
if (typeof args[len - 1] === 'function') {
|
||||
args[len - 1].call(this, paramMock.businessErrorMock, array)
|
||||
} else {
|
||||
return new Promise((resolve) => {
|
||||
resolve(array)
|
||||
});
|
||||
}
|
||||
},
|
||||
queryKey: function (...args) {
|
||||
console.warn("contact.queryKey interface mocked in the Previewer. How this interface works on the" +
|
||||
" Previewer may be different 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)
|
||||
});
|
||||
}
|
||||
},
|
||||
queryMyCard: function (...args) {
|
||||
console.warn("contact.queryMyCard 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(contactMock);
|
||||
const len = args.length
|
||||
if (typeof args[len - 1] === 'function') {
|
||||
args[len - 1].call(this, paramMock.businessErrorMock, array)
|
||||
} else {
|
||||
return new Promise((resolve) => {
|
||||
resolve(array)
|
||||
});
|
||||
}
|
||||
},
|
||||
updateContact: function (...args) {
|
||||
console.warn("contact.updateContact interface mocked in the Previewer. How this interface works on the" +
|
||||
" Previewer may be different from that on a 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()
|
||||
});
|
||||
}
|
||||
},
|
||||
isLocalContact: function (...args) {
|
||||
console.warn("contact.isLocalContact interface mocked in the Previewer. How this interface works on the" +
|
||||
" Previewer may be different 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)
|
||||
});
|
||||
}
|
||||
},
|
||||
isMyCard: function (...args) {
|
||||
console.warn("contact.isMyCard interface mocked in the Previewer. How this interface works on the" +
|
||||
" Previewer may be different 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)
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -42,6 +42,19 @@ export function mockDistributedSchedule() {
|
||||
resolve(paramMock.paramStringMock)
|
||||
})
|
||||
}
|
||||
},
|
||||
queryRemoteAbilityByWant: function (...args) {
|
||||
console.warn("distributedSchedule.queryRemoteAbilityByWant interface mocked in the Previewer. " +
|
||||
"How this interface works on the Previewer" +
|
||||
" may be different from that on a real device.")
|
||||
const len = args.length
|
||||
if (typeof args[len - 1] === 'function') {
|
||||
args[len - 1].call(this, paramMock.businessErrorMock, paramMock.paramArrayMock)
|
||||
} else {
|
||||
return new Promise((resolve) => {
|
||||
resolve(paramMock.paramArrayMock)
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -3,13 +3,19 @@ import regeneratorRuntime from 'babel-runtime/regenerator'
|
||||
import {
|
||||
mockAbilityFeatureAbility,
|
||||
mockAbilityParticleAbility,
|
||||
mockAbilityFormManager
|
||||
mockAbilityFormManager,
|
||||
mockAbilityContinuationRegisterManager,
|
||||
mockAbilityDataUriUtils,
|
||||
mockAbilityAbilityAgent,
|
||||
mockAbilityFormBindingData
|
||||
} from './ability'
|
||||
import {mockAppAbilityManager} from './ohos/app'
|
||||
|
||||
import { mockBackgroundTaskManager } from './ohos/backgroundTaskManager'
|
||||
import { mockBattery } from './battery'
|
||||
import { mockBrightness } from './brightness'
|
||||
import { mockBluetooth } from './bluetooth'
|
||||
import { mockCall } from './telephony'
|
||||
import { mockCall, mockData, mockRadio, mockSim, mockSMS } from './telephony'
|
||||
import { mockCipher } from './cipher'
|
||||
import { mockDataStorage } from './data'
|
||||
import { mockDeviceInfo } from './deviceInfo'
|
||||
@@ -29,6 +35,8 @@ import {
|
||||
import { mockNetwork } from './network'
|
||||
import { mockNfcCardEmulation } from './nfc'
|
||||
import { mockNotification } from './notification'
|
||||
import { mockOhosNotification } from './ohos/notification'
|
||||
import { mockCommonEvent } from './ohos/commonEvent'
|
||||
import { mockOhosBatteryinfo } from './batteryinfo'
|
||||
import { mockOhosRequest } from './ohos/request'
|
||||
|
||||
@@ -36,14 +44,17 @@ import { mockPasteBoard } from './pasteboard'
|
||||
import { mockReminderAgent } from './ohos/reminderAgent'
|
||||
import { mockRequest } from './request'
|
||||
|
||||
import { mockResourceManager } from './resourceManager'
|
||||
|
||||
import { mockSensor } from './sensor'
|
||||
import { mockStorage } from './storage'
|
||||
import { mockStorageInfoManager} from './ohos/storageInfoManager'
|
||||
import { mockSystemPackage } from './systemPackage'
|
||||
|
||||
import { mockUserauth } from './userIAM'
|
||||
import { mockVibrator } from './vibrator'
|
||||
|
||||
import { mockWebSocket, mockHttp } from './net'
|
||||
import { mockWebSocket, mockHttp, mockMdns, mockSocket } from './net'
|
||||
import { mockWifi } from './wifi'
|
||||
import { mockWindow } from './window'
|
||||
|
||||
@@ -52,6 +63,10 @@ import { mockAccessibility } from './accessibility'
|
||||
import { mockAI } from './ai'
|
||||
import { mockDisplay } from './display'
|
||||
import { mockDeviceManager } from './deviceManager'
|
||||
import { mockScreenshot } from './screenshot'
|
||||
import {mockContact} from './contact'
|
||||
import {mockScreenLock} from "./screenLock"
|
||||
import {mockSettings} from "./settings"
|
||||
|
||||
export function mockSystemPlugin() {
|
||||
global.regeneratorRuntime = regeneratorRuntime
|
||||
@@ -60,6 +75,8 @@ export function mockSystemPlugin() {
|
||||
global.ohosplugin = {}
|
||||
|
||||
mockNotification()
|
||||
mockOhosNotification()
|
||||
mockCommonEvent()
|
||||
mockFetch()
|
||||
mockRequest()
|
||||
mockStorage()
|
||||
@@ -85,20 +102,38 @@ export function mockSystemPlugin() {
|
||||
mockMultimediaMedia()
|
||||
mockMultimediaMedialibrary()
|
||||
mockCall()
|
||||
mockData()
|
||||
mockRadio()
|
||||
mockSim()
|
||||
mockSMS()
|
||||
mockWebSocket()
|
||||
mockHttp()
|
||||
mockMdns()
|
||||
mockSocket()
|
||||
mockDeviceInfo()
|
||||
mockWifi()
|
||||
mockResourceManager()
|
||||
mockNfcCardEmulation()
|
||||
mockDataStorage()
|
||||
mockWindow()
|
||||
mockAbilityFeatureAbility()
|
||||
mockAbilityContinuationRegisterManager()
|
||||
mockReminderAgent()
|
||||
mockRequireNapiFun()
|
||||
mockAbilityDataUriUtils()
|
||||
mockAccessibility()
|
||||
mockAbilityParticleAbility()
|
||||
mockAbilityFormManager()
|
||||
mockAbilityAbilityAgent()
|
||||
mockAbilityFormBindingData()
|
||||
mockAI()
|
||||
mockDisplay()
|
||||
mockDeviceManager()
|
||||
mockScreenshot()
|
||||
mockBackgroundTaskManager()
|
||||
mockStorageInfoManager()
|
||||
mockContact()
|
||||
mockScreenLock()
|
||||
mockSettings()
|
||||
mockAppAbilityManager()
|
||||
}
|
||||
|
||||
@@ -1,237 +1,545 @@
|
||||
import { paramMock } from "./utils"
|
||||
|
||||
export function mockMultimediaImage() {
|
||||
global.systemplugin.multimedia = {}
|
||||
const sizeMock = {
|
||||
height: "[PC Preview] unknow height",
|
||||
width: "[PC Preview] unknow width"
|
||||
}
|
||||
const imageInfoMock = {
|
||||
size: sizeMock,
|
||||
pixelFortmat: "[PC Preview] unknow pixelFortmat",
|
||||
colorSpace: "[PC Preview] unknow colorSpace",
|
||||
alphaType: "[PC Preview] unknow alphaType"
|
||||
}
|
||||
const imageSourceMock = {
|
||||
getImageInfo: function (...args) {
|
||||
console.warn("ImageSource.getImageInfo interface mocked in the Previewer. How this interface works on the" +
|
||||
" Previewer may be different from that on a real device.")
|
||||
const len = args.length
|
||||
if (typeof args[len - 1] === 'function') {
|
||||
args[len - 1].call(this, paramMock.businessErrorMock, imageInfoMock);
|
||||
} else {
|
||||
return new Promise((resolve, reject) => {
|
||||
resolve(imageInfoMock);
|
||||
})
|
||||
}
|
||||
},
|
||||
release: function (...args) {
|
||||
console.warn("ImageSource.release interface mocked in the Previewer. How this interface works on the Previewer" +
|
||||
" may be different from that on a real device.")
|
||||
const len = args.length
|
||||
if (typeof args[len - 1] === 'function') {
|
||||
args[len - 1].call(this, paramMock.businessErrorMock);
|
||||
} else {
|
||||
return new Promise((resolve, reject) => {
|
||||
resolve();
|
||||
})
|
||||
}
|
||||
},
|
||||
supportedFormats: "[PC Preview] unknow supportedFormats"
|
||||
}
|
||||
const imagePackerMock = {
|
||||
packing: function (...args) {
|
||||
console.warn("ImagePacker.packing interface mocked in the Previewer. How this interface works on the Previewer" +
|
||||
" may be different from that on a real device.")
|
||||
const len = args.length
|
||||
if (typeof args[len - 1] === 'function') {
|
||||
args[len - 1].call(this, paramMock.businessErrorMock, paramMock.paramArrayMock);
|
||||
} else {
|
||||
return new Promise((resolve, reject) => {
|
||||
resolve(paramMock.paramArrayMock);
|
||||
})
|
||||
}
|
||||
},
|
||||
release: function (...args) {
|
||||
console.warn("ImagePacker.release interface mocked in the Previewer. How this interface works on the Previewer" +
|
||||
" may be different from that on a real device.")
|
||||
const len = args.length
|
||||
if (typeof args[len - 1] === 'function') {
|
||||
args[len - 1].call(this, paramMock.businessErrorMock);
|
||||
} else {
|
||||
return new Promise((resolve, reject) => {
|
||||
resolve();
|
||||
})
|
||||
}
|
||||
},
|
||||
supportedFormats: "[PC Preview] unknow supportedFormats"
|
||||
}
|
||||
global.systemplugin.multimedia.image = {
|
||||
createImageSource: function () {
|
||||
console.warn("multimedia.image.createImageSource interface mocked in the Previewer. How this interface works" +
|
||||
" on the Previewer may be different from that on a real device.")
|
||||
return imageSourceMock;
|
||||
},
|
||||
createImagePacker: function () {
|
||||
console.warn("multimedia.image.createImagePacker interface mocked in the Previewer. How this interface works" +
|
||||
" on the Previewer may be different from that on a real device.")
|
||||
return imagePackerMock;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
export function mockMultimediaMedia() {
|
||||
const audioPlayerMock = {
|
||||
play: function () {
|
||||
console.warn("AudioPlayer.play interface mocked in the Previewer. How this interface works on the Previewer" +
|
||||
" may be different from that on a real device.")
|
||||
return
|
||||
},
|
||||
pause: function () {
|
||||
console.warn("AudioPlayer.pause interface mocked in the Previewer. How this interface works on the Previewer" +
|
||||
" may be different from that on a real device.")
|
||||
return
|
||||
},
|
||||
stop: function () {
|
||||
console.warn("AudioPlayer.stop interface mocked in the Previewer. How this interface works on the Previewer" +
|
||||
" may be different from that on a real device.")
|
||||
return
|
||||
},
|
||||
seek: function (...args) {
|
||||
console.warn("AudioPlayer.seek interface mocked in the Previewer. How this interface works on the Previewer" +
|
||||
" may be different from that on a real device.")
|
||||
return
|
||||
},
|
||||
setVolume: function (...args) {
|
||||
console.warn("AudioPlayer.setVolume interface mocked in the Previewer. How this interface works on the" +
|
||||
" Previewer may be different from that on a real device.")
|
||||
return
|
||||
},
|
||||
release: function () {
|
||||
console.warn("AudioPlayer.release interface mocked in the Previewer. How this interface works on the Previewer" +
|
||||
" may be different from that on a real device.")
|
||||
return
|
||||
},
|
||||
src: "[PC Preview] unknow src",
|
||||
loop: "[PC Preview] unknow loop",
|
||||
currentTime: "[PC Preview] unknow currentTime",
|
||||
duration: "[PC Preview] unknow duration",
|
||||
state: "[PC Preview] unknow state",
|
||||
on: function (...args) {
|
||||
console.warn("AudioPlayer.on interface mocked in the Previewer. How this interface works on the Previewer may" +
|
||||
" be different from that on a real device.")
|
||||
const len = args.length
|
||||
if (typeof args[len - 1] === 'function') {
|
||||
if (args[0] == 'error') {
|
||||
args[len - 1].call(this, paramMock.businessErrorMock);
|
||||
} else if (args[0] == 'timeUpdate') {
|
||||
args[len - 1].call(this, paramMock.paramNumberMock);
|
||||
} else {
|
||||
args[len - 1].call(this);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
const audioRecorderMock = {
|
||||
prepare: function () {
|
||||
console.warn("AudioRecorder.prepare interface mocked in the Previewer. How this interface works on the" +
|
||||
" Previewer may be different from that on a real device.")
|
||||
},
|
||||
start: function () {
|
||||
console.warn("AudioRecorder.start interface mocked in the Previewer. How this interface works on the Previewer" +
|
||||
" may be different from that on a real device.")
|
||||
},
|
||||
pause: function () {
|
||||
console.warn("AudioRecorder.pause interface mocked in the Previewer. How this interface works on the Previewer" +
|
||||
" may be different from that on a real device.")
|
||||
},
|
||||
resume: function () {
|
||||
console.warn("AudioRecorder.resume interface mocked in the Previewer. How this interface works on the" +
|
||||
" Previewer may be different from that on a real device.")
|
||||
},
|
||||
stop: function () {
|
||||
console.warn("AudioRecorder.stop interface mocked in the Previewer. How this interface works on the Previewer" +
|
||||
" may be different from that on a real device.")
|
||||
},
|
||||
release: function () {
|
||||
console.warn("AudioRecorder.release interface mocked in the Previewer. How this interface works on the" +
|
||||
" Previewer may be different from that on a real device.")
|
||||
},
|
||||
reset: function () {
|
||||
console.warn("AudioRecorder.reset 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("AudioRecorder.on interface mocked in the Previewer. How this interface works on the Previewer" +
|
||||
" may be different from that on a real device.")
|
||||
const len = args.length
|
||||
if (typeof args[len - 1] === 'function') {
|
||||
if (args[0] == 'error') {
|
||||
args[len - 1].call(this, paramMock.businessErrorMock);
|
||||
} else {
|
||||
args[len - 1].call(this);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
global.systemplugin.multimedia.media = {
|
||||
createAudioPlayer: function () {
|
||||
console.warn("multimedia.media.createAudioPlayer interface mocked in the Previewer. How this interface works" +
|
||||
" on the Previewer may be different from that on a real device.")
|
||||
return audioPlayerMock;
|
||||
},
|
||||
createAudioRecorder: function () {
|
||||
console.warn("multimedia.media.createAudioRecorder interface mocked in the Previewer. How this interface works" +
|
||||
" on the Previewer may be different from that on a real device.")
|
||||
return audioRecorderMock;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
export function mockMultimediaMedialibrary() {
|
||||
const MediaLibraryMock = {
|
||||
storeMediaAsset: function (...args) {
|
||||
console.warn("MediaLibrary.storeMediaAsset interface mocked in the Previewer. How this interface works on the" +
|
||||
" Previewer may be different from that on a real device.")
|
||||
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);
|
||||
})
|
||||
}
|
||||
},
|
||||
startImagePreview: function (...args) {
|
||||
console.warn("MediaLibrary.startImagePreview interface mocked in the Previewer. How this interface works on" +
|
||||
" the Previewer may be different from that on a real device.")
|
||||
const len = args.length
|
||||
if (typeof args[len - 1] === 'function') {
|
||||
args[len - 1].call(this, paramMock.businessErrorMock);
|
||||
} else {
|
||||
return new Promise((resolve, reject) => {
|
||||
resolve();
|
||||
})
|
||||
}
|
||||
},
|
||||
startMediaSelect: function (...args) {
|
||||
console.warn("MediaLibrary.startMediaSelect interface mocked in the Previewer. How this interface works on the" +
|
||||
" Previewer may be different from that on a real device.")
|
||||
const len = args.length
|
||||
if (typeof args[len - 1] === 'function') {
|
||||
args[len - 1].call(this, paramMock.businessErrorMock, paramMock.paramArrayMock);
|
||||
} else {
|
||||
return new Promise((resolve, reject) => {
|
||||
resolve(paramMock.paramArrayMock);
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
global.systemplugin.multimedia.mediaLibrary = {
|
||||
getMediaLibrary: function () {
|
||||
console.warn("multimedia.mediaLibrary.getMediaLibrary interface mocked in the Previewer. How this interface" +
|
||||
" works on the Previewer may be different from that on a real device.")
|
||||
return MediaLibraryMock;
|
||||
}
|
||||
}
|
||||
}
|
||||
import { paramMock } from "./utils"
|
||||
|
||||
const sizeMock = {
|
||||
height: "[PC Preview] unknow height",
|
||||
width: "[PC Preview] unknow width"
|
||||
}
|
||||
const imageInfoMock = {
|
||||
size: sizeMock,
|
||||
pixelFortmat: "[PC Preview] unknow pixelFortmat",
|
||||
colorSpace: "[PC Preview] unknow colorSpace",
|
||||
alphaType: "[PC Preview] unknow alphaType"
|
||||
}
|
||||
export const PixelMapMock = {
|
||||
isEditable: "[PC Preview]: unknow isEditable",
|
||||
readPixelsToBuffer: function (...args) {
|
||||
console.warn("PixelMap.readPixelsToBuffer interface mocked in the Previewer. How this interface works on the Previewer" +
|
||||
" may be different from that on a 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();
|
||||
})
|
||||
}
|
||||
},
|
||||
readPixels: function (...args) {
|
||||
console.warn("PixelMap.readPixels interface mocked in the Previewer. How this interface works on the Previewer" +
|
||||
" may be different from that on a 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();
|
||||
})
|
||||
}
|
||||
},
|
||||
writePixels: function (...args) {
|
||||
console.warn("PixelMap.writePixels interface mocked in the Previewer. How this interface works on the Previewer" +
|
||||
" may be different from that on a 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();
|
||||
})
|
||||
}
|
||||
},
|
||||
writeBufferToPixels: function (...args) {
|
||||
console.warn("PixelMap.writeBufferToPixels interface mocked in the Previewer. How this interface works on the Previewer" +
|
||||
" may be different from that on a 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();
|
||||
})
|
||||
}
|
||||
},
|
||||
getImageInfo: function (...args) {
|
||||
console.warn("PixelMap.getImageInfo interface mocked in the Previewer. How this interface works on the Previewer" +
|
||||
" may be different from that on a real device.")
|
||||
const len = args.length
|
||||
if (len > 0 && typeof args[len - 1] === 'function') {
|
||||
args[len - 1].call(this, paramMock.businessErrorMock, imageInfoMock);
|
||||
} else {
|
||||
return new Promise((resolve, reject) => {
|
||||
resolve(imageInfoMock);
|
||||
})
|
||||
}
|
||||
},
|
||||
getBytesNumberPerRow: function (...args) {
|
||||
console.warn("PixelMap.getBytesNumberPerRow interface mocked in the Previewer. How this interface works on the Previewer" +
|
||||
" may be different from that on a real device.")
|
||||
return paramMock.paramNumberMock
|
||||
},
|
||||
getPixelBytesNumber: function (...args) {
|
||||
console.warn("PixelMap.getPixelBytesNumber interface mocked in the Previewer. How this interface works on the Previewer" +
|
||||
" may be different from that on a real device.")
|
||||
return paramMock.paramNumberMock
|
||||
},
|
||||
release: function (...args) {
|
||||
console.warn("PixelMap.release interface mocked in the Previewer. How this interface works on the Previewer" +
|
||||
" may be different from that on a real device.")
|
||||
const len = args.length
|
||||
if (len > 0 && typeof args[len - 1] === 'function') {
|
||||
args[len - 1].call(this, paramMock.businessErrorMock);
|
||||
} else {
|
||||
return new Promise((resolve, reject) => {
|
||||
resolve();
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
export function mockMultimediaImage() {
|
||||
global.systemplugin.multimedia = {}
|
||||
const imageSourceMock = {
|
||||
getImageInfo: function (...args) {
|
||||
console.warn("ImageSource.getImageInfo interface mocked in the Previewer. How this interface works on the" +
|
||||
" Previewer may be different from that on a real device.")
|
||||
const len = args.length
|
||||
if (typeof args[len - 1] === 'function') {
|
||||
args[len - 1].call(this, paramMock.businessErrorMock, imageInfoMock);
|
||||
} else {
|
||||
return new Promise((resolve, reject) => {
|
||||
resolve(imageInfoMock);
|
||||
})
|
||||
}
|
||||
},
|
||||
release: function (...args) {
|
||||
console.warn("ImageSource.release interface mocked in the Previewer. How this interface works on the Previewer" +
|
||||
" may be different from that on a real device.")
|
||||
const len = args.length
|
||||
if (len > 0 && typeof args[len - 1] === 'function') {
|
||||
args[len - 1].call(this, paramMock.businessErrorMock);
|
||||
} else {
|
||||
return new Promise((resolve, reject) => {
|
||||
resolve();
|
||||
})
|
||||
}
|
||||
},
|
||||
createPixelMap: function (...args) {
|
||||
console.warn("ImageSource.createPixelMap interface mocked in the Previewer. How this interface works on the Previewer" +
|
||||
" may be different from that on a real device.")
|
||||
const len = args.length
|
||||
if (len > 0 && typeof args[len - 1] === 'function') {
|
||||
args[len - 1].call(this, paramMock.businessErrorMock, PixelMapMock);
|
||||
} else {
|
||||
return new Promise((resolve, reject) => {
|
||||
resolve(PixelMapMock);
|
||||
})
|
||||
}
|
||||
},
|
||||
getImageProperty: function (...args) {
|
||||
console.warn("ImageSource.getImageProperty interface mocked in the Previewer. How this interface works on the Previewer" +
|
||||
" may be different from 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);
|
||||
})
|
||||
}
|
||||
},
|
||||
supportedFormats: "[PC Preview] unknow supportedFormats"
|
||||
}
|
||||
const imagePackerMock = {
|
||||
packing: function (...args) {
|
||||
console.warn("ImagePacker.packing interface mocked in the Previewer. How this interface works on the Previewer" +
|
||||
" may be different from that on a real device.")
|
||||
const len = args.length
|
||||
if (typeof args[len - 1] === 'function') {
|
||||
args[len - 1].call(this, paramMock.businessErrorMock, paramMock.paramArrayMock);
|
||||
} else {
|
||||
return new Promise((resolve, reject) => {
|
||||
resolve(paramMock.paramArrayMock);
|
||||
})
|
||||
}
|
||||
},
|
||||
release: function (...args) {
|
||||
console.warn("ImagePacker.release interface mocked in the Previewer. How this interface works on the Previewer" +
|
||||
" may be different from that on a real device.")
|
||||
const len = args.length
|
||||
if (typeof args[len - 1] === 'function') {
|
||||
args[len - 1].call(this, paramMock.businessErrorMock);
|
||||
} else {
|
||||
return new Promise((resolve, reject) => {
|
||||
resolve();
|
||||
})
|
||||
}
|
||||
},
|
||||
supportedFormats: "[PC Preview] unknow supportedFormats"
|
||||
}
|
||||
const PixelMapFormatMock = {
|
||||
UNKNOWN: "[PC Preview]: unknow UNKNOWN",
|
||||
RGB_565: "[PC Preview]: unknow RGB_565",
|
||||
RGBA_8888: "[PC Preview]: unknow RGBA_8888",
|
||||
}
|
||||
const PropertyKeyMock = {
|
||||
BITS_PER_SAMPLE: "[PC Preview]: unknow BITS_PER_SAMPLE",
|
||||
ORIENTATION: "[PC Preview]: unknow ORIENTATION",
|
||||
IMAGE_LENGTH: "[PC Preview]: unknow IMAGE_LENGTH",
|
||||
GPS_LATITUDE: "[PC Preview]: unknow GPS_LATITUDE",
|
||||
GPS_LONGITUDE: "[PC Preview]: unknow GPS_LONGITUDE",
|
||||
GPS_LATITUDE_REF: "[PC Preview]: unknow GPS_LATITUDE_REF",
|
||||
GPS_LONGITUDE_REF: "[PC Preview]: unknow GPS_LONGITUDE_REF"
|
||||
}
|
||||
|
||||
global.systemplugin.multimedia.image = {
|
||||
PixelMapFormat: PixelMapFormatMock,
|
||||
PropertyKey: PropertyKeyMock,
|
||||
createImageSource: function () {
|
||||
console.warn("multimedia.image.createImageSource interface mocked in the Previewer. How this interface works" +
|
||||
" on the Previewer may be different from that on a real device.")
|
||||
return imageSourceMock;
|
||||
},
|
||||
createImagePacker: function () {
|
||||
console.warn("multimedia.image.createImagePacker interface mocked in the Previewer. How this interface works" +
|
||||
" on the Previewer may be different from that on a real device.")
|
||||
return imagePackerMock;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
export function mockMultimediaMedia() {
|
||||
const audioPlayerMock = {
|
||||
play: function () {
|
||||
console.warn("AudioPlayer.play interface mocked in the Previewer. How this interface works on the Previewer" +
|
||||
" may be different from that on a real device.")
|
||||
return
|
||||
},
|
||||
pause: function () {
|
||||
console.warn("AudioPlayer.pause interface mocked in the Previewer. How this interface works on the Previewer" +
|
||||
" may be different from that on a real device.")
|
||||
return
|
||||
},
|
||||
stop: function () {
|
||||
console.warn("AudioPlayer.stop interface mocked in the Previewer. How this interface works on the Previewer" +
|
||||
" may be different from that on a real device.")
|
||||
return
|
||||
},
|
||||
seek: function (...args) {
|
||||
console.warn("AudioPlayer.seek interface mocked in the Previewer. How this interface works on the Previewer" +
|
||||
" may be different from that on a real device.")
|
||||
return
|
||||
},
|
||||
setVolume: function (...args) {
|
||||
console.warn("AudioPlayer.setVolume interface mocked in the Previewer. How this interface works on the" +
|
||||
" Previewer may be different from that on a real device.")
|
||||
return
|
||||
},
|
||||
release: function () {
|
||||
console.warn("AudioPlayer.release interface mocked in the Previewer. How this interface works on the Previewer" +
|
||||
" may be different from that on a real device.")
|
||||
return
|
||||
},
|
||||
src: "[PC Preview] unknow src",
|
||||
loop: "[PC Preview] unknow loop",
|
||||
currentTime: "[PC Preview] unknow currentTime",
|
||||
duration: "[PC Preview] unknow duration",
|
||||
state: "[PC Preview] unknow state",
|
||||
on: function (...args) {
|
||||
console.warn("AudioPlayer.on interface mocked in the Previewer. How this interface works on the Previewer may" +
|
||||
" be different from that on a real device.")
|
||||
const len = args.length
|
||||
if (typeof args[len - 1] === 'function') {
|
||||
if (args[0] == 'error') {
|
||||
args[len - 1].call(this, paramMock.businessErrorMock);
|
||||
} else if (args[0] == 'timeUpdate') {
|
||||
args[len - 1].call(this, paramMock.paramNumberMock);
|
||||
} else {
|
||||
args[len - 1].call(this);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
const audioRecorderMock = {
|
||||
prepare: function () {
|
||||
console.warn("AudioRecorder.prepare interface mocked in the Previewer. How this interface works on the" +
|
||||
" Previewer may be different from that on a real device.")
|
||||
},
|
||||
start: function () {
|
||||
console.warn("AudioRecorder.start interface mocked in the Previewer. How this interface works on the Previewer" +
|
||||
" may be different from that on a real device.")
|
||||
},
|
||||
pause: function () {
|
||||
console.warn("AudioRecorder.pause interface mocked in the Previewer. How this interface works on the Previewer" +
|
||||
" may be different from that on a real device.")
|
||||
},
|
||||
resume: function () {
|
||||
console.warn("AudioRecorder.resume interface mocked in the Previewer. How this interface works on the" +
|
||||
" Previewer may be different from that on a real device.")
|
||||
},
|
||||
stop: function () {
|
||||
console.warn("AudioRecorder.stop interface mocked in the Previewer. How this interface works on the Previewer" +
|
||||
" may be different from that on a real device.")
|
||||
},
|
||||
release: function () {
|
||||
console.warn("AudioRecorder.release interface mocked in the Previewer. How this interface works on the" +
|
||||
" Previewer may be different from that on a real device.")
|
||||
},
|
||||
reset: function () {
|
||||
console.warn("AudioRecorder.reset 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("AudioRecorder.on interface mocked in the Previewer. How this interface works on the Previewer" +
|
||||
" may be different from that on a real device.")
|
||||
const len = args.length
|
||||
if (typeof args[len - 1] === 'function') {
|
||||
if (args[0] == 'error') {
|
||||
args[len - 1].call(this, paramMock.businessErrorMock);
|
||||
} else {
|
||||
args[len - 1].call(this);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
global.systemplugin.multimedia.media = {
|
||||
createAudioPlayer: function () {
|
||||
console.warn("multimedia.media.createAudioPlayer interface mocked in the Previewer. How this interface works" +
|
||||
" on the Previewer may be different from that on a real device.")
|
||||
return audioPlayerMock;
|
||||
},
|
||||
createAudioRecorder: function () {
|
||||
console.warn("multimedia.media.createAudioRecorder interface mocked in the Previewer. How this interface works" +
|
||||
" on the Previewer may be different from that on a real device.")
|
||||
return audioRecorderMock;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
export function mockMultimediaMedialibrary() {
|
||||
const FileAssetMock = {
|
||||
id: "[PC Preview] unknow id",
|
||||
uri: "[PC Preview] unknow uri",
|
||||
thumbnailUri: "[PC Preview] unknow thumbnailUri",
|
||||
mimeType: "[PC Preview] unknow mimeType",
|
||||
mediaType: "[PC Preview] unknow mediaType",
|
||||
displayName: "[PC Preview] unknow displayName",
|
||||
title: "[PC Preview] unknow title",
|
||||
size: "[PC Preview] unknow size",
|
||||
albumId: "[PC Preview] unknow albumId",
|
||||
albumName: "[PC Preview] unknow albumName",
|
||||
dateAdded: "[PC Preview] unknow dateAdded",
|
||||
dateModified: "[PC Preview] unknow dateMidified",
|
||||
dateTaken: "[PC Preview] unknow dateTaken",
|
||||
orientation: "[PC Preview] unknow orientation",
|
||||
width: "[PC Preview] unknow width",
|
||||
height: "[PC Preview] unknow height",
|
||||
extendedValues: "[PC Preview] unknow extendedValues",
|
||||
}
|
||||
const MediaLibraryMock = {
|
||||
storeMediaAsset: function (...args) {
|
||||
console.warn("MediaLibrary.storeMediaAsset interface mocked in the Previewer. How this interface works on the" +
|
||||
" Previewer may be different from that on a real device.")
|
||||
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);
|
||||
})
|
||||
}
|
||||
},
|
||||
startImagePreview: function (...args) {
|
||||
console.warn("MediaLibrary.startImagePreview interface mocked in the Previewer. How this interface works on" +
|
||||
" the Previewer may be different from that on a real device.")
|
||||
const len = args.length
|
||||
if (typeof args[len - 1] === 'function') {
|
||||
args[len - 1].call(this, paramMock.businessErrorMock);
|
||||
} else {
|
||||
return new Promise((resolve, reject) => {
|
||||
resolve();
|
||||
})
|
||||
}
|
||||
},
|
||||
startMediaSelect: function (...args) {
|
||||
console.warn("MediaLibrary.startMediaSelect interface mocked in the Previewer. How this interface works on the" +
|
||||
" Previewer may be different from that on a real device.")
|
||||
const len = args.length
|
||||
if (typeof args[len - 1] === 'function') {
|
||||
args[len - 1].call(this, paramMock.businessErrorMock, paramMock.paramArrayMock);
|
||||
} else {
|
||||
return new Promise((resolve, reject) => {
|
||||
resolve(paramMock.paramArrayMock);
|
||||
})
|
||||
}
|
||||
},
|
||||
getFileAssets: function (...args) {
|
||||
console.warn("MediaLibrary.getFileAssets interface mocked in the Previewer. How this interface works on the" +
|
||||
" Previewer may be different from that on a real device.")
|
||||
const len = args.length
|
||||
var isCallBack = typeof args[len - 1] === 'function'
|
||||
return isCallBack ? args[len - 1].call(this, paramMock.businessErrorMock, FetchFileResultMock)
|
||||
: new Promise((resolve, reject) => {
|
||||
resolve(FetchFileResultMock);
|
||||
})
|
||||
},
|
||||
getAlbums: function (...args) {
|
||||
console.warn("MediaLibrary.getAlbums interface mocked in the Previewer. How this interface works on the" +
|
||||
" Previewer may be different from that on a real device.")
|
||||
const len = args.length
|
||||
var albumsMock = new Array(AlbumMock)
|
||||
var isCallBack = typeof args[len - 1] === 'function'
|
||||
return isCallBack ? args[len - 1].call(this, paramMock.businessErrorMock, albumsMock)
|
||||
: new Promise((resolve, reject) => {
|
||||
resolve(albumsMock);
|
||||
})
|
||||
},
|
||||
on: function (...args) {
|
||||
console.warn("MediaLibrary.on interface mocked in the Previewer. How this interface works on the Previewer" +
|
||||
" may be different from that on a real device.")
|
||||
return
|
||||
},
|
||||
off: function (...args) {
|
||||
console.warn("MediaLibrary.off interface mocked in the Previewer. How this interface works on the Previewer" +
|
||||
" may be different from that on a real device.")
|
||||
return
|
||||
}
|
||||
}
|
||||
const FetchFileResultMock = {
|
||||
getCount: function (...args) {
|
||||
console.warn("FetchFileResult.getCount interface mocked in the Previewer. How this interface works on the" +
|
||||
" Previewer may be different from that on a real device.")
|
||||
return paramMock.paramNumberMock
|
||||
},
|
||||
isAfterLast: function (...args) {
|
||||
console.warn("FetchFileResult.isAfterLast interface mocked in the Previewer. How this interface works on the" +
|
||||
" Previewer may be different from that on a real device.")
|
||||
return paramMock.paramBooleanMock
|
||||
},
|
||||
close: function (...args) {
|
||||
console.warn("FetchFileResult.close interface mocked in the Previewer. How this interface works on the Previewer" +
|
||||
" may be different from that on a real device.")
|
||||
return
|
||||
},
|
||||
getFirstObject: function (...args) {
|
||||
console.warn("FetchFileResult.getFirstObject interface mocked in the Previewer. How this interface works on the" +
|
||||
" Previewer may be different from that on a real device.")
|
||||
const len = args.length
|
||||
var isCallBack = typeof args[len - 1] === 'function'
|
||||
return isCallBack ? args[len - 1].call(this, paramMock.businessErrorMock, FileAssetMock)
|
||||
: new Promise((resolve, reject) => {
|
||||
resolve(FileAssetMock);
|
||||
})
|
||||
},
|
||||
getLastObject: function (...args) {
|
||||
console.warn("FetchFileResult.getLastObject interface mocked in the Previewer. How this interface works on the" +
|
||||
" Previewer may be different from that on a real device.")
|
||||
const len = args.length
|
||||
var isCallBack = typeof args[len - 1] === 'function'
|
||||
return isCallBack ? args[len - 1].call(this, paramMock.businessErrorMock, FileAssetMock)
|
||||
: new Promise((resolve, reject) => {
|
||||
resolve(FileAssetMock);
|
||||
})
|
||||
},
|
||||
getNextObject: function (...args) {
|
||||
console.warn("FetchFileResult.getNextObject interface mocked in the Previewer. How this interface works on the" +
|
||||
" Previewer may be different from that on a real device.")
|
||||
const len = args.length
|
||||
var isCallBack = typeof args[len - 1] === 'function'
|
||||
return isCallBack ? args[len - 1].call(this, paramMock.businessErrorMock, FileAssetMock)
|
||||
: new Promise((resolve, reject) => {
|
||||
resolve(FileAssetMock);
|
||||
})
|
||||
},
|
||||
getPositionObject: function (...args) {
|
||||
console.warn("FetchFileResult.getPositionObject interface mocked in the Previewer. How this interface works on" +
|
||||
" the Previewer may be different from that on a real device.")
|
||||
const len = args.length
|
||||
var isCallBack = typeof args[len - 1] === 'function'
|
||||
return isCallBack ? args[len - 1].call(this, paramMock.businessErrorMock, FileAssetMock)
|
||||
: new Promise((resolve, reject) => {
|
||||
resolve(FileAssetMock);
|
||||
})
|
||||
},
|
||||
getAllObject: function (...args) {
|
||||
console.warn("FetchFileResult.getAllObject interface mocked in the Previewer. How this interface works on" +
|
||||
" the Previewer may be different from that on a real device.")
|
||||
const len = args.length
|
||||
var fileAssets = new Array(FileAssetMock)
|
||||
var isCallBack = typeof args[len - 1] === 'function'
|
||||
return isCallBack ? args[len - 1].call(this, paramMock.businessErrorMock, fileAssets)
|
||||
: new Promise((resolve, reject) => {
|
||||
resolve(fileAssets);
|
||||
})
|
||||
}
|
||||
}
|
||||
const AlbumMock = {
|
||||
albumId: "[PC Preview] unknow albumId",
|
||||
albumName: "[PC Preview] unknow albumName",
|
||||
path: "[PC Preview] unknow path",
|
||||
dateModified: "[PC Preview] unknow dateModified",
|
||||
getFileAssets: function (...args) {
|
||||
console.warn("Album.getFileAssets interface mocked in the Previewer. How this interface works on the" +
|
||||
" Previewer may be different from that on a real device.")
|
||||
const len = args.length
|
||||
var isCallBack = typeof args[len - 1] === 'function'
|
||||
return isCallBack ? args[len - 1].call(this, paramMock.businessErrorMock, FetchFileResultMock)
|
||||
: new Promise((resolve, reject) => {
|
||||
resolve(FetchFileResultMock);
|
||||
})
|
||||
}
|
||||
}
|
||||
const AVMetadataHelperMock = {
|
||||
setSource: function (...args) {
|
||||
console.warn("AVMetadataHelper.setSource interface mocked in the Previewer. How this interface works on the" +
|
||||
" Previewer may be different from that on a real device.")
|
||||
const len = args.length
|
||||
var isCallBack = typeof args[len - 1] === 'function'
|
||||
return isCallBack ? args[len - 1].call(this, paramMock.businessErrorMock)
|
||||
: new Promise((resolve, reject) => {
|
||||
resolve();
|
||||
})
|
||||
},
|
||||
fetchVideoPixelMapByTime: function (...args) {
|
||||
console.warn("AVMetadataHelper.fetchVideoPixelMapByTime interface mocked in the Previewer. How this interface" +
|
||||
" works on the Previewer may be different from that on a real device.")
|
||||
const len = args.length
|
||||
var isCallBack = typeof args[len - 1] === 'function'
|
||||
return isCallBack ? args[len - 1].call(this, paramMock.businessErrorMock, paramMock.paramObjectMock)
|
||||
: new Promise((resolve, reject) => {
|
||||
resolve(paramMock.paramObjectMock);
|
||||
})
|
||||
},
|
||||
resolveMetadata: function (...args) {
|
||||
console.warn("AVMetadataHelper.resolveMetadata interface mocked in the Previewer. How this interface" +
|
||||
" works on the Previewer may be different from that on a real device.")
|
||||
const len = args.length
|
||||
var isCallBack = typeof args[len - 1] === 'function'
|
||||
return isCallBack ? args[len - 1].call(this, paramMock.businessErrorMock, paramMock.paramStringMock)
|
||||
: new Promise((resolve, reject) => {
|
||||
resolve(paramMock.paramStringMock);
|
||||
})
|
||||
},
|
||||
release: function (...args) {
|
||||
console.warn("AVMetadataHelper.release interface mocked in the Previewer. How this interface works on the" +
|
||||
" Previewer may be different from that on a real device.")
|
||||
const len = args.length
|
||||
var isCallBack = typeof args[len - 1] === 'function'
|
||||
return isCallBack ? args[len - 1].call(this, paramMock.businessErrorMock)
|
||||
: new Promise((resolve, reject) => {
|
||||
resolve();
|
||||
})
|
||||
}
|
||||
}
|
||||
global.systemplugin.multimedia.mediaLibrary = {
|
||||
getMediaLibrary: function () {
|
||||
console.warn("multimedia.mediaLibrary.getMediaLibrary interface mocked in the Previewer. How this interface" +
|
||||
" works on the Previewer may be different from that on a real device.")
|
||||
return MediaLibraryMock;
|
||||
},
|
||||
createAVMetadataHelper: function () {
|
||||
console.warn("multimedia.mediaLibrary.createAVMetadataHelper interface mocked in the Previewer. How this" +
|
||||
" interface works on the Previewer may be different from that on a real device.")
|
||||
return AVMetadataHelperMock;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,19 @@
|
||||
import { paramMock } from "../utils"
|
||||
|
||||
export function mockBytrace() {
|
||||
const bytrace = {
|
||||
startTrace: function (...args) {
|
||||
console.warn("bytrace.startTrace interface mocked in the Previewer. How this interface works on the" +
|
||||
" Previewer may be different from that on a real device.")
|
||||
},
|
||||
finishTrace: function (...args) {
|
||||
console.warn("bytrace.finishTrace interface mocked in the Previewer. How this interface works on the" +
|
||||
" Previewer may be different from that on a real device.")
|
||||
},
|
||||
traceByValue: function (...args) {
|
||||
console.warn("bytrace.traceByValue interface mocked in the Previewer. How this interface works on the" +
|
||||
" Previewer may be different from that on a real device.")
|
||||
}
|
||||
}
|
||||
return bytrace
|
||||
}
|
||||
@@ -0,0 +1,47 @@
|
||||
import { paramMock } from "../utils"
|
||||
|
||||
function buildMockInfo(interfaceName) {
|
||||
return interfaceName + " interface mocked in the Previewer. How this interface works on the Previewer" +
|
||||
" may be different from that on a real device."
|
||||
}
|
||||
|
||||
export function 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 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
|
||||
}
|
||||
@@ -0,0 +1,32 @@
|
||||
import { paramMock } from "../utils"
|
||||
|
||||
export function mockHilog() {
|
||||
const hilog = {
|
||||
debug: function (...args) {
|
||||
console.warn("hilog.debug interface mocked in the Previewer. How this interface works on the" +
|
||||
" Previewer may be different from that on a real device.")
|
||||
},
|
||||
info: function (...args) {
|
||||
console.warn("hilog.info interface mocked in the Previewer. How this interface works on the" +
|
||||
" Previewer may be different from that on a real device.")
|
||||
},
|
||||
warn: function (...args) {
|
||||
console.warn("hilog.warn interface mocked in the Previewer. How this interface works on the" +
|
||||
" Previewer may be different from that on a real device.")
|
||||
},
|
||||
error: function (...args) {
|
||||
console.warn("hilog.error interface mocked in the Previewer. How this interface works on the" +
|
||||
" Previewer may be different from that on a real device.")
|
||||
},
|
||||
fatal: function (...args) {
|
||||
console.warn("hilog.fatal interface mocked in the Previewer. How this interface works on the" +
|
||||
" Previewer may be different from that on a real device.")
|
||||
},
|
||||
isLoggable: function (...args) {
|
||||
console.warn("hilog.isLoggable 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 hilog;
|
||||
}
|
||||
@@ -4,6 +4,15 @@ import { mockWorker } from './worker'
|
||||
import { mockUtil } from './util'
|
||||
import { mockPower } from './power'
|
||||
import { mockRunningLock } from './runningLock'
|
||||
import { mockRpc } from './rpc'
|
||||
import { mockBytrace } from './bytrace'
|
||||
import { mockwebgl } from './webgl'
|
||||
import { mockwebgl2 } from './webgl2'
|
||||
import { mockProcess } from './process'
|
||||
import { mockUrl } from './url'
|
||||
import { mockMediaQuery } from './mediaquery'
|
||||
import { mockHiAppEvent } from './hiAppEvent'
|
||||
import { mockHilog } from './hilog'
|
||||
|
||||
export function mockRequireNapiFun() {
|
||||
global.requireNapi = function (...args) {
|
||||
@@ -20,6 +29,24 @@ export function mockRequireNapiFun() {
|
||||
return mockPower();
|
||||
case "runningLock":
|
||||
return mockRunningLock();
|
||||
case "rpc":
|
||||
return mockRpc();
|
||||
case "webgl":
|
||||
return mockwebgl();
|
||||
case "webgl2":
|
||||
return mockwebgl2();
|
||||
case "process":
|
||||
return mockProcess();
|
||||
case "bytrace":
|
||||
return mockBytrace();
|
||||
case "url":
|
||||
return mockUrl();
|
||||
case "mediaquery":
|
||||
return mockMediaQuery();
|
||||
case "hiAppEvent":
|
||||
return mockHiAppEvent();
|
||||
case "hilog":
|
||||
return mockHilog();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,25 @@
|
||||
export function mockMediaQuery() {
|
||||
const mediaquery = {
|
||||
matchMediaSync: function (...args) {
|
||||
console.warn("mediaquery.matchMediaSync interface mocked in the Previewer." +
|
||||
" How this interface works on the Previewer may be different from that on a real device.")
|
||||
var listener = {
|
||||
on: function (...args) {
|
||||
console.warn("listener.on interface mocked in the Previewer." +
|
||||
" How this interface works on the Previewer may be different from that on a real device.")
|
||||
},
|
||||
off: function (...args) {
|
||||
console.warn("listener.off interface mocked in the Previewer." +
|
||||
" How this interface works on the Previewer may be different from that on a real device.")
|
||||
},
|
||||
matches:false,
|
||||
media:String
|
||||
};
|
||||
if (args.length === 1 && typeof args[0] === 'string') {
|
||||
listener.media = args[0];
|
||||
}
|
||||
return listener;
|
||||
}
|
||||
}
|
||||
return mediaquery
|
||||
}
|
||||
@@ -0,0 +1,93 @@
|
||||
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;
|
||||
},
|
||||
getEgid: '[PC preview] unknow getEgid',
|
||||
getEuid: '[PC preview] unknow getEuid',
|
||||
getGid: '[PC preview] unknow getGid',
|
||||
getUid: '[PC preview] unknow getUid',
|
||||
getGroups: '[PC preview] unknow getGroups',
|
||||
getPid: '[PC preview] unknow getPid',
|
||||
getPpid: '[PC preview] unknow getPpid',
|
||||
|
||||
}
|
||||
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;
|
||||
}
|
||||
@@ -0,0 +1,424 @@
|
||||
import { paramMock } from "../utils"
|
||||
|
||||
export function mockRpc() {
|
||||
const MessageParcel = {
|
||||
reclaim: function () {
|
||||
console.warn("rpc.reclaim interface mocked in the Previewer. How this interface works on the" +
|
||||
" Previewer may be different from that on a real device.")
|
||||
},
|
||||
writeRemoteObject: function (...args) {
|
||||
console.warn("rpc.writeRemoteObject interface mocked in the Previewer. How this interface works on the" +
|
||||
" Previewer may be different from that on a real device.")
|
||||
return paramMock.paramBooleanMock
|
||||
},
|
||||
readRemoteObject: function () {
|
||||
console.warn("rpc.readRemoteObject interface mocked in the Previewer. How this interface works on the" +
|
||||
" Previewer may be different from that on a real device.")
|
||||
return IRemoteObject
|
||||
},
|
||||
writeInterfaceToken: function (...args) {
|
||||
console.warn("rpc.writeInterfaceToken interface mocked in the Previewer. How this interface works on the" +
|
||||
" Previewer may be different from that on a real device.")
|
||||
return paramMock.paramBooleanMock
|
||||
},
|
||||
readInterfaceToken: function () {
|
||||
console.warn("rpc.readInterfaceToken interface mocked in the Previewer. How this interface works on the" +
|
||||
" Previewer may be different from that on a real device.")
|
||||
return paramMock.paramStringMock
|
||||
},
|
||||
getSize: function () {
|
||||
console.warn("rpc.getSize interface mocked in the Previewer. How this interface works on the" +
|
||||
" Previewer may be different from that on a real device.")
|
||||
return paramMock.paramNumberMock
|
||||
},
|
||||
getCapacity: function () {
|
||||
console.warn("rpc.getCapacity interface mocked in the Previewer. How this interface works on the" +
|
||||
" Previewer may be different from that on a real device.")
|
||||
return paramMock.paramNumberMock
|
||||
},
|
||||
setSize: function (...args) {
|
||||
console.warn("rpc.setSize interface mocked in the Previewer. How this interface works on the" +
|
||||
" Previewer may be different from that on a real device.")
|
||||
return paramMock.paramBooleanMock
|
||||
},
|
||||
setCapacity: function (...args) {
|
||||
console.warn("rpc.setCapacity interface mocked in the Previewer. How this interface works on the" +
|
||||
" Previewer may be different from that on a real device.")
|
||||
return paramMock.paramBooleanMock
|
||||
},
|
||||
getWritableBytes: function () {
|
||||
console.warn("rpc.getWritableBytes interface mocked in the Previewer. How this interface works on the" +
|
||||
" Previewer may be different from that on a real device.")
|
||||
return paramMock.paramNumberMock
|
||||
},
|
||||
getReadableBytes: function () {
|
||||
console.warn("rpc.getReadableBytes interface mocked in the Previewer. How this interface works on the" +
|
||||
" Previewer may be different from that on a real device.")
|
||||
return paramMock.paramNumberMock
|
||||
},
|
||||
getReadPosition: function () {
|
||||
console.warn("rpc.getReadPosition interface mocked in the Previewer. How this interface works on the" +
|
||||
" Previewer may be different from that on a real device.")
|
||||
return paramMock.paramNumberMock
|
||||
},
|
||||
getWritePosition: function () {
|
||||
console.warn("rpc.getWritePosition interface mocked in the Previewer. How this interface works on the" +
|
||||
" Previewer may be different from that on a real device.")
|
||||
return paramMock.paramNumberMock
|
||||
},
|
||||
rewindRead: function (...args) {
|
||||
console.warn("rpc.rewindRead interface mocked in the Previewer. How this interface works on the" +
|
||||
" Previewer may be different from that on a real device.")
|
||||
return paramMock.paramBooleanMock
|
||||
},
|
||||
rewindWrite: function (...args) {
|
||||
console.warn("rpc.rewindWrite interface mocked in the Previewer. How this interface works on the" +
|
||||
" Previewer may be different from that on a real device.")
|
||||
return paramMock.paramBooleanMock
|
||||
},
|
||||
writeByte: function (...args) {
|
||||
console.warn("rpc.writeByte interface mocked in the Previewer. How this interface works on the" +
|
||||
" Previewer may be different from that on a real device.")
|
||||
return paramMock.paramBooleanMock
|
||||
},
|
||||
writeShort: function (...args) {
|
||||
console.warn("rpc.writeShort interface mocked in the Previewer. How this interface works on the" +
|
||||
" Previewer may be different from that on a real device.")
|
||||
return paramMock.paramBooleanMock
|
||||
},
|
||||
writeInt: function (...args) {
|
||||
console.warn("rpc.writeInt interface mocked in the Previewer. How this interface works on the" +
|
||||
" Previewer may be different from that on a real device.")
|
||||
return paramMock.paramBooleanMock
|
||||
},
|
||||
writeLong: function (...args) {
|
||||
console.warn("rpc.writeLong interface mocked in the Previewer. How this interface works on the" +
|
||||
" Previewer may be different from that on a real device.")
|
||||
return paramMock.paramBooleanMock
|
||||
},
|
||||
writeFloat: function (...args) {
|
||||
console.warn("rpc.writeFloat interface mocked in the Previewer. How this interface works on the" +
|
||||
" Previewer may be different from that on a real device.")
|
||||
return paramMock.paramBooleanMock
|
||||
},
|
||||
writeDouble: function (...args) {
|
||||
console.warn("rpc.writeDouble interface mocked in the Previewer. How this interface works on the" +
|
||||
" Previewer may be different from that on a real device.")
|
||||
return paramMock.paramBooleanMock
|
||||
},
|
||||
writeBoolean: function (...args) {
|
||||
console.warn("rpc.writeBoolean interface mocked in the Previewer. How this interface works on the" +
|
||||
" Previewer may be different from that on a real device.")
|
||||
return paramMock.paramBooleanMock
|
||||
},
|
||||
writeChar: function (...args) {
|
||||
console.warn("rpc.writeChar interface mocked in the Previewer. How this interface works on the" +
|
||||
" Previewer may be different from that on a real device.")
|
||||
return paramMock.paramBooleanMock
|
||||
},
|
||||
writeString: function (...args) {
|
||||
console.warn("rpc.writeString interface mocked in the Previewer. How this interface works on the" +
|
||||
" Previewer may be different from that on a real device.")
|
||||
return paramMock.paramBooleanMock
|
||||
},
|
||||
writeSequenceable: function (...args) {
|
||||
console.warn("rpc.writeSequenceable interface mocked in the Previewer. How this interface works on the" +
|
||||
" Previewer may be different from that on a real device.")
|
||||
return paramMock.paramBooleanMock
|
||||
},
|
||||
writeByteArray: function (...args) {
|
||||
console.warn("rpc.writeByteArray interface mocked in the Previewer. How this interface works on the" +
|
||||
" Previewer may be different from that on a real device.")
|
||||
return paramMock.paramBooleanMock
|
||||
},
|
||||
writeShortArray: function (...args) {
|
||||
console.warn("rpc.writeShortArray interface mocked in the Previewer. How this interface works on the" +
|
||||
" Previewer may be different from that on a real device.")
|
||||
return paramMock.paramBooleanMock
|
||||
},
|
||||
writeIntArray: function (...args) {
|
||||
console.warn("rpc.writeIntArray interface mocked in the Previewer. How this interface works on the" +
|
||||
" Previewer may be different from that on a real device.")
|
||||
return paramMock.paramBooleanMock
|
||||
},
|
||||
writeLongArray: function (...args) {
|
||||
console.warn("rpc.writeLongArray interface mocked in the Previewer. How this interface works on the" +
|
||||
" Previewer may be different from that on a real device.")
|
||||
return paramMock.paramBooleanMock
|
||||
},
|
||||
writeFloatArray: function (...args) {
|
||||
console.warn("rpc.writeFloatArray interface mocked in the Previewer. How this interface works on the" +
|
||||
" Previewer may be different from that on a real device.")
|
||||
return paramMock.paramBooleanMock
|
||||
},
|
||||
writeDoubleArray: function (...args) {
|
||||
console.warn("rpc.writeDoubleArray interface mocked in the Previewer. How this interface works on the" +
|
||||
" Previewer may be different from that on a real device.")
|
||||
return paramMock.paramBooleanMock
|
||||
},
|
||||
writeBooleanArray: function (...args) {
|
||||
console.warn("rpc.writeBooleanArray interface mocked in the Previewer. How this interface works on the" +
|
||||
" Previewer may be different from that on a real device.")
|
||||
return paramMock.paramBooleanMock
|
||||
},
|
||||
writeCharArray: function (...args) {
|
||||
console.warn("rpc.writeCharArray interface mocked in the Previewer. How this interface works on the" +
|
||||
" Previewer may be different from that on a real device.")
|
||||
return paramMock.paramBooleanMock
|
||||
},
|
||||
writeStringArray: function (...args) {
|
||||
console.warn("rpc.writeStringArray interface mocked in the Previewer. How this interface works on the" +
|
||||
" Previewer may be different from that on a real device.")
|
||||
return paramMock.paramBooleanMock
|
||||
},
|
||||
writeSequenceableArray: function (...args) {
|
||||
console.warn("rpc.writeSequenceableArray interface mocked in the Previewer. How this interface works on the" +
|
||||
" Previewer may be different from that on a real device.")
|
||||
return paramMock.paramBooleanMock
|
||||
},
|
||||
readByte: function () {
|
||||
console.warn("rpc.readByte interface mocked in the Previewer. How this interface works on the" +
|
||||
" Previewer may be different from that on a real device.")
|
||||
return paramMock.paramNumberMock
|
||||
},
|
||||
readShort: function () {
|
||||
console.warn("rpc.readShort interface mocked in the Previewer. How this interface works on the" +
|
||||
" Previewer may be different from that on a real device.")
|
||||
return paramMock.paramNumberMock
|
||||
},
|
||||
readInt: function () {
|
||||
console.warn("rpc.readInt interface mocked in the Previewer. How this interface works on the" +
|
||||
" Previewer may be different from that on a real device.")
|
||||
return paramMock.paramNumberMock
|
||||
},
|
||||
readLong: function () {
|
||||
console.warn("rpc.readLong interface mocked in the Previewer. How this interface works on the" +
|
||||
" Previewer may be different from that on a real device.")
|
||||
return paramMock.paramNumberMock
|
||||
},
|
||||
readFloat: function () {
|
||||
console.warn("rpc.readFloat interface mocked in the Previewer. How this interface works on the" +
|
||||
" Previewer may be different from that on a real device.")
|
||||
return paramMock.paramNumberMock
|
||||
},
|
||||
readDouble: function () {
|
||||
console.warn("rpc.readDouble interface mocked in the Previewer. How this interface works on the" +
|
||||
" Previewer may be different from that on a real device.")
|
||||
return paramMock.paramNumberMock
|
||||
},
|
||||
readBoolean: function () {
|
||||
console.warn("rpc.readBoolean interface mocked in the Previewer. How this interface works on the" +
|
||||
" Previewer may be different from that on a real device.")
|
||||
return paramMock.paramBooleanMock
|
||||
},
|
||||
readChar: function () {
|
||||
console.warn("rpc.readChar interface mocked in the Previewer. How this interface works on the" +
|
||||
" Previewer may be different from that on a real device.")
|
||||
return paramMock.paramNumberMock
|
||||
},
|
||||
readString: function () {
|
||||
console.warn("rpc.readString interface mocked in the Previewer. How this interface works on the" +
|
||||
" Previewer may be different from that on a real device.")
|
||||
return paramMock.paramStringMock
|
||||
},
|
||||
readSequenceable: function (...args) {
|
||||
console.warn("rpc.readSequenceable interface mocked in the Previewer. How this interface works on the" +
|
||||
" Previewer may be different from that on a real device.")
|
||||
return paramMock.paramBooleanMock
|
||||
},
|
||||
readByteArray: function () {
|
||||
console.warn("rpc.readByteArray interface mocked in the Previewer. How this interface works on the" +
|
||||
" Previewer may be different from that on a real device.")
|
||||
return paramMock.paramArrayMock;
|
||||
},
|
||||
readShortArray: function () {
|
||||
console.warn("rpc.readShortArray interface mocked in the Previewer. How this interface works on the" +
|
||||
" Previewer may be different from that on a real device.")
|
||||
return paramMock.paramArrayMock;
|
||||
},
|
||||
readIntArray: function () {
|
||||
console.warn("rpc.readIntArray interface mocked in the Previewer. How this interface works on the" +
|
||||
" Previewer may be different from that on a real device.")
|
||||
return paramMock.paramArrayMock;
|
||||
},
|
||||
readLongArray: function () {
|
||||
console.warn("rpc.readLongArray interface mocked in the Previewer. How this interface works on the" +
|
||||
" Previewer may be different from that on a real device.")
|
||||
return paramMock.paramArrayMock;
|
||||
},
|
||||
readFloatArray: function () {
|
||||
console.warn("rpc.readFloatArray interface mocked in the Previewer. How this interface works on the" +
|
||||
" Previewer may be different from that on a real device.")
|
||||
return paramMock.paramArrayMock;
|
||||
},
|
||||
readDoubleArray: function () {
|
||||
console.warn("rpc.readDoubleArray interface mocked in the Previewer. How this interface works on the" +
|
||||
" Previewer may be different from that on a real device.")
|
||||
return paramMock.paramArrayMock;
|
||||
},
|
||||
readBooleanArray: function () {
|
||||
console.warn("rpc.readBooleanArray interface mocked in the Previewer. How this interface works on the" +
|
||||
" Previewer may be different from that on a real device.")
|
||||
return paramMock.paramArrayMock;
|
||||
},
|
||||
readCharArray: function () {
|
||||
console.warn("rpc.readCharArray interface mocked in the Previewer. How this interface works on the" +
|
||||
" Previewer may be different from that on a real device.")
|
||||
return paramMock.paramArrayMock;
|
||||
},
|
||||
readStringArray: function () {
|
||||
console.warn("rpc.readStringArray interface mocked in the Previewer. How this interface works on the" +
|
||||
" Previewer may be different from that on a real device.")
|
||||
return paramMock.paramArrayMock;
|
||||
}
|
||||
};
|
||||
const IRemoteObject = {
|
||||
queryLocalInterface: function (...args) {
|
||||
console.warn("rpc.queryLocalInterface interface mocked in the Previewer. How this interface works on the" +
|
||||
" Previewer may be different from that on a real device.")
|
||||
return IRemoteBroker
|
||||
},
|
||||
sendRequest: function (...args) {
|
||||
console.warn("rpc.sendRequest interface mocked in the Previewer. How this interface works on the" +
|
||||
" Previewer may be different from that on a real device.")
|
||||
return paramMock.paramBooleanMock
|
||||
},
|
||||
addDeathRecipient: function (...args) {
|
||||
console.warn("rpc.addDeathRecipient interface mocked in the Previewer. How this interface works on the" +
|
||||
" Previewer may be different from that on a real device.")
|
||||
return paramMock.paramBooleanMock
|
||||
},
|
||||
removeDeathRecipient: function (...args) {
|
||||
console.warn("rpc.removeDeathRecipient interface mocked in the Previewer. How this interface works on the" +
|
||||
" Previewer may be different from that on a real device.")
|
||||
return paramMock.paramBooleanMock
|
||||
},
|
||||
getInterfaceDescriptor: function () {
|
||||
console.warn("rpc.getInterfaceDescriptor interface mocked in the Previewer. How this interface works on the" +
|
||||
" Previewer may be different from that on a real device.")
|
||||
return paramMock.paramStringMock
|
||||
},
|
||||
isObjectDead: function () {
|
||||
console.warn("rpc.isObjectDead interface mocked in the Previewer. How this interface works on the" +
|
||||
" Previewer may be different from that on a real device.")
|
||||
return paramMock.paramBooleanMock
|
||||
}
|
||||
};
|
||||
const IRemoteBroker = {
|
||||
asObject: function () {
|
||||
console.warn("rpc.asObject interface mocked in the Previewer. How this interface works on the" +
|
||||
" Previewer may be different from that on a real device.")
|
||||
return IRemoteObject
|
||||
}
|
||||
};
|
||||
const RemoteProxy = {
|
||||
queryLocalInterface: function (...args) {
|
||||
console.warn("rpc.queryLocalInterface interface mocked in the Previewer. How this interface works on the" +
|
||||
" Previewer may be different from that on a real device.")
|
||||
return IRemoteObject
|
||||
},
|
||||
addDeathRecipient: function (...args) {
|
||||
console.warn("rpc.addDeathRecipient interface mocked in the Previewer. How this interface works on the" +
|
||||
" Previewer may be different from that on a real device.")
|
||||
return paramMock.paramBooleanMock
|
||||
},
|
||||
removeDeathRecipient: function (...args) {
|
||||
console.warn("rpc.removeDeathRecipient interface mocked in the Previewer. How this interface works on the" +
|
||||
" Previewer may be different from that on a real device.")
|
||||
return paramMock.paramBooleanMock
|
||||
},
|
||||
getInterfaceDescriptor: function () {
|
||||
console.warn("rpc.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
|
||||
},
|
||||
sendRequest: function (...args) {
|
||||
console.warn("rpc.sendRequest interface mocked in the Previewer. How this interface works on the" +
|
||||
" Previewer may be different from that on a real device.")
|
||||
return paramMock.paramBooleanMock
|
||||
},
|
||||
isObjectDead: function () {
|
||||
console.warn("rpc.isObjectDead interface mocked in the Previewer. How this interface works on the" +
|
||||
" Previewer may be different from that on a real device.")
|
||||
return paramMock.paramBooleanMock
|
||||
}
|
||||
};
|
||||
const rpc = {
|
||||
MessageParcel: {
|
||||
create: function () {
|
||||
console.warn("rpc.create interface mocked in the Previewer. How this interface works on the" +
|
||||
" Previewer may be different from that on a real device.")
|
||||
return MessageParcel
|
||||
}
|
||||
},
|
||||
MessageOption: {
|
||||
flags: '[PC preview] unknow flags',
|
||||
waitTime: '[PC preview] unknow waitTime'
|
||||
},
|
||||
RemoteProxy: RemoteProxy,
|
||||
IPCSkeleton: {
|
||||
getContextObject: function () {
|
||||
console.warn("rpc.getContextObject interface mocked in the Previewer. How this interface works on the" +
|
||||
" Previewer may be different from that on a real device.")
|
||||
return IRemoteObject
|
||||
},
|
||||
getCallingPid: function () {
|
||||
console.warn("rpc.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
|
||||
},
|
||||
getCallingUid: function () {
|
||||
console.warn("rpc.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
|
||||
},
|
||||
getCallingDeviceID: function () {
|
||||
console.warn("rpc.getCallingDeviceID interface mocked in the Previewer. How this interface works on the" +
|
||||
" Previewer may be different from that on a real device.")
|
||||
return paramMock.paramStringMock
|
||||
},
|
||||
getLocalDeviceID: function () {
|
||||
console.warn("rpc.getLocalDeviceID interface mocked in the Previewer. How this interface works on the" +
|
||||
" Previewer may be different from that on a real device.")
|
||||
return paramMock.paramStringMock
|
||||
},
|
||||
getLocalAbility: function () {
|
||||
console.warn("rpc.getLocalAbility interface mocked in the Previewer. How this interface works on the" +
|
||||
" Previewer may be different from that on a real device.")
|
||||
return RemoteProxy
|
||||
},
|
||||
isLocalCalling: function () {
|
||||
console.warn("rpc.isLocalCalling interface mocked in the Previewer. How this interface works on the" +
|
||||
" Previewer may be different from that on a real device.")
|
||||
return paramMock.paramBooleanMock
|
||||
},
|
||||
flushCommands: function (...args) {
|
||||
console.warn("rpc.flushCommands interface mocked in the Previewer. How this interface works on the" +
|
||||
" Previewer may be different from that on a real device.")
|
||||
return paramMock.paramNumberMock
|
||||
},
|
||||
resetCallingIdentity: function () {
|
||||
console.warn("rpc.resetCallingIdentity interface mocked in the Previewer. How this interface works on the" +
|
||||
" Previewer may be different from that on a real device.")
|
||||
return paramMock.paramStringMock
|
||||
},
|
||||
setCallingIdentity: function (...args) {
|
||||
console.warn("rpc.setCallingIdentity interface mocked in the Previewer. How this interface works on the" +
|
||||
" Previewer may be different from that on a real device.")
|
||||
return paramMock.paramBooleanMock
|
||||
}
|
||||
},
|
||||
RemoteObject: {
|
||||
onRemoteRequest: function (...args) {
|
||||
console.warn("rpc.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
|
||||
},
|
||||
attachLocalInterface: function (...args) {
|
||||
console.warn("rpc.attachLocalInterface interface mocked in the Previewer. How this interface works on the" +
|
||||
" Previewer may be different from that on a real device.")
|
||||
}
|
||||
}
|
||||
}
|
||||
return rpc
|
||||
}
|
||||
@@ -16,7 +16,12 @@ export function mockRunningLock() {
|
||||
" may be different from that on a real device.")
|
||||
}
|
||||
};
|
||||
const RunningLockType = {
|
||||
BACKGROUND : '[PC Preview] unknow BACKGROUND',
|
||||
PROXIMITY_SCREEN_CONTROL : '[PC Preview] unknow PROXIMITY_SCREEN_CONTROL'
|
||||
};
|
||||
const runningLock = {
|
||||
RunningLockType,
|
||||
isRunningLockTypeSupported: function (...args) {
|
||||
console.warn("runningLock.isRunningLockTypeSupported interface mocked in the Previewer. How this interface works on the" +
|
||||
" Previewer may be different from that on a real device.")
|
||||
@@ -43,4 +48,4 @@ export function mockRunningLock() {
|
||||
}
|
||||
}
|
||||
return runningLock
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,104 @@
|
||||
import { paramMock } from "../utils"
|
||||
|
||||
export function mockUrl() {
|
||||
const result = {
|
||||
URLSearchParams: function(...args) {
|
||||
console.warn("url.URLSearchParams interface mocked in the Previewer. How this interface works on the Previewer" +
|
||||
" may be different from that on a real device.")
|
||||
return URLSearchParamsMock;
|
||||
},
|
||||
URL: function(...args) {
|
||||
console.warn("url.URL interface mocked in the Previewer. How this interface works on the Previewer" +
|
||||
" may be different from that on a real device.")
|
||||
return URLMock;
|
||||
}
|
||||
}
|
||||
const URLSearchParamsMock = {
|
||||
append: function(...args) {
|
||||
console.warn("URLSearchParams.append 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("URLSearchParams.delete interface mocked in the Previewer. How this interface works on the Previewer" +
|
||||
" may be different from that on a real device.")
|
||||
},
|
||||
getAll: function(...args) {
|
||||
console.warn("URLSearchParams.getAll interface mocked in the Previewer. How this interface works on the Previewer" +
|
||||
" may be different from that on a real device.")
|
||||
var arrStr = new Array()
|
||||
return arrStr;
|
||||
},
|
||||
entries: function(...args) {
|
||||
console.warn("URLSearchParams.entries interface mocked in the Previewer. How this interface works on the Previewer" +
|
||||
" may be different from that on a real device.")
|
||||
return paramMock.paramObjectMock;
|
||||
},
|
||||
forEach: function(...args) {
|
||||
console.warn("URLSearchParams.forEach interface mocked in the Previewer. How this interface works on the Previewer" +
|
||||
" may be different from that on a real device.")
|
||||
},
|
||||
get: function(...args) {
|
||||
console.warn("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;
|
||||
},
|
||||
has: function(...args) {
|
||||
console.warn("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;
|
||||
},
|
||||
set: function(...args) {
|
||||
console.warn("URLSearchParams.set interface mocked in the Previewer. How this interface works on the Previewer" +
|
||||
" may be different from that on a real device.")
|
||||
},
|
||||
sort: function(...args) {
|
||||
console.warn("URLSearchParams.sort interface mocked in the Previewer. How this interface works on the Previewer" +
|
||||
" may be different from that on a real device.")
|
||||
},
|
||||
keys: function(...args) {
|
||||
console.warn("URLSearchParams.keys interface mocked in the Previewer. How this interface works on the Previewer" +
|
||||
" may be different from that on a real device.")
|
||||
return paramMock.paramObjectMock;
|
||||
},
|
||||
values: function(...args) {
|
||||
console.warn("URLSearchParams.values interface mocked in the Previewer. How this interface works on the Previewer" +
|
||||
" may be different from that on a real device.")
|
||||
return paramMock.paramObjectMock;
|
||||
},
|
||||
[Symbol.iterator]: function(...args) {
|
||||
console.warn("URLSearchParams.[Symbol.iterator] interface mocked in the Previewer. How this interface works on the Previewer" +
|
||||
" may be different from that on a real device.")
|
||||
return paramMock.paramObjectMock;
|
||||
},
|
||||
toString: function(...args) {
|
||||
console.warn("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;
|
||||
}
|
||||
}
|
||||
const URLMock = {
|
||||
toString: function(...args) {
|
||||
console.warn("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;
|
||||
},
|
||||
toJSON: function(...args) {
|
||||
console.warn("URLSearchParams.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;
|
||||
},
|
||||
hash: '[PC preview] unknow hash',
|
||||
host: '[PC preview] unknow host',
|
||||
hostname: '[PC preview] unknow hostname',
|
||||
href: '[PC preview] unknow href',
|
||||
origin: '[PC preview] unknow origin',
|
||||
password: '[PC preview] unknow password',
|
||||
pathname: '[PC preview] unknow pathname',
|
||||
port: '[PC preview] unknow port',
|
||||
protocol: '[PC preview] unknow protocol',
|
||||
search: '[PC preview] unknow search',
|
||||
searchParams: URLSearchParamsMock,
|
||||
username: '[PC preview] unknow username',
|
||||
}
|
||||
return result;
|
||||
}
|
||||
@@ -2,6 +2,25 @@ import { paramMock } from "../utils"
|
||||
|
||||
export function mockUtil() {
|
||||
const result = {
|
||||
printf: function(...args) {
|
||||
console.warn("util.printf interface mocked in the Previewer. How this interface works on the Previewer" +
|
||||
" may be different from that on a real device.")
|
||||
return paramMock.paramStringMock;
|
||||
},
|
||||
getErrorString: function(...args) {
|
||||
console.warn("util.getErrorString interface mocked in the Previewer. How this interface works on the Previewer" +
|
||||
" may be different from that on a real device.")
|
||||
return paramMock.paramStringMock;
|
||||
},
|
||||
callbackWrapper: function(...args) {
|
||||
console.warn("util.callbackWrapper interface mocked in the Previewer. How this interface works on the Previewer" +
|
||||
" may be different from that on a real device.")
|
||||
},
|
||||
promiseWrapper: function(...args) {
|
||||
console.warn("util.promiseWrapper interface mocked in the Previewer. How this interface works on the Previewer" +
|
||||
" may be different from that on a real device.")
|
||||
return paramMock.paramObjectMock;
|
||||
},
|
||||
TextDecoder: function(...args) {
|
||||
console.warn("util.TextDecoder interface mocked in the Previewer. How this interface works on the Previewer" +
|
||||
" may be different from that on a real device.")
|
||||
@@ -28,7 +47,8 @@ export function mockUtil() {
|
||||
encode: function(...args) {
|
||||
console.warn("TextEncoder.encode interface mocked in the Previewer. How this interface works on the Previewer" +
|
||||
" may be different from that on a real device.")
|
||||
return paramMock.paramArrayMock;
|
||||
const arr = new Uint8Array()
|
||||
return arr;
|
||||
},
|
||||
encodeInto: function(...args) {
|
||||
console.warn("TextEncoder.encodeInto interface mocked in the Previewer. How this interface works on the Previewer" +
|
||||
|
||||
@@ -0,0 +1,739 @@
|
||||
import { paramMock } from "../utils"
|
||||
|
||||
export function mockwebgl() {
|
||||
|
||||
const WebGLContextAttributes ={
|
||||
brightness: '[PC preview] unknow brightness',
|
||||
alpha: '[PC preview] unknow alpha',
|
||||
depth: '[PC preview] unknow depth',
|
||||
stencil: '[PC preview] unknow stencil',
|
||||
antialias: '[PC preview] unknow antialias',
|
||||
premultipliedAlpha: '[PC preview] unknow premultipliedAlpha',
|
||||
preserveDrawingBuffer: '[PC preview] unknow preserveDrawingBuffer',
|
||||
powerPreference: '[PC preview] unknow powerPreference',
|
||||
failIfMajorPerformanceCaveat: '[PC preview] unknow failIfMajorPerformanceCaveat',
|
||||
desynchronized: '[PC preview] unknow desynchronized'
|
||||
}
|
||||
|
||||
const float32ArrayWith2val = [
|
||||
paramMock.paramNumberMock,paramMock.paramNumberMock
|
||||
]
|
||||
|
||||
const float32ArrayWith4val = [
|
||||
paramMock.paramNumberMock,paramMock.paramNumberMock,paramMock.paramNumberMock,paramMock.paramNumberMock
|
||||
]
|
||||
const int32ArrayWith2ele = [
|
||||
paramMock.paramNumberMock,paramMock.paramNumberMock
|
||||
]
|
||||
const int32ArrayWith4ele = [
|
||||
paramMock.paramNumberMock,paramMock.paramNumberMock,paramMock.paramNumberMock,paramMock.paramNumberMock
|
||||
]
|
||||
|
||||
const WebGLShaderArray = [
|
||||
WebGLShader,WebGLShader,WebGLShader
|
||||
]
|
||||
const WebGLBuffer = {
|
||||
}
|
||||
const WebGLFramebuffer = {
|
||||
}
|
||||
const WebGLProgram = {
|
||||
}
|
||||
const WebGLRenderbuffer = {
|
||||
}
|
||||
const WebGLShader = {
|
||||
}
|
||||
const WebGLTexture = {
|
||||
}
|
||||
const WebGLUniformLocation = {
|
||||
}
|
||||
const WebGLActiveInfo = {
|
||||
size: '[PC preview] unknow size',
|
||||
type: '[PC preview] unknow type',
|
||||
name: '[PC preview] unknow name'
|
||||
}
|
||||
const WebGLShaderPrecisionFormat = {
|
||||
rangeMin: '[PC preview] unknow rangeMin',
|
||||
rangeMax: '[PC preview] unknow rangeMax',
|
||||
precision: '[PC preview] unknow precision'
|
||||
}
|
||||
const webglmock = {
|
||||
paramDoubleMock: '[PC Preview] unknow double',
|
||||
paramAnyMock: '[PC Preview] unknow any',
|
||||
stringArray: '[PC preview] unknow stringArray',
|
||||
uint32Array: '[PC preview] unknow uint32Array',
|
||||
glBooleanArray: '[PC preview] unknow glBooleanArray',
|
||||
WebGLShaderArray: '[PC preview] unknow WebGLShaderArray',
|
||||
|
||||
getContextAttributes: function (...args) {
|
||||
console.warn("webgl.getContextAttributes interface mocked in the Previewer. How this interface works on the" +
|
||||
" Previewer may be different from that on a real device.")
|
||||
return WebGLContextAttributes
|
||||
},
|
||||
isContextLost: function (...args) {
|
||||
console.warn("webgl.isContextLost interface mocked in the Previewer. How this interface works on the" +
|
||||
" Previewer may be different from that on a real device.")
|
||||
return paramMock.paramBooleanMock
|
||||
},
|
||||
getSupportedExtensions: function (...args) {
|
||||
console.warn("webgl.getSupportedExtensions interface mocked in the Previewer. How this interface works on the" +
|
||||
" Previewer may be different from that on a real device.")
|
||||
return stringarray
|
||||
},
|
||||
getExtension: function (...args) {
|
||||
console.warn("webgl.getExtension interface mocked in the Previewer. How this interface works on the" +
|
||||
" Previewer may be different from that on a real device.")
|
||||
return paramAnyMock
|
||||
},
|
||||
activeTexture: function (...args) {
|
||||
console.warn("webgl.activeTexture interface mocked in the Previewer. How this interface works on the" +
|
||||
" Previewer may be different from that on a real device.")
|
||||
},
|
||||
attachShader: function (...args) {
|
||||
console.warn("webgl.attachShader interface mocked in the Previewer. How this interface works on the" +
|
||||
" Previewer may be different from that on a real device.")
|
||||
},
|
||||
bindAttribLocation: function (...args) {
|
||||
console.warn("webgl.bindAttribLocation interface mocked in the Previewer. How this interface works on the" +
|
||||
" Previewer may be different from that on a real device.")
|
||||
},
|
||||
bindBuffer: function (...args) {
|
||||
console.warn("webgl.bindBuffer interface mocked in the Previewer. How this interface works on the" +
|
||||
" Previewer may be different from that on a real device.")
|
||||
},
|
||||
bindFramebuffer: function (...args) {
|
||||
console.warn("webgl.bindFramebuffer interface mocked in the Previewer. How this interface works on the" +
|
||||
" Previewer may be different from that on a real device.")
|
||||
},
|
||||
bindRenderbuffer: function (...args) {
|
||||
console.warn("webgl.bindRenderbuffer interface mocked in the Previewer. How this interface works on the" +
|
||||
" Previewer may be different from that on a real device.")
|
||||
},
|
||||
bindTexture: function (...args) {
|
||||
console.warn("webgl.bindTexture interface mocked in the Previewer. How this interface works on the" +
|
||||
" Previewer may be different from that on a real device.")
|
||||
},
|
||||
blendColor: function (...args) {
|
||||
console.warn("webgl.blendColor interface mocked in the Previewer. How this interface works on the" +
|
||||
" Previewer may be different from that on a real device.")
|
||||
},
|
||||
blendEquation: function (...args) {
|
||||
console.warn("webgl.blendEquation interface mocked in the Previewer. How this interface works on the" +
|
||||
" Previewer may be different from that on a real device.")
|
||||
},
|
||||
blendEquationSeparate: function (...args) {
|
||||
console.warn("webgl.blendEquationSeparate interface mocked in the Previewer. How this interface works on the" +
|
||||
" Previewer may be different from that on a real device.")
|
||||
},
|
||||
blendFunc: function (...args) {
|
||||
console.warn("webgl.blendFunc interface mocked in the Previewer. How this interface works on the" +
|
||||
" Previewer may be different from that on a real device.")
|
||||
},
|
||||
|
||||
blendFuncSeparate: function (...args) {
|
||||
console.warn("webgl.blendFuncSeparate interface mocked in the Previewer. How this interface works on the" +
|
||||
" Previewer may be different from that on a real device.")
|
||||
},
|
||||
checkFramebufferStatus: function (...args) {
|
||||
console.warn("webgl.checkFramebufferStatus interface mocked in the Previewer. How this interface works on the" +
|
||||
" Previewer may be different from that on a real device.")
|
||||
return paramMock.paramNumberMock
|
||||
},
|
||||
clear: function (...args) {
|
||||
console.warn("webgl.clear interface mocked in the Previewer. How this interface works on the" +
|
||||
" Previewer may be different from that on a real device.")
|
||||
},
|
||||
clearColor: function (...args) {
|
||||
console.warn("webgl.clearColor interface mocked in the Previewer. How this interface works on the" +
|
||||
" Previewer may be different from that on a real device.")
|
||||
},
|
||||
clearDepth: function (...args) {
|
||||
console.warn("webgl.clearDepth interface mocked in the Previewer. How this interface works on the" +
|
||||
" Previewer may be different from that on a real device.")
|
||||
},
|
||||
clearStencil: function (...args) {
|
||||
console.warn("webgl.clearStencil interface mocked in the Previewer. How this interface works on the" +
|
||||
" Previewer may be different from that on a real device.")
|
||||
},
|
||||
colorMask: function (...args) {
|
||||
console.warn("webgl.colorMask interface mocked in the Previewer. How this interface works on the" +
|
||||
" Previewer may be different from that on a real device.")
|
||||
},
|
||||
compileShader: function (...args) {
|
||||
console.warn("webgl.compileShader interface mocked in the Previewer. How this interface works on the" +
|
||||
" Previewer may be different from that on a real device.")
|
||||
},
|
||||
copyTexImage2D: function (...args) {
|
||||
console.warn("webgl.copyTexImage2D interface mocked in the Previewer. How this interface works on the" +
|
||||
" Previewer may be different from that on a real device.")
|
||||
},
|
||||
copyTexSubImage2D: function (...args) {
|
||||
console.warn("webgl.copyTexSubImage2D interface mocked in the Previewer. How this interface works on the" +
|
||||
" Previewer may be different from that on a real device.")
|
||||
},
|
||||
createBuffer: function (...args) {
|
||||
console.warn("webgl.createBuffer interface mocked in the Previewer. How this interface works on the" +
|
||||
" Previewer may be different from that on a real device.")
|
||||
return WebGLBuffer;
|
||||
},
|
||||
createFramebuffer: function (...args) {
|
||||
console.warn("webgl.createFramebuffer interface mocked in the Previewer. How this interface works on the" +
|
||||
" Previewer may be different from that on a real device.")
|
||||
return WebGLFramebuffer;
|
||||
},
|
||||
createProgram: function (...args) {
|
||||
console.warn("webgl.createProgram interface mocked in the Previewer. How this interface works on the" +
|
||||
" Previewer may be different from that on a real device.")
|
||||
return WebGLProgram;
|
||||
},
|
||||
createRenderbuffer: function (...args) {
|
||||
console.warn("webgl.createRenderbuffer interface mocked in the Previewer. How this interface works on the" +
|
||||
" Previewer may be different from that on a real device.")
|
||||
return WebGLRenderbuffer;
|
||||
},
|
||||
createShader: function (...args) {
|
||||
console.warn("webgl.createShader interface mocked in the Previewer. How this interface works on the" +
|
||||
" Previewer may be different from that on a real device.")
|
||||
return WebGLShader;
|
||||
},
|
||||
|
||||
createTexture: function (...args) {
|
||||
console.warn("webgl.createTexture interface mocked in the Previewer. How this interface works on the" +
|
||||
" Previewer may be different from that on a real device.")
|
||||
return WebGLTexture;
|
||||
},
|
||||
cullFace: function (...args) {
|
||||
console.warn("webgl.cullFace interface mocked in the Previewer. How this interface works on the" +
|
||||
" Previewer may be different from that on a real device.")
|
||||
},
|
||||
deleteBuffer: function (...args) {
|
||||
console.warn("webgl.deleteBuffer interface mocked in the Previewer. How this interface works on the" +
|
||||
" Previewer may be different from that on a real device.")
|
||||
},
|
||||
deleteFramebuffer: function (...args) {
|
||||
console.warn("webgl.deleteFramebuffer interface mocked in the Previewer. How this interface works on the" +
|
||||
" Previewer may be different from that on a real device.")
|
||||
},
|
||||
deleteProgram: function (...args) {
|
||||
console.warn("webgl.deleteProgram interface mocked in the Previewer. How this interface works on the" +
|
||||
" Previewer may be different from that on a real device.")
|
||||
},
|
||||
|
||||
deleteRenderbuffer: function (...args) {
|
||||
console.warn("webgl.deleteRenderbuffer interface mocked in the Previewer. How this interface works on the" +
|
||||
" Previewer may be different from that on a real device.")
|
||||
},
|
||||
deleteShader: function (...args) {
|
||||
console.warn("webgl.deleteRenderbuffer interface mocked in the Previewer. How this interface works on the" +
|
||||
" Previewer may be different from that on a real device.")
|
||||
},
|
||||
deleteTexture: function (...args) {
|
||||
console.warn("webgl.deleteRenderbuffer interface mocked in the Previewer. How this interface works on the" +
|
||||
" Previewer may be different from that on a real device.")
|
||||
},
|
||||
depthFunc: function (...args) {
|
||||
console.warn("webgl.deleteRenderbuffer interface mocked in the Previewer. How this interface works on the" +
|
||||
" Previewer may be different from that on a real device.")
|
||||
},
|
||||
depthMask: function (...args) {
|
||||
console.warn("webgl.deleteRenderbuffer interface mocked in the Previewer. How this interface works on the" +
|
||||
" Previewer may be different from that on a real device.")
|
||||
},
|
||||
|
||||
depthRange: function (...args) {
|
||||
console.warn("webgl.depthRange interface mocked in the Previewer. How this interface works on the" +
|
||||
" Previewer may be different from that on a real device.")
|
||||
},
|
||||
detachShader: function (...args) {
|
||||
console.warn("webgl.detachShader interface mocked in the Previewer. How this interface works on the" +
|
||||
" Previewer may be different from that on a real device.")
|
||||
},
|
||||
disable: function (...args) {
|
||||
console.warn("webgl.disable interface mocked in the Previewer. How this interface works on the" +
|
||||
" Previewer may be different from that on a real device.")
|
||||
},
|
||||
disableVertexAttribArray: function (...args) {
|
||||
console.warn("webgl.disableVertexAttribArray interface mocked in the Previewer. How this interface works on the" +
|
||||
" Previewer may be different from that on a real device.")
|
||||
},
|
||||
drawArrays: function (...args) {
|
||||
console.warn("webgl.drawArrays interface mocked in the Previewer. How this interface works on the" +
|
||||
" Previewer may be different from that on a real device.")
|
||||
},
|
||||
|
||||
drawElements: function (...args) {
|
||||
console.warn("webgl.drawElements interface mocked in the Previewer. How this interface works on the" +
|
||||
" Previewer may be different from that on a real device.")
|
||||
},
|
||||
enable: function (...args) {
|
||||
console.warn("webgl.enable interface mocked in the Previewer. How this interface works on the" +
|
||||
" Previewer may be different from that on a real device.")
|
||||
},
|
||||
enableVertexAttribArray: function (...args) {
|
||||
console.warn("webgl.enableVertexAttribArray interface mocked in the Previewer. How this interface works on the" +
|
||||
" Previewer may be different from that on a real device.")
|
||||
},
|
||||
finish: function (...args) {
|
||||
console.warn("webgl.finish interface mocked in the Previewer. How this interface works on the" +
|
||||
" Previewer may be different from that on a real device.")
|
||||
},
|
||||
flush: function (...args) {
|
||||
console.warn("webgl.flush interface mocked in the Previewer. How this interface works on the" +
|
||||
" Previewer may be different from that on a real device.")
|
||||
},
|
||||
|
||||
framebufferRenderbuffer: function (...args) {
|
||||
console.warn("webgl.framebufferRenderbuffer interface mocked in the Previewer. How this interface works on the" +
|
||||
" Previewer may be different from that on a real device.")
|
||||
},
|
||||
framebufferTexture2D: function (...args) {
|
||||
console.warn("webgl.framebufferTexture2D interface mocked in the Previewer. How this interface works on the" +
|
||||
" Previewer may be different from that on a real device.")
|
||||
},
|
||||
frontFace: function (...args) {
|
||||
console.warn("webgl.frontFace interface mocked in the Previewer. How this interface works on the" +
|
||||
" Previewer may be different from that on a real device.")
|
||||
},
|
||||
generateMipmap: function (...args) {
|
||||
console.warn("webgl.generateMipmap interface mocked in the Previewer. How this interface works on the" +
|
||||
" Previewer may be different from that on a real device.")
|
||||
},
|
||||
getActiveAttrib: function (...args) {
|
||||
console.warn("webgl.getActiveAttrib interface mocked in the Previewer. How this interface works on the" +
|
||||
" Previewer may be different from that on a real device.")
|
||||
return WebGLActiveInfo;
|
||||
},
|
||||
|
||||
getActiveUniform: function (...args) {
|
||||
console.warn("webgl.getActiveAttrib interface mocked in the Previewer. How this interface works on the" +
|
||||
" Previewer may be different from that on a real device.")
|
||||
return WebGLActiveInfo;
|
||||
},
|
||||
getAttachedShaders: function (...args) {
|
||||
console.warn("webgl.getActiveAttrib interface mocked in the Previewer. How this interface works on the" +
|
||||
" Previewer may be different from that on a real device.")
|
||||
return WebGLShaderArray;
|
||||
},
|
||||
getAttribLocation: function (...args) {
|
||||
console.warn("webgl.getActiveAttrib interface mocked in the Previewer. How this interface works on the" +
|
||||
" Previewer may be different from that on a real device.")
|
||||
return paramMock.paramNumberMock;
|
||||
},
|
||||
getBufferParameter: function (...args) {
|
||||
console.warn("webgl.getActiveAttrib interface mocked in the Previewer. How this interface works on the" +
|
||||
" Previewer may be different from that on a real device.")
|
||||
return paramMock.paramNumberMock;
|
||||
},
|
||||
getParameter: function (...args) {
|
||||
console.warn("webgl.getActiveAttrib interface mocked in the Previewer. How this interface works on the" +
|
||||
" Previewer may be different from that on a real device.")
|
||||
if (args[0] == 0x0B73 || args[0] == 0x0B21 ||
|
||||
args[0] == 0x8038 || args[0] == 0x2A00 ||
|
||||
args[0] == 0x80AA) {
|
||||
return paramMock.paramNumberMock;;
|
||||
} else if (args[0] == 0x8069 || args[0] == 0x8514) {
|
||||
return WebGLTexture;
|
||||
} else if (args[0] == 0x1F01 || args[0] == 0x8B8C ||
|
||||
args[0] == 0x1F00 || args[0] == 0x1F02) {
|
||||
return stringArray;
|
||||
} else if (args[0] == 0x8894 || args[0] == 0x8895) {
|
||||
return WebGLBuffer;
|
||||
} else if (args[0] == 0x8CA6) {
|
||||
return WebGLFramebuffer;
|
||||
} else if (args[0] == 0x8B8D) {
|
||||
return WebGLProgram;
|
||||
} else if (args[0] == 0x8CA7) {
|
||||
return WebGLRenderbuffer;
|
||||
} else if (args[0] == 0x846E || args[0] == 0x846D ||
|
||||
args[0] == 0x0B70) {
|
||||
return float32ArrayWith2val;
|
||||
} else if (args[0] == 0x0C22 || args[0] == 0x8005) {
|
||||
return float32ArrayWith4val;
|
||||
} else if (args[0] == 0x86A3) {
|
||||
return uint32Array;
|
||||
} else if (args[0] == 0x0D3A) {
|
||||
return int32ArrayWith2ele;
|
||||
} else if (args[0] == 0x0C10) {
|
||||
return int32ArrayWith4ele;
|
||||
} else if (args[0] == 0x0BE2 || args[0] == 0x0B44 || args[0] == 0x0B71 ||
|
||||
args[0] == 0x0B72 || args[0] == 0x0BD0 || args[0] == 0x8037 ||
|
||||
args[0] == 0x809E || args[0] == 0x80A0 ||
|
||||
args[0] == 0x80AB || args[0] == 0x0C11 || args[0] == 0x0B90 ||
|
||||
args[0] == 0x9240 ||
|
||||
args[0] == 0x9241) {
|
||||
return paramMock.paramBooleanMock;
|
||||
} else if (args[0] == 0x0C23) {
|
||||
return glBooleanArray;
|
||||
} else {
|
||||
return paramMock.paramNumberMock;;
|
||||
}
|
||||
},
|
||||
getError: function (...args) {
|
||||
console.warn("webgl.getError interface mocked in the Previewer. How this interface works on the" +
|
||||
" Previewer may be different from that on a real device.")
|
||||
return paramMock.paramNumberMock;
|
||||
},
|
||||
getFramebufferAttachmentParameter: function (...args) {
|
||||
console.warn("webgl.getFramebufferAttachmentParameter interface mocked in the Previewer. How this interface works on the" +
|
||||
" Previewer may be different from that on a real device.")
|
||||
if (args[2] == 0x8CD0 ||
|
||||
args[2] == 0x8CD2 ||
|
||||
args[2] == 0x8CD3 ||
|
||||
args[2] == 0x8215 ||
|
||||
args[2] == 0x8214 ||
|
||||
args[2] == 0x8210 ||
|
||||
args[2] == 0x8211 ||
|
||||
args[2] == 0x8216 ||
|
||||
args[2] == 0x8213 ||
|
||||
args[2] == 0x8212 ||
|
||||
args[2] == 0x8217 ||
|
||||
args[2] == 0x8CD4) {
|
||||
return paramMock.paramNumberMock;
|
||||
} else if (args[2] == 0x8CD1) {
|
||||
return paramMock.paramObjectMock;
|
||||
}
|
||||
},
|
||||
getProgramParameter: function (...args) {
|
||||
console.warn("webgl.getProgramParameter interface mocked in the Previewer. How this interface works on the" +
|
||||
" Previewer may be different from that on a real device.")
|
||||
if (args[1] == 0x8B80 || args[1] == 0x8B82 || args[1] == 0x8B83) {
|
||||
return paramMock.paramBooleanMock;
|
||||
} else {
|
||||
return paramMock.paramNumberMock;
|
||||
}
|
||||
},
|
||||
getProgramInfoLog: function (...args) {
|
||||
console.warn("webgl.getProgramInfoLog interface mocked in the Previewer. How this interface works on the" +
|
||||
" Previewer may be different from that on a real device.")
|
||||
return paramMock.paramStringMock;
|
||||
},
|
||||
getRenderbufferParameter: function (...args) {
|
||||
console.warn("webgl.getRenderbufferParameter interface mocked in the Previewer. How this interface works on the" +
|
||||
" Previewer may be different from that on a real device.")
|
||||
return paramMock.paramNumberMock;
|
||||
},
|
||||
|
||||
getShaderParameter: function (...args) {
|
||||
console.warn("webgl.getShaderParameter interface mocked in the Previewer. How this interface works on the" +
|
||||
" Previewer may be different from that on a real device.")
|
||||
if (args[1] == 0x8B4F) {
|
||||
return paramMock.paramNumberMock;
|
||||
} else {
|
||||
return paramMock.paramBooleanMock;
|
||||
}
|
||||
},
|
||||
getShaderPrecisionFormat: function (...args) {
|
||||
console.warn("webgl.getShaderPrecisionFormat interface mocked in the Previewer. How this interface works on the" +
|
||||
" Previewer may be different from that on a real device.")
|
||||
return WebGLShaderPrecisionFormat;
|
||||
},
|
||||
getShaderInfoLog: function (...args) {
|
||||
console.warn("webgl.getShaderInfoLog interface mocked in the Previewer. How this interface works on the" +
|
||||
" Previewer may be different from that on a real device.")
|
||||
return paramMock.paramStringMock;
|
||||
},
|
||||
getShaderSource: function (...args) {
|
||||
console.warn("webgl.getShaderSource interface mocked in the Previewer. How this interface works on the" +
|
||||
" Previewer may be different from that on a real device.")
|
||||
return paramMock.paramStringMock;
|
||||
},
|
||||
getTexParameter: function (...args) {
|
||||
console.warn("webgl.getTexParameter interface mocked in the Previewer. How this interface works on the" +
|
||||
" Previewer may be different from that on a real device.")
|
||||
if (args[1] == 0x84FE) {
|
||||
return paramMock.paramDoubleMock;
|
||||
} else {
|
||||
return paramMock.paramNumberMock;
|
||||
}
|
||||
},
|
||||
|
||||
getUniform: function (...args) {
|
||||
console.warn("webgl.getUniform interface mocked in the Previewer. How this interface works on the" +
|
||||
" Previewer may be different from that on a real device.")
|
||||
return paramAnyMock;
|
||||
},
|
||||
getUniformLocation: function (...args) {
|
||||
console.warn("webgl.getUniformLocation interface mocked in the Previewer. How this interface works on the" +
|
||||
" Previewer may be different from that on a real device.")
|
||||
return WebGLUniformLocation;
|
||||
},
|
||||
getVertexAttrib: function (...args) {
|
||||
console.warn("webgl.getVertexAttrib interface mocked in the Previewer. How this interface works on the" +
|
||||
" Previewer may be different from that on a real device.")
|
||||
return paramMock.paramBooleanMock;
|
||||
},
|
||||
getVertexAttribOffset: function (...args) {
|
||||
console.warn("webgl.getVertexAttribOffset interface mocked in the Previewer. How this interface works on the" +
|
||||
" Previewer may be different from that on a real device.")
|
||||
return paramMock.paramNumberMock;
|
||||
},
|
||||
hint: function (...args) {
|
||||
console.warn("webgl.hint interface mocked in the Previewer. How this interface works on the" +
|
||||
" Previewer may be different from that on a real device.")
|
||||
},
|
||||
|
||||
isBuffer: function (...args) {
|
||||
console.warn("webgl.isBuffer interface mocked in the Previewer. How this interface works on the" +
|
||||
" Previewer may be different from that on a real device.")
|
||||
return paramMock.paramBooleanMock;
|
||||
},
|
||||
isEnabled: function (...args) {
|
||||
console.warn("webgl.isEnabled interface mocked in the Previewer. How this interface works on the" +
|
||||
" Previewer may be different from that on a real device.")
|
||||
return paramMock.paramBooleanMock;
|
||||
},
|
||||
isFramebuffer: function (...args) {
|
||||
console.warn("webgl.isFramebuffer interface mocked in the Previewer. How this interface works on the" +
|
||||
" Previewer may be different from that on a real device.")
|
||||
return paramMock.paramBooleanMock;
|
||||
},
|
||||
isProgram: function (...args) {
|
||||
console.warn("webgl.isProgram interface mocked in the Previewer. How this interface works on the" +
|
||||
" Previewer may be different from that on a real device.")
|
||||
return paramMock.paramBooleanMock;
|
||||
},
|
||||
isRenderbuffer: function (...args) {
|
||||
console.warn("webgl.isRenderbuffer interface mocked in the Previewer. How this interface works on the" +
|
||||
" Previewer may be different from that on a real device.")
|
||||
return paramMock.paramBooleanMock;
|
||||
},
|
||||
|
||||
isShader: function (...args) {
|
||||
console.warn("webgl.isShader interface mocked in the Previewer. How this interface works on the" +
|
||||
" Previewer may be different from that on a real device.")
|
||||
return paramMock.paramBooleanMock;
|
||||
},
|
||||
isTexture: function (...args) {
|
||||
console.warn("webgl.isTexture interface mocked in the Previewer. How this interface works on the" +
|
||||
" Previewer may be different from that on a real device.")
|
||||
return paramMock.paramBooleanMock;
|
||||
},
|
||||
lineWidth: function (...args) {
|
||||
console.warn("webgl.lineWidth interface mocked in the Previewer. How this interface works on the" +
|
||||
" Previewer may be different from that on a real device.")
|
||||
},
|
||||
linkProgram: function (...args) {
|
||||
console.warn("webgl.linkProgram interface mocked in the Previewer. How this interface works on the" +
|
||||
" Previewer may be different from that on a real device.")
|
||||
},
|
||||
pixelStorei: function (...args) {
|
||||
console.warn("webgl.pixelStorei interface mocked in the Previewer. How this interface works on the" +
|
||||
" Previewer may be different from that on a real device.")
|
||||
},
|
||||
|
||||
polygonOffset: function (...args) {
|
||||
console.warn("webgl.polygonOffset interface mocked in the Previewer. How this interface works on the" +
|
||||
" Previewer may be different from that on a real device.")
|
||||
},
|
||||
renderbufferStorage: function (...args) {
|
||||
console.warn("webgl.renderbufferStorage interface mocked in the Previewer. How this interface works on the" +
|
||||
" Previewer may be different from that on a real device.")
|
||||
},
|
||||
sampleCoverage: function (...args) {
|
||||
console.warn("webgl.sampleCoverage interface mocked in the Previewer. How this interface works on the" +
|
||||
" Previewer may be different from that on a real device.")
|
||||
},
|
||||
scissor: function (...args) {
|
||||
console.warn("webgl.scissor interface mocked in the Previewer. How this interface works on the" +
|
||||
" Previewer may be different from that on a real device.")
|
||||
},
|
||||
shaderSource: function (...args) {
|
||||
console.warn("webgl.shaderSource interface mocked in the Previewer. How this interface works on the" +
|
||||
" Previewer may be different from that on a real device.")
|
||||
},
|
||||
|
||||
stencilFunc: function (...args) {
|
||||
console.warn("webgl.stencilFunc interface mocked in the Previewer. How this interface works on the" +
|
||||
" Previewer may be different from that on a real device.")
|
||||
},
|
||||
stencilFuncSeparate: function (...args) {
|
||||
console.warn("webgl.stencilFuncSeparate interface mocked in the Previewer. How this interface works on the" +
|
||||
" Previewer may be different from that on a real device.")
|
||||
},
|
||||
stencilMask: function (...args) {
|
||||
console.warn("webgl.stencilMask interface mocked in the Previewer. How this interface works on the" +
|
||||
" Previewer may be different from that on a real device.")
|
||||
},
|
||||
stencilMaskSeparate: function (...args) {
|
||||
console.warn("webgl.stencilMaskSeparate interface mocked in the Previewer. How this interface works on the" +
|
||||
" Previewer may be different from that on a real device.")
|
||||
},
|
||||
stencilOp: function (...args) {
|
||||
console.warn("webgl.stencilOp interface mocked in the Previewer. How this interface works on the" +
|
||||
" Previewer may be different from that on a real device.")
|
||||
},
|
||||
|
||||
stencilOpSeparate: function (...args) {
|
||||
console.warn("webgl.stencilOpSeparate interface mocked in the Previewer. How this interface works on the" +
|
||||
" Previewer may be different from that on a real device.")
|
||||
},
|
||||
texParameterf: function (...args) {
|
||||
console.warn("webgl.texParameterf interface mocked in the Previewer. How this interface works on the" +
|
||||
" Previewer may be different from that on a real device.")
|
||||
},
|
||||
texParameteri: function (...args) {
|
||||
console.warn("webgl.texParameteri interface mocked in the Previewer. How this interface works on the" +
|
||||
" Previewer may be different from that on a real device.")
|
||||
},
|
||||
uniform1f: function (...args) {
|
||||
console.warn("webgl.uniform1f interface mocked in the Previewer. How this interface works on the" +
|
||||
" Previewer may be different from that on a real device.")
|
||||
},
|
||||
uniform2f: function (...args) {
|
||||
console.warn("webgl.uniform2f interface mocked in the Previewer. How this interface works on the" +
|
||||
" Previewer may be different from that on a real device.")
|
||||
},
|
||||
|
||||
uniform3f: function (...args) {
|
||||
console.warn("webgl.uniform3f interface mocked in the Previewer. How this interface works on the" +
|
||||
" Previewer may be different from that on a real device.")
|
||||
},
|
||||
uniform4f: function (...args) {
|
||||
console.warn("webgl.uniform4f interface mocked in the Previewer. How this interface works on the" +
|
||||
" Previewer may be different from that on a real device.")
|
||||
},
|
||||
uniform1i: function (...args) {
|
||||
console.warn("webgl.uniform1i interface mocked in the Previewer. How this interface works on the" +
|
||||
" Previewer may be different from that on a real device.")
|
||||
},
|
||||
uniform2i: function (...args) {
|
||||
console.warn("webgl.uniform2i interface mocked in the Previewer. How this interface works on the" +
|
||||
" Previewer may be different from that on a real device.")
|
||||
},
|
||||
uniform3i: function (...args) {
|
||||
console.warn("webgl.uniform3i interface mocked in the Previewer. How this interface works on the" +
|
||||
" Previewer may be different from that on a real device.")
|
||||
},
|
||||
|
||||
uniform4i: function (...args) {
|
||||
console.warn("webgl.uniform4i interface mocked in the Previewer. How this interface works on the" +
|
||||
" Previewer may be different from that on a real device.")
|
||||
},
|
||||
useProgram: function (...args) {
|
||||
console.warn("webgl.useProgram interface mocked in the Previewer. How this interface works on the" +
|
||||
" Previewer may be different from that on a real device.")
|
||||
},
|
||||
validateProgram: function (...args) {
|
||||
console.warn("webgl.validateProgram interface mocked in the Previewer. How this interface works on the" +
|
||||
" Previewer may be different from that on a real device.")
|
||||
},
|
||||
vertexAttrib1f: function (...args) {
|
||||
console.warn("webgl.vertexAttrib1f interface mocked in the Previewer. How this interface works on the" +
|
||||
" Previewer may be different from that on a real device.")
|
||||
},
|
||||
vertexAttrib2f: function (...args) {
|
||||
console.warn("webgl.vertexAttrib2f interface mocked in the Previewer. How this interface works on the" +
|
||||
" Previewer may be different from that on a real device.")
|
||||
},
|
||||
|
||||
vertexAttrib3f: function (...args) {
|
||||
console.warn("webgl.vertexAttrib3f interface mocked in the Previewer. How this interface works on the" +
|
||||
" Previewer may be different from that on a real device.")
|
||||
},
|
||||
vertexAttrib4f: function (...args) {
|
||||
console.warn("webgl.vertexAttrib4f interface mocked in the Previewer. How this interface works on the" +
|
||||
" Previewer may be different from that on a real device.")
|
||||
},
|
||||
vertexAttrib1fv: function (...args) {
|
||||
console.warn("webgl.vertexAttrib1fv interface mocked in the Previewer. How this interface works on the" +
|
||||
" Previewer may be different from that on a real device.")
|
||||
},
|
||||
vertexAttrib2fv: function (...args) {
|
||||
console.warn("webgl.vertexAttrib2fv interface mocked in the Previewer. How this interface works on the" +
|
||||
" Previewer may be different from that on a real device.")
|
||||
},
|
||||
vertexAttrib3fv: function (...args) {
|
||||
console.warn("webgl.vertexAttrib3fv interface mocked in the Previewer. How this interface works on the" +
|
||||
" Previewer may be different from that on a real device.")
|
||||
},
|
||||
|
||||
vertexAttrib4fv: function (...args) {
|
||||
console.warn("webgl.vertexAttrib4fv interface mocked in the Previewer. How this interface works on the" +
|
||||
" Previewer may be different from that on a real device.")
|
||||
},
|
||||
vertexAttribPointer: function (...args) {
|
||||
console.warn("webgl.vertexAttribPointer interface mocked in the Previewer. How this interface works on the" +
|
||||
" Previewer may be different from that on a real device.")
|
||||
},
|
||||
viewport: function (...args) {
|
||||
console.warn("webgl.vertexAttrib3fv interface mocked in the Previewer. How this interface works on the" +
|
||||
" Previewer may be different from that on a real device.")
|
||||
},
|
||||
|
||||
bufferData: function (...args) {
|
||||
console.warn("webgl.bufferData interface mocked in the Previewer. How this interface works on the" +
|
||||
" Previewer may be different from that on a real device.")
|
||||
},
|
||||
bufferSubData: function (...args) {
|
||||
console.warn("webgl.bufferSubData interface mocked in the Previewer. How this interface works on the" +
|
||||
" Previewer may be different from that on a real device.")
|
||||
},
|
||||
compressedTexImage2D: function (...args) {
|
||||
console.warn("webgl.compressedTexImage2D interface mocked in the Previewer. How this interface works on the" +
|
||||
" Previewer may be different from that on a real device.")
|
||||
},
|
||||
compressedTexSubImage2D: function (...args) {
|
||||
console.warn("webgl.compressedTexSubImage2D interface mocked in the Previewer. How this interface works on the" +
|
||||
" Previewer may be different from that on a real device.")
|
||||
},
|
||||
readPixels: function (...args) {
|
||||
console.warn("webgl.readPixels interface mocked in the Previewer. How this interface works on the" +
|
||||
" Previewer may be different from that on a real device.")
|
||||
},
|
||||
|
||||
texImage2D: function (...args) {
|
||||
console.warn("webgl.texImage2D interface mocked in the Previewer. How this interface works on the" +
|
||||
" Previewer may be different from that on a real device.")
|
||||
},
|
||||
texSubImage2D: function (...args) {
|
||||
console.warn("webgl.texSubImage2D interface mocked in the Previewer. How this interface works on the" +
|
||||
" Previewer may be different from that on a real device.")
|
||||
},
|
||||
uniform1fv: function (...args) {
|
||||
console.warn("webgl.uniform1fv interface mocked in the Previewer. How this interface works on the" +
|
||||
" Previewer may be different from that on a real device.")
|
||||
},
|
||||
uniform2fv: function (...args) {
|
||||
console.warn("webgl.uniform2fv interface mocked in the Previewer. How this interface works on the" +
|
||||
" Previewer may be different from that on a real device.")
|
||||
},
|
||||
uniform3fv: function (...args) {
|
||||
console.warn("webgl.uniform3fv interface mocked in the Previewer. How this interface works on the" +
|
||||
" Previewer may be different from that on a real device.")
|
||||
},
|
||||
|
||||
uniform4fv: function (...args) {
|
||||
console.warn("webgl.uniform4fv interface mocked in the Previewer. How this interface works on the" +
|
||||
" Previewer may be different from that on a real device.")
|
||||
},
|
||||
uniform1iv: function (...args) {
|
||||
console.warn("webgl.uniform1iv interface mocked in the Previewer. How this interface works on the" +
|
||||
" Previewer may be different from that on a real device.")
|
||||
},
|
||||
uniform2iv: function (...args) {
|
||||
console.warn("webgl.uniform2iv interface mocked in the Previewer. How this interface works on the" +
|
||||
" Previewer may be different from that on a real device.")
|
||||
},
|
||||
uniform3iv: function (...args) {
|
||||
console.warn("webgl.uniform3iv interface mocked in the Previewer. How this interface works on the" +
|
||||
" Previewer may be different from that on a real device.")
|
||||
},
|
||||
uniform4iv: function (...args) {
|
||||
console.warn("webgl.uniform4iv interface mocked in the Previewer. How this interface works on the" +
|
||||
" Previewer may be different from that on a real device.")
|
||||
},
|
||||
|
||||
uniformMatrix2fv: function (...args) {
|
||||
console.warn("webgl.uniformMatrix2fv interface mocked in the Previewer. How this interface works on the" +
|
||||
" Previewer may be different from that on a real device.")
|
||||
},
|
||||
uniformMatrix3fv: function (...args) {
|
||||
console.warn("webgl.uniformMatrix3fv interface mocked in the Previewer. How this interface works on the" +
|
||||
" Previewer may be different from that on a real device.")
|
||||
},
|
||||
uniformMatrix4fv: function (...args) {
|
||||
console.warn("webgl.uniformMatrix4fv interface mocked in the Previewer. How this interface works on the" +
|
||||
" Previewer may be different from that on a real device.")
|
||||
}
|
||||
}
|
||||
return webglmock
|
||||
}
|
||||
@@ -0,0 +1,507 @@
|
||||
import { paramMock } from "../utils"
|
||||
|
||||
export function mockwebgl2() {
|
||||
const WebGLQuery = {
|
||||
}
|
||||
const WebGLSampler = {
|
||||
}
|
||||
const WebGLSync = {
|
||||
}
|
||||
const WebGLTransformFeedback = {
|
||||
}
|
||||
const WebGLVertexArrayObject = {
|
||||
}
|
||||
|
||||
const webgl2Mock = {
|
||||
paramDoubleMock: '[PC Preview] unknow double',
|
||||
paramAnyMock: '[PC Preview] unknow any',
|
||||
stringArray: '[PC preview] unknow stringArray',
|
||||
uint32Array: '[PC preview] unknow uint32Array',
|
||||
glBooleanArray: '[PC preview] unknow glBooleanArray',
|
||||
int32Array: '[PC preview] unknow int32Array',
|
||||
uintArray: '[PC preview] unknow uintArray',
|
||||
|
||||
copyBufferSubData: function (...args) {
|
||||
console.warn("webgl.copyBufferSubData interface mocked in the Previewer. How this interface works on the" +
|
||||
" Previewer may be different from that on a real device.")
|
||||
},
|
||||
getBufferSubData: function (...args) {
|
||||
console.warn("webgl.getBufferSubData interface mocked in the Previewer. How this interface works on the" +
|
||||
" Previewer may be different from that on a real device.")
|
||||
},
|
||||
blitFramebuffer: function (...args) {
|
||||
console.warn("webgl.blitFramebuffer interface mocked in the Previewer. How this interface works on the" +
|
||||
" Previewer may be different from that on a real device.")
|
||||
},
|
||||
framebufferTextureLayer: function (...args) {
|
||||
console.warn("webgl.framebufferTextureLayer interface mocked in the Previewer. How this interface works on the" +
|
||||
" Previewer may be different from that on a real device.")
|
||||
},
|
||||
invalidateFramebuffer: function (...args) {
|
||||
console.warn("webgl.invalidateFramebuffer interface mocked in the Previewer. How this interface works on the" +
|
||||
" Previewer may be different from that on a real device.")
|
||||
},
|
||||
|
||||
invalidateSubFramebuffer: function (...args) {
|
||||
console.warn("webgl.invalidateFramebuffer interface mocked in the Previewer. How this interface works on the" +
|
||||
" Previewer may be different from that on a real device.")
|
||||
},
|
||||
readBuffer: function (...args) {
|
||||
console.warn("webgl.readBuffer interface mocked in the Previewer. How this interface works on the" +
|
||||
" Previewer may be different from that on a real device.")
|
||||
},
|
||||
getInternalformatParameter: function (...args) {
|
||||
console.warn("webgl.getInternalformatParameter interface mocked in the Previewer. How this interface works on the" +
|
||||
" Previewer may be different from that on a real device.")
|
||||
if (pname == GL_SAMPLES) {
|
||||
return int32Array
|
||||
}
|
||||
},
|
||||
renderbufferStorageMultisample: function (...args) {
|
||||
console.warn("webgl.renderbufferStorageMultisample interface mocked in the Previewer. How this interface works on the" +
|
||||
" Previewer may be different from that on a real device.")
|
||||
},
|
||||
texStorage2D: function (...args) {
|
||||
console.warn("webgl.texStorage2D interface mocked in the Previewer. How this interface works on the" +
|
||||
" Previewer may be different from that on a real device.")
|
||||
},
|
||||
|
||||
texStorage3D: function (...args) {
|
||||
console.warn("webgl.texStorage3D interface mocked in the Previewer. How this interface works on the" +
|
||||
" Previewer may be different from that on a real device.")
|
||||
},
|
||||
texImage3D: function (...args) {
|
||||
console.warn("webgl.texImage3D interface mocked in the Previewer. How this interface works on the" +
|
||||
" Previewer may be different from that on a real device.")
|
||||
},
|
||||
texSubImage3D: function (...args) {
|
||||
console.warn("webgl.texSubImage3D interface mocked in the Previewer. How this interface works on the" +
|
||||
" Previewer may be different from that on a real device.")
|
||||
},
|
||||
copyTexSubImage3D: function (...args) {
|
||||
console.warn("webgl.copyTexSubImage3D interface mocked in the Previewer. How this interface works on the" +
|
||||
" Previewer may be different from that on a real device.")
|
||||
},
|
||||
compressedTexImage3D: function (...args) {
|
||||
console.warn("webgl.compressedTexImage3D interface mocked in the Previewer. How this interface works on the" +
|
||||
" Previewer may be different from that on a real device.")
|
||||
},
|
||||
|
||||
compressedTexSubImage3D: function (...args) {
|
||||
console.warn("webgl.compressedTexSubImage3D interface mocked in the Previewer. How this interface works on the" +
|
||||
" Previewer may be different from that on a real device.")
|
||||
},
|
||||
getFragDataLocation: function (...args) {
|
||||
console.warn("webgl.getFragDataLocation interface mocked in the Previewer. How this interface works on the" +
|
||||
" Previewer may be different from that on a real device.")
|
||||
return paramMock.paramNumberMock;
|
||||
},
|
||||
uniform1ui: function (...args) {
|
||||
console.warn("webgl.uniform1ui interface mocked in the Previewer. How this interface works on the" +
|
||||
" Previewer may be different from that on a real device.")
|
||||
},
|
||||
uniform2ui: function (...args) {
|
||||
console.warn("webgl.uniform2ui interface mocked in the Previewer. How this interface works on the" +
|
||||
" Previewer may be different from that on a real device.")
|
||||
},
|
||||
uniform3ui: function (...args) {
|
||||
console.warn("webgl.uniform3ui interface mocked in the Previewer. How this interface works on the" +
|
||||
" Previewer may be different from that on a real device.")
|
||||
},
|
||||
|
||||
uniform4ui: function (...args) {
|
||||
console.warn("webgl.uniform4ui interface mocked in the Previewer. How this interface works on the" +
|
||||
" Previewer may be different from that on a real device.")
|
||||
},
|
||||
uniform1uiv: function (...args) {
|
||||
console.warn("webgl.uniform1uiv interface mocked in the Previewer. How this interface works on the" +
|
||||
" Previewer may be different from that on a real device.")
|
||||
},
|
||||
uniform2uiv: function (...args) {
|
||||
console.warn("webgl.uniform2uiv interface mocked in the Previewer. How this interface works on the" +
|
||||
" Previewer may be different from that on a real device.")
|
||||
},
|
||||
uniform3uiv: function (...args) {
|
||||
console.warn("webgl.uniform3uiv interface mocked in the Previewer. How this interface works on the" +
|
||||
" Previewer may be different from that on a real device.")
|
||||
},
|
||||
uniform4uiv: function (...args) {
|
||||
console.warn("webgl.uniform4uiv interface mocked in the Previewer. How this interface works on the" +
|
||||
" Previewer may be different from that on a real device.")
|
||||
},
|
||||
|
||||
uniformMatrix3x2fv: function (...args) {
|
||||
console.warn("webgl.uniformMatrix3x2fv interface mocked in the Previewer. How this interface works on the" +
|
||||
" Previewer may be different from that on a real device.")
|
||||
},
|
||||
uniformMatrix4x2fv: function (...args) {
|
||||
console.warn("webgl.uniformMatrix4x2fv interface mocked in the Previewer. How this interface works on the" +
|
||||
" Previewer may be different from that on a real device.")
|
||||
},
|
||||
uniformMatrix2x3fv: function (...args) {
|
||||
console.warn("webgl.uniformMatrix2x3fv interface mocked in the Previewer. How this interface works on the" +
|
||||
" Previewer may be different from that on a real device.")
|
||||
},
|
||||
uniformMatrix4x3fv: function (...args) {
|
||||
console.warn("webgl.uniformMatrix4x3fv interface mocked in the Previewer. How this interface works on the" +
|
||||
" Previewer may be different from that on a real device.")
|
||||
},
|
||||
uniformMatrix2x4fv: function (...args) {
|
||||
console.warn("webgl.uniformMatrix2x4fv interface mocked in the Previewer. How this interface works on the" +
|
||||
" Previewer may be different from that on a real device.")
|
||||
},
|
||||
|
||||
uniformMatrix3x4fv: function (...args) {
|
||||
console.warn("webgl.uniformMatrix3x4fv interface mocked in the Previewer. How this interface works on the" +
|
||||
" Previewer may be different from that on a real device.")
|
||||
},
|
||||
vertexAttribI4i: function (...args) {
|
||||
console.warn("webgl.vertexAttribI4i interface mocked in the Previewer. How this interface works on the" +
|
||||
" Previewer may be different from that on a real device.")
|
||||
},
|
||||
vertexAttribI4iv: function (...args) {
|
||||
console.warn("webgl.vertexAttribI4iv interface mocked in the Previewer. How this interface works on the" +
|
||||
" Previewer may be different from that on a real device.")
|
||||
},
|
||||
vertexAttribI4ui: function (...args) {
|
||||
console.warn("webgl.vertexAttribI4ui interface mocked in the Previewer. How this interface works on the" +
|
||||
" Previewer may be different from that on a real device.")
|
||||
},
|
||||
vertexAttribI4uiv: function (...args) {
|
||||
console.warn("webgl.vertexAttribI4uiv interface mocked in the Previewer. How this interface works on the" +
|
||||
" Previewer may be different from that on a real device.")
|
||||
},
|
||||
|
||||
vertexAttribIPointer: function (...args) {
|
||||
console.warn("webgl.vertexAttribIPointer interface mocked in the Previewer. How this interface works on the" +
|
||||
" Previewer may be different from that on a real device.")
|
||||
},
|
||||
vertexAttribDivisor: function (...args) {
|
||||
console.warn("webgl.vertexAttribDivisor interface mocked in the Previewer. How this interface works on the" +
|
||||
" Previewer may be different from that on a real device.")
|
||||
},
|
||||
drawArraysInstanced: function (...args) {
|
||||
console.warn("webgl.drawArraysInstanced interface mocked in the Previewer. How this interface works on the" +
|
||||
" Previewer may be different from that on a real device.")
|
||||
},
|
||||
drawElementsInstanced: function (...args) {
|
||||
console.warn("webgl.drawElementsInstanced interface mocked in the Previewer. How this interface works on the" +
|
||||
" Previewer may be different from that on a real device.")
|
||||
},
|
||||
drawRangeElements: function (...args) {
|
||||
console.warn("webgl.drawRangeElements interface mocked in the Previewer. How this interface works on the" +
|
||||
" Previewer may be different from that on a real device.")
|
||||
},
|
||||
|
||||
drawBuffers: function (...args) {
|
||||
console.warn("webgl.drawBuffers interface mocked in the Previewer. How this interface works on the" +
|
||||
" Previewer may be different from that on a real device.")
|
||||
},
|
||||
clearBufferfv: function (...args) {
|
||||
console.warn("webgl.clearBufferfv interface mocked in the Previewer. How this interface works on the" +
|
||||
" Previewer may be different from that on a real device.")
|
||||
},
|
||||
clearBufferiv: function (...args) {
|
||||
console.warn("webgl.clearBufferiv interface mocked in the Previewer. How this interface works on the" +
|
||||
" Previewer may be different from that on a real device.")
|
||||
},
|
||||
clearBufferuiv: function (...args) {
|
||||
console.warn("webgl.clearBufferuiv interface mocked in the Previewer. How this interface works on the" +
|
||||
" Previewer may be different from that on a real device.")
|
||||
},
|
||||
clearBufferfi: function (...args) {
|
||||
console.warn("webgl.clearBufferfi interface mocked in the Previewer. How this interface works on the" +
|
||||
" Previewer may be different from that on a real device.")
|
||||
},
|
||||
|
||||
createQuery: function (...args) {
|
||||
console.warn("webgl.createQuery interface mocked in the Previewer. How this interface works on the" +
|
||||
" Previewer may be different from that on a real device.")
|
||||
return WebGLQuery;
|
||||
},
|
||||
deleteQuery: function (...args) {
|
||||
console.warn("webgl.deleteQuery interface mocked in the Previewer. How this interface works on the" +
|
||||
" Previewer may be different from that on a real device.")
|
||||
},
|
||||
isQuery: function (...args) {
|
||||
console.warn("webgl.isQuery interface mocked in the Previewer. How this interface works on the" +
|
||||
" Previewer may be different from that on a real device.")
|
||||
return paramMock.paramBooleanMock;
|
||||
},
|
||||
beginQuery: function (...args) {
|
||||
console.warn("webgl.beginQuery interface mocked in the Previewer. How this interface works on the" +
|
||||
" Previewer may be different from that on a real device.")
|
||||
},
|
||||
endQuery: function (...args) {
|
||||
console.warn("webgl.endQuery interface mocked in the Previewer. How this interface works on the" +
|
||||
" Previewer may be different from that on a real device.")
|
||||
},
|
||||
|
||||
getQuery: function (...args) {
|
||||
console.warn("webgl2.getQuery interface mocked in the Previewer. How this interface works on the" +
|
||||
" Previewer may be different from that on a real device.")
|
||||
return WebGLQuery;
|
||||
},
|
||||
getQueryParameter: function (...args) {
|
||||
console.warn("webgl2.getQueryParameter interface mocked in the Previewer. How this interface works on the" +
|
||||
" Previewer may be different from that on a real device.")
|
||||
if (args[1] == GL_QUERY_RESULT) {
|
||||
return paramMock.paramNumberMock;
|
||||
} else if (args[1] == GL_QUERY_RESULT_AVAILABLE) {
|
||||
return paramMock.paramBooleanMock;
|
||||
}
|
||||
},
|
||||
createSampler: function (...args) {
|
||||
console.warn("webgl2.createSampler interface mocked in the Previewer. How this interface works on the" +
|
||||
" Previewer may be different from that on a real device.")
|
||||
return WebGLSampler;
|
||||
},
|
||||
deleteSampler: function (...args) {
|
||||
console.warn("webgl2.deleteSampler interface mocked in the Previewer. How this interface works on the" +
|
||||
" Previewer may be different from that on a real device.")
|
||||
},
|
||||
isSampler: function (...args) {
|
||||
console.warn("webgl2.isSampler interface mocked in the Previewer. How this interface works on the" +
|
||||
" Previewer may be different from that on a real device.")
|
||||
return paramMock.paramBooleanMock;
|
||||
},
|
||||
|
||||
bindSampler: function (...args) {
|
||||
console.warn("webgl2.bindSampler interface mocked in the Previewer. How this interface works on the" +
|
||||
" Previewer may be different from that on a real device.")
|
||||
},
|
||||
samplerParameteri: function (...args) {
|
||||
console.warn("webgl2.samplerParameteri interface mocked in the Previewer. How this interface works on the" +
|
||||
" Previewer may be different from that on a real device.")
|
||||
},
|
||||
samplerParameterf: function (...args) {
|
||||
console.warn("webgl2.samplerParameterf interface mocked in the Previewer. How this interface works on the" +
|
||||
" Previewer may be different from that on a real device.")
|
||||
},
|
||||
getSamplerParameter: function (...args) {
|
||||
console.warn("webgl2.getSamplerParameter interface mocked in the Previewer. How this interface works on the" +
|
||||
" Previewer may be different from that on a real device.")
|
||||
if (args[1] == GL_TEXTURE_MAX_LOD || pName == GL_TEXTURE_MIN_LOD) {
|
||||
return paramDoubleMock;
|
||||
} else {
|
||||
return paramMock.paramNumberMock;
|
||||
}
|
||||
},
|
||||
fenceSync: function (...args) {
|
||||
console.warn("webgl2.fenceSync interface mocked in the Previewer. How this interface works on the" +
|
||||
" Previewer may be different from that on a real device.")
|
||||
return WebGLSync;
|
||||
},
|
||||
|
||||
isSync: function (...args) {
|
||||
console.warn("webgl2.isSync interface mocked in the Previewer. How this interface works on the" +
|
||||
" Previewer may be different from that on a real device.")
|
||||
return paramMock.paramBooleanMock;
|
||||
},
|
||||
deleteSync: function (...args) {
|
||||
console.warn("webgl2.deleteSync interface mocked in the Previewer. How this interface works on the" +
|
||||
" Previewer may be different from that on a real device.")
|
||||
},
|
||||
clientWaitSync: function (...args) {
|
||||
console.warn("webgl2.clientWaitSync interface mocked in the Previewer. How this interface works on the" +
|
||||
" Previewer may be different from that on a real device.")
|
||||
return paramMock.paramNumberMock;
|
||||
},
|
||||
waitSync: function (...args) {
|
||||
console.warn("webgl2.waitSync interface mocked in the Previewer. How this interface works on the" +
|
||||
" Previewer may be different from that on a real device.")
|
||||
},
|
||||
getSyncParameter: function (...args) {
|
||||
console.warn("webgl2.getSyncParameter interface mocked in the Previewer. How this interface works on the" +
|
||||
" Previewer may be different from that on a real device.")
|
||||
return paramAnyMock;
|
||||
},
|
||||
|
||||
createTransformFeedback: function (...args) {
|
||||
console.warn("webgl2.createTransformFeedback interface mocked in the Previewer. How this interface works on the" +
|
||||
" Previewer may be different from that on a real device.")
|
||||
return WebGLTransformFeedback;
|
||||
},
|
||||
deleteTransformFeedback: function (...args) {
|
||||
console.warn("webgl2.deleteTransformFeedback interface mocked in the Previewer. How this interface works on the" +
|
||||
" Previewer may be different from that on a real device.")
|
||||
},
|
||||
isTransformFeedback: function (...args) {
|
||||
console.warn("webgl2.isTransformFeedback interface mocked in the Previewer. How this interface works on the" +
|
||||
" Previewer may be different from that on a real device.")
|
||||
return paramMock.paramBooleanMock;
|
||||
},
|
||||
bindTransformFeedback: function (...args) {
|
||||
console.warn("webgl2.bindTransformFeedback interface mocked in the Previewer. How this interface works on the" +
|
||||
" Previewer may be different from that on a real device.")
|
||||
},
|
||||
beginTransformFeedback: function (...args) {
|
||||
console.warn("webgl2.beginTransformFeedback interface mocked in the Previewer. How this interface works on the" +
|
||||
" Previewer may be different from that on a real device.")
|
||||
},
|
||||
|
||||
endTransformFeedback: function (...args) {
|
||||
console.warn("webgl2.endTransformFeedback interface mocked in the Previewer. How this interface works on the" +
|
||||
" Previewer may be different from that on a real device.")
|
||||
},
|
||||
transformFeedbackVaryings: function (...args) {
|
||||
console.warn("webgl2.transformFeedbackVaryings interface mocked in the Previewer. How this interface works on the" +
|
||||
" Previewer may be different from that on a real device.")
|
||||
},
|
||||
getTransformFeedbackVarying: function (...args) {
|
||||
console.warn("webgl2.getTransformFeedbackVarying interface mocked in the Previewer. How this interface works on the" +
|
||||
" Previewer may be different from that on a real device.")
|
||||
return WebGLActiveInfo;
|
||||
},
|
||||
pauseTransformFeedback: function (...args) {
|
||||
console.warn("webgl2.pauseTransformFeedback interface mocked in the Previewer. How this interface works on the" +
|
||||
" Previewer may be different from that on a real device.")
|
||||
},
|
||||
resumeTransformFeedback: function (...args) {
|
||||
console.warn("webgl2.resumeTransformFeedback interface mocked in the Previewer. How this interface works on the" +
|
||||
" Previewer may be different from that on a real device.")
|
||||
},
|
||||
|
||||
bindBufferBase: function (...args) {
|
||||
console.warn("webgl2.bindBufferBase interface mocked in the Previewer. How this interface works on the" +
|
||||
" Previewer may be different from that on a real device.")
|
||||
},
|
||||
bindBufferRange: function (...args) {
|
||||
console.warn("webgl2.bindBufferRange interface mocked in the Previewer. How this interface works on the" +
|
||||
" Previewer may be different from that on a real device.")
|
||||
},
|
||||
getIndexedParameter: function (...args) {
|
||||
console.warn("webgl2.getIndexedParameter interface mocked in the Previewer. How this interface works on the" +
|
||||
" Previewer may be different from that on a real device.")
|
||||
return paramAnyMock;
|
||||
},
|
||||
getUniformIndices: function (...args) {
|
||||
console.warn("webgl2.getUniformIndices interface mocked in the Previewer. How this interface works on the" +
|
||||
" Previewer may be different from that on a real device.")
|
||||
return uintArray;
|
||||
},
|
||||
getActiveUniforms: function (...args) {
|
||||
console.warn("webgl2.getActiveUniforms interface mocked in the Previewer. How this interface works on the" +
|
||||
" Previewer may be different from that on a real device.")
|
||||
return paramAnyMock;
|
||||
},
|
||||
|
||||
getUniformBlockIndex: function (...args) {
|
||||
console.warn("webgl2.getUniformBlockIndex interface mocked in the Previewer. How this interface works on the" +
|
||||
" Previewer may be different from that on a real device.")
|
||||
return paramMock.paramNumberMock;
|
||||
},
|
||||
getActiveUniformBlockParameter: function (...args) {
|
||||
console.warn("webgl2.getActiveUniformBlockParameter interface mocked in the Previewer. How this interface works on the" +
|
||||
" Previewer may be different from that on a real device.")
|
||||
return paramAnyMock;
|
||||
},
|
||||
getActiveUniformBlockName: function (...args) {
|
||||
console.warn("webgl2.getActiveUniformBlockName interface mocked in the Previewer. How this interface works on the" +
|
||||
" Previewer may be different from that on a real device.")
|
||||
return paramMock.paramStringMock;
|
||||
},
|
||||
uniformBlockBinding: function (...args) {
|
||||
console.warn("webgl2.uniformBlockBinding interface mocked in the Previewer. How this interface works on the" +
|
||||
" Previewer may be different from that on a real device.")
|
||||
},
|
||||
createVertexArray: function (...args) {
|
||||
console.warn("webgl2.createVertexArray interface mocked in the Previewer. How this interface works on the" +
|
||||
" Previewer may be different from that on a real device.")
|
||||
return WebGLVertexArrayObject;
|
||||
},
|
||||
|
||||
deleteVertexArray: function (...args) {
|
||||
console.warn("webgl2.deleteVertexArray interface mocked in the Previewer. How this interface works on the" +
|
||||
" Previewer may be different from that on a real device.")
|
||||
},
|
||||
isVertexArray: function (...args) {
|
||||
console.warn("webgl2.isVertexArray interface mocked in the Previewer. How this interface works on the" +
|
||||
" Previewer may be different from that on a real device.")
|
||||
return paramMock.paramBooleanMock;
|
||||
},
|
||||
bindVertexArray: function (...args) {
|
||||
console.warn("webgl2.bindVertexArray interface mocked in the Previewer. How this interface works on the" +
|
||||
" Previewer may be different from that on a real device.")
|
||||
},
|
||||
|
||||
bufferData: function (...args) {
|
||||
console.warn("webgl2.bufferData interface mocked in the Previewer. How this interface works on the" +
|
||||
" Previewer may be different from that on a real device.")
|
||||
},
|
||||
bufferSubData: function (...args) {
|
||||
console.warn("webgl2.bufferSubData interface mocked in the Previewer. How this interface works on the" +
|
||||
" Previewer may be different from that on a real device.")
|
||||
},
|
||||
texImage2D: function (...args) {
|
||||
|
||||
console.warn("webgl2.texImage2D interface mocked in the Previewer. How this interface works on the" +
|
||||
" Previewer may be different from that on a real device.")
|
||||
},
|
||||
texSubImage2D: function (...args) {
|
||||
console.warn("webgl2.texSubImage2D interface mocked in the Previewer. How this interface works on the" +
|
||||
" Previewer may be different from that on a real device.")
|
||||
},
|
||||
compressedTexImage2D: function (...args) {
|
||||
console.warn("webgl2.compressedTexImage2D interface mocked in the Previewer. How this interface works on the" +
|
||||
" Previewer may be different from that on a real device.")
|
||||
},
|
||||
|
||||
compressedTexSubImage2D: function (...args) {
|
||||
console.warn("webgl2.compressedTexSubImage2D interface mocked in the Previewer. How this interface works on the" +
|
||||
" Previewer may be different from that on a real device.")
|
||||
},
|
||||
uniform1fv: function (...args) {
|
||||
console.warn("webgl2.uniform1fv interface mocked in the Previewer. How this interface works on the" +
|
||||
" Previewer may be different from that on a real device.")
|
||||
},
|
||||
uniform2fv: function (...args) {
|
||||
console.warn("webgl2.uniform2fv interface mocked in the Previewer. How this interface works on the" +
|
||||
" Previewer may be different from that on a real device.")
|
||||
},
|
||||
uniform3fv: function (...args) {
|
||||
console.warn("webgl2.uniform3fv interface mocked in the Previewer. How this interface works on the" +
|
||||
" Previewer may be different from that on a real device.")
|
||||
},
|
||||
uniform4fv: function (...args) {
|
||||
console.warn("webgl2.uniform4fv interface mocked in the Previewer. How this interface works on the" +
|
||||
" Previewer may be different from that on a real device.")
|
||||
},
|
||||
|
||||
uniform1iv: function (...args) {
|
||||
console.warn("webgl2.uniform1iv interface mocked in the Previewer. How this interface works on the" +
|
||||
" Previewer may be different from that on a real device.")
|
||||
},
|
||||
uniform2iv: function (...args) {
|
||||
console.warn("webgl2.uniform2iv interface mocked in the Previewer. How this interface works on the" +
|
||||
" Previewer may be different from that on a real device.")
|
||||
},
|
||||
uniform3iv: function (...args) {
|
||||
console.warn("webgl2.uniform3iv interface mocked in the Previewer. How this interface works on the" +
|
||||
" Previewer may be different from that on a real device.")
|
||||
},
|
||||
uniform4iv: function (...args) {
|
||||
console.warn("webgl2.uniform4iv interface mocked in the Previewer. How this interface works on the" +
|
||||
" Previewer may be different from that on a real device.")
|
||||
},
|
||||
uniformMatrix2fv: function (...args) {
|
||||
console.warn("webgl2.uniformMatrix2fv interface mocked in the Previewer. How this interface works on the" +
|
||||
" Previewer may be different from that on a real device.")
|
||||
},
|
||||
|
||||
uniformMatrix3fv: function (...args) {
|
||||
console.warn("webgl2.uniformMatrix3fv interface mocked in the Previewer. How this interface works on the" +
|
||||
" Previewer may be different from that on a real device.")
|
||||
},
|
||||
uniformMatrix4fv: function (...args) {
|
||||
console.warn("webgl2.uniformMatrix4fv interface mocked in the Previewer. How this interface works on the" +
|
||||
" Previewer may be different from that on a real device.")
|
||||
},
|
||||
readPixels: function (...args) {
|
||||
console.warn("webgl2.readPixels interface mocked in the Previewer. How this interface works on the" +
|
||||
" Previewer may be different from that on a real device.")
|
||||
}
|
||||
}
|
||||
return webgl2Mock;
|
||||
|
||||
}
|
||||
@@ -1,137 +1,499 @@
|
||||
import { paramMock } from "./utils"
|
||||
import {paramMock} from "./utils"
|
||||
|
||||
export function mockWebSocket() {
|
||||
global.systemplugin.net = {}
|
||||
const WebSocketMock = {
|
||||
connect: function (...args) {
|
||||
console.warn("WebSocket.connect interface mocked in the Previewer. How this interface works on the Previewer" +
|
||||
" may be different from that on a real device.")
|
||||
const len = args.length
|
||||
if (typeof args[len - 1] === 'function') {
|
||||
args[len - 1].call(this, paramMock.businessErrorMock, paramMock.paramBooleanMock);
|
||||
} else {
|
||||
return new Promise((resolve, reject) => {
|
||||
resolve(paramMock.paramBooleanMock);
|
||||
})
|
||||
connect: function (...args) {
|
||||
console.warn("WebSocket.connect interface mocked in the Previewer. How this interface works on the Previewer" +
|
||||
" may be different from that on a real device.")
|
||||
const len = args.length
|
||||
if (typeof args[len - 1] === 'function') {
|
||||
args[len - 1].call(this, paramMock.businessErrorMock, paramMock.paramBooleanMock);
|
||||
} else {
|
||||
return new Promise((resolve, reject) => {
|
||||
resolve(paramMock.paramBooleanMock);
|
||||
})
|
||||
}
|
||||
},
|
||||
send: function (...args) {
|
||||
console.warn("WebSocket.send interface mocked in the Previewer. How this interface works on the Previewer may" +
|
||||
" be different from that on a real device.")
|
||||
const len = args.length
|
||||
if (typeof args[len - 1] === 'function') {
|
||||
args[len - 1].call(this, paramMock.businessErrorMock, paramMock.paramBooleanMock);
|
||||
} else {
|
||||
return new Promise((resolve, reject) => {
|
||||
resolve(paramMock.paramBooleanMock);
|
||||
})
|
||||
}
|
||||
},
|
||||
close: function (...args) {
|
||||
console.warn("WebSocket.close interface mocked in the Previewer. How this interface works on the Previewer " +
|
||||
"may be different from that on a real device.")
|
||||
const len = args.length
|
||||
if (typeof args[len - 1] === 'function') {
|
||||
args[len - 1].call(this, paramMock.businessErrorMock, paramMock.paramBooleanMock);
|
||||
} else {
|
||||
return new Promise((resolve, reject) => {
|
||||
resolve(paramMock.paramBooleanMock);
|
||||
})
|
||||
}
|
||||
},
|
||||
on: function (...args) {
|
||||
console.warn("WebSocket.on interface mocked in the Previewer. How this interface works on the Previewer may " +
|
||||
"be different from that on a real device.")
|
||||
const len = args.length
|
||||
if (typeof args[len - 1] === 'function') {
|
||||
if (args[0] === 'open') {
|
||||
args[len - 1].call(this, paramMock.businessErrorMock, paramMock.paramObjectMock);
|
||||
} else if (args[0] === 'message') {
|
||||
args[len - 1].call(this, paramMock.businessErrorMock, paramMock.paramStringMock);
|
||||
} else if (args[0] === 'close') {
|
||||
args[len - 1].call(this, paramMock.businessErrorMock, {
|
||||
code: "[PC Preview] unknow code",
|
||||
reason: "[PC Preview] unknow reason"
|
||||
});
|
||||
} else if (args[0] === 'error') {
|
||||
args[len - 1].call(this, paramMock.businessErrorMock);
|
||||
}
|
||||
}
|
||||
},
|
||||
off: function (...args) {
|
||||
console.warn("WebSocket.off interface mocked in the Previewer. How this interface works on the Previewer may" +
|
||||
" be different from that on a real device.")
|
||||
const len = args.length
|
||||
if (typeof args[len - 1] === 'function') {
|
||||
if (args[0] === 'open') {
|
||||
args[len - 1].call(this, paramMock.businessErrorMock, paramMock.paramObjectMock);
|
||||
} else if (args[0] === 'message') {
|
||||
args[len - 1].call(this, paramMock.businessErrorMock, paramMock.paramStringMock);
|
||||
} else if (args[0] === 'close') {
|
||||
args[len - 1].call(this, paramMock.businessErrorMock,{
|
||||
code: "[PC Preview] unknow code",
|
||||
reason: "[PC Preview] unknow reason"
|
||||
});
|
||||
} else if (args[0] === 'error') {
|
||||
args[len - 1].call(this, paramMock.businessErrorMock);
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
send: function (...args) {
|
||||
console.warn("WebSocket.send interface mocked in the Previewer. How this interface works on the Previewer may" +
|
||||
" be different from that on a real device.")
|
||||
const len = args.length
|
||||
if (typeof args[len - 1] === 'function') {
|
||||
args[len - 1].call(this, paramMock.businessErrorMock, paramMock.paramBooleanMock);
|
||||
} else {
|
||||
return new Promise((resolve, reject) => {
|
||||
resolve(paramMock.paramBooleanMock);
|
||||
})
|
||||
}
|
||||
},
|
||||
close: function (...args) {
|
||||
console.warn("WebSocket.close interface mocked in the Previewer. How this interface works on the Previewer " +
|
||||
"may be different from that on a real device.")
|
||||
const len = args.length
|
||||
if (typeof args[len - 1] === 'function') {
|
||||
args[len - 1].call(this, paramMock.businessErrorMock, paramMock.paramBooleanMock);
|
||||
} else {
|
||||
return new Promise((resolve, reject) => {
|
||||
resolve(paramMock.paramBooleanMock);
|
||||
})
|
||||
}
|
||||
},
|
||||
on: function (...args) {
|
||||
console.warn("WebSocket.on interface mocked in the Previewer. How this interface works on the Previewer may " +
|
||||
"be different from that on a real device.")
|
||||
const len = args.length
|
||||
if (typeof args[len - 1] === 'function') {
|
||||
if (args[0] == 'open') {
|
||||
args[len - 1].call(this, paramMock.businessErrorMock, paramMock.paramObjectMock);
|
||||
} else if (args[0] == 'message') {
|
||||
args[len - 1].call(this, paramMock.businessErrorMock, paramMock.paramStringMock);
|
||||
} else if (args[0] == 'close') {
|
||||
args[len - 1].call(this, {
|
||||
code: "[PC Preview] unknow code",
|
||||
reason: "[PC Preview] unknow reason"
|
||||
});
|
||||
} else if (args[0] == 'error') {
|
||||
args[len - 1].call(this, paramMock.businessErrorMock);
|
||||
}
|
||||
}
|
||||
},
|
||||
off: function (...args) {
|
||||
console.warn("WebSocket.off interface mocked in the Previewer. How this interface works on the Previewer may" +
|
||||
" be different from that on a real device.")
|
||||
const len = args.length
|
||||
if (typeof args[len - 1] === 'function') {
|
||||
if (args[0] == 'open') {
|
||||
args[len - 1].call(this, paramMock.businessErrorMock, paramMock.paramObjectMock);
|
||||
} else if (args[0] == 'message') {
|
||||
args[len - 1].call(this, paramMock.businessErrorMock, paramMock.paramStringMock);
|
||||
} else if (args[0] == 'close') {
|
||||
args[len - 1].call(this, {
|
||||
code: "[PC Preview] unknow code",
|
||||
reason: "[PC Preview] unknow reason"
|
||||
});
|
||||
} else if (args[0] == 'error') {
|
||||
args[len - 1].call(this, paramMock.businessErrorMock);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
global.systemplugin.net.webSocket = {
|
||||
createWebSocket: function () {
|
||||
console.warn("net.webSocket.createWebSocket interface mocked in the Previewer. How this interface works on the" +
|
||||
" Previewer may be different from that on a real device.")
|
||||
return WebSocketMock;
|
||||
}
|
||||
createWebSocket: function () {
|
||||
console.warn("net.webSocket.createWebSocket interface mocked in the Previewer. How this interface works on the" +
|
||||
" Previewer may be different from that on a real device.")
|
||||
return WebSocketMock;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
export function mockHttp() {
|
||||
const HttpResponseMock = {
|
||||
result: "[PC Preview] unknow result",
|
||||
responseCode: "[PC Preview] unknow responseCode",
|
||||
header: "[PC Preview] unknow header"
|
||||
}
|
||||
const HttpRequestMock = {
|
||||
request: function (...args) {
|
||||
console.warn("HttpRequest.request interface mocked in the Previewer. How this interface works on the Previewer" +
|
||||
" may be different from that on a real device.")
|
||||
const len = args.length
|
||||
if (typeof args[len - 1] === 'function') {
|
||||
args[len - 1].call(this, paramMock.businessErrorMock, HttpResponseMock);
|
||||
} else {
|
||||
return new Promise((resolve, reject) => {
|
||||
resolve(HttpResponseMock);
|
||||
})
|
||||
const HttpResponseMock = {
|
||||
result: "[PC Preview] unknow result",
|
||||
responseCode: "[PC Preview] unknow responseCode",
|
||||
header: "[PC Preview] unknow header"
|
||||
}
|
||||
const HttpRequestMock = {
|
||||
request: function (...args) {
|
||||
console.warn("HttpRequest.request interface mocked in the Previewer. How this interface works on the Previewer" +
|
||||
" may be different from that on a real device.")
|
||||
const len = args.length
|
||||
if (typeof args[len - 1] === 'function') {
|
||||
args[len - 1].call(this, paramMock.businessErrorMock, HttpResponseMock);
|
||||
} else {
|
||||
return new Promise((resolve, reject) => {
|
||||
resolve(HttpResponseMock);
|
||||
})
|
||||
}
|
||||
},
|
||||
destroy: function () {
|
||||
console.warn("HttpRequest.destroy interface mocked in the Previewer. How this interface works on the Previewer" +
|
||||
" may be different from that on a real device.")
|
||||
},
|
||||
on: function (...args) {
|
||||
console.warn("HttpRequest.on interface mocked in the Previewer. How this interface works on the Previewer may" +
|
||||
" be different from that on a real device.")
|
||||
const len = args.length
|
||||
if (typeof args[len - 1] === 'function') {
|
||||
args[len - 1].call(this, paramMock.businessErrorMock, paramMock.paramObjectMock);
|
||||
}
|
||||
},
|
||||
off: function (...args) {
|
||||
console.warn("HttpRequest.off interface mocked in the Previewer. How this interface works on the Previewer may" +
|
||||
" be different from that on a real device.")
|
||||
const len = args.length
|
||||
if (typeof args[len - 1] === 'function') {
|
||||
args[len - 1].call(this, paramMock.businessErrorMock, paramMock.paramObjectMock);
|
||||
}
|
||||
}
|
||||
}
|
||||
global.systemplugin.net.http = {
|
||||
createHttp: function () {
|
||||
console.warn("net.http.createHttp interface mocked in the Previewer. How this interface works on the Previewer" +
|
||||
" may be different from that on a real device.")
|
||||
return HttpRequestMock;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
export function mockMdns() {
|
||||
const localServiceInfoMock = {
|
||||
serviceType: "[PC Preview] unknow serviceType",
|
||||
serviceName: "[PC Preview] unknow serviceName",
|
||||
host: "[PC Preview] unknow host",
|
||||
port: "[PC Preview] unknow port"
|
||||
}
|
||||
global.systemplugin.net.mdns = {
|
||||
on: function (...args) {
|
||||
console.warn("net.mdns.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] === 'serviceAdd') {
|
||||
args[len - 1].call(this, {serviceInfo : localServiceInfoMock, errorCode: 0});
|
||||
} else if (args[0] === 'serviceRemove') {
|
||||
args[len - 1].call(this, {serviceInfo : localServiceInfoMock, errorCode: 0});
|
||||
} else if (args[0] === 'serviceStart') {
|
||||
args[len - 1].call(this, {serviceInfo : localServiceInfoMock, errorCode: 0});
|
||||
} else if (args[0] === 'serviceStop') {
|
||||
args[len - 1].call(this, {serviceInfo : localServiceInfoMock, errorCode: 0});
|
||||
} else if (args[0] === 'serviceFound') {
|
||||
args[len - 1].call(this, localServiceInfoMock);
|
||||
} else if (args[0] === 'serviceLost') {
|
||||
args[len - 1].call(this, localServiceInfoMock);
|
||||
} else if (args[0] === 'serviceResolve') {
|
||||
args[len - 1].call(this, {serviceInfo : localServiceInfoMock, errorCode: 0});
|
||||
} else if (args[0] === 'serviceLost') {
|
||||
args[len - 1].call(this, {serviceInfo : localServiceInfoMock, errorCode: 0});
|
||||
} else if (args[0] === 'error') {
|
||||
args[len - 1].call(this, {serviceInfo : localServiceInfoMock, errorCode: 0});
|
||||
} else {
|
||||
args[len - 1].call(this);
|
||||
}
|
||||
}
|
||||
},
|
||||
off: function (...args) {
|
||||
console.warn("net.mdns.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 (args[0] === 'serviceAdd') {
|
||||
args[len - 1].call(this, {serviceInfo : localServiceInfoMock, errorCode: 0});
|
||||
} else if (args[0] === 'serviceRemove') {
|
||||
args[len - 1].call(this, {serviceInfo : localServiceInfoMock, errorCode: 0});
|
||||
} else if (args[0] === 'serviceStart') {
|
||||
args[len - 1].call(this, {serviceInfo : localServiceInfoMock, errorCode: 0});
|
||||
} else if (args[0] === 'serviceStop') {
|
||||
args[len - 1].call(this, {serviceInfo : localServiceInfoMock, errorCode: 0});
|
||||
} else if (args[0] === 'serviceFound') {
|
||||
args[len - 1].call(this, localServiceInfoMock);
|
||||
} else if (args[0] === 'serviceLost') {
|
||||
args[len - 1].call(this, localServiceInfoMock);
|
||||
} else if (args[0] === 'serviceResolve') {
|
||||
args[len - 1].call(this, {serviceInfo : localServiceInfoMock, errorCode: 0});
|
||||
} else if (args[0] === 'serviceLost') {
|
||||
args[len - 1].call(this, {serviceInfo : localServiceInfoMock, errorCode: 0});
|
||||
} else if (args[0] === 'error') {
|
||||
args[len - 1].call(this, {serviceInfo : localServiceInfoMock, errorCode: 0});
|
||||
} else {
|
||||
args[len - 1].call(this);
|
||||
}
|
||||
},
|
||||
addLocalService: function (...args) {
|
||||
console.warn("net.mdns.addLocalService interface mocked in the Previewer. How this interface works on the Previewer may" +
|
||||
" be different from that on a 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();
|
||||
})
|
||||
}
|
||||
},
|
||||
removeLocalService: function (...args) {
|
||||
console.warn("net.mdns.removeLocalService interface mocked in the Previewer. How this interface works on the Previewer may" +
|
||||
" be different from that on a 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();
|
||||
})
|
||||
}
|
||||
},
|
||||
startSearchingMDNS: function (...args) {
|
||||
console.warn("net.mdns.startSearchingMDNS interface mocked in the Previewer. How this interface works on the Previewer may" +
|
||||
" be different from that on a 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();
|
||||
})
|
||||
}
|
||||
},
|
||||
stopSearchingMDNS: function (...args) {
|
||||
console.warn("net.mdns.stopSearchingMDNS interface mocked in the Previewer. How this interface works on the Previewer may" +
|
||||
" be different from that on a 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();
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
export function mockSocket(){
|
||||
const SocketStateBase = {
|
||||
isBound: "[PC Preview] unknow isBound",
|
||||
isClose: "[PC Preview] unknow isClose",
|
||||
isConnected: "[PC Preview] unknow isConnected"
|
||||
}
|
||||
const SocketRemoteInfo = {
|
||||
address: "[PC Preview] unknow address",
|
||||
family: "[PC Preview] unknow family",
|
||||
port: "[PC Preview] unknow port",
|
||||
size: "[PC Preview] unknow size"
|
||||
}
|
||||
const NetAddress = {
|
||||
address: "[PC Preview] unknow saddressize",
|
||||
family: "[PC Preview] unknow family",
|
||||
port: "[PC Preview] unknow port "
|
||||
}
|
||||
const UDPSocket = {
|
||||
bind: function (...args){
|
||||
console.warn("UDPSocket.bind interface mocked in the Previewer. How this interface works on the Previewer" +
|
||||
" may be different from that on a real device.")
|
||||
const len = args.length
|
||||
if( typeof args[len - 1] === 'function') {
|
||||
args[len -1].call(this, paramMock.businessErrorMock)
|
||||
} else {
|
||||
return new Promise((resolve, reject) => {
|
||||
resolve();
|
||||
})
|
||||
}
|
||||
},
|
||||
send: function (...args) {
|
||||
console.warn("UDPSocket.send interface mocked in the Previewer. How this interface works on the Previewer may" +
|
||||
" be different from that on a real device.")
|
||||
const len = args.length
|
||||
if( typeof args[len - 1] === 'function') {
|
||||
args[len -1].call(this, paramMock.businessErrorMock)
|
||||
} else {
|
||||
return new Promise((resolve, reject) => {
|
||||
resolve();
|
||||
})
|
||||
}
|
||||
},
|
||||
close: function (...args) {
|
||||
console.warn("UDPSocket.close interface mocked in the Previewer. How this interface works on the Previewer may" +
|
||||
" be different from that on a real device.")
|
||||
const len = args.length
|
||||
if( typeof args[len - 1] === 'function') {
|
||||
args[len -1].call(this, paramMock.businessErrorMock)
|
||||
} else {
|
||||
return new Promise((resolve, reject) => {
|
||||
resolve();
|
||||
})
|
||||
}
|
||||
},
|
||||
getState: function (...args) {
|
||||
console.warn("UDPSocket.getState interface mocked in the Previewer. How this interface works on the Previewer may" +
|
||||
" be different from that on a real device.")
|
||||
const len = args.length
|
||||
if( typeof args[len - 1] === 'function') {
|
||||
args[len -1].call(this, paramMock.businessErrorMock, SocketStateBase)
|
||||
} else {
|
||||
return new Promise((resolve, reject) => {
|
||||
resolve(SocketStateBase);
|
||||
})
|
||||
}
|
||||
},
|
||||
setExtraOptions: function (...args) {
|
||||
console.warn("UDPSocket.setExtraOptions interface mocked in the Previewer. How this interface works on the Previewer may" +
|
||||
" be different from that on a real device.")
|
||||
const len = args.length
|
||||
if( typeof args[len - 1] === 'function') {
|
||||
args[len -1].call(this, paramMock.businessErrorMock)
|
||||
} else {
|
||||
return new Promise((resolve, reject) => {
|
||||
resolve();
|
||||
})
|
||||
}
|
||||
},
|
||||
on: function (...args) {
|
||||
console.warn("UDPSocket.on interface mocked in the Previewer. How this interface works on the Previewer may " +
|
||||
"be different from that on a real device.")
|
||||
const len = args.length
|
||||
if (typeof args[len - 1] === 'function') {
|
||||
if (args[0] === 'message') {
|
||||
args[len - 1].call(this, {
|
||||
message: "[PC Preview] unknow message",
|
||||
remoteInfo: SocketRemoteInfo
|
||||
});
|
||||
} else if (args[0] === 'listening') {
|
||||
args[len - 1].call(this, paramMock.businessErrorMock);
|
||||
} else if (args[0] === 'error') {
|
||||
args[len - 1].call(this, paramMock.businessErrorMock);
|
||||
}
|
||||
}
|
||||
},
|
||||
off: function (...args) {
|
||||
console.warn("UDPSocket.off interface mocked in the Previewer. How this interface works on the Previewer may" +
|
||||
" be different from that on a real device.")
|
||||
const len = args.length
|
||||
if (typeof args[len - 1] === 'function') {
|
||||
if (args[0] === 'message') {
|
||||
args[len - 1].call(this, {
|
||||
message: "[PC Preview] unknow message",
|
||||
remoteInfo: SocketRemoteInfo
|
||||
});
|
||||
} else if (args[0] === 'listening') {
|
||||
args[len - 1].call(this, paramMock.businessErrorMock);
|
||||
} else if (args[0] === 'error') {
|
||||
args[len - 1].call(this, paramMock.businessErrorMock);
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
destroy: function () {
|
||||
console.warn("HttpRequest.destroy interface mocked in the Previewer. How this interface works on the Previewer" +
|
||||
" may be different from that on a real device.")
|
||||
},
|
||||
on: function (...args) {
|
||||
console.warn("HttpRequest.on interface mocked in the Previewer. How this interface works on the Previewer may" +
|
||||
" be different from that on a real device.")
|
||||
const len = args.length
|
||||
if (typeof args[len - 1] === 'function') {
|
||||
args[len - 1].call(this, paramMock.businessErrorMock, paramMock.paramObjectMock);
|
||||
}
|
||||
|
||||
const TCPSocket = {
|
||||
bind: function (...args){
|
||||
console.warn("TcpSocket.bind interface mocked in the Previewer. How this interface works on the Previewer" +
|
||||
" may be different from that on a real device.")
|
||||
const len = args.length
|
||||
if( typeof args[len - 1] === 'function') {
|
||||
args[len -1].call(this, paramMock.businessErrorMock)
|
||||
} else {
|
||||
return new Promise((resolve, reject) => {
|
||||
resolve();
|
||||
})
|
||||
}
|
||||
},
|
||||
connect: function (...args) {
|
||||
console.warn("TcpSocket.connect interface mocked in the Previewer. How this interface works on the Previewer" +
|
||||
" may be different from that on a real device.")
|
||||
const len = args.length
|
||||
if( typeof args[len - 1] === 'function') {
|
||||
args[len -1].call(this, paramMock.businessErrorMock)
|
||||
} else {
|
||||
return new Promise((resolve, reject) => {
|
||||
resolve();
|
||||
})
|
||||
}
|
||||
},
|
||||
send: function (...args) {
|
||||
console.warn("TcpSocket.send interface mocked in the Previewer. How this interface works on the Previewer may" +
|
||||
" be different from that on a real device.")
|
||||
const len = args.length
|
||||
if( typeof args[len - 1] === 'function') {
|
||||
args[len -1].call(this, paramMock.businessErrorMock)
|
||||
} else {
|
||||
return new Promise((resolve, reject) => {
|
||||
resolve();
|
||||
})
|
||||
}
|
||||
},
|
||||
close: function (...args) {
|
||||
console.warn("TcpSocket.close interface mocked in the Previewer. How this interface works on the Previewer may" +
|
||||
" be different from that on a real device.")
|
||||
const len = args.length
|
||||
if( typeof args[len - 1] === 'function') {
|
||||
args[len -1].call(this, paramMock.businessErrorMock)
|
||||
} else {
|
||||
return new Promise((resolve, reject) => {
|
||||
resolve();
|
||||
})
|
||||
}
|
||||
},
|
||||
getRemoteAddress: function (...args) {
|
||||
console.warn("TcpSocket.getRemoteAddress interface mocked in the Previewer. How this interface works on the Previewer may" +
|
||||
" be different from that on a real device.")
|
||||
const len = args.length
|
||||
if( typeof args[len - 1] === 'function') {
|
||||
args[len -1].call(this, paramMock.businessErrorMock, NetAddress)
|
||||
} else {
|
||||
return new Promise((resolve, reject) => {
|
||||
resolve(NetAddress);
|
||||
})
|
||||
}
|
||||
},
|
||||
getState: function (...args) {
|
||||
console.warn("TcpSocket.getState interface mocked in the Previewer. How this interface works on the Previewer may" +
|
||||
" be different from that on a real device.")
|
||||
const len = args.length
|
||||
if( typeof args[len - 1] === 'function') {
|
||||
args[len -1].call(this, paramMock.businessErrorMock, SocketStateBase)
|
||||
} else {
|
||||
return new Promise((resolve, reject) => {
|
||||
resolve(SocketStateBase);
|
||||
})
|
||||
}
|
||||
},
|
||||
setExtraOptions: function (...args) {
|
||||
console.warn("TcpSocket.setExtraOptions interface mocked in the Previewer. How this interface works on the Previewer may" +
|
||||
" be different from that on a real device.")
|
||||
const len = args.length
|
||||
if( typeof args[len - 1] === 'function') {
|
||||
args[len -1].call(this, paramMock.businessErrorMock)
|
||||
} else {
|
||||
return new Promise((resolve, reject) => {
|
||||
resolve();
|
||||
})
|
||||
}
|
||||
},
|
||||
on: function (...args) {
|
||||
console.warn("TcpSocket.on interface mocked in the Previewer. How this interface works on the Previewer may " +
|
||||
"be different from that on a real device.")
|
||||
const len = args.length
|
||||
if (typeof args[len - 1] === 'function') {
|
||||
if (args[0] === 'message') {
|
||||
args[len - 1].call(this, {
|
||||
message: "[PC Preview] unknow message",
|
||||
remoteInfo: SocketRemoteInfo
|
||||
});
|
||||
} else if (args[0] === 'listening') {
|
||||
args[len - 1].call(this, paramMock.businessErrorMock);
|
||||
} else if (args[0] === 'error') {
|
||||
args[len - 1].call(this, paramMock.businessErrorMock);
|
||||
}
|
||||
}
|
||||
},
|
||||
off: function (...args) {
|
||||
console.warn("TcpSocket.off interface mocked in the Previewer. How this interface works on the Previewer may" +
|
||||
" be different from that on a real device.")
|
||||
const len = args.length
|
||||
if (typeof args[len - 1] === 'function') {
|
||||
if (args[0] === 'message') {
|
||||
args[len - 1].call(this, {
|
||||
message: "[PC Preview] unknow message",
|
||||
remoteInfo: SocketRemoteInfo
|
||||
});
|
||||
} else if (args[0] === 'listening') {
|
||||
args[len - 1].call(this, paramMock.businessErrorMock);
|
||||
} else if (args[0] === 'error') {
|
||||
args[len - 1].call(this, paramMock.businessErrorMock);
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
off: function (...args) {
|
||||
console.warn("HttpRequest.off interface mocked in the Previewer. How this interface works on the Previewer may" +
|
||||
" be different from that on a real device.")
|
||||
const len = args.length
|
||||
if (typeof args[len - 1] === 'function') {
|
||||
args[len - 1].call(this, paramMock.businessErrorMock, paramMock.paramObjectMock);
|
||||
}
|
||||
global.systemplugin.net.socket ={
|
||||
constructUDPSocketInstance : function () {
|
||||
console.warn("net.socket.constructUDPSocketInstance interface mocked in the Previewer. How this interface works on the Previewer" +
|
||||
" may be different from that on a real device.")
|
||||
return UDPSocket;
|
||||
},
|
||||
constructTCPSocketInstance : function () {
|
||||
console.warn("net.socket.constructTCPSocketInstance interface mocked in the Previewer. How this interface works on the Previewer" +
|
||||
" may be different from that on a real device.")
|
||||
return TCPSocket;
|
||||
}
|
||||
}
|
||||
}
|
||||
global.systemplugin.net.http = {
|
||||
createHttp: function () {
|
||||
console.warn("net.http.createHttp interface mocked in the Previewer. How this interface works on the Previewer" +
|
||||
" may be different from that on a real device.")
|
||||
return HttpRequestMock;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,287 @@
|
||||
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"
|
||||
}
|
||||
|
||||
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"
|
||||
}
|
||||
|
||||
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)
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,35 @@
|
||||
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)
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,189 @@
|
||||
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.");
|
||||
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',
|
||||
}
|
||||
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.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);
|
||||
}
|
||||
},
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,324 @@
|
||||
import {paramMock} from "../utils"
|
||||
|
||||
export function mockOhosNotification() {
|
||||
const NotificationSlotMock = {
|
||||
type: '[PC preview] unknow type',
|
||||
level: '[PC preview] unknow level',
|
||||
desc: '[PC preview] unknow desc',
|
||||
badgeFlag: '[PC preview] unknow badgeFlag',
|
||||
bypassDnd: '[PC preview] unknow bypassDnd',
|
||||
lockscreenVisibility: '[PC preview] unknow lockscreenVisibility',
|
||||
vibrationEnabled: '[PC preview] unknow vibrationEnabled',
|
||||
sound: '[PC preview] unknow sound',
|
||||
lightEnabled: '[PC preview] unknow lightEnabled',
|
||||
lightColor: '[PC preview] unknow lightColor',
|
||||
vibrationValues: '[PC preview] unknow vibrationValues'
|
||||
}
|
||||
const NotificationRequestMock = {
|
||||
content: '[PC preview] unknow content',
|
||||
id: '[PC preview] unknow id',
|
||||
slotType: '[PC preview] unknow slotType',
|
||||
isOngoing: '[PC preview] unknow isOngoing',
|
||||
isUnremovable: '[PC preview] unknow isUnremovable',
|
||||
deliveryTime: '[PC preview] unknow deliveryTime',
|
||||
tapDismissed: '[PC preview] unknow tapDismissed',
|
||||
autoDeletedTime: '[PC preview] unknow autoDeletedTime',
|
||||
wantAgent: '[PC preview] unknow wantAgent',
|
||||
extraInfo: '[PC preview] unknow extraInfo',
|
||||
color: '[PC preview] unknow color',
|
||||
colorEnabled: '[PC preview] unknow colorEnabled',
|
||||
isAlertOnce: '[PC preview] unknow isAlertOnce',
|
||||
isStopwatch: '[PC preview] unknow isStopwatch',
|
||||
isCountDown: '[PC preview] unknow isCountDown',
|
||||
isFloatingIcon: '[PC preview] unknow isFloatingIcon',
|
||||
label: '[PC preview] unknow label',
|
||||
badgeIconStyle: '[PC preview] unknow badgeIconStyle',
|
||||
showDeliveryTime: '[PC preview] unknow showDeliveryTime',
|
||||
actionButtons: '[PC preview] unknow actionButtons',
|
||||
creatorBundleName: '[PC preview] unknow creatorBundleName',
|
||||
creatorUid: '[PC preview] unknow creatorUid',
|
||||
creatorPid: '[PC preview] unknow creatorPid',
|
||||
classification: '[PC preview] unknow classification',
|
||||
hashCode: '[PC preview] unknow hashCode',
|
||||
}
|
||||
global.ohosplugin.notification = {
|
||||
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;
|
||||
if (typeof args[len - 1] === 'function') {
|
||||
args[len - 1].call(this, paramMock.businessErrorMock);
|
||||
} else {
|
||||
return new Promise((resolve) => {
|
||||
resolve();
|
||||
});
|
||||
}
|
||||
},
|
||||
cancel: function (...args) {
|
||||
console.warn("notification.cancel interface mocked in the Previewer. How this interface works on the" +
|
||||
" Previewer may be different from that on a real device.");
|
||||
const len = args.length;
|
||||
if (typeof args[len - 1] === 'function') {
|
||||
args[len - 1].call(this, paramMock.businessErrorMock);
|
||||
} else {
|
||||
return new Promise((resolve) => {
|
||||
resolve();
|
||||
});
|
||||
}
|
||||
},
|
||||
cancelAll: function (...args) {
|
||||
console.warn("notification.cancelAll interface mocked in the Previewer. How this interface works on the" +
|
||||
" Previewer may be different from that on a real device.");
|
||||
const len = args.length;
|
||||
if (typeof args[len - 1] === 'function') {
|
||||
args[len - 1].call(this, paramMock.businessErrorMock);
|
||||
} else {
|
||||
return new Promise((resolve) => {
|
||||
resolve();
|
||||
});
|
||||
}
|
||||
},
|
||||
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;
|
||||
if (typeof args[len - 1] === 'function') {
|
||||
args[len - 1].call(this, paramMock.businessErrorMock);
|
||||
} else {
|
||||
return new Promise((resolve) => {
|
||||
resolve();
|
||||
});
|
||||
}
|
||||
},
|
||||
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;
|
||||
if (typeof args[len - 1] === 'function') {
|
||||
args[len - 1].call(this, paramMock.businessErrorMock);
|
||||
} else {
|
||||
return new Promise((resolve) => {
|
||||
resolve();
|
||||
});
|
||||
}
|
||||
},
|
||||
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;
|
||||
if (typeof args[len - 1] === 'function') {
|
||||
args[len - 1].call(this, paramMock.businessErrorMock, NotificationSlotMock);
|
||||
} else {
|
||||
return new Promise((resolve) => {
|
||||
resolve(NotificationSlotMock);
|
||||
});
|
||||
}
|
||||
},
|
||||
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;
|
||||
if (typeof args[len - 1] === 'function') {
|
||||
args[len - 1].call(this, paramMock.businessErrorMock, [NotificationSlotMock]);
|
||||
} else {
|
||||
return new Promise((resolve) => {
|
||||
resolve([NotificationSlotMock]);
|
||||
});
|
||||
}
|
||||
},
|
||||
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;
|
||||
if (typeof args[len - 1] === 'function') {
|
||||
args[len - 1].call(this, paramMock.businessErrorMock);
|
||||
} else {
|
||||
return new Promise((resolve) => {
|
||||
resolve();
|
||||
});
|
||||
}
|
||||
},
|
||||
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;
|
||||
if (typeof args[len - 1] === 'function') {
|
||||
args[len - 1].call(this, paramMock.businessErrorMock);
|
||||
} else {
|
||||
return new Promise((resolve) => {
|
||||
resolve();
|
||||
});
|
||||
}
|
||||
},
|
||||
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;
|
||||
if (typeof args[len - 1] === 'function') {
|
||||
args[len - 1].call(this, paramMock.businessErrorMock);
|
||||
} else {
|
||||
return new Promise((resolve) => {
|
||||
resolve();
|
||||
});
|
||||
}
|
||||
},
|
||||
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;
|
||||
if (typeof args[len - 1] === 'function') {
|
||||
args[len - 1].call(this, paramMock.businessErrorMock);
|
||||
} else {
|
||||
return new Promise((resolve) => {
|
||||
resolve();
|
||||
});
|
||||
}
|
||||
},
|
||||
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;
|
||||
if (typeof args[len - 1] === 'function') {
|
||||
args[len - 1].call(this, paramMock.businessErrorMock);
|
||||
} else {
|
||||
return new Promise((resolve) => {
|
||||
resolve();
|
||||
});
|
||||
}
|
||||
},
|
||||
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;
|
||||
if (typeof args[len - 1] === 'function') {
|
||||
args[len - 1].call(this, paramMock.businessErrorMock, paramMock.paramBooleanMock);
|
||||
} else {
|
||||
return new Promise((resolve) => {
|
||||
resolve(paramMock.paramBooleanMock);
|
||||
});
|
||||
}
|
||||
},
|
||||
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;
|
||||
if (typeof args[len - 1] === 'function') {
|
||||
args[len - 1].call(this, paramMock.businessErrorMock);
|
||||
} else {
|
||||
return new Promise((resolve) => {
|
||||
resolve();
|
||||
});
|
||||
}
|
||||
},
|
||||
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;
|
||||
if (typeof args[len - 1] === 'function') {
|
||||
args[len - 1].call(this, paramMock.businessErrorMock, paramMock.paramBooleanMock);
|
||||
} else {
|
||||
return new Promise((resolve) => {
|
||||
resolve(paramMock.paramBooleanMock);
|
||||
});
|
||||
}
|
||||
},
|
||||
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;
|
||||
if (typeof args[len - 1] === 'function') {
|
||||
args[len - 1].call(this, paramMock.businessErrorMock);
|
||||
} else {
|
||||
return new Promise((resolve) => {
|
||||
resolve();
|
||||
});
|
||||
}
|
||||
},
|
||||
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;
|
||||
if (typeof args[len - 1] === 'function') {
|
||||
args[len - 1].call(this, paramMock.businessErrorMock, [NotificationSlotMock]);
|
||||
} else {
|
||||
return new Promise((resolve) => {
|
||||
resolve([NotificationSlotMock]);
|
||||
});
|
||||
}
|
||||
},
|
||||
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;
|
||||
if (typeof args[len - 1] === 'function') {
|
||||
args[len - 1].call(this, paramMock.businessErrorMock, paramMock.paramNumberMock);
|
||||
} else {
|
||||
return new Promise((resolve) => {
|
||||
resolve(paramMock.paramStringMock);
|
||||
});
|
||||
}
|
||||
},
|
||||
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;
|
||||
if (typeof args[len - 1] === 'function') {
|
||||
args[len - 1].call(this, paramMock.businessErrorMock);
|
||||
} else {
|
||||
return new Promise((resolve) => {
|
||||
resolve();
|
||||
});
|
||||
}
|
||||
},
|
||||
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;
|
||||
if (typeof args[len - 1] === 'function') {
|
||||
args[len - 1].call(this, paramMock.businessErrorMock);
|
||||
} else {
|
||||
return new Promise((resolve) => {
|
||||
resolve();
|
||||
});
|
||||
}
|
||||
},
|
||||
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;
|
||||
if (typeof args[len - 1] === 'function') {
|
||||
args[len - 1].call(this, paramMock.businessErrorMock, [NotificationRequestMock]);
|
||||
} else {
|
||||
return new Promise((resolve) => {
|
||||
resolve([NotificationRequestMock]);
|
||||
});
|
||||
}
|
||||
},
|
||||
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;
|
||||
if (typeof args[len - 1] === 'function') {
|
||||
args[len - 1].call(this, paramMock.businessErrorMock, paramMock.paramNumberMock);
|
||||
} else {
|
||||
return new Promise((resolve) => {
|
||||
resolve(paramMock.paramNumberMock);
|
||||
});
|
||||
}
|
||||
},
|
||||
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;
|
||||
if (typeof args[len - 1] === 'function') {
|
||||
args[len - 1].call(this, paramMock.businessErrorMock, [NotificationRequestMock]);
|
||||
} else {
|
||||
return new Promise((resolve) => {
|
||||
resolve([NotificationRequestMock]);
|
||||
});
|
||||
}
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,63 @@
|
||||
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);
|
||||
})
|
||||
}
|
||||
},
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,202 @@
|
||||
/*
|
||||
* Copyright (c) 2021 Huawei Device Co., Ltd.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
export function mockResourceManager() {
|
||||
function Configuration(direction, locale) {
|
||||
this.direction = direction;
|
||||
this.locale = locale;
|
||||
};
|
||||
|
||||
function DeviceCapability(screenDensity, deviceType) {
|
||||
this.screenDensity = screenDensity;
|
||||
this.deviceType = deviceType;
|
||||
};
|
||||
|
||||
function ResourceManager(mgrId, module) {
|
||||
var resMgrId = mgrId;
|
||||
var resourcemgrModuleGroup = module;
|
||||
|
||||
this.getString = getString;
|
||||
async function getString(resId, callback) {
|
||||
var data = "mock string";
|
||||
console.warn("ResourceManager.getString interface mocked in the Previewer. " +
|
||||
"How this interface works on the Previewer may be different from that on a real device.")
|
||||
if (typeof callback === 'function') {
|
||||
callback.call(this, null, data);
|
||||
} else {
|
||||
return new Promise((resolve) => {
|
||||
resolve(data);
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
this.getStringArray = getStringArray;
|
||||
async function getStringArray(resId, callback) {
|
||||
var data = [ "mock string1", "mock string2"];
|
||||
console.warn("ResourceManager.getStringArray interface mocked in the Previewer. " +
|
||||
"How this interface works on the Previewer may be different from that on a real device.")
|
||||
if (typeof callback === 'function') {
|
||||
callback.call(this, null, data);
|
||||
} else {
|
||||
return new Promise((resolve) => {
|
||||
resolve(data);
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
this.getJsonConfig = getJsonConfig;
|
||||
async function getJsonConfig(resId, callback) {
|
||||
var data = {"data" : { "name": "mock string1"} };
|
||||
console.warn("ResourceManager.getJsonConfig interface mocked in the Previewer." +
|
||||
" How this interface works on the Previewer may be different from that on a real device.")
|
||||
if (typeof callback === 'function') {
|
||||
callback.call(this, null, data);
|
||||
} else {
|
||||
return new Promise((resolve) => {
|
||||
resolve(data);
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
this.getMedia = getMedia;
|
||||
async function getMedia(resId, callback) {
|
||||
var data = "mock media data";
|
||||
console.warn("ResourceManager.getMedia interface mocked in the Previewer. " +
|
||||
"How this interface works on the Previewer may be different from that on a real device.")
|
||||
if (typeof callback === 'function') {
|
||||
callback.call(this, 1, data);
|
||||
} else {
|
||||
return new Promise((resolve, reject) => {
|
||||
reject(data);
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
this.getMediaBase64 = getMediaBase64;
|
||||
async function getMediaBase64(resId, callback) {
|
||||
var data = "mock media data";
|
||||
console.warn("ResourceManager.getMediaBase64 interface mocked in the Previewer. " +
|
||||
"How this interface works on the Previewer may be different from that on a real device.")
|
||||
if (typeof callback === 'function') {
|
||||
callback.call(this, 1, data);
|
||||
} else {
|
||||
return new Promise((resolve, reject) => {
|
||||
reject(data);
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
this.getPluralString = getPluralString;
|
||||
async function getPluralString(resId, num, callback) {
|
||||
var data = "mock plural string";
|
||||
console.warn("ResourceManager.getPluralString interface mocked in the Previewer. " +
|
||||
"How this interface works on the Previewer may be different from that on a real device.")
|
||||
if (typeof callback === 'function') {
|
||||
callback.call(this, null, data);
|
||||
} else {
|
||||
return new Promise((resolve) => {
|
||||
resolve(data);
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
this.getConfiguration = getConfiguration;
|
||||
async function getConfiguration(callback) {
|
||||
var data = {"direction" : 0, "locale" : "zh_CN"};
|
||||
console.warn("ResourceManager.getConfiguration interface mocked in the Previewer. " +
|
||||
"How this interface works on the Previewer may be different from that on a real device.")
|
||||
if (typeof callback === 'function') {
|
||||
callback.call(this, null, data);
|
||||
} else {
|
||||
return new Promise((resolve) => {
|
||||
resolve(data);
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
this.getDeviceCapability = getDeviceCapability;
|
||||
async function getDeviceCapability(callback) {
|
||||
var data = {"deviceType" : 0, "screenDensity" : 480 };
|
||||
console.warn("ResourceManager.getDeviceCapability interface mocked in the Previewer. " +
|
||||
"How this interface works on the Previewer may be different from that on a real device.")
|
||||
if (typeof callback === 'function') {
|
||||
callback.call(this, null, data);
|
||||
} else {
|
||||
return new Promise((resolve) => {
|
||||
resolve(data);
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
this.release = release;
|
||||
async function release(callback) {
|
||||
console.warn("ResourceManager.getJsonConfig interface mocked in the Previewer. " +
|
||||
"How this interface works on the Previewer may be different from that on a real device.")
|
||||
}
|
||||
}
|
||||
|
||||
var resourceManager = {
|
||||
getResourceManager: async function getResourceManager(optBundleName, optCallback) {
|
||||
let bundleName = '';
|
||||
let callback;
|
||||
if (typeof optCallback == 'function') {
|
||||
bundleName = optBundleName ? optBundleName : '';
|
||||
callback = optCallback;
|
||||
} else if (typeof optBundleName == 'function') {
|
||||
callback = optBundleName;
|
||||
} else {
|
||||
bundleName = optBundleName ? optBundleName : '';
|
||||
}
|
||||
let data = new ResourceManager(1, null);
|
||||
console.warn("ResourceManager.getResourceManager interface mocked in the Previewer. " +
|
||||
"How this interface works on the Previewer may be different from that on a real device.")
|
||||
if (typeof callback === 'function') {
|
||||
callback.call(this, 1, data);
|
||||
} else {
|
||||
return new Promise((resolve) => {
|
||||
resolve(data);
|
||||
})
|
||||
}
|
||||
},
|
||||
getAResourceManager: async function getAResourceManager(optBundleName, optCallback) {
|
||||
let bundleName = '';
|
||||
let callback;
|
||||
if (typeof optCallback == 'function') {
|
||||
bundleName = optBundleName ? optBundleName : '';
|
||||
callback = optCallback;
|
||||
} else if (typeof optBundleName == 'function') {
|
||||
callback = optBundleName;
|
||||
} else {
|
||||
bundleName = optBundleName ? optBundleName : '';
|
||||
}
|
||||
|
||||
let data = new ResourceManager(1, null);
|
||||
console.warn("ResourceManager.getAResourceManager interface mocked in the Previewer. " +
|
||||
"How this interface works on the Previewer may be different from that on a real device.")
|
||||
if (typeof callback === 'function') {
|
||||
callback.call(this, 1, data);
|
||||
} else {
|
||||
return new Promise((resolve) => {
|
||||
resolve(data);
|
||||
})
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
global.systemplugin.resourceManager = {
|
||||
getResourceManager: resourceManager.getResourceManager,
|
||||
getAResourceManager: resourceManager.getAResourceManager
|
||||
};
|
||||
};
|
||||
@@ -0,0 +1,42 @@
|
||||
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();
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
import { paramMock } from "./utils"
|
||||
|
||||
export function mockScreenshot() {
|
||||
const screenshotMock = {
|
||||
ImageSource: '[PC preview] unknow ImageSource'
|
||||
}
|
||||
|
||||
global.systemplugin.window.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)
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,69 @@
|
||||
import { paramMock } from "./utils"
|
||||
|
||||
export function mockSettings () {
|
||||
const mockInfo = {
|
||||
URI : "[PC Preview] unknow string"
|
||||
}
|
||||
global.systemplugin.settings = {
|
||||
getURI: function (...args) {
|
||||
console.warn("settings.getURI interface mocked in the Previewer. How this interface works on the" +
|
||||
" Previewer may be different from that on a real device.")
|
||||
const len = args.length
|
||||
if (typeof args[len - 1] === 'function') {
|
||||
args[len - 1].call(this, paramMock.businessErrorMock, mockInfo)
|
||||
} else {
|
||||
return new Promise((resolve) => {
|
||||
resolve(mockInfo);
|
||||
})
|
||||
}
|
||||
},
|
||||
getValue: function (...args) {
|
||||
console.warn("settings.getValue interface mocked in the Previewer. How this interface works on the" +
|
||||
" Previewer may be different 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);
|
||||
})
|
||||
}
|
||||
},
|
||||
setValue: function (...args) {
|
||||
console.warn("settings.setValue interface mocked in the Previewer. How this interface works on the" +
|
||||
" Previewer may be different from that on a 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();
|
||||
})
|
||||
}
|
||||
},
|
||||
enableAirplaneMode: function (...args) {
|
||||
console.warn("settings.enableAirplaneMode interface mocked in the Previewer. How this interface works on the" +
|
||||
" Previewer may be different from that on a real device.")
|
||||
const len = args.length
|
||||
if (typeof args[len - 1] === 'function') {
|
||||
args[len - 1].call(this, paramMock.businessErrorMock)
|
||||
} else {
|
||||
return new Promise((resolve) => {
|
||||
resolve();
|
||||
})
|
||||
}
|
||||
},
|
||||
canShowFloating: function (...args) {
|
||||
console.warn("settings.canShowFloating interface mocked in the Previewer. How this interface works on the" +
|
||||
" Previewer may be different 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);
|
||||
})
|
||||
}
|
||||
},
|
||||
}
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
@@ -10,12 +10,7 @@ export function getRandomArbitrary(min, max) {
|
||||
}
|
||||
|
||||
export const paramMock = {
|
||||
businessErrorMock: {
|
||||
code: '[PC Preview]: unknow code',
|
||||
name: '[PC Preview]: unknow name',
|
||||
message: '[PC Preview]: unknow message',
|
||||
stack: '[PC Preview]: unknow stack'
|
||||
},
|
||||
businessErrorMock: null,
|
||||
paramNumberMock: "[PC Preview] unknow number",
|
||||
paramStringMock: "[PC Preview] unknow string",
|
||||
paramBooleanMock: "[PC Preview] unknow boolean",
|
||||
|
||||
@@ -1,295 +1,323 @@
|
||||
import { paramMock } from "./utils"
|
||||
|
||||
const windowPropertiesMock = {
|
||||
windowRect:'[PC preview] unknow windowRect',
|
||||
type:'[PC preview] unknow type',
|
||||
brightness: '[PC preview] unknow brightness',
|
||||
isTransparent: '[PC preview] unknow isTransparent',
|
||||
isFullScreen: '[PC preview] unknow isFullScreen',
|
||||
isKeepScreenOn: '[PC preview] unknow isKeepScreenOn',
|
||||
dimBehindValue: '[PC preview] unknow dimBehindValue',
|
||||
isLayoutFullScreen: '[PC preview] unknow isLayoutFullScreen',
|
||||
focusable: '[PC preview] unknow focusable',
|
||||
touchable: '[PC preview] unknow touchable',
|
||||
isPrivacyMode: '[PC preview] unknow isPrivacyMode',
|
||||
isRoundCorner: '[PC preview] unknow isRoundCorner'
|
||||
}
|
||||
const RectMock = {
|
||||
left: '[PC preview] unknow Rect.left',
|
||||
top: '[PC preview] unknow Rect.top',
|
||||
width: '[PC preview] unknow Rect.width',
|
||||
height: '[PC preview] unknow Rect.height'
|
||||
}
|
||||
const AvoidAreaMock = {
|
||||
leftRect: RectMock,
|
||||
topRect: RectMock,
|
||||
rightRect: RectMock,
|
||||
bottomRect: RectMock
|
||||
}
|
||||
export const windowMock = {
|
||||
setBrightness: function (...args) {
|
||||
console.warn("Window.setBrightness interface mocked in the Previewer. How this interface works on the" +
|
||||
" Previewer may be different from that on a real device.")
|
||||
const len = args.length
|
||||
if (typeof args[len - 1] === 'function') {
|
||||
args[len - 1].call(this, paramMock.businessErrorMock)
|
||||
} else {
|
||||
return new Promise((resolve) => {
|
||||
resolve()
|
||||
})
|
||||
}
|
||||
},
|
||||
setBackgroundColor: function (...args) {
|
||||
console.warn("Window.setBackgroundColor interface mocked in the Previewer. How this interface works on the" +
|
||||
" Previewer may be different from that on a real device.")
|
||||
const len = args.length
|
||||
if (typeof args[len - 1] === 'function') {
|
||||
args[len - 1].call(this, paramMock.businessErrorMock)
|
||||
} else {
|
||||
return new Promise((resolve) => {
|
||||
resolve()
|
||||
})
|
||||
}
|
||||
},
|
||||
setTransparent: function (...args) {
|
||||
console.warn("Window.setTransparent interface mocked in the Previewer. How this interface works on the" +
|
||||
" Previewer may be different from that on a real device.")
|
||||
const len = args.length
|
||||
if (typeof args[len - 1] === 'function') {
|
||||
args[len - 1].call(this, paramMock.businessErrorMock)
|
||||
} else {
|
||||
return new Promise((resolve) => {
|
||||
resolve()
|
||||
})
|
||||
}
|
||||
},
|
||||
setFullScreen: function (...args) {
|
||||
console.warn("Window.setFullScreen interface mocked in the Previewer. How this interface works on the" +
|
||||
" Previewer may be different from that on a real device.")
|
||||
const len = args.length
|
||||
if (typeof args[len - 1] === 'function') {
|
||||
args[len - 1].call(this, paramMock.businessErrorMock)
|
||||
} else {
|
||||
return new Promise((resolve) => {
|
||||
resolve()
|
||||
})
|
||||
}
|
||||
},
|
||||
setKeepScreenOn: function (...args) {
|
||||
console.warn("Window.setKeepScreenOn interface mocked in the Previewer. How this interface works on the" +
|
||||
" Previewer may be different from that on a real device.")
|
||||
const len = args.length
|
||||
if (typeof args[len - 1] === 'function') {
|
||||
args[len - 1].call(this, paramMock.businessErrorMock)
|
||||
} else {
|
||||
return new Promise((resolve) => {
|
||||
resolve()
|
||||
})
|
||||
}
|
||||
},
|
||||
setDimBehind: function (...args) {
|
||||
console.warn("Window.setDimBehind interface mocked in the Previewer. How this interface works on the" +
|
||||
" Previewer may be different from that on a real device.")
|
||||
const len = args.length
|
||||
if (typeof args[len - 1] === 'function') {
|
||||
args[len - 1].call(this, paramMock.businessErrorMock)
|
||||
} else {
|
||||
return new Promise((resolve) => {
|
||||
resolve()
|
||||
})
|
||||
}
|
||||
},
|
||||
setLayoutFullScreen: function (...args) {
|
||||
console.warn("Window.setLayoutFullScreen interface mocked in the Previewer. How this interface works on the" +
|
||||
" Previewer may be different from that on a real device.")
|
||||
const len = args.length
|
||||
if (typeof args[len - 1] === 'function') {
|
||||
args[len - 1].call(this, paramMock.businessErrorMock)
|
||||
} else {
|
||||
return new Promise((resolve) => {
|
||||
resolve()
|
||||
})
|
||||
}
|
||||
},
|
||||
setFocusable: function (...args) {
|
||||
console.warn("Window.setFocusable interface mocked in the Previewer. How this interface works on the" +
|
||||
" Previewer may be different from that on a real device.")
|
||||
const len = args.length
|
||||
if (typeof args[len - 1] === 'function') {
|
||||
args[len - 1].call(this, paramMock.businessErrorMock)
|
||||
} else {
|
||||
return new Promise((resolve) => {
|
||||
resolve()
|
||||
})
|
||||
}
|
||||
},
|
||||
setTouchable: function (...args) {
|
||||
console.warn("Window.setTouchable interface mocked in the Previewer. How this interface works on the" +
|
||||
" Previewer may be different from that on a real device.")
|
||||
const len = args.length
|
||||
if (typeof args[len - 1] === 'function') {
|
||||
args[len - 1].call(this, paramMock.businessErrorMock)
|
||||
} else {
|
||||
return new Promise((resolve) => {
|
||||
resolve()
|
||||
})
|
||||
}
|
||||
},
|
||||
setPrivacyMode: function (...args) {
|
||||
console.warn("Window.setPrivacyMode interface mocked in the Previewer. How this interface works on the" +
|
||||
" Previewer may be different from that on a real device.")
|
||||
const len = args.length
|
||||
if (typeof args[len - 1] === 'function') {
|
||||
args[len - 1].call(this, paramMock.businessErrorMock)
|
||||
} else {
|
||||
return new Promise((resolve) => {
|
||||
resolve()
|
||||
})
|
||||
}
|
||||
},
|
||||
setSystemBarEnable: function (...args) {
|
||||
console.warn("Window.setSystemBarEnable interface mocked in the Previewer. How this interface works on the" +
|
||||
" Previewer may be different from that on a real device.")
|
||||
const len = args.length
|
||||
if (typeof args[len - 1] === 'function') {
|
||||
args[len - 1].call(this, paramMock.businessErrorMock)
|
||||
} else {
|
||||
return new Promise((resolve) => {
|
||||
resolve()
|
||||
})
|
||||
}
|
||||
},
|
||||
setSystemBarProperties: function (...args) {
|
||||
console.warn("Window.setSystemBarProperties interface mocked in the Previewer. How this interface works on the" +
|
||||
" Previewer may be different from that on a real device.")
|
||||
const len = args.length
|
||||
if (typeof args[len - 1] === 'function') {
|
||||
args[len - 1].call(this, paramMock.businessErrorMock)
|
||||
} else {
|
||||
return new Promise((resolve) => {
|
||||
resolve()
|
||||
})
|
||||
}
|
||||
},
|
||||
getProperties: function (...args) {
|
||||
console.warn("Window.getProperties interface mocked in the Previewer. How this interface works on the" +
|
||||
" Previewer may be different from that on a real device.")
|
||||
const len = args.length
|
||||
if (typeof args[len - 1] === 'function') {
|
||||
args[len - 1].call(this, paramMock.businessErrorMock, windowPropertiesMock)
|
||||
} else {
|
||||
return new Promise((resolve) => {
|
||||
resolve(windowPropertiesMock)
|
||||
})
|
||||
}
|
||||
},
|
||||
getAvoidArea: function (...args) {
|
||||
console.warn("Window.getAvoidArea interface mocked in the Previewer. How this interface works on the" +
|
||||
" Previewer may be different from that on a real device.")
|
||||
const len = args.length
|
||||
if (typeof args[len - 1] === 'function') {
|
||||
args[len - 1].call(this, paramMock.businessErrorMock, AvoidAreaMock)
|
||||
} else {
|
||||
return new Promise((resolve) => {
|
||||
resolve(AvoidAreaMock)
|
||||
})
|
||||
}
|
||||
},
|
||||
moveTo: function (...args) {
|
||||
console.warn("Window.moveTo interface mocked in the Previewer. How this interface works on the" +
|
||||
" Previewer may be different from that on a real device.")
|
||||
const len = args.length
|
||||
if (typeof args[len - 1] === 'function') {
|
||||
args[len - 1].call(this, paramMock.businessErrorMock)
|
||||
} else {
|
||||
return new Promise((resolve) => {
|
||||
resolve()
|
||||
})
|
||||
}
|
||||
},
|
||||
resetSize: function (...args) {
|
||||
console.warn("Window.resetSize interface mocked in the Previewer. How this interface works on the" +
|
||||
" Previewer may be different from that on a real device.")
|
||||
const len = args.length
|
||||
if (typeof args[len - 1] === 'function') {
|
||||
args[len - 1].call(this, paramMock.businessErrorMock)
|
||||
} else {
|
||||
return new Promise((resolve) => {
|
||||
resolve()
|
||||
})
|
||||
}
|
||||
},
|
||||
loadContent: function (...args) {
|
||||
console.warn("Window.loadContent interface mocked in the Previewer. How this interface works on the" +
|
||||
" Previewer may be different from that on a real device.")
|
||||
const len = args.length
|
||||
if (typeof args[len - 1] === 'function') {
|
||||
args[len - 1].call(this, paramMock.businessErrorMock)
|
||||
} else {
|
||||
return new Promise((resolve) => {
|
||||
resolve()
|
||||
})
|
||||
}
|
||||
},
|
||||
hide: function (...args) {
|
||||
console.warn("Window.hide interface mocked in the Previewer. How this interface works on the" +
|
||||
" Previewer may be different from that on a real device.")
|
||||
const len = args.length
|
||||
if (typeof args[len - 1] === 'function') {
|
||||
args[len - 1].call(this, paramMock.businessErrorMock)
|
||||
} else {
|
||||
return new Promise((resolve) => {
|
||||
resolve()
|
||||
})
|
||||
}
|
||||
},
|
||||
show: function (...args) {
|
||||
console.warn("Window.show interface mocked in the Previewer. How this interface works on the" +
|
||||
" Previewer may be different from that on a real device.")
|
||||
const len = args.length
|
||||
if (typeof args[len - 1] === 'function') {
|
||||
args[len - 1].call(this, paramMock.businessErrorMock)
|
||||
} else {
|
||||
return new Promise((resolve) => {
|
||||
resolve()
|
||||
})
|
||||
}
|
||||
},
|
||||
isShowing: function (...args) {
|
||||
console.warn("Window.isShowing interface mocked in the Previewer. How this interface works on the" +
|
||||
" Previewer may be different from that on a real device.")
|
||||
const len = args.length
|
||||
if (typeof args[len - 1] === 'function') {
|
||||
args[len - 1].call(this, paramMock.businessErrorMock, paramMock.paramBooleanMock)
|
||||
} else {
|
||||
return new Promise((resolve) => {
|
||||
resolve(paramMock.paramBooleanMock)
|
||||
})
|
||||
}
|
||||
},
|
||||
destroy: function (...args) {
|
||||
console.warn("Window.destroy interface mocked in the Previewer. How this interface works on the" +
|
||||
" Previewer may be different from that on a real device.")
|
||||
const len = args.length
|
||||
if (typeof args[len - 1] === 'function') {
|
||||
args[len - 1].call(this, paramMock.businessErrorMock)
|
||||
} else {
|
||||
return new Promise((resolve) => {
|
||||
resolve()
|
||||
})
|
||||
}
|
||||
},
|
||||
setOutsideTouchable: function (...args) {
|
||||
console.warn("Window.setOutsideTouchable interface mocked in the Previewer. How this interface works on the" +
|
||||
" Previewer may be different from that on a real device.")
|
||||
const len = args.length
|
||||
if (typeof args[len - 1] === 'function') {
|
||||
args[len - 1].call(this, paramMock.businessErrorMock)
|
||||
} else {
|
||||
return new Promise((resolve) => {
|
||||
resolve()
|
||||
})
|
||||
}
|
||||
},
|
||||
on: function (...args) {
|
||||
console.warn("Window.on interface mocked in the Previewer. How this interface works on the Previewer may be" +
|
||||
" different from that on a real device.")
|
||||
const len = args.length
|
||||
args[len - 1].call(this, paramMock.businessErrorMock, paramMock.paramNumberMock)
|
||||
},
|
||||
off: function (...args) {
|
||||
console.warn("Window.off interface mocked in the Previewer. How this interface works on the Previewer may be" +
|
||||
" different from that on a real device.")
|
||||
const len = args.length
|
||||
args[len - 1].call(this, paramMock.businessErrorMock, paramMock.paramNumberMock)
|
||||
},
|
||||
}
|
||||
export function mockWindow() {
|
||||
const windowPropertiesMock = {
|
||||
brightness: '[PC preview] unknow brightness',
|
||||
isFullScreen: '[PC preview] unknow isFullScreen',
|
||||
isKeepScreenOn: '[PC preview] unknow isKeepScreenOn',
|
||||
isPrivacyMode: '[PC preview] unknow isPrivacyMode',
|
||||
touchable: '[PC preview] unknow touchable',
|
||||
focusable: '[PC preview] unknow focusable',
|
||||
isLayoutFullScreen: '[PC preview] unknow isLayoutFullScreen',
|
||||
isDimBehind: '[PC preview] unknow isDimBehind',
|
||||
isTransparent: '[PC preview] unknow isTransparent',
|
||||
isRoundCorner: '[PC preview] unknow isRoundCorner'
|
||||
const SizeMock = {
|
||||
width: '[PC preview] unknow width',
|
||||
height: '[PC preview] unknow height'
|
||||
}
|
||||
const AvoidAreaMock = {
|
||||
left: '[PC preview] unknow Rect.left Rect.top Rect.right Rect.bottom',
|
||||
top: '[PC preview] unknow Rect.left Rect.top Rect.right Rect.bottom',
|
||||
right: '[PC preview] unknow Rect.left Rect.top Rect.right Rect.bottom',
|
||||
bottom: '[PC preview] unknow Rect.left Rect.top Rect.right Rect.bottom'
|
||||
|
||||
}
|
||||
const windowMock = {
|
||||
setBrightness: function (...args) {
|
||||
console.warn("Window.setBrightness interface mocked in the Previewer. How this interface works on the" +
|
||||
" Previewer may be different from that on a real device.")
|
||||
const len = args.length
|
||||
if (typeof args[len - 1] === 'function') {
|
||||
args[len - 1].call(this, paramMock.businessErrorMock)
|
||||
} else {
|
||||
return new Promise((resolve) => {
|
||||
resolve()
|
||||
})
|
||||
}
|
||||
},
|
||||
setBackgroundColor: function (...args) {
|
||||
console.warn("Window.setBackgroundColor interface mocked in the Previewer. How this interface works on the" +
|
||||
" Previewer may be different from that on a real device.")
|
||||
const len = args.length
|
||||
if (typeof args[len - 1] === 'function') {
|
||||
args[len - 1].call(this, paramMock.businessErrorMock)
|
||||
} else {
|
||||
return new Promise((resolve) => {
|
||||
resolve()
|
||||
})
|
||||
}
|
||||
},
|
||||
setFullScreen: function (...args) {
|
||||
console.warn("Window.setFullScreen interface mocked in the Previewer. How this interface works on the" +
|
||||
" Previewer may be different from that on a real device.")
|
||||
const len = args.length
|
||||
if (typeof args[len - 1] === 'function') {
|
||||
args[len - 1].call(this, paramMock.businessErrorMock)
|
||||
} else {
|
||||
return new Promise((resolve) => {
|
||||
resolve()
|
||||
})
|
||||
}
|
||||
},
|
||||
setKeepScreenOn: function (...args) {
|
||||
console.warn("Window.setKeepScreenOn interface mocked in the Previewer. How this interface works on the" +
|
||||
" Previewer may be different from that on a real device.")
|
||||
const len = args.length
|
||||
if (typeof args[len - 1] === 'function') {
|
||||
args[len - 1].call(this, paramMock.businessErrorMock)
|
||||
} else {
|
||||
return new Promise((resolve) => {
|
||||
resolve()
|
||||
})
|
||||
}
|
||||
},
|
||||
setSystemBarProperties: function (...args) {
|
||||
console.warn("Window.setSystemBarProperties interface mocked in the Previewer. How this interface works on the" +
|
||||
" Previewer may be different from that on a real device.")
|
||||
const len = args.length
|
||||
if (typeof args[len - 1] === 'function') {
|
||||
args[len - 1].call(this, paramMock.businessErrorMock)
|
||||
} else {
|
||||
return new Promise((resolve) => {
|
||||
resolve()
|
||||
})
|
||||
}
|
||||
},
|
||||
getProperties: function (...args) {
|
||||
console.warn("Window.getProperties interface mocked in the Previewer. How this interface works on the" +
|
||||
" Previewer may be different from that on a real device.")
|
||||
const len = args.length
|
||||
if (typeof args[len - 1] === 'function') {
|
||||
args[len - 1].call(this, paramMock.businessErrorMock, windowPropertiesMock)
|
||||
} else {
|
||||
return new Promise((resolve) => {
|
||||
resolve(windowPropertiesMock)
|
||||
})
|
||||
}
|
||||
},
|
||||
on: function (...args) {
|
||||
console.warn("Window.on interface mocked in the Previewer. How this interface works on the Previewer may be" +
|
||||
" different from that on a real device.")
|
||||
const len = args.length
|
||||
args[len - 1].call(this, paramMock.businessErrorMock, paramMock.paramNumberMock)
|
||||
},
|
||||
off: function (...args) {
|
||||
console.warn("Window.off interface mocked in the Previewer. How this interface works on the Previewer may be" +
|
||||
" different from that on a real device.")
|
||||
const len = args.length
|
||||
args[len - 1].call(this, paramMock.businessErrorMock, paramMock.paramNumberMock)
|
||||
},
|
||||
setSystemBarEnable: function (...args) {
|
||||
console.warn("Window.setSystemBarEnable interface mocked in the Previewer. How this interface works on the" +
|
||||
" Previewer may be different from that on a real device.")
|
||||
const len = args.length
|
||||
if (typeof args[len - 1] === 'function') {
|
||||
args[len - 1].call(this, paramMock.businessErrorMock)
|
||||
} else {
|
||||
return new Promise((resolve) => {
|
||||
resolve()
|
||||
})
|
||||
}
|
||||
},
|
||||
setTransparent: function (...args) {
|
||||
console.warn("Window.setTransparent interface mocked in the Previewer. How this interface works on the" +
|
||||
" Previewer may be different from that on a real device.")
|
||||
const len = args.length
|
||||
if (typeof args[len - 1] === 'function') {
|
||||
args[len - 1].call(this, paramMock.businessErrorMock)
|
||||
} else {
|
||||
return new Promise((resolve) => {
|
||||
resolve()
|
||||
})
|
||||
}
|
||||
},
|
||||
setWindowType: function (...args) {
|
||||
console.warn("Window.setWindowType interface mocked in the Previewer. How this interface works on the" +
|
||||
" Previewer may be different from that on a real device.")
|
||||
const len = args.length
|
||||
if (typeof args[len - 1] === 'function') {
|
||||
args[len - 1].call(this, paramMock.businessErrorMock)
|
||||
} else {
|
||||
return new Promise((resolve) => {
|
||||
resolve()
|
||||
})
|
||||
}
|
||||
},
|
||||
setPrivacyMode: function (...args) {
|
||||
console.warn("Window.setPrivacyMode interface mocked in the Previewer. How this interface works on the" +
|
||||
" Previewer may be different from that on a real device.")
|
||||
const len = args.length
|
||||
if (typeof args[len - 1] === 'function') {
|
||||
args[len - 1].call(this, paramMock.businessErrorMock)
|
||||
} else {
|
||||
return new Promise((resolve) => {
|
||||
resolve()
|
||||
})
|
||||
}
|
||||
},
|
||||
setTouchable: function (...args) {
|
||||
console.warn("Window.setTouchable interface mocked in the Previewer. How this interface works on the" +
|
||||
" Previewer may be different from that on a real device.")
|
||||
const len = args.length
|
||||
if (typeof args[len - 1] === 'function') {
|
||||
args[len - 1].call(this, paramMock.businessErrorMock)
|
||||
} else {
|
||||
return new Promise((resolve) => {
|
||||
resolve()
|
||||
})
|
||||
}
|
||||
},
|
||||
setFocusable: function (...args) {
|
||||
console.warn("Window.setFocusable interface mocked in the Previewer. How this interface works on the" +
|
||||
" Previewer may be different from that on a real device.")
|
||||
const len = args.length
|
||||
if (typeof args[len - 1] === 'function') {
|
||||
args[len - 1].call(this, paramMock.businessErrorMock)
|
||||
} else {
|
||||
return new Promise((resolve) => {
|
||||
resolve()
|
||||
})
|
||||
}
|
||||
},
|
||||
setLayoutFullScreen: function (...args) {
|
||||
console.warn("Window.setLayoutFullScreen interface mocked in the Previewer. How this interface works on the" +
|
||||
" Previewer may be different from that on a real device.")
|
||||
const len = args.length
|
||||
if (typeof args[len - 1] === 'function') {
|
||||
args[len - 1].call(this, paramMock.businessErrorMock)
|
||||
} else {
|
||||
return new Promise((resolve) => {
|
||||
resolve()
|
||||
})
|
||||
}
|
||||
},
|
||||
getAvoidArea: function (...args) {
|
||||
console.warn("Window.getAvoidArea interface mocked in the Previewer. How this interface works on the" +
|
||||
" Previewer may be different from that on a real device.")
|
||||
const len = args.length
|
||||
if (typeof args[len - 1] === 'function') {
|
||||
args[len - 1].call(this, paramMock.businessErrorMock, AvoidAreaMock)
|
||||
} else {
|
||||
return new Promise((resolve) => {
|
||||
resolve(AvoidAreaMock)
|
||||
})
|
||||
}
|
||||
},
|
||||
setDimBehind: function (...args) {
|
||||
console.warn("Window.setDimBehind interface mocked in the Previewer. How this interface works on the" +
|
||||
" Previewer may be different from that on a real device.")
|
||||
const len = args.length
|
||||
if (typeof args[len - 1] === 'function') {
|
||||
args[len - 1].call(this, paramMock.businessErrorMock)
|
||||
} else {
|
||||
return new Promise((resolve) => {
|
||||
resolve()
|
||||
})
|
||||
}
|
||||
},
|
||||
loadContent: function (...args) {
|
||||
console.warn("Window.loadContent interface mocked in the Previewer. How this interface works on the" +
|
||||
" Previewer may be different from that on a real device.")
|
||||
const len = args.length
|
||||
if (typeof args[len - 1] === 'function') {
|
||||
args[len - 1].call(this, paramMock.businessErrorMock)
|
||||
} else {
|
||||
return new Promise((resolve) => {
|
||||
resolve()
|
||||
})
|
||||
}
|
||||
},
|
||||
hide: function (...args) {
|
||||
console.warn("Window.hide interface mocked in the Previewer. How this interface works on the" +
|
||||
" Previewer may be different from that on a real device.")
|
||||
const len = args.length
|
||||
if (typeof args[len - 1] === 'function') {
|
||||
args[len - 1].call(this, paramMock.businessErrorMock)
|
||||
} else {
|
||||
return new Promise((resolve) => {
|
||||
resolve()
|
||||
})
|
||||
}
|
||||
},
|
||||
show: function (...args) {
|
||||
console.warn("Window.show interface mocked in the Previewer. How this interface works on the" +
|
||||
" Previewer may be different from that on a real device.")
|
||||
const len = args.length
|
||||
if (typeof args[len - 1] === 'function') {
|
||||
args[len - 1].call(this, paramMock.businessErrorMock)
|
||||
} else {
|
||||
return new Promise((resolve) => {
|
||||
resolve()
|
||||
})
|
||||
}
|
||||
},
|
||||
isShowing: function (...args) {
|
||||
console.warn("Window.isShowing interface mocked in the Previewer. How this interface works on the" +
|
||||
" Previewer may be different from that on a real device.")
|
||||
const len = args.length
|
||||
if (typeof args[len - 1] === 'function') {
|
||||
args[len - 1].call(this, paramMock.businessErrorMock, paramMock.paramBooleanMock)
|
||||
} else {
|
||||
return new Promise((resolve) => {
|
||||
resolve(paramMock.paramBooleanMock)
|
||||
})
|
||||
}
|
||||
},
|
||||
destroy: function (...args) {
|
||||
console.warn("Window.destroy interface mocked in the Previewer. How this interface works on the" +
|
||||
" Previewer may be different from that on a real device.")
|
||||
const len = args.length
|
||||
if (typeof args[len - 1] === 'function') {
|
||||
args[len - 1].call(this, paramMock.businessErrorMock)
|
||||
} else {
|
||||
return new Promise((resolve) => {
|
||||
resolve()
|
||||
})
|
||||
}
|
||||
},
|
||||
setOutsideTouchable: function (...args) {
|
||||
console.warn("Window.setOutsideTouchable interface mocked in the Previewer. How this interface works on the" +
|
||||
" Previewer may be different from that on a real device.")
|
||||
const len = args.length
|
||||
if (typeof args[len - 1] === 'function') {
|
||||
args[len - 1].call(this, paramMock.businessErrorMock)
|
||||
} else {
|
||||
return new Promise((resolve) => {
|
||||
resolve()
|
||||
})
|
||||
}
|
||||
},
|
||||
const getSplitScreenBoundsMock = {
|
||||
splitMode: '[PC preview] unknow splitMode',
|
||||
primaryBounds: RectMock,
|
||||
secondaryBounds: RectMock,
|
||||
}
|
||||
global.systemplugin.window = {
|
||||
getTopWindow: function (...args) {
|
||||
console.warn("window.getTopWindow interface mocked in the Previewer. How this interface works on the Previewer" +
|
||||
" may be different from that on a real device.")
|
||||
" may be different from that on a real device.")
|
||||
const len = args.length
|
||||
if (typeof args[len - 1] === 'function') {
|
||||
args[len - 1].call(this, paramMock.businessErrorMock, windowMock)
|
||||
@@ -301,7 +329,7 @@ export function mockWindow() {
|
||||
},
|
||||
create: function (...args) {
|
||||
console.warn("Window.create interface mocked in the Previewer. How this interface works on the" +
|
||||
" Previewer may be different from that on a real device.")
|
||||
" Previewer may be different from that on a real device.")
|
||||
const len = args.length
|
||||
if (typeof args[len - 1] === 'function') {
|
||||
args[len - 1].call(this, paramMock.businessErrorMock, windowMock)
|
||||
@@ -313,7 +341,7 @@ export function mockWindow() {
|
||||
},
|
||||
find: function (...args) {
|
||||
console.warn("Window.find interface mocked in the Previewer. How this interface works on the" +
|
||||
" Previewer may be different from that on a real device.")
|
||||
" Previewer may be different from that on a real device.")
|
||||
const len = args.length
|
||||
if (typeof args[len - 1] === 'function') {
|
||||
args[len - 1].call(this, paramMock.businessErrorMock, windowMock)
|
||||
@@ -323,5 +351,53 @@ export function mockWindow() {
|
||||
})
|
||||
}
|
||||
},
|
||||
getWindowMode: function (...args) {
|
||||
console.warn("Window.getWindowMode interface mocked in the Previewer. How this interface works on the Previewer" +
|
||||
" may be different from that on a real device.")
|
||||
const len = args.length
|
||||
if (typeof args[len - 1] === 'function') {
|
||||
args[len - 1].call(this, paramMock.businessErrorMock, paramMock.paramNumberMock)
|
||||
} else {
|
||||
return new Promise((resolve, reject) => {
|
||||
resolve(paramMock.paramNumberMock)
|
||||
})
|
||||
}
|
||||
},
|
||||
getSplitScreenBounds: function (...args) {
|
||||
console.warn("window.getSplitScreenBounds interface mocked in the Previewer. How this interface works on the Previewer" +
|
||||
" may be different from that on a real device.")
|
||||
const len = args.length
|
||||
if (typeof args[len - 1] === 'function') {
|
||||
args[len - 1].call(this, paramMock.businessErrorMock, getSplitScreenBoundsMock)
|
||||
} else {
|
||||
return new Promise((resolve, reject) => {
|
||||
resolve(getSplitScreenBoundsMock)
|
||||
})
|
||||
}
|
||||
},
|
||||
isFloatingAbilityWindowVisible: function (...args) {
|
||||
console.warn("window.isFloatingAbilityWindowVisible interface mocked in the Previewer. How this interface works on the Previewer" +
|
||||
" may be different from that on a real device.")
|
||||
const len = args.length
|
||||
if (typeof args[len - 1] === 'function') {
|
||||
args[len - 1].call(this, paramMock.businessErrorMock, paramMock.paramBooleanMock)
|
||||
} else {
|
||||
return new Promise((resolve, reject) => {
|
||||
resolve(paramMock.paramBooleanMock)
|
||||
})
|
||||
}
|
||||
},
|
||||
setSplitBarVisibility: function (...args) {
|
||||
console.warn("window.setSplitBarVisibility interface mocked in the Previewer. How this interface works on the Previewer" +
|
||||
" may be different from that on a real device.")
|
||||
const len = args.length
|
||||
if (typeof args[len - 1] === 'function') {
|
||||
args[len - 1].call(this, paramMock.businessErrorMock)
|
||||
} else {
|
||||
return new Promise((resolve, reject) => {
|
||||
resolve()
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -449,12 +449,13 @@ function compileNativeComponent(vm: Vm, template: TemplateInterface, dest: FragB
|
||||
vm.mediaStatus.width = e.width;
|
||||
vm.mediaStatus.height = e.height;
|
||||
vm.mediaStatus.resolution = e.resolution;
|
||||
vm.mediaStatus['device-type'] = e.deviceType;
|
||||
vm.mediaStatus['aspect-ratio'] = e.aspectRatio;
|
||||
vm.mediaStatus['device-width'] = e.deviceWidth;
|
||||
vm.mediaStatus['device-height'] = e.deviceHeight;
|
||||
vm.mediaStatus['round-screen'] = e.roundScreen;
|
||||
vm.mediaStatus['dark-mode'] = e.darkMode;
|
||||
vm.mediaStatus['device-type'] = e['device-type'];
|
||||
vm.mediaStatus['aspect-ratio'] = e['aspect-ratio'];
|
||||
vm.mediaStatus['device-width'] = e['device-width'];
|
||||
vm.mediaStatus['device-height'] = e['device-height'];
|
||||
vm.mediaStatus['round-screen'] = e['round-screen'];
|
||||
vm.mediaStatus['dark-mode'] = e['dark-mode'];
|
||||
vm.mediaStatus['api-version'] = e['api-version'];
|
||||
const css = vm.vmOptions && vm.vmOptions.style || {};
|
||||
const mqArr = css['@MEDIA'];
|
||||
if (!mqArr) {
|
||||
|
||||
@@ -29,6 +29,9 @@ import { TaskCenter } from '../main/manage/event/TaskCenter';
|
||||
import { FragBlockInterface } from '../main/model/compiler';
|
||||
import Vm from '../main/model';
|
||||
import { CSS_INHERITANCE } from '../main/app/bundle';
|
||||
import {interceptCallback} from "../main/manage/event/callbackIntercept";
|
||||
import {mockwebgl} from "../main/extend/systemplugin/napi/webgl";
|
||||
import {mockwebgl2} from "../main/extend/systemplugin/napi/webgl2";
|
||||
|
||||
/**
|
||||
* Element is a basic class to describe a tree node in vdom.
|
||||
@@ -57,6 +60,32 @@ class Element extends Node {
|
||||
super();
|
||||
const NativeElementClass = NativeElementClassFactory.nativeElementClassMap.get(type);
|
||||
if (NativeElementClass && !isExtended) {
|
||||
if (global.pcPreview && type === 'canvas') {
|
||||
Object.defineProperty(NativeElementClass.prototype, 'getContext', {
|
||||
configurable: true,
|
||||
enumerable: true,
|
||||
get: function moduleGetter() {
|
||||
return (...args: any) => {
|
||||
const taskCenter = this.getTaskCenter(this.docId);
|
||||
if (taskCenter) {
|
||||
// support aceapp callback style
|
||||
args = interceptCallback(args);
|
||||
if (args[0] === 'webgl') {
|
||||
return mockwebgl();
|
||||
} else if (args[0] === 'webgl2') {
|
||||
return mockwebgl2();
|
||||
}
|
||||
const ret = taskCenter.send('component', {
|
||||
ref: this.ref,
|
||||
component: type,
|
||||
method: 'getContext'
|
||||
}, args);
|
||||
return ret;
|
||||
}
|
||||
};
|
||||
}
|
||||
});
|
||||
}
|
||||
return new NativeElementClass(props);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user