From a295688fd0977d5872605fefef53714104b218ff Mon Sep 17 00:00:00 2001 From: li-yaoyao777 Date: Sat, 28 May 2022 14:45:58 +0800 Subject: [PATCH 001/109] =?UTF-8?q?gitsensorlists=E5=92=8Cgetsinglesensor?= =?UTF-8?q?=E6=8E=A5=E5=8F=A3Mock=E9=AA=8C=E8=AF=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: li-yaoyao777 --- .../extend/systemplugin/napi/ohos_sensor.js | 24 +++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/runtime/main/extend/systemplugin/napi/ohos_sensor.js b/runtime/main/extend/systemplugin/napi/ohos_sensor.js index f81ae7c1..de7172ea 100644 --- a/runtime/main/extend/systemplugin/napi/ohos_sensor.js +++ b/runtime/main/extend/systemplugin/napi/ohos_sensor.js @@ -350,6 +350,30 @@ export function mockSensor() { resolve(paramMock.paramArrayMock); }) } + }, + getSingleSensor: function (...args) { + console.warn("sensor.getSingleSensor interface mocked in the Previewer. How this interface works on the" + + " Previewer may be different from that on a real device.") + const len = args.length + if (typeof args[len - 1] === 'function') { + args[len - 1].call(this, paramMock.businessErrorMoc, paramMock.paramArrayMock); + } else { + return new Promise((resolve, reject) => { + resolve(paramMock.paramArrayMock); + }) + } + }, + getSensorLists: function (...args) { + console.warn("sensor.getSensorLists interface mocked in the Previewer. How this interface works on the" + + " Previewer may be different from that on a real device.") + const len = args.length + if (typeof args[len - 1] === 'function') { + args[len - 1].call(this, paramMock.businessErrorMoc, paramMock.paramArrayMock); + } else { + return new Promise((resolve, reject) => { + resolve(paramMock.paramArrayMock); + }) + } } } return sensor From 8e80e35621159bec1629e8c4ea01afac109b81c7 Mon Sep 17 00:00:00 2001 From: li-yaoyao777 Date: Sat, 28 May 2022 16:56:29 +0800 Subject: [PATCH 002/109] =?UTF-8?q?gitsensorlists=E5=92=8Cgetsinglesensor?= =?UTF-8?q?=E6=8E=A5=E5=8F=A3Mock=E9=AA=8C=E8=AF=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: li-yaoyao777 --- runtime/main/extend/systemplugin/napi/ohos_sensor.js | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/runtime/main/extend/systemplugin/napi/ohos_sensor.js b/runtime/main/extend/systemplugin/napi/ohos_sensor.js index de7172ea..e03f1301 100644 --- a/runtime/main/extend/systemplugin/napi/ohos_sensor.js +++ b/runtime/main/extend/systemplugin/napi/ohos_sensor.js @@ -128,6 +128,16 @@ export function mockSensor() { x: "[PC preview] unknown x", y: "[PC preview] unknown y" } + const Sensor = { + sensorName: "[PC preview] unknown sensorName", + venderName: "[PC preview] unknown venderName", + firmwareVersion: "[PC preview] unknown firmwareVersion", + hardwareVersion: "[PC preview] unknown hardwareVersion", + sensorTypeId: "[PC preview] unknown sensorTypeId", + maxRange: "[PC preview] unknown maxRange", + precision: "[PC preview] unknown precision", + power: "[PC preview] unknown power" + } const SensorType = { SENSOR_TYPE_ID_ACCELEROMETER: 1, SENSOR_TYPE_ID_GYROSCOPE: 2, From 556c4cbba3e91d6afb40fa728c5cddc640a51ae9 Mon Sep 17 00:00:00 2001 From: li-yaoyao777 Date: Mon, 30 May 2022 10:28:48 +0800 Subject: [PATCH 003/109] =?UTF-8?q?gitsensorlists=E5=92=8Cgetsinglesensor?= =?UTF-8?q?=E6=8E=A5=E5=8F=A3Mock=E9=AA=8C=E8=AF=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: li-yaoyao777 --- runtime/main/extend/systemplugin/napi/ohos_sensor.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/runtime/main/extend/systemplugin/napi/ohos_sensor.js b/runtime/main/extend/systemplugin/napi/ohos_sensor.js index e03f1301..d345b77d 100644 --- a/runtime/main/extend/systemplugin/napi/ohos_sensor.js +++ b/runtime/main/extend/systemplugin/napi/ohos_sensor.js @@ -366,7 +366,7 @@ export function mockSensor() { " Previewer may be different from that on a real device.") const len = args.length if (typeof args[len - 1] === 'function') { - args[len - 1].call(this, paramMock.businessErrorMoc, paramMock.paramArrayMock); + args[len - 1].call(this, paramMock.businessErrorMoc, paramMock.OrientationResponse); } else { return new Promise((resolve, reject) => { resolve(paramMock.paramArrayMock); From db30efe7b28ce99fb7dee27def8d275d7dcf8157 Mon Sep 17 00:00:00 2001 From: li-yaoyao777 Date: Mon, 30 May 2022 10:33:02 +0800 Subject: [PATCH 004/109] ohos_sensor.js Signed-off-by: li-yaoyao777 --- runtime/main/extend/systemplugin/napi/ohos_sensor.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/runtime/main/extend/systemplugin/napi/ohos_sensor.js b/runtime/main/extend/systemplugin/napi/ohos_sensor.js index d345b77d..d7e4daff 100644 --- a/runtime/main/extend/systemplugin/napi/ohos_sensor.js +++ b/runtime/main/extend/systemplugin/napi/ohos_sensor.js @@ -366,7 +366,7 @@ export function mockSensor() { " Previewer may be different from that on a real device.") const len = args.length if (typeof args[len - 1] === 'function') { - args[len - 1].call(this, paramMock.businessErrorMoc, paramMock.OrientationResponse); + args[len - 1].call(this, paramMock.businessErrorMoc, paramMock.Sensor); } else { return new Promise((resolve, reject) => { resolve(paramMock.paramArrayMock); From 8ff3acab4ec48f50500b59b0206e90ecbb3fa536 Mon Sep 17 00:00:00 2001 From: li-yaoyao777 Date: Wed, 15 Jun 2022 10:54:47 +0800 Subject: [PATCH 005/109] ohos_sensor.js Signed-off-by: li-yaoyao777 --- runtime/main/extend/systemplugin/napi/ohos_sensor.js | 4 ++-- runtime/main/extend/systemplugin/utils.js | 8 ++++++++ 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/runtime/main/extend/systemplugin/napi/ohos_sensor.js b/runtime/main/extend/systemplugin/napi/ohos_sensor.js index d7e4daff..5e3ec99c 100644 --- a/runtime/main/extend/systemplugin/napi/ohos_sensor.js +++ b/runtime/main/extend/systemplugin/napi/ohos_sensor.js @@ -369,7 +369,7 @@ export function mockSensor() { args[len - 1].call(this, paramMock.businessErrorMoc, paramMock.Sensor); } else { return new Promise((resolve, reject) => { - resolve(paramMock.paramArrayMock); + resolve(paramMock.Sensor); }) } }, @@ -387,4 +387,4 @@ export function mockSensor() { } } return sensor -} +} \ No newline at end of file diff --git a/runtime/main/extend/systemplugin/utils.js b/runtime/main/extend/systemplugin/utils.js index fdfd56c8..00075baf 100644 --- a/runtime/main/extend/systemplugin/utils.js +++ b/runtime/main/extend/systemplugin/utils.js @@ -24,6 +24,14 @@ export function getRandomArbitrary(min, max) { return Math.random().toFixed(6) * (max - min) + min; } +// export const paramMock = { +// businessErrorMock: null, +// paramNumberMock: '[PC Preview] unknow number', +// paramStringMock: '[PC Preview] unknow string', +// paramBooleanMock: '[PC Preview] unknow boolean', +// paramObjectMock: '[PC Preview] unknow object', +// paramArrayMock: '[PC Preview] unknow Array' +// }; export const paramMock = { businessErrorMock: null, paramNumberMock: '[PC Preview] unknow number', From 59a34b872cc0a11b462dd68277c916a0110070f7 Mon Sep 17 00:00:00 2001 From: li-yaoyao777 Date: Wed, 15 Jun 2022 10:56:12 +0800 Subject: [PATCH 006/109] ohos_sensor.js Signed-off-by: li-yaoyao777 --- runtime/main/extend/systemplugin/utils.js | 8 -------- 1 file changed, 8 deletions(-) diff --git a/runtime/main/extend/systemplugin/utils.js b/runtime/main/extend/systemplugin/utils.js index 00075baf..fdfd56c8 100644 --- a/runtime/main/extend/systemplugin/utils.js +++ b/runtime/main/extend/systemplugin/utils.js @@ -24,14 +24,6 @@ export function getRandomArbitrary(min, max) { return Math.random().toFixed(6) * (max - min) + min; } -// export const paramMock = { -// businessErrorMock: null, -// paramNumberMock: '[PC Preview] unknow number', -// paramStringMock: '[PC Preview] unknow string', -// paramBooleanMock: '[PC Preview] unknow boolean', -// paramObjectMock: '[PC Preview] unknow object', -// paramArrayMock: '[PC Preview] unknow Array' -// }; export const paramMock = { businessErrorMock: null, paramNumberMock: '[PC Preview] unknow number', From 3e9d855f4ac6476505eba7d42aeea18ce6f5e170 Mon Sep 17 00:00:00 2001 From: li-yaoyao777 Date: Fri, 17 Jun 2022 15:43:19 +0800 Subject: [PATCH 007/109] ohos_sensor.js Signed-off-by: li-yaoyao777 --- .../extend/systemplugin/napi/ohos_sensor.js | 55 ++++++++++--------- 1 file changed, 28 insertions(+), 27 deletions(-) diff --git a/runtime/main/extend/systemplugin/napi/ohos_sensor.js b/runtime/main/extend/systemplugin/napi/ohos_sensor.js index 5e3ec99c..44ba4a28 100644 --- a/runtime/main/extend/systemplugin/napi/ohos_sensor.js +++ b/runtime/main/extend/systemplugin/napi/ohos_sensor.js @@ -126,19 +126,20 @@ export function mockSensor() { } const CoordinatesOptions = { x: "[PC preview] unknown x", - y: "[PC preview] unknown y" - } + y: '[PC preview] unknown y' + }; const Sensor = { - sensorName: "[PC preview] unknown sensorName", - venderName: "[PC preview] unknown venderName", - firmwareVersion: "[PC preview] unknown firmwareVersion", - hardwareVersion: "[PC preview] unknown hardwareVersion", - sensorTypeId: "[PC preview] unknown sensorTypeId", - maxRange: "[PC preview] unknown maxRange", - precision: "[PC preview] unknown precision", - power: "[PC preview] unknown power" - } - const SensorType = { + sensorName: '[PC preview] unknown sensorName', + venderName: '[PC preview] unknown venderName', + firmwareVersion: '[PC preview] unknown firmwareVersion', + hardwareVersion: '[PC preview] unknown hardwareVersion', + sensorTypeId: '[PC preview] unknown sensorTypeId', + maxRange: '[PC preview] unknown maxRange', + precision: '[PC preview] unknown precision', + power: '[PC preview] unknown power' +}; + + const SensorType = { SENSOR_TYPE_ID_ACCELEROMETER: 1, SENSOR_TYPE_ID_GYROSCOPE: 2, SENSOR_TYPE_ID_AMBIENT_LIGHT: 5, @@ -338,7 +339,7 @@ export function mockSensor() { } }, createQuaternion: function (...args) { - console.warn("sensor.createQuaternion interface mocked in the Previewer. How this interface works on the" + + console.warn("sensor.createQuaternion interface mocked in the Previewer. How this interface works on the" + " Previewer may be different from that on a real device.") const len = args.length if (typeof args[len - 1] === 'function') { @@ -350,7 +351,7 @@ export function mockSensor() { } }, getDirection: function (...args) { - console.warn("sensor.getDirection interface mocked in the Previewer. How this interface works on the" + + console.warn("sensor.getDirection interface mocked in the Previewer. How this interface works on the" + " Previewer may be different from that on a real device.") const len = args.length if (typeof args[len - 1] === 'function') { @@ -358,33 +359,33 @@ export function mockSensor() { } else { return new Promise((resolve, reject) => { resolve(paramMock.paramArrayMock); - }) + }); } }, getSingleSensor: function (...args) { - console.warn("sensor.getSingleSensor interface mocked in the Previewer. How this interface works on the" + - " Previewer may be different from that on a real device.") - const len = args.length - if (typeof args[len - 1] === 'function') { + console.warn('sensor.getSingleSensor interface mocked in the Previewer. How this interface works on the' + + ' Previewer may be different from that on a real device.'); + const len = args.length; + if (typeof args[len - 1] === 'function') { args[len - 1].call(this, paramMock.businessErrorMoc, paramMock.Sensor); } else { return new Promise((resolve, reject) => { resolve(paramMock.Sensor); - }) + }); } }, getSensorLists: function (...args) { - console.warn("sensor.getSensorLists interface mocked in the Previewer. How this interface works on the" + - " Previewer may be different from that on a real device.") - const len = args.length - if (typeof args[len - 1] === 'function') { + console.warn('sensor.getSensorLists interface mocked in the Previewer. How this interface works on the' + + " Previewer may be different from that on a real device."); + const len = args.length; + if (typeof args[len - 1] === 'function') { args[len - 1].call(this, paramMock.businessErrorMoc, paramMock.paramArrayMock); } else { return new Promise((resolve, reject) => { resolve(paramMock.paramArrayMock); - }) + }); } - } + }, } - return sensor + return sensor; } \ No newline at end of file From d2e9c2b634420a86946f2a888081a7bbef77792f Mon Sep 17 00:00:00 2001 From: li-yaoyao777 Date: Fri, 17 Jun 2022 16:09:27 +0800 Subject: [PATCH 008/109] ohos_sensor.js Signed-off-by: li-yaoyao777 --- .../extend/systemplugin/napi/ohos_sensor.js | 707 +++++++++--------- 1 file changed, 353 insertions(+), 354 deletions(-) diff --git a/runtime/main/extend/systemplugin/napi/ohos_sensor.js b/runtime/main/extend/systemplugin/napi/ohos_sensor.js index 44ba4a28..83350923 100644 --- a/runtime/main/extend/systemplugin/napi/ohos_sensor.js +++ b/runtime/main/extend/systemplugin/napi/ohos_sensor.js @@ -16,376 +16,375 @@ import { paramMock } from "../utils" export function mockSensor() { - const AccelerometerResponse = { - x: "[PC preview] unknown x", - y: "[PC preview] unknown y", - z: "[PC preview] unknown z" + const AccelerometerResponse = { + x: '[PC preview] unknown x', + y: '[PC preview] unknown y', + z: '[PC preview] unknown z' } - const LinearAccelerometerResponse = { - x: "[PC preview] unknown x", - y: "[PC preview] unknown y", - z: "[PC preview] unknown z" - } - const AccelerometerUncalibratedResponse = { - x: "[PC preview] unknown x", - y: "[PC preview] unknown y", - z: "[PC preview] unknown z", - biasX: "[PC preview] unknown biasX", - biasY: "[PC preview] unknown biasY", - biasZ: "[PC preview] unknown biasZ" - } - const GravityResponse = { - x: "[PC preview] unknown x", - y: "[PC preview] unknown y", - z: "[PC preview] unknown z" - } - const OrientationResponse = { - alpha: "[PC preview] unknown alpha", - beta: "[PC preview] unknown beta", - gamma: "[PC preview] unknown gamma" - } - const RotationVectorResponse = { - x: "[PC preview] unknown x", - y: "[PC preview] unknown y", - z: "[PC preview] unknown z" - } - const GyroscopeResponse = { - x: "[PC preview] unknown x", - y: "[PC preview] unknown y", - z: "[PC preview] unknown z" - } - const GyroscopeUncalibratedResponse = { - x: "[PC preview] unknown x", - y: "[PC preview] unknown y", - z: "[PC preview] unknown z", - biasX: "[PC preview] unknown biasX", - biasY: "[PC preview] unknown biasY", - biasZ: "[PC preview] unknown biasZ" - } - const SignificantMotionResponse = { - scalar: "[PC preview] unknown scalar" - } - const ProximityResponse = { - distance: "[PC preview] unknown distance" - } - const LightResponse = { - intensity: "[PC preview] unknown intensity" - } - const HallResponse = { - status: "[PC preview] unknown status" - } - const MagneticFieldResponse = { - x: "[PC preview] unknown x", - y: "[PC preview] unknown y", - z: "[PC preview] unknown z" - } - const MagneticFieldUncalibratedResponse = { - x: "[PC preview] unknown x", - y: "[PC preview] unknown y", - z: "[PC preview] unknown z", - biasX: "[PC preview] unknown biasX", - biasY: "[PC preview] unknown biasY", - biasZ: "[PC preview] unknown biasZ" - } - const PedometerResponse = { - steps: "[PC preview] unknown steps" - } - const HumidityResponse = { - humidity: "[PC preview] unknown humidity" - } - const PedometerDetectResponse = { - scalar: "[PC preview] unknown scalar" - } - const AmbientTemperatureResponse = { - temperature: "[PC preview] unknown temperature" - } - const BarometerResponse = { - pressure: "[PC preview] unknown pressure" - } - const HeartRateResponse = { - heartRate: "[PC preview] unknown heartRate" - } - const WearDetectionResponse = { - value: "[PC preview] unknown value" - } - const Options = { - interval: "[PC preview] unknown value" - } - const GeomagneticResponse = { - x: "[PC preview] unknown x", - y: "[PC preview] unknown y", - z: "[PC preview] unknown z", - biasX: "[PC preview] unknown biasX", - biasY: "[PC preview] unknown biasY", - biasZ: "[PC preview] unknown biasZ" - } - const LocationOptions = { - latitude: "[PC preview] unknown latitude", - longitude: "[PC preview] unknown longitude", - altitude: "[PC preview] unknown altitude", - } - const CoordinatesOptions = { - x: "[PC preview] unknown x", - y: '[PC preview] unknown y' - }; - const Sensor = { - sensorName: '[PC preview] unknown sensorName', - venderName: '[PC preview] unknown venderName', - firmwareVersion: '[PC preview] unknown firmwareVersion', - hardwareVersion: '[PC preview] unknown hardwareVersion', - sensorTypeId: '[PC preview] unknown sensorTypeId', - maxRange: '[PC preview] unknown maxRange', - precision: '[PC preview] unknown precision', - power: '[PC preview] unknown power' -}; - + const LinearAccelerometerResponse = { + x: '[PC preview] unknown x', + y: '[PC preview] unknown y', + z: '[PC preview] unknown z' + } + const AccelerometerUncalibratedResponse = { + x: '[PC preview] unknown x', + y: '[PC preview] unknown y', + z: '[PC preview] unknown z', + biasX: '[PC preview] unknown biasX', + biasY: '[PC preview] unknown biasY', + biasZ: '[PC preview] unknown biasZ' + } + const GravityResponse = { + x: '[PC preview] unknown x', + y: '[PC preview] unknown y', + z: '[PC preview] unknown z' + } + const OrientationResponse = { + alpha: '[PC preview] unknown alpha', + beta: '[PC preview] unknown beta', + gamma: '[PC preview] unknown gamma' + } + const RotationVectorResponse = { + x: '[PC preview] unknown x', + y: '[PC preview] unknown y', + z: '[PC preview] unknown z' + } + const GyroscopeResponse = { + x: '[PC preview] unknown x', + y: '[PC preview] unknown y', + z: '[PC preview] unknown z' + } + const GyroscopeUncalibratedResponse = { + x: '[PC preview] unknown x', + y: '[PC preview] unknown y', + z: '[PC preview] unknown z', + biasX: '[PC preview] unknown biasX', + biasY: '[PC preview] unknown biasY', + biasZ: '[PC preview] unknown biasZ' + } + const SignificantMotionResponse = { + scalar: '[PC preview] unknown scalar' + } + const ProximityResponse = { + distance: '[PC preview] unknown distance' + } + const LightResponse = { + intensity: '[PC preview] unknown intensity' + } + const HallResponse = { + status: '[PC preview] unknown status' + } + const MagneticFieldResponse = { + x: '[PC preview] unknown x', + y: '[PC preview] unknown y', + z: '[PC preview] unknown z' + } + const MagneticFieldUncalibratedResponse = { + x: '[PC preview] unknown x', + y: '[PC preview] unknown y', + z: '[PC preview] unknown z', + biasX: '[PC preview] unknown biasX', + biasY: '[PC preview] unknown biasY', + biasZ: '[PC preview] unknown biasZ' + } + const PedometerResponse = { + steps: '[PC preview] unknown steps' + } + const HumidityResponse = { + humidity: '[PC preview] unknown humidity' + } + const PedometerDetectResponse = { + scalar: '[PC preview] unknown scalar' + } + const AmbientTemperatureResponse = { + temperature: '[PC preview] unknown temperature' + } + const BarometerResponse = { + pressure: '[PC preview] unknown pressure' + } + const HeartRateResponse = { + heartRate: '[PC preview] unknown heartRate' + } + const WearDetectionResponse = { + value: '[PC preview] unknown value' + } + const Options = { + interval: '[PC preview] unknown value' + } + const GeomagneticResponse = { + x: '[PC preview] unknown x', + y: '[PC preview] unknown y', + z: '[PC preview] unknown z', + biasX: '[PC preview] unknown biasX', + biasY: '[PC preview] unknown biasY', + biasZ: '[PC preview] unknown biasZ' + } + const LocationOptions = { + latitude: '[PC preview] unknown latitude', + longitude: '[PC preview] unknown longitude', + altitude: '[PC preview] unknown altitude', + } + const CoordinatesOptions = { + x: '[PC preview] unknown x', + y: '[PC preview] unknown y' + } + const Sensor = { + sensorName: '[PC preview] unknown sensorName', + venderName: '[PC preview] unknown venderName', + firmwareVersion: '[PC preview] unknown firmwareVersion', + hardwareVersion: '[PC preview] unknown hardwareVersion', + sensorTypeId: '[PC preview] unknown sensorTypeId', + maxRange: '[PC preview] unknown maxRange', + precision: '[PC preview] unknown precision', + power: '[PC preview] unknown power' + } const SensorType = { - SENSOR_TYPE_ID_ACCELEROMETER: 1, - SENSOR_TYPE_ID_GYROSCOPE: 2, - SENSOR_TYPE_ID_AMBIENT_LIGHT: 5, - SENSOR_TYPE_ID_MAGNETIC_FIELD: 6, - SENSOR_TYPE_ID_BAROMETER: 8, - SENSOR_TYPE_ID_HALL: 10, - SENSOR_TYPE_ID_PROXIMITY: 12, - SENSOR_TYPE_ID_HUMIDITY: 13, - SENSOR_TYPE_ID_ORIENTATION: 256, - SENSOR_TYPE_ID_GRAVITY: 257, - SENSOR_TYPE_ID_LINEAR_ACCELERATION: 258, - SENSOR_TYPE_ID_ROTATION_VECTOR: 259, - SENSOR_TYPE_ID_AMBIENT_TEMPERATURE: 260, - SENSOR_TYPE_ID_MAGNETIC_FIELD_UNCALIBRATED: 261, - SENSOR_TYPE_ID_GYROSCOPE_UNCALIBRATED: 263, - SENSOR_TYPE_ID_SIGNIFICANT_MOTION: 264, - SENSOR_TYPE_ID_PEDOMETER_DETECTION: 265, - SENSOR_TYPE_ID_PEDOMETER: 266, - SENSOR_TYPE_ID_HEART_RATE: 278, - SENSOR_TYPE_ID_WEAR_DETECTION: 280, - SENSOR_TYPE_ID_ACCELEROMETER_UNCALIBRATED: 281 - } - const sensor = { - on: function (...args) { - console.warn("sensor.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; - const callback = typeof args[len - 1] == 'function' ? args[len - 1] : args[len - 2]; - if (args[0] == 1) { - callback.call(this, paramMock.businessErrorMock, AccelerometerResponse); - } else if (args[0] == 2) { - callback.call(this, paramMock.businessErrorMock, GyroscopeResponse); - } else if (args[0] == 5) { - callback.call(this, paramMock.businessErrorMock, LightResponse); - } else if (args[0] == 6) { - callback.call(this, paramMock.businessErrorMock, MagneticFieldResponse); - } else if (args[0] == 8) { - callback.call(this, paramMock.businessErrorMock, BarometerResponse); - } else if (args[0] == 10) { - callback.call(this, paramMock.businessErrorMock, HallResponse); - } else if (args[0] == 12) { - callback.call(this, paramMock.businessErrorMock, ProximityResponse); - } else if (args[0] == 13) { - callback.call(this, paramMock.businessErrorMock, HumidityResponse); - } else if (args[0] == 256) { - callback.call(this, paramMock.businessErrorMock, OrientationResponse); - } else if (args[0] == 257) { - callback.call(this, paramMock.businessErrorMock, GravityResponse); - } else if (args[0] == 258) { - callback.call(this, paramMock.businessErrorMock, LinearAccelerometerResponse); - } else if (args[0] == 259) { - callback.call(this, paramMock.businessErrorMock, RotationVectorResponse); - } else if (args[0] == 260) { - callback.call(this, paramMock.businessErrorMock, AmbientTemperatureResponse); - } else if (args[0] == 261) { - callback.call(this, paramMock.businessErrorMock, MagneticFieldUncalibratedResponse); - } else if (args[0] == 263) { - callback.call(this, paramMock.businessErrorMock, GyroscopeUncalibratedResponse); - } else if (args[0] == 264) { - callback.call(this, paramMock.businessErrorMock, SignificantMotionResponse); - } else if (args[0] == 265) { - callback.call(this, paramMock.businessErrorMock, PedometerDetectResponse); - } else if (args[0] == 266) { - callback.call(this, paramMock.businessErrorMock, PedometerResponse); - } else if (args[0] == 278) { - callback.call(this, paramMock.businessErrorMock, HeartRateResponse); - } else if (args[0] == 280) { - callback.call(this, paramMock.businessErrorMock, WearDetectionResponse); - } else if (args[0] == 281) { - callback.call(this, paramMock.businessErrorMock, AccelerometerUncalibratedResponse); - } - }, + SENSOR_TYPE_ID_ACCELEROMETER: 1, + SENSOR_TYPE_ID_GYROSCOPE: 2, + SENSOR_TYPE_ID_AMBIENT_LIGHT: 5, + SENSOR_TYPE_ID_MAGNETIC_FIELD: 6, + SENSOR_TYPE_ID_BAROMETER: 8, + SENSOR_TYPE_ID_HALL: 10, + SENSOR_TYPE_ID_PROXIMITY: 12, + SENSOR_TYPE_ID_HUMIDITY: 13, + SENSOR_TYPE_ID_ORIENTATION: 256, + SENSOR_TYPE_ID_GRAVITY: 257, + SENSOR_TYPE_ID_LINEAR_ACCELERATION: 258, + SENSOR_TYPE_ID_ROTATION_VECTOR: 259, + SENSOR_TYPE_ID_AMBIENT_TEMPERATURE: 260, + SENSOR_TYPE_ID_MAGNETIC_FIELD_UNCALIBRATED: 261, + SENSOR_TYPE_ID_GYROSCOPE_UNCALIBRATED: 263, + SENSOR_TYPE_ID_SIGNIFICANT_MOTION: 264, + SENSOR_TYPE_ID_PEDOMETER_DETECTION: 265, + SENSOR_TYPE_ID_PEDOMETER: 266, + SENSOR_TYPE_ID_HEART_RATE: 278, + SENSOR_TYPE_ID_WEAR_DETECTION: 280, + SENSOR_TYPE_ID_ACCELEROMETER_UNCALIBRATED: 281 + } + const sensor = { + on: function (...args) { + console.warn('sensor.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; + const callback = typeof args[len - 1] == 'function' ? args[len - 1] : args[len - 2]; + if (args[0] == 1) { + callback.call(this, paramMock.businessErrorMock, AccelerometerResponse); + } else if (args[0] == 2) { + callback.call(this, paramMock.businessErrorMock, GyroscopeResponse); + } else if (args[0] == 5) { + callback.call(this, paramMock.businessErrorMock, LightResponse); + } else if (args[0] == 6) { + callback.call(this, paramMock.businessErrorMock, MagneticFieldResponse); + } else if (args[0] == 8) { + callback.call(this, paramMock.businessErrorMock, BarometerResponse); + } else if (args[0] == 10) { + callback.call(this, paramMock.businessErrorMock, HallResponse); + } else if (args[0] == 12) { + callback.call(this, paramMock.businessErrorMock, ProximityResponse); + } else if (args[0] == 13) { + callback.call(this, paramMock.businessErrorMock, HumidityResponse); + } else if (args[0] == 256) { + callback.call(this, paramMock.businessErrorMock, OrientationResponse); + } else if (args[0] == 257) { + callback.call(this, paramMock.businessErrorMock, GravityResponse); + } else if (args[0] == 258) { + callback.call(this, paramMock.businessErrorMock, LinearAccelerometerResponse); + } else if (args[0] == 259) { + callback.call(this, paramMock.businessErrorMock, RotationVectorResponse); + } else if (args[0] == 260) { + callback.call(this, paramMock.businessErrorMock, AmbientTemperatureResponse); + } else if (args[0] == 261) { + callback.call(this, paramMock.businessErrorMock, MagneticFieldUncalibratedResponse); + } else if (args[0] == 263) { + callback.call(this, paramMock.businessErrorMock, GyroscopeUncalibratedResponse); + } else if (args[0] == 264) { + callback.call(this, paramMock.businessErrorMock, SignificantMotionResponse); + } else if (args[0] == 265) { + callback.call(this, paramMock.businessErrorMock, PedometerDetectResponse); + } else if (args[0] == 266) { + callback.call(this, paramMock.businessErrorMock, PedometerResponse); + } else if (args[0] == 278) { + callback.call(this, paramMock.businessErrorMock, HeartRateResponse); + } else if (args[0] == 280) { + callback.call(this, paramMock.businessErrorMock, WearDetectionResponse); + } else if (args[0] == 281) { + callback.call(this, paramMock.businessErrorMock, AccelerometerUncalibratedResponse); + } + }, once: function (...args) { - console.warn("sensor.once interface mocked in the Previewer. How this interface works on the" + - " Previewer may be different from that on a real device.") - const len = args.length - if (args[0] == 1) { - args[len - 1].call(this, paramMock.businessErrorMock, AccelerometerResponse); - } else if (args[0] == 2) { - args[len - 1].call(this, paramMock.businessErrorMock, GyroscopeResponse); - } else if (args[0] == 5) { - args[len - 1].call(this, paramMock.businessErrorMock, LightResponse); - } else if (args[0] == 6) { - args[len - 1].call(this, paramMock.businessErrorMock, MagneticFieldResponse); - } else if (args[0] == 8) { - args[len - 1].call(this, paramMock.businessErrorMock, BarometerResponse); - } else if (args[0] == 10) { - args[len - 1].call(this, paramMock.businessErrorMock, HallResponse); - } else if (args[0] == 12) { - args[len - 1].call(this, paramMock.businessErrorMock, ProximityResponse); - } else if (args[0] == 13) { - args[len - 1].call(this, paramMock.businessErrorMock, HumidityResponse); - } else if (args[0] == 256) { - args[len - 1].call(this, paramMock.businessErrorMock, OrientationResponse); - } else if (args[0] == 257) { - args[len - 1].call(this, paramMock.businessErrorMock, GravityResponse); - } else if (args[0] == 258) { - args[len - 1].call(this, paramMock.businessErrorMock, LinearAccelerometerResponse); - } else if (args[0] == 259) { - args[len - 1].call(this, paramMock.businessErrorMock, RotationVectorResponse); - } else if (args[0] == 260) { - args[len - 1].call(this, paramMock.businessErrorMock, AmbientTemperatureResponse); - } else if (args[0] == 261) { - args[len - 1].call(this, paramMock.businessErrorMock, MagneticFieldUncalibratedResponse); - } else if (args[0] == 263) { - args[len - 1].call(this, paramMock.businessErrorMock, GyroscopeUncalibratedResponse); - } else if (args[0] == 264) { - args[len - 1].call(this, paramMock.businessErrorMock, SignificantMotionResponse); - } else if (args[0] == 265) { - args[len - 1].call(this, paramMock.businessErrorMock, PedometerDetectResponse); - } else if (args[0] == 266) { - args[len - 1].call(this, paramMock.businessErrorMock, PedometerResponse); - } else if (args[0] == 278) { - args[len - 1].call(this, paramMock.businessErrorMock, HeartRateResponse); - } else if (args[0] == 280) { - args[len - 1].call(this, paramMock.businessErrorMock, WearDetectionResponse); - } else if (args[0] == 281) { - args[len - 1].call(this, paramMock.businessErrorMock, AccelerometerUncalibratedResponse); - } - }, + console.warn('sensor.once interface mocked in the Previewer. How this interface works on the' + + 'Previewer may be different from that on a real device.') + const len = args.length + if (args[0] == 1) { + args[len - 1].call(this, paramMock.businessErrorMock, AccelerometerResponse); + } else if (args[0] == 2) { + args[len - 1].call(this, paramMock.businessErrorMock, GyroscopeResponse); + } else if (args[0] == 5) { + args[len - 1].call(this, paramMock.businessErrorMock, LightResponse); + } else if (args[0] == 6) { + args[len - 1].call(this, paramMock.businessErrorMock, MagneticFieldResponse); + } else if (args[0] == 8) { + args[len - 1].call(this, paramMock.businessErrorMock, BarometerResponse); + } else if (args[0] == 10) { + args[len - 1].call(this, paramMock.businessErrorMock, HallResponse); + } else if (args[0] == 12) { + args[len - 1].call(this, paramMock.businessErrorMock, ProximityResponse); + } else if (args[0] == 13) { + args[len - 1].call(this, paramMock.businessErrorMock, HumidityResponse); + } else if (args[0] == 256) { + args[len - 1].call(this, paramMock.businessErrorMock, OrientationResponse); + } else if (args[0] == 257) { + args[len - 1].call(this, paramMock.businessErrorMock, GravityResponse); + } else if (args[0] == 258) { + args[len - 1].call(this, paramMock.businessErrorMock, LinearAccelerometerResponse); + } else if (args[0] == 259) { + args[len - 1].call(this, paramMock.businessErrorMock, RotationVectorResponse); + } else if (args[0] == 260) { + args[len - 1].call(this, paramMock.businessErrorMock, AmbientTemperatureResponse); + } else if (args[0] == 261) { + args[len - 1].call(this, paramMock.businessErrorMock, MagneticFieldUncalibratedResponse); + } else if (args[0] == 263) { + args[len - 1].call(this, paramMock.businessErrorMock, GyroscopeUncalibratedResponse); + } else if (args[0] == 264) { + args[len - 1].call(this, paramMock.businessErrorMock, SignificantMotionResponse); + } else if (args[0] == 265) { + args[len - 1].call(this, paramMock.businessErrorMock, PedometerDetectResponse); + } else if (args[0] == 266) { + args[len - 1].call(this, paramMock.businessErrorMock, PedometerResponse); + } else if (args[0] == 278) { + args[len - 1].call(this, paramMock.businessErrorMock, HeartRateResponse); + } else if (args[0] == 280) { + args[len - 1].call(this, paramMock.businessErrorMock, WearDetectionResponse); + } else if (args[0] == 281) { + args[len - 1].call(this, paramMock.businessErrorMock, AccelerometerUncalibratedResponse); + } + }, off: function (...args) { - console.warn("sensor.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); - }, + console.warn('sensor.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); + }, getGeomagneticField: function (...args) { - console.warn("sensor.getGeomagneticField interface mocked in the Previewer. How this interface works on the" + - " Previewer may be different from that on a real device.") - const len = args.length - if (typeof args[len - 1] === 'function') { - args[len - 1].call(this, paramMock.businessErrorMoc, GeomagneticResponse); - } else { - return new Promise((resolve, reject) => { - resolve(GeomagneticResponse); - }) - } - }, + console.warn('sensor.getGeomagneticField interface mocked in the Previewer. How this interface works on the' + + 'Previewer may be different from that on a real device.') + const len = args.length + if (typeof args[len - 1] === 'function') { + args[len - 1].call(this, paramMock.businessErrorMoc, GeomagneticResponse); + } else { + return new Promise((resolve, reject) => { + resolve(GeomagneticResponse); + }); + } + }, getAltitude: function (...args) { - console.warn("sensor.getAltitude interface mocked in the Previewer. How this interface works on the" + - " Previewer may be different from that on a real device.") - const len = args.length - if (typeof args[len - 1] === 'function') { - args[len - 1].call(this, paramMock.businessErrorMoc, paramMock.paramNumberMock); - } else { - return new Promise((resolve, reject) => { - resolve(paramMock.paramNumberMock); - }) - } - }, + console.warn('sensor.getAltitude interface mocked in the Previewer. How this interface works on the' + + 'Previewer may be different from that on a real device.') + const len = args.length + if (typeof args[len - 1] === 'function') { + args[len - 1].call(this, paramMock.businessErrorMoc, paramMock.paramNumberMock); + } else { + return new Promise((resolve, reject) => { + resolve(paramMock.paramNumberMock); + }); + } + }, getGeomagneticDip: function (...args) { - console.warn("sensor.getGeomagneticDip interface mocked in the Previewer. How this interface works on the" + - " Previewer may be different from that on a real device.") - const len = args.length - if (typeof args[len - 1] === 'function') { - args[len - 1].call(this, paramMock.businessErrorMoc, paramMock.paramNumberMock); - } else { - return new Promise((resolve, reject) => { - resolve(paramMock.paramNumberMock); - }) - } - }, + console.warn('sensor.getGeomagneticDip interface mocked in the Previewer. How this interface works on the' + + 'Previewer may be different from that on a real device.') + const len = args.length + if (typeof args[len - 1] === 'function') { + args[len - 1].call(this, paramMock.businessErrorMoc, paramMock.paramNumberMock); + } else { + return new Promise((resolve, reject) => { + resolve(paramMock.paramNumberMock); + }); + } + }, getAngleModifiy: function (...args) { - console.warn("sensor.getAngleModifiy interface mocked in the Previewer. How this interface works on the" + - " Previewer may be different from that on a real device.") - const len = args.length - if (typeof args[len - 1] === 'function') { - args[len - 1].call(this, paramMock.businessErrorMoc, paramMock.paramArrayMock); - } else { - return new Promise((resolve, reject) => { - resolve(paramMock.paramArrayMock); - }) - } - }, + console.warn('sensor.getAngleModifiy interface mocked in the Previewer. How this interface works on the' + + 'Previewer may be different from that on a real device.') + const len = args.length + if (typeof args[len - 1] === 'function') { + args[len - 1].call(this, paramMock.businessErrorMoc, paramMock.paramArrayMock); + } else { + return new Promise((resolve, reject) => { + resolve(paramMock.paramArrayMock); + }); + } + }, createRotationMatrix: function (...args) { - console.warn("sensor.createRotationMatrix interface mocked in the Previewer. How this interface works on the" + - " Previewer may be different from that on a real device.") - const len = args.length - if (typeof args[len - 1] === 'function') { - args[len - 1].call(this, paramMock.businessErrorMoc, paramMock.paramArrayMock); - } else { - return new Promise((resolve, reject) => { - resolve(paramMock.paramArrayMock); - }) - } - }, + console.warn('sensor.createRotationMatrix interface mocked in the Previewer. How this interface works on the' + + 'Previewer may be different from that on a real device.') + const len = args.length + if (typeof args[len - 1] === 'function') { + args[len - 1].call(this, paramMock.businessErrorMoc, paramMock.paramArrayMock); + } else { + return new Promise((resolve, reject) => { + resolve(paramMock.paramArrayMock); + }); + } + }, transformCoordinateSystem: function (...args) { - console.warn("sensor.transformCoordinateSystem interface mocked in the Previewer. How this interface works on the" + - " Previewer may be different from that on a real device.") - const len = args.length - if (typeof args[len - 1] === 'function') { - args[len - 1].call(this, paramMock.businessErrorMoc, paramMock.paramArrayMock); - } else { - return new Promise((resolve, reject) => { - resolve(paramMock.paramArrayMock); - }) - } - }, + console.warn('sensor.transformCoordinateSystem interface mocked in the Previewer. How this interface works on the' + + 'Previewer may be different from that on a real device.') + const len = args.length + if (typeof args[len - 1] === 'function') { + args[len - 1].call(this, paramMock.businessErrorMoc, paramMock.paramArrayMock); + } else { + return new Promise((resolve, reject) => { + resolve(paramMock.paramArrayMock); + }); + } + }, createQuaternion: function (...args) { - console.warn("sensor.createQuaternion interface mocked in the Previewer. How this interface works on the" + - " Previewer may be different from that on a real device.") - const len = args.length - if (typeof args[len - 1] === 'function') { - args[len - 1].call(this, paramMock.businessErrorMoc, paramMock.paramArrayMock); - } else { - return new Promise((resolve, reject) => { - resolve(paramMock.paramArrayMock); - }) - } - }, + console.warn('sensor.createQuaternion interface mocked in the Previewer. How this interface works on the' + + 'Previewer may be different from that on a real device.') + const len = args.length + if (typeof args[len - 1] === 'function') { + args[len - 1].call(this, paramMock.businessErrorMoc, paramMock.paramArrayMock); + } else { + return new Promise((resolve, reject) => { + resolve(paramMock.paramArrayMock); + }); + } + }, getDirection: function (...args) { - console.warn("sensor.getDirection interface mocked in the Previewer. How this interface works on the" + - " Previewer may be different from that on a real device.") - const len = args.length - if (typeof args[len - 1] === 'function') { - args[len - 1].call(this, paramMock.businessErrorMoc, paramMock.paramArrayMock); - } else { - return new Promise((resolve, reject) => { - resolve(paramMock.paramArrayMock); - }); - } - }, + console.warn('sensor.getDirection interface mocked in the Previewer. How this interface works on the' + + 'Previewer may be different from that on a real device.') + const len = args.length + if (typeof args[len - 1] === 'function') { + args[len - 1].call(this, paramMock.businessErrorMoc, paramMock.paramArrayMock); + } else { + return new Promise((resolve, reject) => { + resolve(paramMock.paramArrayMock); + }); + } + }, getSingleSensor: function (...args) { console.warn('sensor.getSingleSensor interface mocked in the Previewer. How this interface works on the' - + ' Previewer may be different from that on a real device.'); - const len = args.length; + + 'Previewer may be different from that on a real device.') + const len = args.length if (typeof args[len - 1] === 'function') { - args[len - 1].call(this, paramMock.businessErrorMoc, paramMock.Sensor); - } else { - return new Promise((resolve, reject) => { - resolve(paramMock.Sensor); - }); - } - }, + args[len - 1].call(this, paramMock.businessErrorMoc, paramMock.Sensor); + } else { + return new Promise((resolve, reject) => { + resolve(paramMock.Sensor); + }); + } + }, getSensorLists: function (...args) { console.warn('sensor.getSensorLists interface mocked in the Previewer. How this interface works on the' - + " Previewer may be different from that on a real device."); - const len = args.length; + + 'Previewer may be different from that on a real device.') + const len = args.length if (typeof args[len - 1] === 'function') { - args[len - 1].call(this, paramMock.businessErrorMoc, paramMock.paramArrayMock); - } else { - return new Promise((resolve, reject) => { - resolve(paramMock.paramArrayMock); - }); - } - }, - } - return sensor; + args[len - 1].call(this, paramMock.businessErrorMoc, paramMock.paramArrayMock); + } else { + return new Promise((resolve, reject) => { + resolve(paramMock.paramArrayMock); + }); + } + }, + } + return sensor } \ No newline at end of file From 9d35f855fa7d2dda1873057f5acc2dae78a03003 Mon Sep 17 00:00:00 2001 From: li-yaoyao777 Date: Fri, 17 Jun 2022 16:20:00 +0800 Subject: [PATCH 009/109] ohos_sensor.js Signed-off-by: li-yaoyao777 --- .../extend/systemplugin/napi/ohos_sensor.js | 332 +++++++++--------- 1 file changed, 166 insertions(+), 166 deletions(-) diff --git a/runtime/main/extend/systemplugin/napi/ohos_sensor.js b/runtime/main/extend/systemplugin/napi/ohos_sensor.js index 83350923..d7d4cbd0 100644 --- a/runtime/main/extend/systemplugin/napi/ohos_sensor.js +++ b/runtime/main/extend/systemplugin/napi/ohos_sensor.js @@ -163,228 +163,228 @@ export function mockSensor() { } const sensor = { on: function (...args) { - console.warn('sensor.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; - const callback = typeof args[len - 1] == 'function' ? args[len - 1] : args[len - 2]; - if (args[0] == 1) { - callback.call(this, paramMock.businessErrorMock, AccelerometerResponse); - } else if (args[0] == 2) { - callback.call(this, paramMock.businessErrorMock, GyroscopeResponse); - } else if (args[0] == 5) { - callback.call(this, paramMock.businessErrorMock, LightResponse); - } else if (args[0] == 6) { - callback.call(this, paramMock.businessErrorMock, MagneticFieldResponse); - } else if (args[0] == 8) { - callback.call(this, paramMock.businessErrorMock, BarometerResponse); - } else if (args[0] == 10) { - callback.call(this, paramMock.businessErrorMock, HallResponse); - } else if (args[0] == 12) { - callback.call(this, paramMock.businessErrorMock, ProximityResponse); - } else if (args[0] == 13) { - callback.call(this, paramMock.businessErrorMock, HumidityResponse); - } else if (args[0] == 256) { - callback.call(this, paramMock.businessErrorMock, OrientationResponse); - } else if (args[0] == 257) { - callback.call(this, paramMock.businessErrorMock, GravityResponse); - } else if (args[0] == 258) { - callback.call(this, paramMock.businessErrorMock, LinearAccelerometerResponse); - } else if (args[0] == 259) { - callback.call(this, paramMock.businessErrorMock, RotationVectorResponse); - } else if (args[0] == 260) { - callback.call(this, paramMock.businessErrorMock, AmbientTemperatureResponse); - } else if (args[0] == 261) { - callback.call(this, paramMock.businessErrorMock, MagneticFieldUncalibratedResponse); - } else if (args[0] == 263) { - callback.call(this, paramMock.businessErrorMock, GyroscopeUncalibratedResponse); - } else if (args[0] == 264) { - callback.call(this, paramMock.businessErrorMock, SignificantMotionResponse); - } else if (args[0] == 265) { - callback.call(this, paramMock.businessErrorMock, PedometerDetectResponse); - } else if (args[0] == 266) { - callback.call(this, paramMock.businessErrorMock, PedometerResponse); - } else if (args[0] == 278) { - callback.call(this, paramMock.businessErrorMock, HeartRateResponse); - } else if (args[0] == 280) { - callback.call(this, paramMock.businessErrorMock, WearDetectionResponse); - } else if (args[0] == 281) { - callback.call(this, paramMock.businessErrorMock, AccelerometerUncalibratedResponse); - } - }, + console.warn('sensor.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; + const callback = typeof args[len - 1] == 'function' ? args[len - 1] : args[len - 2]; + if (args[0] == 1) { + callback.call(this, paramMock.businessErrorMock, AccelerometerResponse); + } else if (args[0] == 2) { + callback.call(this, paramMock.businessErrorMock, GyroscopeResponse); + } else if (args[0] == 5) { + callback.call(this, paramMock.businessErrorMock, LightResponse); + } else if (args[0] == 6) { + callback.call(this, paramMock.businessErrorMock, MagneticFieldResponse); + } else if (args[0] == 8) { + callback.call(this, paramMock.businessErrorMock, BarometerResponse); + } else if (args[0] == 10) { + callback.call(this, paramMock.businessErrorMock, HallResponse); + } else if (args[0] == 12) { + callback.call(this, paramMock.businessErrorMock, ProximityResponse); + } else if (args[0] == 13) { + callback.call(this, paramMock.businessErrorMock, HumidityResponse); + } else if (args[0] == 256) { + callback.call(this, paramMock.businessErrorMock, OrientationResponse); + } else if (args[0] == 257) { + callback.call(this, paramMock.businessErrorMock, GravityResponse); + } else if (args[0] == 258) { + callback.call(this, paramMock.businessErrorMock, LinearAccelerometerResponse); + } else if (args[0] == 259) { + callback.call(this, paramMock.businessErrorMock, RotationVectorResponse); + } else if (args[0] == 260) { + callback.call(this, paramMock.businessErrorMock, AmbientTemperatureResponse); + } else if (args[0] == 261) { + callback.call(this, paramMock.businessErrorMock, MagneticFieldUncalibratedResponse); + } else if (args[0] == 263) { + callback.call(this, paramMock.businessErrorMock, GyroscopeUncalibratedResponse); + } else if (args[0] == 264) { + callback.call(this, paramMock.businessErrorMock, SignificantMotionResponse); + } else if (args[0] == 265) { + callback.call(this, paramMock.businessErrorMock, PedometerDetectResponse); + } else if (args[0] == 266) { + callback.call(this, paramMock.businessErrorMock, PedometerResponse); + } else if (args[0] == 278) { + callback.call(this, paramMock.businessErrorMock, HeartRateResponse); + } else if (args[0] == 280) { + callback.call(this, paramMock.businessErrorMock, WearDetectionResponse); + } else if (args[0] == 281) { + callback.call(this, paramMock.businessErrorMock, AccelerometerUncalibratedResponse); + } + }, once: function (...args) { console.warn('sensor.once interface mocked in the Previewer. How this interface works on the' - + 'Previewer may be different from that on a real device.') - const len = args.length - if (args[0] == 1) { - args[len - 1].call(this, paramMock.businessErrorMock, AccelerometerResponse); - } else if (args[0] == 2) { - args[len - 1].call(this, paramMock.businessErrorMock, GyroscopeResponse); - } else if (args[0] == 5) { - args[len - 1].call(this, paramMock.businessErrorMock, LightResponse); - } else if (args[0] == 6) { - args[len - 1].call(this, paramMock.businessErrorMock, MagneticFieldResponse); - } else if (args[0] == 8) { - args[len - 1].call(this, paramMock.businessErrorMock, BarometerResponse); - } else if (args[0] == 10) { - args[len - 1].call(this, paramMock.businessErrorMock, HallResponse); - } else if (args[0] == 12) { - args[len - 1].call(this, paramMock.businessErrorMock, ProximityResponse); - } else if (args[0] == 13) { - args[len - 1].call(this, paramMock.businessErrorMock, HumidityResponse); - } else if (args[0] == 256) { - args[len - 1].call(this, paramMock.businessErrorMock, OrientationResponse); - } else if (args[0] == 257) { - args[len - 1].call(this, paramMock.businessErrorMock, GravityResponse); - } else if (args[0] == 258) { - args[len - 1].call(this, paramMock.businessErrorMock, LinearAccelerometerResponse); - } else if (args[0] == 259) { - args[len - 1].call(this, paramMock.businessErrorMock, RotationVectorResponse); - } else if (args[0] == 260) { - args[len - 1].call(this, paramMock.businessErrorMock, AmbientTemperatureResponse); - } else if (args[0] == 261) { - args[len - 1].call(this, paramMock.businessErrorMock, MagneticFieldUncalibratedResponse); - } else if (args[0] == 263) { - args[len - 1].call(this, paramMock.businessErrorMock, GyroscopeUncalibratedResponse); - } else if (args[0] == 264) { - args[len - 1].call(this, paramMock.businessErrorMock, SignificantMotionResponse); - } else if (args[0] == 265) { - args[len - 1].call(this, paramMock.businessErrorMock, PedometerDetectResponse); - } else if (args[0] == 266) { - args[len - 1].call(this, paramMock.businessErrorMock, PedometerResponse); - } else if (args[0] == 278) { - args[len - 1].call(this, paramMock.businessErrorMock, HeartRateResponse); - } else if (args[0] == 280) { - args[len - 1].call(this, paramMock.businessErrorMock, WearDetectionResponse); - } else if (args[0] == 281) { - args[len - 1].call(this, paramMock.businessErrorMock, AccelerometerUncalibratedResponse); - } - }, + + 'Previewer may be different from that on a real device.') + const len = args.length + if (args[0] == 1) { + args[len - 1].call(this, paramMock.businessErrorMock, AccelerometerResponse); + } else if (args[0] == 2) { + args[len - 1].call(this, paramMock.businessErrorMock, GyroscopeResponse); + } else if (args[0] == 5) { + args[len - 1].call(this, paramMock.businessErrorMock, LightResponse); + } else if (args[0] == 6) { + args[len - 1].call(this, paramMock.businessErrorMock, MagneticFieldResponse); + } else if (args[0] == 8) { + args[len - 1].call(this, paramMock.businessErrorMock, BarometerResponse); + } else if (args[0] == 10) { + args[len - 1].call(this, paramMock.businessErrorMock, HallResponse); + } else if (args[0] == 12) { + args[len - 1].call(this, paramMock.businessErrorMock, ProximityResponse); + } else if (args[0] == 13) { + args[len - 1].call(this, paramMock.businessErrorMock, HumidityResponse); + } else if (args[0] == 256) { + args[len - 1].call(this, paramMock.businessErrorMock, OrientationResponse); + } else if (args[0] == 257) { + args[len - 1].call(this, paramMock.businessErrorMock, GravityResponse); + } else if (args[0] == 258) { + args[len - 1].call(this, paramMock.businessErrorMock, LinearAccelerometerResponse); + } else if (args[0] == 259) { + args[len - 1].call(this, paramMock.businessErrorMock, RotationVectorResponse); + } else if (args[0] == 260) { + args[len - 1].call(this, paramMock.businessErrorMock, AmbientTemperatureResponse); + } else if (args[0] == 261) { + args[len - 1].call(this, paramMock.businessErrorMock, MagneticFieldUncalibratedResponse); + } else if (args[0] == 263) { + args[len - 1].call(this, paramMock.businessErrorMock, GyroscopeUncalibratedResponse); + } else if (args[0] == 264) { + args[len - 1].call(this, paramMock.businessErrorMock, SignificantMotionResponse); + } else if (args[0] == 265) { + args[len - 1].call(this, paramMock.businessErrorMock, PedometerDetectResponse); + } else if (args[0] == 266) { + args[len - 1].call(this, paramMock.businessErrorMock, PedometerResponse); + } else if (args[0] == 278) { + args[len - 1].call(this, paramMock.businessErrorMock, HeartRateResponse); + } else if (args[0] == 280) { + args[len - 1].call(this, paramMock.businessErrorMock, WearDetectionResponse); + } else if (args[0] == 281) { + args[len - 1].call(this, paramMock.businessErrorMock, AccelerometerUncalibratedResponse); + } + }, off: function (...args) { console.warn('sensor.off interface mocked in the Previewer. How this interface works on the' - + 'Previewer may be different from that on a real device.') + + 'Previewer may be different from that on a real device.') const len = args.length args[len - 1].call(this, paramMock.businessErrorMock); - }, + }, getGeomagneticField: function (...args) { console.warn('sensor.getGeomagneticField interface mocked in the Previewer. How this interface works on the' + 'Previewer may be different from that on a real device.') const len = args.length if (typeof args[len - 1] === 'function') { - args[len - 1].call(this, paramMock.businessErrorMoc, GeomagneticResponse); + args[len - 1].call(this, paramMock.businessErrorMoc, GeomagneticResponse); } else { - return new Promise((resolve, reject) => { - resolve(GeomagneticResponse); - }); - } - }, + return new Promise((resolve, reject) => { + resolve(GeomagneticResponse); + }); + } + }, getAltitude: function (...args) { console.warn('sensor.getAltitude 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.businessErrorMoc, paramMock.paramNumberMock); + args[len - 1].call(this, paramMock.businessErrorMoc, paramMock.paramNumberMock); } else { - return new Promise((resolve, reject) => { - resolve(paramMock.paramNumberMock); - }); - } - }, + return new Promise((resolve, reject) => { + resolve(paramMock.paramNumberMock); + }); + } + }, getGeomagneticDip: function (...args) { console.warn('sensor.getGeomagneticDip 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.businessErrorMoc, paramMock.paramNumberMock); + args[len - 1].call(this, paramMock.businessErrorMoc, paramMock.paramNumberMock); } else { - return new Promise((resolve, reject) => { - resolve(paramMock.paramNumberMock); - }); - } - }, + return new Promise((resolve, reject) => { + resolve(paramMock.paramNumberMock); + }); + } + }, getAngleModifiy: function (...args) { console.warn('sensor.getAngleModifiy 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.businessErrorMoc, paramMock.paramArrayMock); + args[len - 1].call(this, paramMock.businessErrorMoc, paramMock.paramArrayMock); } else { - return new Promise((resolve, reject) => { - resolve(paramMock.paramArrayMock); - }); - } - }, + return new Promise((resolve, reject) => { + resolve(paramMock.paramArrayMock); + }); + } + }, createRotationMatrix: function (...args) { console.warn('sensor.createRotationMatrix 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.businessErrorMoc, paramMock.paramArrayMock); + args[len - 1].call(this, paramMock.businessErrorMoc, paramMock.paramArrayMock); } else { - return new Promise((resolve, reject) => { - resolve(paramMock.paramArrayMock); - }); - } - }, + return new Promise((resolve, reject) => { + resolve(paramMock.paramArrayMock); + }); + } + }, transformCoordinateSystem: function (...args) { console.warn('sensor.transformCoordinateSystem 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.businessErrorMoc, paramMock.paramArrayMock); + args[len - 1].call(this, paramMock.businessErrorMoc, paramMock.paramArrayMock); } else { - return new Promise((resolve, reject) => { - resolve(paramMock.paramArrayMock); - }); - } - }, - createQuaternion: function (...args) { + return new Promise((resolve, reject) => { + resolve(paramMock.paramArrayMock); + }); + } + }, + createQuaternion: function (...args) { console.warn('sensor.createQuaternion 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.businessErrorMoc, paramMock.paramArrayMock); + args[len - 1].call(this, paramMock.businessErrorMoc, paramMock.paramArrayMock); } else { - return new Promise((resolve, reject) => { - resolve(paramMock.paramArrayMock); - }); - } - }, + return new Promise((resolve, reject) => { + resolve(paramMock.paramArrayMock); + }); + } + }, getDirection: function (...args) { console.warn('sensor.getDirection 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.businessErrorMoc, paramMock.paramArrayMock); + args[len - 1].call(this, paramMock.businessErrorMoc, paramMock.paramArrayMock); } else { - return new Promise((resolve, reject) => { - resolve(paramMock.paramArrayMock); - }); - } - }, + return new Promise((resolve, reject) => { + resolve(paramMock.paramArrayMock); + }); + } + }, getSingleSensor: function (...args) { console.warn('sensor.getSingleSensor 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.businessErrorMoc, paramMock.Sensor); + args[len - 1].call(this, paramMock.businessErrorMoc, paramMock.Sensor); } else { - return new Promise((resolve, reject) => { - resolve(paramMock.Sensor); - }); - } - }, + return new Promise((resolve, reject) => { + resolve(paramMock.Sensor); + }); + } + }, getSensorLists: function (...args) { console.warn('sensor.getSensorLists 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.businessErrorMoc, paramMock.paramArrayMock); + args[len - 1].call(this, paramMock.businessErrorMoc, paramMock.paramArrayMock); } else { - return new Promise((resolve, reject) => { - resolve(paramMock.paramArrayMock); - }); + return new Promise((resolve, reject) => { + resolve(paramMock.paramArrayMock); + }); + } + }, } - }, - } return sensor } \ No newline at end of file From 30177a536915fee0abe201ef53a4e792d288f305 Mon Sep 17 00:00:00 2001 From: li-yaoyao777 Date: Fri, 17 Jun 2022 17:04:52 +0800 Subject: [PATCH 010/109] ohos_sensor.js Signed-off-by: li-yaoyao777 --- .../extend/systemplugin/napi/ohos_sensor.js | 334 +++++++++--------- 1 file changed, 167 insertions(+), 167 deletions(-) diff --git a/runtime/main/extend/systemplugin/napi/ohos_sensor.js b/runtime/main/extend/systemplugin/napi/ohos_sensor.js index d7d4cbd0..993b2eec 100644 --- a/runtime/main/extend/systemplugin/napi/ohos_sensor.js +++ b/runtime/main/extend/systemplugin/napi/ohos_sensor.js @@ -20,7 +20,7 @@ export function mockSensor() { x: '[PC preview] unknown x', y: '[PC preview] unknown y', z: '[PC preview] unknown z' - } + } const LinearAccelerometerResponse = { x: '[PC preview] unknown x', y: '[PC preview] unknown y', @@ -210,181 +210,181 @@ export function mockSensor() { } else if (args[0] == 281) { callback.call(this, paramMock.businessErrorMock, AccelerometerUncalibratedResponse); } - }, - once: function (...args) { - console.warn('sensor.once interface mocked in the Previewer. How this interface works on the' - + 'Previewer may be different from that on a real device.') + }, + once: function (...args) { + console.warn('sensor.once interface mocked in the Previewer. How this interface works on the' + + 'Previewer may be different from that on a real device.') + const len = args.length + if (args[0] == 1) { + args[len - 1].call(this, paramMock.businessErrorMock, AccelerometerResponse); + } else if (args[0] == 2) { + args[len - 1].call(this, paramMock.businessErrorMock, GyroscopeResponse); + } else if (args[0] == 5) { + args[len - 1].call(this, paramMock.businessErrorMock, LightResponse); + } else if (args[0] == 6) { + args[len - 1].call(this, paramMock.businessErrorMock, MagneticFieldResponse); + } else if (args[0] == 8) { + args[len - 1].call(this, paramMock.businessErrorMock, BarometerResponse); + } else if (args[0] == 10) { + args[len - 1].call(this, paramMock.businessErrorMock, HallResponse); + } else if (args[0] == 12) { + args[len - 1].call(this, paramMock.businessErrorMock, ProximityResponse); + } else if (args[0] == 13) { + args[len - 1].call(this, paramMock.businessErrorMock, HumidityResponse); + } else if (args[0] == 256) { + args[len - 1].call(this, paramMock.businessErrorMock, OrientationResponse); + } else if (args[0] == 257) { + args[len - 1].call(this, paramMock.businessErrorMock, GravityResponse); + } else if (args[0] == 258) { + args[len - 1].call(this, paramMock.businessErrorMock, LinearAccelerometerResponse); + } else if (args[0] == 259) { + args[len - 1].call(this, paramMock.businessErrorMock, RotationVectorResponse); + } else if (args[0] == 260) { + args[len - 1].call(this, paramMock.businessErrorMock, AmbientTemperatureResponse); + } else if (args[0] == 261) { + args[len - 1].call(this, paramMock.businessErrorMock, MagneticFieldUncalibratedResponse); + } else if (args[0] == 263) { + args[len - 1].call(this, paramMock.businessErrorMock, GyroscopeUncalibratedResponse); + } else if (args[0] == 264) { + args[len - 1].call(this, paramMock.businessErrorMock, SignificantMotionResponse); + } else if (args[0] == 265) { + args[len - 1].call(this, paramMock.businessErrorMock, PedometerDetectResponse); + } else if (args[0] == 266) { + args[len - 1].call(this, paramMock.businessErrorMock, PedometerResponse); + } else if (args[0] == 278) { + args[len - 1].call(this, paramMock.businessErrorMock, HeartRateResponse); + } else if (args[0] == 280) { + args[len - 1].call(this, paramMock.businessErrorMock, WearDetectionResponse); + } else if (args[0] == 281) { + args[len - 1].call(this, paramMock.businessErrorMock, AccelerometerUncalibratedResponse); + } + }, + off: function (...args) { + console.warn('sensor.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] == 1) { - args[len - 1].call(this, paramMock.businessErrorMock, AccelerometerResponse); - } else if (args[0] == 2) { - args[len - 1].call(this, paramMock.businessErrorMock, GyroscopeResponse); - } else if (args[0] == 5) { - args[len - 1].call(this, paramMock.businessErrorMock, LightResponse); - } else if (args[0] == 6) { - args[len - 1].call(this, paramMock.businessErrorMock, MagneticFieldResponse); - } else if (args[0] == 8) { - args[len - 1].call(this, paramMock.businessErrorMock, BarometerResponse); - } else if (args[0] == 10) { - args[len - 1].call(this, paramMock.businessErrorMock, HallResponse); - } else if (args[0] == 12) { - args[len - 1].call(this, paramMock.businessErrorMock, ProximityResponse); - } else if (args[0] == 13) { - args[len - 1].call(this, paramMock.businessErrorMock, HumidityResponse); - } else if (args[0] == 256) { - args[len - 1].call(this, paramMock.businessErrorMock, OrientationResponse); - } else if (args[0] == 257) { - args[len - 1].call(this, paramMock.businessErrorMock, GravityResponse); - } else if (args[0] == 258) { - args[len - 1].call(this, paramMock.businessErrorMock, LinearAccelerometerResponse); - } else if (args[0] == 259) { - args[len - 1].call(this, paramMock.businessErrorMock, RotationVectorResponse); - } else if (args[0] == 260) { - args[len - 1].call(this, paramMock.businessErrorMock, AmbientTemperatureResponse); - } else if (args[0] == 261) { - args[len - 1].call(this, paramMock.businessErrorMock, MagneticFieldUncalibratedResponse); - } else if (args[0] == 263) { - args[len - 1].call(this, paramMock.businessErrorMock, GyroscopeUncalibratedResponse); - } else if (args[0] == 264) { - args[len - 1].call(this, paramMock.businessErrorMock, SignificantMotionResponse); - } else if (args[0] == 265) { - args[len - 1].call(this, paramMock.businessErrorMock, PedometerDetectResponse); - } else if (args[0] == 266) { - args[len - 1].call(this, paramMock.businessErrorMock, PedometerResponse); - } else if (args[0] == 278) { - args[len - 1].call(this, paramMock.businessErrorMock, HeartRateResponse); - } else if (args[0] == 280) { - args[len - 1].call(this, paramMock.businessErrorMock, WearDetectionResponse); - } else if (args[0] == 281) { - args[len - 1].call(this, paramMock.businessErrorMock, AccelerometerUncalibratedResponse); - } + args[len - 1].call(this, paramMock.businessErrorMock); }, - off: function (...args) { - console.warn('sensor.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); - }, - getGeomagneticField: function (...args) { - console.warn('sensor.getGeomagneticField interface mocked in the Previewer. How this interface works on the' - + 'Previewer may be different from that on a real device.') - const len = args.length - if (typeof args[len - 1] === 'function') { - args[len - 1].call(this, paramMock.businessErrorMoc, GeomagneticResponse); - } else { - return new Promise((resolve, reject) => { - resolve(GeomagneticResponse); - }); - } - }, - getAltitude: function (...args) { - console.warn('sensor.getAltitude interface mocked in the Previewer. How this interface works on the' - + 'Previewer may be different from that on a real device.') - const len = args.length - if (typeof args[len - 1] === 'function') { - args[len - 1].call(this, paramMock.businessErrorMoc, paramMock.paramNumberMock); - } else { - return new Promise((resolve, reject) => { - resolve(paramMock.paramNumberMock); - }); - } - }, - getGeomagneticDip: function (...args) { - console.warn('sensor.getGeomagneticDip interface mocked in the Previewer. How this interface works on the' - + 'Previewer may be different from that on a real device.') - const len = args.length - if (typeof args[len - 1] === 'function') { - args[len - 1].call(this, paramMock.businessErrorMoc, paramMock.paramNumberMock); - } else { - return new Promise((resolve, reject) => { - resolve(paramMock.paramNumberMock); - }); - } - }, - getAngleModifiy: function (...args) { - console.warn('sensor.getAngleModifiy interface mocked in the Previewer. How this interface works on the' - + 'Previewer may be different from that on a real device.') - const len = args.length - if (typeof args[len - 1] === 'function') { - args[len - 1].call(this, paramMock.businessErrorMoc, paramMock.paramArrayMock); - } else { - return new Promise((resolve, reject) => { - resolve(paramMock.paramArrayMock); - }); - } - }, - createRotationMatrix: function (...args) { - console.warn('sensor.createRotationMatrix interface mocked in the Previewer. How this interface works on the' - + 'Previewer may be different from that on a real device.') - const len = args.length - if (typeof args[len - 1] === 'function') { - args[len - 1].call(this, paramMock.businessErrorMoc, paramMock.paramArrayMock); - } else { - return new Promise((resolve, reject) => { - resolve(paramMock.paramArrayMock); - }); - } - }, - transformCoordinateSystem: function (...args) { - console.warn('sensor.transformCoordinateSystem interface mocked in the Previewer. How this interface works on the' - + 'Previewer may be different from that on a real device.') - const len = args.length - if (typeof args[len - 1] === 'function') { - args[len - 1].call(this, paramMock.businessErrorMoc, paramMock.paramArrayMock); - } else { - return new Promise((resolve, reject) => { - resolve(paramMock.paramArrayMock); + getGeomagneticField: function (...args) { + console.warn('sensor.getGeomagneticField interface mocked in the Previewer. How this interface works on the' + + 'Previewer may be different from that on a real device.') + const len = args.length + if (typeof args[len - 1] === 'function') { + args[len - 1].call(this, paramMock.businessErrorMoc, GeomagneticResponse); + } else { + return new Promise((resolve, reject) => { + resolve(GeomagneticResponse); }); } }, - createQuaternion: function (...args) { - console.warn('sensor.createQuaternion interface mocked in the Previewer. How this interface works on the' + getAltitude: function (...args) { + console.warn('sensor.getAltitude interface mocked in the Previewer. How this interface works on the' + + 'Previewer may be different from that on a real device.') + const len = args.length + if (typeof args[len - 1] === 'function') { + args[len - 1].call(this, paramMock.businessErrorMoc, paramMock.paramNumberMock); + } else { + return new Promise((resolve, reject) => { + resolve(paramMock.paramNumberMock); + }); + } + }, + getGeomagneticDip: function (...args) { + console.warn('sensor.getGeomagneticDip interface mocked in the Previewer. How this interface works on the' + + 'Previewer may be different from that on a real device.') + const len = args.length + if (typeof args[len - 1] === 'function') { + args[len - 1].call(this, paramMock.businessErrorMoc, paramMock.paramNumberMock); + } else { + return new Promise((resolve, reject) => { + resolve(paramMock.paramNumberMock); + }); + } + }, + getAngleModifiy: function (...args) { + console.warn('sensor.getAngleModifiy interface mocked in the Previewer. How this interface works on the' + 'Previewer may be different from that on a real device.') - const len = args.length - if (typeof args[len - 1] === 'function') { - args[len - 1].call(this, paramMock.businessErrorMoc, paramMock.paramArrayMock); - } else { - return new Promise((resolve, reject) => { - resolve(paramMock.paramArrayMock); + const len = args.length + if (typeof args[len - 1] === 'function') { + args[len - 1].call(this, paramMock.businessErrorMoc, paramMock.paramArrayMock); + } else { + return new Promise((resolve, reject) => { + resolve(paramMock.paramArrayMock); }); } }, - getDirection: function (...args) { - console.warn('sensor.getDirection interface mocked in the Previewer. How this interface works on the' - + 'Previewer may be different from that on a real device.') - const len = args.length - if (typeof args[len - 1] === 'function') { - args[len - 1].call(this, paramMock.businessErrorMoc, paramMock.paramArrayMock); - } else { - return new Promise((resolve, reject) => { - resolve(paramMock.paramArrayMock); - }); + createRotationMatrix: function (...args) { + console.warn('sensor.createRotationMatrix interface mocked in the Previewer. How this interface works on the' + + 'Previewer may be different from that on a real device.') + const len = args.length + if (typeof args[len - 1] === 'function') { + args[len - 1].call(this, paramMock.businessErrorMoc, paramMock.paramArrayMock); + } else { + return new Promise((resolve, reject) => { + resolve(paramMock.paramArrayMock); + }); + } + }, + transformCoordinateSystem: function (...args) { + console.warn('sensor.transformCoordinateSystem interface mocked in the Previewer. How this interface works on the' + + 'Previewer may be different from that on a real device.') + const len = args.length + if (typeof args[len - 1] === 'function') { + args[len - 1].call(this, paramMock.businessErrorMoc, paramMock.paramArrayMock); + } else { + return new Promise((resolve, reject) => { + resolve(paramMock.paramArrayMock); + }); + } + }, + createQuaternion: function (...args) { + console.warn('sensor.createQuaternion interface mocked in the Previewer. How this interface works on the' + + 'Previewer may be different from that on a real device.') + const len = args.length + if (typeof args[len - 1] === 'function') { + args[len - 1].call(this, paramMock.businessErrorMoc, paramMock.paramArrayMock); + } else { + return new Promise((resolve, reject) => { + resolve(paramMock.paramArrayMock); + }); + } + }, + getDirection: function (...args) { + console.warn('sensor.getDirection interface mocked in the Previewer. How this interface works on the' + + 'Previewer may be different from that on a real device.') + const len = args.length + if (typeof args[len - 1] === 'function') { + args[len - 1].call(this, paramMock.businessErrorMoc, paramMock.paramArrayMock); + } else { + return new Promise((resolve, reject) => { + resolve(paramMock.paramArrayMock); + }); + } + }, + getSingleSensor: function (...args) { + console.warn('sensor.getSingleSensor interface mocked in the Previewer. How this interface works on the' + + 'Previewer may be different from that on a real device.') + const len = args.length + if (typeof args[len - 1] === 'function') { + args[len - 1].call(this, paramMock.businessErrorMoc, paramMock.Sensor); + } else { + return new Promise((resolve, reject) => { + resolve(paramMock.Sensor); + }); + } + }, + getSensorLists: function (...args) { + console.warn('sensor.getSensorLists interface mocked in the Previewer. How this interface works on the' + + 'Previewer may be different from that on a real device.') + const len = args.length + if (typeof args[len - 1] === 'function') { + args[len - 1].call(this, paramMock.businessErrorMoc, paramMock.paramArrayMock); + } else { + return new Promise((resolve, reject) => { + resolve(paramMock.paramArrayMock); + }); + } } - }, - getSingleSensor: function (...args) { - console.warn('sensor.getSingleSensor interface mocked in the Previewer. How this interface works on the' - + 'Previewer may be different from that on a real device.') - const len = args.length - if (typeof args[len - 1] === 'function') { - args[len - 1].call(this, paramMock.businessErrorMoc, paramMock.Sensor); - } else { - return new Promise((resolve, reject) => { - resolve(paramMock.Sensor); - }); - } - }, - getSensorLists: function (...args) { - console.warn('sensor.getSensorLists interface mocked in the Previewer. How this interface works on the' - + 'Previewer may be different from that on a real device.') - const len = args.length - if (typeof args[len - 1] === 'function') { - args[len - 1].call(this, paramMock.businessErrorMoc, paramMock.paramArrayMock); - } else { - return new Promise((resolve, reject) => { - resolve(paramMock.paramArrayMock); - }); - } - }, - } + }; return sensor } \ No newline at end of file From 45bfa90abfe7e691fa71073b95ff0d7b1638572d Mon Sep 17 00:00:00 2001 From: li-yaoyao777 Date: Fri, 17 Jun 2022 17:12:38 +0800 Subject: [PATCH 011/109] ohos_sensor.js Signed-off-by: li-yaoyao777 --- .../extend/systemplugin/napi/ohos_sensor.js | 28 +++++++++---------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/runtime/main/extend/systemplugin/napi/ohos_sensor.js b/runtime/main/extend/systemplugin/napi/ohos_sensor.js index 993b2eec..590a378b 100644 --- a/runtime/main/extend/systemplugin/napi/ohos_sensor.js +++ b/runtime/main/extend/systemplugin/napi/ohos_sensor.js @@ -128,7 +128,7 @@ export function mockSensor() { x: '[PC preview] unknown x', y: '[PC preview] unknown y' } - const Sensor = { + const Sensor = { sensorName: '[PC preview] unknown sensorName', venderName: '[PC preview] unknown venderName', firmwareVersion: '[PC preview] unknown firmwareVersion', @@ -210,7 +210,7 @@ export function mockSensor() { } else if (args[0] == 281) { callback.call(this, paramMock.businessErrorMock, AccelerometerUncalibratedResponse); } - }, + }, once: function (...args) { console.warn('sensor.once interface mocked in the Previewer. How this interface works on the' + 'Previewer may be different from that on a real device.') @@ -258,13 +258,13 @@ export function mockSensor() { } else if (args[0] == 281) { args[len - 1].call(this, paramMock.businessErrorMock, AccelerometerUncalibratedResponse); } - }, + }, off: function (...args) { console.warn('sensor.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); - }, + }, getGeomagneticField: function (...args) { console.warn('sensor.getGeomagneticField interface mocked in the Previewer. How this interface works on the' + 'Previewer may be different from that on a real device.') @@ -276,7 +276,7 @@ export function mockSensor() { resolve(GeomagneticResponse); }); } - }, + }, getAltitude: function (...args) { console.warn('sensor.getAltitude interface mocked in the Previewer. How this interface works on the' + 'Previewer may be different from that on a real device.') @@ -288,7 +288,7 @@ export function mockSensor() { resolve(paramMock.paramNumberMock); }); } - }, + }, getGeomagneticDip: function (...args) { console.warn('sensor.getGeomagneticDip interface mocked in the Previewer. How this interface works on the' + 'Previewer may be different from that on a real device.') @@ -300,7 +300,7 @@ export function mockSensor() { resolve(paramMock.paramNumberMock); }); } - }, + }, getAngleModifiy: function (...args) { console.warn('sensor.getAngleModifiy interface mocked in the Previewer. How this interface works on the' + 'Previewer may be different from that on a real device.') @@ -312,7 +312,7 @@ export function mockSensor() { resolve(paramMock.paramArrayMock); }); } - }, + }, createRotationMatrix: function (...args) { console.warn('sensor.createRotationMatrix interface mocked in the Previewer. How this interface works on the' + 'Previewer may be different from that on a real device.') @@ -324,7 +324,7 @@ export function mockSensor() { resolve(paramMock.paramArrayMock); }); } - }, + }, transformCoordinateSystem: function (...args) { console.warn('sensor.transformCoordinateSystem interface mocked in the Previewer. How this interface works on the' + 'Previewer may be different from that on a real device.') @@ -336,7 +336,7 @@ export function mockSensor() { resolve(paramMock.paramArrayMock); }); } - }, + }, createQuaternion: function (...args) { console.warn('sensor.createQuaternion interface mocked in the Previewer. How this interface works on the' + 'Previewer may be different from that on a real device.') @@ -348,7 +348,7 @@ export function mockSensor() { resolve(paramMock.paramArrayMock); }); } - }, + }, getDirection: function (...args) { console.warn('sensor.getDirection interface mocked in the Previewer. How this interface works on the' + 'Previewer may be different from that on a real device.') @@ -360,7 +360,7 @@ export function mockSensor() { resolve(paramMock.paramArrayMock); }); } - }, + }, getSingleSensor: function (...args) { console.warn('sensor.getSingleSensor interface mocked in the Previewer. How this interface works on the' + 'Previewer may be different from that on a real device.') @@ -372,7 +372,7 @@ export function mockSensor() { resolve(paramMock.Sensor); }); } - }, + }, getSensorLists: function (...args) { console.warn('sensor.getSensorLists interface mocked in the Previewer. How this interface works on the' + 'Previewer may be different from that on a real device.') @@ -384,7 +384,7 @@ export function mockSensor() { resolve(paramMock.paramArrayMock); }); } - } + } }; return sensor } \ No newline at end of file From 459cdb5d7257c0a5375257df24dec2f9c2e4b1c8 Mon Sep 17 00:00:00 2001 From: li-yaoyao777 Date: Fri, 17 Jun 2022 17:17:44 +0800 Subject: [PATCH 012/109] ohos_sensor.js Signed-off-by: li-yaoyao777 --- .../extend/systemplugin/napi/ohos_sensor.js | 36 +++++++++---------- 1 file changed, 18 insertions(+), 18 deletions(-) diff --git a/runtime/main/extend/systemplugin/napi/ohos_sensor.js b/runtime/main/extend/systemplugin/napi/ohos_sensor.js index 590a378b..68e2dcc9 100644 --- a/runtime/main/extend/systemplugin/napi/ohos_sensor.js +++ b/runtime/main/extend/systemplugin/napi/ohos_sensor.js @@ -273,8 +273,8 @@ export function mockSensor() { args[len - 1].call(this, paramMock.businessErrorMoc, GeomagneticResponse); } else { return new Promise((resolve, reject) => { - resolve(GeomagneticResponse); - }); + resolve(GeomagneticResponse); + }); } }, getAltitude: function (...args) { @@ -285,8 +285,8 @@ export function mockSensor() { args[len - 1].call(this, paramMock.businessErrorMoc, paramMock.paramNumberMock); } else { return new Promise((resolve, reject) => { - resolve(paramMock.paramNumberMock); - }); + resolve(paramMock.paramNumberMock); + }); } }, getGeomagneticDip: function (...args) { @@ -297,8 +297,8 @@ export function mockSensor() { args[len - 1].call(this, paramMock.businessErrorMoc, paramMock.paramNumberMock); } else { return new Promise((resolve, reject) => { - resolve(paramMock.paramNumberMock); - }); + resolve(paramMock.paramNumberMock); + }); } }, getAngleModifiy: function (...args) { @@ -309,8 +309,8 @@ export function mockSensor() { args[len - 1].call(this, paramMock.businessErrorMoc, paramMock.paramArrayMock); } else { return new Promise((resolve, reject) => { - resolve(paramMock.paramArrayMock); - }); + resolve(paramMock.paramArrayMock); + }); } }, createRotationMatrix: function (...args) { @@ -321,8 +321,8 @@ export function mockSensor() { args[len - 1].call(this, paramMock.businessErrorMoc, paramMock.paramArrayMock); } else { return new Promise((resolve, reject) => { - resolve(paramMock.paramArrayMock); - }); + resolve(paramMock.paramArrayMock); + }); } }, transformCoordinateSystem: function (...args) { @@ -332,9 +332,9 @@ export function mockSensor() { if (typeof args[len - 1] === 'function') { args[len - 1].call(this, paramMock.businessErrorMoc, paramMock.paramArrayMock); } else { - return new Promise((resolve, reject) => { + return new Promise((resolve, reject) => { resolve(paramMock.paramArrayMock); - }); + }); } }, createQuaternion: function (...args) { @@ -345,8 +345,8 @@ export function mockSensor() { args[len - 1].call(this, paramMock.businessErrorMoc, paramMock.paramArrayMock); } else { return new Promise((resolve, reject) => { - resolve(paramMock.paramArrayMock); - }); + resolve(paramMock.paramArrayMock); + }); } }, getDirection: function (...args) { @@ -357,8 +357,8 @@ export function mockSensor() { args[len - 1].call(this, paramMock.businessErrorMoc, paramMock.paramArrayMock); } else { return new Promise((resolve, reject) => { - resolve(paramMock.paramArrayMock); - }); + resolve(paramMock.paramArrayMock); + }); } }, getSingleSensor: function (...args) { @@ -370,7 +370,7 @@ export function mockSensor() { } else { return new Promise((resolve, reject) => { resolve(paramMock.Sensor); - }); + }); } }, getSensorLists: function (...args) { @@ -382,7 +382,7 @@ export function mockSensor() { } else { return new Promise((resolve, reject) => { resolve(paramMock.paramArrayMock); - }); + }); } } }; From 22dccd01bc704ffd6ef89ff293b3ee8025b1adc3 Mon Sep 17 00:00:00 2001 From: li-yaoyao777 Date: Tue, 21 Jun 2022 20:25:20 +0800 Subject: [PATCH 013/109] ohos_sensor.js Signed-off-by: li-yaoyao777 --- runtime/main/extend/systemplugin/napi/ohos_sensor.js | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/runtime/main/extend/systemplugin/napi/ohos_sensor.js b/runtime/main/extend/systemplugin/napi/ohos_sensor.js index 68e2dcc9..a493b3a3 100644 --- a/runtime/main/extend/systemplugin/napi/ohos_sensor.js +++ b/runtime/main/extend/systemplugin/napi/ohos_sensor.js @@ -162,6 +162,7 @@ export function mockSensor() { SENSOR_TYPE_ID_ACCELEROMETER_UNCALIBRATED: 281 } const sensor = { + Sensor, on: function (...args) { console.warn('sensor.on interface mocked in the Previewer. How this interface works on the' + 'Previewer may be different from that on a real device.') @@ -366,10 +367,10 @@ export function mockSensor() { + 'Previewer may be different from that on a real device.') const len = args.length if (typeof args[len - 1] === 'function') { - args[len - 1].call(this, paramMock.businessErrorMoc, paramMock.Sensor); + args[len - 1].call(this, paramMock.businessErrorMoc, Sensor); } else { return new Promise((resolve, reject) => { - resolve(paramMock.Sensor); + resolve(Sensor); }); } }, @@ -378,10 +379,10 @@ export function mockSensor() { + 'Previewer may be different from that on a real device.') const len = args.length if (typeof args[len - 1] === 'function') { - args[len - 1].call(this, paramMock.businessErrorMoc, paramMock.paramArrayMock); + args[len - 1].call(this, paramMock.businessErrorMoc, Array(Sensor)); } else { return new Promise((resolve, reject) => { - resolve(paramMock.paramArrayMock); + resolve(Array(Sensor)); }); } } From a687d6db3b5ae9b37d17c633badc83420b4ef6f9 Mon Sep 17 00:00:00 2001 From: ql Date: Thu, 30 Jun 2022 15:58:31 +0800 Subject: [PATCH 014/109] Add distributedMissionManager mock Signed-off-by: ql Change-Id: Icf4503ff1f061d50c2dec1f253ea40db7bcc1815 --- .../main/extend/systemplugin/napi/index.js | 3 + .../napi/ohos_distributedMissionManager.js | 70 +++++++++++++++++++ 2 files changed, 73 insertions(+) create mode 100755 runtime/main/extend/systemplugin/napi/ohos_distributedMissionManager.js diff --git a/runtime/main/extend/systemplugin/napi/index.js b/runtime/main/extend/systemplugin/napi/index.js index 92e0645c..18b03bc6 100644 --- a/runtime/main/extend/systemplugin/napi/index.js +++ b/runtime/main/extend/systemplugin/napi/index.js @@ -111,6 +111,7 @@ import { mockContact } from './ohos_contact' import { mockDataStorage } from './ohos_data_Storage' import { mockDeviceInfo } from './ohos_deviceInfo' import { mockDeviceManager } from './ohos_distributedHardware_deviceManager' +import { mockDistributedMissionManager } from "./ohos_distributedMissionManager" import { mockDisplay } from './ohos_display' import { mockHuks } from './ohos_security_huks' import { mockInputMethod } from './ohos_inputmethod' @@ -234,6 +235,8 @@ export function mockRequireNapiFun() { return mockDisplay(); case "distributedHardware.deviceManager": return mockDeviceManager(); + case "distributedMissionManager": + return mockDistributedMissionManager(); case "deviceInfo": return mockDeviceInfo(); case "data.storage": diff --git a/runtime/main/extend/systemplugin/napi/ohos_distributedMissionManager.js b/runtime/main/extend/systemplugin/napi/ohos_distributedMissionManager.js new file mode 100755 index 00000000..cbfa39f5 --- /dev/null +++ b/runtime/main/extend/systemplugin/napi/ohos_distributedMissionManager.js @@ -0,0 +1,70 @@ +/* + * Copyright (c) 2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { paramMock } from "../utils" + +export function mockDistributedMissionManager() { + const distributedMissionManager = { + startSyncRemoteMissions: function (...args) { + console.warn('distributedMissionManager.startSyncRemoteMission interface mocked in the Previewer. How this interface works on the' + + ' Previewer may be different from that on a 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(); + }); + } + }, + stopSyncRemoteMissions: function (...args) { + console.warn('distributedMissionManager.stopSyncRemoteMission interface mocked in the Previewer. How this interface works on the' + + ' Previewer may be different from that on a 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(); + }); + } + }, + registerMissionListener: function (...args) { + console.warn('distributedMissionManager.registerMissionListener interface mocked in the Previewer. How this interface works on the' + + ' Previewer may be different from that on a 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(); + }); + } + }, + unRegisterMissionListener: function (...args) { + console.warn('distributedMissionManager.unRegisterMissionListener interface mocked in the Previewer. How this interface works on the' + + ' Previewer may be different from that on a real device.'); + const len = args.length; + if (typeof args[len - 1] === 'function') { + args[len - 1].call(this, paramMock.businessErrorMock); + } else { + return new Promise((resolve) => { + resolve(); + }); + } + } + } + return distributedMissionManager +} \ No newline at end of file From 33cefc4ed2cfef839b09c5eb8e47742ec70e13fc Mon Sep 17 00:00:00 2001 From: wangkai Date: Fri, 1 Jul 2022 12:01:42 +0800 Subject: [PATCH 015/109] change mock Signed-off-by: wangkai --- .../main/extend/systemplugin/napi/ohos_data_distributedData.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/runtime/main/extend/systemplugin/napi/ohos_data_distributedData.js b/runtime/main/extend/systemplugin/napi/ohos_data_distributedData.js index 0cf30c63..1e420cb4 100644 --- a/runtime/main/extend/systemplugin/napi/ohos_data_distributedData.js +++ b/runtime/main/extend/systemplugin/napi/ohos_data_distributedData.js @@ -264,7 +264,8 @@ export function mockDistributedData() { }; const kvManagerConfigMock = { userInfo: "[PC Preview] unknown userInfo", - bundleName: "[PC Preview] unknown bundleName" + bundleName: "[PC Preview] unknown bundleName", + context : "[PC Preview] unknown context" }; const constantsMock = { MAX_KEY_LENGTH: "[PC Preview] unknown MAX_KEY_LENGTH", From f2d3a090d3dcc62126da91dd2950ea7ef5056127 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=80=BF=E6=96=87=E5=B9=BF?= Date: Fri, 1 Jul 2022 15:22:57 +0800 Subject: [PATCH 016/109] =?UTF-8?q?=E6=95=B4=E6=94=B9bundle.d.ts=E6=8E=A5?= =?UTF-8?q?=E5=8F=A3api-mock=E8=A7=84=E8=8C=83,=E5=88=A0=E9=99=A4=E5=B7=B2?= =?UTF-8?q?=E5=88=A0=E9=99=A4=E6=8E=A5=E5=8F=A3api-mock?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 耿文广 --- .../napi/bundle/applicationInfo.js | 70 ++++++++++---- .../extend/systemplugin/napi/ohos_bundle.js | 94 ++++++------------- .../napi/ohos_bundle_innerBundleManager.js | 4 +- 3 files changed, 83 insertions(+), 85 deletions(-) diff --git a/runtime/main/extend/systemplugin/napi/bundle/applicationInfo.js b/runtime/main/extend/systemplugin/napi/bundle/applicationInfo.js index 05b117fd..52ad36e7 100644 --- a/runtime/main/extend/systemplugin/napi/bundle/applicationInfo.js +++ b/runtime/main/extend/systemplugin/napi/bundle/applicationInfo.js @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021 Huawei Device Co., Ltd. + * Copyright (c) 2021-2022 Huawei Device Co., Ltd. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at @@ -14,22 +14,59 @@ */ export const ApplicationInfoMock = { - packageName: "[PC preview] unknown packageName", - className: "[PC preview] unknown className", name: "[PC preview] unknown name", - labelId: 1, - iconId: 2, - sourceDir: "[PC preview] unknown sourceDir", - flags: 3, - customizeData: { - key: "[PC preview] unknown key", - value: { - CustomizeData: { - name: "[PC preview] unknown name", - value: "[PC preview] unknown value", - } + description: "[PC preview] unknown description", + descriptionId: "[PC preview] unknown descriptionId", + systemApp: "[PC preview] unknown systemApp", + enabled: "[PC preview] unknown enabled", + label: "[PC preview] unknown label", + labelId: "[PC preview] unknown labelId", + icon: "[PC preview] unknown icon", + iconId: "[PC preview] unknown iconId", + process: "[PC preview] unknown process", + supportedModes: "[PC preview] unknown supportedModes", + moduleSourceDirs: ["[PC preview] unknown moduleSourceDirs"], + permissions: ["[PC preview] unknown permissions"], + moduleInfos: [ + { + moduleName: "[PC preview] unknown moduleName", + moduleSourceDir: "[PC preview] unknown moduleSourceDir", } - } + ], + entryDir: "[PC preview] unknown entryDir", + codePath: "[PC preview] unknown codePath", + metaData: [{ + name: "[PC preview] unknown name", + value: "[PC preview] unknown value", + extra: "[PC preview] unknown extra", + }], + metadata: [{ + name: "[PC preview] unknown name", + value: "[PC preview] unknown value", + resource: "[PC preview] unknown resource", + }], + removable: "[PC preview] unknown removable", + accessTokenId: "[PC preview] unknown accessTokenId", + uid: "[PC preview] unknown uid", + entityType: "[PC preview] unknown entityType", + fingerprint: "[PC preview] unknown fingerprint", + iconResource: { + bundleName: "[PC preview] unknown bundleName", + moduleName: "[PC preview] unknown moduleName", + id: "[PC preview] unknown id" + }, + labelResource: { + bundleName: "[PC preview] unknown bundleName", + moduleName: "[PC preview] unknown moduleName", + id: "[PC preview] unknown id" + }, + descriptionResource: { + bundleName: "[PC preview] unknown bundleName", + moduleName: "[PC preview] unknown moduleName", + id: "[PC preview] unknown id" + }, + appDistributionType: "[PC preview] unknown appDistributionType", + appProvisionType: "[PC preview] unknown appProvisionType", } export const WantMock = { @@ -41,7 +78,8 @@ export const WantMock = { flag: "[PC Preview] unknow flag", action: "[PC Preview] unknow action", parameters: "[PC Preview] unknow parameters", - entities: "[PC Preview] unknow entities" + entities: "[PC Preview] unknow entities", + moduleName: "[PC Preview] unknow moduleName" } export const ShortcutInfoMock = { diff --git a/runtime/main/extend/systemplugin/napi/ohos_bundle.js b/runtime/main/extend/systemplugin/napi/ohos_bundle.js index 8a515d27..dede023e 100644 --- a/runtime/main/extend/systemplugin/napi/ohos_bundle.js +++ b/runtime/main/extend/systemplugin/napi/ohos_bundle.js @@ -14,13 +14,9 @@ */ import { paramMock } from "../utils" -import {resolve} from 'path/posix' import {BundleInfoMock, BundlePackInfo, DispatchInfoMock} from './bundle/bundleInfo' import {ApplicationInfoMock} from './bundle/applicationInfo' -import {AbilityInfoMock} from './bundle/abilityInfo' import {WantMock} from './bundle/applicationInfo' -import {ShortcutInfoMock} from './bundle/applicationInfo' -import {ModuleUsageRecordMock} from './bundle/applicationInfo' export function mockBundle() { const extensionAbilityType = { @@ -94,7 +90,7 @@ export function mockBundle() { const bundle = { getBundleInfo: function(...args) { console.warn("bundle.getBundleInfo 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, BundleInfoMock); @@ -106,7 +102,7 @@ export function mockBundle() { }, getBundleInstaller: function(...args) { console.warn("bundle.getBundleInstaller 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); @@ -118,7 +114,7 @@ export function mockBundle() { }, getApplicationInfo: function(...args) { console.warn("bundle.getApplicationInfo 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, ApplicationInfoMock); @@ -128,21 +124,9 @@ export function mockBundle() { }) } }, - checkPermission: function(...args) { - console.warn("bundle.checkPermission interface mocked in the Previewer. How this interface works on the" + - " Previewer may be different 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); - }) - } - }, queryAbilityByWant: function(...args) { console.warn("bundle.queryAbilityByWant 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, Array(BundleInfoMock)); @@ -154,7 +138,7 @@ export function mockBundle() { }, getAllApplicationInfo: function(...args){ console.warn("bundle.getAllApplicationInfo 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, Array(BundleInfoMock)); @@ -166,7 +150,7 @@ export function mockBundle() { }, getAllBundleInfo: function(...args) { console.warn("bundle.getAllBundleInfo 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, Array(ApplicationInfoMock)); @@ -178,7 +162,7 @@ export function mockBundle() { }, getBundleArchiveInfo: function(...args) { console.warn("bundle.getBundleArchiveInfo 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, Array(BundleInfoMock)); @@ -190,7 +174,7 @@ export function mockBundle() { }, getLaunchWantForBundle: function(...args) { console.warn("bundle.getBundleArchiveInfo 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, Array(WantMock)); @@ -200,33 +184,9 @@ export function mockBundle() { }) } }, - getAllShortcutInfo: function(...args) { - console.warn("bundle.getAllShortcutInfo interface mocked in the Previewer. How this interface works on the" + - " Previewer may be different from that on a real device.") - const len = args.length; - if (typeof args[len - 1] === 'function') { - args[len - 1].call(this, paramMock.businessErrorMock, Array(ShortcutInfoMock)); - } else { - return new Promise((resolve) => { - resolve(Array(ShortcutInfoMock)); - }) - } - }, - getModuleUsageRecords: function(...args) { - console.warn("bundle.getAllShortcutInfo interface mocked in the Previewer. How this interface works on the" + - " Previewer may be different from that on a real device.") - const len = args.length; - if (typeof args[len - 1] === 'function') { - args[len - 1].call(this, paramMock.businessErrorMock, Array(ModuleUsageRecordMock)); - } else { - return new Promise((resolve) => { - resolve(Array(ModuleUsageRecordMock)); - }) - } - }, cleanBundleCacheFiles: function(...args) { console.warn("bundle.cleanBundleCacheFiles 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); @@ -238,7 +198,7 @@ export function mockBundle() { }, setApplicationEnabled: function(...args) { console.warn("bundle.setApplicationEnabled 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); @@ -250,7 +210,7 @@ export function mockBundle() { }, setAbilityEnabled: function(...args) { console.warn("bundle.setAbilityEnabled 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); @@ -262,10 +222,10 @@ export function mockBundle() { }, setModuleUpgradeFlag: function (...args) { console.warn("bundle.setModuleUpgradeFlag 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) + args[len - 1].call(this, paramMock.businessErrorMock) } else { return new Promise((resolve) => { resolve() @@ -274,10 +234,10 @@ export function mockBundle() { }, isModuleRemovable: function (...args) { console.warn("bundle.isModuleRemovable interface mocked in the Previewer. How this interface works on the" + - " Previewer may be different from that on a real device.") + " Previewer may be different from that on a real device.") const len = args.length if (typeof args[len - 1] === 'function') { - args[len - 1].call(this, paramMock.businessErrorMock, paramMock.paramBooleanMock) + args[len - 1].call(this, paramMock.businessErrorMock, paramMock.paramBooleanMock) } else { return new Promise((resolve) => { resolve(paramMock.paramBooleanMock) @@ -286,10 +246,10 @@ export function mockBundle() { }, getProfileByAbility: function (...args) { console.warn("bundle.getProfileByAbility 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, new Array(paramMock.paramStringMock)) + args[len - 1].call(this, paramMock.businessErrorMock, new Array(paramMock.paramStringMock)) } else { return new Promise((resolve) => { resolve(new Array(paramMock.paramStringMock)) @@ -298,10 +258,10 @@ export function mockBundle() { }, getProfileByExtensionAbility: function (...args) { console.warn("bundle.getProfileByExtensionAbility 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, new Array(paramMock.paramStringMock)) + args[len - 1].call(this, paramMock.businessErrorMock, new Array(paramMock.paramStringMock)) } else { return new Promise((resolve) => { resolve(new Array(paramMock.paramStringMock)) @@ -310,10 +270,10 @@ export function mockBundle() { }, queryExtensionAbilityInfos: function (...args) { console.warn("bundle.queryExtensionAbilityInfos 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, Array(ExtensionAbilityInfoMock)) + args[len - 1].call(this,paramMock.businessErrorMock, Array(ExtensionAbilityInfoMock)) } else { return new Promise((resolve) => { resolve(Array(ExtensionAbilityInfoMock)) @@ -322,7 +282,7 @@ export function mockBundle() { }, getBundlePackInfo: function(...args) { console.warn("bundle.getBundlePackInfo 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, BundlePackInfo); @@ -334,7 +294,7 @@ export function mockBundle() { }, getDispatcherVersion: function(...args) { console.warn("bundle.getDispatcherVersion 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, DispatchInfoMock); @@ -346,10 +306,10 @@ export function mockBundle() { }, setDisposedStatus: function (...args) { console.warn("bundle.setDisposedStatus 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) + args[len - 1].call(this, paramMock.businessErrorMock) } else { return new Promise((resolve) => { resolve() @@ -358,10 +318,10 @@ export function mockBundle() { }, getDisposedStatus: function (...args) { console.warn("bundle.getDisposedStatus interface mocked in the Previewer. How this interface works on the" + - " Previewer may be different from that on a real device.") + " Previewer may be different from that on a real device.") const len = args.length if (typeof args[len - 1] === 'function') { - args[len - 1].call(this, paramMock.businessErrorMock, paramMock.paramNumberMock) + args[len - 1].call(this, paramMock.businessErrorMock, paramMock.paramNumberMock) } else { return new Promise((resolve) => { resolve(paramMock.paramNumberMock) diff --git a/runtime/main/extend/systemplugin/napi/ohos_bundle_innerBundleManager.js b/runtime/main/extend/systemplugin/napi/ohos_bundle_innerBundleManager.js index 72fe60d6..eb0d6dc3 100644 --- a/runtime/main/extend/systemplugin/napi/ohos_bundle_innerBundleManager.js +++ b/runtime/main/extend/systemplugin/napi/ohos_bundle_innerBundleManager.js @@ -14,8 +14,8 @@ */ import { paramMock } from "../utils" -import {resolve} from 'path/posix' -import {BundleInfoMock} from './bundle/bundleInfo' +import { resolve } from 'path/posix' +import { BundleInfoMock } from './bundle/bundleInfo' import {ApplicationInfoMock} from './bundle/applicationInfo' import {AbilityInfoMock} from './bundle/abilityInfo' import {WantMock} from './bundle/applicationInfo' From 8dd957d0a66d58ddda48230abb1c27b98444298b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=80=BF=E6=96=87=E5=B9=BF?= Date: Fri, 1 Jul 2022 15:26:29 +0800 Subject: [PATCH 017/109] =?UTF-8?q?=E6=95=B4=E6=94=B9bundle.d.ts=E6=8E=A5?= =?UTF-8?q?=E5=8F=A3api-mock=E8=A7=84=E8=8C=83,=E5=88=A0=E9=99=A4=E5=B7=B2?= =?UTF-8?q?=E5=88=A0=E9=99=A4=E6=8E=A5=E5=8F=A3api-mock?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 耿文广 --- runtime/main/extend/systemplugin/napi/ohos_bundle.js | 6 +++--- .../napi/ohos_bundle_innerBundleManager.js | 10 ++-------- 2 files changed, 5 insertions(+), 11 deletions(-) diff --git a/runtime/main/extend/systemplugin/napi/ohos_bundle.js b/runtime/main/extend/systemplugin/napi/ohos_bundle.js index dede023e..cba24dee 100644 --- a/runtime/main/extend/systemplugin/napi/ohos_bundle.js +++ b/runtime/main/extend/systemplugin/napi/ohos_bundle.js @@ -14,9 +14,9 @@ */ import { paramMock } from "../utils" -import {BundleInfoMock, BundlePackInfo, DispatchInfoMock} from './bundle/bundleInfo' -import {ApplicationInfoMock} from './bundle/applicationInfo' -import {WantMock} from './bundle/applicationInfo' +import { BundleInfoMock, BundlePackInfo, DispatchInfoMock } from './bundle/bundleInfo' +import { ApplicationInfoMock } from './bundle/applicationInfo' +import { WantMock } from './bundle/applicationInfo' export function mockBundle() { const extensionAbilityType = { diff --git a/runtime/main/extend/systemplugin/napi/ohos_bundle_innerBundleManager.js b/runtime/main/extend/systemplugin/napi/ohos_bundle_innerBundleManager.js index eb0d6dc3..8487432b 100644 --- a/runtime/main/extend/systemplugin/napi/ohos_bundle_innerBundleManager.js +++ b/runtime/main/extend/systemplugin/napi/ohos_bundle_innerBundleManager.js @@ -14,14 +14,8 @@ */ import { paramMock } from "../utils" -import { resolve } from 'path/posix' -import { BundleInfoMock } from './bundle/bundleInfo' -import {ApplicationInfoMock} from './bundle/applicationInfo' -import {AbilityInfoMock} from './bundle/abilityInfo' -import {WantMock} from './bundle/applicationInfo' -import {ShortcutInfoMock} from './bundle/applicationInfo' -import {ModuleUsageRecordMock} from './bundle/applicationInfo' -import {LauncherAbilityInfoMock} from './bundle/launcherAbilityInfo' +import { ShortcutInfoMock } from './bundle/applicationInfo' +import { LauncherAbilityInfoMock } from './bundle/launcherAbilityInfo' export function mockInnerBundle() { const innerBundleManager = { From 31000fc5889717f25621d14b3e6eada17f41083e Mon Sep 17 00:00:00 2001 From: jackd320 Date: Fri, 1 Jul 2022 10:23:21 +0000 Subject: [PATCH 018/109] Signed-off-by: jackd320 --- .../extend/systemplugin/napi/ohos_update.js | 442 +++++++++++++----- 1 file changed, 315 insertions(+), 127 deletions(-) diff --git a/runtime/main/extend/systemplugin/napi/ohos_update.js b/runtime/main/extend/systemplugin/napi/ohos_update.js index f3efb101..ce05f296 100644 --- a/runtime/main/extend/systemplugin/napi/ohos_update.js +++ b/runtime/main/extend/systemplugin/napi/ohos_update.js @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021 Huawei Device Co., Ltd. + * Copyright (c) 2021-2022 Huawei Device Co., Ltd. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at @@ -13,13 +13,25 @@ * limitations under the License. */ -import {paramMock} from "../utils" +import { paramMock } from "../utils" export function mockUpdate() { - const updater = { + const Updater = { checkNewVersion: function (...args) { console.warn("Updater.checkNewVersion interface mocked in the Previewer. How this interface works on the" + - " Previewer may be different from that on a real device.") + " Previewer may be different from that on a real device.") + const len = args.length + if (len > 0 && typeof args[len - 1] === 'function') { + args[len - 1].call(this, paramMock.businessErrorMock, CheckResult); + } else { + return new Promise((resolve, reject) => { + resolve(CheckResult); + }) + } + }, + getNewVersionInfo: function (...args) { + console.warn("Updater.getNewVersionInfo interface mocked in the Previewer. How this interface works" + + " on the Previewer may be different from that on a real device.") const len = args.length if (len > 0 && typeof args[len - 1] === 'function') { args[len - 1].call(this, paramMock.businessErrorMock, NewVersionInfo); @@ -29,41 +41,161 @@ export function mockUpdate() { }) } }, + getCurrentVersionInfo: function (...args) { + console.warn("Updater.getCurrentVersionInfo interface mocked in the Previewer. How this interface works" + + " on the Previewer may be different from that on a real device.") + const len = args.length + if (len > 0 && typeof args[len - 1] === 'function') { + args[len - 1].call(this, paramMock.businessErrorMock, CurrentVersionInfo); + } else { + return new Promise((resolve, reject) => { + resolve(CurrentVersionInfo); + }) + } + }, + getTaskInfo: function (...args) { + console.warn("Updater.getTaskInfo interface mocked in the Previewer. How this interface works on the" + + " Previewer may be different from that on a real device.") + const len = args.length + if (len > 0 && typeof args[len - 1] === 'function') { + args[len - 1].call(this, paramMock.businessErrorMock, TaskInfo); + } else { + return new Promise((resolve, reject) => { + resolve(TaskInfo); + }) + } + }, download: function (...args) { console.warn("Updater.download interface mocked in the Previewer. How this interface works on the" + - " Previewer may be different from that on a real device.") + " Previewer may be different from that on a real device.") + const len = args.length + if (len > 0 && typeof args[len - 1] === 'function') { + args[len - 1].call(this, paramMock.businessErrorMock); + } else { + return new Promise((resolve, reject) => { + resolve(); + }) + } + }, + resumeDownload: function (...args) { + console.warn("Updater.resumeDownload interface mocked in the Previewer. How this interface works on the" + + " Previewer may be different from 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(); + }) + } + }, + pauseDownload: function (...args) { + console.warn("Updater.pauseDownload interface mocked in the Previewer. How this interface works on the" + + " Previewer may be different from 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(); + }) + } }, upgrade: function (...args) { console.warn("Updater.upgrade interface mocked in the Previewer. How this interface works on the" + - " Previewer may be different from that on a real device.") - }, - getNewVersionInfo: function (...args) { - console.warn("Updater.getNewVersionInfo interface mocked in the Previewer. How this interface works on the" + - " Previewer may be different from that on a real device.") + " Previewer may be different from that on a real device.") const len = args.length if (len > 0 && typeof args[len - 1] === 'function') { - args[len - 1].call(this, paramMock.businessErrorMock, NewVersionInfo); + args[len - 1].call(this, paramMock.businessErrorMock); } else { return new Promise((resolve, reject) => { - resolve(NewVersionInfo); + resolve(); }) } }, - getUpdatePolicy: function (...args) { - console.warn("Updater.getUpdatePolicy interface mocked in the Previewer. How this interface works on the" + - " Previewer may be different from that on a real device.") + clearError: function (...args) { + console.warn("Updater.clearError interface mocked in the Previewer. How this interface works on the" + + " Previewer may be different from that on a real device.") const len = args.length if (len > 0 && typeof args[len - 1] === 'function') { - args[len - 1].call(this, paramMock.businessErrorMock, UpdatePolicy); + args[len - 1].call(this, paramMock.businessErrorMock); } else { return new Promise((resolve, reject) => { - resolve(UpdatePolicy); + resolve(); }) } }, - setUpdatePolicy: function (...args) { - console.warn("Updater.setUpdatePolicy interface mocked in the Previewer. How this interface works on the" + - " Previewer may be different from that on a real device.") + getUpgradePolicy: function (...args) { + console.warn("Updater.getUpgradePolicy interface mocked in the Previewer. How this interface works on the" + + " Previewer may be different from that on a real device.") + const len = args.length + if (len > 0 && typeof args[len - 1] === 'function') { + args[len - 1].call(this, paramMock.businessErrorMock, UpgradePolicy); + } else { + return new Promise((resolve, reject) => { + resolve(UpgradePolicy); + }) + } + }, + setUpgradePolicy: function (...args) { + console.warn("Updater.setUpgradePolicy interface mocked in the Previewer. How this interface works on the" + + " Previewer may be different from that on a real device.") + const len = args.length + if (len > 0 && typeof args[len - 1] === 'function') { + args[len - 1].call(this, paramMock.businessErrorMock, paramMock.paramNumberMock); + } else { + return new Promise((resolve, reject) => { + resolve(paramMock.paramNumberMock); + }) + } + }, + terminateUpgrade: function (...args) { + console.warn("Updater.terminateUpgrade interface mocked in the Previewer. How this interface works on the" + + " Previewer may be different from that on a real device.") + const len = args.length + if (len > 0 && typeof args[len - 1] === 'function') { + args[len - 1].call(this, paramMock.businessErrorMock); + } else { + return new Promise((resolve, reject) => { + resolve(); + }) + } + }, + on: function (...args) { + console.warn("Updater.on interface mocked in the Previewer. How this interface works on the" + + " Previewer may be different from that on a real device.") + const len = args.length + if (len > 0 && typeof args[len - 1] === 'function') { + args[len - 1].call(this, EventInfo); + } + }, + off: function (...args) { + console.warn("Updater.off interface mocked in the Previewer. How this interface works on the" + + " Previewer may be different from that on a real device.") + const len = args.length + if (len > 0 && typeof args[len - 1] === 'function') { + args[len - 1].call(this, EventInfo); + } + }, + } + const Restorer = { + factoryReset: function (...args) { + console.warn("Restorer.factoryReset interface mocked in the Previewer. How this interface works on the" + + " Previewer may be different from that on a real device.") + const len = args.length + if (len > 0 && typeof args[len - 1] === 'function') { + args[len - 1].call(this, paramMock.businessErrorMock); + } else { + return new Promise((resolve, reject) => { + resolve(); + }) + } + }, + } + const LocalUpdater = { + verifyUpgradePackage: function (...args) { + console.warn("LocalUpdater.verifyUpgradePackage interface mocked in the Previewer. How this interface" + + " works on the Previewer may be different from that on a real device.") const len = args.length if (len > 0 && typeof args[len - 1] === 'function') { args[len - 1].call(this, paramMock.businessErrorMock, paramMock.paramNumberMock); @@ -74,154 +206,210 @@ export function mockUpdate() { } }, applyNewVersion: function (...args) { - console.warn("Updater.applyNewVersion interface mocked in the Previewer. How this interface works on the" + - " Previewer may be different from that on a real device.") + console.warn("LocalUpdater.applyNewVersion interface mocked in the Previewer. How this interface works" + + " on the Previewer may be different from that on a real device.") const len = args.length if (len > 0 && typeof args[len - 1] === 'function') { - args[len - 1].call(this, paramMock.businessErrorMock, paramMock.paramNumberMock); + args[len - 1].call(this, paramMock.businessErrorMock); } else { return new Promise((resolve, reject) => { - resolve(paramMock.paramNumberMock); + resolve(); }) } }, - rebootAndCleanCache: function (...args) { - console.warn("Updater.rebootAndCleanCache interface mocked in the Previewer. How this interface works on the" + - " Previewer may be different from that on a real device.") - const len = args.length - if (len > 0 && typeof args[len - 1] === 'function') { - args[len - 1].call(this, paramMock.businessErrorMock, paramMock.paramNumberMock); - } else { - return new Promise((resolve, reject) => { - resolve(paramMock.paramNumberMock); - }) - } - }, - verifyUpdatePackage: function (...args) { - console.warn("Updater.verifyUpdatePackage 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("Updater.on interface mocked in the Previewer. How this interface works on the" + - " Previewer may be different from that on a real device.") + console.warn("LocalUpdater.on interface mocked in the Previewer. How this interface works on the" + + " Previewer may be different from that on a real device.") const len = args.length if (len > 0 && typeof args[len - 1] === 'function') { - args[len - 1].call(this, Progress); + args[len - 1].call(this, EventInfo); } }, off: function (...args) { - console.warn("Updater.off interface mocked in the Previewer. How this interface works on the" + - " Previewer may be different from that on a real device.") + console.warn("LocalUpdater.off interface mocked in the Previewer. How this interface works on the" + + " Previewer may be different from that on a real device.") const len = args.length if (len > 0 && typeof args[len - 1] === 'function') { - args[len - 1].call(this, Progress); + args[len - 1].call(this, EventInfo); } }, - cancel: function (...args) { - console.warn("Updater.cancel interface mocked in the Previewer. How this interface works on the" + - " Previewer may be different from that on a real device.") - }, } const update = { - PackageTypes, - NewVersionStatus, - UpdateState, - InstallMode, - getUpdater: function (...args) { - console.warn("update.getUpdater interface mocked in the Previewer. How this interface works on the" + - " Previewer may be different from that on a real device.") - return updater; + BusinessVendor, + BusinessSubType, + ComponentType, + UpgradeAction, + EffectiveMode, + DescriptionType, + NetType, + Order, + UpgradeStatus, + EventClassify, + EventId, + getOnlineUpdater: function (...args) { + console.warn("update.getOnlineUpdater interface mocked in the Previewer. How this interface works on the" + + " Previewer may be different from that on a real device.") + return Updater; }, - getUpdaterForOther: function (...args) { - console.warn("update.getUpdaterForOther interface mocked in the Previewer. How this interface works on the" + - " Previewer may be different from that on a real device.") - return updater; + getRestorer: function (...args) { + console.warn("update.getRestorer interface mocked in the Previewer. How this interface works on the" + + " Previewer may be different from that on a real device.") + return Restorer; }, - getUpdaterFromOther: function (...args) { - console.warn("update.getUpdaterFromOther interface mocked in the Previewer. How this interface works on the" + - " Previewer may be different from that on a real device.") - return updater; + getLocalUpdater: function (...args) { + console.warn("update.getLocalUpdater interface mocked in the Previewer. How this interface works on the" + + " Previewer may be different from that on a real device.") + return LocalUpdater; } } return update; } -const PackageTypes = { - PACKAGE_TYPE_NORMAL: 1, - PACKAGE_TYPE_BASE: 2, - PACKAGE_TYPE_CUST: 3, - PACKAGE_TYPE_PRELOAD: 4, - PACKAGE_TYPE_COTA: 5, - PACKAGE_TYPE_VERSION: 6, - PACKAGE_TYPE_PATCH: 7, +const BusinessVendor = { + PUBLIC: "public", } -const CheckResult = { - versionName: "[PC Preview] unknow versionName", - versionCode: "[PC Preview] unknow versionCode", - size: "[PC Preview] unknow size", - verifyInfo: "[PC Preview] unknow verifyInfo", - packageType: PackageTypes.PACKAGE_TYPE_NORMAL, - descriptionId: "[PC Preview] unknow descriptionId", +const BusinessSubType = { + FIRMWARE: 1, + PARAM: 2, +} + +const ComponentType = { + OTA: 1, +} + +const UpgradeAction = { + UPGRADE: "upgrade", + RECOVERY: "recovery", +} + +const EffectiveMode = { + COLD: 1, + LIVE: 2, + LIVE_AND_COLD: 3, +} + +const DescriptionType = { + CONTENT: 0, + URI: 1, +} + +const NetType = { + CELLULAR: 1, + METERED_WIFI: 2, + NOT_METERED_WIFI: 4, +} + +const Order = { + DOWNLOAD: 1, + INSTALL: 2, + APPLY: 4, +} + +const UpgradeStatus = { + WAITING_DOWNLOAD: 20, + DOWNLOADING: 21, + DOWNLOAD_PAUSED: 22, + DOWNLOAD_FAIL: 23, + WAITING_INSTALL: 30, + UPDATING: 31, + WAITING_APPLY: 40, + APPLYING: 41, + UPGRADE_SUCCESS: 50, + UPGRADE_FAIL: 51, +} + +const EventClassify = { + TASK: 0x01000000, +} + +const EventId = { + EVENT_TASK_BASE: 0x01000000, + EVENT_TASK_RECEIVE: 0x01000001, + EVENT_TASK_CANCEL: 0x01000002, + EVENT_DOWNLOAD_WAIT: 0x01000003, + EVENT_DOWNLOAD_START: 0x01000004, + EVENT_DOWNLOAD_UPDATE: 0x01000005, + EVENT_DOWNLOAD_PAUSE: 0x01000006, + EVENT_DOWNLOAD_RESUME: 0x01000007, + EVENT_DOWNLOAD_SUCCESS: 0x01000008, + EVENT_DOWNLOAD_FAIL: 0x01000009, + EVENT_UPGRADE_WAIT: 0x01000010, + EVENT_UPGRADE_START: 0x01000011, + EVENT_UPGRADE_UPDATE: 0x01000012, + EVENT_APPLY_WAIT: 0x01000013, + EVENT_APPLY_START: 0x01000014, + EVENT_UPGRADE_SUCCESS: 0x01000015, + EVENT_UPGRADE_FAIL: 0x01000016, +} + +const VersionDigestInfo = { + versionDigest: "[PC Preview] unknown versionDigest", } const DescriptionInfo = { - descriptionId: "[PC Preview] unknow descriptionId", - content: "[PC Preview] unknow content", + descriptionType: DescriptionType.CONTENT, + content: "[PC Preview] unknown content", } -const NewVersionStatus = { - VERSION_STATUS_ERR: -1, - VERSION_STATUS_NEW: 0, - VERSION_STATUS_NONE: 1, - VERSION_STATUS_BUSY: 2, +const VersionComponent = { + componentType: ComponentType.OTA, + upgradeAction: UpgradeAction.UPGRADE, + displayVersion: "[PC Preview] unknown displayVersion", + innerVersion: "[PC Preview] unknown innerVersion", + size: "[PC Preview] unknown size", + effectiveMode: EffectiveMode.COLD, + descriptionInfo: DescriptionInfo, } const NewVersionInfo = { - status: NewVersionStatus.VERSION_STATUS_NEW, - errMsg: "[PC Preview] unknow errMsg", - checkResults: [CheckResult], - descriptionInfo: [DescriptionInfo] + versionDigestInfo: VersionDigestInfo, + versionComponents: [VersionComponent], } -const UpdateState = { - UPDATE_STATE_INIT: 0, - UPDATE_STATE_CHECK_VERSION_ON: 10, - UPDATE_STATE_CHECK_VERSION_FAIL: 11, - UPDATE_STATE_CHECK_VERSION_SUCCESS: 12, - UPDATE_STATE_DOWNLOAD_ON: 20, - UPDATE_STATE_DOWNLOAD_PAUSE: 21, - UPDATE_STATE_DOWNLOAD_CANCEL: 22, - UPDATE_STATE_DOWNLOAD_FAIL: 23, - UPDATE_STATE_DOWNLOAD_SUCCESS: 24, - UPDATE_STATE_VERIFY_ON: 30, - UPDATE_STATE_VERIFY_FAIL: 31, - UPDATE_STATE_VERIFY_SUCCESS: 32, - UPDATE_STATE_PACKAGE_TRANS_ON: 70, - UPDATE_STATE_PACKAGE_TRANS_FAIL: 71, - UPDATE_STATE_PACKAGE_TRANS_SUCCESS: 72, - UPDATE_STATE_INSTALL_ON: 80, - UPDATE_STATE_INSTALL_FAIL: 81, - UPDATE_STATE_INSTALL_SUCCESS: 82, - UPDATE_STATE_UPDATE_ON: 90, - UPDATE_STATE_UPDATE_FAIL: 91, - UPDATE_STATE_UPDATE_SUCCESS: 92 +const CheckResult = { + isExistNewVersion: "[PC Preview] unknown isExistNewVersion", + newVersionInfo: NewVersionInfo, } -const Progress = { - percent: "[PC Preview] unknow percent", - status: UpdateState.UPDATE_STATE_INIT, - endReason: "[PC Preview] unknow endReason" +const CurrentVersionInfo = { + osVersion: "[PC Preview] unknown osVersion", + deviceName: "[PC Preview] unknown deviceName", + versionComponents: [VersionComponent], } -const InstallMode = { - INSTALL_MODE_NORMAL: "[PC Preview] unknow INSTALL_MODE_NORMAL", - INSTALL_MODE_NIGHT: "[PC Preview] unknow INSTALL_MODE_NIGHT", - INSTALL_MODE_AUTO: "[PC Preview] unknow INSTALL_MODE_AUTO" +const UpgradePeriod = { + start: "[PC Preview] unknown start", + end: "[PC Preview] unknown end", } -const UpdatePolicy = { - autoDownload: "[PC Preview] unknow autoDownload", - installMode: InstallMode.INSTALL_MODE_NORMAL, - autoUpgradeInterval: [0] -} \ No newline at end of file +const UpgradePolicy = { + downloadStrategy: "[PC Preview] unknown downloadStrategy", + autoUpgradeStrategy: "[PC Preview] unknown autoUpgradeStrategy", + autoUpgradePeriods: [UpgradePeriod], +} + +const ErrorMessage = { + errorCode: "[PC Preview] unknown errorCode", + errorMessage: "[PC Preview] unknown errorMessage", +} + +const TaskBody = { + versionDigestInfo: VersionDigestInfo, + status: UpgradeStatus.WAITING_DOWNLOAD, + subStatus: "[PC Preview] unknown subStatus", + progress: "[PC Preview] unknown progress", + installMode: "[PC Preview] unknown installMode", + errorMessages: [ErrorMessage], + versionComponents: [VersionComponent], +} + +const TaskInfo = { + existTask: "[PC Preview] unknown existTask", + taskBody: TaskBody, +} + +const EventInfo = { + eventId: EventId.EVENT_TASK_RECEIVE, + taskBody: TaskBody, +} From d75c6f9790652f5ab0074588bf6147e21637fa53 Mon Sep 17 00:00:00 2001 From: liukaii Date: Thu, 30 Jun 2022 10:51:46 +0800 Subject: [PATCH 019/109] Add uiappearance mock. Signed-off-by: liukaii --- .../main/extend/systemplugin/napi/index.js | 3 ++ .../systemplugin/napi/ohos_uiappearance.js | 44 +++++++++++++++++++ 2 files changed, 47 insertions(+) create mode 100644 runtime/main/extend/systemplugin/napi/ohos_uiappearance.js diff --git a/runtime/main/extend/systemplugin/napi/index.js b/runtime/main/extend/systemplugin/napi/index.js index 4415d0c2..fdab14e9 100644 --- a/runtime/main/extend/systemplugin/napi/index.js +++ b/runtime/main/extend/systemplugin/napi/index.js @@ -161,11 +161,14 @@ import { mockDefaultAppManager } from './ohos_bundle_defaultAppManager' import { mockKeyEvent } from './ohos_multimodalInput_keyEvent' import { mockMouseEvent } from './ohos_multimodalInput_mouseEvent' import { mockTouchEvent } from './ohos_multimodalInput_touchEvent' +import { mockUiAppearance } from './ohos_uiappearance' export function mockRequireNapiFun() { global.requireNapi = function (...args) { switch (args[0]) { case "file": return mockFile(); + case "uiappearance": + return mockUiAppearance(); case "resourceManager": return mockResourceManager(); case "mediaquery": diff --git a/runtime/main/extend/systemplugin/napi/ohos_uiappearance.js b/runtime/main/extend/systemplugin/napi/ohos_uiappearance.js new file mode 100644 index 00000000..ab8a8602 --- /dev/null +++ b/runtime/main/extend/systemplugin/napi/ohos_uiappearance.js @@ -0,0 +1,44 @@ +/* + * Copyright (c) 2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { paramMock } from '../utils'; + +export function mockUiAppearance() { + const DarkMode = { + ALWAYS_DARK: 0, + ALWAYS_LIGHT: 1 + }; + const uiappearance = { + DarkMode, + setDarkMode: function (...args) { + console.warn("uiappearance.setDarkMode interface mocked in the Previewer." + + " How this interface works on the Previewer may be different from 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) => { + resolve(); + }); + } + }, + getDarkMode: function () { + console.warn("uiappearance.getDarkMode interface mocked in the Previewer." + + " How this interface works on the Previewer may be different from that on a real device.") + return DarkMode; + } + } + return uiappearance; +} From 28c3545c9e3da80cd29ac236f0daf256a6c66d3d Mon Sep 17 00:00:00 2001 From: zhangmingxiang Date: Mon, 4 Jul 2022 15:29:24 +0800 Subject: [PATCH 020/109] add continuation manager api mock Signed-off-by: zhangmingxiang Change-Id: If660ec05d40930636aaa61b1063028f986108ea4 Signed-off-by: zhangmingxiang --- .../main/extend/systemplugin/napi/index.js | 3 + .../ohos_continuation_continuationManager.js | 118 ++++++++++++++++++ 2 files changed, 121 insertions(+) create mode 100644 runtime/main/extend/systemplugin/napi/ohos_continuation_continuationManager.js diff --git a/runtime/main/extend/systemplugin/napi/index.js b/runtime/main/extend/systemplugin/napi/index.js index fdab14e9..f1b95bfe 100644 --- a/runtime/main/extend/systemplugin/napi/index.js +++ b/runtime/main/extend/systemplugin/napi/index.js @@ -162,6 +162,7 @@ import { mockKeyEvent } from './ohos_multimodalInput_keyEvent' import { mockMouseEvent } from './ohos_multimodalInput_mouseEvent' import { mockTouchEvent } from './ohos_multimodalInput_touchEvent' import { mockUiAppearance } from './ohos_uiappearance' +import { mockContinationManager } from './ohos_continuation_continuationManager' export function mockRequireNapiFun() { global.requireNapi = function (...args) { switch (args[0]) { @@ -463,6 +464,8 @@ export function mockRequireNapiFun() { return mockMouseEvent(); case "multimodalInput.touchEvent": return mockTouchEvent(); + case "continuation.continuationManager": + return mockContinationManager(); default: return global.requireNapiPreview(...args); } diff --git a/runtime/main/extend/systemplugin/napi/ohos_continuation_continuationManager.js b/runtime/main/extend/systemplugin/napi/ohos_continuation_continuationManager.js new file mode 100644 index 00000000..dd0925a6 --- /dev/null +++ b/runtime/main/extend/systemplugin/napi/ohos_continuation_continuationManager.js @@ -0,0 +1,118 @@ +/* + * Copyright (c) 2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { paramMock } from "../utils" + +export function mockContinationManager() { + const ContinuationExtraParams = { + deviceType: [paramMock.paramStringMock], + targetBundle: '[PC preview] unknown targetBundle', + description: '[PC preview] unknown description', + filter: '[PC preview] unknown filter', + continuationMode: continuationManager.ContinuationMode, + authInfo: '[PC preview] unknown authInfo' + } + + const ContinuationResult = { + id: '[PC preview] unknown id', + type: '[PC preview] unknown type', + name: '[PC preview] unknown name' + } + + const continuationManager = { + DeviceConnectState: { + IDLE: 0, + CONNECTING: 1, + CONNECTED: 2, + DISCONNECTING: 3 + }, + + ContinuationMode: { + COLLABORATION_SINGLE: 0, + COLLABORATION_MULTIPLE: 1 + }, + + on: function (...args) { + console.warn("continuationManager.on interface mocked in the Previewer. How this interface works on the Previewer may" + + " be different from that on a real device.") + const len = args.length; + if (typeof args[len - 1] === 'function') { + if (args[0] == 'deviceConnect') { + args[len - 1].call(this, new Array(ContinuationResult)); + } else if (args[0] == 'deviceDisconnect') { + args[len - 1].call(this, new Array(paramMock.paramStringMock)); + } + } + }, + + off: function (...args) { + console.warn("continuationManager.off interface mocked in the Previewer. How this interface works on the Previewer may" + + " be different from that on a real device.") + }, + + register: function (...args) { + console.warn("continuationManager.register interface mocked in the Previewer. How this interface works on the Previewer" + + " may be different from that on a real device.") + const len = args.length; + if (typeof args[len - 1] === 'function') { + args[len - 1].call(this, paramMock.businessErrorMock, paramMock.paramNumberMock); + } else { + return new Promise((resolve) => { + resolve(paramMock.paramNumberMock); + }); + } + }, + + unregister: function (...args) { + console.warn("continuationManager.unregister interface mocked in the Previewer. How this interface works on the Previewer" + + " may be different from that on a real device.") + const len = args.length; + if (typeof args[len - 1] === 'function') { + args[len - 1].call(this, paramMock.businessErrorMock); + } else { + return new Promise((resolve) => { + resolve(); + }); + } + }, + + updateConnectStatus: function (...args) { + console.warn("continuationManager.updateConnectStatus interface mocked in the Previewer. How this interface works on the Previewer" + + " may be different from that on a 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(); + }); + } + }, + + startDeviceManager: function (...args) { + console.warn("continuationManager.startDeviceManager interface mocked in the Previewer. How this interface works on the Previewer" + + " may be different from that on a real device.") + const len = args.length; + if (typeof args[len - 1] === 'function') { + args[len - 1].call(this, paramMock.businessErrorMock); + } else { + return new Promise((resolve) => { + resolve(); + }); + } + }, + } + return continuationManager +} \ No newline at end of file From 51a4ee459729d99a73232d602375570e35ee9e93 Mon Sep 17 00:00:00 2001 From: sunyaozu Date: Wed, 29 Jun 2022 18:52:09 +0800 Subject: [PATCH 021/109] add timezone and local digit mock Signed-off-by: sunyaozu --- .../extend/systemplugin/napi/ohos_i18n.js | 95 +++++++++++++------ 1 file changed, 67 insertions(+), 28 deletions(-) diff --git a/runtime/main/extend/systemplugin/napi/ohos_i18n.js b/runtime/main/extend/systemplugin/napi/ohos_i18n.js index 0b946057..5aa4ad09 100644 --- a/runtime/main/extend/systemplugin/napi/ohos_i18n.js +++ b/runtime/main/extend/systemplugin/napi/ohos_i18n.js @@ -30,12 +30,12 @@ export function mockI18N() { getSystemLanguages: function() { console.warn("I18N.getSystemLanguages interface mocked in the Previewer. How this interface works on the Previewer" + " may be different from that on a real device.") - return paramMock.paramArrayMock; + return new Array(paramMock.paramStringMock); }, getSystemCountries: function(...args) { console.warn("I18N.getSystemCountries interface mocked in the Previewer. How this interface works on the Previewer" + " may be different from that on a real device.") - return paramMock.paramArrayMock; + return new Array(paramMock.paramStringMock); }, isSuggested: function(...args) { console.warn("I18N.isSuggested interface mocked in the Previewer. How this interface works on the Previewer" + @@ -72,11 +72,6 @@ export function mockI18N() { " may be different from that on a real device.") return paramMock.paramBooleanMock; }, - PhoneNumberFormat: function(...args) { - console.warn("I18N.PhoneNumberFormat interface mocked in the Previewer. How this interface works on the Previewer" + - " may be different from that on a real device.") - return PhoneNumberFormatMock; - }, getCalendar: function(...args) { console.warn("I18N.getCalendar interface mocked in the Previewer. How this interface works on the Previewer" + " may be different from that on a real device.") @@ -95,7 +90,7 @@ export function mockI18N() { getTimeZone: function(...args) { console.warn("I18N.getTimeZone interface mocked in the Previewer. How this interface works on the Previewer" + " may be different from that on a real device.") - return TimeZoneMock; + return new TimeZoneClass(); }, Util: { unitConvert: function(...args) { @@ -180,25 +175,25 @@ export function mockI18N() { getPreferredLanguageList: function() { console.warn("I18N.getPreferredLanguageList interface mocked in the Previewer. How this interface works on the Previewer" + " may be different from that on a real device.") - return paramMock.paramArrayMock; + return new Array(paramMock.paramStringMock); }, getFirstPreferredLanguage: function() { console.warn("I18N.getFirstPreferredLanguage 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 PhoneNumberFormatMock = { - isValidNumber: function(...args) { - console.warn("I18N.PhoneNumberFormat.isValidNumber interface mocked in the Previewer. How this interface works on the Previewer" + + }, + TimeZone: TimeZoneClass, + setUsingLocalDigit: function(...args) { + console.warn("I18N.setUsingLocalDigit interface mocked in the Previewer. How this interface works on the Previewer" + " may be different from that on a real device.") return paramMock.paramBooleanMock; }, - format: function(...args) { - console.warn("I18N.PhoneNumberFormat.format interface mocked in the Previewer. How this interface works on the Previewer" + + getUsingLocalDigit: function() { + console.warn("I18N.getUsingLocalDigit interface mocked in the Previewer. How this interface works on the Previewer" + " may be different from that on a real device.") - return paramMock.paramStringMock; + return paramMock.paramBooleanMock; }, + PhoneNumberFormat: PhoneNumberFormatClass } const CalendarMock = { setTime: function(...args) { @@ -302,7 +297,7 @@ export function mockI18N() { getIndexList: function() { console.warn("I18N.IndexUtil.getIndexList interface mocked in the Previewer. How this interface works on the Previewer" + " may be different from that on a real device.") - return paramMock.paramArrayMock; + return new Array(paramMock.paramStringMock); }, addLocale: function(...args) { console.warn("I18N.IndexUtil.addLocale interface mocked in the Previewer. How this interface works on the Previewer" + @@ -314,27 +309,71 @@ export function mockI18N() { return paramMock.paramStringMock; } } - const TimeZoneMock = { - getID: function() { + return result; +} + +export const TimeZoneClass = class TimeZone{ + constructor() { + this.getID = function() { console.warn("I18N.TimeZone.getID interface mocked in the Previewer. How this interface works on the Previewer" + " may be different from that on a real device.") return paramMock.paramStringMock; - }, - getDisplayName: function(...args) { + }; + this.getDisplayName = function(...args) { console.warn("I18N.TimeZone.getDisplayName interface mocked in the Previewer. How this interface works on the Previewer" + " may be different from that on a real device.") return paramMock.paramStringMock; - }, - getRawOffset: function() { + }; + this.getRawOffset = function() { console.warn("I18N.TimeZone.getRawOffset interface mocked in the Previewer. How this interface works on the Previewer" + " may be different from that on a real device.") return paramMock.paramNumberMock; - }, - getOffset: function(...args) { + }; + this.getOffset = function(...args) { console.warn("I18N.TimeZone.getOffset interface mocked in the Previewer. How this interface works on the Previewer" + " may be different from that on a real device.") return paramMock.paramNumberMock; - } + }; } - return result; +} +TimeZoneClass.getAvailableIDs = function() { + console.warn("I18N.TimeZone.getAvailableIDs interface mocked in the Previewer. How this interface works on the Previewer" + + " may be different from that on a real device.") + return new Array(paramMock.paramStringMock); +}; +TimeZoneClass.getAvailableZoneCityIDs = function() { + console.warn("I18N.TimeZone.getAvailableZoneCityIDs interface mocked in the Previewer. How this interface works on the Previewer" + + " may be different from that on a real device.") + return new Array(paramMock.paramStringMock); +}; +TimeZoneClass.getCityDisplayName = function(...args) { + console.warn("I18N.TimeZone.getCityDisplayName interface mocked in the Previewer. How this interface works on the Previewer" + + " may be different from that on a real device.") + return paramMock.paramStringMock; +}; +TimeZoneClass.getTimezoneFromCity = function(...args) { + console.warn("I18N.TimeZone.getTimezoneFromCity interface mocked in the Previewer. How this interface works on the Previewer" + + " may be different from that on a real device.") + return new TimeZoneClass(); +}; +const PhoneNumberFormatClass = class PhoneNumberFormat{ + constructor(...args) { + console.warn("I18N.PhoneNumberFormat.constructor interface mocked in the Previewer. How this interface works on the Previewer" + + " may be different from that on a real device.") + this.isValidNumber = function(...args) { + console.warn("I18N.PhoneNumberFormat.isValidNumber interface mocked in the Previewer. How this interface works on the Previewer" + + " may be different from that on a real device.") + return paramMock.paramBooleanMock; + }; + this.format = function(...args) { + console.warn("I18N.PhoneNumberFormat.format interface mocked in the Previewer. How this interface works on the Previewer" + + " may be different from that on a real device.") + return paramMock.paramStringMock; + }; + } +} +PhoneNumberFormatClass.getLocationName = function(...args) { + console.warn("I18N.PhoneNumberFormat.getLocationName interface mocked in the Previewer. How this interface works on the Previewer" + + " may be different from that on a real device.") + return paramMock.paramStringMock; } \ No newline at end of file From 3c010eb885948356e7f9ee872cef7728292b0ef1 Mon Sep 17 00:00:00 2001 From: jackd320 Date: Mon, 4 Jul 2022 11:17:14 +0000 Subject: [PATCH 022/109] Signed-off-by: jackd320 --- .../extend/systemplugin/napi/ohos_update.js | 31 ++++++++++--------- 1 file changed, 16 insertions(+), 15 deletions(-) diff --git a/runtime/main/extend/systemplugin/napi/ohos_update.js b/runtime/main/extend/systemplugin/napi/ohos_update.js index ce05f296..3a3b2d51 100644 --- a/runtime/main/extend/systemplugin/napi/ohos_update.js +++ b/runtime/main/extend/systemplugin/napi/ohos_update.js @@ -326,21 +326,22 @@ const EventClassify = { const EventId = { EVENT_TASK_BASE: 0x01000000, EVENT_TASK_RECEIVE: 0x01000001, - EVENT_TASK_CANCEL: 0x01000002, - EVENT_DOWNLOAD_WAIT: 0x01000003, - EVENT_DOWNLOAD_START: 0x01000004, - EVENT_DOWNLOAD_UPDATE: 0x01000005, - EVENT_DOWNLOAD_PAUSE: 0x01000006, - EVENT_DOWNLOAD_RESUME: 0x01000007, - EVENT_DOWNLOAD_SUCCESS: 0x01000008, - EVENT_DOWNLOAD_FAIL: 0x01000009, - EVENT_UPGRADE_WAIT: 0x01000010, - EVENT_UPGRADE_START: 0x01000011, - EVENT_UPGRADE_UPDATE: 0x01000012, - EVENT_APPLY_WAIT: 0x01000013, - EVENT_APPLY_START: 0x01000014, - EVENT_UPGRADE_SUCCESS: 0x01000015, - EVENT_UPGRADE_FAIL: 0x01000016, + EVENT_TASK_CANCEL: 0x01000010, + EVENT_DOWNLOAD_WAIT: 0x01000011, + EVENT_DOWNLOAD_START: 0x01000100, + EVENT_DOWNLOAD_UPDATE: 0x01000101, + EVENT_DOWNLOAD_PAUSE: 0x01000110, + EVENT_DOWNLOAD_RESUME: 0x01000111, + EVENT_DOWNLOAD_SUCCESS: 0x01001000, + EVENT_DOWNLOAD_FAIL: 0x01001001, + EVENT_UPGRADE_WAIT: 0x01001010, + EVENT_UPGRADE_START: 0x01001011, + EVENT_UPGRADE_UPDATE: 0x01001100, + EVENT_APPLY_WAIT: 0x01001101, + EVENT_APPLY_START: 0x01001110, + EVENT_UPGRADE_SUCCESS: 0x01001111, + EVENT_UPGRADE_FAIL: 0x01010000, + } const VersionDigestInfo = { From 54d0025572a70dc1b8e03e5d459099004f9f8865 Mon Sep 17 00:00:00 2001 From: jackd320 Date: Mon, 4 Jul 2022 11:17:27 +0000 Subject: [PATCH 023/109] Signed-off-by: jackd320 --- runtime/main/extend/systemplugin/napi/ohos_update.js | 1 - 1 file changed, 1 deletion(-) diff --git a/runtime/main/extend/systemplugin/napi/ohos_update.js b/runtime/main/extend/systemplugin/napi/ohos_update.js index 3a3b2d51..d78eeb32 100644 --- a/runtime/main/extend/systemplugin/napi/ohos_update.js +++ b/runtime/main/extend/systemplugin/napi/ohos_update.js @@ -341,7 +341,6 @@ const EventId = { EVENT_APPLY_START: 0x01001110, EVENT_UPGRADE_SUCCESS: 0x01001111, EVENT_UPGRADE_FAIL: 0x01010000, - } const VersionDigestInfo = { From b908a7c95f5c7319036bf11eb6a03becea28b261 Mon Sep 17 00:00:00 2001 From: liukaii Date: Mon, 4 Jul 2022 17:21:14 +0800 Subject: [PATCH 024/109] Modify file name. Signed-off-by: liukaii --- runtime/main/extend/systemplugin/napi/index.js | 4 ++-- .../{ohos_uiappearance.js => ohos_uiAppearance.js} | 10 +++++----- 2 files changed, 7 insertions(+), 7 deletions(-) rename runtime/main/extend/systemplugin/napi/{ohos_uiappearance.js => ohos_uiAppearance.js} (88%) diff --git a/runtime/main/extend/systemplugin/napi/index.js b/runtime/main/extend/systemplugin/napi/index.js index fdab14e9..205259ad 100644 --- a/runtime/main/extend/systemplugin/napi/index.js +++ b/runtime/main/extend/systemplugin/napi/index.js @@ -161,13 +161,13 @@ import { mockDefaultAppManager } from './ohos_bundle_defaultAppManager' import { mockKeyEvent } from './ohos_multimodalInput_keyEvent' import { mockMouseEvent } from './ohos_multimodalInput_mouseEvent' import { mockTouchEvent } from './ohos_multimodalInput_touchEvent' -import { mockUiAppearance } from './ohos_uiappearance' +import { mockUiAppearance } from './ohos_uiAppearance' export function mockRequireNapiFun() { global.requireNapi = function (...args) { switch (args[0]) { case "file": return mockFile(); - case "uiappearance": + case "uiAppearance": return mockUiAppearance(); case "resourceManager": return mockResourceManager(); diff --git a/runtime/main/extend/systemplugin/napi/ohos_uiappearance.js b/runtime/main/extend/systemplugin/napi/ohos_uiAppearance.js similarity index 88% rename from runtime/main/extend/systemplugin/napi/ohos_uiappearance.js rename to runtime/main/extend/systemplugin/napi/ohos_uiAppearance.js index ab8a8602..69302595 100644 --- a/runtime/main/extend/systemplugin/napi/ohos_uiappearance.js +++ b/runtime/main/extend/systemplugin/napi/ohos_uiAppearance.js @@ -19,11 +19,11 @@ export function mockUiAppearance() { const DarkMode = { ALWAYS_DARK: 0, ALWAYS_LIGHT: 1 - }; - const uiappearance = { + } + const uiAppearance = { DarkMode, setDarkMode: function (...args) { - console.warn("uiappearance.setDarkMode interface mocked in the Previewer." + + console.warn("uiAppearance.setDarkMode interface mocked in the Previewer." + " How this interface works on the Previewer may be different from that on a real device.") const len = args.length; if (len > 0 && typeof args[len - 1] === 'function') { @@ -35,10 +35,10 @@ export function mockUiAppearance() { } }, getDarkMode: function () { - console.warn("uiappearance.getDarkMode interface mocked in the Previewer." + + console.warn("uiAppearance.getDarkMode interface mocked in the Previewer." + " How this interface works on the Previewer may be different from that on a real device.") return DarkMode; } } - return uiappearance; + return uiAppearance; } From 1a28a700177baf350eb632fe4e8c0f8dce5deadf Mon Sep 17 00:00:00 2001 From: hungry_feiwei Date: Wed, 6 Jul 2022 10:02:57 +0800 Subject: [PATCH 025/109] =?UTF-8?q?=C3=A4=C2=BFinput=20event=20client=20mo?= =?UTF-8?q?ck?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: hungry_feiwei Change-Id: I9e0002633cd5f1d8b593368796936b097d2c24fa --- .../napi/ohos_multimodalInput_inputEventClient.js | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/runtime/main/extend/systemplugin/napi/ohos_multimodalInput_inputEventClient.js b/runtime/main/extend/systemplugin/napi/ohos_multimodalInput_inputEventClient.js index 09a64faa..c76b4e92 100644 --- a/runtime/main/extend/systemplugin/napi/ohos_multimodalInput_inputEventClient.js +++ b/runtime/main/extend/systemplugin/napi/ohos_multimodalInput_inputEventClient.js @@ -29,19 +29,23 @@ export function mockInputEventClient() { console.warn("the second parameter type must be 'object'"); return; } - if (typeof args[0].isPressed !== 'boolean') { + if (!('KeyEvent' in args[0])) { + console.warn("missing 'KeyEvent' field"); + return; + } + if (typeof args[0].KeyEvent.isPressed !== 'boolean') { console.warn("Field isPressed must be boolean"); return; } - if (typeof args[0].keyCode !== 'number') { + if (typeof args[0].KeyEvent.keyCode !== 'number') { console.warn("Field keyCode must be number"); return; } - if (typeof args[0].keyDownDuration !== 'number') { + if (typeof args[0].KeyEvent.keyDownDuration !== 'number') { console.warn("Field keyDownDuration must be number"); return; } - if (typeof args[0].isIntercepted !== 'boolean') { + if (typeof args[0].KeyEvent.isIntercepted !== 'boolean') { console.warn("Field isIntercepted must be boolean"); return; } From ce6e6540e4bb13f34a91dd26e07c2dcca3c3155e Mon Sep 17 00:00:00 2001 From: ql Date: Wed, 6 Jul 2022 07:36:17 +0000 Subject: [PATCH 026/109] update runtime/main/extend/systemplugin/napi/ohos_distributedMissionManager.js. Signed-off-by: ql --- .../napi/ohos_distributedMissionManager.js | 44 +++++++++---------- 1 file changed, 22 insertions(+), 22 deletions(-) diff --git a/runtime/main/extend/systemplugin/napi/ohos_distributedMissionManager.js b/runtime/main/extend/systemplugin/napi/ohos_distributedMissionManager.js index cbfa39f5..f98c30e2 100755 --- a/runtime/main/extend/systemplugin/napi/ohos_distributedMissionManager.js +++ b/runtime/main/extend/systemplugin/napi/ohos_distributedMissionManager.js @@ -25,34 +25,34 @@ export function mockDistributedMissionManager() { args[len - 1].call(this, paramMock.businessErrorMock); } else { return new Promise((resolve) => { - resolve(); + resolve(); }); } }, stopSyncRemoteMissions: function (...args) { - console.warn('distributedMissionManager.stopSyncRemoteMission interface mocked in the Previewer. How this interface works on the' + - ' Previewer may be different from that on a real device.'); - const len = args.length; - if (typeof args[len - 1] === 'function') { - args[len - 1].call(this, paramMock.businessErrorMock); - } else { - return new Promise((resolve) => { + console.warn('distributedMissionManager.stopSyncRemoteMission interface mocked in the Previewer. How this interface works on the' + + ' Previewer may be different from that on a 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(); - }); - } - }, + }); + } + }, registerMissionListener: function (...args) { - console.warn('distributedMissionManager.registerMissionListener interface mocked in the Previewer. How this interface works on the' + - ' Previewer may be different from that on a 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(); - }); - } - }, + console.warn('distributedMissionManager.registerMissionListener interface mocked in the Previewer. How this interface works on the' + + ' Previewer may be different from that on a 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(); + }); + } + }, unRegisterMissionListener: function (...args) { console.warn('distributedMissionManager.unRegisterMissionListener interface mocked in the Previewer. How this interface works on the' + ' Previewer may be different from that on a real device.'); From 6a2b6d57d0513140620650c23d5f5d24bbfc5c71 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=80=BF=E6=96=87=E5=B9=BF?= Date: Wed, 6 Jul 2022 11:49:31 +0800 Subject: [PATCH 027/109] =?UTF-8?q?=E8=A1=A5=E9=BD=90api-mock=EF=BC=8C?= =?UTF-8?q?=E5=88=A0=E5=B7=B2ye=E5=88=A0=E9=99=A4=E6=8E=A5=E5=8F=A3api-moc?= =?UTF-8?q?k?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 耿文广 --- .../systemplugin/napi/bundle/abilityInfo.js | 165 +++++-- .../napi/bundle/applicationInfo.js | 12 +- .../systemplugin/napi/bundle/bundleInfo.js | 453 +++++++++++++++++- .../napi/bundle/launcherAbilityInfo.js | 64 ++- 4 files changed, 619 insertions(+), 75 deletions(-) diff --git a/runtime/main/extend/systemplugin/napi/bundle/abilityInfo.js b/runtime/main/extend/systemplugin/napi/bundle/abilityInfo.js index 99300e9b..ee690e17 100644 --- a/runtime/main/extend/systemplugin/napi/bundle/abilityInfo.js +++ b/runtime/main/extend/systemplugin/napi/bundle/abilityInfo.js @@ -14,37 +14,99 @@ */ export const AbilityInfoMock = { - bundleName: "string", - name: "string", - label: "string", - description: "string", - icon: "string", - labelId: 1, - descriptionId: 2, - iconId: 3, - moduleName: "string", - process: "string", - targetAbility: "string", - backgroundModes: 4, - isVisible: true, - formEnabled: true, - type: "bundle.AbilityType", - subType: "bundle.AbilitySubType", - orientation: "bundle.DisplayOrientation", - launchMode: "bundle.LaunchMode", - permissions: ["1"], - deviceTypes: ["2"], - deviceCapabilities: ["3"], - readPermission: "string", - writePermission: "string", + name: "[PC preview] unknown name", + bundleName: "[PC preview] unknown bundleName", + moduleName: "[PC preview] unknown moduleName", + process: "[PC preview] unknown process", + targetAbility: "[PC preview] unknown targetAbility", + backgroundModes: "[PC preview] unknown backgroundModes", + isVisible: "[PC preview] unknown isVisible", + formEnabled: "[PC preview] unknown formEnabled", + type: { + UNKNOWN: 0, + PAGE: 2, + SERVICE: 3, + DATA: 4, + }, + subType: { + UNSPECIFIED: 0, + CA: 1, + }, + orientation: { + UNSPECIFIED: 0, + LANDSCAPE: 2, + PORTRAIT: 1, + FOLLOW_RECENT: 2, + LANDSCAPE_INVERTED: 4, + PORTRAIT_INVERTED: 3, + AUTO_ROTATION: 5, + AUTO_ROTATION_LANDSCAPE: 7, + AUTO_ROTATION_PORTRAIT: 6, + AUTO_ROTATION_RESTRICTED: 8, + AUTO_ROTATION_LANDSCAPE_RESTRICTED: 10, + AUTO_ROTATION_PORTRAIT_RESTRICTED: 9, + LOCKED: 11, + }, + launchMode: { + SINGLETON: 0, + STANDARD: 1, + }, + permissions: ['[PC Preview] unknow permissions'], + deviceTypes: ['[PC Preview] unknow deviceTypes'], + deviceCapabilities: ['[PC Preview] unknow deviceCapabilities'], + readPermission: '[PC Preview] unknow readPermission', + writePermission: '[PC Preview] unknow writePermission', + appId: '[PC Preview] unknow appId', + label: "[PC preview] unknown label", + description: "[PC preview] unknown description", + uid: '[PC Preview] unknow uid', + installTime: '[PC Preview] unknow installTime', + updateTime: '[PC Preview] unknow updateTime', + descriptionId: '[PC Preview] unknow descriptionId', applicationInfo: { packageName: "[PC preview] unknown packageName", + description: "[PC preview] unknown description", + descriptionId: "[PC preview] unknown descriptionId", + enabled: "[PC preview] unknown enabled", + systemApp: "[PC preview] unknown systemApp", className: "[PC preview] unknown className", name: "[PC preview] unknown name", - labelId: 1, - iconId: 2, + label: "[PC preview] unknown label", + labelId: "[PC preview] unknown labelId", + icon: "[PC preview] unknown icon", + iconId: "[PC preview] unknown iconId", + process: "[PC preview] unknown process", sourceDir: "[PC preview] unknown sourceDir", - flags: 3, + moduleSourceDirs: ["[PC preview] unknown moduleSourceDirs"], + permissions: ["[PC preview] unknown permissions"], + moduleInfos: [{ + moduleName: "[PC preview] unknown moduleName", + moduleSourceDir: "[PC preview] unknown moduleSourceDir", + }], + entryDir: ["[PC preview] unknown entryDir"], + codePath: ["[PC preview] unknown codePath"], + metaData: [{ + name: "[PC preview] unknown name", + value: "[PC preview] unknown value", + extra: "[PC preview] unknown extra", + }], + metadata: [{ + name: "[PC preview] unknown name", + value: "[PC preview] unknown value", + resource: "[PC preview] unknown resource", + }], + removable: "[PC preview] unknown removable", + accessTokenId: "[PC preview] unknown accessTokenId", + uid: "[PC preview] unknown uid", + entityType: "[PC preview] unknown entityType", + fingerprint: "[PC preview] unknown fingerprint", + iconResource: "[PC preview] unknown iconResource", + labelResource: "[PC preview] unknown labelResource", + descriptionResource: "[PC preview] unknown descriptionResource", + appDistributionType: "[PC preview] unknown appDistributionType", + appProvisionType: "[PC preview] unknown appProvisionType", + supportedModes: "[PC preview] unknown supportedModes", + flags: "[PC preview] unknown flags", customizeData: { key: "[PC preview] unknown key", value: { @@ -55,27 +117,32 @@ export const AbilityInfoMock = { } } }, - formEntity: 5, - minFormHeight: 6, - defaultFormHeight: 7, - minFormWidth: 8, - defaultFormWidth: 9, - uri: "string", - customizeData: { - key: "[PC preview] unknown key", - value: [ - { - CustomizeData: { - name: "[PC preview] unknown name", - value: "[PC preview] unknown value", - }, - }, - { - CustomizeData: { - name: "[PC preview] unknown name", - value: "[PC preview] unknown value", - }, - } - ] - }, + metaData: [{ + name: "[PC preview] unknown name", + value: "[PC preview] unknown value", + extra: "[PC preview] unknown extra", + }], + metadata: [{ + name: "[PC preview] unknown name", + value: "[PC preview] unknown value", + resource: "[PC preview] unknown resource", + }], + enabled: "[PC preview] unknown enabled", + supportWindowMode: [{ + FULL_SCREEN: 0, + SPLIT: 1, + FLOATING: 2, + }], + maxWindowRatio: "[PC preview] unknown maxWindowRatio", + minWindowRatio: "[PC preview] unknown minWindowRatio", + maxWindowWidth: "[PC preview] unknown maxWindowWidth", + minWindowWidth: "[PC preview] unknown minWindowWidth", + maxWindowHeight: "[PC preview] unknown maxWindowHeight", + minWindowHeight: "[PC preview] unknown minWindowHeight", + formEntity: "[PC preview] unknown formEntity", + minFormHeight: "[PC preview] unknown minFormHeight", + defaultFormHeight: "[PC preview] unknown defaultFormHeight", + minFormWidth: "[PC preview] unknown minFormWidth", + defaultFormWidth: "[PC preview] unknown defaultFormWidth", + uri: "[PC preview] unknown uri", } \ No newline at end of file diff --git a/runtime/main/extend/systemplugin/napi/bundle/applicationInfo.js b/runtime/main/extend/systemplugin/napi/bundle/applicationInfo.js index 52ad36e7..cd6b17a1 100644 --- a/runtime/main/extend/systemplugin/napi/bundle/applicationInfo.js +++ b/runtime/main/extend/systemplugin/napi/bundle/applicationInfo.js @@ -77,26 +77,30 @@ export const WantMock = { type: "[PC Preview] unknow type", flag: "[PC Preview] unknow flag", action: "[PC Preview] unknow action", - parameters: "[PC Preview] unknow parameters", - entities: "[PC Preview] unknow entities", - moduleName: "[PC Preview] unknow moduleName" - } + parameters: ["[PC Preview] unknow parameters"], + entities: ["[PC Preview] unknow entities"], + moduleName: "[PC Preview] unknow moduleName", +} export const ShortcutInfoMock = { id: "[PC preview] unknown id", bundleName: "[PC preview] unknown bundleName", hostAbility: "[PC preview] unknown hostAbility", icon: "[PC preview] unknown icon", + iconId: "[PC preview] unknown iconId", label: "[PC preview] unknown label", + labelId: "[PC preview] unknown labelId", disableMessage: "[PC preview] unknown disableMessage", wants: [ { targetBundle: "[PC preview] unknown targetBundle", + targetModule: "[PC preview] unknown targetModule", targetClass: "[PC preview] unknown targetClass", }], isStatic: "[PC preview] unknown isStatic", isHomeShortcut: "[PC preview] unknown isHomeShortcut", isEnabled: "[PC preview] unknown isEnabled", + moduleName: "[PC preview] unknown moduleName", } export const ModuleUsageRecordMock = { diff --git a/runtime/main/extend/systemplugin/napi/bundle/bundleInfo.js b/runtime/main/extend/systemplugin/napi/bundle/bundleInfo.js index aa6120e6..ab73c42a 100644 --- a/runtime/main/extend/systemplugin/napi/bundle/bundleInfo.js +++ b/runtime/main/extend/systemplugin/napi/bundle/bundleInfo.js @@ -22,12 +22,60 @@ export const BundleInfoMock = { updateTime: "[PC preview] unknown updateTime", appInfo: { packageName: "[PC preview] unknown packageName", + description: "[PC preview] unknown description", + descriptionId: "[PC preview] unknown descriptionId", + systemApp: "[PC preview] unknown systemApp", + enabled: "[PC preview] unknown enabled", className: "[PC preview] unknown className", name: "[PC preview] unknown name", labelId: "[PC preview] unknown labelId", + label: "[PC preview] unknown label", + icon: "[PC preview] unknown icon", iconId: "[PC preview] unknown iconId", + process: "[PC preview] unknown process", + supportedModes: "[PC preview] unknown supportedModes", + moduleSourceDirs: ["[PC preview] unknown moduleSourceDirs"], + permissions: ["[PC preview] unknown permissions"], sourceDir: "[PC preview] unknown sourceDir", + moduleInfos: [{ + moduleName: "[PC preview] unknown moduleName", + moduleSourceDir: "[PC preview] unknown moduleSourceDir", + }], flags: "[PC preview] unknown flags", + entryDir: "[PC preview] unknown entryDir", + codePath: "[PC preview] unknown codePath", + metaData: [{ + name: "[PC preview] unknown name", + value: "[PC preview] unknown value", + extra: "[PC preview] unknown extra", + }], + metadata: [{ + name: "[PC preview] unknown name", + value: "[PC preview] unknown value", + resource: "[PC preview] unknown resource", + }], + removable: "[PC preview] unknown removable", + accessTokenId: "[PC preview] unknown accessTokenId", + uid: "[PC preview] unknown uid", + entityType: "[PC preview] unknown entityType", + fingerprint: "[PC preview] unknown fingerprint", + iconResource: { + bundleName: "[PC preview] unknown bundleName", + moduleName: "[PC preview] unknown moduleName", + id: "[PC preview] unknown id", + }, + labelResource: { + bundleName: "[PC preview] unknown bundleName", + moduleName: "[PC preview] unknown moduleName", + id: "[PC preview] unknown id", + }, + descriptionResource: { + bundleName: "[PC preview] unknown bundleName", + moduleName: "[PC preview] unknown moduleName", + id: "[PC preview] unknown id", + }, + appDistributionType: "[PC preview] unknown appDistributionType", + appProvisionType: "[PC preview] unknown appProvisionType", customizeData: { key: "[PC preview] unknown key", value: { @@ -41,20 +89,97 @@ export const BundleInfoMock = { abilityInfo: [ { name: "[PC preview] unknown name", - type: '[[PC Preview] unknow type]', - appId: '[[PC Preview] unknow appId]', + bundleName: "[PC preview] unknown bundleName", + moduleName: "[PC preview] unknown moduleName", + process: "[PC preview] unknown process", + targetAbility: "[PC preview] unknown targetAbility", + backgroundModes: "[PC preview] unknown backgroundModes", + isVisible: "[PC preview] unknown isVisible", + formEnabled: "[PC preview] unknown formEnabled", + type: { + UNKNOWN: 0, + PAGE: 2, + SERVICE: 3, + DATA: 4, + }, + subType: { + UNSPECIFIED: 0, + CA: 1, + }, + orientation: { + UNSPECIFIED: 0, + LANDSCAPE: 2, + PORTRAIT: 1, + FOLLOW_RECENT: 2, + LANDSCAPE_INVERTED: 4, + PORTRAIT_INVERTED: 3, + AUTO_ROTATION: 5, + AUTO_ROTATION_LANDSCAPE: 7, + AUTO_ROTATION_PORTRAIT: 6, + AUTO_ROTATION_RESTRICTED: 8, + AUTO_ROTATION_LANDSCAPE_RESTRICTED: 10, + AUTO_ROTATION_PORTRAIT_RESTRICTED: 9, + LOCKED: 11, + }, + launchMode: { + SINGLETON: 0, + STANDARD: 1, + }, + permissions: ['[PC Preview] unknow permissions'], + deviceTypes: ['[PC Preview] unknow deviceTypes'], + deviceCapabilities: ['[PC Preview] unknow deviceCapabilities'], + readPermission: '[PC Preview] unknow readPermission', + writePermission: '[PC Preview] unknow writePermission', + appId: '[PC Preview] unknow appId', label: "[PC preview] unknown label", description: "[PC preview] unknown description", - uid: '[[PC Preview] unknow uid]', - installTime: '[[PC Preview] unknow installTime]', - updateTime: '[[PC Preview] unknow updateTime]', + uid: '[PC Preview] unknow uid', + installTime: '[PC Preview] unknow installTime', + updateTime: '[PC Preview] unknow updateTime', + descriptionId: '[PC Preview] unknow descriptionId', applicationInfo: { - packageName: "[PC preview] unknown package name", - className: "[PC preview] unknown class name", + packageName: "[PC preview] unknown packageName", + description: "[PC preview] unknown description", + descriptionId: "[PC preview] unknown descriptionId", + enabled: "[PC preview] unknown enabled", + systemApp: "[PC preview] unknown systemApp", + className: "[PC preview] unknown className", name: "[PC preview] unknown name", - labelId: "[PC preview] unknown label id", - iconId: "[PC preview] unknown icon id", - sourceDir: "[PC preview] unknown source dir", + label: "[PC preview] unknown label", + labelId: "[PC preview] unknown labelId", + icon: "[PC preview] unknown icon", + iconId: "[PC preview] unknown iconId", + process: "[PC preview] unknown process", + sourceDir: "[PC preview] unknown sourceDir", + moduleSourceDirs: ["[PC preview] unknown moduleSourceDirs"], + permissions: ["[PC preview] unknown permissions"], + moduleInfos: [{ + moduleName: "[PC preview] unknown moduleName", + moduleSourceDir: "[PC preview] unknown moduleSourceDir", + }], + entryDir: ["[PC preview] unknown entryDir"], + codePath: ["[PC preview] unknown codePath"], + metaData: [{ + name: "[PC preview] unknown name", + value: "[PC preview] unknown value", + extra: "[PC preview] unknown extra", + }], + metadata: [{ + name: "[PC preview] unknown name", + value: "[PC preview] unknown value", + resource: "[PC preview] unknown resource", + }], + removable: "[PC preview] unknown removable", + accessTokenId: "[PC preview] unknown accessTokenId", + uid: "[PC preview] unknown uid", + entityType: "[PC preview] unknown entityType", + fingerprint: "[PC preview] unknown fingerprint", + iconResource: "[PC preview] unknown iconResource", + labelResource: "[PC preview] unknown labelResource", + descriptionResource: "[PC preview] unknown descriptionResource", + appDistributionType: "[PC preview] unknown appDistributionType", + appProvisionType: "[PC preview] unknown appProvisionType", + supportedModes: "[PC preview] unknown supportedModes", flags: "[PC preview] unknown flags", customizeData: { key: "[PC preview] unknown key", @@ -66,6 +191,28 @@ export const BundleInfoMock = { } } }, + metaData: [{ + name: "[PC preview] unknown name", + value: "[PC preview] unknown value", + extra: "[PC preview] unknown extra", + }], + metadata: [{ + name: "[PC preview] unknown name", + value: "[PC preview] unknown value", + resource: "[PC preview] unknown resource", + }], + enabled: "[PC preview] unknown enabled", + supportWindowMode: [{ + FULL_SCREEN: 0, + SPLIT: 1, + FLOATING: 2, + }], + maxWindowRatio: "[PC preview] unknown maxWindowRatio", + minWindowRatio: "[PC preview] unknown minWindowRatio", + maxWindowWidth: "[PC preview] unknown maxWindowWidth", + minWindowWidth: "[PC preview] unknown minWindowWidth", + maxWindowHeight: "[PC preview] unknown maxWindowHeight", + minWindowHeight: "[PC preview] unknown minWindowHeight", formEntity: "[PC preview] unknown formEntity", minFormHeight: "[PC preview] unknown minFormHeight", defaultFormHeight: "[PC preview] unknown defaultFormHeight", @@ -96,6 +243,7 @@ export const BundleInfoMock = { { name: "[PC preview] unknown name", reason: "[PC preview] unknown reason", + reasonId: "[PC preview] unknown reasonId", usedScene: { abilities: ["[PC preview] unknown ability"], when: "[PC preview] unknown when", @@ -108,6 +256,209 @@ export const BundleInfoMock = { compatibleVersion: "[PC preview] unknown compatibleVersion", targetVersion: "[PC preview] unknown targetVersion", isCompressNativeLibs: "[PC preview] unknown isCompressNativeLibs", + hapModuleInfos: [{ + name: "[PC preview] unknown name", + description: "[PC preview] unknown description", + descriptionId: "[PC preview] unknown descriptionId", + icon: "[PC preview] unknown icon", + label: "[PC preview] unknown label", + labelId: "[PC preview] unknown labelId", + iconId: "[PC preview] unknown iconId", + backgroundImg: "[PC preview] unknown backgroundImg", + supportedModes: "[PC preview] unknown supportedModes", + reqCapabilities: ["[PC preview] unknown reqCapabilities"], + deviceTypes: ["[PC preview] unknown deviceTypes"], + abilityInfo: [ + { + name: "[PC preview] unknown name", + bundleName: "[PC preview] unknown bundleName", + moduleName: "[PC preview] unknown moduleName", + process: "[PC preview] unknown process", + targetAbility: "[PC preview] unknown targetAbility", + backgroundModes: "[PC preview] unknown backgroundModes", + isVisible: "[PC preview] unknown isVisible", + formEnabled: "[PC preview] unknown formEnabled", + type: { + UNKNOWN: 0, + PAGE: 2, + SERVICE: 3, + DATA: 4, + }, + subType: { + UNSPECIFIED: 0, + CA: 1, + }, + orientation: { + UNSPECIFIED: 0, + LANDSCAPE: 2, + PORTRAIT: 1, + FOLLOW_RECENT: 2, + LANDSCAPE_INVERTED: 4, + PORTRAIT_INVERTED: 3, + AUTO_ROTATION: 5, + AUTO_ROTATION_LANDSCAPE: 7, + AUTO_ROTATION_PORTRAIT: 6, + AUTO_ROTATION_RESTRICTED: 8, + AUTO_ROTATION_LANDSCAPE_RESTRICTED: 10, + AUTO_ROTATION_PORTRAIT_RESTRICTED: 9, + LOCKED: 11, + }, + launchMode: { + SINGLETON: 0, + STANDARD: 1, + }, + permissions: ['[PC Preview] unknow permissions'], + deviceTypes: ['[PC Preview] unknow deviceTypes'], + deviceCapabilities: ['[PC Preview] unknow deviceCapabilities'], + readPermission: '[PC Preview] unknow readPermission', + writePermission: '[PC Preview] unknow writePermission', + appId: '[PC Preview] unknow appId', + label: "[PC preview] unknown label", + description: "[PC preview] unknown description", + uid: '[PC Preview] unknow uid', + installTime: '[PC Preview] unknow installTime', + updateTime: '[PC Preview] unknow updateTime', + descriptionId: '[PC Preview] unknow descriptionId', + applicationInfo: { + packageName: "[PC preview] unknown packageName", + description: "[PC preview] unknown description", + descriptionId: "[PC preview] unknown descriptionId", + enabled: "[PC preview] unknown enabled", + systemApp: "[PC preview] unknown systemApp", + className: "[PC preview] unknown className", + name: "[PC preview] unknown name", + label: "[PC preview] unknown label", + labelId: "[PC preview] unknown labelId", + icon: "[PC preview] unknown icon", + iconId: "[PC preview] unknown iconId", + process: "[PC preview] unknown process", + sourceDir: "[PC preview] unknown sourceDir", + moduleSourceDirs: ["[PC preview] unknown moduleSourceDirs"], + permissions: ["[PC preview] unknown permissions"], + moduleInfos: [{ + moduleName: "[PC preview] unknown moduleName", + moduleSourceDir: "[PC preview] unknown moduleSourceDir", + }], + entryDir: ["[PC preview] unknown entryDir"], + codePath: ["[PC preview] unknown codePath"], + metaData: [{ + name: "[PC preview] unknown name", + value: "[PC preview] unknown value", + extra: "[PC preview] unknown extra", + }], + metadata: [{ + name: "[PC preview] unknown name", + value: "[PC preview] unknown value", + resource: "[PC preview] unknown resource", + }], + removable: "[PC preview] unknown removable", + accessTokenId: "[PC preview] unknown accessTokenId", + uid: "[PC preview] unknown uid", + entityType: "[PC preview] unknown entityType", + fingerprint: "[PC preview] unknown fingerprint", + iconResource: "[PC preview] unknown iconResource", + labelResource: "[PC preview] unknown labelResource", + descriptionResource: "[PC preview] unknown descriptionResource", + appDistributionType: "[PC preview] unknown appDistributionType", + appProvisionType: "[PC preview] unknown appProvisionType", + supportedModes: "[PC preview] unknown supportedModes", + flags: "[PC preview] unknown flags", + customizeData: { + key: "[PC preview] unknown key", + value: { + CustomizeData: { + name: "[PC preview] unknown name", + value: "[PC preview] unknown value", + } + } + } + }, + metaData: [{ + name: "[PC preview] unknown name", + value: "[PC preview] unknown value", + extra: "[PC preview] unknown extra", + }], + metadata: [{ + name: "[PC preview] unknown name", + value: "[PC preview] unknown value", + resource: "[PC preview] unknown resource", + }], + enabled: "[PC preview] unknown enabled", + supportWindowMode: [{ + FULL_SCREEN: 0, + SPLIT: 1, + FLOATING: 2, + }], + maxWindowRatio: "[PC preview] unknown maxWindowRatio", + minWindowRatio: "[PC preview] unknown minWindowRatio", + maxWindowWidth: "[PC preview] unknown maxWindowWidth", + minWindowWidth: "[PC preview] unknown minWindowWidth", + maxWindowHeight: "[PC preview] unknown maxWindowHeight", + minWindowHeight: "[PC preview] unknown minWindowHeight", + formEntity: "[PC preview] unknown formEntity", + minFormHeight: "[PC preview] unknown minFormHeight", + defaultFormHeight: "[PC preview] unknown defaultFormHeight", + minFormWidth: "[PC preview] unknown minFormWidth", + defaultFormWidth: "[PC preview] unknown defaultFormWidth", + uri: "[PC preview] unknown uri", + customizeData: { + key: "[PC preview] unknown key", + value: [ + { + CustomizeData: { + name: "[PC preview] unknown name", + value: "[PC preview] unknown value", + }, + }, + { + CustomizeData: { + name: "[PC preview] unknown name", + value: "[PC preview] unknown value", + }, + } + ] + }, + } + ], + moduleName: "[PC preview] unknown moduleName", + mainAbilityName: "[PC preview] unknown mainAbilityName", + installationFree: "[PC preview] unknown installationFree", + mainElementName: "[PC preview] unknown mainElementName", + extensionAbilityInfo: [ + { + bundleName: "[PC preview] unknown bundleName", + moduleName: "[PC preview] unknown moduleName", + name: "[PC preview] unknown name", + labelId: "[PC preview] unknown labelId", + descriptionId: "[PC preview] unknown descriptionId", + iconId: "[PC preview] unknown iconId", + isVisible: "[PC preview] unknown isVisible", + extensionAbilityType: { + FORM: 0, + WORK_SCHEDULER: 1, + INPUT_METHOD: 2, + SERVICE: 3, + ACCESSIBILITY: 4, + DATA_SHARE: 5, + FILE_SHARE: 6, + STATIC_SUBSCRIBER: 7, + WALLPAPER: 8, + BACKUP: 9, + WINDOW: 10, + ENTERPRISE_ADMIN: 11, + UNSPECIFIED: 20, + }, + metadata: [{ + name: "[PC preview] unknown name", + value: "[PC preview] unknown value", + resource: "[PC preview] unknown resource", + }], + hashValue: "[PC preview] unknown hashValue", + } + ], + metadata: "[PC preview] unknown mainElementName", + hashValue: "[PC preview] unknown hashValue", + }], hapModuleInfo: [ { name: "string", @@ -199,6 +550,88 @@ export const BundleInfoMock = { isSilentInstallation: "string", minCompatibleVersionCode: 7, entryInstallationFree: true, + reqPermissionStates: ["[PC preview] unknown reqPermissionStates"], + extensionAbilityInfo: [{ + bundleName: "[PC preview] unknown bundleName", + moduleName: "[PC preview] unknown moduleName", + name: "[PC preview] unknown name", + labelId: "[PC preview] unknown labelId", + descriptionId: "[PC preview] unknown descriptionId", + iconId: "[PC preview] unknown iconId", + isVisible: "[PC preview] unknown isVisible", + extensionAbilityType: { + FORM: 0, + WORK_SCHEDULER: 1, + INPUT_METHOD: 2, + SERVICE: 3, + ACCESSIBILITY: 4, + DATA_SHARE: 5, + FILE_SHARE: 6, + STATIC_SUBSCRIBER: 7, + WALLPAPER: 8, + BACKUP: 9, + WINDOW: 10, + ENTERPRISE_ADMIN: 11, + UNSPECIFIED: 20, + }, + metadata: [{ + name: "[PC preview] unknown name", + value: "[PC preview] unknown value", + resource: "[PC preview] unknown resource", + }], + permissions: ["[PC preview] unknown hashValue"], + applicationInfo: { + packageName: "[PC preview] unknown packageName", + description: "[PC preview] unknown description", + descriptionId: "[PC preview] unknown descriptionId", + enabled: "[PC preview] unknown enabled", + systemApp: "[PC preview] unknown systemApp", + className: "[PC preview] unknown className", + name: "[PC preview] unknown name", + label: "[PC preview] unknown label", + labelId: "[PC preview] unknown labelId", + icon: "[PC preview] unknown icon", + iconId: "[PC preview] unknown iconId", + process: "[PC preview] unknown process", + moduleSourceDirs: ["[PC preview] unknown moduleSourceDirs"], + permissions: ["[PC preview] unknown permissions"], + moduleInfos: [{ + moduleName: "[PC preview] unknown moduleName", + moduleSourceDir: "[PC preview] unknown moduleSourceDir", + }], + entryDir: ["[PC preview] unknown entryDir"], + codePath: ["[PC preview] unknown codePath"], + metaData: [{ + name: "[PC preview] unknown name", + value: "[PC preview] unknown value", + extra: "[PC preview] unknown extra", + }], + metadata: [{ + name: "[PC preview] unknown name", + value: "[PC preview] unknown value", + resource: "[PC preview] unknown resource", + }], + removable: "[PC preview] unknown removable", + accessTokenId: "[PC preview] unknown accessTokenId", + uid: "[PC preview] unknown uid", + entityType: "[PC preview] unknown entityType", + fingerprint: "[PC preview] unknown fingerprint", + iconResource: "[PC preview] unknown iconResource", + labelResource: "[PC preview] unknown labelResource", + descriptionResource: "[PC preview] unknown descriptionResource", + appDistributionType: "[PC preview] unknown appDistributionType", + appProvisionType: "[PC preview] unknown appProvisionType", + supportedModes: "[PC preview] unknown supportedModes", + }, + metadata: [{ + name: "[PC preview] unknown name", + value: "[PC preview] unknown value", + resource: "[PC preview] unknown resource", + }], + enabled: "[PC preview] unknown enabled", + readPermission: "[PC preview] unknown readPermission", + writePermission: "[PC preview] unknown writePermission", + }], }; export const BundlePackInfo = { diff --git a/runtime/main/extend/systemplugin/napi/bundle/launcherAbilityInfo.js b/runtime/main/extend/systemplugin/napi/bundle/launcherAbilityInfo.js index 53fb1653..720915a6 100644 --- a/runtime/main/extend/systemplugin/napi/bundle/launcherAbilityInfo.js +++ b/runtime/main/extend/systemplugin/napi/bundle/launcherAbilityInfo.js @@ -16,21 +16,60 @@ export const LauncherAbilityInfoMock = { applicationInfo: { packageName: "[PC preview] unknown packageName", + description: "[PC preview] unknown description", + descriptionId: "[PC preview] unknown descriptionId", + systemApp: "[PC preview] unknown systemApp", + enabled: "[PC preview] unknown enabled", className: "[PC preview] unknown className", name: "[PC preview] unknown name", - labelId: 1, - iconId: 2, + labelId: "[PC preview] unknown labelId", + label: "[PC preview] unknown label", + icon: "[PC preview] unknown icon", + iconId: "[PC preview] unknown iconId", + process: "[PC preview] unknown process", + supportedModes: "[PC preview] unknown supportedModes", + moduleSourceDirs: ["[PC preview] unknown moduleSourceDirs"], + permissions: ["[PC preview] unknown permissions"], sourceDir: "[PC preview] unknown sourceDir", - flags: 3, - customizeData: { - key: "[PC preview] unknown key", - value: { - CustomizeData: { - name: "[PC preview] unknown name", - value: "[PC preview] unknown value", - } - } - } + moduleInfos: [{ + moduleName: "[PC preview] unknown moduleName", + moduleSourceDir: "[PC preview] unknown moduleSourceDir", + }], + flags: "[PC preview] unknown flags", + entryDir: "[PC preview] unknown entryDir", + codePath: "[PC preview] unknown codePath", + metaData: [{ + name: "[PC preview] unknown name", + value: "[PC preview] unknown value", + extra: "[PC preview] unknown extra", + }], + metadata: [{ + name: "[PC preview] unknown name", + value: "[PC preview] unknown value", + resource: "[PC preview] unknown resource", + }], + removable: "[PC preview] unknown removable", + accessTokenId: "[PC preview] unknown accessTokenId", + uid: "[PC preview] unknown uid", + entityType: "[PC preview] unknown entityType", + fingerprint: "[PC preview] unknown fingerprint", + iconResource: { + bundleName: "[PC preview] unknown bundleName", + moduleName: "[PC preview] unknown moduleName", + id: "[PC preview] unknown id", + }, + labelResource: { + bundleName: "[PC preview] unknown bundleName", + moduleName: "[PC preview] unknown moduleName", + id: "[PC preview] unknown id", + }, + descriptionResource: { + bundleName: "[PC preview] unknown bundleName", + moduleName: "[PC preview] unknown moduleName", + id: "[PC preview] unknown id", + }, + appDistributionType: "[PC preview] unknown appDistributionType", + appProvisionType: "[PC preview] unknown appProvisionType", }, elementName: { deviceId: "[PC preview] unknown deviceId", @@ -38,6 +77,7 @@ export const LauncherAbilityInfoMock = { abilityName: "[PC preview] unknown abilityName", uri: "[PC preview] unknown uri", shortName: "[PC preview] unknown shortName", + moduleName: "[PC preview] unknown moduleName", }, labelId: "[PC preview] unknown labelId", iconId: "[PC preview] unknown iconId", From 11091dce54311d4d2f152787d2c9f0647e265eec Mon Sep 17 00:00:00 2001 From: ql Date: Wed, 6 Jul 2022 08:27:42 +0000 Subject: [PATCH 028/109] update runtime/main/extend/systemplugin/napi/ohos_distributedMissionManager.js. Signed-off-by: ql --- .../systemplugin/napi/ohos_distributedMissionManager.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/runtime/main/extend/systemplugin/napi/ohos_distributedMissionManager.js b/runtime/main/extend/systemplugin/napi/ohos_distributedMissionManager.js index f98c30e2..7ee24615 100755 --- a/runtime/main/extend/systemplugin/napi/ohos_distributedMissionManager.js +++ b/runtime/main/extend/systemplugin/napi/ohos_distributedMissionManager.js @@ -24,7 +24,7 @@ export function mockDistributedMissionManager() { if (typeof args[len - 1] === 'function') { args[len - 1].call(this, paramMock.businessErrorMock); } else { - return new Promise((resolve) => { + return new Promise((resolve,reject) => { resolve(); }); } @@ -36,7 +36,7 @@ export function mockDistributedMissionManager() { if (typeof args[len - 1] === 'function') { args[len - 1].call(this, paramMock.businessErrorMock); } else { - return new Promise((resolve) => { + return new Promise((resolve,reject) => { resolve(); }); } @@ -48,7 +48,7 @@ export function mockDistributedMissionManager() { if (typeof args[len - 1] === 'function') { args[len - 1].call(this, paramMock.businessErrorMock); } else { - return new Promise((resolve) => { + return new Promise((resolve,reject) => { resolve(); }); } @@ -60,7 +60,7 @@ export function mockDistributedMissionManager() { if (typeof args[len - 1] === 'function') { args[len - 1].call(this, paramMock.businessErrorMock); } else { - return new Promise((resolve) => { + return new Promise((resolve,reject) => { resolve(); }); } From 201550ff7363ba7a7657b473f451599434e547e2 Mon Sep 17 00:00:00 2001 From: ql Date: Wed, 6 Jul 2022 08:33:46 +0000 Subject: [PATCH 029/109] update runtime/main/extend/systemplugin/napi/ohos_distributedMissionManager.js. Signed-off-by: ql --- .../systemplugin/napi/ohos_distributedMissionManager.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/runtime/main/extend/systemplugin/napi/ohos_distributedMissionManager.js b/runtime/main/extend/systemplugin/napi/ohos_distributedMissionManager.js index 7ee24615..9990e237 100755 --- a/runtime/main/extend/systemplugin/napi/ohos_distributedMissionManager.js +++ b/runtime/main/extend/systemplugin/napi/ohos_distributedMissionManager.js @@ -24,7 +24,7 @@ export function mockDistributedMissionManager() { if (typeof args[len - 1] === 'function') { args[len - 1].call(this, paramMock.businessErrorMock); } else { - return new Promise((resolve,reject) => { + return new Promise((resolve, reject) => { resolve(); }); } @@ -36,7 +36,7 @@ export function mockDistributedMissionManager() { if (typeof args[len - 1] === 'function') { args[len - 1].call(this, paramMock.businessErrorMock); } else { - return new Promise((resolve,reject) => { + return new Promise((resolve, reject) => { resolve(); }); } @@ -48,7 +48,7 @@ export function mockDistributedMissionManager() { if (typeof args[len - 1] === 'function') { args[len - 1].call(this, paramMock.businessErrorMock); } else { - return new Promise((resolve,reject) => { + return new Promise((resolve, reject) => { resolve(); }); } @@ -60,7 +60,7 @@ export function mockDistributedMissionManager() { if (typeof args[len - 1] === 'function') { args[len - 1].call(this, paramMock.businessErrorMock); } else { - return new Promise((resolve,reject) => { + return new Promise((resolve, reject) => { resolve(); }); } From e6f1fc0f7ec3aab54925554d33f36fd95525e56e Mon Sep 17 00:00:00 2001 From: yanwenhao Date: Wed, 29 Jun 2022 16:28:03 +0800 Subject: [PATCH 030/109] Add formExtensionContext::startAbility jsMock Signed-off-by: yanwenhao Change-Id: I7381e99adb3a40df6112e021b13415068030eb6c --- .../napi/ohos_application_FormExtension.js | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/runtime/main/extend/systemplugin/napi/ohos_application_FormExtension.js b/runtime/main/extend/systemplugin/napi/ohos_application_FormExtension.js index 0062016c..64a7de63 100644 --- a/runtime/main/extend/systemplugin/napi/ohos_application_FormExtension.js +++ b/runtime/main/extend/systemplugin/napi/ohos_application_FormExtension.js @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021 Huawei Device Co., Ltd. + * Copyright (c) 2021-2022 Huawei Device Co., Ltd. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at @@ -36,7 +36,19 @@ export function mockFormExtension() { resolve(); }) } - } + }; + this.startAbility = function (...args) { + console.warn("formExtension.formExtensionContext.startAbility interface mocked in the Previewer." + + " How this interface works on the Previewer may be different from that on a real device."); + const len = args.length; + if (len > 0 && typeof args[len - 1] === 'function') { + args[len - 1].call(this, paramMock.businessErrorMock); + } else { + return new Promise((resolve, reject) => { + resolve(); + }) + } + }; } } const formExtensionClass = class formExtension { @@ -71,5 +83,5 @@ export function mockFormExtension() { }; } } - return new formExtensionClass(); + return formExtensionClass; } \ No newline at end of file From 6a36ef10a1a2849bf90799e7520c9c49b33955c9 Mon Sep 17 00:00:00 2001 From: liuyanzhi Date: Wed, 6 Jul 2022 17:16:32 +0800 Subject: [PATCH 031/109] add notification mock Signed-off-by: liuyanzhi Change-Id: Ie2dc4787d78cb6de4c8c3a7374aa7645bd274ff9 --- .../systemplugin/napi/ohos_commonEvent.js | 12 +++++ .../systemplugin/napi/ohos_notification.js | 48 ++++++++++++++++--- 2 files changed, 54 insertions(+), 6 deletions(-) diff --git a/runtime/main/extend/systemplugin/napi/ohos_commonEvent.js b/runtime/main/extend/systemplugin/napi/ohos_commonEvent.js index 43f94185..07f1fdd7 100644 --- a/runtime/main/extend/systemplugin/napi/ohos_commonEvent.js +++ b/runtime/main/extend/systemplugin/napi/ohos_commonEvent.js @@ -163,6 +163,18 @@ export function mockCommonEvent() { }); } }, + finishCommonEvent: function (...args) { + console.warn('CommonEventSubscriber.finishCommonEvent interface mocked in the Previewer. How this interface works on the' + + ' Previewer may be different from that on a real device.'); + const len = args.length; + if (typeof args[len - 1] === 'function') { + args[len - 1].call(this, paramMock.businessErrorMock); + } else { + return new Promise((resolve, reject) => { + resolve(); + }); + } + }, } const commonEvent = { publish: function (...args) { diff --git a/runtime/main/extend/systemplugin/napi/ohos_notification.js b/runtime/main/extend/systemplugin/napi/ohos_notification.js index ec3660b2..db6bddc7 100644 --- a/runtime/main/extend/systemplugin/napi/ohos_notification.js +++ b/runtime/main/extend/systemplugin/napi/ohos_notification.js @@ -317,6 +317,18 @@ export function mockNotification() { }); } }, + publishAsBundle: function (...args) { + console.warn('notification.publishAsBundle interface mocked in the Previewer. How this interface works on the' + + ' Previewer may be different from that on a 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(); + }); + } + }, 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.'); @@ -329,6 +341,18 @@ export function mockNotification() { }); } }, + cancelAsBundle: function (...args) { + console.warn('notification.cancelAsBundle interface mocked in the Previewer. How this interface works on the' + + ' Previewer may be different from that on a 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(); + }); + } + }, 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.'); @@ -653,8 +677,20 @@ export function mockNotification() { }) } }, - isNotificationEnabledSelf: function (...args) { - console.warn("notification.isNotificationEnabledSelf interface mocked in the Previewer. How this interface works on the" + + requestEnableNotification: function (...args) { + console.warn("notification.requestEnableNotification interface mocked in the Previewer. How this interface works on the" + + " Previewer may be different from 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(); + }) + } + }, + isNotificationSlotEnabled: function (...args) { + console.warn("notification.isNotificationSlotEnabled interface mocked in the Previewer. How this interface works on the" + " Previewer may be different from that on a real device.") const len = args.length if (len > 0 && typeof args[len - 1] === 'function') { @@ -665,8 +701,8 @@ export function mockNotification() { }) } }, - requestEnableNotification: function (...args) { - console.warn("notification.requestEnableNotification interface mocked in the Previewer. How this interface works on the" + + setSyncNotificationEnabledForUninstallApp: function (...args) { + console.warn("notification.setSyncNotificationEnabledForUninstallApp interface mocked in the Previewer. How this interface works on the" + " Previewer may be different from that on a real device.") const len = args.length if (len > 0 && typeof args[len - 1] === 'function') { @@ -689,8 +725,8 @@ export function mockNotification() { }) } }, - isNotificationSlotEnabled: function (...args) { - console.warn("notification.isNotificationSlotEnabled interface mocked in the Previewer. How this interface works on the" + + getSyncNotificationEnabledForUninstallApp: function (...args) { + console.warn("notification.getSyncNotificationEnabledForUninstallApp interface mocked in the Previewer. How this interface works on the" + " Previewer may be different from that on a real device.") const len = args.length if (len > 0 && typeof args[len - 1] === 'function') { From 3183a8b3ac1aed1a5c1d6e247b148d29eb602146 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=BB=96=E5=BA=B7=E5=BA=B7?= Date: Wed, 6 Jul 2022 20:33:19 +0800 Subject: [PATCH 032/109] =?UTF-8?q?=E6=8F=90=E9=86=92=E4=BB=A3=E7=90=86moc?= =?UTF-8?q?k=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 廖康康 --- .../systemplugin/napi/ohos_reminderAgent.js | 75 ++++++++++++++++--- 1 file changed, 66 insertions(+), 9 deletions(-) diff --git a/runtime/main/extend/systemplugin/napi/ohos_reminderAgent.js b/runtime/main/extend/systemplugin/napi/ohos_reminderAgent.js index 8e69469b..609b0a16 100644 --- a/runtime/main/extend/systemplugin/napi/ohos_reminderAgent.js +++ b/runtime/main/extend/systemplugin/napi/ohos_reminderAgent.js @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021 Huawei Device Co., Ltd. + * Copyright (c) 2021-2022 Huawei Device Co., Ltd. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at @@ -17,15 +17,15 @@ import { paramMock } from "../utils" export function mockReminderAgent() { const infoMock = { - reminderId: 1, + reminderId: "[PC preview] unknown reminderId", info: "[PC preview] unknown info" } const reminderReq = { - reminderType: 1, + reminderType: "[PC preview] unknown reminderType", actionButton: [ { title: "[PC preview] unknown title", - type: 0 + type: "[PC preview] unknown type" } ], wantAgent: { @@ -36,20 +36,77 @@ export function mockReminderAgent() { pkgName: "[PC preview] unknown pkg name", abilityName: "[PC preview] unknown ability name" }, - ringDuration: 1, - snoozeTimes: 1, - timeInterval: 1, + ringDuration: "[PC preview] unknown ringDuration", + snoozeTimes: "[PC preview] unknown snoozeTimes", + timeInterval: "[PC preview] unknown timeInterval", title: "[PC preview] unknown title", content: "[PC preview] unknown content", expiredContent: "[PC preview] unknown expiredContent", snoozeContent: "[PC preview] unknown snoozeContent", - notificationId: 1, - slotType: 3 + notificationId: "[PC preview] unknown notificationId", + slotType: "[PC preview] unknown slotType" } const reminderReqs = [ reminderReq ] + const ActionButton = { + title: "[PC preview] unknown title", + type: "[PC preview] unknown type" + } + const WantAgent = { + pkgName: "[PC preview] unknown pkgName", + abilityName: "[PC preview] unknown abilityName" + } + const MaxScreenWantAgent = { + pkgName: "[PC preview] unknown pkgName", + abilityName: "[PC preview] unknown abilityName" + } + const ReminderRequest = { + reminderType: "[PC preview] unknown reminderType", + actionButton: ActionButton, + wantAgent: WantAgent, + maxScreenWantAgent: MaxScreenWantAgent, + ringDuration: "[PC preview] unknown ringDuration", + snoozeTimes: "[PC preview] unknown snoozeTimes", + timeInterval: "[PC preview] unknown timeInterval", + title: "[PC preview] unknown title", + content: "[PC preview] unknown content", + expiredContent: "[PC preview] unknown expiredContent", + snoozeContent: "[PC preview] unknown snoozeContent", + notificationId: "[PC preview] unknown notificationId", + slotType: "[PC preview] unknown slotType" + } + const ReminderRequestCalendar = { + dateTime: LocalDateTime, + repeatMonths: "[PC preview] unknown repeatMonths", + repeatDays: "[PC preview] unknown repeatDays" + } + const ReminderRequestAlarm = { + hour: "[PC preview] unknown hour", + minute: "[PC preview] unknown minute", + daysOfWeek: "[PC preview] unknown daysOfWeek" + } + const ReminderRequestTimer = { + triggerTimeInSeconds: "[PC preview] unknown triggerTimeInSeconds" + } + const LocalDateTime = { + year: "[PC preview] unknown year", + month: "[PC preview] unknown month", + day: "[PC preview] unknown day", + hour: "[PC preview] unknown hour", + minute: "[PC preview] unknown minute", + second: "[PC preview] unknown second" + } const reminderAgent = { + ActionButtonType: { + ACTION_BUTTON_TYPE_CLOSE: 0, + ACTION_BUTTON_TYPE_SNOOZE: 1 + }, + ReminderType: { + REMINDER_TYPE_TIMER: 0, + REMINDER_TYPE_CALENDAR: 1, + REMINDER_TYPE_ALARM: 2 + }, publishReminder: function (...args) { console.warn("reminderAgent.publishReminder interface mocked in the Previewer." + "How this interface works on the Previewer may be different from that on a real device.") From 22aff5d5e472a882ddd9e97a2627175b046f805a Mon Sep 17 00:00:00 2001 From: magekkkk Date: Wed, 6 Jul 2022 20:44:47 +0800 Subject: [PATCH 033/109] add js mock for audio stream listener apis Signed-off-by: magekkkk --- .../napi/ohos_multimedia_audio.js | 313 ++++++++++++------ 1 file changed, 204 insertions(+), 109 deletions(-) diff --git a/runtime/main/extend/systemplugin/napi/ohos_multimedia_audio.js b/runtime/main/extend/systemplugin/napi/ohos_multimedia_audio.js index a85b21bc..e0d4e5fd 100644 --- a/runtime/main/extend/systemplugin/napi/ohos_multimedia_audio.js +++ b/runtime/main/extend/systemplugin/napi/ohos_multimedia_audio.js @@ -27,6 +27,27 @@ export function mockMultimediaAudio() { const AudioDeviceDescriptorMock = { deviceRole: DeviceRoleMock, deviceType: DeviceTypeMock, + id: "[PC Preview] unknow id", + name: "[PC Preview] unknow name", + address: "[PC Preview] unknow address", + sampleRates: function () { + console.warn("AudioDeviceDescriptorMock.sampleRates interface mocked in the Previewer." + + " How this interface works on the Previewer may be different from that on a real device.") + var sampleRatesArray = new Array(); + return sampleRatesArray; + }, + channelCounts: function () { + console.warn("AudioDeviceDescriptorMock.channelCounts interface mocked in the Previewer." + + " How this interface works on the Previewer may be different from that on a real device.") + var channelCountsArray = new Array(); + return channelCountsArray; + }, + channelMasks: function () { + console.warn("AudioDeviceDescriptorMock.channelMasks interface mocked in the Previewer." + + " How this interface works on the Previewer may be different from that on a real device.") + var channelMasksArray = new Array(); + return channelMasksArray; + }, } const DeviceChangeActionMock = { type: "[PC Preview] unknow type", @@ -65,11 +86,35 @@ export function mockMultimediaAudio() { const AudioStateMock = '[PC Preview] unknow AudioState' const AudioRendererRateMock = '[PC Preview] unknow AudioRendererRate' const InterruptEventMock = '[PC Preview] unknow InterruptEvent' + const AudioRendererChangeInfoMock = { + streamId: "[PC Preview] unknow streamId", + clientUid: "[PC Preview] unknow clientUid", + rendererInfo: AudioRendererInfoMock, + rendererState: AudioStateMock, + deviceDescriptors: function () { + console.warn("AudioRendererChangeInfoMock.deviceDescriptors interface mocked in the Previewer." + + " How this interface works on the Previewer may be different from that on a real device.") + var audioDeviceDescriptors = new Array(AudioDeviceDescriptorMock); + return audioDeviceDescriptors; + }, + } + const AudioCapturerChangeInfoMock = { + streamId: "[PC Preview] unknow streamId", + clientUid: "[PC Preview] unknow clientUid", + capturerInfo: AudioRendererInfoMock, + capturerState: AudioStateMock, + deviceDescriptors: function () { + console.warn("AudioCapturerChangeInfoMock.deviceDescriptors interface mocked in the Previewer." + + " How this interface works on the Previewer may be different from that on a real device.") + var audioDeviceDescriptors = new Array(AudioDeviceDescriptorMock); + return audioDeviceDescriptors; + }, + } const AudioCapturerMock = { state: "[PC Preview] unknow state", getCapturerInfo: function (...args) { - console.warn("AudioCapturer.getCapturerInfo interface mocked in the Previewer. How this interface works on the" + - " Previewer may be different from that on a real device.") + console.warn("AudioCapturer.getCapturerInfo interface mocked in the Previewer." + + " How this interface works on the Previewer may be different from that on a real device.") const len = args.length if (typeof args[len - 1] === 'function') { args[len - 1].call(this, paramMock.businessErrorMock, AudioCapturerInfoMock); @@ -80,8 +125,8 @@ export function mockMultimediaAudio() { } }, getStreamInfo: function (...args) { - console.warn("AudioCapturer.getStreamInfo interface mocked in the Previewer. How this interface works on the" + - " Previewer may be different from that on a real device.") + console.warn("AudioCapturer.getStreamInfo interface mocked in the Previewer." + + " How this interface works on the Previewer may be different from that on a real device.") const len = args.length if (typeof args[len - 1] === 'function') { args[len - 1].call(this, paramMock.businessErrorMock, AudioStreamInfoMock); @@ -92,8 +137,8 @@ export function mockMultimediaAudio() { } }, start: function (...args) { - console.warn("AudioCapturer.start interface mocked in the Previewer. How this interface works on the" + - " Previewer may be different from that on a real device.") + console.warn("AudioCapturer.start interface mocked in the Previewer." + + " How this interface works on the Previewer may be different from that on a real device.") const len = args.length if (typeof args[len - 1] === 'function') { args[len - 1].call(this, paramMock.businessErrorMock); @@ -104,8 +149,8 @@ export function mockMultimediaAudio() { } }, read: function (...args) { - console.warn("AudioCapturer.read interface mocked in the Previewer. How this interface works on the" + - " Previewer may be different from that on a real device.") + console.warn("AudioCapturer.read interface mocked in the Previewer." + + " How this interface works on the Previewer may be different 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); @@ -116,8 +161,8 @@ export function mockMultimediaAudio() { } }, getAudioTime: function (...args) { - console.warn("AudioCapturer.getAudioTime interface mocked in the Previewer. How this interface works on the" + - " Previewer may be different from that on a real device.") + console.warn("AudioCapturer.getAudioTime interface mocked in the Previewer." + + " How this interface works on the Previewer may be different 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); @@ -128,8 +173,8 @@ export function mockMultimediaAudio() { } }, stop: function (...args) { - console.warn("AudioCapturer.stop interface mocked in the Previewer. How this interface works on the" + - " Previewer may be different from that on a real device.") + console.warn("AudioCapturer.stop interface mocked in the Previewer." + + " How this interface works on the Previewer may be different from that on a real device.") const len = args.length if (typeof args[len - 1] === 'function') { args[len - 1].call(this, paramMock.businessErrorMock); @@ -140,8 +185,8 @@ export function mockMultimediaAudio() { } }, release: function (...args) { - console.warn("AudioCapturer.release interface mocked in the Previewer. How this interface works on the" + - " Previewer may be different from that on a real device.") + console.warn("AudioCapturer.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); @@ -152,8 +197,8 @@ export function mockMultimediaAudio() { } }, getBufferSize: function (...args) { - console.warn("AudioCapturer.getBufferSize interface mocked in the Previewer. How this interface works on the" + - " Previewer may be different from that on a real device.") + console.warn("AudioCapturer.getBufferSize interface mocked in the Previewer." + + " How this interface works on the Previewer may be different 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); @@ -164,19 +209,19 @@ export function mockMultimediaAudio() { } }, on: function (...args) { - console.warn("AudioCapturer.on interface mocked in the Previewer. How this interface works on the Previewer" + - " may be different from that on a real device.") + console.warn("AudioCapturer.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("AudioCapturer.off interface mocked in the Previewer. How this interface works on the Previewer" + - " may be different from that on a real device.") + console.warn("AudioCapturer.off interface mocked in the Previewer." + + " How this interface works on the Previewer may be different from that on a real device.") }, } const AudioRendererMock ={ state: "[PC Preview] unknow state", getRendererInfo: function (...args) { - console.warn("AudioRenderer.getRendererInfo interface mocked in the Previewer. How this interface works on the" + - " Previewer may be different from that on a real device.") + console.warn("AudioRenderer.getRendererInfo interface mocked in the Previewer." + + " How this interface works on the Previewer may be different from that on a real device.") const len = args.length if (typeof args[len - 1] === 'function') { args[len - 1].call(this, paramMock.businessErrorMock, AudioRendererInfoMock); @@ -187,8 +232,8 @@ export function mockMultimediaAudio() { } }, getStreamInfo: function (...args) { - console.warn("AudioRenderer.getStreamInfo interface mocked in the Previewer. How this interface works on the" + - " Previewer may be different from that on a real device.") + console.warn("AudioRenderer.getStreamInfo interface mocked in the Previewer." + + " How this interface works on the Previewer may be different from that on a real device.") const len = args.length if (typeof args[len - 1] === 'function') { args[len - 1].call(this, paramMock.businessErrorMock, AudioStreamInfoMock); @@ -199,8 +244,8 @@ export function mockMultimediaAudio() { } }, start: function (...args) { - console.warn("AudioRenderer.start interface mocked in the Previewer. How this interface works on the" + - " Previewer may be different from that on a real device.") + console.warn("AudioRenderer.start interface mocked in the Previewer." + + " How this interface works on the Previewer may be different from that on a real device.") const len = args.length if (typeof args[len - 1] === 'function') { args[len - 1].call(this, paramMock.businessErrorMock); @@ -211,8 +256,8 @@ export function mockMultimediaAudio() { } }, write: function (...args) { - console.warn("AudioRenderer.write interface mocked in the Previewer. How this interface works on the" + - " Previewer may be different from that on a real device.") + console.warn("AudioRenderer.write interface mocked in the Previewer." + + " How this interface works on the Previewer may be different 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); @@ -223,8 +268,8 @@ export function mockMultimediaAudio() { } }, getAudioTime: function (...args) { - console.warn("AudioRenderer.getAudioTime interface mocked in the Previewer. How this interface works on the" + - " Previewer may be different from that on a real device.") + console.warn("AudioRenderer.getAudioTime interface mocked in the Previewer." + + " How this interface works on the Previewer may be different 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); @@ -235,8 +280,8 @@ export function mockMultimediaAudio() { } }, drain: function (...args) { - console.warn("AudioRenderer.drain interface mocked in the Previewer. How this interface works on the" + - " Previewer may be different from that on a real device.") + console.warn("AudioRenderer.drain interface mocked in the Previewer." + + " How this interface works on the Previewer may be different from that on a real device.") const len = args.length if (typeof args[len - 1] === 'function') { args[len - 1].call(this, paramMock.businessErrorMock); @@ -247,8 +292,8 @@ export function mockMultimediaAudio() { } }, pause: function (...args) { - console.warn("AudioRenderer.pause interface mocked in the Previewer. How this interface works on the" + - " Previewer may be different from that on a real device.") + console.warn("AudioRenderer.pause interface mocked in the Previewer." + + " How this interface works on the Previewer may be different from that on a real device.") const len = args.length if (typeof args[len - 1] === 'function') { args[len - 1].call(this, paramMock.businessErrorMock); @@ -259,8 +304,8 @@ export function mockMultimediaAudio() { } }, stop: function (...args) { - console.warn("AudioRenderer.stop interface mocked in the Previewer. How this interface works on the" + - " Previewer may be different from that on a real device.") + console.warn("AudioRenderer.stop interface mocked in the Previewer." + + " How this interface works on the Previewer may be different from that on a real device.") const len = args.length if (typeof args[len - 1] === 'function') { args[len - 1].call(this, paramMock.businessErrorMock); @@ -271,8 +316,8 @@ export function mockMultimediaAudio() { } }, release: function (...args) { - console.warn("AudioRenderer.release interface mocked in the Previewer. How this interface works on the" + - " Previewer may be different from that on a real device.") + console.warn("AudioRenderer.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); @@ -283,8 +328,8 @@ export function mockMultimediaAudio() { } }, getBufferSize: function (...args) { - console.warn("AudioRenderer.getBufferSize interface mocked in the Previewer. How this interface works on the" + - " Previewer may be different from that on a real device.") + console.warn("AudioRenderer.getBufferSize interface mocked in the Previewer." + + " How this interface works on the Previewer may be different 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); @@ -295,8 +340,8 @@ export function mockMultimediaAudio() { } }, setRenderRate: function (...args) { - console.warn("AudioRenderer.setRenderRate interface mocked in the Previewer. How this interface works on the" + - " Previewer may be different from that on a real device.") + console.warn("AudioRenderer.setRenderRate interface mocked in the Previewer." + + " How this interface works on the Previewer may be different from that on a real device.") const len = args.length if (typeof args[len - 1] === 'function') { args[len - 1].call(this, paramMock.businessErrorMock); @@ -307,8 +352,8 @@ export function mockMultimediaAudio() { } }, getRenderRate: function (...args) { - console.warn("AudioRenderer.getRenderRate interface mocked in the Previewer. How this interface works on the" + - " Previewer may be different from that on a real device.") + console.warn("AudioRenderer.getRenderRate interface mocked in the Previewer." + + " How this interface works on the Previewer may be different from that on a real device.") const len = args.length if (typeof args[len - 1] === 'function') { args[len - 1].call(this, paramMock.businessErrorMock, AudioRendererRateMock); @@ -319,16 +364,16 @@ export function mockMultimediaAudio() { } }, on: function (...args) { - console.warn("AudioRenderer.on interface mocked in the Previewer. How this interface works on the Previewer" + - " may be different from that on a real device.") + console.warn("AudioRenderer.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("AudioRenderer.off interface mocked in the Previewer. How this interface works on the Previewer" + - " may be different from that on a real device.") + console.warn("AudioRenderer.off interface mocked in the Previewer." + + " How this interface works on the Previewer may be different from that on a real device.") }, setInterruptMode: function (...args) { - console.warn("AudioRenderer.setInterruptMode interface mocked in the Previewer. How this interface works on the" + - " Previewer may be different from that on a real device.") + console.warn("AudioRenderer.setInterruptMode interface mocked in the Previewer." + + " How this interface works on the Previewer may be different from that on a real device.") const len = args.length if (typeof args[len - 1] === 'function') { args[len - 1].call(this, paramMock.businessErrorMock); @@ -339,10 +384,10 @@ export function mockMultimediaAudio() { } } } - const audioManagerMock = { + const AudioManagerMock = { on: function (...args) { - console.warn("AudioManager.on interface mocked in the Previewer. How this interface works on the Previewer" + - " may be different from that on a real device.") + console.warn("AudioManager.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] == 'interrupt') { @@ -357,12 +402,12 @@ export function mockMultimediaAudio() { } }, off: function (...args) { - console.warn("AudioManager.off interface mocked in the Previewer. How this interface works on the Previewer" + - " may be different from that on a real device.") + console.warn("AudioManager.off interface mocked in the Previewer." + + " How this interface works on the Previewer may be different from that on a real device.") }, getDevices: function (...args) { - console.warn("AudioManager.getDevices interface mocked in the Previewer. How this interface works on the" + - " Previewer may be different from that on a real device.") + console.warn("AudioManager.getDevices interface mocked in the Previewer." + + " How this interface works on the Previewer may be different from that on a real device.") var AudioDeviceDescriptors = new Array(AudioDeviceDescriptorMock) const len = args.length if (typeof args[len - 1] === 'function') { @@ -374,8 +419,8 @@ export function mockMultimediaAudio() { } }, isDeviceActive: function (...args) { - console.warn("AudioManager.isDeviceActive interface mocked in the Previewer. How this interface works on" + - " the Previewer may be different from that on a real device.") + console.warn("AudioManager.isDeviceActive interface mocked in the Previewer." + + " How this interface works on the Previewer may be different 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); @@ -386,8 +431,8 @@ export function mockMultimediaAudio() { } }, setDeviceActive: function (...args) { - console.warn("AudioManager.setDeviceActive interface mocked in the Previewer. How this interface works on the" + - " Previewer may be different from that on a real device.") + console.warn("AudioManager.setDeviceActive interface mocked in the Previewer." + + " How this interface works on the Previewer may be different from that on a real device.") const len = args.length if (typeof args[len - 1] === 'function') { args[len - 1].call(this, paramMock.businessErrorMock); @@ -398,8 +443,8 @@ export function mockMultimediaAudio() { } }, setRingerMode: function (...args) { - console.warn("AudioManager.setRingerMode interface mocked in the Previewer. How this interface works on the" + - " Previewer may be different from that on a real device.") + console.warn("AudioManager.setRingerMode interface mocked in the Previewer." + + " How this interface works on the Previewer may be different from that on a real device.") const len = args.length if (typeof args[len - 1] === 'function') { args[len - 1].call(this, paramMock.businessErrorMock); @@ -410,8 +455,8 @@ export function mockMultimediaAudio() { } }, setAudioParameter: function (...args) { - console.warn("AudioManager.setAudioParameter interface mocked in the Previewer. How this interface works on the" + - " Previewer may be different from that on a real device.") + console.warn("AudioManager.setAudioParameter interface mocked in the Previewer." + + " How this interface works on the Previewer may be different from that on a real device.") const len = args.length if (typeof args[len - 1] === 'function') { args[len - 1].call(this, paramMock.businessErrorMock); @@ -422,8 +467,8 @@ export function mockMultimediaAudio() { } }, setVolume: function (...args) { - console.warn("AudioManager.setVolume interface mocked in the Previewer. How this interface works on the" + - " Previewer may be different from that on a real device.") + console.warn("AudioManager.setVolume interface mocked in the Previewer." + + " How this interface works on the Previewer may be different from that on a real device.") const len = args.length if (typeof args[len - 1] === 'function') { args[len - 1].call(this, paramMock.businessErrorMock); @@ -434,8 +479,8 @@ export function mockMultimediaAudio() { } }, getVolume: function (...args) { - console.warn("AudioManager.getVolume interface mocked in the Previewer. How this interface works on the" + - " Previewer may be different from that on a real device.") + console.warn("AudioManager.getVolume interface mocked in the Previewer." + + " How this interface works on the Previewer may be different 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); @@ -446,8 +491,8 @@ export function mockMultimediaAudio() { } }, getMinVolume: function (...args) { - console.warn("AudioManager.getMinVolume interface mocked in the Previewer. How this interface works on the" + - " Previewer may be different from that on a real device.") + console.warn("AudioManager.getMinVolume interface mocked in the Previewer." + + " How this interface works on the Previewer may be different 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); @@ -458,8 +503,8 @@ export function mockMultimediaAudio() { } }, getMaxVolume: function (...args) { - console.warn("AudioManager.getMaxVolume interface mocked in the Previewer. How this interface works on the" + - " Previewer may be different from that on a real device.") + console.warn("AudioManager.getMaxVolume interface mocked in the Previewer." + + " How this interface works on the Previewer may be different 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); @@ -470,8 +515,8 @@ export function mockMultimediaAudio() { } }, isMute: function (...args) { - console.warn("AudioManager.isMute interface mocked in the Previewer. How this interface works on the" + - " Previewer may be different from that on a real device.") + console.warn("AudioManager.isMute interface mocked in the Previewer." + + " How this interface works on the Previewer may be different 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); @@ -482,8 +527,8 @@ export function mockMultimediaAudio() { } }, mute: function (...args) { - console.warn("AudioManager.mute interface mocked in the Previewer. How this interface works on the" + - " Previewer may be different from that on a real device.") + console.warn("AudioManager.mute interface mocked in the Previewer." + + " How this interface works on the Previewer may be different from that on a real device.") const len = args.length if (typeof args[len - 1] === 'function') { args[len - 1].call(this, paramMock.businessErrorMock); @@ -494,8 +539,8 @@ export function mockMultimediaAudio() { } }, isActive: function (...args) { - console.warn("AudioManager.isActive interface mocked in the Previewer. How this interface works on the" + - " Previewer may be different from that on a real device.") + console.warn("AudioManager.isActive interface mocked in the Previewer." + + " How this interface works on the Previewer may be different from that on a real device.") const len = args.length if (typeof args[len - 1] === 'function') { args[len - 1].call(this, paramMock.businessErrorMock, paramMock.paramBooleanMock); @@ -506,8 +551,8 @@ export function mockMultimediaAudio() { } }, isMicrophoneMute: function (...args) { - console.warn("AudioManager.isMicrophoneMute interface mocked in the Previewer. How this interface works on the" + - " Previewer may be different from that on a real device.") + console.warn("AudioManager.isMicrophoneMute interface mocked in the Previewer." + + " How this interface works on the Previewer may be different 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); @@ -518,8 +563,8 @@ export function mockMultimediaAudio() { } }, setMicrophoneMute: function (...args) { - console.warn("AudioManager.setMicrophoneMute interface mocked in the Previewer. How this interface works on the" + - " Previewer may be different from that on a real device.") + console.warn("AudioManager.setMicrophoneMute interface mocked in the Previewer." + + " How this interface works on the Previewer may be different from that on a real device.") const len = args.length if (typeof args[len - 1] === 'function') { args[len - 1].call(this, paramMock.businessErrorMock); @@ -530,8 +575,8 @@ export function mockMultimediaAudio() { } }, getAudioParameter: function (...args) { - console.warn("AudioManager.getAudioParameter interface mocked in the Previewer. How this interface works on the" + - " Previewer may be different from that on a real device.") + console.warn("AudioManager.getAudioParameter interface mocked in the Previewer." + + " How this interface works on the Previewer may be different 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); @@ -542,8 +587,8 @@ export function mockMultimediaAudio() { } }, getRingerMode: function (...args) { - console.warn("AudioManager.getRingerMode interface mocked in the Previewer. How this interface works on the" + - " Previewer may be different from that on a real device.") + console.warn("AudioManager.getRingerMode interface mocked in the Previewer." + + " How this interface works on the Previewer may be different from that on a real device.") const len = args.length if (typeof args[len - 1] === 'function') { args[len - 1].call(this, paramMock.businessErrorMock, AudioRingModeMock); @@ -554,8 +599,8 @@ export function mockMultimediaAudio() { } }, setAudioScene: function (...args) { - console.warn("AudioManager.setAudioScene interface mocked in the Previewer. How this interface works on the" + - " Previewer may be different from that on a real device.") + console.warn("AudioManager.setAudioScene interface mocked in the Previewer." + + " How this interface works on the Previewer may be different from that on a real device.") const len = args.length if (typeof args[len - 1] === 'function') { args[len - 1].call(this, paramMock.businessErrorMock); @@ -566,8 +611,8 @@ export function mockMultimediaAudio() { } }, getAudioScene: function (...args) { - console.warn("AudioManager.getAudioScene interface mocked in the Previewer. How this interface works on the" + - " Previewer may be different from that on a real device.") + console.warn("AudioManager.getAudioScene interface mocked in the Previewer." + + " How this interface works on the Previewer may be different from that on a real device.") const len = args.length if (typeof args[len - 1] === 'function') { args[len - 1].call(this, paramMock.businessErrorMock, AudioSceneMock); @@ -578,8 +623,8 @@ export function mockMultimediaAudio() { } }, requestIndependentInterrupt: function (...args) { - console.warn("AudioManager.requestIndependentInterrupt interface mocked in the Previewer. How this interface works on the" + - " Previewer may be different from that on a real device.") + console.warn("AudioManager.requestIndependentInterrupt interface mocked in the Previewer." + + " How this interface works on the Previewer may be different 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); @@ -590,8 +635,8 @@ export function mockMultimediaAudio() { } }, abandonIndependentInterrupt: function (...args) { - console.warn("AudioManager.abandonIndependentInterrupt interface mocked in the Previewer. How this interface works on the" + - " Previewer may be different from that on a real device.") + console.warn("AudioManager.abandonIndependentInterrupt interface mocked in the Previewer." + + " How this interface works on the Previewer may be different 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); @@ -600,6 +645,62 @@ export function mockMultimediaAudio() { resolve(paramMock.paramBooleanMock); }) } + }, + getStreamManager: function (...args) { + console.warn("AudioManager.getStreamManager interface mocked in the Previewer." + + " How this interface works on the Previewer may be different from that on a real device.") + const len = args.length + if (typeof args[len - 1] === 'function') { + args[len - 1].call(this, paramMock.businessErrorMock, AudioStreamManagerMock); + } else { + return new Promise((resolve, reject) => { + resolve(AudioStreamManagerMock); + }) + } + } + } + const AudioStreamManagerMock = { + on: function (...args) { + const len = args.length + if (typeof args[len - 1] === 'function') { + if (args[0] == 'audioRendererChange') { + console.warn("AudioStreamManager.on_audioRendererChange interface mocked in the Previewer." + + " How this interface works on the Previewer may be different from that on a real device.") + } else if (args[0] == 'audioCapturerChange') { + console.warn("AudioStreamManager.on_audioCapturerChange 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("AudioStreamManager.off interface mocked in the Previewer." + + " How this interface works on the Previewer may be different from that on a real device.") + }, + getCurrentAudioRendererInfoArray: function (...args) { + console.warn("AudioStreamManager.getCurrentAudioRendererInfoArray interface mocked in the Previewer." + + " How this interface works on the Previewer may be different from that on a real device.") + var AudioRendererChangeInfoArray = new Array(AudioRendererChangeInfoMock) + const len = args.length + if (typeof args[len - 1] === 'function') { + args[len - 1].call(this, paramMock.businessErrorMock, AudioRendererChangeInfoArray); + } else { + return new Promise((resolve, reject) => { + resolve(AudioRendererChangeInfoArray); + }) + } + }, + getCurrentAudioCapturerInfoArray: function (...args) { + console.warn("AudioStreamManager.getCurrentAudioCapturerInfoArray interface mocked in the Previewer." + + " How this interface works on the Previewer may be different from that on a real device.") + var AudioCapturerChangeInfoArray = new Array(AudioCapturerChangeInfoMock) + const len = args.length + if (typeof args[len - 1] === 'function') { + args[len - 1].call(this, paramMock.businessErrorMock, AudioCapturerChangeInfoArray); + } else { + return new Promise((resolve, reject) => { + resolve(AudioCapturerChangeInfoArray); + }) + } } } const audio = { @@ -653,6 +754,7 @@ export function mockMultimediaAudio() { SAMPLE_FORMAT_S16LE: 1, SAMPLE_FORMAT_S24LE: 2, SAMPLE_FORMAT_S32LE: 3, + SAMPLE_FORMAT_F32LE: 4, }, AudioChannel: { CHANNEL_1: 1, @@ -691,13 +793,6 @@ export function mockMultimediaAudio() { AUDIO_SCENE_PHONE_CALL: 2, AUDIO_SCENE_VOICE_CHAT: 3, }, - AudioSampleFormat: { - SAMPLE_FORMAT_INVALID: -1, - SAMPLE_FORMAT_U8: 0, - SAMPLE_FORMAT_S16LE: 1, - SAMPLE_FORMAT_S24LE: 2, - SAMPLE_FORMAT_S32LE: 3, - }, InterruptType: { INTERRUPT_TYPE_BEGIN: 1, INTERRUPT_TYPE_END: 2, @@ -714,13 +809,13 @@ export function mockMultimediaAudio() { INDEPENDENT_MODE: 1 }, getAudioManager: function () { - console.warn("audio.getAudioManager interface mocked in the Previewer. How this interface works" + - " on the Previewer may be different from that on a real device.") - return audioManagerMock; + console.warn("audio.getAudioManager interface mocked in the Previewer." + + " How this interface works on the Previewer may be different from that on a real device.") + return AudioManagerMock; }, createAudioCapturer: function (...args) { - console.warn("audio.createAudioCapturer interface mocked in the Previewer. How this interface works on the" + - " Previewer may be different from that on a real device.") + console.warn("audio.createAudioCapturer interface mocked in the Previewer." + + " How this interface works on the Previewer may be different from that on a real device.") const len = args.length if (typeof args[len - 1] === 'function') { args[len - 1].call(this, paramMock.businessErrorMock, AudioCapturerMock); @@ -731,8 +826,8 @@ export function mockMultimediaAudio() { } }, createAudioRenderer: function (...args) { - console.warn("audio.createAudioRenderer interface mocked in the Previewer. How this interface works on the" + - " Previewer may be different from that on a real device.") + console.warn("audio.createAudioRenderer interface mocked in the Previewer." + + " How this interface works on the Previewer may be different from that on a real device.") const len = args.length if (typeof args[len - 1] === 'function') { args[len - 1].call(this, paramMock.businessErrorMock, AudioRendererMock); From 8b73dfbf671b679b19b74a149a42ecd056b690c2 Mon Sep 17 00:00:00 2001 From: liuyanzhi Date: Thu, 7 Jul 2022 08:20:37 +0800 Subject: [PATCH 034/109] add notification API8 mock Signed-off-by: liuyanzhi Change-Id: I537bc0eaeb7c3b0d7babf60585cd030bffc1555b --- .../systemplugin/napi/ohos_notification.js | 66 +++++++++++++++++++ 1 file changed, 66 insertions(+) diff --git a/runtime/main/extend/systemplugin/napi/ohos_notification.js b/runtime/main/extend/systemplugin/napi/ohos_notification.js index db6bddc7..b07fad65 100644 --- a/runtime/main/extend/systemplugin/napi/ohos_notification.js +++ b/runtime/main/extend/systemplugin/napi/ohos_notification.js @@ -290,6 +290,12 @@ export function mockNotification() { source: '[PC preview] unknow source', template: '[PC preview] unknow template' }; + const DeviceRemindType = { + IDLE_DONOT_REMIND: 0, + IDLE_REMIND: 1, + ACTIVE_DONOT_REMIND: 2, + ACTIVE_REMIND: 3, + }; const notification = { SlotType: { UNKNOWN_TYPE: 0, @@ -689,6 +695,66 @@ export function mockNotification() { }) } }, + enableDistributed: function (...args) { + console.warn("notification.enableDistributed interface mocked in the Previewer. How this interface works on the" + + " Previewer may be different from 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(); + }) + } + }, + isDistributedEnabled: function (...args) { + console.warn("notification.isDistributedEnabled interface mocked in the Previewer. How this interface works on the" + + " Previewer may be different from that on a real device.") + const len = args.length + if (len > 0 && typeof args[len - 1] === 'function') { + args[len - 1].call(this, paramMock.businessErrorMock, paramMock.paramBooleanMock); + } else { + return new Promise((resolve, reject) => { + resolve(paramMock.paramBooleanMock); + }) + } + }, + enableDistributedByBundle: function (...args) { + console.warn("notification.enableDistributedByBundle interface mocked in the Previewer. How this interface works on the" + + " Previewer may be different from 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(); + }) + } + }, + isDistributedEnabledByBundle: function (...args) { + console.warn("notification.isDistributedEnabledByBundle interface mocked in the Previewer. How this interface works on the" + + " Previewer may be different from that on a real device.") + const len = args.length + if (len > 0 && typeof args[len - 1] === 'function') { + args[len - 1].call(this, paramMock.businessErrorMock, paramMock.paramBooleanMock); + } else { + return new Promise((resolve, reject) => { + resolve(paramMock.paramBooleanMock); + }) + } + }, + getDeviceRemindType: function (...args) { + console.warn("notification.getDeviceRemindType interface mocked in the Previewer. How this interface works on the" + + " Previewer may be different from that on a real device.") + const len = args.length + if (len > 0 && typeof args[len - 1] === 'function') { + args[len - 1].call(this, paramMock.businessErrorMock, DeviceRemindType); + } else { + return new Promise((resolve, reject) => { + resolve(DeviceRemindType); + }) + } + }, isNotificationSlotEnabled: function (...args) { console.warn("notification.isNotificationSlotEnabled interface mocked in the Previewer. How this interface works on the" + " Previewer may be different from that on a real device.") From 5c0f3a04be0d7dd104328532d2d253bd7e73a322 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=BB=96=E5=BA=B7=E5=BA=B7?= Date: Thu, 7 Jul 2022 10:00:10 +0800 Subject: [PATCH 035/109] =?UTF-8?q?mock=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 廖康康 --- .../napi/ohos_backgroundTaskManager.js | 8 ++-- .../systemplugin/napi/ohos_bundleState.js | 46 +++++++++---------- .../systemplugin/napi/ohos_workScheduler.js | 12 ++--- 3 files changed, 33 insertions(+), 33 deletions(-) diff --git a/runtime/main/extend/systemplugin/napi/ohos_backgroundTaskManager.js b/runtime/main/extend/systemplugin/napi/ohos_backgroundTaskManager.js index 5eacd161..d3e9eebf 100644 --- a/runtime/main/extend/systemplugin/napi/ohos_backgroundTaskManager.js +++ b/runtime/main/extend/systemplugin/napi/ohos_backgroundTaskManager.js @@ -16,7 +16,7 @@ import { paramMock } from "../utils" export function mockBackgroundTaskManager() { - const DelaySuspendInfoMock = { + const DelaySuspendInfo = { requestId: '[PC preview] unknown requestId', actualDelayTime: '[PC preview] unknown actualDelayTime', }; @@ -38,7 +38,7 @@ export function mockBackgroundTaskManager() { const len = args.length; if (typeof args[len - 1] === 'function') { args[len - 1].call(this, paramMock.businessErrorMock) - return DelaySuspendInfoMock; + return DelaySuspendInfo; } }, cancelSuspendDelay: function (...args) { @@ -50,10 +50,10 @@ export function mockBackgroundTaskManager() { " Previewer may be 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) + args[len - 1].call(this, paramMock.businessErrorMock, DelaySuspendInfo.actualDelayTime) } else { return new Promise((resolve) => { - resolve(DelaySuspendInfoMock.actualDelayTime) + resolve(DelaySuspendInfo.actualDelayTime) }); } }, diff --git a/runtime/main/extend/systemplugin/napi/ohos_bundleState.js b/runtime/main/extend/systemplugin/napi/ohos_bundleState.js index 35f75ed3..92d909f3 100644 --- a/runtime/main/extend/systemplugin/napi/ohos_bundleState.js +++ b/runtime/main/extend/systemplugin/napi/ohos_bundleState.js @@ -16,7 +16,7 @@ import { paramMock } from "../utils" export function mockBundleState() { - const bundleStateInfomMock = [{ + const BundleStateInfo = [{ abilityInFgTotalTime: '[PC preview] unknown abilityInFgTotalTime', abilityPrevAccessTime: '[PC preview] unknown abilityPrevAccessTime', abilityPrevSeenTime: '[PC preview] unknown abilityPrevSeenTime', @@ -33,7 +33,7 @@ export function mockBundleState() { " Previewer may be different from that on a real device."); }, }] - const bundleActiveStateMock = [{ + const BundleActiveState = [{ appUsagePriorityGroup: '[PC preview] unknown appUsagePriorityGroup', bundleName: '[PC preview] unknown bundleName', indexOfLink: '[PC preview] unknown indexOfLink', @@ -41,22 +41,22 @@ export function mockBundleState() { stateOccurredTime: '[PC preview] unknown stateOccurredTime', stateType: '[PC preview] unknown stateType', }] - const bundleActiveEventStateMock = [{ + const BundleActiveEventState = [{ name: '[PC preview] unknown name', eventId: '[PC preview] unknown eventId', count: '[PC preview] unknown count', }] - const bundleActiveInfoResponseMock = { - "key": bundleStateInfomMock + const BundleActiveInfoResponse = { + "key": BundleStateInfo } - const BundleActiveGroupCallbackInfoMock = { + const BundleActiveGroupCallbackInfo = { appUsageOldGroup : '[PC preview] unknown appUsageOldGroup', appUsageNewGroup : '[PC preview] unknown appUsageNewGroup', userId : '[PC preview] unknown userId', changeReason : '[PC preview] unknown changeReason', bundleName : '[PC preview] unknown bundleName', } - const BundleActiveModuleInfoMock = { + const BundleActiveModuleInfo = { deviceId : '[PC preview] unknown deviceId', bundleName : '[PC preview] unknown bundleName', moduleName : '[PC preview] unknown moduleName', @@ -71,14 +71,14 @@ export function mockBundleState() { lastModuleUsedTime : '[PC preview] unknown lastModuleUsedTime', formRecords : '[PC preview] unknown formRecords', } - const intervalTypeMock = { + const IntervalType = { BY_OPTIMIZED: 0, BY_DAILY: 1, BY_WEEKLY: 2, BY_MONTHLY: 3, BY_ANNUALLY: 4 } - const groupType = { + const GroupType = { ACTIVE_GROUP_ALIVE : 10, ACTIVE_GROUP_DAILY : 20, ACTIVE_GROUP_FIXED : 30, @@ -116,10 +116,10 @@ export function mockBundleState() { " Previewer may be different from that on a real device."); const len = args.length; if (typeof args[len - 1] === 'function') { - args[len - 1].call(this, paramMock.businessErrorMock, bundleActiveInfoResponseMock); + args[len - 1].call(this, paramMock.businessErrorMock, BundleActiveInfoResponse); } else { return new Promise((resolve) => { - resolve(bundleActiveInfoResponseMock) + resolve(BundleActiveInfoResponse) }); } }, @@ -128,10 +128,10 @@ export function mockBundleState() { " Previewer may be different from that on a real device."); const len = args.length; if (typeof args[len - 1] === 'function') { - args[len - 1].call(this, paramMock.businessErrorMock, bundleStateInfomMock); + args[len - 1].call(this, paramMock.businessErrorMock, BundleStateInfo); } else { return new Promise((resolve) => { - resolve(bundleStateInfomMock) + resolve(BundleStateInfo) }); } }, @@ -140,10 +140,10 @@ export function mockBundleState() { " Previewer may be different from that on a real device."); const len = args.length; if (typeof args[len - 1] === 'function') { - args[len - 1].call(this, paramMock.businessErrorMock, bundleActiveStateMock); + args[len - 1].call(this, paramMock.businessErrorMock, BundleActiveState); } else { return new Promise((resolve) => { - resolve(bundleActiveStateMock) + resolve(BundleActiveState) }); } }, @@ -152,10 +152,10 @@ export function mockBundleState() { " Previewer may be different from that on a real device."); const len = args.length; if (typeof args[len - 1] === 'function') { - args[len - 1].call(this, paramMock.businessErrorMock, bundleActiveStateMock); + args[len - 1].call(this, paramMock.businessErrorMock, BundleActiveState); } else { return new Promise((resolve) => { - resolve(bundleActiveStateMock) + resolve(BundleActiveState) }); } }, @@ -164,10 +164,10 @@ export function mockBundleState() { " Previewer may be different from that on a real device."); const len = args.length; if (typeof args[len - 1] === 'function') { - args[len - 1].call(this, paramMock.businessErrorMock, bundleActiveEventStateMock); + args[len - 1].call(this, paramMock.businessErrorMock, BundleActiveEventState); } else { return new Promise((resolve) => { - resolve(bundleActiveEventStateMock) + resolve(BundleActiveEventState) }); } }, @@ -176,10 +176,10 @@ export function mockBundleState() { " Previewer may be different from that on a real device."); const len = args.length; if (typeof args[len - 1] === 'function') { - args[len - 1].call(this, paramMock.businessErrorMock, bundleActiveEventStateMock); + args[len - 1].call(this, paramMock.businessErrorMock, BundleActiveEventState); } else { return new Promise((resolve) => { - resolve(bundleActiveEventStateMock) + resolve(BundleActiveEventState) }); } }, @@ -224,10 +224,10 @@ export function mockBundleState() { " Previewer may be different from that on a real device."); const len = args.length; if (typeof args[len - 1] === 'function') { - args[len - 1].call(this, paramMock.businessErrorMock, BundleActiveModuleInfoMock); + args[len - 1].call(this, paramMock.businessErrorMock, BundleActiveModuleInfo); } else { return new Promise((resolve) => { - resolve(BundleActiveModuleInfoMock) + resolve(BundleActiveModuleInfo) }); } }, diff --git a/runtime/main/extend/systemplugin/napi/ohos_workScheduler.js b/runtime/main/extend/systemplugin/napi/ohos_workScheduler.js index 374d0947..4a6419b8 100644 --- a/runtime/main/extend/systemplugin/napi/ohos_workScheduler.js +++ b/runtime/main/extend/systemplugin/napi/ohos_workScheduler.js @@ -16,7 +16,7 @@ import { paramMock } from "../utils" export function mockWorkScheduler() { - const WorkInfoMock = { + const WorkInfo = { workId: '[PC preview] unknown workId', bundleName: '[PC preview] unknown bundleName', abilityName: '[PC preview] unknown abilityName', @@ -33,7 +33,7 @@ export function mockWorkScheduler() { isDeepIdle: '[PC preview] unknown isDeepIdle', idleWaitTime: '[PC preview] unknown idleWaitTime', }; - const WorkInfoArrayMock = [WorkInfoMock] + const WorkInfoArray = [WorkInfo] const workScheduler = { NetworkType : { NETWORK_TYPE_ANY: 0, @@ -74,10 +74,10 @@ export function mockWorkScheduler() { " Previewer may be different from that on a real device.") const len = args.length; if (typeof args[len - 1] === 'function') { - args[len - 1].call(this, paramMock.businessErrorMock, WorkInfoMock) + args[len - 1].call(this, paramMock.businessErrorMock, WorkInfo) } else { return new Promise(resolve => { - resolve(WorkInfoMock); + resolve(WorkInfo); }) } }, @@ -86,10 +86,10 @@ export function mockWorkScheduler() { " Previewer may be different from that on a real device.") const len = args.length; if (typeof args[len - 1] === 'function') { - args[len - 1].call(this, paramMock.businessErrorMock, WorkInfoArrayMock) + args[len - 1].call(this, paramMock.businessErrorMock, WorkInfoArray) } else { return new Promise(resolve => { - resolve(WorkInfoArrayMock); + resolve(WorkInfoArray); }) } }, From f89e0b275eca27c25ba9e6f4f576e70b57017e90 Mon Sep 17 00:00:00 2001 From: li-yaoyao777 Date: Thu, 7 Jul 2022 11:04:59 +0800 Subject: [PATCH 036/109] ohos_sensor.js Signed-off-by: li-yaoyao777 --- .../extend/systemplugin/napi/ohos_sensor.js | 30 +++++++++---------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/runtime/main/extend/systemplugin/napi/ohos_sensor.js b/runtime/main/extend/systemplugin/napi/ohos_sensor.js index a493b3a3..fce4fe9a 100644 --- a/runtime/main/extend/systemplugin/napi/ohos_sensor.js +++ b/runtime/main/extend/systemplugin/napi/ohos_sensor.js @@ -271,7 +271,7 @@ export function mockSensor() { + 'Previewer may be different from that on a real device.') const len = args.length if (typeof args[len - 1] === 'function') { - args[len - 1].call(this, paramMock.businessErrorMoc, GeomagneticResponse); + args[len - 1].call(this, paramMock.businessErrorMock, GeomagneticResponse); } else { return new Promise((resolve, reject) => { resolve(GeomagneticResponse); @@ -283,7 +283,7 @@ export function mockSensor() { + 'Previewer may be different from that on a real device.') const len = args.length if (typeof args[len - 1] === 'function') { - args[len - 1].call(this, paramMock.businessErrorMoc, paramMock.paramNumberMock); + args[len - 1].call(this, paramMock.businessErrorMock, paramMock.paramNumberMock); } else { return new Promise((resolve, reject) => { resolve(paramMock.paramNumberMock); @@ -295,7 +295,7 @@ export function mockSensor() { + 'Previewer may be different from that on a real device.') const len = args.length if (typeof args[len - 1] === 'function') { - args[len - 1].call(this, paramMock.businessErrorMoc, paramMock.paramNumberMock); + args[len - 1].call(this, paramMock.businessErrorMock, paramMock.paramNumberMock); } else { return new Promise((resolve, reject) => { resolve(paramMock.paramNumberMock); @@ -307,10 +307,10 @@ export function mockSensor() { + 'Previewer may be different from that on a real device.') const len = args.length if (typeof args[len - 1] === 'function') { - args[len - 1].call(this, paramMock.businessErrorMoc, paramMock.paramArrayMock); + args[len - 1].call(this, paramMock.businessErrorMock, paramMock.paramNumberMock); } else { return new Promise((resolve, reject) => { - resolve(paramMock.paramArrayMock); + resolve(paramMock.paramNumberMock); }); } }, @@ -319,10 +319,10 @@ export function mockSensor() { + 'Previewer may be different from that on a real device.') const len = args.length if (typeof args[len - 1] === 'function') { - args[len - 1].call(this, paramMock.businessErrorMoc, paramMock.paramArrayMock); + args[len - 1].call(this, paramMock.businessErrorMock, paramMock.paramNumberMock); } else { return new Promise((resolve, reject) => { - resolve(paramMock.paramArrayMock); + resolve(paramMock.paramNumberMock); }); } }, @@ -331,10 +331,10 @@ export function mockSensor() { + 'Previewer may be different from that on a real device.') const len = args.length if (typeof args[len - 1] === 'function') { - args[len - 1].call(this, paramMock.businessErrorMoc, paramMock.paramArrayMock); + args[len - 1].call(this, paramMock.businessErrorMock, paramMock.paramNumberMock); } else { return new Promise((resolve, reject) => { - resolve(paramMock.paramArrayMock); + resolve(paramMock.paramNumberMock); }); } }, @@ -343,10 +343,10 @@ export function mockSensor() { + 'Previewer may be different from that on a real device.') const len = args.length if (typeof args[len - 1] === 'function') { - args[len - 1].call(this, paramMock.businessErrorMoc, paramMock.paramArrayMock); + args[len - 1].call(this, paramMock.businessErrorMock, paramMock.paramNumberMock); } else { return new Promise((resolve, reject) => { - resolve(paramMock.paramArrayMock); + resolve(paramMock.paramNumberMock); }); } }, @@ -355,10 +355,10 @@ export function mockSensor() { + 'Previewer may be different from that on a real device.') const len = args.length if (typeof args[len - 1] === 'function') { - args[len - 1].call(this, paramMock.businessErrorMoc, paramMock.paramArrayMock); + args[len - 1].call(this, paramMock.businessErrorMock, paramMock.paramNumberMock); } else { return new Promise((resolve, reject) => { - resolve(paramMock.paramArrayMock); + resolve(paramMock.paramNumberMock); }); } }, @@ -367,7 +367,7 @@ export function mockSensor() { + 'Previewer may be different from that on a real device.') const len = args.length if (typeof args[len - 1] === 'function') { - args[len - 1].call(this, paramMock.businessErrorMoc, Sensor); + args[len - 1].call(this, paramMock.businessErrorMock, Sensor); } else { return new Promise((resolve, reject) => { resolve(Sensor); @@ -379,7 +379,7 @@ export function mockSensor() { + 'Previewer may be different from that on a real device.') const len = args.length if (typeof args[len - 1] === 'function') { - args[len - 1].call(this, paramMock.businessErrorMoc, Array(Sensor)); + args[len - 1].call(this, paramMock.businessErrorMock, Array(Sensor)); } else { return new Promise((resolve, reject) => { resolve(Array(Sensor)); From 55e71525cd43a3fd3bdb6f805879f4c3fc001c28 Mon Sep 17 00:00:00 2001 From: li-yaoyao777 Date: Thu, 7 Jul 2022 14:23:41 +0800 Subject: [PATCH 037/109] ohos_sensor.js Signed-off-by: li-yaoyao777 --- .../extend/systemplugin/napi/ohos_sensor.js | 41 ++++++++++++------- 1 file changed, 27 insertions(+), 14 deletions(-) diff --git a/runtime/main/extend/systemplugin/napi/ohos_sensor.js b/runtime/main/extend/systemplugin/napi/ohos_sensor.js index fce4fe9a..cb1c1723 100644 --- a/runtime/main/extend/systemplugin/napi/ohos_sensor.js +++ b/runtime/main/extend/systemplugin/napi/ohos_sensor.js @@ -128,6 +128,10 @@ export function mockSensor() { x: '[PC preview] unknown x', y: '[PC preview] unknown y' } + const RotationMatrixResponse = { + rotation: '[PC preview] unknown rotation', + inclination: '[PC preview] unknown inclination' + } const Sensor = { sensorName: '[PC preview] unknown sensorName', venderName: '[PC preview] unknown venderName', @@ -167,7 +171,7 @@ export function mockSensor() { console.warn('sensor.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; - const callback = typeof args[len - 1] == 'function' ? args[len - 1] : args[len - 2]; + const callback = typeof args[len - 1] === 'function' ? args[len - 1] : args[len - 2]; if (args[0] == 1) { callback.call(this, paramMock.businessErrorMock, AccelerometerResponse); } else if (args[0] == 2) { @@ -302,15 +306,15 @@ export function mockSensor() { }); } }, - getAngleModifiy: function (...args) { + getAngleModify: function (...args) { console.warn('sensor.getAngleModifiy interface mocked in the Previewer. How this interface works on the' + 'Previewer may be different 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); + args[len - 1].call(this, paramMock.businessErrorMock, paramMock.paramarrayMock); } else { return new Promise((resolve, reject) => { - resolve(paramMock.paramNumberMock); + resolve(paramMock.paramarrayMock); }); } }, @@ -318,23 +322,32 @@ export function mockSensor() { console.warn('sensor.createRotationMatrix interface mocked in the Previewer. How this interface works on the' + 'Previewer may be different 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 { + if (len === 1) { return new Promise((resolve, reject) => { - resolve(paramMock.paramNumberMock); + resolve(paramMock.paramArrayMock); }); + } else if (len === 2) { + if (typeof args[len - 1] === 'function') { + args[len - 1].call(this, paramMock.businessErrorMock, paramMock.paramArrayMock); + } else { + return new Promise((resolve, reject) => { + resolve(paramMock.RotationMatrixResponse); + }); + } + } else if (len === 3) { + args[len - 1].call(this, paramMock.businessErrorMock, paramMock.RotationMatrixResponse); } + }, transformCoordinateSystem: function (...args) { console.warn('sensor.transformCoordinateSystem interface mocked in the Previewer. How this interface works on the' + 'Previewer may be different 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); + args[len - 1].call(this, paramMock.businessErrorMock, paramMock.paramArrayMock); } else { return new Promise((resolve, reject) => { - resolve(paramMock.paramNumberMock); + resolve(paramMock.paramArrayMock); }); } }, @@ -343,10 +356,10 @@ export function mockSensor() { + 'Previewer may be different 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); + args[len - 1].call(this, paramMock.businessErrorMock, paramMock.paramArrayMock); } else { return new Promise((resolve, reject) => { - resolve(paramMock.paramNumberMock); + resolve(paramMock.paramArrayMock); }); } }, @@ -355,10 +368,10 @@ export function mockSensor() { + 'Previewer may be different 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); + args[len - 1].call(this, paramMock.businessErrorMock, paramMock.paramArrayMock); } else { return new Promise((resolve, reject) => { - resolve(paramMock.paramNumberMock); + resolve(paramMock.paramArrayMock); }); } }, From 46ce42f413393f5a0ecb8cdae241b7f02604a475 Mon Sep 17 00:00:00 2001 From: hwx1119949 <3052854011@qq.com> Date: Thu, 7 Jul 2022 14:55:12 +0800 Subject: [PATCH 038/109] White screen fix Signed-off-by: hwx1119949 <3052854011@qq.com> Change-Id: I622c14dd593a10ee1756b9d68dd135f462b84f3d --- build.js | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/build.js b/build.js index 73d4e330..25a59fad 100644 --- a/build.js +++ b/build.js @@ -37,6 +37,8 @@ const { const frameworkBanner = `var global=this; var process={env:{}}; ` + `var setTimeout=global.setTimeout;\n`; +const frameworkBannerForJSAPIMock = `var global=globalThis;`; + const onwarn = warning => { // Silence circular dependency warning if (warning.code === 'CIRCULAR_DEPENDENCY') { @@ -94,7 +96,8 @@ const configOutput = { const configJSAPIMockOutput = { file: path.resolve(__dirname, 'dist/jsMockSystemPlugin.js'), - format: 'umd' + format: 'umd', + banner: frameworkBannerForJSAPIMock }; rollup.rollup(configInput).then(bundle => { From b42a86bb73ca373bf3aeeccc694e80c735c68f98 Mon Sep 17 00:00:00 2001 From: hungry_feiwei Date: Thu, 7 Jul 2022 16:47:33 +0800 Subject: [PATCH 039/109] =?UTF-8?q?=C3=A4Fill=20in=20the=20missing=20mocks?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: hungry_feiwei Change-Id: Ieb3c3338c4a4c536646d4095963ec47c3baa0f84 --- .../ohos_multimodalInput_inputConsumer.js | 6 +++++ .../napi/ohos_multimodalInput_inputDevice.js | 17 ++++++++++-- .../napi/ohos_multimodalInput_inputEvent.js | 24 +++++++++++++++++ .../napi/ohos_multimodalInput_inputMonitor.js | 3 +++ .../napi/ohos_multimodalInput_keyCode.js | 2 ++ .../napi/ohos_multimodalInput_keyEvent.js | 19 ++++++++++++++ .../napi/ohos_multimodalInput_mouseEvent.js | 25 ++++++++++++++++++ .../napi/ohos_multimodalInput_touchEvent.js | 26 +++++++++++++++++++ 8 files changed, 120 insertions(+), 2 deletions(-) create mode 100755 runtime/main/extend/systemplugin/napi/ohos_multimodalInput_inputEvent.js diff --git a/runtime/main/extend/systemplugin/napi/ohos_multimodalInput_inputConsumer.js b/runtime/main/extend/systemplugin/napi/ohos_multimodalInput_inputConsumer.js index c251ab58..5bab4542 100644 --- a/runtime/main/extend/systemplugin/napi/ohos_multimodalInput_inputConsumer.js +++ b/runtime/main/extend/systemplugin/napi/ohos_multimodalInput_inputConsumer.js @@ -16,6 +16,12 @@ import { paramMock } from "../utils" export function mockInputConsumer() { + const KeyOptions = { + preKeys: ["[PC preview] unknown preKeys"], + finalKey: "[PC preview] unknown finalKey", + isFinalKeyDown: "[PC preview] unknown isFinalKeyDown", + finalKeyDownDuration: "[PC preview] unknown finalKeyDownDuration", + } const EventType = ['key'] const inputConsumer = { on: function (...args) { diff --git a/runtime/main/extend/systemplugin/napi/ohos_multimodalInput_inputDevice.js b/runtime/main/extend/systemplugin/napi/ohos_multimodalInput_inputDevice.js index 874f1756..2edabfd6 100644 --- a/runtime/main/extend/systemplugin/napi/ohos_multimodalInput_inputDevice.js +++ b/runtime/main/extend/systemplugin/napi/ohos_multimodalInput_inputDevice.js @@ -16,17 +16,30 @@ import { paramMock } from "../utils" export function mockInputDevice() { + const DeviceListener = { + type: '[PC preview] unknow type', + deviceId: '[PC preview] unknow deviceId', + } const AxisRange = { source: '[PC preview] unknow source', axis: '[PC preview] unknow axis', max: '[PC preview] unknow max', - min: '[PC preview] unknow min' + min: '[PC preview] unknow min', + fuzz: '[PC preview] unknow fuzz', + flat: '[PC preview] unknow flat', + resolution: '[PC preview] unknow resolution', } const InputDeviceData = { id: '[PC preview] unknow id', name: '[PC preview] unknow name', sources: ['[PC preview] unknow sources'], - axisRanges: [AxisRange] + axisRanges: [AxisRange], + bus: '[PC preview] unknow bus', + product: '[PC preview] unknow product', + vendor: '[PC preview] unknow vendor', + version: '[PC preview] unknow version', + phys: '[PC preview] unknow phys', + uniq: '[PC preview] unknow uniq', } const KeyboardType = { NONE: 0, diff --git a/runtime/main/extend/systemplugin/napi/ohos_multimodalInput_inputEvent.js b/runtime/main/extend/systemplugin/napi/ohos_multimodalInput_inputEvent.js new file mode 100755 index 00000000..afcd6edd --- /dev/null +++ b/runtime/main/extend/systemplugin/napi/ohos_multimodalInput_inputEvent.js @@ -0,0 +1,24 @@ +/* + * Copyright (c) 2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +export function mockInputEvent() { + const InputEvent = { + id: '[PC preview] unknow id', + deviceId: '[PC preview] unknow deviceId', + actionTime: '[PC preview] unknow actionTime', + screenId: '[PC preview] unknow screenId', + windowId: '[PC preview] unknow windowId', + } +} \ No newline at end of file diff --git a/runtime/main/extend/systemplugin/napi/ohos_multimodalInput_inputMonitor.js b/runtime/main/extend/systemplugin/napi/ohos_multimodalInput_inputMonitor.js index ff969d42..4534dfb1 100644 --- a/runtime/main/extend/systemplugin/napi/ohos_multimodalInput_inputMonitor.js +++ b/runtime/main/extend/systemplugin/napi/ohos_multimodalInput_inputMonitor.js @@ -14,6 +14,9 @@ */ export function mockInputMonitor() { + const TouchEventReceiver = { + "touchEvent": '[PC preview] unknow boolean' + } const touches = [{ force: 1.67, globalX: 122, diff --git a/runtime/main/extend/systemplugin/napi/ohos_multimodalInput_keyCode.js b/runtime/main/extend/systemplugin/napi/ohos_multimodalInput_keyCode.js index 3a9e8180..63a34cfc 100644 --- a/runtime/main/extend/systemplugin/napi/ohos_multimodalInput_keyCode.js +++ b/runtime/main/extend/systemplugin/napi/ohos_multimodalInput_keyCode.js @@ -16,6 +16,8 @@ export const KeyCode = { KEYCODE_FN: 0, KEYCODE_UNKNOWN: -1, + KEYCODE_HOME: 1, + KEYCODE_BACK: 2, KEYCODE_MEDIA_PLAY_PAUSE: 10, KEYCODE_MEDIA_STOP: 11, KEYCODE_MEDIA_NEXT: 12, diff --git a/runtime/main/extend/systemplugin/napi/ohos_multimodalInput_keyEvent.js b/runtime/main/extend/systemplugin/napi/ohos_multimodalInput_keyEvent.js index 93d84695..888f6432 100644 --- a/runtime/main/extend/systemplugin/napi/ohos_multimodalInput_keyEvent.js +++ b/runtime/main/extend/systemplugin/napi/ohos_multimodalInput_keyEvent.js @@ -20,6 +20,25 @@ export const Action = { } export function mockKeyEvent() { + const Key = { + code: '[PC preview] unknow code', + pressedTime: '[PC preview] unknow pressedTime', + deviceId: '[PC preview] unknow deviceId', + } + const KeyEvent = { + action: '[PC preview] unknow action', + key: Key, + unicodeChar: '[PC preview] unknow unicodeChar', + keys: ['[PC preview] unknow Key'], + ctrlKey: '[PC preview] unknow ctrlKey', + altKey: '[PC preview] unknow altKey', + shiftKey: '[PC preview] unknow shiftKey', + logoKey: '[PC preview] unknow logoKey', + fnKey: '[PC preview] unknow fnKey', + capsLock: '[PC preview] unknow capsLock', + numLock: '[PC preview] unknow numLock', + scrollLock: '[PC preview] unknow scrollLock', + } const keyEvent = { Action, } diff --git a/runtime/main/extend/systemplugin/napi/ohos_multimodalInput_mouseEvent.js b/runtime/main/extend/systemplugin/napi/ohos_multimodalInput_mouseEvent.js index f0f65236..7d7fd3bb 100644 --- a/runtime/main/extend/systemplugin/napi/ohos_multimodalInput_mouseEvent.js +++ b/runtime/main/extend/systemplugin/napi/ohos_multimodalInput_mouseEvent.js @@ -41,6 +41,31 @@ export const Axis = { } export function mockMouseEvent() { + const AxisValue = { + axis: '[PC preview] unknow axis', + value: '[PC preview] unknow value', + } + const MouseEvent = { + action: '[PC preview] unknow action', + screenX: '[PC preview] unknow screenX', + screenY: '[PC preview] unknow screenY', + windowX: '[PC preview] unknow windowX', + windowY: '[PC preview] unknow windowY', + rawDeltaX: '[PC preview] unknow rawDeltaX', + rawDeltaY: '[PC preview] unknow rawDeltaY', + button: '[PC preview] unknow button', + pressedButtons: ['[PC preview] unknow pressedButtons'], + axes: ['[PC preview] unknow axes'], + pressedKeys: ['[PC preview] unknow pressedKeys'], + ctrlKey: '[PC preview] unknow ctrlKey', + altKey: '[PC preview] unknow altKey', + shiftKey: '[PC preview] unknow shiftKey', + logoKey: '[PC preview] unknow logoKey', + fnKey: '[PC preview] unknow fnKey', + capsLock: '[PC preview] unknow capsLock', + numLock: '[PC preview] unknow numLock', + scrollLock: '[PC preview] unknow scrollLock', + } const mouseEvent = { Action, Button, diff --git a/runtime/main/extend/systemplugin/napi/ohos_multimodalInput_touchEvent.js b/runtime/main/extend/systemplugin/napi/ohos_multimodalInput_touchEvent.js index 58b53f7a..76655570 100644 --- a/runtime/main/extend/systemplugin/napi/ohos_multimodalInput_touchEvent.js +++ b/runtime/main/extend/systemplugin/napi/ohos_multimodalInput_touchEvent.js @@ -38,6 +38,32 @@ export const SourceType = { } export function mockTouchEvent() { + const Touch = { + id: '[PC preview] unknow id', + pressedTime: '[PC preview] unknow pressedTime', + screenX: '[PC preview] unknow screenX', + screenY: '[PC preview] unknow screenY', + windowX: '[PC preview] unknow windowX', + windowY: '[PC preview] unknow windowY', + pressure: '[PC preview] unknow pressure', + width: '[PC preview] unknow width', + height: '[PC preview] unknow height', + tiltX: '[PC preview] unknow tiltX', + tiltY: '[PC preview] unknow tiltY', + toolX: '[PC preview] unknow toolX', + toolY: '[PC preview] unknow toolY', + toolWidth: '[PC preview] unknow toolWidth', + toolHeight: '[PC preview] unknow toolHeight', + rawX: '[PC preview] unknow rawX', + rawY: '[PC preview] unknow rawY', + toolType: '[PC preview] unknow toolType', + } + const TouchEvent = { + action: '[PC preview] unknow action', + touch: '[PC preview] unknow Touch', + touches: ['[PC preview] unknow Touch'], + sourceType: '[PC preview] unknow SourceType', + } const touchEvent = { Action, ToolType, From 682e04774830dc124deca7913faac52a606e78d0 Mon Sep 17 00:00:00 2001 From: hungry_feiwei Date: Thu, 7 Jul 2022 17:55:52 +0800 Subject: [PATCH 040/109] =?UTF-8?q?=C3=A4Fill=20in=20the=20missing=20mocks?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: hungry_feiwei Change-Id: Ie2a97c7f09577622a3613ea4c91322e87d8112c8 --- .../napi/ohos_multimodalInput_inputMonitor.js | 22 +++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) diff --git a/runtime/main/extend/systemplugin/napi/ohos_multimodalInput_inputMonitor.js b/runtime/main/extend/systemplugin/napi/ohos_multimodalInput_inputMonitor.js index 4534dfb1..d808db3b 100644 --- a/runtime/main/extend/systemplugin/napi/ohos_multimodalInput_inputMonitor.js +++ b/runtime/main/extend/systemplugin/napi/ohos_multimodalInput_inputMonitor.js @@ -82,8 +82,26 @@ export function mockInputMonitor() { off: function (...args) { console.warn('multimodalInput.inputMonitor.off interface mocked in the Previewer. How this interface works on the' + ' Previewer may be different from that on a real device.'); - clearInterval(this.offInputMonitor); - delete this.offInputMonitor; + const len = args.length; + if (len < 1 || len > 2) { + console.warn("a maximum of two parameters"); + return; + } + if (typeof args[0] !== 'string') { + console.warn("the first parameter type must be string"); + return; + } + if (len === 1) { + if (args[0] !== 'touch' && args[0] !== 'mouse') { + console.warn("the first param should be touch or mouse"); + return; + } + } else { + if (typeof args[1] !== 'function') { + console.warn("the second parameter type must be function"); + return; + } + } } } return inputMonitor From 3f297a65d9f2c47ae2fe4b1292546154eca9415b Mon Sep 17 00:00:00 2001 From: chenqy930 Date: Thu, 7 Jul 2022 19:55:19 +0800 Subject: [PATCH 041/109] Switch component ark_ts2abc to arkcompiler_ets_frontend Signed-off-by: chenqy930 Change-Id: Ic145214b2a91cda51b9b164de3b30fd20becc58b --- BUILD.gn | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/BUILD.gn b/BUILD.gn index 7dc25231..e39ecde3 100644 --- a/BUILD.gn +++ b/BUILD.gn @@ -289,7 +289,7 @@ ohos_static_library("jsf") { } if (!is_cross_platform_build) { - import("//ark/ts2abc/ts2panda/ts2abc_config.gni") + import("//arkcompiler/ets_frontend/ts2panda/ts2abc_config.gni") ark_abc_path = get_label_info(":ark_build", "target_out_dir") + "/strip.native.min.abc" From 27e6496124d82ba11156ec2b433f894c14aef876 Mon Sep 17 00:00:00 2001 From: li-yaoyao777 Date: Fri, 8 Jul 2022 09:32:15 +0800 Subject: [PATCH 042/109] ohos_sensor.js Signed-off-by: li-yaoyao777 --- .../extend/systemplugin/napi/ohos_sensor.js | 114 +++++++++--------- 1 file changed, 56 insertions(+), 58 deletions(-) diff --git a/runtime/main/extend/systemplugin/napi/ohos_sensor.js b/runtime/main/extend/systemplugin/napi/ohos_sensor.js index cb1c1723..8111094c 100644 --- a/runtime/main/extend/systemplugin/napi/ohos_sensor.js +++ b/runtime/main/extend/systemplugin/napi/ohos_sensor.js @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021 Huawei Device Co., Ltd. + * Copyright (c) 2021-2022 Huawei Device Co., Ltd. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at @@ -166,54 +166,54 @@ export function mockSensor() { SENSOR_TYPE_ID_ACCELEROMETER_UNCALIBRATED: 281 } const sensor = { - Sensor, + Sensor, on: function (...args) { console.warn('sensor.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; const callback = typeof args[len - 1] === 'function' ? args[len - 1] : args[len - 2]; if (args[0] == 1) { - callback.call(this, paramMock.businessErrorMock, AccelerometerResponse); + callback.call(this, AccelerometerResponse); } else if (args[0] == 2) { - callback.call(this, paramMock.businessErrorMock, GyroscopeResponse); + callback.call(this, GyroscopeResponse); } else if (args[0] == 5) { - callback.call(this, paramMock.businessErrorMock, LightResponse); + callback.call(this, LightResponse); } else if (args[0] == 6) { - callback.call(this, paramMock.businessErrorMock, MagneticFieldResponse); + callback.call(this, MagneticFieldResponse); } else if (args[0] == 8) { - callback.call(this, paramMock.businessErrorMock, BarometerResponse); + callback.call(this, BarometerResponse); } else if (args[0] == 10) { - callback.call(this, paramMock.businessErrorMock, HallResponse); + callback.call(this, HallResponse); } else if (args[0] == 12) { - callback.call(this, paramMock.businessErrorMock, ProximityResponse); + callback.call(this, ProximityResponse); } else if (args[0] == 13) { - callback.call(this, paramMock.businessErrorMock, HumidityResponse); + callback.call(this, HumidityResponse); } else if (args[0] == 256) { - callback.call(this, paramMock.businessErrorMock, OrientationResponse); + callback.call(this, OrientationResponse); } else if (args[0] == 257) { - callback.call(this, paramMock.businessErrorMock, GravityResponse); + callback.call(this, GravityResponse); } else if (args[0] == 258) { - callback.call(this, paramMock.businessErrorMock, LinearAccelerometerResponse); + callback.call(this, LinearAccelerometerResponse); } else if (args[0] == 259) { - callback.call(this, paramMock.businessErrorMock, RotationVectorResponse); + callback.call(this, RotationVectorResponse); } else if (args[0] == 260) { - callback.call(this, paramMock.businessErrorMock, AmbientTemperatureResponse); + callback.call(this, AmbientTemperatureResponse); } else if (args[0] == 261) { - callback.call(this, paramMock.businessErrorMock, MagneticFieldUncalibratedResponse); + callback.call(this, MagneticFieldUncalibratedResponse); } else if (args[0] == 263) { - callback.call(this, paramMock.businessErrorMock, GyroscopeUncalibratedResponse); + callback.call(this, GyroscopeUncalibratedResponse); } else if (args[0] == 264) { - callback.call(this, paramMock.businessErrorMock, SignificantMotionResponse); + callback.call(this, SignificantMotionResponse); } else if (args[0] == 265) { - callback.call(this, paramMock.businessErrorMock, PedometerDetectResponse); + callback.call(this, PedometerDetectResponse); } else if (args[0] == 266) { - callback.call(this, paramMock.businessErrorMock, PedometerResponse); + callback.call(this, PedometerResponse); } else if (args[0] == 278) { - callback.call(this, paramMock.businessErrorMock, HeartRateResponse); + callback.call(this, HeartRateResponse); } else if (args[0] == 280) { - callback.call(this, paramMock.businessErrorMock, WearDetectionResponse); + callback.call(this, WearDetectionResponse); } else if (args[0] == 281) { - callback.call(this, paramMock.businessErrorMock, AccelerometerUncalibratedResponse); + callback.call(this, AccelerometerUncalibratedResponse); } }, once: function (...args) { @@ -221,54 +221,52 @@ export function mockSensor() { + 'Previewer may be different from that on a real device.') const len = args.length if (args[0] == 1) { - args[len - 1].call(this, paramMock.businessErrorMock, AccelerometerResponse); + args[len - 1].call(this, AccelerometerResponse); } else if (args[0] == 2) { - args[len - 1].call(this, paramMock.businessErrorMock, GyroscopeResponse); + args[len - 1].call(this, GyroscopeResponse); } else if (args[0] == 5) { - args[len - 1].call(this, paramMock.businessErrorMock, LightResponse); + args[len - 1].call(this, LightResponse); } else if (args[0] == 6) { - args[len - 1].call(this, paramMock.businessErrorMock, MagneticFieldResponse); + args[len - 1].call(this, MagneticFieldResponse); } else if (args[0] == 8) { - args[len - 1].call(this, paramMock.businessErrorMock, BarometerResponse); + args[len - 1].call(this, BarometerResponse); } else if (args[0] == 10) { - args[len - 1].call(this, paramMock.businessErrorMock, HallResponse); + args[len - 1].call(this, HallResponse); } else if (args[0] == 12) { - args[len - 1].call(this, paramMock.businessErrorMock, ProximityResponse); + args[len - 1].call(this, ProximityResponse); } else if (args[0] == 13) { - args[len - 1].call(this, paramMock.businessErrorMock, HumidityResponse); + args[len - 1].call(this, HumidityResponse); } else if (args[0] == 256) { - args[len - 1].call(this, paramMock.businessErrorMock, OrientationResponse); + args[len - 1].call(this, OrientationResponse); } else if (args[0] == 257) { - args[len - 1].call(this, paramMock.businessErrorMock, GravityResponse); + args[len - 1].call(this, GravityResponse); } else if (args[0] == 258) { - args[len - 1].call(this, paramMock.businessErrorMock, LinearAccelerometerResponse); + args[len - 1].call(this, LinearAccelerometerResponse); } else if (args[0] == 259) { - args[len - 1].call(this, paramMock.businessErrorMock, RotationVectorResponse); + args[len - 1].call(this, RotationVectorResponse); } else if (args[0] == 260) { - args[len - 1].call(this, paramMock.businessErrorMock, AmbientTemperatureResponse); + args[len - 1].call(this, AmbientTemperatureResponse); } else if (args[0] == 261) { - args[len - 1].call(this, paramMock.businessErrorMock, MagneticFieldUncalibratedResponse); + args[len - 1].call(this, MagneticFieldUncalibratedResponse); } else if (args[0] == 263) { - args[len - 1].call(this, paramMock.businessErrorMock, GyroscopeUncalibratedResponse); + args[len - 1].call(this, GyroscopeUncalibratedResponse); } else if (args[0] == 264) { - args[len - 1].call(this, paramMock.businessErrorMock, SignificantMotionResponse); + args[len - 1].call(this, SignificantMotionResponse); } else if (args[0] == 265) { - args[len - 1].call(this, paramMock.businessErrorMock, PedometerDetectResponse); + args[len - 1].call(this, PedometerDetectResponse); } else if (args[0] == 266) { - args[len - 1].call(this, paramMock.businessErrorMock, PedometerResponse); + args[len - 1].call(this, PedometerResponse); } else if (args[0] == 278) { - args[len - 1].call(this, paramMock.businessErrorMock, HeartRateResponse); + args[len - 1].call(this, HeartRateResponse); } else if (args[0] == 280) { - args[len - 1].call(this, paramMock.businessErrorMock, WearDetectionResponse); + args[len - 1].call(this, WearDetectionResponse); } else if (args[0] == 281) { - args[len - 1].call(this, paramMock.businessErrorMock, AccelerometerUncalibratedResponse); + args[len - 1].call(this, AccelerometerUncalibratedResponse); } }, off: function (...args) { console.warn('sensor.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); }, getGeomagneticField: function (...args) { console.warn('sensor.getGeomagneticField interface mocked in the Previewer. How this interface works on the' @@ -311,10 +309,10 @@ export function mockSensor() { + 'Previewer may be different from that on a real device.') const len = args.length if (typeof args[len - 1] === 'function') { - args[len - 1].call(this, paramMock.businessErrorMock, paramMock.paramarrayMock); + args[len - 1].call(this, paramMock.businessErrorMock, [paramMock.paraNumberMock]); } else { return new Promise((resolve, reject) => { - resolve(paramMock.paramarrayMock); + resolve([paramMock.paraNumberMock]); }); } }, @@ -322,19 +320,19 @@ export function mockSensor() { console.warn('sensor.createRotationMatrix interface mocked in the Previewer. How this interface works on the' + 'Previewer may be different from that on a real device.') const len = args.length - if (len === 1) { + if (len == 1) { return new Promise((resolve, reject) => { resolve(paramMock.paramArrayMock); }); - } else if (len === 2) { - if (typeof args[len - 1] === 'function') { + } else if (len == 2) { + if (typeof args[len - 1] == 'function') { args[len - 1].call(this, paramMock.businessErrorMock, paramMock.paramArrayMock); } else { return new Promise((resolve, reject) => { resolve(paramMock.RotationMatrixResponse); }); } - } else if (len === 3) { + } else if (len == 3) { args[len - 1].call(this, paramMock.businessErrorMock, paramMock.RotationMatrixResponse); } @@ -344,10 +342,10 @@ export function mockSensor() { + 'Previewer may be different from that on a real device.') const len = args.length if (typeof args[len - 1] === 'function') { - args[len - 1].call(this, paramMock.businessErrorMock, paramMock.paramArrayMock); + args[len - 1].call(this, paramMock.businessErrorMock, [paramMock.paraNumberMock]); } else { return new Promise((resolve, reject) => { - resolve(paramMock.paramArrayMock); + resolve([paramMock.paraNumberMock]); }); } }, @@ -356,10 +354,10 @@ export function mockSensor() { + 'Previewer may be different from that on a real device.') const len = args.length if (typeof args[len - 1] === 'function') { - args[len - 1].call(this, paramMock.businessErrorMock, paramMock.paramArrayMock); + args[len - 1].call(this, paramMock.businessErrorMock, paramMock.[paramMock.paraNumberMock]); } else { return new Promise((resolve, reject) => { - resolve(paramMock.paramArrayMock); + resolve([paramMock.paraNumberMock]); }); } }, @@ -368,10 +366,10 @@ export function mockSensor() { + 'Previewer may be different from that on a real device.') const len = args.length if (typeof args[len - 1] === 'function') { - args[len - 1].call(this, paramMock.businessErrorMock, paramMock.paramArrayMock); + args[len - 1].call(this, paramMock.businessErrorMock, [paramMock.paraNumberMock]); } else { return new Promise((resolve, reject) => { - resolve(paramMock.paramArrayMock); + resolve([paramMock.paraNumberMock]); }); } }, From ae35ccdeea36c72ad9e5ff622116a51fa6e47cf3 Mon Sep 17 00:00:00 2001 From: li-yaoyao777 Date: Fri, 8 Jul 2022 11:21:25 +0800 Subject: [PATCH 043/109] ohos_sensor.js Signed-off-by: li-yaoyao777 --- .../extend/systemplugin/napi/ohos_sensor.js | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/runtime/main/extend/systemplugin/napi/ohos_sensor.js b/runtime/main/extend/systemplugin/napi/ohos_sensor.js index 8111094c..ab7f0d00 100644 --- a/runtime/main/extend/systemplugin/napi/ohos_sensor.js +++ b/runtime/main/extend/systemplugin/napi/ohos_sensor.js @@ -47,7 +47,8 @@ export function mockSensor() { const RotationVectorResponse = { x: '[PC preview] unknown x', y: '[PC preview] unknown y', - z: '[PC preview] unknown z' + z: '[PC preview] unknown z', + w: '[PC preview] unknown w' } const GyroscopeResponse = { x: '[PC preview] unknown x', @@ -115,14 +116,21 @@ export function mockSensor() { x: '[PC preview] unknown x', y: '[PC preview] unknown y', z: '[PC preview] unknown z', - biasX: '[PC preview] unknown biasX', - biasY: '[PC preview] unknown biasY', - biasZ: '[PC preview] unknown biasZ' + geomagneticDip: '[PC preview] unknown geomagneticDip', + deflectionAngle: '[PC preview] unknown deflectionAngle', + levelIntensity: '[PC preview] unknown levelIntensity', + totalIntensity: '[PC preview] unknown totalIntensity' + } + const PedometerDetectionResponse = { + scalar: '[PC preview] unknown scalar' + } + const Response = { + timestamp: '[PC preview] unknown z' } const LocationOptions = { latitude: '[PC preview] unknown latitude', longitude: '[PC preview] unknown longitude', - altitude: '[PC preview] unknown altitude', + altitude: '[PC preview] unknown altitude' } const CoordinatesOptions = { x: '[PC preview] unknown x', From c85e131bab3932c65961a2094933f8047b54311d Mon Sep 17 00:00:00 2001 From: hungry_feiwei Date: Fri, 8 Jul 2022 15:04:12 +0800 Subject: [PATCH 044/109] =?UTF-8?q?=C3=A4Fill=20in=20the=20missing=20mocks?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: hungry_feiwei Change-Id: I66c2cbad69b946ffcfb32e1e318ad35d01f61b55 --- .../systemplugin/napi/ohos_multimodalInput_inputEvent.js | 1 + .../napi/ohos_multimodalInput_inputEventClient.js | 6 ++++++ 2 files changed, 7 insertions(+) diff --git a/runtime/main/extend/systemplugin/napi/ohos_multimodalInput_inputEvent.js b/runtime/main/extend/systemplugin/napi/ohos_multimodalInput_inputEvent.js index afcd6edd..1deaf88f 100755 --- a/runtime/main/extend/systemplugin/napi/ohos_multimodalInput_inputEvent.js +++ b/runtime/main/extend/systemplugin/napi/ohos_multimodalInput_inputEvent.js @@ -21,4 +21,5 @@ export function mockInputEvent() { screenId: '[PC preview] unknow screenId', windowId: '[PC preview] unknow windowId', } + return InputEvent; } \ No newline at end of file diff --git a/runtime/main/extend/systemplugin/napi/ohos_multimodalInput_inputEventClient.js b/runtime/main/extend/systemplugin/napi/ohos_multimodalInput_inputEventClient.js index c76b4e92..4ebf7cee 100644 --- a/runtime/main/extend/systemplugin/napi/ohos_multimodalInput_inputEventClient.js +++ b/runtime/main/extend/systemplugin/napi/ohos_multimodalInput_inputEventClient.js @@ -16,6 +16,12 @@ import { paramMock } from "../utils" export function mockInputEventClient() { + const KeyEvent = { + isPressed: '[PC preview] unknow isPressed', + keyCode: '[PC preview] unknow keyCode', + keyDownDuration: '[PC preview] unknow keyDownDuration', + isIntercepted: '[PC preview] unknow isIntercepted', + } const inputEventClient = { injectEvent: function(...args) { console.warn("inputEventClient.injectEvent interface mocked in the Previewer. How this interface works on the" + From 802c9bd44e9f603d7e4bfadeaa95383804c80be5 Mon Sep 17 00:00:00 2001 From: zhouyan Date: Tue, 5 Jul 2022 14:38:19 +0800 Subject: [PATCH 045/109] =?UTF-8?q?access=5Ftoken=E6=B7=BB=E5=8A=A0?= =?UTF-8?q?=E9=89=B4=E6=9D=83=E5=90=8C=E6=AD=A5=E6=8E=A5=E5=8F=A3mock?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: zhouyan Change-Id: I112f9dfdb75f8ffe6a20d08b9e7389c2fbde9a5d --- .../systemplugin/napi/ohos_abilityAccessCtrl.js | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/runtime/main/extend/systemplugin/napi/ohos_abilityAccessCtrl.js b/runtime/main/extend/systemplugin/napi/ohos_abilityAccessCtrl.js index c0c93dd7..9f41c7f9 100644 --- a/runtime/main/extend/systemplugin/napi/ohos_abilityAccessCtrl.js +++ b/runtime/main/extend/systemplugin/napi/ohos_abilityAccessCtrl.js @@ -16,14 +16,21 @@ import { paramMock } from "../utils" export function mockAbilityAccessCtrl() { - const AtManagerMock = { + const GrantStatus = "[PC preview] unknow GrantStatus"; + + const AtManager = { verifyAccessToken: function (...args) { console.warn("AtManager.verifyAccessToken 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(GrantStatusMock); + resolve(GrantStatus); }) }, + verifyAccessTokenSync: function (...args) { + console.warn("AtManager.verifyAccessTokenSync interface mocked in the Previewer." + + " How this interface works on the Previewer may be different from that on a real device.") + return GrantStatus; + }, grantUserGrantedPermission: function (...args) { console.warn("AtManager.grantUserGrantedPermission interface mocked in the Previewer." + " How this interface works on the Previewer may be different from that on a real device.") @@ -60,9 +67,8 @@ export function mockAbilityAccessCtrl() { createAtManager : function (...args) { console.warn("abilityAccessCtrl.createAtManager interface mocked in the Previewer." + " How this interface works on the Previewer may be different from that on a real device.") - return AtManagerMock; + return AtManager; }, - GrantStatusMock:'[PC preview] unknow GrantStatusMock' }; return abilityAccessCtrl; From 9eb59ffc48513b49076328d168ea80fac986b12a Mon Sep 17 00:00:00 2001 From: huangjie Date: Wed, 6 Jul 2022 11:28:25 +0800 Subject: [PATCH 046/109] =?UTF-8?q?=E5=85=A8=E7=90=83=E5=8C=96=E5=A2=9E?= =?UTF-8?q?=E5=8A=A0APImock?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: huangjie --- .../napi/global/rawFileDescriptor.js | 20 ++ .../systemplugin/napi/ohos_resourceManager.js | 320 ++++++++++++------ 2 files changed, 239 insertions(+), 101 deletions(-) create mode 100644 runtime/main/extend/systemplugin/napi/global/rawFileDescriptor.js diff --git a/runtime/main/extend/systemplugin/napi/global/rawFileDescriptor.js b/runtime/main/extend/systemplugin/napi/global/rawFileDescriptor.js new file mode 100644 index 00000000..ef263de1 --- /dev/null +++ b/runtime/main/extend/systemplugin/napi/global/rawFileDescriptor.js @@ -0,0 +1,20 @@ +/* + * Copyright (c) 2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +export const RawFileDescriptor = { + fd : '[PC Preview] unknow number', + offset : '[PC Preview] unknow number', + length : '[PC Preview] unknow number' +} \ No newline at end of file diff --git a/runtime/main/extend/systemplugin/napi/ohos_resourceManager.js b/runtime/main/extend/systemplugin/napi/ohos_resourceManager.js index c5c1d19e..5d5b5283 100644 --- a/runtime/main/extend/systemplugin/napi/ohos_resourceManager.js +++ b/runtime/main/extend/systemplugin/napi/ohos_resourceManager.js @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021 Huawei Device Co., Ltd. + * Copyright (c) 2021-2022 Huawei Device Co., Ltd. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at @@ -13,169 +13,290 @@ * limitations under the License. */ +import { paramMock } from "../utils"; +import { RawFileDescriptor } from "./global/rawFileDescriptor" + export function mockResourceManager() { - function Configuration(direction, locale) { - this.direction = direction; - this.locale = locale; + const Direction = { + DIRECTION_VERTICAL : 0, + DIRECTION_HORIZONTAL : 1 } - function DeviceCapability(screenDensity, deviceType) { - this.screenDensity = screenDensity; - this.deviceType = deviceType; + const ConfigurationClass = class Configuration { + constructor() { + console.warn('resourceManager.Configuration.constructor interface mocked in the Previewer. How this interface works on' + + ' the Previewer may be different from that on a real device.'); + this.direction = Direction; + this.locale = '[PC Preview] unknow string'; + } } - function ResourceManager(mgrId, module) { - var resMgrId = mgrId; - var resourcemgrModuleGroup = module; + const ScreenDensity = { + SCREEN_SDPI : 120, + SCREEN_MDPI : 160, + SCREEN_LDPI : 240, + SCREEN_XLDPI : 320, + SCREEN_XXLDPI : 480 + } - this.getString = getString; - async function getString(resId, callback) { - var data = "mock string"; + const DeviceType = { + DEVICE_TYPE_PHONE : 0x00, + DEVICE_TYPE_TABLET : 0x01, + DEVICE_TYPE_CAR : 0x02, + DEVICE_TYPE_PC : 0x03, + DEVICE_TYPE_TV : 0x04, + DEVICE_TYPE_WEARABLE : 0x06 + } + + const DeviceCapabilityClass = class DeviceCapability { + constructor() { + console.warn('resourceManager.DeviceCapability.constructor interface mocked in the Previewer. How this interface works on' + + ' the Previewer may be different from that on a real device.'); + this.screenDensity = ScreenDensity; + this.deviceType = DeviceType; + } + } + + const ResourceManager = { + getString: function(...args) { console.warn("ResourceManager.getString interface mocked in the Previewer. " + "How this interface works on the Previewer may be different from that on a real device.") - if (typeof callback === 'function') { - callback.call(this, null, data); + 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(data); + return new Promise((resolve, reject) => { + resolve(paramMock.paramStringMock); }) } - } + }, - this.getStringArray = getStringArray; - async function getStringArray(resId, callback) { - var data = ["mock string1", "mock string2"]; + getStringArray: function(...args) { console.warn("ResourceManager.getStringArray interface mocked in the Previewer. " + "How this interface works on the Previewer may be different from that on a real device.") - if (typeof callback === 'function') { - callback.call(this, null, data); + 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(data); + return new Promise((resolve, reject) => { + resolve([paramMock.paramStringMock]); }) } - } + }, - this.getMedia = getMedia; - async function getMedia(resId, callback) { - var data = "mock media data"; + getMedia: function(...args) { console.warn("ResourceManager.getMedia interface mocked in the Previewer. " + "How this interface works on the Previewer may be different from that on a real device.") - if (typeof callback === 'function') { - callback.call(this, 1, data); + 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) => { - reject(data); + resolve(paramMock.paramArrayMock); }) } - } + }, - this.getMediaBase64 = getMediaBase64; - async function getMediaBase64(resId, callback) { - var data = "mock media data"; + getMediaBase64: function(...args) { console.warn("ResourceManager.getMediaBase64 interface mocked in the Previewer. " + "How this interface works on the Previewer may be different from that on a real device.") - if (typeof callback === 'function') { - callback.call(this, 1, data); + 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) => { - reject(data); + resolve(paramMock.paramArrayMock); }) } - } + }, - this.getPluralString = getPluralString; - async function getPluralString(resId, num, callback) { - var data = "mock plural string"; + getPluralString: function(...args) { console.warn("ResourceManager.getPluralString interface mocked in the Previewer. " + "How this interface works on the Previewer may be different from that on a real device.") - if (typeof callback === 'function') { - callback.call(this, null, data); + 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(data); + return new Promise((resolve, reject) => { + resolve(paramMock.paramStringMock); }) } - } + }, - this.getConfiguration = getConfiguration; - async function getConfiguration(callback) { - var data = { "direction": 0, "locale": "zh_CN" }; + getConfiguration: function(...args) { console.warn("ResourceManager.getConfiguration interface mocked in the Previewer. " + "How this interface works on the Previewer may be different from that on a real device.") - if (typeof callback === 'function') { - callback.call(this, null, data); + const len = args.length + if (typeof args[len - 1] === 'function') { + args[len - 1].call(this, paramMock.businessErrorMock, new ConfigurationClass()); } else { - return new Promise((resolve) => { - resolve(data); + return new Promise((resolve, reject) => { + resolve(new ConfigurationClass()); }) } - } + }, - this.getDeviceCapability = getDeviceCapability; - async function getDeviceCapability(callback) { - var data = { "deviceType": 0, "screenDensity": 480 }; + getDeviceCapability: function(...args) { console.warn("ResourceManager.getDeviceCapability interface mocked in the Previewer. " + "How this interface works on the Previewer may be different from that on a real device.") - if (typeof callback === 'function') { - callback.call(this, null, data); + const len = args.length + if (typeof args[len - 1] === 'function') { + args[len - 1].call(this, paramMock.businessErrorMock, new DeviceCapabilityClass()); } else { - return new Promise((resolve) => { - resolve(data); + return new Promise((resolve, reject) => { + resolve(new DeviceCapabilityClass()); }) } - } + }, - this.release = release; - async function release(callback) { + release: function() { console.warn("ResourceManager.release interface mocked in the Previewer. " + "How this interface works on the Previewer may be different from that on a real device.") - } + }, - this.getRawFile = getRawFile; - async function getRawFile(path, callback) { - var data = "mock raw file"; + getRawFile: function(...args) { console.warn("ResourceManager.getRawFile interface mocked in the Previewer. " + "How this interface works on the Previewer may be different from that on a real device.") - if (typeof callback === 'function') { - callback.call(this, null, data); + 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(data); + return new Promise((resolve, reject) => { + resolve(paramMock.paramArrayMock); }) } - } + }, - this.getRawFileDescriptor = getRawFileDescriptor; - async function getRawFileDescriptor(path, callback) { - var data = "mock raw file descriptor"; + getRawFileDescriptor: function(...args) { console.warn("ResourceManager.getRawFileDescriptor interface mocked in the Previewer. " + "How this interface works on the Previewer may be different from that on a real device.") - if (typeof callback === 'function') { - callback.call(this, null, data); + const len = args.length + if (typeof args[len - 1] === 'function') { + args[len - 1].call(this, paramMock.businessErrorMock, RawFileDescriptor); } else { - return new Promise((resolve) => { - resolve(data); + return new Promise((resolve, reject) => { + resolve(RawFileDescriptor); }) } - } + }, - this.closeRawFileDescriptor = closeRawFileDescriptor; - async function closeRawFileDescriptor(path, callback) { - var data = "mock close raw file descriptor"; + closeRawFileDescriptor: function(...args) { console.warn("ResourceManager.closeRawFileDescriptor interface mocked in the Previewer. " + "How this interface works on the Previewer may be different from that on a real device.") - if (typeof callback === 'function') { - callback.call(this, null, data); + 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(data); + return new Promise((resolve, reject) => { + resolve(paramMock.paramStringMock); }) } + }, + + getStringByName: function(...args) { + console.warn("ResourceManager.getStringByName interface mocked in the Previewer. " + + "How this interface works on the Previewer may be different from that on a real device.") + const len = args.length + if (typeof args[len - 1] === 'function') { + args[len - 1].call(this, paramMock.businessErrorMock, paramMock.paramStringMock); + } else { + return new Promise((resolve, reject) => { + resolve(paramMock.paramStringMock); + }) + } + }, + + getStringArrayByName: function(...args) { + console.warn("ResourceManager.getStringArrayByName interface mocked in the Previewer. " + + "How this interface works on the Previewer may be different from that on a real device.") + const len = args.length + if (typeof args[len - 1] === 'function') { + args[len - 1].call(this, paramMock.businessErrorMock, [paramMock.paramStringMock]); + } else { + return new Promise((resolve, reject) => { + resolve([paramMock.paramStringMock]); + }) + } + }, + + getMediaByName: function(...args) { + console.warn("ResourceManager.getMediaByName interface mocked in the Previewer. " + + "How this interface works on the Previewer may be different from that on a real device.") + const len = args.length + if (typeof args[len - 1] === 'function') { + args[len - 1].call(this, paramMock.businessErrorMock, paramMock.paramArrayMock); + } else { + return new Promise((resolve, reject) => { + resolve(paramMock.paramArrayMock); + }) + } + }, + + getMediaBase64ByName: function(...args) { + console.warn("ResourceManager.getMediaBase64ByName interface mocked in the Previewer. " + + "How this interface works on the Previewer may be different from that on a real device.") + const len = args.length + if (typeof args[len - 1] === 'function') { + args[len - 1].call(this, paramMock.businessErrorMock, paramMock.paramArrayMock); + } else { + return new Promise((resolve, reject) => { + resolve(paramMock.paramArrayMock); + }) + } + }, + + getPluralStringByName: function(...args) { + console.warn("ResourceManager.getPluralStringByName interface mocked in the Previewer. " + + "How this interface works on the Previewer may be different from that on a real device.") + const len = args.length + if (typeof args[len - 1] === 'function') { + args[len - 1].call(this, paramMock.businessErrorMock, paramMock.paramStringMock); + } else { + return new Promise((resolve, reject) => { + resolve(paramMock.paramStringMock); + }) + } + }, + + getStringSync: function(...args) { + console.warn("ResourceManager.getStringSync interface mocked in the Previewer. " + + "How this interface works on the Previewer may be different from that on a real device.") + return paramMock.paramStringMock; + }, + + getStringByNameSync: function(...args) { + console.warn("ResourceManager.getStringByNameSync interface mocked in the Previewer. " + + "How this interface works on the Previewer may be different from that on a real device.") + return paramMock.paramStringMock; + }, + + getBoolean: function(...args) { + console.warn("ResourceManager.getBoolean interface mocked in the Previewer. " + + "How this interface works on the Previewer may be different from that on a real device.") + return paramMock.paramBooleanMock; + }, + + getBooleanByName: function(...args) { + console.warn("ResourceManager.getBooleanByName interface mocked in the Previewer. " + + "How this interface works on the Previewer may be different from that on a real device.") + return paramMock.paramBooleanMock; + }, + + getNumber: function(...args) { + console.warn("ResourceManager.getNumber interface mocked in the Previewer. " + + "How this interface works on the Previewer may be different from that on a real device.") + return paramMock.paramNumberMock; + }, + + getNumberByName: function(...args) { + console.warn("ResourceManager.getNumberByName interface mocked in the Previewer. " + + "How this interface works on the Previewer may be different from that on a real device.") + return paramMock.paramNumberMock; } } - var resourceManagerMock = { + const resourceManager = { + ResourceManager, getResourceManager: async function getResourceManager(optBundleName, optCallback) { let bundleName = ''; let callback; @@ -187,21 +308,18 @@ export function mockResourceManager() { } 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); + callback.call(this, paramMock.businessErrorMock, ResourceManager); } else { - return new Promise((resolve) => { - resolve(data); + return new Promise((resolve, reject) => { + resolve(ResourceManager); }) } - } - }; - - const resourceManager = { - getResourceManager: resourceManagerMock.getResourceManager + }, } - return resourceManager + return resourceManager; } + + From 579e09408b7f25f9e6e1c7319237394ce4e4adf5 Mon Sep 17 00:00:00 2001 From: liuyanzhi Date: Thu, 7 Jul 2022 21:30:04 +0800 Subject: [PATCH 047/109] application mock Signed-off-by: liuyanzhi Change-Id: I2cf2fcc8df92d41e6a7014e9b316b5d4a2b3c1d9 --- runtime/main/extend/systemplugin/ability.js | 26 +-- runtime/main/extend/systemplugin/index.js | 2 - .../napi/application/abilityDelegator.js | 155 ++++++++++++++++++ .../napi/application/abilityDelegatorArgs.js | 21 +++ .../napi/application/shellCmdResult.js | 19 +++ .../main/extend/systemplugin/napi/index.js | 11 +- .../napi/ohos_ability_dataUriUtils.js | 42 +++++ .../napi/ohos_application_Ability.js | 122 +++++++------- .../napi/ohos_application_AbilityConstant.js | 20 +++ ...os_application_AbilityLifecycleCallback.js | 54 ++++++ .../napi/ohos_application_Want.js | 32 ++++ ...os_application_abilityDelegatorRegistry.js | 41 +++++ 12 files changed, 454 insertions(+), 91 deletions(-) create mode 100644 runtime/main/extend/systemplugin/napi/application/abilityDelegator.js create mode 100644 runtime/main/extend/systemplugin/napi/application/abilityDelegatorArgs.js create mode 100644 runtime/main/extend/systemplugin/napi/application/shellCmdResult.js create mode 100644 runtime/main/extend/systemplugin/napi/ohos_ability_dataUriUtils.js create mode 100644 runtime/main/extend/systemplugin/napi/ohos_application_AbilityConstant.js create mode 100644 runtime/main/extend/systemplugin/napi/ohos_application_AbilityLifecycleCallback.js create mode 100644 runtime/main/extend/systemplugin/napi/ohos_application_Want.js create mode 100644 runtime/main/extend/systemplugin/napi/ohos_application_abilityDelegatorRegistry.js diff --git a/runtime/main/extend/systemplugin/ability.js b/runtime/main/extend/systemplugin/ability.js index e69545de..64ecc6d8 100644 --- a/runtime/main/extend/systemplugin/ability.js +++ b/runtime/main/extend/systemplugin/ability.js @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021 Huawei Device Co., Ltd. + * Copyright (c) 2021-2022 Huawei Device Co., Ltd. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at @@ -1355,30 +1355,6 @@ export function mockAbilityContinuationRegisterManager() { } } } -export function mockAbilityDataUriUtils() { - global.systemplugin.ability.dataUriUtils = { - getId: function (...args) { - console.warn("ability.dataUriUtils.getId interface mocked in the Previewer. How this interface works" + - " on the Previewer may be different from that on a real device.") - return paramMock.paramNumberMock - }, - attachId: function (...args) { - console.warn("ability.dataUriUtils.attachId interface mocked in the Previewer. How this interface works" + - " on the Previewer may be different from that on a real device.") - return paramMock.paramStringMock - }, - deleteId: function (...args) { - console.warn("ability.dataUriUtils.deleteId interface mocked in the Previewer. How this interface works" + - " on the Previewer may be different from that on a real device.") - return paramMock.paramStringMock - }, - updateId: function (...args) { - console.warn("ability.dataUriUtils.updateId interface mocked in the Previewer. How this interface works" + - " on the Previewer may be different from that on a real device.") - return paramMock.paramStringMock - } - } -} export function mockAbilityAbilityAgent() { global.systemplugin.ability.abilityAgent = { on: function (...args) { diff --git a/runtime/main/extend/systemplugin/index.js b/runtime/main/extend/systemplugin/index.js index aa9b3208..6bb85b48 100644 --- a/runtime/main/extend/systemplugin/index.js +++ b/runtime/main/extend/systemplugin/index.js @@ -20,7 +20,6 @@ import { mockAbilityParticleAbility, mockAbilityFormManager, mockAbilityContinuationRegisterManager, - mockAbilityDataUriUtils, mockAbilityAbilityAgent, mockAbilityFormBindingData } from './ability' @@ -73,7 +72,6 @@ export function mockSystemPlugin() { mockAbilityFeatureAbility() mockAbilityContinuationRegisterManager() mockRequireNapiFun() - mockAbilityDataUriUtils() mockAccessibility() mockAbilityParticleAbility() mockAbilityFormManager() diff --git a/runtime/main/extend/systemplugin/napi/application/abilityDelegator.js b/runtime/main/extend/systemplugin/napi/application/abilityDelegator.js new file mode 100644 index 00000000..fb5d7fa1 --- /dev/null +++ b/runtime/main/extend/systemplugin/napi/application/abilityDelegator.js @@ -0,0 +1,155 @@ +/* + * Copyright (c) 2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import { paramMock } from "../../utils" +import { AbilityClass } from "../ohos_application_Ability" +import { ContextClass } from "../ohos_application_ServiceExtAbility" +import { ShellCmdResult } from "./shellCmdResult" + +export const AbilityDelegator = { + addAbilityMonitor: function (...args) { + console.warn("AbilityDelegator.addAbilityMonitor interface mocked in the Previewer." + + " How this interface works on the Previewer may be different from 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(); + }) + } + }, + removeAbilityMonitor: function (...args) { + console.warn("AbilityDelegator.removeAbilityMonitor interface mocked in the Previewer." + + " How this interface works on the Previewer may be different from 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(); + }) + } + }, + waitAbilityMonitor: function (...args) { + console.warn("AbilityDelegator.waitAbilityMonitor interface mocked in the Previewer." + + " How this interface works on the Previewer may be different from that on a real device.") + const len = args.length + if (len > 0 && typeof args[len - 1] === 'function') { + args[len - 1].call(this, paramMock.businessErrorMock, new AbilityClass()); + } else { + return new Promise((resolve, reject) => { + resolve(new AbilityClass()); + }) + } + }, + getAppContext: function (...args) { + console.warn('AbilityDelegator.getAppContext interface mocked in the Previewer. How this interface works on the' + + ' Previewer may be different from that on a real device.'); + return new ContextClass(); + }, + getAbilityState: function (...args) { + console.warn('AbilityDelegator.getAbilityState interface mocked in the Previewer. How this interface works on the' + + ' Previewer may be different from that on a real device.'); + return paramMock.paramNumberMock; + }, + getCurrentTopAbility: function (...args) { + console.warn("AbilityDelegator.getCurrentTopAbility interface mocked in the Previewer." + + " How this interface works on the Previewer may be different from that on a real device.") + const len = args.length + if (len > 0 && typeof args[len - 1] === 'function') { + args[len - 1].call(this, paramMock.businessErrorMock, new AbilityClass()); + } else { + return new Promise((resolve, reject) => { + resolve(new AbilityClass()); + }) + } + }, + startAbility: function (...args) { + console.warn("AbilityDelegator.startAbility interface mocked in the Previewer." + + " How this interface works on the Previewer may be different from that on a real device.") + const len = args.length + if (len > 0 && typeof args[len - 1] === 'function') { + args[len - 1].call(this, paramMock.businessErrorMock); + } else { + return new Promise((resolve, reject) => { + resolve(); + }) + } + }, + doAbilityForeground: function (...args) { + console.warn("AbilityDelegator.doAbilityForeground interface mocked in the Previewer." + + " How this interface works on the Previewer may be different from that on a real device.") + const len = args.length + if (len > 0 && typeof args[len - 1] === 'function') { + args[len - 1].call(this, paramMock.businessErrorMock, paramMock.paramBooleanMock); + } else { + return new Promise((resolve, reject) => { + resolve(paramMock.paramBooleanMock); + }) + } + }, + doAbilityBackground: function (...args) { + console.warn("AbilityDelegator.doAbilityBackground interface mocked in the Previewer." + + " How this interface works on the Previewer may be different from that on a real device.") + const len = args.length + if (len > 0 && typeof args[len - 1] === 'function') { + args[len - 1].call(this, paramMock.businessErrorMock, paramMock.paramBooleanMock); + } else { + return new Promise((resolve, reject) => { + resolve(paramMock.paramBooleanMock); + }) + } + }, + print: function (...args) { + console.warn("AbilityDelegator.print interface mocked in the Previewer." + + " How this interface works on the Previewer may be different from 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(); + }) + } + }, + printSync: function (...args) { + console.warn('AbilityDelegator.printSync interface mocked in the Previewer. How this interface works on the' + + ' Previewer may be different from that on a real device.'); + }, + executeShellCommand: function (...args) { + console.warn("AbilityDelegator.executeShellCommand interface mocked in the Previewer." + + " How this interface works on the Previewer may be different from that on a real device.") + const len = args.length + if (len > 0 && typeof args[len - 1] === 'function') { + args[len - 1].call(this, paramMock.businessErrorMock, ShellCmdResult); + } else { + return new Promise((resolve, reject) => { + resolve(ShellCmdResult); + }) + } + }, + finishTest: function (...args) { + console.warn("AbilityDelegator.finishTest interface mocked in the Previewer." + + " How this interface works on the Previewer may be different from 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(); + }) + } + } +} \ No newline at end of file diff --git a/runtime/main/extend/systemplugin/napi/application/abilityDelegatorArgs.js b/runtime/main/extend/systemplugin/napi/application/abilityDelegatorArgs.js new file mode 100644 index 00000000..104b0367 --- /dev/null +++ b/runtime/main/extend/systemplugin/napi/application/abilityDelegatorArgs.js @@ -0,0 +1,21 @@ +/* + * Copyright (c) 2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +export const AbilityDelegatorArgs = { + bundleName: "[PC Preview] unknow bundleName", + parameters: {}, + testCaseNames: "[PC Preview] unknow testCaseNames", + testRunnerClassName: "[PC Preview] unknow testRunnerClassName", +} \ No newline at end of file diff --git a/runtime/main/extend/systemplugin/napi/application/shellCmdResult.js b/runtime/main/extend/systemplugin/napi/application/shellCmdResult.js new file mode 100644 index 00000000..920d25dd --- /dev/null +++ b/runtime/main/extend/systemplugin/napi/application/shellCmdResult.js @@ -0,0 +1,19 @@ +/* + * Copyright (c) 2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +export const ShellCmdResult = { + stdResult: "[PC Preview] unknow stdResult", + exitCode: "[PC Preview] unknow exitCode", +} \ No newline at end of file diff --git a/runtime/main/extend/systemplugin/napi/index.js b/runtime/main/extend/systemplugin/napi/index.js index 92e0645c..0401d174 100644 --- a/runtime/main/extend/systemplugin/napi/index.js +++ b/runtime/main/extend/systemplugin/napi/index.js @@ -15,6 +15,9 @@ import { mockSystemParameter } from './ohos_systemparameter' import { mockAbility } from './ohos_application_Ability' +import { mockDataUriUtils } from './ohos_ability_dataUriUtils' +import { mockAbilityDelegatorRegistry } from './ohos_application_abilityDelegatorRegistry' +import { mockAbilityLifecycleCallback } from './ohos_application_AbilityLifecycleCallback' import { mockFormExtension } from './ohos_application_FormExtension' import { mockServiceExtensionAbility } from './ohos_application_ServiceExtensionAbility' import { mockAbilityStage } from './ohos_application_AbilityStage' @@ -252,12 +255,18 @@ export function mockRequireNapiFun() { return mockOhosBatteryinfo(); case "systemParameter": return mockSystemParameter(); - case "11.Ability": + case "ability.dataUriUtils": + return mockDataUriUtils(); + case "application.Ability": return mockAbility(); case "application.FormExtension": return mockFormExtension(); case "application.ServiceExtensionAbility": return mockServiceExtensionAbility(); + case "application.abilityDelegatorRegistry": + return mockAbilityDelegatorRegistry(); + case "application.AbilityLifecycleCallback": + return mockAbilityLifecycleCallback(); case "application.AbilityStage": return mockAbilityStage(); case "application.formBindingData": diff --git a/runtime/main/extend/systemplugin/napi/ohos_ability_dataUriUtils.js b/runtime/main/extend/systemplugin/napi/ohos_ability_dataUriUtils.js new file mode 100644 index 00000000..9ed2ad00 --- /dev/null +++ b/runtime/main/extend/systemplugin/napi/ohos_ability_dataUriUtils.js @@ -0,0 +1,42 @@ +/* + * Copyright (c) 2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { paramMock } from "../utils" + +export function mockDataUriUtils() { + const dataUriUtils = { + getId: function (...args) { + console.warn("dataUriUtils.getId interface mocked in the Previewer. How this interface works" + + " on the Previewer may be different from that on a real device.") + return paramMock.paramNumberMock + }, + attachId: function (...args) { + console.warn("dataUriUtils.attachId interface mocked in the Previewer. How this interface works" + + " on the Previewer may be different from that on a real device.") + return paramMock.paramStringMock + }, + deleteId: function (...args) { + console.warn("dataUriUtils.deleteId interface mocked in the Previewer. How this interface works" + + " on the Previewer may be different from that on a real device.") + return paramMock.paramStringMock + }, + updateId: function (...args) { + console.warn("dataUriUtils.updateId interface mocked in the Previewer. How this interface works" + + " on the Previewer may be different from that on a real device.") + return paramMock.paramStringMock + } + } + return dataUriUtils; +} diff --git a/runtime/main/extend/systemplugin/napi/ohos_application_Ability.js b/runtime/main/extend/systemplugin/napi/ohos_application_Ability.js index 7402c1bb..51b30eb8 100644 --- a/runtime/main/extend/systemplugin/napi/ohos_application_Ability.js +++ b/runtime/main/extend/systemplugin/napi/ohos_application_Ability.js @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021 Huawei Device Co., Ltd. + * Copyright (c) 2021-2022 Huawei Device Co., Ltd. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at @@ -15,22 +15,9 @@ import { paramMock } from "../utils" import { AbilityContextClass } from "./application/abilityContext" +import { WantClass } from "./ohos_application_Want" +import { OnContinueResult } from "./ohos_application_AbilityConstant" -const WantClass = class Want { - constructor() { - console.warn('Ability.Want.constructor interface mocked in the Previewer. How this interface works on' + - ' the Previewer may be different from that on a real device.'); - this.deviceId = "[PC Preview] unknow deviceId"; - this.bundleName = "[PC Preview] unknow bundleName"; - this.abilityName = "[PC Preview] unknow abilityName"; - this.uri = "[PC Preview] unknow uri"; - this.type = "[PC Preview] unknow type"; - this.flag = "[PC Preview] unknow flag"; - this.action = "[PC Preview] unknow action"; - this.parameters = {}; - this.entities = [paramMock.paramStringMock]; - } -} const calleeMock = { on: function (...args) { console.warn("Ability.calleeClass.on interface mocked in the Previewer. How this interface works on the Previewer" + @@ -41,53 +28,62 @@ const calleeMock = { " may be different from that on a real device.") }, } -export function mockAbility() { - const AbilityClass = class Ability { - constructor() { - console.warn('application.Ability.constructor interface mocked in the Previewer. How this interface works on' + - ' the Previewer may be different from that on a real device.'); - this.context = new AbilityContextClass(); - this.launchWant = new WantClass(); - this.lastRequestWant = new WantClass(); - this.callee = calleeMock; - this.onCreate = function (...args) { - console.warn("application.Ability.onCreate interface mocked in the Previewer. How this interface works on the Previewer" + - " may be different from that on a real device.") - }; - this.onWindowStageCreate = function (...args) { - console.warn("application.Ability.onWindowStageCreate interface mocked in the Previewer. How this interface works on the Previewer" + - " may be different from that on a real device.") - }; - this.onWindowStageDestroy = function () { - console.warn("application.Ability.onWindowStageDestroy interface mocked in the Previewer. How this interface works on the Previewer" + - " may be different from that on a real device.") - }; - this.onDestroy = function () { - console.warn("application.Ability.onDestroy interface mocked in the Previewer. How this interface works on the Previewer" + - " may be different from that on a real device.") - }; - this.onForeground = function () { - console.warn("application.Ability.onForeground interface mocked in the Previewer. How this interface works on the Previewer" + - " may be different from that on a real device.") - }; - this.onBackground = function () { - console.warn("application.Ability.onBackground interface mocked in the Previewer. How this interface works on the Previewer" + - " may be different from that on a real device.") - }; - this.onContinue = function () { - console.warn("application.Ability.onContinue interface mocked in the Previewer. How this interface works on the Previewer" + - " may be different from that on a real device.") - return paramMock.paramBooleanMock; - }; - this.onNewWant = function () { - console.warn("application.Ability.onNewWant interface mocked in the Previewer. How this interface works on the Previewer" + - " may be different from that on a real device.") - }; - this.onConfigurationUpdated = function () { - console.warn("application.Ability.onConfigurationUpdated interface mocked in the Previewer. How this interface works on the Previewer" + - " may be different from that on a real device.") - }; - } +export const AbilityClass = class Ability { + constructor() { + console.warn('application.Ability.constructor interface mocked in the Previewer. How this interface works on' + + ' the Previewer may be different from that on a real device.'); + this.context = new AbilityContextClass(); + this.launchWant = new WantClass(); + this.lastRequestWant = new WantClass(); + this.callee = calleeMock; + this.onCreate = function (...args) { + console.warn("application.Ability.onCreate interface mocked in the Previewer. How this interface works on the Previewer" + + " may be different from that on a real device.") + }; + this.onWindowStageCreate = function (...args) { + console.warn("application.Ability.onWindowStageCreate interface mocked in the Previewer. How this interface works on the Previewer" + + " may be different from that on a real device.") + }; + this.onWindowStageDestroy = function () { + console.warn("application.Ability.onWindowStageDestroy interface mocked in the Previewer. How this interface works on the Previewer" + + " may be different from that on a real device.") + }; + this.onWindowStageRestore = function (...args) { + console.warn("application.Ability.onWindowStageRestore interface mocked in the Previewer. How this interface works on the Previewer" + + " may be different from that on a real device.") + }; + this.onDestroy = function () { + console.warn("application.Ability.onDestroy interface mocked in the Previewer. How this interface works on the Previewer" + + " may be different from that on a real device.") + }; + this.onForeground = function () { + console.warn("application.Ability.onForeground interface mocked in the Previewer. How this interface works on the Previewer" + + " may be different from that on a real device.") + }; + this.onBackground = function () { + console.warn("application.Ability.onBackground interface mocked in the Previewer. How this interface works on the Previewer" + + " may be different from that on a real device.") + }; + this.onContinue = function (...args) { + console.warn("application.Ability.onContinue interface mocked in the Previewer. How this interface works on the Previewer" + + " may be different from that on a real device.") + return OnContinueResult; + }; + this.onNewWant = function (...args) { + console.warn("application.Ability.onNewWant interface mocked in the Previewer. How this interface works on the Previewer" + + " may be different from that on a real device.") + }; + this.onConfigurationUpdated = function (...args) { + console.warn("application.Ability.onConfigurationUpdated interface mocked in the Previewer. How this interface works on the Previewer" + + " may be different from that on a real device.") + }; + this.dump = function (...args) { + console.warn("application.Ability.dump interface mocked in the Previewer. How this interface works on the Previewer" + + " may be different from that on a real device.") + return [paramMock.paramStringMock]; + }; } +} +export function mockAbility() { return new AbilityClass(); } diff --git a/runtime/main/extend/systemplugin/napi/ohos_application_AbilityConstant.js b/runtime/main/extend/systemplugin/napi/ohos_application_AbilityConstant.js new file mode 100644 index 00000000..4d1f9623 --- /dev/null +++ b/runtime/main/extend/systemplugin/napi/ohos_application_AbilityConstant.js @@ -0,0 +1,20 @@ +/* + * Copyright (c) 2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +export const OnContinueResult = { + AGREE: 0, + REJECT: 1, + MISMATCH: 2, +} \ No newline at end of file diff --git a/runtime/main/extend/systemplugin/napi/ohos_application_AbilityLifecycleCallback.js b/runtime/main/extend/systemplugin/napi/ohos_application_AbilityLifecycleCallback.js new file mode 100644 index 00000000..511379ed --- /dev/null +++ b/runtime/main/extend/systemplugin/napi/ohos_application_AbilityLifecycleCallback.js @@ -0,0 +1,54 @@ +/* + * Copyright (c) 2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { paramMock } from "../utils" + +export function mockAbilityLifecycleCallback() { + const AbilityLifecycleCallbackClass = class AbilityLifecycleCallback { + constructor() { + console.warn('application.AbilityLifecycleCallback.constructor interface mocked in the Previewer. How this interface works on' + + ' the Previewer may be different from that on a real device.'); + this.onAbilityCreate = function (...args) { + console.warn("application.AbilityLifecycleCallback.onAbilityCreate interface mocked in the Previewer. How this interface works on the Previewer" + + " may be different from that on a real device.") + }; + this.onAbilityWindowStageCreate = function (...args) { + console.warn("application.AbilityLifecycleCallback.onAbilityWindowStageCreate interface mocked in the Previewer. How this interface works on the Previewer" + + " may be different from that on a real device.") + }; + this.onAbilityWindowStageDestroy = function (...args) { + console.warn("application.AbilityLifecycleCallback.onAbilityWindowStageDestroy interface mocked in the Previewer. How this interface works on the Previewer" + + " may be different from that on a real device.") + }; + this.onAbilityDestroy = function (...args) { + console.warn("application.AbilityLifecycleCallback.onAbilityDestroy interface mocked in the Previewer. How this interface works on the Previewer" + + " may be different from that on a real device.") + }; + this.onAbilityForeground = function (...args) { + console.warn("application.AbilityLifecycleCallback.onAbilityForeground interface mocked in the Previewer. How this interface works on the Previewer" + + " may be different from that on a real device.") + }; + this.onAbilityBackground = function (...args) { + console.warn("application.AbilityLifecycleCallback.onAbilityBackground interface mocked in the Previewer. How this interface works on the Previewer" + + " may be different from that on a real device.") + }; + this.onAbilityContinue = function (...args) { + console.warn("application.AbilityLifecycleCallback.onAbilityContinue interface mocked in the Previewer. How this interface works on the Previewer" + + " may be different from that on a real device.") + }; + } + } + return new AbilityLifecycleCallbackClass(); +} \ No newline at end of file diff --git a/runtime/main/extend/systemplugin/napi/ohos_application_Want.js b/runtime/main/extend/systemplugin/napi/ohos_application_Want.js new file mode 100644 index 00000000..1fad9fd2 --- /dev/null +++ b/runtime/main/extend/systemplugin/napi/ohos_application_Want.js @@ -0,0 +1,32 @@ +/* + * Copyright (c) 2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import { paramMock } from "../utils" + +export const WantClass = class Want { + constructor() { + console.warn('Want.constructor interface mocked in the Previewer. How this interface works on' + + ' the Previewer may be different from that on a real device.'); + this.deviceId = "[PC Preview] unknow deviceId"; + this.bundleName = "[PC Preview] unknow bundleName"; + this.abilityName = "[PC Preview] unknow abilityName"; + this.uri = "[PC Preview] unknow uri"; + this.type = "[PC Preview] unknow type"; + this.flag = "[PC Preview] unknow flag"; + this.action = "[PC Preview] unknow action"; + this.parameters = {}; + this.entities = [paramMock.paramStringMock]; + this.moduleName = "[PC Preview] unknow moduleName"; + } +} \ No newline at end of file diff --git a/runtime/main/extend/systemplugin/napi/ohos_application_abilityDelegatorRegistry.js b/runtime/main/extend/systemplugin/napi/ohos_application_abilityDelegatorRegistry.js new file mode 100644 index 00000000..6b3df79d --- /dev/null +++ b/runtime/main/extend/systemplugin/napi/ohos_application_abilityDelegatorRegistry.js @@ -0,0 +1,41 @@ +/* + * Copyright (c) 2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { AbilityDelegator } from "./application/abilityDelegator" +import { AbilityDelegatorArgs } from "./application/abilityDelegatorArgs" + +export const AbilityLifecycleState = { + UNINITIALIZED: '[PC preview] unknow UNINITIALIZED', + CREATE: '[PC preview] unknow CREATE', + FOREGROUND: '[PC preview] unknow FOREGROUND', + BACKGROUND: '[PC preview] unknow BACKGROUND', + DESTROY: '[PC preview] unknow DESTROY', +} + +export function mockAbilityDelegatorRegistry() { + const abilityDelegatorRegistry = { + getAbilityDelegator: function () { + console.warn('abilityDelegatorRegistry.getAbilityDelegator interface mocked in the Previewer. How this interface works on the' + + ' Previewer may be different from that on a real device.'); + return AbilityDelegator; + }, + getArguments: function () { + console.warn('abilityDelegatorRegistry.getArguments interface mocked in the Previewer. How this interface works on the' + + ' Previewer may be different from that on a real device.'); + return AbilityDelegatorArgs; + }, + } + return abilityDelegatorRegistry +} \ No newline at end of file From 02e510e3540dc131891adcb9702177ce6b25fe5b Mon Sep 17 00:00:00 2001 From: hungry_feiwei Date: Sat, 9 Jul 2022 09:38:01 +0800 Subject: [PATCH 048/109] =?UTF-8?q?=C3=A4Fill=20in=20the=20missing=20mocks?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: hungry_feiwei Change-Id: I35f4ea8a61562c552c907a3e1b7a784c709f4660 --- .../systemplugin/napi/ohos_multimodalInput_inputConsumer.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/runtime/main/extend/systemplugin/napi/ohos_multimodalInput_inputConsumer.js b/runtime/main/extend/systemplugin/napi/ohos_multimodalInput_inputConsumer.js index 5bab4542..772faabd 100644 --- a/runtime/main/extend/systemplugin/napi/ohos_multimodalInput_inputConsumer.js +++ b/runtime/main/extend/systemplugin/napi/ohos_multimodalInput_inputConsumer.js @@ -17,7 +17,7 @@ import { paramMock } from "../utils" export function mockInputConsumer() { const KeyOptions = { - preKeys: ["[PC preview] unknown preKeys"], + preKeys: [param.paramNumberMock], finalKey: "[PC preview] unknown finalKey", isFinalKeyDown: "[PC preview] unknown isFinalKeyDown", finalKeyDownDuration: "[PC preview] unknown finalKeyDownDuration", From 65cf61b43230c952d9eaca38ec692cec199ef3ed Mon Sep 17 00:00:00 2001 From: li-yaoyao777 Date: Mon, 11 Jul 2022 08:56:01 +0800 Subject: [PATCH 049/109] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E6=A3=80=E8=A7=86?= =?UTF-8?q?=E6=84=8F=E8=A7=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: li-yaoyao777 --- runtime/main/extend/systemplugin/napi/ohos_sensor.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/runtime/main/extend/systemplugin/napi/ohos_sensor.js b/runtime/main/extend/systemplugin/napi/ohos_sensor.js index ab7f0d00..60f410e5 100644 --- a/runtime/main/extend/systemplugin/napi/ohos_sensor.js +++ b/runtime/main/extend/systemplugin/napi/ohos_sensor.js @@ -337,7 +337,7 @@ export function mockSensor() { args[len - 1].call(this, paramMock.businessErrorMock, paramMock.paramArrayMock); } else { return new Promise((resolve, reject) => { - resolve(paramMock.RotationMatrixResponse); + resolve(RotationMatrixResponse); }); } } else if (len == 3) { @@ -362,7 +362,7 @@ export function mockSensor() { + 'Previewer may be different from that on a real device.') const len = args.length if (typeof args[len - 1] === 'function') { - args[len - 1].call(this, paramMock.businessErrorMock, paramMock.[paramMock.paraNumberMock]); + args[len - 1].call(this, paramMock.businessErrorMock, [paramMock.paraNumberMock]); } else { return new Promise((resolve, reject) => { resolve([paramMock.paraNumberMock]); @@ -398,7 +398,7 @@ export function mockSensor() { + 'Previewer may be different from that on a real device.') const len = args.length if (typeof args[len - 1] === 'function') { - args[len - 1].call(this, paramMock.businessErrorMock, Array(Sensor)); + args[len - 1].call(this, paramMock.businessErrorMock,new Array(Sensor)); } else { return new Promise((resolve, reject) => { resolve(Array(Sensor)); From 6a49f0af97a1618dc47afa0b37179faf2267a8fd Mon Sep 17 00:00:00 2001 From: li-yaoyao777 Date: Mon, 11 Jul 2022 09:24:52 +0800 Subject: [PATCH 050/109] =?UTF-8?q?=E6=A0=BC=E5=BC=8F=E5=AF=B9=E9=BD=90?= =?UTF-8?q?=EF=BC=8C=E5=9B=9B=E5=AD=97=E7=AC=A6=E7=BC=A9=E8=BF=9B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: li-yaoyao777 --- runtime/main/extend/systemplugin/napi/ohos_sensor.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/runtime/main/extend/systemplugin/napi/ohos_sensor.js b/runtime/main/extend/systemplugin/napi/ohos_sensor.js index 60f410e5..66b6f6d0 100644 --- a/runtime/main/extend/systemplugin/napi/ohos_sensor.js +++ b/runtime/main/extend/systemplugin/napi/ohos_sensor.js @@ -314,7 +314,7 @@ export function mockSensor() { }, getAngleModify: function (...args) { console.warn('sensor.getAngleModifiy interface mocked in the Previewer. How this interface works on the' - + 'Previewer may be different from that on a real device.') + + 'Previewer may be different from that on a real device.') const len = args.length if (typeof args[len - 1] === 'function') { args[len - 1].call(this, paramMock.businessErrorMock, [paramMock.paraNumberMock]); From 83a5b49a6d41dc59d8785ff2bc470f632509263b Mon Sep 17 00:00:00 2001 From: li-yaoyao777 Date: Mon, 11 Jul 2022 09:28:40 +0800 Subject: [PATCH 051/109] =?UTF-8?q?=E6=A0=BC=E5=BC=8F=E5=AF=B9=E9=BD=90?= =?UTF-8?q?=EF=BC=8C=E5=9B=9B=E5=AD=97=E7=AC=A6=E7=BC=A9=E8=BF=9B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: li-yaoyao777 --- .../main/extend/systemplugin/napi/ohos_sensor.js | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/runtime/main/extend/systemplugin/napi/ohos_sensor.js b/runtime/main/extend/systemplugin/napi/ohos_sensor.js index 66b6f6d0..711782c2 100644 --- a/runtime/main/extend/systemplugin/napi/ohos_sensor.js +++ b/runtime/main/extend/systemplugin/napi/ohos_sensor.js @@ -178,8 +178,8 @@ export function mockSensor() { on: function (...args) { console.warn('sensor.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; - const callback = typeof args[len - 1] === 'function' ? args[len - 1] : args[len - 2]; + const len = args.length; + const callback = typeof args[len - 1] === 'function' ? args[len - 1] : args[len - 2]; if (args[0] == 1) { callback.call(this, AccelerometerResponse); } else if (args[0] == 2) { @@ -227,7 +227,7 @@ export function mockSensor() { once: function (...args) { console.warn('sensor.once interface mocked in the Previewer. How this interface works on the' + 'Previewer may be different from that on a real device.') - const len = args.length + const len = args.length if (args[0] == 1) { args[len - 1].call(this, AccelerometerResponse); } else if (args[0] == 2) { @@ -337,7 +337,7 @@ export function mockSensor() { args[len - 1].call(this, paramMock.businessErrorMock, paramMock.paramArrayMock); } else { return new Promise((resolve, reject) => { - resolve(RotationMatrixResponse); + resolve(RotationMatrixResponse); }); } } else if (len == 3) { @@ -358,10 +358,10 @@ export function mockSensor() { } }, createQuaternion: function (...args) { - console.warn('sensor.createQuaternion interface mocked in the Previewer. How this interface works on the' + console.warn('sensor.createQuaternion interface mocked in the Previewer. How this interface works on the' + 'Previewer may be different from that on a real device.') - const len = args.length - if (typeof args[len - 1] === 'function') { + const len = args.length + if (typeof args[len - 1] === 'function') { args[len - 1].call(this, paramMock.businessErrorMock, [paramMock.paraNumberMock]); } else { return new Promise((resolve, reject) => { From 1471832b39f5ec1b6b972764b886f49940f4724e Mon Sep 17 00:00:00 2001 From: li-yaoyao777 Date: Mon, 11 Jul 2022 09:46:43 +0800 Subject: [PATCH 052/109] =?UTF-8?q?=E6=A0=BC=E5=BC=8F=E5=AF=B9=E9=BD=90?= =?UTF-8?q?=EF=BC=8C=E5=9B=9B=E5=AD=97=E7=AC=A6=E7=BC=A9=E8=BF=9B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: li-yaoyao777 --- .../extend/systemplugin/napi/ohos_sensor.js | 172 +++++++++--------- 1 file changed, 86 insertions(+), 86 deletions(-) diff --git a/runtime/main/extend/systemplugin/napi/ohos_sensor.js b/runtime/main/extend/systemplugin/napi/ohos_sensor.js index 711782c2..fddc787f 100644 --- a/runtime/main/extend/systemplugin/napi/ohos_sensor.js +++ b/runtime/main/extend/systemplugin/napi/ohos_sensor.js @@ -180,97 +180,97 @@ export function mockSensor() { + 'Previewer may be different from that on a real device.') const len = args.length; const callback = typeof args[len - 1] === 'function' ? args[len - 1] : args[len - 2]; - if (args[0] == 1) { - callback.call(this, AccelerometerResponse); - } else if (args[0] == 2) { - callback.call(this, GyroscopeResponse); - } else if (args[0] == 5) { - callback.call(this, LightResponse); - } else if (args[0] == 6) { - callback.call(this, MagneticFieldResponse); - } else if (args[0] == 8) { - callback.call(this, BarometerResponse); - } else if (args[0] == 10) { - callback.call(this, HallResponse); - } else if (args[0] == 12) { - callback.call(this, ProximityResponse); - } else if (args[0] == 13) { - callback.call(this, HumidityResponse); - } else if (args[0] == 256) { - callback.call(this, OrientationResponse); - } else if (args[0] == 257) { - callback.call(this, GravityResponse); - } else if (args[0] == 258) { - callback.call(this, LinearAccelerometerResponse); - } else if (args[0] == 259) { - callback.call(this, RotationVectorResponse); - } else if (args[0] == 260) { - callback.call(this, AmbientTemperatureResponse); - } else if (args[0] == 261) { - callback.call(this, MagneticFieldUncalibratedResponse); - } else if (args[0] == 263) { - callback.call(this, GyroscopeUncalibratedResponse); - } else if (args[0] == 264) { - callback.call(this, SignificantMotionResponse); - } else if (args[0] == 265) { - callback.call(this, PedometerDetectResponse); - } else if (args[0] == 266) { - callback.call(this, PedometerResponse); - } else if (args[0] == 278) { - callback.call(this, HeartRateResponse); - } else if (args[0] == 280) { - callback.call(this, WearDetectionResponse); - } else if (args[0] == 281) { - callback.call(this, AccelerometerUncalibratedResponse); - } + if (args[0] == 1) { + callback.call(this, AccelerometerResponse); + } else if (args[0] == 2) { + callback.call(this, GyroscopeResponse); + } else if (args[0] == 5) { + callback.call(this, LightResponse); + } else if (args[0] == 6) { + callback.call(this, MagneticFieldResponse); + } else if (args[0] == 8) { + callback.call(this, BarometerResponse); + } else if (args[0] == 10) { + callback.call(this, HallResponse); + } else if (args[0] == 12) { + callback.call(this, ProximityResponse); + } else if (args[0] == 13) { + callback.call(this, HumidityResponse); + } else if (args[0] == 256) { + callback.call(this, OrientationResponse); + } else if (args[0] == 257) { + callback.call(this, GravityResponse); + } else if (args[0] == 258) { + callback.call(this, LinearAccelerometerResponse); + } else if (args[0] == 259) { + callback.call(this, RotationVectorResponse); + } else if (args[0] == 260) { + callback.call(this, AmbientTemperatureResponse); + } else if (args[0] == 261) { + callback.call(this, MagneticFieldUncalibratedResponse); + } else if (args[0] == 263) { + callback.call(this, GyroscopeUncalibratedResponse); + } else if (args[0] == 264) { + callback.call(this, SignificantMotionResponse); + } else if (args[0] == 265) { + callback.call(this, PedometerDetectResponse); + } else if (args[0] == 266) { + callback.call(this, PedometerResponse); + } else if (args[0] == 278) { + callback.call(this, HeartRateResponse); + } else if (args[0] == 280) { + callback.call(this, WearDetectionResponse); + } else if (args[0] == 281) { + callback.call(this, AccelerometerUncalibratedResponse); + } }, once: function (...args) { console.warn('sensor.once interface mocked in the Previewer. How this interface works on the' + 'Previewer may be different from that on a real device.') const len = args.length - if (args[0] == 1) { - args[len - 1].call(this, AccelerometerResponse); - } else if (args[0] == 2) { - args[len - 1].call(this, GyroscopeResponse); - } else if (args[0] == 5) { - args[len - 1].call(this, LightResponse); - } else if (args[0] == 6) { - args[len - 1].call(this, MagneticFieldResponse); - } else if (args[0] == 8) { - args[len - 1].call(this, BarometerResponse); - } else if (args[0] == 10) { - args[len - 1].call(this, HallResponse); - } else if (args[0] == 12) { - args[len - 1].call(this, ProximityResponse); - } else if (args[0] == 13) { - args[len - 1].call(this, HumidityResponse); - } else if (args[0] == 256) { - args[len - 1].call(this, OrientationResponse); - } else if (args[0] == 257) { - args[len - 1].call(this, GravityResponse); - } else if (args[0] == 258) { - args[len - 1].call(this, LinearAccelerometerResponse); - } else if (args[0] == 259) { - args[len - 1].call(this, RotationVectorResponse); - } else if (args[0] == 260) { - args[len - 1].call(this, AmbientTemperatureResponse); - } else if (args[0] == 261) { - args[len - 1].call(this, MagneticFieldUncalibratedResponse); - } else if (args[0] == 263) { - args[len - 1].call(this, GyroscopeUncalibratedResponse); - } else if (args[0] == 264) { - args[len - 1].call(this, SignificantMotionResponse); - } else if (args[0] == 265) { - args[len - 1].call(this, PedometerDetectResponse); - } else if (args[0] == 266) { - args[len - 1].call(this, PedometerResponse); - } else if (args[0] == 278) { - args[len - 1].call(this, HeartRateResponse); - } else if (args[0] == 280) { - args[len - 1].call(this, WearDetectionResponse); - } else if (args[0] == 281) { - args[len - 1].call(this, AccelerometerUncalibratedResponse); - } + if (args[0] == 1) { + args[len - 1].call(this, AccelerometerResponse); + } else if (args[0] == 2) { + args[len - 1].call(this, GyroscopeResponse); + } else if (args[0] == 5) { + args[len - 1].call(this, LightResponse); + } else if (args[0] == 6) { + args[len - 1].call(this, MagneticFieldResponse); + } else if (args[0] == 8) { + args[len - 1].call(this, BarometerResponse); + } else if (args[0] == 10) { + args[len - 1].call(this, HallResponse); + } else if (args[0] == 12) { + args[len - 1].call(this, ProximityResponse); + } else if (args[0] == 13) { + args[len - 1].call(this, HumidityResponse); + } else if (args[0] == 256) { + args[len - 1].call(this, OrientationResponse); + } else if (args[0] == 257) { + args[len - 1].call(this, GravityResponse); + } else if (args[0] == 258) { + args[len - 1].call(this, LinearAccelerometerResponse); + } else if (args[0] == 259) { + args[len - 1].call(this, RotationVectorResponse); + } else if (args[0] == 260) { + args[len - 1].call(this, AmbientTemperatureResponse); + } else if (args[0] == 261) { + args[len - 1].call(this, MagneticFieldUncalibratedResponse); + } else if (args[0] == 263) { + args[len - 1].call(this, GyroscopeUncalibratedResponse); + } else if (args[0] == 264) { + args[len - 1].call(this, SignificantMotionResponse); + } else if (args[0] == 265) { + args[len - 1].call(this, PedometerDetectResponse); + } else if (args[0] == 266) { + args[len - 1].call(this, PedometerResponse); + } else if (args[0] == 278) { + args[len - 1].call(this, HeartRateResponse); + } else if (args[0] == 280) { + args[len - 1].call(this, WearDetectionResponse); + } else if (args[0] == 281) { + args[len - 1].call(this, AccelerometerUncalibratedResponse); + } }, off: function (...args) { console.warn('sensor.off interface mocked in the Previewer. How this interface works on the' From a6a078105a0bfcb6543eeb213aa52ef9e3e998c9 Mon Sep 17 00:00:00 2001 From: liuyanzhi Date: Thu, 7 Jul 2022 21:30:04 +0800 Subject: [PATCH 053/109] application mock Signed-off-by: liuyanzhi Change-Id: I2cf2fcc8df92d41e6a7014e9b316b5d4a2b3c1d9 --- .../napi/ohos_application_abilityDelegatorRegistry.js | 1 + 1 file changed, 1 insertion(+) diff --git a/runtime/main/extend/systemplugin/napi/ohos_application_abilityDelegatorRegistry.js b/runtime/main/extend/systemplugin/napi/ohos_application_abilityDelegatorRegistry.js index 6b3df79d..8eb11310 100644 --- a/runtime/main/extend/systemplugin/napi/ohos_application_abilityDelegatorRegistry.js +++ b/runtime/main/extend/systemplugin/napi/ohos_application_abilityDelegatorRegistry.js @@ -24,6 +24,7 @@ export const AbilityLifecycleState = { DESTROY: '[PC preview] unknow DESTROY', } + export function mockAbilityDelegatorRegistry() { const abilityDelegatorRegistry = { getAbilityDelegator: function () { From 81f909a11157bde58794b45e5e4d7e0b34590ef6 Mon Sep 17 00:00:00 2001 From: liuyanzhi Date: Mon, 11 Jul 2022 09:48:15 +0800 Subject: [PATCH 054/109] add notification mock Signed-off-by: liuyanzhi Change-Id: I702f482a875f304f74c01b7ade3d66159284bdec --- .../napi/commonEvent/commonEventData.js | 22 + .../commonEvent/commonEventPublishData.js | 25 + .../commonEvent/commonEventSubscribeInfo.js | 23 + .../napi/commonEvent/commonEventSubscriber.js | 163 +++++ .../notification/notificationActionButton.js | 22 + .../napi/notification/notificationContent.js | 45 ++ .../napi/notification/notificationFlags.js | 24 + .../napi/notification/notificationRequest.js | 67 ++ .../napi/notification/notificationSlot.js | 31 + .../napi/notification/notificationSorting.js | 21 + .../notification/notificationSortingMap.js | 20 + .../notification/notificationSubscribeInfo.js | 20 + .../notification/notificationSubscriber.js | 64 ++ .../napi/notification/notificationTemplate.js | 18 + .../notification/notificationUserInput.js | 17 + ...os_application_abilityDelegatorRegistry.js | 1 - .../systemplugin/napi/ohos_commonEvent.js | 355 ++++++----- .../systemplugin/napi/ohos_events_emitter.js | 23 +- .../systemplugin/napi/ohos_notification.js | 588 +++++++++--------- 19 files changed, 1073 insertions(+), 476 deletions(-) create mode 100644 runtime/main/extend/systemplugin/napi/commonEvent/commonEventData.js create mode 100644 runtime/main/extend/systemplugin/napi/commonEvent/commonEventPublishData.js create mode 100644 runtime/main/extend/systemplugin/napi/commonEvent/commonEventSubscribeInfo.js create mode 100644 runtime/main/extend/systemplugin/napi/commonEvent/commonEventSubscriber.js create mode 100644 runtime/main/extend/systemplugin/napi/notification/notificationActionButton.js create mode 100644 runtime/main/extend/systemplugin/napi/notification/notificationContent.js create mode 100644 runtime/main/extend/systemplugin/napi/notification/notificationFlags.js create mode 100644 runtime/main/extend/systemplugin/napi/notification/notificationRequest.js create mode 100644 runtime/main/extend/systemplugin/napi/notification/notificationSlot.js create mode 100644 runtime/main/extend/systemplugin/napi/notification/notificationSorting.js create mode 100644 runtime/main/extend/systemplugin/napi/notification/notificationSortingMap.js create mode 100644 runtime/main/extend/systemplugin/napi/notification/notificationSubscribeInfo.js create mode 100644 runtime/main/extend/systemplugin/napi/notification/notificationSubscriber.js create mode 100644 runtime/main/extend/systemplugin/napi/notification/notificationTemplate.js create mode 100644 runtime/main/extend/systemplugin/napi/notification/notificationUserInput.js diff --git a/runtime/main/extend/systemplugin/napi/commonEvent/commonEventData.js b/runtime/main/extend/systemplugin/napi/commonEvent/commonEventData.js new file mode 100644 index 00000000..83ee21a6 --- /dev/null +++ b/runtime/main/extend/systemplugin/napi/commonEvent/commonEventData.js @@ -0,0 +1,22 @@ +/* + * Copyright (c) 2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +export const CommonEventData = { + event: '[PC preview] unknow event', + bundleName: '[PC preview] unknow bundleName', + code: '[PC preview] unknow code', + data: '[PC preview] unknow data', + parameters: {} +} \ No newline at end of file diff --git a/runtime/main/extend/systemplugin/napi/commonEvent/commonEventPublishData.js b/runtime/main/extend/systemplugin/napi/commonEvent/commonEventPublishData.js new file mode 100644 index 00000000..9174974b --- /dev/null +++ b/runtime/main/extend/systemplugin/napi/commonEvent/commonEventPublishData.js @@ -0,0 +1,25 @@ +/* + * Copyright (c) 2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import { paramMock } from "../../utils" + +export const CommonEventPublishData = { + bundleName: '[PC preview] unknow bundleName', + code: '[PC preview] unknow code', + data: '[PC preview] unknow data', + subscriberPermissions: [paramMock.paramStringMock], + isOrdered: '[PC preview] unknow isOrdered', + isSticky: '[PC preview] unknow isSticky', + parameters: {} +} \ No newline at end of file diff --git a/runtime/main/extend/systemplugin/napi/commonEvent/commonEventSubscribeInfo.js b/runtime/main/extend/systemplugin/napi/commonEvent/commonEventSubscribeInfo.js new file mode 100644 index 00000000..d2cc1633 --- /dev/null +++ b/runtime/main/extend/systemplugin/napi/commonEvent/commonEventSubscribeInfo.js @@ -0,0 +1,23 @@ +/* + * Copyright (c) 2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import { paramMock } from "../../utils" + +export const CommonEventSubscribeInfo = { + events: [paramMock.paramStringMock], + publisherPermission: '[PC preview] unknow publisherPermission', + publisherDeviceId: '[PC preview] unknow publisherDeviceId', + userId: '[PC preview] unknow userId', + priority: '[PC preview] unknow priority' +} \ No newline at end of file diff --git a/runtime/main/extend/systemplugin/napi/commonEvent/commonEventSubscriber.js b/runtime/main/extend/systemplugin/napi/commonEvent/commonEventSubscriber.js new file mode 100644 index 00000000..0f478d53 --- /dev/null +++ b/runtime/main/extend/systemplugin/napi/commonEvent/commonEventSubscriber.js @@ -0,0 +1,163 @@ +/* + * Copyright (c) 2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import { paramMock } from "../../utils" +import { CommonEventSubscribeInfo } from "./commonEventSubscribeInfo" + +export const CommonEventSubscriber = { + getCode: function (...args) { + console.warn('CommonEventSubscriber.getCode interface mocked in the Previewer. How this interface works on the' + + ' Previewer may be different from that on a real device.'); + const len = args.length; + if (typeof args[len - 1] === 'function') { + args[len - 1].call(this, paramMock.businessErrorMock, paramMock.paramNumberMock); + } else { + return new Promise((resolve) => { + resolve(paramMock.paramNumberMock); + }); + } + }, + setCode: function (...args) { + console.warn('CommonEventSubscriber.setCode interface mocked in the Previewer. How this interface works on the' + + ' Previewer may be different from that on a real device.'); + const len = args.length; + if (typeof args[len - 1] === 'function') { + args[len - 1].call(this, paramMock.businessErrorMock); + } else { + return new Promise((resolve) => { + resolve(); + }); + } + }, + getData: function (...args) { + console.warn('CommonEventSubscriber.getData interface mocked in the Previewer. How this interface works on the' + + ' Previewer may be different from that on a real device.'); + const len = args.length; + if (typeof args[len - 1] === 'function') { + args[len - 1].call(this, paramMock.businessErrorMock, paramMock.paramStringMock); + } else { + return new Promise((resolve) => { + resolve(paramMock.paramStringMock); + }); + } + }, + setData: function (...args) { + console.warn('CommonEventSubscriber.setData interface mocked in the Previewer. How this interface works on the' + + ' Previewer may be different from that on a real device.'); + const len = args.length; + if (typeof args[len - 1] === 'function') { + args[len - 1].call(this, paramMock.businessErrorMock); + } else { + return new Promise((resolve) => { + resolve(); + }); + } + }, + setCodeAndData: function (...args) { + console.warn('CommonEventSubscriber.setCodeAndData interface mocked in the Previewer. How this interface works on the' + + ' Previewer may be different from that on a real device.'); + const len = args.length; + if (typeof args[len - 1] === 'function') { + args[len - 1].call(this, paramMock.businessErrorMock); + } else { + return new Promise((resolve) => { + resolve(); + }); + } + }, + isOrderedCommonEvent: function (...args) { + console.warn('CommonEventSubscriber.isOrderedCommonEvent interface mocked in the Previewer. How this interface works on the' + + ' Previewer may be different from that on a real device.'); + const len = args.length; + if (typeof args[len - 1] === 'function') { + args[len - 1].call(this, paramMock.businessErrorMock, paramMock.paramBooleanMock); + } else { + return new Promise((resolve) => { + resolve(paramMock.paramBooleanMock); + }); + } + }, + isStickyCommonEvent: function (...args) { + console.warn('CommonEventSubscriber.isStickyCommonEvent interface mocked in the Previewer. How this interface works on the' + + ' Previewer may be different from that on a real device.'); + const len = args.length; + if (typeof args[len - 1] === 'function') { + args[len - 1].call(this, paramMock.businessErrorMock, paramMock.paramBooleanMock); + } else { + return new Promise((resolve) => { + resolve(paramMock.paramBooleanMock); + }); + } + }, + abortCommonEvent: function (...args) { + console.warn('CommonEventSubscriber.abortCommonEvent interface mocked in the Previewer. How this interface works on the' + + ' Previewer may be different from that on a real device.'); + const len = args.length; + if (typeof args[len - 1] === 'function') { + args[len - 1].call(this, paramMock.businessErrorMock); + } else { + return new Promise((resolve) => { + resolve(); + }); + } + }, + clearAbortCommonEvent: function (...args) { + console.warn('CommonEventSubscriber.clearAbortCommonEvent interface mocked in the Previewer. How this interface works on the' + + ' Previewer may be different from that on a real device.'); + const len = args.length; + if (typeof args[len - 1] === 'function') { + args[len - 1].call(this, paramMock.businessErrorMock); + } else { + return new Promise((resolve) => { + resolve(); + }); + } + }, + getAbortCommonEvent: function (...args) { + console.warn('CommonEventSubscriber.getAbortCommonEvent interface mocked in the Previewer. How this interface works on the' + + ' Previewer may be different from that on a real device.'); + const len = args.length; + if (typeof args[len - 1] === 'function') { + args[len - 1].call(this, paramMock.businessErrorMock, paramMock.paramBooleanMock); + } else { + return new Promise((resolve) => { + resolve(paramMock.paramBooleanMock); + }); + } + }, + getSubscribeInfo: function (...args) { + console.warn('CommonEventSubscriber.getSubscribeInfo interface mocked in the Previewer. How this interface works on the' + + ' Previewer may be different from that on a real device.'); + const len = args.length; + if (typeof args[len - 1] === 'function') { + args[len - 1].call(this, paramMock.businessErrorMock, CommonEventSubscribeInfo); + } else { + return new Promise((resolve) => { + resolve(CommonEventSubscribeInfo); + }); + } + }, + finishCommonEvent: function (...args) { + console.warn('CommonEventSubscriber.finishCommonEvent interface mocked in the Previewer. How this interface works on the' + + ' Previewer may be different from that on a 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(); + }); + } + }, +} \ No newline at end of file diff --git a/runtime/main/extend/systemplugin/napi/notification/notificationActionButton.js b/runtime/main/extend/systemplugin/napi/notification/notificationActionButton.js new file mode 100644 index 00000000..f78f5a58 --- /dev/null +++ b/runtime/main/extend/systemplugin/napi/notification/notificationActionButton.js @@ -0,0 +1,22 @@ +/* + * Copyright (c) 2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import { NotificationUserInput } from "./notificationUserInput" + +export const NotificationActionButton = { + title: '[PC preview] unknow title', + wantAgent: '[PC preview] unknow wantAgent', + extras: {}, + userInput: NotificationUserInput, +} \ No newline at end of file diff --git a/runtime/main/extend/systemplugin/napi/notification/notificationContent.js b/runtime/main/extend/systemplugin/napi/notification/notificationContent.js new file mode 100644 index 00000000..25da4a05 --- /dev/null +++ b/runtime/main/extend/systemplugin/napi/notification/notificationContent.js @@ -0,0 +1,45 @@ +/* + * Copyright (c) 2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import { paramMock } from "../../utils" +import { ContentType } from "../ohos_notification" +import { PixelMapMock } from "../ohos_multimedia_image" + +export const NotificationBasicContent = { + title: '[PC preview] unknow title', + text: '[PC preview] unknow text', + additionalText: '[PC preview] unknow additionalText', +} +export const NotificationLongTextContent = { + longText: '[PC preview] unknow longText', + briefText: '[PC preview] unknow briefText', + expandedTitle: '[PC preview] unknow expandedTitle', +} +export const NotificationMultiLineContent = { + briefText: '[PC preview] unknow briefText', + longTitle: '[PC preview] unknow longTitle', + lines: [paramMock.paramStringMock], +} +export const NotificationPictureContent = { + briefText: '[PC preview] unknow briefText', + expandedTitle: '[PC preview] unknow expandedTitle', + picture: PixelMapMock, +} +export const NotificationContent = { + contentType: ContentType, + normal: NotificationBasicContent, + longText: NotificationLongTextContent, + multiLine: NotificationMultiLineContent, + picture: NotificationPictureContent, +} \ No newline at end of file diff --git a/runtime/main/extend/systemplugin/napi/notification/notificationFlags.js b/runtime/main/extend/systemplugin/napi/notification/notificationFlags.js new file mode 100644 index 00000000..44942bd3 --- /dev/null +++ b/runtime/main/extend/systemplugin/napi/notification/notificationFlags.js @@ -0,0 +1,24 @@ +/* + * Copyright (c) 2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +export const NotificationFlagStatus = { + TYPE_NONE: 0, + TYPE_OPEN: 1, + TYPE_CLOSE: 2, +} +export const NotificationFlags = { + soundEnabled: NotificationFlagStatus, + vibrationEnabled: NotificationFlagStatus, +} \ No newline at end of file diff --git a/runtime/main/extend/systemplugin/napi/notification/notificationRequest.js b/runtime/main/extend/systemplugin/napi/notification/notificationRequest.js new file mode 100644 index 00000000..4507b3d6 --- /dev/null +++ b/runtime/main/extend/systemplugin/napi/notification/notificationRequest.js @@ -0,0 +1,67 @@ +/* + * Copyright (c) 2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import { paramMock } from "../../utils" +import { SlotType } from "../ohos_notification" +import { NotificationActionButton } from "./notificationActionButton" +import { PixelMapMock } from "../ohos_multimedia_image" +import { NotificationTemplate } from "./notificationTemplate" +import { NotificationFlags } from "./notificationFlags" +import { NotificationContent } from "./notificationContent" + +export const NotificationRequest = { + content: NotificationContent, + id: '[PC preview] unknow id', + slotType: 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: {}, + 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: [NotificationActionButton], + smallIcon: PixelMapMock, + largeIcon: PixelMapMock, + groupName: '[PC preview] unknow groupName', + creatorBundleName: '[PC preview] unknow creatorBundleName', + creatorUid: '[PC preview] unknow creatorUid', + creatorPid: '[PC preview] unknow creatorPid', + creatorUserId: '[PC preview] unknow creatorUserId', + classification: '[PC preview] unknow classification', + hashCode: '[PC preview] unknow hashCode', + isRemveAllowd: '[PC preview] unknow isRemveAllowd', + source: '[PC preview] unknow source', + template: NotificationTemplate, + distributedOption: DistributedOptions, + deviceId: '[PC preview] unknow deviceId', + notificationFlags: NotificationFlags, + removalWantAgent: '[PC preview] unknow removalWantAgent', + badgeNumber: '[PC preview] unknow badgeNumber', +} +export const DistributedOptions = { + isDistributed: '[PC preview] unknow isDistributed', + supportDisplayDevices: [paramMock.paramStringMock], + supportOperateDevices: [paramMock.paramStringMock], + remindType: '[PC preview] unknow remindType', +} \ No newline at end of file diff --git a/runtime/main/extend/systemplugin/napi/notification/notificationSlot.js b/runtime/main/extend/systemplugin/napi/notification/notificationSlot.js new file mode 100644 index 00000000..bc884a43 --- /dev/null +++ b/runtime/main/extend/systemplugin/napi/notification/notificationSlot.js @@ -0,0 +1,31 @@ +/* + * Copyright (c) 2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import { paramMock } from "../../utils" +import { SlotType, SlotLevel } from "../ohos_notification" + +export const NotificationSlot = { + type: SlotType, + level: SlotLevel, + 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: [paramMock.paramNumberMock], + enabled: '[PC preview] unknow enabled', +}; \ No newline at end of file diff --git a/runtime/main/extend/systemplugin/napi/notification/notificationSorting.js b/runtime/main/extend/systemplugin/napi/notification/notificationSorting.js new file mode 100644 index 00000000..efc1e751 --- /dev/null +++ b/runtime/main/extend/systemplugin/napi/notification/notificationSorting.js @@ -0,0 +1,21 @@ +/* + * Copyright (c) 2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import { NotificationSlot } from "./notificationSlot" + +export const NotificationSorting = { + slot: NotificationSlot, + hashCode: '[PC preview] unknow hashCode', + ranking: '[PC preview] unknow ranking', +}; \ No newline at end of file diff --git a/runtime/main/extend/systemplugin/napi/notification/notificationSortingMap.js b/runtime/main/extend/systemplugin/napi/notification/notificationSortingMap.js new file mode 100644 index 00000000..d7ca9875 --- /dev/null +++ b/runtime/main/extend/systemplugin/napi/notification/notificationSortingMap.js @@ -0,0 +1,20 @@ +/* + * Copyright (c) 2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import { paramMock } from "../../utils" + +export const NotificationSortingMap = { + sortings: {}, + sortedHashCode: [paramMock.paramStringMock], +}; \ No newline at end of file diff --git a/runtime/main/extend/systemplugin/napi/notification/notificationSubscribeInfo.js b/runtime/main/extend/systemplugin/napi/notification/notificationSubscribeInfo.js new file mode 100644 index 00000000..8476e26c --- /dev/null +++ b/runtime/main/extend/systemplugin/napi/notification/notificationSubscribeInfo.js @@ -0,0 +1,20 @@ +/* + * Copyright (c) 2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import { paramMock } from "../../utils" + +export const NotificationSubscribeInfo = { + bundleNames: [paramMock.paramStringMock], + userId: '[PC preview] unknow userId', +}; \ No newline at end of file diff --git a/runtime/main/extend/systemplugin/napi/notification/notificationSubscriber.js b/runtime/main/extend/systemplugin/napi/notification/notificationSubscriber.js new file mode 100644 index 00000000..e9568430 --- /dev/null +++ b/runtime/main/extend/systemplugin/napi/notification/notificationSubscriber.js @@ -0,0 +1,64 @@ +/* + * Copyright (c) 2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import { paramMock } from "../../utils" +import { NotificationRequest } from "./notificationRequest" +import { NotificationSortingMap } from "./notificationSortingMap" + +export const NotificationSubscriber = { + onConsume: function (...args) { + console.warn("NotificationSubscriber.onConsume interface mocked in the Previewer. How this interface works on the" + + " Previewer may be different from that on a real device.") + }, + onCancel: function (...args) { + console.warn("NotificationSubscriber.onCancel interface mocked in the Previewer. How this interface works on the" + + " Previewer may be different from that on a real device.") + }, + onUpdate: function (...args) { + console.warn("NotificationSubscriber.onUpdate interface mocked in the Previewer. How this interface works on the" + + " Previewer may be different from that on a real device.") + }, + onConnect: function () { + console.warn("NotificationSubscriber.onConnect interface mocked in the Previewer. How this interface works on the" + + " Previewer may be different from that on a real device.") + }, + onDisconnect: function () { + console.warn("NotificationSubscriber.onDisconnect interface mocked in the Previewer. How this interface works on the" + + " Previewer may be different from that on a real device.") + }, + onDestroy: function () { + console.warn("NotificationSubscriber.onDestroy interface mocked in the Previewer. How this interface works on the" + + " Previewer may be different from that on a real device.") + }, + onDoNotDisturbDateChange: function (...args) { + console.warn("NotificationSubscriber.onDoNotDisturbDateChange interface mocked in the Previewer. How this interface works on the" + + " Previewer may be different from that on a real device.") + }, + onEnabledNotificationChanged: function (...args) { + console.warn("NotificationSubscriber.onEnabledNotificationChanged interface mocked in the Previewer. How this interface works on the" + + " Previewer may be different from that on a real device.") + } +} +export const SubscribeCallbackData = { + request: NotificationRequest, + sortingMap: NotificationSortingMap, + reason: '[PC preview] unknow reason', + sound: '[PC preview] unknow sound', + vibrationValues: [paramMock.paramNumberMock], +} +export const EnabledNotificationCallbackData = { + bundle: '[PC preview] unknow bundle', + uid: '[PC preview] unknow uid', + enable: '[PC preview] unknow enable', +} \ No newline at end of file diff --git a/runtime/main/extend/systemplugin/napi/notification/notificationTemplate.js b/runtime/main/extend/systemplugin/napi/notification/notificationTemplate.js new file mode 100644 index 00000000..62d68e12 --- /dev/null +++ b/runtime/main/extend/systemplugin/napi/notification/notificationTemplate.js @@ -0,0 +1,18 @@ +/* + * Copyright (c) 2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +export const NotificationTemplate = { + name: '[PC preview] unknow name', + data: {}, +} \ No newline at end of file diff --git a/runtime/main/extend/systemplugin/napi/notification/notificationUserInput.js b/runtime/main/extend/systemplugin/napi/notification/notificationUserInput.js new file mode 100644 index 00000000..8c12935d --- /dev/null +++ b/runtime/main/extend/systemplugin/napi/notification/notificationUserInput.js @@ -0,0 +1,17 @@ +/* + * Copyright (c) 2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +export const NotificationUserInput = { + inputKey: '[PC preview] unknow inputKey', +} \ No newline at end of file diff --git a/runtime/main/extend/systemplugin/napi/ohos_application_abilityDelegatorRegistry.js b/runtime/main/extend/systemplugin/napi/ohos_application_abilityDelegatorRegistry.js index 8eb11310..6b3df79d 100644 --- a/runtime/main/extend/systemplugin/napi/ohos_application_abilityDelegatorRegistry.js +++ b/runtime/main/extend/systemplugin/napi/ohos_application_abilityDelegatorRegistry.js @@ -24,7 +24,6 @@ export const AbilityLifecycleState = { DESTROY: '[PC preview] unknow DESTROY', } - export function mockAbilityDelegatorRegistry() { const abilityDelegatorRegistry = { getAbilityDelegator: function () { diff --git a/runtime/main/extend/systemplugin/napi/ohos_commonEvent.js b/runtime/main/extend/systemplugin/napi/ohos_commonEvent.js index 07f1fdd7..fe3a0e6f 100644 --- a/runtime/main/extend/systemplugin/napi/ohos_commonEvent.js +++ b/runtime/main/extend/systemplugin/napi/ohos_commonEvent.js @@ -14,168 +14,197 @@ */ import { paramMock } from "../utils" +import { CommonEventData } from "./commonEvent/commonEventData" +import { CommonEventSubscriber } from "./commonEvent/commonEventSubscriber" +export const Support = { + COMMON_EVENT_BOOT_COMPLETED: "usual.event.BOOT_COMPLETED", + COMMON_EVENT_LOCKED_BOOT_COMPLETED: "usual.event.LOCKED_BOOT_COMPLETED", + COMMON_EVENT_SHUTDOWN: "usual.event.SHUTDOWN", + COMMON_EVENT_BATTERY_CHANGED: "usual.event.BATTERY_CHANGED", + COMMON_EVENT_BATTERY_LOW: "usual.event.BATTERY_LOW", + COMMON_EVENT_BATTERY_OKAY: "usual.event.BATTERY_OKAY", + COMMON_EVENT_POWER_CONNECTED: "usual.event.POWER_CONNECTED", + COMMON_EVENT_POWER_DISCONNECTED: "usual.event.POWER_DISCONNECTED", + COMMON_EVENT_SCREEN_OFF: "usual.event.SCREEN_OFF", + COMMON_EVENT_SCREEN_ON: "usual.event.SCREEN_ON", + COMMON_EVENT_THERMAL_LEVEL_CHANGED: "usual.event.THERMAL_LEVEL_CHANGED", + COMMON_EVENT_USER_PRESENT: "usual.event.USER_PRESENT", + COMMON_EVENT_TIME_TICK: "usual.event.TIME_TICK", + COMMON_EVENT_TIME_CHANGED: "usual.event.TIME_CHANGED", + COMMON_EVENT_DATE_CHANGED: "usual.event.DATE_CHANGED", + COMMON_EVENT_TIMEZONE_CHANGED: "usual.event.TIMEZONE_CHANGED", + COMMON_EVENT_CLOSE_SYSTEM_DIALOGS: "usual.event.CLOSE_SYSTEM_DIALOGS", + COMMON_EVENT_PACKAGE_ADDED: "usual.event.PACKAGE_ADDED", + COMMON_EVENT_PACKAGE_REPLACED: "usual.event.PACKAGE_REPLACED", + COMMON_EVENT_MY_PACKAGE_REPLACED: "usual.event.MY_PACKAGE_REPLACED", + COMMON_EVENT_PACKAGE_REMOVED: "usual.event.PACKAGE_REMOVED", + COMMON_EVENT_BUNDLE_REMOVED: "usual.event.BUNDLE_REMOVED", + COMMON_EVENT_PACKAGE_FULLY_REMOVED: "usual.event.PACKAGE_FULLY_REMOVED", + COMMON_EVENT_PACKAGE_CHANGED: "usual.event.PACKAGE_CHANGED", + COMMON_EVENT_PACKAGE_RESTARTED: "usual.event.PACKAGE_RESTARTED", + COMMON_EVENT_PACKAGE_DATA_CLEARED: "usual.event.PACKAGE_DATA_CLEARED", + COMMON_EVENT_PACKAGES_SUSPENDED: "usual.event.PACKAGES_SUSPENDED", + COMMON_EVENT_PACKAGES_UNSUSPENDED: "usual.event.PACKAGES_UNSUSPENDED", + COMMON_EVENT_MY_PACKAGE_SUSPENDED: "usual.event.MY_PACKAGE_SUSPENDED", + COMMON_EVENT_MY_PACKAGE_UNSUSPENDED: "usual.event.MY_PACKAGE_UNSUSPENDED", + COMMON_EVENT_UID_REMOVED: "usual.event.UID_REMOVED", + COMMON_EVENT_PACKAGE_FIRST_LAUNCH: "usual.event.PACKAGE_FIRST_LAUNCH", + COMMON_EVENT_PACKAGE_NEEDS_VERIFICATION: "usual.event.PACKAGE_NEEDS_VERIFICATION", + COMMON_EVENT_PACKAGE_VERIFIED: "usual.event.PACKAGE_VERIFIED", + COMMON_EVENT_EXTERNAL_APPLICATIONS_AVAILABLE: "usual.event.EXTERNAL_APPLICATIONS_AVAILABLE", + COMMON_EVENT_EXTERNAL_APPLICATIONS_UNAVAILABLE: "usual.event.EXTERNAL_APPLICATIONS_UNAVAILABLE", + COMMON_EVENT_CONFIGURATION_CHANGED: "usual.event.CONFIGURATION_CHANGED", + COMMON_EVENT_LOCALE_CHANGED: "usual.event.LOCALE_CHANGED", + COMMON_EVENT_MANAGE_PACKAGE_STORAGE: "usual.event.MANAGE_PACKAGE_STORAGE", + COMMON_EVENT_DRIVE_MODE: "common.event.DRIVE_MODE", + COMMON_EVENT_HOME_MODE: "common.event.HOME_MODE", + COMMON_EVENT_OFFICE_MODE: "common.event.OFFICE_MODE", + COMMON_EVENT_USER_STARTED: "usual.event.USER_STARTED", + COMMON_EVENT_USER_BACKGROUND: "usual.event.USER_BACKGROUND", + COMMON_EVENT_USER_FOREGROUND: "usual.event.USER_FOREGROUND", + COMMON_EVENT_USER_SWITCHED: "usual.event.USER_SWITCHED", + COMMON_EVENT_USER_STARTING: "usual.event.USER_STARTING", + COMMON_EVENT_USER_UNLOCKED: "usual.event.USER_UNLOCKED", + COMMON_EVENT_USER_STOPPING: "usual.event.USER_STOPPING", + COMMON_EVENT_USER_STOPPED: "usual.event.USER_STOPPED", + COMMON_EVENT_HWID_LOGIN: "common.event.HWID_LOGIN", + COMMON_EVENT_HWID_LOGOUT: "common.event.HWID_LOGOUT", + COMMON_EVENT_HWID_TOKEN_INVALID: "common.event.HWID_TOKEN_INVALID", + COMMON_EVENT_HWID_LOGOFF: "common.event.HWID_LOGOFF", + COMMON_EVENT_WIFI_POWER_STATE: "usual.event.wifi.POWER_STATE", + COMMON_EVENT_WIFI_SCAN_FINISHED: "usual.event.wifi.SCAN_FINISHED", + COMMON_EVENT_WIFI_RSSI_VALUE: "usual.event.wifi.RSSI_VALUE", + COMMON_EVENT_WIFI_CONN_STATE: "usual.event.wifi.CONN_STATE", + COMMON_EVENT_WIFI_HOTSPOT_STATE: "usual.event.wifi.HOTSPOT_STATE", + COMMON_EVENT_WIFI_AP_STA_JOIN: "usual.event.wifi.WIFI_HS_STA_JOIN", + COMMON_EVENT_WIFI_AP_STA_LEAVE: "usual.event.wifi.WIFI_HS_STA_LEAVE", + COMMON_EVENT_WIFI_MPLINK_STATE_CHANGE: "usual.event.wifi.mplink.STATE_CHANGE", + COMMON_EVENT_WIFI_P2P_CONN_STATE: "usual.event.wifi.p2p.CONN_STATE_CHANGE", + COMMON_EVENT_WIFI_P2P_STATE_CHANGED: "usual.event.wifi.p2p.STATE_CHANGE", + COMMON_EVENT_WIFI_P2P_PEERS_STATE_CHANGED: "usual.event.wifi.p2p.DEVICES_CHANGE", + COMMON_EVENT_WIFI_P2P_PEERS_DISCOVERY_STATE_CHANGED: "usual.event.wifi.p2p.PEER_DISCOVERY_STATE_CHANGE", + COMMON_EVENT_WIFI_P2P_CURRENT_DEVICE_STATE_CHANGED:"usual.event.wifi.p2p.CURRENT_DEVICE_CHANGE", + COMMON_EVENT_WIFI_P2P_GROUP_STATE_CHANGED:"usual.event.wifi.p2p.GROUP_STATE_CHANGED", + COMMON_EVENT_BLUETOOTH_HANDSFREE_AG_CONNECT_STATE_UPDATE: + "usual.event.bluetooth.handsfree.ag.CONNECT_STATE_UPDATE", + COMMON_EVENT_BLUETOOTH_HANDSFREE_AG_CURRENT_DEVICE_UPDATE: + "usual.event.bluetooth.handsfree.ag.CURRENT_DEVICE_UPDATE", + COMMON_EVENT_BLUETOOTH_HANDSFREE_AG_AUDIO_STATE_UPDATE: "usual.event.bluetooth.handsfree.ag.AUDIO_STATE_UPDATE", + COMMON_EVENT_BLUETOOTH_A2DPSOURCE_CONNECT_STATE_UPDATE:"usual.event.bluetooth.a2dpsource.CONNECT_STATE_UPDATE", + COMMON_EVENT_BLUETOOTH_A2DPSOURCE_CURRENT_DEVICE_UPDATE: "usual.event.bluetooth.a2dpsource.CURRENT_DEVICE_UPDATE", + COMMON_EVENT_BLUETOOTH_A2DPSOURCE_PLAYING_STATE_UPDATE: "usual.event.bluetooth.a2dpsource.PLAYING_STATE_UPDATE", + COMMON_EVENT_BLUETOOTH_A2DPSOURCE_AVRCP_CONNECT_STATE_UPDATE: + "usual.event.bluetooth.a2dpsource.AVRCP_CONNECT_STATE_UPDATE", + COMMON_EVENT_BLUETOOTH_A2DPSOURCE_CODEC_VALUE_UPDATE: "usual.event.bluetooth.a2dpsource.CODEC_VALUE_UPDATE", + COMMON_EVENT_BLUETOOTH_REMOTEDEVICE_DISCOVERED: "usual.event.bluetooth.remotedevice.DISCOVERED", + COMMON_EVENT_BLUETOOTH_REMOTEDEVICE_CLASS_VALUE_UPDATE: "usual.event.bluetooth.remotedevice.CLASS_VALUE_UPDATE", + COMMON_EVENT_BLUETOOTH_REMOTEDEVICE_ACL_CONNECTED: "usual.event.bluetooth.remotedevice.ACL_CONNECTED", + COMMON_EVENT_BLUETOOTH_REMOTEDEVICE_ACL_DISCONNECTED: "usual.event.bluetooth.remotedevice.ACL_DISCONNECTED", + COMMON_EVENT_BLUETOOTH_REMOTEDEVICE_NAME_UPDATE: + "usual.event.bluetooth.remotedevice.NAME_UPDATE", + COMMON_EVENT_BLUETOOTH_REMOTEDEVICE_PAIR_STATE: + "usual.event.bluetooth.remotedevice.PAIR_STATE", + COMMON_EVENT_BLUETOOTH_REMOTEDEVICE_BATTERY_VALUE_UPDATE: + "usual.event.bluetooth.remotedevice.BATTERY_VALUE_UPDATE", + COMMON_EVENT_BLUETOOTH_REMOTEDEVICE_SDP_RESULT: + "usual.event.bluetooth.remotedevice.SDP_RESULT", + COMMON_EVENT_BLUETOOTH_REMOTEDEVICE_UUID_VALUE: + "usual.event.bluetooth.remotedevice.UUID_VALUE", + COMMON_EVENT_BLUETOOTH_REMOTEDEVICE_PAIRING_REQ: + "usual.event.bluetooth.remotedevice.PAIRING_REQ", + COMMON_EVENT_BLUETOOTH_REMOTEDEVICE_PAIRING_CANCEL: + "usual.event.bluetooth.remotedevice.PAIRING_CANCEL", + COMMON_EVENT_BLUETOOTH_REMOTEDEVICE_CONNECT_REQ: + "usual.event.bluetooth.remotedevice.CONNECT_REQ", + COMMON_EVENT_BLUETOOTH_REMOTEDEVICE_CONNECT_REPLY: + "usual.event.bluetooth.remotedevice.CONNECT_REPLY", + COMMON_EVENT_BLUETOOTH_REMOTEDEVICE_CONNECT_CANCEL: + "usual.event.bluetooth.remotedevice.CONNECT_CANCEL", + COMMON_EVENT_BLUETOOTH_HANDSFREEUNIT_CONNECT_STATE_UPDATE: + "usual.event.bluetooth.handsfreeunit.CONNECT_STATE_UPDATE", + COMMON_EVENT_BLUETOOTH_HANDSFREEUNIT_AUDIO_STATE_UPDATE: + "usual.event.bluetooth.handsfreeunit.AUDIO_STATE_UPDATE", + COMMON_EVENT_BLUETOOTH_HANDSFREEUNIT_AG_COMMON_EVENT: + "usual.event.bluetooth.handsfreeunit.AG_COMMON_EVENT", + COMMON_EVENT_BLUETOOTH_HANDSFREEUNIT_AG_CALL_STATE_UPDATE: + "usual.event.bluetooth.handsfreeunit.AG_CALL_STATE_UPDATE", + COMMON_EVENT_BLUETOOTH_HOST_STATE_UPDATE: + "usual.event.bluetooth.host.STATE_UPDATE", + COMMON_EVENT_BLUETOOTH_HOST_REQ_DISCOVERABLE: + "usual.event.bluetooth.host.REQ_DISCOVERABLE", + COMMON_EVENT_BLUETOOTH_HOST_REQ_ENABLE: "usual.event.bluetooth.host.REQ_ENABLE", + COMMON_EVENT_BLUETOOTH_HOST_REQ_DISABLE: + "usual.event.bluetooth.host.REQ_DISABLE", + COMMON_EVENT_BLUETOOTH_HOST_SCAN_MODE_UPDATE: + "usual.event.bluetooth.host.SCAN_MODE_UPDATE", + COMMON_EVENT_BLUETOOTH_HOST_DISCOVERY_STARTED: + "usual.event.bluetooth.host.DISCOVERY_STARTED", + COMMON_EVENT_BLUETOOTH_HOST_DISCOVERY_FINISHED: + "usual.event.bluetooth.host.DISCOVERY_FINISHED", + COMMON_EVENT_BLUETOOTH_HOST_NAME_UPDATE: + "usual.event.bluetooth.host.NAME_UPDATE", + COMMON_EVENT_BLUETOOTH_A2DPSINK_CONNECT_STATE_UPDATE: + "usual.event.bluetooth.a2dpsink.CONNECT_STATE_UPDATE", + COMMON_EVENT_BLUETOOTH_A2DPSINK_PLAYING_STATE_UPDATE: + "usual.event.bluetooth.a2dpsink.PLAYING_STATE_UPDATE", + COMMON_EVENT_BLUETOOTH_A2DPSINK_AUDIO_STATE_UPDATE: + "usual.event.bluetooth.a2dpsink.AUDIO_STATE_UPDATE", + COMMON_EVENT_NFC_ACTION_ADAPTER_STATE_CHANGED: + "usual.event.nfc.action.ADAPTER_STATE_CHANGED", + COMMON_EVENT_NFC_ACTION_RF_FIELD_ON_DETECTED: + "usual.event.nfc.action.RF_FIELD_ON_DETECTED", + COMMON_EVENT_NFC_ACTION_RF_FIELD_OFF_DETECTED: + "usual.event.nfc.action.RF_FIELD_OFF_DETECTED", + COMMON_EVENT_DISCHARGING: "usual.event.DISCHARGING", + COMMON_EVENT_CHARGING: "usual.event.CHARGING", + COMMON_EVENT_DEVICE_IDLE_MODE_CHANGED: "usual.event.DEVICE_IDLE_MODE_CHANGED", + COMMON_EVENT_POWER_SAVE_MODE_CHANGED: "usual.event.POWER_SAVE_MODE_CHANGED", + COMMON_EVENT_USER_ADDED: "usual.event.USER_ADDED", + COMMON_EVENT_USER_REMOVED: "usual.event.USER_REMOVED", + COMMON_EVENT_ABILITY_ADDED: "common.event.ABILITY_ADDED", + COMMON_EVENT_ABILITY_REMOVED: "common.event.ABILITY_REMOVED", + COMMON_EVENT_ABILITY_UPDATED: "common.event.ABILITY_UPDATED", + COMMON_EVENT_LOCATION_MODE_STATE_CHANGED: + "usual.event.location.MODE_STATE_CHANGED", + COMMON_EVENT_IVI_SLEEP: "common.event.IVI_SLEEP", + COMMON_EVENT_IVI_PAUSE: "common.event.IVI_PAUSE", + COMMON_EVENT_IVI_STANDBY: "common.event.IVI_STANDBY", + COMMON_EVENT_IVI_LASTMODE_SAVE: "common.event.IVI_LASTMODE_SAVE", + COMMON_EVENT_IVI_VOLTAGE_ABNORMAL: "common.event.IVI_VOLTAGE_ABNORMAL", + COMMON_EVENT_IVI_HIGH_TEMPERATURE: "common.event.IVI_HIGH_TEMPERATURE", + COMMON_EVENT_IVI_EXTREME_TEMPERATURE: "common.event.IVI_EXTREME_TEMPERATURE", + COMMON_EVENT_IVI_TEMPERATURE_ABNORMAL: "common.event.IVI_TEMPERATURE_ABNORMAL", + COMMON_EVENT_IVI_VOLTAGE_RECOVERY: "common.event.IVI_VOLTAGE_RECOVERY", + COMMON_EVENT_IVI_TEMPERATURE_RECOVERY: "common.event.IVI_TEMPERATURE_RECOVERY", + COMMON_EVENT_IVI_ACTIVE: "common.event.IVI_ACTIVE", + COMMON_EVENT_USB_DEVICE_ATTACHED: + "usual.event.hardware.usb.action.USB_DEVICE_ATTACHED", + COMMON_EVENT_USB_DEVICE_DETACHED: + "usual.event.hardware.usb.action.USB_DEVICE_DETACHED", + COMMON_EVENT_USB_ACCESSORY_ATTACHED: + "usual.event.hardware.usb.action.USB_ACCESSORY_ATTACHED", + COMMON_EVENT_USB_ACCESSORY_DETACHED: + "usual.event.hardware.usb.action.USB_ACCESSORY_DETACHED", + COMMON_EVENT_DISK_REMOVED: "usual.event.data.DISK_REMOVED", + COMMON_EVENT_DISK_UNMOUNTED: "usual.event.data.DISK_UNMOUNTED", + COMMON_EVENT_DISK_MOUNTED: "usual.event.data.DISK_MOUNTED", + COMMON_EVENT_DISK_BAD_REMOVAL: "usual.event.data.DISK_BAD_REMOVAL", + COMMON_EVENT_DISK_UNMOUNTABLE: "usual.event.data.DISK_UNMOUNTABLE", + COMMON_EVENT_DISK_EJECT: "usual.event.data.DISK_EJECT", + COMMON_EVENT_VOLUME_REMOVED: "usual.event.data.VOLUME_REMOVED", + COMMON_EVENT_VOLUME_UNMOUNTED: "usual.event.data.VOLUME_UNMOUNTED", + COMMON_EVENT_VOLUME_MOUNTED: "usual.event.data.VOLUME_MOUNTED", + COMMON_EVENT_VOLUME_BAD_REMOVAL: "usual.event.data.VOLUME_BAD_REMOVAL", + COMMON_EVENT_VOLUME_EJECT: "usual.event.data.VOLUME_EJECT", + COMMON_EVENT_VISIBLE_ACCOUNTS_UPDATED: + "usual.event.data.VISIBLE_ACCOUNTS_UPDATED", + COMMON_EVENT_ACCOUNT_DELETED: "usual.event.data.ACCOUNT_DELETED", + COMMON_EVENT_FOUNDATION_READY: "common.event.FOUNDATION_READY", + COMMON_EVENT_AIRPLANE_MODE_CHANGED: "usual.event.AIRPLANE_MODE", + COMMON_EVENT_SPLIT_SCREEN: "common.event.SPLIT_SCREEN" +} export function mockCommonEvent() { - const CommonEventDataMock = { - event: '[PC preview] unknow event', - bundleName: '[PC preview] unknow bundleName', - code: '[PC preview] unknow code', - data: '[PC preview] unknow data', - parameters: {} - } - const CommonEventSubscribeInfoMock = { - events: [paramMock.paramStringMock], - publisherPermission: '[PC preview] unknow publisherPermission', - publisherDeviceId: '[PC preview] unknow publisherDeviceId', - userId: '[PC preview] unknow userId', - priority: '[PC preview] unknow priority' - } - const CommonEventSubscriberMock = { - getCode: function (...args) { - console.warn('CommonEventSubscriber.getCode interface mocked in the Previewer. How this interface works on the' + - ' Previewer may be different from that on a real device.'); - const len = args.length; - if (typeof args[len - 1] === 'function') { - args[len - 1].call(this, paramMock.businessErrorMock, paramMock.paramNumberMock); - } else { - return new Promise((resolve) => { - resolve(paramMock.paramNumberMock); - }); - } - }, - setCode: function (...args) { - console.warn('CommonEventSubscriber.setCode interface mocked in the Previewer. How this interface works on the' + - ' Previewer may be different from that on a real device.'); - const len = args.length; - if (typeof args[len - 1] === 'function') { - args[len - 1].call(this, paramMock.businessErrorMock); - } else { - return new Promise((resolve) => { - resolve(); - }); - } - }, - getData: function (...args) { - console.warn('CommonEventSubscriber.getData interface mocked in the Previewer. How this interface works on the' + - ' Previewer may be different from that on a real device.'); - const len = args.length; - if (typeof args[len - 1] === 'function') { - args[len - 1].call(this, paramMock.businessErrorMock, paramMock.paramStringMock); - } else { - return new Promise((resolve) => { - resolve(paramMock.paramStringMock); - }); - } - }, - setData: function (...args) { - console.warn('CommonEventSubscriber.setData interface mocked in the Previewer. How this interface works on the' + - ' Previewer may be different from that on a real device.'); - const len = args.length; - if (typeof args[len - 1] === 'function') { - args[len - 1].call(this, paramMock.businessErrorMock); - } else { - return new Promise((resolve) => { - resolve(); - }); - } - }, - setCodeAndData: function (...args) { - console.warn('CommonEventSubscriber.setCodeAndData interface mocked in the Previewer. How this interface works on the' + - ' Previewer may be different from that on a real device.'); - const len = args.length; - if (typeof args[len - 1] === 'function') { - args[len - 1].call(this, paramMock.businessErrorMock); - } else { - return new Promise((resolve) => { - resolve(); - }); - } - }, - isOrderedCommonEvent: function (...args) { - console.warn('CommonEventSubscriber.isOrderedCommonEvent interface mocked in the Previewer. How this interface works on the' + - ' Previewer may be different from that on a real device.'); - const len = args.length; - if (typeof args[len - 1] === 'function') { - args[len - 1].call(this, paramMock.businessErrorMock, paramMock.paramBooleanMock); - } else { - return new Promise((resolve) => { - resolve(paramMock.paramBooleanMock); - }); - } - }, - isStickyCommonEvent: function (...args) { - console.warn('CommonEventSubscriber.isStickyCommonEvent interface mocked in the Previewer. How this interface works on the' + - ' Previewer may be different from that on a real device.'); - const len = args.length; - if (typeof args[len - 1] === 'function') { - args[len - 1].call(this, paramMock.businessErrorMock, paramMock.paramBooleanMock); - } else { - return new Promise((resolve) => { - resolve(paramMock.paramBooleanMock); - }); - } - }, - abortCommonEvent: function (...args) { - console.warn('CommonEventSubscriber.abortCommonEvent interface mocked in the Previewer. How this interface works on the' + - ' Previewer may be different from that on a real device.'); - const len = args.length; - if (typeof args[len - 1] === 'function') { - args[len - 1].call(this, paramMock.businessErrorMock); - } else { - return new Promise((resolve) => { - resolve(); - }); - } - }, - clearAbortCommonEvent: function (...args) { - console.warn('CommonEventSubscriber.clearAbortCommonEvent interface mocked in the Previewer. How this interface works on the' + - ' Previewer may be different from that on a real device.'); - const len = args.length; - if (typeof args[len - 1] === 'function') { - args[len - 1].call(this, paramMock.businessErrorMock); - } else { - return new Promise((resolve) => { - resolve(); - }); - } - }, - getAbortCommonEvent: function (...args) { - console.warn('CommonEventSubscriber.getAbortCommonEvent interface mocked in the Previewer. How this interface works on the' + - ' Previewer may be different from that on a real device.'); - const len = args.length; - if (typeof args[len - 1] === 'function') { - args[len - 1].call(this, paramMock.businessErrorMock, paramMock.paramBooleanMock); - } else { - return new Promise((resolve) => { - resolve(paramMock.paramBooleanMock); - }); - } - }, - getSubscribeInfo: function (...args) { - console.warn('CommonEventSubscriber.getSubscribeInfo interface mocked in the Previewer. How this interface works on the' + - ' Previewer may be different from that on a real device.'); - const len = args.length; - if (typeof args[len - 1] === 'function') { - args[len - 1].call(this, paramMock.businessErrorMock, CommonEventSubscribeInfoMock); - } else { - return new Promise((resolve) => { - resolve(CommonEventSubscribeInfoMock); - }); - } - }, - finishCommonEvent: function (...args) { - console.warn('CommonEventSubscriber.finishCommonEvent interface mocked in the Previewer. How this interface works on the' + - ' Previewer may be different from that on a real device.'); - const len = args.length; - if (typeof args[len - 1] === 'function') { - args[len - 1].call(this, paramMock.businessErrorMock); - } else { - return new Promise((resolve, reject) => { - resolve(); - }); - } - }, - } const commonEvent = { publish: function (...args) { console.warn('commonEvent.publish interface mocked in the Previewer. How this interface works on the' + @@ -198,10 +227,10 @@ export function mockCommonEvent() { ' Previewer may be 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); + args[len - 1].call(this, paramMock.businessErrorMock, CommonEventSubscriber); } else { return new Promise((resolve) => { - resolve(CommonEventSubscriberMock); + resolve(CommonEventSubscriber); }); } }, @@ -210,7 +239,7 @@ export function mockCommonEvent() { ' Previewer may be 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); + args[len - 1].call(this, paramMock.businessErrorMock, CommonEventData); } }, unsubscribe: function (...args) { diff --git a/runtime/main/extend/systemplugin/napi/ohos_events_emitter.js b/runtime/main/extend/systemplugin/napi/ohos_events_emitter.js index ccc47fcf..b712a291 100644 --- a/runtime/main/extend/systemplugin/napi/ohos_events_emitter.js +++ b/runtime/main/extend/systemplugin/napi/ohos_events_emitter.js @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021 Huawei Device Co., Ltd. + * Copyright (c) 2021-2022 Huawei Device Co., Ltd. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at @@ -15,17 +15,28 @@ import { paramMock } from "../utils" +export const EventPriority = { + IMMEDIATE: 0, + HIGH: 1, + LOW: 2, + IDLE: 3, +} +export const EventData = { + data: '[PC preview] unknow data', +} +export const InnerEvent = { + eventId: '[PC preview] unknow eventId', + priority: EventPriority, +} + export function mockEmitter() { - const EventDataMock = { - data: '[PC preview] unknow data', - }; const emitter = { on: function (...args) { console.warn("emitter.on interface mocked in the Previewer. How this interface works on the" + " Previewer may be different from that on a real device."); const len = args.length; if (typeof args[len - 1] === 'function') { - args[len - 1].call(this, EventDataMock); + args[len - 1].call(this, EventData); } }, once: function (...args) { @@ -33,7 +44,7 @@ export function mockEmitter() { " Previewer may be different from that on a real device."); const len = args.length; if (typeof args[len - 1] === 'function') { - args[len - 1].call(this, EventDataMock); + args[len - 1].call(this, EventData); } }, off: function (...args) { diff --git a/runtime/main/extend/systemplugin/napi/ohos_notification.js b/runtime/main/extend/systemplugin/napi/ohos_notification.js index b07fad65..6aa55fb7 100644 --- a/runtime/main/extend/systemplugin/napi/ohos_notification.js +++ b/runtime/main/extend/systemplugin/napi/ohos_notification.js @@ -14,303 +14,279 @@ */ import { paramMock } from "../utils" +import { NotificationSlot } from "./notification/notificationSlot" +import { NotificationRequest } from "./notification/notificationRequest" +export const SlotType = { + UNKNOWN_TYPE: 0, + SOCIAL_COMMUNICATION: 1, + SERVICE_INFORMATION: 2, + CONTENT_INFORMATION: 3, + OTHER_TYPES: 0xFFFF, +} +export const ContentType = { + NOTIFICATION_CONTENT_BASIC_TEXT: 0, + NOTIFICATION_CONTENT_LONG_TEXT: 1, + NOTIFICATION_CONTENT_PICTURE: 2, + NOTIFICATION_CONTENT_CONVERSATION: 3, + NOTIFICATION_CONTENT_MULTILINE: 4, +} +export const SlotLevel = { + LEVEL_NONE: 0, + LEVEL_MIN: 1, + LEVEL_LOW: 2, + LEVEL_DEFAULT: 3, + LEVEL_HIGH: 4, +} +export const BundleOption = { + bundle: '[PC preview] unknow bundle', + uid: '[PC preview] unknow uid', +} +export const NotificationKey = { + id: '[PC preview] unknow id', + label: '[PC preview] unknow label', +} +export const DoNotDisturbType = { + TYPE_NONE: 0, + TYPE_ONCE: 1, + TYPE_DAILY: 2, + TYPE_CLEARLY: 3, +} +const Date = { + toString: function () { + console.warn("Date.toString interface mocked in the Previewer. How this interface works on the Previewer" + + " may be different from that on a real device.") + return paramMock.paramStringMock + }, + toDateString: function () { + console.warn("Date.toDateString interface mocked in the Previewer. How this interface works on the Previewer" + + " may be different from that on a real device.") + return paramMock.paramStringMock + }, + toTimeString: function () { + console.warn("Date.toTimeString interface mocked in the Previewer. How this interface works on the Previewer" + + " may be different from that on a real device.") + return paramMock.paramStringMock + }, + toLocaleString: function () { + console.warn("Date.toLocaleString interface mocked in the Previewer. How this interface works on the Previewer" + + " may be different from that on a real device.") + return paramMock.paramStringMock + }, + toLocaleDateString: function () { + console.warn("Date.toLocaleDateString interface mocked in the Previewer. How this interface works on the Previewer" + + " may be different from that on a real device.") + return paramMock.paramStringMock + }, + toLocaleTimeString: function () { + console.warn("Date.toLocaleTimeString interface mocked in the Previewer. How this interface works on the Previewer" + + " may be different from that on a real device.") + return paramMock.paramStringMock + }, + valueOf: function () { + console.warn("Date.valueOf interface mocked in the Previewer. How this interface works on the Previewer" + + " may be different from that on a real device.") + return paramMock.paramNumberMock + }, + getTime: function () { + console.warn("Date.getTime interface mocked in the Previewer. How this interface works on the Previewer" + + " may be different from that on a real device.") + return paramMock.paramNumberMock + }, + getFullYear: function () { + console.warn("Date.getFullYear interface mocked in the Previewer. How this interface works on the Previewer" + + " may be different from that on a real device.") + return paramMock.paramNumberMock + }, + getUTCFullYear: function () { + console.warn("Date.getUTCFullYear interface mocked in the Previewer. How this interface works on the Previewer" + + " may be different from that on a real device.") + return paramMock.paramNumberMock + }, + getMonth: function () { + console.warn("Date.getMonth interface mocked in the Previewer. How this interface works on the Previewer" + + " may be different from that on a real device.") + return paramMock.paramNumberMock + }, + getUTCMonth: function () { + console.warn("Date.getUTCMonth interface mocked in the Previewer. How this interface works on the Previewer" + + " may be different from that on a real device.") + return paramMock.paramNumberMock + }, + getDate: function () { + console.warn("Date.getDate interface mocked in the Previewer. How this interface works on the Previewer" + + " may be different from that on a real device.") + return paramMock.paramNumberMock + }, + getUTCDate: function () { + console.warn("Date.getUTCDate interface mocked in the Previewer. How this interface works on the Previewer" + + " may be different from that on a real device.") + return paramMock.paramNumberMock + }, + getDay: function () { + console.warn("Date.getDay interface mocked in the Previewer. How this interface works on the Previewer" + + " may be different from that on a real device.") + return paramMock.paramNumberMock + }, + getUTCDay: function () { + console.warn("Date.getUTCDay interface mocked in the Previewer. How this interface works on the Previewer" + + " may be different from that on a real device.") + return paramMock.paramNumberMock + }, + getHours: function () { + console.warn("Date.getHours interface mocked in the Previewer. How this interface works on the Previewer" + + " may be different from that on a real device.") + return paramMock.paramNumberMock + }, + getUTCHours: function () { + console.warn("Date.getUTCHours interface mocked in the Previewer. How this interface works on the Previewer" + + " may be different from that on a real device.") + return paramMock.paramNumberMock + }, + getMinutes: function () { + console.warn("Date.getMinutes interface mocked in the Previewer. How this interface works on the Previewer" + + " may be different from that on a real device.") + return paramMock.paramNumberMock + }, + getUTCMinutes: function () { + console.warn("Date.getUTCMinutes interface mocked in the Previewer. How this interface works on the Previewer" + + " may be different from that on a real device.") + return paramMock.paramNumberMock + }, + getSeconds: function () { + console.warn("Date.getSeconds interface mocked in the Previewer. How this interface works on the Previewer" + + " may be different from that on a real device.") + return paramMock.paramNumberMock + }, + getUTCSeconds: function () { + console.warn("Date.getUTCSeconds interface mocked in the Previewer. How this interface works on the Previewer" + + " may be different from that on a real device.") + return paramMock.paramNumberMock + }, + getMilliseconds: function () { + console.warn("Date.getMilliseconds interface mocked in the Previewer. How this interface works on the Previewer" + + " may be different from that on a real device.") + return paramMock.paramNumberMock + }, + getUTCMilliseconds: function () { + console.warn("Date.getUTCMilliseconds interface mocked in the Previewer. How this interface works on the Previewer" + + " may be different from that on a real device.") + return paramMock.paramNumberMock + }, + getTimezoneOffset: function () { + console.warn("Date.getTimezoneOffset interface mocked in the Previewer. How this interface works on the Previewer" + + " may be different from that on a real device.") + return paramMock.paramNumberMock + }, + setTime: function (...args) { + console.warn("Date.setTime interface mocked in the Previewer. How this interface works on the Previewer" + + " may be different from that on a real device.") + return paramMock.paramNumberMock + }, + setMilliseconds: function (...args) { + console.warn("Date.setMilliseconds interface mocked in the Previewer. How this interface works on the Previewer" + + " may be different from that on a real device.") + return paramMock.paramNumberMock + }, + setUTCMilliseconds: function (...args) { + console.warn("Date.setUTCMilliseconds interface mocked in the Previewer. How this interface works on the Previewer" + + " may be different from that on a real device.") + return paramMock.paramNumberMock + }, + setSeconds: function (...args) { + console.warn("Date.setSeconds interface mocked in the Previewer. How this interface works on the Previewer" + + " may be different from that on a real device.") + return paramMock.paramNumberMock + }, + setUTCSeconds: function (...args) { + console.warn("Date.setUTCSeconds interface mocked in the Previewer. How this interface works on the Previewer" + + " may be different from that on a real device.") + return paramMock.paramNumberMock + }, + setMinutes: function (...args) { + console.warn("Date.setMinutes interface mocked in the Previewer. How this interface works on the Previewer" + + " may be different from that on a real device.") + return paramMock.paramNumberMock + }, + setUTCMinutes: function (...args) { + console.warn("Date.setUTCMinutes interface mocked in the Previewer. How this interface works on the Previewer" + + " may be different from that on a real device.") + return paramMock.paramNumberMock + }, + setHours: function (...args) { + console.warn("Date.setHours interface mocked in the Previewer. How this interface works on the Previewer" + + " may be different from that on a real device.") + return paramMock.paramNumberMock + }, + setUTCHours: function (...args) { + console.warn("Date.setUTCHours interface mocked in the Previewer. How this interface works on the Previewer" + + " may be different from that on a real device.") + return paramMock.paramNumberMock + }, + setDate: function (...args) { + console.warn("Date.setDate interface mocked in the Previewer. How this interface works on the Previewer" + + " may be different from that on a real device.") + return paramMock.paramNumberMock + }, + setUTCDate: function (...args) { + console.warn("Date.setUTCDate interface mocked in the Previewer. How this interface works on the Previewer" + + " may be different from that on a real device.") + return paramMock.paramNumberMock + }, + setMonth: function (...args) { + console.warn("Date.setMonth interface mocked in the Previewer. How this interface works on the Previewer" + + " may be different from that on a real device.") + return paramMock.paramNumberMock + }, + setUTCMonth: function (...args) { + console.warn("Date.setUTCMonth interface mocked in the Previewer. How this interface works on the Previewer" + + " may be different from that on a real device.") + return paramMock.paramNumberMock + }, + setFullYear: function (...args) { + console.warn("Date.setFullYear interface mocked in the Previewer. How this interface works on the Previewer" + + " may be different from that on a real device.") + return paramMock.paramNumberMock + }, + setUTCFullYear: function (...args) { + console.warn("Date.setUTCFullYear interface mocked in the Previewer. How this interface works on the Previewer" + + " may be different from that on a real device.") + return paramMock.paramNumberMock + }, + toUTCString: function () { + console.warn("Date.toUTCString interface mocked in the Previewer. How this interface works on the Previewer" + + " may be different from that on a real device.") + return paramMock.paramStringMock + }, + toISOString: function () { + console.warn("Date.toISOString interface mocked in the Previewer. How this interface works on the Previewer" + + " may be different from that on a real device.") + return paramMock.paramStringMock + }, + toJSON: function (...args) { + console.warn("Date.toJSON interface mocked in the Previewer. How this interface works on the Previewer" + + " may be different from that on a real device.") + return paramMock.paramStringMock + }, +} +export const DoNotDisturbDate = { + type: DoNotDisturbType, + begin: Date, + end: Date, +} +export const DeviceRemindType = { + IDLE_DONOT_REMIND: 0, + IDLE_REMIND: 1, + ACTIVE_DONOT_REMIND: 2, + ACTIVE_REMIND: 3, +} +export const SourceType = { + TYPE_NORMAL: 0, + TYPE_CONTINUOUS: 1, + TYPE_TIMER: 2, +} export function mockNotification() { - const DateMock = { - toString: function () { - console.warn("Date.toString interface mocked in the Previewer. How this interface works on the Previewer" + - " may be different from that on a real device.") - return paramMock.paramStringMock - }, - toDateString: function () { - console.warn("Date.toDateString interface mocked in the Previewer. How this interface works on the Previewer" + - " may be different from that on a real device.") - return paramMock.paramStringMock - }, - toTimeString: function () { - console.warn("Date.toTimeString interface mocked in the Previewer. How this interface works on the Previewer" + - " may be different from that on a real device.") - return paramMock.paramStringMock - }, - toLocaleString: function () { - console.warn("Date.toLocaleString interface mocked in the Previewer. How this interface works on the Previewer" + - " may be different from that on a real device.") - return paramMock.paramStringMock - }, - toLocaleDateString: function () { - console.warn("Date.toLocaleDateString interface mocked in the Previewer. How this interface works on the Previewer" + - " may be different from that on a real device.") - return paramMock.paramStringMock - }, - toLocaleTimeString: function () { - console.warn("Date.toLocaleTimeString interface mocked in the Previewer. How this interface works on the Previewer" + - " may be different from that on a real device.") - return paramMock.paramStringMock - }, - valueOf: function () { - console.warn("Date.valueOf interface mocked in the Previewer. How this interface works on the Previewer" + - " may be different from that on a real device.") - return paramMock.paramNumberMock - }, - getTime: function () { - console.warn("Date.getTime interface mocked in the Previewer. How this interface works on the Previewer" + - " may be different from that on a real device.") - return paramMock.paramNumberMock - }, - getFullYear: function () { - console.warn("Date.getFullYear interface mocked in the Previewer. How this interface works on the Previewer" + - " may be different from that on a real device.") - return paramMock.paramNumberMock - }, - getUTCFullYear: function () { - console.warn("Date.getUTCFullYear interface mocked in the Previewer. How this interface works on the Previewer" + - " may be different from that on a real device.") - return paramMock.paramNumberMock - }, - getMonth: function () { - console.warn("Date.getMonth interface mocked in the Previewer. How this interface works on the Previewer" + - " may be different from that on a real device.") - return paramMock.paramNumberMock - }, - getUTCMonth: function () { - console.warn("Date.getUTCMonth interface mocked in the Previewer. How this interface works on the Previewer" + - " may be different from that on a real device.") - return paramMock.paramNumberMock - }, - getDate: function () { - console.warn("Date.getDate interface mocked in the Previewer. How this interface works on the Previewer" + - " may be different from that on a real device.") - return paramMock.paramNumberMock - }, - getUTCDate: function () { - console.warn("Date.getUTCDate interface mocked in the Previewer. How this interface works on the Previewer" + - " may be different from that on a real device.") - return paramMock.paramNumberMock - }, - getDay: function () { - console.warn("Date.getDay interface mocked in the Previewer. How this interface works on the Previewer" + - " may be different from that on a real device.") - return paramMock.paramNumberMock - }, - getUTCDay: function () { - console.warn("Date.getUTCDay interface mocked in the Previewer. How this interface works on the Previewer" + - " may be different from that on a real device.") - return paramMock.paramNumberMock - }, - getHours: function () { - console.warn("Date.getHours interface mocked in the Previewer. How this interface works on the Previewer" + - " may be different from that on a real device.") - return paramMock.paramNumberMock - }, - getUTCHours: function () { - console.warn("Date.getUTCHours interface mocked in the Previewer. How this interface works on the Previewer" + - " may be different from that on a real device.") - return paramMock.paramNumberMock - }, - getMinutes: function () { - console.warn("Date.getMinutes interface mocked in the Previewer. How this interface works on the Previewer" + - " may be different from that on a real device.") - return paramMock.paramNumberMock - }, - getUTCMinutes: function () { - console.warn("Date.getUTCMinutes interface mocked in the Previewer. How this interface works on the Previewer" + - " may be different from that on a real device.") - return paramMock.paramNumberMock - }, - getSeconds: function () { - console.warn("Date.getSeconds interface mocked in the Previewer. How this interface works on the Previewer" + - " may be different from that on a real device.") - return paramMock.paramNumberMock - }, - getUTCSeconds: function () { - console.warn("Date.getUTCSeconds interface mocked in the Previewer. How this interface works on the Previewer" + - " may be different from that on a real device.") - return paramMock.paramNumberMock - }, - getMilliseconds: function () { - console.warn("Date.getMilliseconds interface mocked in the Previewer. How this interface works on the Previewer" + - " may be different from that on a real device.") - return paramMock.paramNumberMock - }, - getUTCMilliseconds: function () { - console.warn("Date.getUTCMilliseconds interface mocked in the Previewer. How this interface works on the Previewer" + - " may be different from that on a real device.") - return paramMock.paramNumberMock - }, - getTimezoneOffset: function () { - console.warn("Date.getTimezoneOffset interface mocked in the Previewer. How this interface works on the Previewer" + - " may be different from that on a real device.") - return paramMock.paramNumberMock - }, - setTime: function (...args) { - console.warn("Date.setTime interface mocked in the Previewer. How this interface works on the Previewer" + - " may be different from that on a real device.") - return paramMock.paramNumberMock - }, - setMilliseconds: function (...args) { - console.warn("Date.setMilliseconds interface mocked in the Previewer. How this interface works on the Previewer" + - " may be different from that on a real device.") - return paramMock.paramNumberMock - }, - setUTCMilliseconds: function (...args) { - console.warn("Date.setUTCMilliseconds interface mocked in the Previewer. How this interface works on the Previewer" + - " may be different from that on a real device.") - return paramMock.paramNumberMock - }, - setSeconds: function (...args) { - console.warn("Date.setSeconds interface mocked in the Previewer. How this interface works on the Previewer" + - " may be different from that on a real device.") - return paramMock.paramNumberMock - }, - setUTCSeconds: function (...args) { - console.warn("Date.setUTCSeconds interface mocked in the Previewer. How this interface works on the Previewer" + - " may be different from that on a real device.") - return paramMock.paramNumberMock - }, - setMinutes: function (...args) { - console.warn("Date.setMinutes interface mocked in the Previewer. How this interface works on the Previewer" + - " may be different from that on a real device.") - return paramMock.paramNumberMock - }, - setUTCMinutes: function (...args) { - console.warn("Date.setUTCMinutes interface mocked in the Previewer. How this interface works on the Previewer" + - " may be different from that on a real device.") - return paramMock.paramNumberMock - }, - setHours: function (...args) { - console.warn("Date.setHours interface mocked in the Previewer. How this interface works on the Previewer" + - " may be different from that on a real device.") - return paramMock.paramNumberMock - }, - setUTCHours: function (...args) { - console.warn("Date.setUTCHours interface mocked in the Previewer. How this interface works on the Previewer" + - " may be different from that on a real device.") - return paramMock.paramNumberMock - }, - setDate: function (...args) { - console.warn("Date.setDate interface mocked in the Previewer. How this interface works on the Previewer" + - " may be different from that on a real device.") - return paramMock.paramNumberMock - }, - setUTCDate: function (...args) { - console.warn("Date.setUTCDate interface mocked in the Previewer. How this interface works on the Previewer" + - " may be different from that on a real device.") - return paramMock.paramNumberMock - }, - setMonth: function (...args) { - console.warn("Date.setMonth interface mocked in the Previewer. How this interface works on the Previewer" + - " may be different from that on a real device.") - return paramMock.paramNumberMock - }, - setUTCMonth: function (...args) { - console.warn("Date.setUTCMonth interface mocked in the Previewer. How this interface works on the Previewer" + - " may be different from that on a real device.") - return paramMock.paramNumberMock - }, - setFullYear: function (...args) { - console.warn("Date.setFullYear interface mocked in the Previewer. How this interface works on the Previewer" + - " may be different from that on a real device.") - return paramMock.paramNumberMock - }, - setUTCFullYear: function (...args) { - console.warn("Date.setUTCFullYear interface mocked in the Previewer. How this interface works on the Previewer" + - " may be different from that on a real device.") - return paramMock.paramNumberMock - }, - toUTCString: function () { - console.warn("Date.toUTCString interface mocked in the Previewer. How this interface works on the Previewer" + - " may be different from that on a real device.") - return paramMock.paramStringMock - }, - toISOString: function () { - console.warn("Date.toISOString interface mocked in the Previewer. How this interface works on the Previewer" + - " may be different from that on a real device.") - return paramMock.paramStringMock - }, - toJSON: function (...args) { - console.warn("Date.toJSON interface mocked in the Previewer. How this interface works on the Previewer" + - " may be different from that on a real device.") - return paramMock.paramStringMock - }, - } - const DoNotDisturbDateMock = { - DoNotDisturbTypeMock: '[PC preview] unknow DoNotDisturbTypeMock', - begin: DateMock, - end: DateMock - } - const NotificationSlotMock = { - SlotTypeMock: '[PC preview] unknow SlotTypeMock', - SlotLevelMock: '[PC preview] unknow SlotLevelMock', - 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: [paramMock.paramNumberMock] - }; - const NotificationActionButtonMock = { - title: '[PC preview] unknow title', - wantAgent: '[PC preview] unknow wantAgent', - extras: {}, - userInput: '[PC preview] unknow userInput', - } - const NotificationRequestMock = { - content: '[PC preview] unknow content', - id: '[PC preview] unknow id', - slotTypeMock: '[PC preview] unknow slotTypeMock', - 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: {}, - 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: [NotificationActionButtonMock], - smallIcon: '[PC preview] unknow smallIcon', - largeIcon: '[PC preview] unknow largeIcon', - groupName: '[PC preview] unknow groupName', - 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', - isRemveAllowd: '[PC preview] unknow isRemveAllowd', - source: '[PC preview] unknow source', - template: '[PC preview] unknow template' - }; - const DeviceRemindType = { - IDLE_DONOT_REMIND: 0, - IDLE_REMIND: 1, - ACTIVE_DONOT_REMIND: 2, - ACTIVE_REMIND: 3, - }; const notification = { - SlotType: { - UNKNOWN_TYPE: 0, - SOCIAL_COMMUNICATION: 1, - SERVICE_INFORMATION: 2, - CONTENT_INFORMATION: 3, - OTHER_TYPES: 0xFFFF, - }, - ContentType: { - NOTIFICATION_CONTENT_BASIC_TEXT: 0, - NOTIFICATION_CONTENT_LONG_TEXT: 1, - NOTIFICATION_CONTENT_PICTURE: 2, - NOTIFICATION_CONTENT_CONVERSATION: 3, - NOTIFICATION_CONTENT_MULTILINE: 4, - }, 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.'); @@ -400,10 +376,10 @@ export function mockNotification() { ' Previewer may be 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); + args[len - 1].call(this, paramMock.businessErrorMock, NotificationSlot); } else { return new Promise((resolve) => { - resolve(NotificationSlotMock); + resolve(NotificationSlot); }); } }, @@ -412,10 +388,10 @@ export function mockNotification() { ' Previewer may be 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]); + args[len - 1].call(this, paramMock.businessErrorMock, [NotificationSlot]); } else { return new Promise((resolve) => { - resolve([NotificationSlotMock]); + resolve([NotificationSlot]); }); } }, @@ -532,10 +508,10 @@ export function mockNotification() { ' Previewer may be 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]); + args[len - 1].call(this, paramMock.businessErrorMock, [NotificationSlot]); } else { return new Promise((resolve) => { - resolve([NotificationSlotMock]); + resolve([NotificationSlot]); }); } }, @@ -580,10 +556,10 @@ export function mockNotification() { ' Previewer may be 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]); + args[len - 1].call(this, paramMock.businessErrorMock, [NotificationRequest]); } else { return new Promise((resolve) => { - resolve([NotificationRequestMock]); + resolve([NotificationRequest]); }); } }, @@ -604,10 +580,10 @@ export function mockNotification() { ' Previewer may be 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]); + args[len - 1].call(this, paramMock.businessErrorMock, [NotificationRequest]); } else { return new Promise((resolve) => { - resolve([NotificationRequestMock]); + resolve([NotificationRequest]); }); } }, @@ -652,10 +628,10 @@ export function mockNotification() { " How this interface works on the Previewer may be different from that on a real device.") const len = args.length if (len > 0 && typeof args[len - 1] === 'function') { - args[len - 1].call(this, paramMock.businessErrorMock, DoNotDisturbDateMock); + args[len - 1].call(this, paramMock.businessErrorMock, DoNotDisturbDate); } else { return new Promise((resolve, reject) => { - resolve(DoNotDisturbDateMock); + resolve(DoNotDisturbDate); }) } }, From aa61aadf3b8da8162efbf7fd48d5a6f66a7cb341 Mon Sep 17 00:00:00 2001 From: magekkkk Date: Fri, 8 Jul 2022 17:49:22 +0800 Subject: [PATCH 055/109] remove Mock suffix and use new foramt to rewrite mock impl Signed-off-by: magekkkk --- .../napi/ohos_multimedia_audio.js | 157 ++++++++---------- 1 file changed, 66 insertions(+), 91 deletions(-) diff --git a/runtime/main/extend/systemplugin/napi/ohos_multimedia_audio.js b/runtime/main/extend/systemplugin/napi/ohos_multimedia_audio.js index e0d4e5fd..b94ce59b 100644 --- a/runtime/main/extend/systemplugin/napi/ohos_multimedia_audio.js +++ b/runtime/main/extend/systemplugin/napi/ohos_multimedia_audio.js @@ -16,111 +16,86 @@ import { paramMock } from "../utils" export function mockMultimediaAudio() { - const interruptActionMock = { + const interruptAction = { actionType: "[PC Preview] unknow actionType", type: "[PC Preview] unknow type", hint: "[PC Preview] unknow hint", activated: "[PC Preview] unknow activated", } - const DeviceRoleMock = "[PC Preview] unknow DeviceRole" - const DeviceTypeMock = "[PC Preview] unknow DeviceType" - const AudioDeviceDescriptorMock = { - deviceRole: DeviceRoleMock, - deviceType: DeviceTypeMock, + const DeviceRole = "[PC Preview] unknow DeviceRole" + const DeviceType = "[PC Preview] unknow DeviceType" + const AudioDeviceDescriptor = { + deviceRole: DeviceRole, + deviceType: DeviceType, id: "[PC Preview] unknow id", name: "[PC Preview] unknow name", address: "[PC Preview] unknow address", - sampleRates: function () { - console.warn("AudioDeviceDescriptorMock.sampleRates interface mocked in the Previewer." + - " How this interface works on the Previewer may be different from that on a real device.") - var sampleRatesArray = new Array(); - return sampleRatesArray; - }, - channelCounts: function () { - console.warn("AudioDeviceDescriptorMock.channelCounts interface mocked in the Previewer." + - " How this interface works on the Previewer may be different from that on a real device.") - var channelCountsArray = new Array(); - return channelCountsArray; - }, - channelMasks: function () { - console.warn("AudioDeviceDescriptorMock.channelMasks interface mocked in the Previewer." + - " How this interface works on the Previewer may be different from that on a real device.") - var channelMasksArray = new Array(); - return channelMasksArray; - }, + sampleRates: [paramMock.paramNumberMock], + channelCounts: [paramMock.paramNumberMock], + channelMasks: [paramMock.paramNumberMock], } - const DeviceChangeActionMock = { + const DeviceChangeAction = { type: "[PC Preview] unknow type", - deviceDescriptors: AudioDeviceDescriptorMock, + deviceDescriptors: AudioDeviceDescriptor, } - const AudioRingModeMock = '[PC Preview] unknow AudioRingMode' - const VolumeEventMock = { + const AudioRingMode = '[PC Preview] unknow AudioRingMode' + const VolumeEvent = { volumeType: "[PC Preview] unknow volumeType", volume: "[PC Preview] unknow volume", updateUi: "[PC Preview] unknow updateUi", } - const AudioSceneMock = '[PC Preview] unknow AudioScene' - const AudioStreamInfoMock = { + const AudioScene = '[PC Preview] unknow AudioScene' + const AudioStreamInfo = { samplingRate: "[PC Preview] unknow samplingRate", channels: "[PC Preview] unknow channels", sampleFormat: "[PC Preview] unknow sampleFormat", encodingType: "[PC Preview] unknow encodingType", } - const AudioRendererInfoMock = { + const AudioRendererInfo = { content: "[PC Preview] unknow content", usage: "[PC Preview] unknow usage", rendererFlags: "[PC Preview] unknow rendererFlags", } - const AudioRendererOptionsMock = { - streamInfo: AudioStreamInfoMock, - rendererInfo: AudioRendererInfoMock, + const AudioRendererOptions = { + streamInfo: AudioStreamInfo, + rendererInfo: AudioRendererInfo, } - const AudioCapturerInfoMock = { + const AudioCapturerInfo = { source: "[PC Preview] unknow source", capturerFlags: "[PC Preview] unknow capturerFlags", } - const AudioCapturerOptionsMock = { - streamInfo: AudioStreamInfoMock, - capturerInfo: AudioCapturerInfoMock, + const AudioCapturerOptions = { + streamInfo: AudioStreamInfo, + capturerInfo: AudioCapturerInfo, } - const AudioStateMock = '[PC Preview] unknow AudioState' - const AudioRendererRateMock = '[PC Preview] unknow AudioRendererRate' - const InterruptEventMock = '[PC Preview] unknow InterruptEvent' - const AudioRendererChangeInfoMock = { + const AudioState = '[PC Preview] unknow AudioState' + const AudioRendererRate = '[PC Preview] unknow AudioRendererRate' + const InterruptEvent = '[PC Preview] unknow InterruptEvent' + const AudioRendererChangeInfo = { streamId: "[PC Preview] unknow streamId", clientUid: "[PC Preview] unknow clientUid", - rendererInfo: AudioRendererInfoMock, - rendererState: AudioStateMock, - deviceDescriptors: function () { - console.warn("AudioRendererChangeInfoMock.deviceDescriptors interface mocked in the Previewer." + - " How this interface works on the Previewer may be different from that on a real device.") - var audioDeviceDescriptors = new Array(AudioDeviceDescriptorMock); - return audioDeviceDescriptors; - }, + rendererInfo: AudioRendererInfo, + rendererState: AudioState, + deviceDescriptors: [AudioDeviceDescriptor], } - const AudioCapturerChangeInfoMock = { + const AudioCapturerChangeInfo = { streamId: "[PC Preview] unknow streamId", clientUid: "[PC Preview] unknow clientUid", - capturerInfo: AudioRendererInfoMock, - capturerState: AudioStateMock, - deviceDescriptors: function () { - console.warn("AudioCapturerChangeInfoMock.deviceDescriptors interface mocked in the Previewer." + - " How this interface works on the Previewer may be different from that on a real device.") - var audioDeviceDescriptors = new Array(AudioDeviceDescriptorMock); - return audioDeviceDescriptors; - }, + capturerInfo: AudioRendererInfo, + capturerState: AudioState, + deviceDescriptors: [AudioDeviceDescriptor], } - const AudioCapturerMock = { + const AudioCapturer = { state: "[PC Preview] unknow state", getCapturerInfo: function (...args) { console.warn("AudioCapturer.getCapturerInfo interface mocked in the Previewer." + " How this interface works on the Previewer may be different from that on a real device.") const len = args.length if (typeof args[len - 1] === 'function') { - args[len - 1].call(this, paramMock.businessErrorMock, AudioCapturerInfoMock); + args[len - 1].call(this, paramMock.businessErrorMock, AudioCapturerInfo); } else { return new Promise((resolve, reject) => { - resolve(AudioCapturerInfoMock); + resolve(AudioCapturerInfo); }) } }, @@ -129,10 +104,10 @@ export function mockMultimediaAudio() { " How this interface works on the Previewer may be different from that on a real device.") const len = args.length if (typeof args[len - 1] === 'function') { - args[len - 1].call(this, paramMock.businessErrorMock, AudioStreamInfoMock); + args[len - 1].call(this, paramMock.businessErrorMock, AudioStreamInfo); } else { return new Promise((resolve, reject) => { - resolve(AudioStreamInfoMock); + resolve(AudioStreamInfo); }) } }, @@ -217,17 +192,17 @@ export function mockMultimediaAudio() { " How this interface works on the Previewer may be different from that on a real device.") }, } - const AudioRendererMock ={ + const AudioRenderer = { state: "[PC Preview] unknow state", getRendererInfo: function (...args) { console.warn("AudioRenderer.getRendererInfo interface mocked in the Previewer." + " How this interface works on the Previewer may be different from that on a real device.") const len = args.length if (typeof args[len - 1] === 'function') { - args[len - 1].call(this, paramMock.businessErrorMock, AudioRendererInfoMock); + args[len - 1].call(this, paramMock.businessErrorMock, AudioRendererInfo); } else { return new Promise((resolve, reject) => { - resolve(AudioRendererInfoMock); + resolve(AudioRendererInfo); }) } }, @@ -236,10 +211,10 @@ export function mockMultimediaAudio() { " How this interface works on the Previewer may be different from that on a real device.") const len = args.length if (typeof args[len - 1] === 'function') { - args[len - 1].call(this, paramMock.businessErrorMock, AudioStreamInfoMock); + args[len - 1].call(this, paramMock.businessErrorMock, AudioStreamInfo); } else { return new Promise((resolve, reject) => { - resolve(AudioStreamInfoMock); + resolve(AudioStreamInfo); }) } }, @@ -356,10 +331,10 @@ export function mockMultimediaAudio() { " How this interface works on the Previewer may be different from that on a real device.") const len = args.length if (typeof args[len - 1] === 'function') { - args[len - 1].call(this, paramMock.businessErrorMock, AudioRendererRateMock); + args[len - 1].call(this, paramMock.businessErrorMock, AudioRendererRate); } else { return new Promise((resolve, reject) => { - resolve(AudioRendererRateMock); + resolve(AudioRendererRate); }) } }, @@ -384,20 +359,20 @@ export function mockMultimediaAudio() { } } } - const AudioManagerMock = { + const AudioManager = { on: function (...args) { console.warn("AudioManager.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] == 'interrupt') { - args[len - 1].call(this, interruptActionMock); + args[len - 1].call(this, interruptAction); } else if (args[0] == 'deviceChange') { - args[len - 1].call(this, DeviceChangeActionMock); + args[len - 1].call(this, DeviceChangeAction); } else if (args[0] == 'volumeChange') { - args[len - 1].call(this, VolumeEventMock); + args[len - 1].call(this, VolumeEvent); } else if (args[0] == 'ringerModeChange') { - args[len - 1].call(this, AudioRingModeMock); + args[len - 1].call(this, AudioRingMode); } } }, @@ -408,7 +383,7 @@ export function mockMultimediaAudio() { getDevices: function (...args) { console.warn("AudioManager.getDevices interface mocked in the Previewer." + " How this interface works on the Previewer may be different from that on a real device.") - var AudioDeviceDescriptors = new Array(AudioDeviceDescriptorMock) + var AudioDeviceDescriptors = new Array(AudioDeviceDescriptor) const len = args.length if (typeof args[len - 1] === 'function') { args[len - 1].call(this, paramMock.businessErrorMock, AudioDeviceDescriptors); @@ -591,10 +566,10 @@ export function mockMultimediaAudio() { " How this interface works on the Previewer may be different from that on a real device.") const len = args.length if (typeof args[len - 1] === 'function') { - args[len - 1].call(this, paramMock.businessErrorMock, AudioRingModeMock); + args[len - 1].call(this, paramMock.businessErrorMock, AudioRingMode); } else { return new Promise((resolve, reject) => { - resolve(AudioRingModeMock); + resolve(AudioRingMode); }) } }, @@ -615,10 +590,10 @@ export function mockMultimediaAudio() { " How this interface works on the Previewer may be different from that on a real device.") const len = args.length if (typeof args[len - 1] === 'function') { - args[len - 1].call(this, paramMock.businessErrorMock, AudioSceneMock); + args[len - 1].call(this, paramMock.businessErrorMock, AudioScene); } else { return new Promise((resolve, reject) => { - resolve(AudioSceneMock); + resolve(AudioScene); }) } }, @@ -651,15 +626,15 @@ export function mockMultimediaAudio() { " How this interface works on the Previewer may be different from that on a real device.") const len = args.length if (typeof args[len - 1] === 'function') { - args[len - 1].call(this, paramMock.businessErrorMock, AudioStreamManagerMock); + args[len - 1].call(this, paramMock.businessErrorMock, AudioStreamManager); } else { return new Promise((resolve, reject) => { - resolve(AudioStreamManagerMock); + resolve(AudioStreamManager); }) } } } - const AudioStreamManagerMock = { + const AudioStreamManager = { on: function (...args) { const len = args.length if (typeof args[len - 1] === 'function') { @@ -679,7 +654,7 @@ export function mockMultimediaAudio() { getCurrentAudioRendererInfoArray: function (...args) { console.warn("AudioStreamManager.getCurrentAudioRendererInfoArray interface mocked in the Previewer." + " How this interface works on the Previewer may be different from that on a real device.") - var AudioRendererChangeInfoArray = new Array(AudioRendererChangeInfoMock) + var AudioRendererChangeInfoArray = new Array(AudioRendererChangeInfo) const len = args.length if (typeof args[len - 1] === 'function') { args[len - 1].call(this, paramMock.businessErrorMock, AudioRendererChangeInfoArray); @@ -692,7 +667,7 @@ export function mockMultimediaAudio() { getCurrentAudioCapturerInfoArray: function (...args) { console.warn("AudioStreamManager.getCurrentAudioCapturerInfoArray interface mocked in the Previewer." + " How this interface works on the Previewer may be different from that on a real device.") - var AudioCapturerChangeInfoArray = new Array(AudioCapturerChangeInfoMock) + var AudioCapturerChangeInfoArray = new Array(AudioCapturerChangeInfo) const len = args.length if (typeof args[len - 1] === 'function') { args[len - 1].call(this, paramMock.businessErrorMock, AudioCapturerChangeInfoArray); @@ -811,17 +786,17 @@ export function mockMultimediaAudio() { getAudioManager: function () { console.warn("audio.getAudioManager interface mocked in the Previewer." + " How this interface works on the Previewer may be different from that on a real device.") - return AudioManagerMock; + return AudioManager; }, createAudioCapturer: function (...args) { console.warn("audio.createAudioCapturer interface mocked in the Previewer." + " How this interface works on the Previewer may be different from that on a real device.") const len = args.length if (typeof args[len - 1] === 'function') { - args[len - 1].call(this, paramMock.businessErrorMock, AudioCapturerMock); + args[len - 1].call(this, paramMock.businessErrorMock, AudioCapturer); } else { return new Promise((resolve, reject) => { - resolve(AudioCapturerMock); + resolve(AudioCapturer); }) } }, @@ -830,10 +805,10 @@ export function mockMultimediaAudio() { " How this interface works on the Previewer may be different from that on a real device.") const len = args.length if (typeof args[len - 1] === 'function') { - args[len - 1].call(this, paramMock.businessErrorMock, AudioRendererMock); + args[len - 1].call(this, paramMock.businessErrorMock, AudioRenderer); } else { return new Promise((resolve, reject) => { - resolve(AudioRendererMock); + resolve(AudioRenderer); }) } } From 7f0a741c0d035f1356062f69a55f416dfdc075b3 Mon Sep 17 00:00:00 2001 From: binny1024 Date: Tue, 12 Jul 2022 09:39:34 +0800 Subject: [PATCH 056/109] =?UTF-8?q?=E8=A1=A5=E5=85=85=20mock?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: zhouyaoying Change-Id: If8a2ff8ff635f196e4e48f00df00d692b0f9b858 --- .../extend/systemplugin/napi/ohos_display.js | 202 ++- .../extend/systemplugin/napi/ohos_screen.js | 435 ++--- .../extend/systemplugin/napi/ohos_window.js | 1452 ++++++++--------- 3 files changed, 1053 insertions(+), 1036 deletions(-) diff --git a/runtime/main/extend/systemplugin/napi/ohos_display.js b/runtime/main/extend/systemplugin/napi/ohos_display.js index 9ef6e171..b3123826 100644 --- a/runtime/main/extend/systemplugin/napi/ohos_display.js +++ b/runtime/main/extend/systemplugin/napi/ohos_display.js @@ -1,88 +1,116 @@ -/* - * Copyright (c) 2021 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import { paramMock } from "../utils" - -export function mockDisplay() { - const displayMock = { - densityDPI: '[PC preview] unknow densityDPI', - densityPixels: '[PC preview] unknow densityPixels', - scaledDensity: '[PC preview] unknow scaledDensity', - xDPI: '[PC preview] unknow xDPI', - yDPI: '[PC preview] unknow yDPI', - width: '[PC preview] unknow width', - height: '[PC preview] unknow height', - alive: '[PC preview] unknow alive', - refreshRate: '[PC preview] unknow refreshRate', - id: '[PC preview] unknow id', - state: '[PC preview] unknow state', - rotation: '[PC preview] unknow rotation', - name: '[PC preview] unknow name' - } - const allDisplayMock = [{ - densityDPI: '[PC preview] unknow densityDPI', - densityPixels: '[PC preview] unknow densityPixels', - scaledDensity: '[PC preview] unknow scaledDensity', - xDPI: '[PC preview] unknow xDPI', - yDPI: '[PC preview] unknow yDPI', - width: '[PC preview] unknow width', - height: '[PC preview] unknow height', - alive: '[PC preview] unknow alive', - refreshRate: '[PC preview] unknow refreshRate', - id: '[PC preview] unknow id', - state: '[PC preview] unknow state', - rotation: '[PC preview] unknow rotation', - name: '[PC preview] unknow name' - }] - const display = { - getDefaultDisplay: function (...args) { - console.warn("display.getDefaultDisplay interface mocked in the Previewer. How this interface works on the Previewer" + - " may be different from that on a real device.") - const len = args.length - if (typeof args[len - 1] === 'function') { - args[len - 1].call(this, paramMock.businessErrorMock, displayMock) - } else { - return new Promise((resolve, reject) => { - resolve(displayMock) - }) - } - }, - getAllDisplay: function (...args) { - console.warn("display.getAllDisplay interface mocked in the Previewer. How this interface works on the Previewer" + - " may be different from that on a real device.") - const len = args.length - if (typeof args[len - 1] === 'function') { - args[len - 1].call(this, paramMock.businessErrorMock, allDisplayMock) - } else { - return new Promise((resolve, reject) => { - resolve(allDisplayMock) - }) - } - }, - on: function (...args) { - console.warn("display.on interface mocked in the Previewer. How this interface works on the Previewer may be" + - " different from that on a real device.") - const len = args.length - args[len - 1].call(this, paramMock.businessErrorMock, paramMock.paramNumberMock) - }, - off: function (...args) { - console.warn("display.off interface mocked in the Previewer. How this interface works on the Previewer may be" + - " different from that on a real device.") - const len = args.length - args[len - 1].call(this, paramMock.businessErrorMock, paramMock.paramNumberMock) - }, - } - return display +/* + * Copyright (c) 2021 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { paramMock } from "../utils" + +const DisplayState = { + STATE_UNKNOWN: 0, + STATE_OFF: 1, + STATE_ON: 2, + STATE_DOZE: 3, + STATE_DOZE_SUSPEND: 4, + STATE_VR: 5, + STATE_ON_SUSPEND: 6 +} +const DisplayType = { + add: 'add', + remove: 'remove', + change: 'change' +} + +export const Display = { + id: '[PC preview] unknow id', + name: '[PC preview] unknow name', + alive: '[PC preview] unknow alive', + state: '[PC preview] unknow state', + refreshRate: '[PC preview] unknow refreshRate', + rotation: '[PC preview] unknow rotation', + width: '[PC preview] unknow width', + height: '[PC preview] unknow height', + densityDPI: '[PC preview] unknow densityDPI', + densityPixels: '[PC preview] unknow densityPixels', + scaledDensity: '[PC preview] unknow scaledDensity', + xDPI: '[PC preview] unknow xDPI', + yDPI: '[PC preview] unknow yDPI' +} + +export function mockDisplay() { + + const display = { + getDefaultDisplay: function (...args) { + console.warn("Display.getDefaultDisplay interface mocked in the Previewer. How this interface works on the Previewer" + + " may be different from that on a real device.") + const len = args.length + if (typeof args[len - 1] === 'function') { + args[len - 1].call(this, paramMock.businessErrorMock, Display) + } else { + return new Promise((resolve, reject) => { + resolve(Display) + }) + } + }, + getAllDisplay: function (...args) { + console.warn("Display.getAllDisplay interface mocked in the Previewer. How this interface works on the Previewer" + + " may be different from that on a real device.") + const len = args.length + if (typeof args[len - 1] === 'function') { + args[len - 1].call(this, paramMock.businessErrorMock, [Display]) + } else { + return new Promise((resolve, reject) => { + resolve([Display]) + }) + } + }, + on: function (...args) { + console.warn("Display.on interface mocked in the Previewer. How this interface works on the Previewer may be" + + " different from that on a real device.") + const len = args.length + if (len!==2){ + console.warn("Display.on:please check params !") + return + } + if (typeof args[len - 1] === 'function') { + if (args[0] === DisplayType.add|| args[0] === DisplayType.remove || args[0] === DisplayType.change){ + console.warn(`Display.on: you has registered ${args[0]} event.`) + } else { + console.warn("Display.on:please check first param!") + } + } else { + console.warn("Display.on:please check params, the second parma must be a function!") + } + }, + off: function (...args) { + console.warn("Display.off interface mocked in the Previewer. How this interface works on the Previewer may be" + + " different from that on a real device.") + const len = args.length + if (len!==2){ + console.warn("Display.off:please check params!") + return + } + if (typeof args[len - 1] === 'function') { + if (args[0] === DisplayType.add|| args[0] === DisplayType.remove || args[0] === DisplayType.change){ + console.warn(`Display.off: you has registered ${args[0]} event`) + } else { + console.warn("Display.off:please check first param!") + } + } else { + console.warn("Display.off:please check params, the second parma must be a function!") + } + }, + DisplayState: DisplayState, + Type: DisplayType + } + return display } \ No newline at end of file diff --git a/runtime/main/extend/systemplugin/napi/ohos_screen.js b/runtime/main/extend/systemplugin/napi/ohos_screen.js index 7f1f597f..577a1225 100644 --- a/runtime/main/extend/systemplugin/napi/ohos_screen.js +++ b/runtime/main/extend/systemplugin/napi/ohos_screen.js @@ -1,211 +1,224 @@ -/* - * Copyright (c) 2022 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import {paramMock} from '../utils'; - -export const OrientationMock = { - UNSPECIFIED: 0, - VERTICAL: 1, - HORIZONTAL: 2, - REVERSE_VERTICAL: 3, - REVERSE_HORIZONTAL: 4, - SENSOR: 5, - SENSOR_VERTICAL: 6, - SENSOR_HORIZONTAL: 7 -}; - -export const screenMock = { - id: 'PC preview] unknown id', - parent: '[PC preview] unknown parent', - supportedModeInfo: supportedModeInfoMock, - activeModeIndex: '[PC preview] unknown activeModeIndex', - orientation: OrientationMock, - setOrientation: function(...args) { - console.warn('Screen.setOrientation interface mocked in the Previewer. How this interface works on the' + - ' Previewer may be different from that on a 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(); - }); - } - }, - setScreenActiveMode: function(...args) { - console.warn('Screen.setScreenActiveMode interface mocked in the Previewer. How this interface works on the' + - ' Previewer may be different from that on a 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(); - }); - } - }, - setDensityDpi: function(...args) { - console.warn('Screen.setDensityDpi interface mocked in the Previewer. How this interface works on the' + - ' Previewer may be different from that on a real device.'); - const len = args.length; - if (typeof args[len - 1] === 'function') { - args[len - 1].call(this, paramMock.businessErrorMock); - } else { - return new Promise((resolve) => { - resolve(); - }); - } - } -}; - -export const allScreenMock = [ - screenMock -]; - -export const ExpandOptionMock = { - screenId: '[PC preview] unknown screenId', - startX: '[PC preview] unknown startX', - startY: '[PC preview] unknown startY' -}; - -export const VirtualScreenOptionMock = { - name: '[PC preview] unknown name', - width: '[PC preview] unknown width', - height: '[PC preview] unknown height', - density: '[PC preview] unknown density', - surfaceId: '[PC preview] unknown surfaceId' -}; - -export const screenModeInfoMock = { - id: '[PC preview] unknown id', - width: '[PC preview] unknown width', - height: '[PC preview] unknown height', - refreshRate: '[PC preview] unknown refreshRate' -}; - -export const supportedModeInfoMock = [ - screenModeInfoMock -] - -export function mockScreen() { - const screen = { - ExpandOption: ExpandOptionMock, - VirtualScreenOption: VirtualScreenOptionMock, - Orientation: OrientationMock, - ScreenModeInfo: screenModeInfoMock, - getAllScreens: function(...args) { - console.warn('Screen.getAllScreens interface mocked in the Previewer. How this interface works on the' + - ' Previewer may be different from that on a real device.'); - const len = args.length; - if (typeof args[len - 1] === 'function') { - args[len - 1].call(this, paramMock.businessErrorMock, allScreenMock); - } else { - return new Promise((resolve) => { - resolve(allScreenMock); - }); - } - }, - on: function(...args) { - console.warn('Screen.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] === 'connect' || args[0] === 'disconnect' || args[0] === 'change') { - console.warn(`you has registered ${args[0]} event`) - } else { - console.warn('on: please check first param!') - } - } else { - console.warn('on: please check param!') - } - }, - off: function(...args) { - console.warn('Screen.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] === 'connect' || args[0] === 'disconnect' || args[0] === 'change') { - console.warn(`you has registered ${args[0]} event`) - } else { - console.warn('off: please check first param!') - } - } else { - console.warn('off: please check param!') - } - }, - makeExpand: function(...args) { - console.warn('Screen.makeExpand interface mocked in the Previewer. How this interface works on the' + - ' Previewer may be different 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); - }); - } - }, - makeMirror: function(...args) { - console.warn('Screen.makeMirror interface mocked in the Previewer. How this interface works on the' + - ' Previewer may be different 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); - }); - } - }, - createVirtualScreen: function(...args) { - console.warn('Screen.createVirtualScreen interface mocked in the Previewer. How this interface works on the' + - ' Previewer may be different from that on a real device.'); - const len = args.length; - if (typeof args[len - 1] === 'function') { - args[len - 1].call(this, paramMock.businessErrorMock, screenMock); - } else { - return new Promise((resolve) => { - resolve(screenMock); - }); - } - }, - destroyVirtualScreen: function(...args) { - console.warn('Screen.destroyVirtualScreen interface mocked in the Previewer. How this interface works on the' + - ' Previewer may be different from that on a 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(); - }); - } - }, - setVirtualScreenSurface: function(...args) { - console.warn('Screen.setVirtualScreenSurface interface mocked in the Previewer. How this interface works on the' + - ' Previewer may be different from that on a real device.'); - const len = args.length; - if (typeof args[len - 1] === 'function') { - args[len - 1].call(this, paramMock.businessErrorMock); - } else { - return new Promise((resolve) => { - resolve(); - }); - } - } - } - return screen -} - +/* + * Copyright (c) 2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { paramMock } from '../utils'; + +export const Orientation = { + UNSPECIFIED: 0, + VERTICAL: 1, + HORIZONTAL: 2, + REVERSE_VERTICAL: 3, + REVERSE_HORIZONTAL: 4, + SENSOR: 5, + SENSOR_VERTICAL: 6, + SENSOR_HORIZONTAL: 7 +}; + +export const Screen = { + id: 'PC preview] unknown id', + parent: '[PC preview] unknown parent', + supportedModeInfo: supportedModeInfoArray, + activeModeIndex: '[PC preview] unknown activeModeIndex', + orientation: Orientation, + setOrientation: function(...args) { + console.warn('Screen.setOrientation interface mocked in the Previewer. How this interface works on the' + + ' Previewer may be different from that on a 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(); + }); + } + }, + setScreenActiveMode: function(...args) { + console.warn('Screen.setScreenActiveMode interface mocked in the Previewer. How this interface works on the' + + ' Previewer may be different from that on a 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(); + }); + } + }, + setDensityDpi: function(...args) { + console.warn('Screen.setDensityDpi interface mocked in the Previewer. How this interface works on the' + + ' Previewer may be different from that on a real device.'); + const len = args.length; + if (typeof args[len - 1] === 'function') { + args[len - 1].call(this, paramMock.businessErrorMock); + } else { + return new Promise((resolve) => { + resolve(); + }); + } + } +}; + +export const allScreenMock = [ + Screen +]; + +export const ExpandOption = { + screenId: '[PC preview] unknown screenId', + startX: '[PC preview] unknown startX', + startY: '[PC preview] unknown startY' +}; + +export const VirtualScreenOption = { + name: '[PC preview] unknown name', + width: '[PC preview] unknown width', + height: '[PC preview] unknown height', + density: '[PC preview] unknown density', + surfaceId: '[PC preview] unknown surfaceId' +}; + +export const ScreenModeInfo = { + id: '[PC preview] unknown id', + width: '[PC preview] unknown width', + height: '[PC preview] unknown height', + refreshRate: '[PC preview] unknown refreshRate' +}; + +export const supportedModeInfoArray = [ + ScreenModeInfo +] +const EventTypeMock = { + connect: 'connect', + disconnect: 'disconnect', + change: 'change' +} +export function mockScreen() { + const screen = { + ExpandOption: ExpandOption, + VirtualScreenOption: VirtualScreenOption, + Orientation: Orientation, + ScreenModeInfo: ScreenModeInfo, + EventType: EventTypeMock, + getAllScreens: function(...args) { + console.warn( + 'Screen.getAllScreens interface mocked in the Previewer. How this interface works on the' + ' Previewer may be different from that on a real device.'); + const len = args.length; + if (typeof args[len - 1] === 'function') { + args[len - 1].call(this, paramMock.businessErrorMock, allScreenMock); + } else { + return new Promise((resolve) => { + resolve(allScreenMock); + }); + } + }, + on: function(...args) { + console.warn( + 'Screen.on interface mocked in the Previewer. How this interface works on the Previewer may be' + ' different from that on a real device.'); + const len = args.length; + if (len!==2){ + console.warn("Screen.on please check params!") + return + } + if (typeof args[len - 1] === 'function') { + if (args[0] === EventTypeMock.connect || args[0] === EventTypeMock.disconnect || args[0] === EventTypeMock.change) { + console.warn(`Screen.on you has registered ${args[0]} event`) + } else { + console.warn('Screen.on please check first param!') + } + } else { + console.warn('Screen.on please check param!') + } + }, + off: function(...args) { + console.warn( + 'Screen.off interface mocked in the Previewer. How this interface works on the Previewer may be' + ' different from that on a real device.'); + const len = args.length; + if (len!==2){ + console.warn("Screen.off please check params!") + return + } + if (typeof args[len - 1] === 'function') { + if (args[0] === EventTypeMock.connect || args[0] === EventTypeMock.disconnect || args[0] === EventTypeMock.change) { + console.warn(`Screen.off you has registered ${args[0]} event`) + } else { + console.warn('Screen.off please check first param!') + } + } else { + console.warn('Screen.off please check param!') + } + }, + makeExpand: function(...args) { + console.warn( + 'Screen.makeExpand interface mocked in the Previewer. How this interface works on the' + ' Previewer may be different 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); + }); + } + }, + makeMirror: function(...args) { + console.warn( + 'Screen.makeMirror interface mocked in the Previewer. How this interface works on the' + ' Previewer may be different 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); + }); + } + }, + createVirtualScreen: function(...args) { + console.warn( + 'Screen.createVirtualScreen interface mocked in the Previewer. How this interface works on the' + ' Previewer may be different from that on a real device.'); + const len = args.length; + if (typeof args[len - 1] === 'function') { + args[len - 1].call(this, paramMock.businessErrorMock, Screen); + } else { + return new Promise((resolve) => { + resolve(Screen); + }); + } + }, + destroyVirtualScreen: function(...args) { + console.warn( + 'Screen.destroyVirtualScreen interface mocked in the Previewer. How this interface works on the' + ' Previewer may be different from that on a 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(); + }); + } + }, + setVirtualScreenSurface: function(...args) { + console.warn( + 'Screen.setVirtualScreenSurface interface mocked in the Previewer. How this interface works on the' + ' Previewer may be different from that on a real device.'); + const len = args.length; + if (typeof args[len - 1] === 'function') { + args[len - 1].call(this, paramMock.businessErrorMock); + } else { + return new Promise((resolve) => { + resolve(); + }); + } + } + } + return screen +} + diff --git a/runtime/main/extend/systemplugin/napi/ohos_window.js b/runtime/main/extend/systemplugin/napi/ohos_window.js index f06438a1..2e3279f9 100644 --- a/runtime/main/extend/systemplugin/napi/ohos_window.js +++ b/runtime/main/extend/systemplugin/napi/ohos_window.js @@ -1,738 +1,714 @@ -/* - * Copyright (c) 2021-2022 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import {paramMock} from "../utils" - -export const 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' -} -export 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' -} -export const AvoidAreaMock = { - visible: '[PC preview] unknow visible', - leftRect: RectMock, - topRect: RectMock, - rightRect: RectMock, - bottomRect: RectMock -} -export const WindowTypeMock = { - TYPE_APP: 0, - TYPE_SYSTEM_ALERT: 1, - TYPE_INPUT_METHOD: 2, - TYPE_STATUS_BAR: 3, - TYPE_PANEL: 4, - TYPE_KEYGUARD: 5, - TYPE_VOLUME_OVERLAY: 6, - TYPE_NAVIGATION_BAR: 7 -} -export const SystemBarRegionTintMock={ - type: WindowTypeMock, - isEnable: '[PC preview] unknow isEnable', - region: RectMock, - backgroundColor: '[PC preview] unknow backgroundColor', - contentColor: '[PC preview] unknow contentColor' -} -export const SystemBarTintStateMock= { - displayId: '[PC preview] unknow brightness', - regionTint:[SystemBarRegionTintMock] -} -export const SizeMock = { - width: '[PC preview] unknow width', - height: '[PC preview] unknow height' -} -export const WindowStageEventTypeMock = { - FOREGROUND: 1, - ACTIVE: 2, - INACTIVE: 3, - BACKGROUND: 4 -} - -export const WindowStageMock= { - getMainWindow: function (...args) { - console.warn("windowStage.getMainWindow interface mocked in the Previewer. How this interface works on the Previewer" + - " may be 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) - } else { - return new Promise((resolve, reject) => { - resolve(windowMock) - }) - } - }, - createSubWindow: function (...args) { - console.warn("windowStage.createSubWindow interface mocked in the Previewer. How this interface works on the Previewer" + - " may be 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) - } else { - return new Promise((resolve, reject) => { - resolve(windowMock) - }) - } - }, - getSubWindow: function (...args) { - console.warn("windowStage.getSubWindow interface mocked in the Previewer. How this interface works on the Previewer" + - " may be 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]) - } else { - return new Promise((resolve, reject) => { - resolve([windowMock]) - }) - } - }, - loadContent: function (...args) { - console.warn("windowStage.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, reject) => { - resolve() - }) - } - }, - on: function (...args) { - console.warn("windowStage.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]==='windowStageEvent'){ - console.warn(`you has registered ${args[0]} event`) - }else { - console.warn("on:please check first param!") - } - }else { - console.warn("on:please check param!") - } - }, - off: function (...args) { - console.warn("windowStage.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]==='windowStageEvent'){ - console.warn(`you has registered ${args[0]} event`) - }else { - console.warn("off:please check first param!") - } - }else { - console.warn("off:please check param!") - } - }, - disableWindowDecor: function (){ - console.warn("windowStage.disableWindowDecor interface mocked in the Previewer. How this interface works on the Previewer" + - " may be different from that on a real device.") - }, - setShowOnLockScreen: function (){ - console.warn("windowStage.setShowOnLockScreen interface mocked in the Previewer. How this interface works on the Previewer" + - " may be different from that on a real device.") - } -} - -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() - }) - } - }, - setForbidSplitMove: function (...args) { - console.warn("Window.setForbidSplitMove interface mocked in the Previewer. How this interface works on the" + - " Previewer may be different from that on a 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() - }) - } - }, - 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() - }) - } - }, - 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; - if (typeof args[len - 1] === 'function') { - if (args[0] === 'keyboardHeightChange' || args[0] === 'systemAvoidAreaChange' - || args[0] === 'avoidAreaChange' || args[0] === 'windowSizeChange' || args[0] === 'touchOutside') { - console.warn(`you has registered ${args[0]} event`) - } else { - console.warn('on: please check first param!') - } - } else { - console.warn('on:please check param!') - } - }, - off: function (...args) { - console.warn('Window.off interface mocked in the Previewer. How this interface works on the Previewer may be' + - ' different from that on a real device.') - const len = args.length; - if (typeof args[len - 1] === 'function') { - if (args[0] === 'keyboardHeightChange' || args[0] === 'systemAvoidAreaChange' - || args[0] === 'avoidAreaChange' || args[0] === 'windowSizeChange' || args[0] === 'touchOutside') { - console.warn(`you has registered ${args[0]} event`) - } else { - console.warn('off:please check first param!') - } - } else { - console.warn('off:please check param!') - } - }, - setColorSpace: function (...args) { - console.warn("Window.setColorSpace interface mocked in the Previewer. How this interface works on the Previewer" + - " may be different from that on a 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() - }) - } - }, - getColorSpace: function (...args) { - console.warn("Window.getColorSpace interface mocked in the Previewer. How this interface works on the Previewer" + - " may be different 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) - }) - } - }, - isSupportWideGamut: function (...args) { - console.warn("Window.isSupportWideGamut interface mocked in the Previewer. How this interface works on the" + - " Previewer may be different from that on a real device.") - const len = args.length - if (typeof args[len - 1] === 'function') { - args[len - 1].call(this, paramMock.businessErrorMock, paramMock.paramBooleanMock) - } else { - return new Promise((resolve) => { - resolve(paramMock.paramBooleanMock) - }) - } - }, -} - -export function mockWindow() { - const SizeMock = { - width: '[PC preview] unknow width', - height: '[PC preview] unknow height' - } - const getSplitScreenBoundsMock = { - splitMode: '[PC preview] unknow splitMode', - primaryBounds: RectMock, - secondaryBounds: RectMock, - } - const window = { - getTopWindow: function (...args) { - console.warn("window.getTopWindow interface mocked in the Previewer. How this interface works on the Previewer" + - " may be different from that on a real device.") - const len = args.length - if (typeof args[len - 1] === 'function') { - args[len - 1].call(this, paramMock.businessErrorMock, windowMock) - } else { - return new Promise((resolve, reject) => { - resolve(windowMock) - }) - } - }, - create: function (...args) { - console.warn("Window.create interface mocked in the Previewer. How this interface works on the" + - " Previewer may be different from that on a real device.") - const len = args.length - if (typeof args[len - 1] === 'function') { - args[len - 1].call(this, paramMock.businessErrorMock, windowMock) - } else { - return new Promise((resolve, reject) => { - resolve(windowMock) - }) - } - }, - find: function (...args) { - console.warn("Window.find interface mocked in the Previewer. How this interface works on the" + - " Previewer may be different from that on a real device.") - const len = args.length - if (typeof args[len - 1] === 'function') { - args[len - 1].call(this, paramMock.businessErrorMock, windowMock) - } else { - return new Promise((resolve, reject) => { - resolve(windowMock) - }) - } - }, - getAbilityWindowMode: function (...args) { - console.warn("Window.getAbilityWindowMode interface mocked in the Previewer. How this interface works on the Previewer" + - " may be different 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() - }) - } - }, - minimizeAll: function (...args) { - console.warn("window.minimizeAll interface mocked in the Previewer. How this interface works on the Previewer" + - " may be different from that on a real device.") - const len = args.length - if (typeof args[len - 1] === 'function') { - args[len - 1].call(this, paramMock.businessErrorMock) - } else { - return new Promise((resolve, reject) => { - resolve() - }) - } - }, - toggleShownStateForAllAppWindows: function (...args) { - console.warn("window.toggleShownStateForAllAppWindows interface mocked in the Previewer. How this interface works on the Previewer" + - " may be different from that on a real device.") - const len = args.length - if (typeof args[len - 1] === 'function') { - args[len - 1].call(this, paramMock.businessErrorMock) - } else { - return new Promise((resolve, reject) => { - resolve() - }) - } - }, - setWindowLayoutMode: function (...args) { - console.warn("window.setWindowLayoutMode interface mocked in the Previewer. How this interface works on the Previewer" + - " may be different from that on a real device.") - const len = args.length - if (typeof args[len - 1] === 'function') { - args[len - 1].call(this, paramMock.businessErrorMock) - } else { - return new Promise((resolve, reject) => { - resolve() - }) - } - }, - on: function (...args) { - console.warn("window.on interface mocked in the Previewer. How this interface works on the Previewer" + - " may be different from that on a real device.") - const len = args.length - if (typeof args[len - 1] === 'function') { - if (args[0]==='systemBarTintChange'){ - console.warn(`you has registered ${args[0]} event`) - }else { - console.warn("on:please check first param!") - } - }else { - console.warn("on:please check param!") - } - }, - off: function (...args) { - console.warn("window.off interface mocked in the Previewer. How this interface works on the Previewer" + - " may be different from that on a real device.") - const len = args.length - if (typeof args[len - 1] === 'function') { - if (args[0]==='systemBarTintChange'){ - console.warn(`you has registered ${args[0]} event`) - }else { - console.warn("off:please check first param!") - } - }else { - console.warn("off:please check param!") - } - }, - WindowType: WindowTypeMock, - AvoidAreaType: { - TYPE_SYSTEM: 0, - TYPE_CUTOUT: 1, - TYPE_SYSTEM_GESTURE: 2, - TYPE_KEYBOARD: 3 - }, - WindowMode: { - UNDEFINED: 1, - FULLSCREEN: 2, - PRIMARY: 3, - SECONDARY: 4, - FLOATING: 5 - }, - WindowLayoutMode: { - WINDOW_LAYOUT_MODE_CASCADE: 0, - WINDOW_LAYOUT_MODE_TILE: 1 - }, - SystemBarProperties: { - statusBarColor: '[PC preview] unknow statusBarColor', - isStatusBarLightIcon: '[PC preview] unknow isStatusBarLightIcon', - statusBarContentColor: '[PC preview] unknow statusBarContentColor', - navigationBarColor: '[PC preview] unknow navigationBarColor', - isNavigationBarLightIcon: '[PC preview] unknow isNavigationBarLightIcon', - navigationBarContentColor: '[PC preview] unknow navigationBarContentColor' - }, - SystemBarRegionTint: SystemBarRegionTintMock, - SystemBarTintState: SystemBarTintStateMock, - Rect: { - left: '[PC preview] unknow left', - top: '[PC preview] unknow top', - width: '[PC preview] unknow width', - height: '[PC preview] unknow height' - }, - AvoidArea:AvoidAreaMock, - Size: SizeMock, - WindowProperties: { - windowRect: RectMock, - type: WindowTypeMock, - isFullScreen: '[PC preview] unknow isFullScreen', - isLayoutFullScreen: '[PC preview] unknow isLayoutFullScreen', - focusable: '[PC preview] unknow focusable', - touchable: '[PC preview] unknow touchable', - brightness: '[PC preview] unknow brightness', - dimBehindValue: '[PC preview] unknow dimBehindValue', - isKeepScreenOn: '[PC preview] unknow isKeepScreenOn', - isPrivacyMode: '[PC preview] unknow isPrivacyMode', - isRoundCorner: '[PC preview] unknow isRoundCorner', - isTransparent: '[PC preview] unknow isTransparent' - }, - ColorSpace: { - DEFAULT: 0, - WIDE_GAMUT: 1 - }, - WindowStageEventType: WindowStageEventTypeMock, - WindowStage: WindowStageMock - } - return window -} +/* + * Copyright (c) 2021-2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { paramMock } from "../utils" + +export const WindowType = { + TYPE_APP: 0, + TYPE_SYSTEM_ALERT: 1, + TYPE_INPUT_METHOD: 2, + TYPE_STATUS_BAR: 3, + TYPE_PANEL: 4, + TYPE_KEYGUARD: 5, + TYPE_VOLUME_OVERLAY: 6, + TYPE_NAVIGATION_BAR: 7, + TYPE_FLOAT: 8, + TYPE_WALLPAPER: 9, + TYPE_DESKTOP: 10, + TYPE_LAUNCHER_RECENT: 11, + TYPE_LAUNCHER_DOCK: 12, + TYPE_VOICE_INTERACTION: 13, + TYPE_POINTER: 14 +} + +export const AvoidAreaType= { + TYPE_SYSTEM: 0, + TYPE_CUTOUT: 1, + TYPE_SYSTEM_GESTURE: 2, + TYPE_KEYBOARD: 3 +} + +export const WindowMode= { + UNDEFINED: 1, + FULLSCREEN: 2, + PRIMARY: 3, + SECONDARY: 4, + FLOATING: 5 +} + +export const WindowLayoutMode= { + WINDOW_LAYOUT_MODE_CASCADE: 0, + WINDOW_LAYOUT_MODE_TILE: 1 +} + +export const SystemBarProperties= { + statusBarColor: '[PC preview] unknow statusBarColor', + isStatusBarLightIcon: '[PC preview] unknow isStatusBarLightIcon', + statusBarContentColor: '[PC preview] unknow statusBarContentColor', + navigationBarColor: '[PC preview] unknow navigationBarColor', + isNavigationBarLightIcon: '[PC preview] unknow isNavigationBarLightIcon', + navigationBarContentColor: '[PC preview] unknow navigationBarContentColor' +} + +export const Rect = { + left: '[PC preview] unknow Rect.left', + top: '[PC preview] unknow Rect.top', + width: '[PC preview] unknow Rect.width', + height: '[PC preview] unknow Rect.height' +} + +export const SystemBarRegionTint = { + type: WindowType, + isEnable: '[PC preview] unknow isEnable', + region: Rect, + backgroundColor: '[PC preview] unknow backgroundColor', + contentColor: '[PC preview] unknow contentColor' +} + +export const SystemBarTintState = { + displayId: '[PC preview] unknow brightness', + regionTint:[SystemBarRegionTint] +} + +export const AvoidArea = { + visible: '[PC preview] unknow AvoidArea.visible', + leftRect: Rect, + topRect: Rect, + rightRect: Rect, + bottomRect: Rect +} +export const Size = { + width: '[PC preview] unknow width', + height: '[PC preview] unknow height' +} + +export const WindowProperties = { + 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' +} + +export const ColorSpace = { + DEFAULT: 0, + WIDE_GAMUT: 1 +} + +export const WindowStageEventType = { + FOREGROUND: 1, + ACTIVE: 2, + INACTIVE: 3, + BACKGROUND: 4 +} + +export const WindowStage = { + getMainWindow: function(...args) { + console.warn("WindowStage.getMainWindow interface mocked in the Previewer. How this interface works on the Previewer" + + " may be different from that on a real device.") + const len = args.length + if (typeof args[len - 1] === 'function') { + args[len - 1].call(this, paramMock.businessErrorMock, Window) + } else { + return new Promise((resolve) => { + resolve(Window) + }) + } + }, + createSubWindow: function(...args) { + console.warn("WindowStage.createSubWindow interface mocked in the Previewer. How this interface works on the Previewer" + + " may be different from that on a real device.") + const len = args.length + if (typeof args[len - 1] === 'function') { + args[len - 1].call(this, paramMock.businessErrorMock, Window) + } else { + return new Promise((resolve) => { + resolve(Window) + }) + } + }, + getSubWindow: function(...args) { + console.warn("WindowStage.getSubWindow interface mocked in the Previewer. How this interface works on the Previewer" + + " may be different from that on a real device.") + const len = args.length + if (typeof args[len - 1] === 'function') { + args[len - 1].call(this, paramMock.businessErrorMock, [Window]) + } else { + return new Promise((resolve) => { + resolve([Window]) + }) + } + }, + loadContent: function(...args) { + console.warn("WindowStage.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() + }) + } + }, + on: function(...args) { + console.warn("WindowStage.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] === 'windowStageEvent') { + console.warn(`WindowStage.on you has registered ${args[0]} event`) + } else { + console.warn("WindowStage.on:please check first param!") + } + } else { + console.warn("WindowStage.on:please check param!") + } + }, + off: function(...args) { + console.warn("WindowStage.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] === 'windowStageEvent') { + console.warn(`you has registered ${args[0]} event`) + }else { + console.warn("WindowStage.off:please check first param!") + } + }else { + console.warn("WindowStage.off:please check param!") + } + }, + disableWindowDecor: function() { + console.warn("WindowStage.disableWindowDecor interface mocked in the Previewer. How this interface works on the Previewer" + + " may be different from that on a real device.") + }, + setShowOnLockScreen: function() { + console.warn("WindowStage.setShowOnLockScreen interface mocked in the Previewer. How this interface works on the" + + " Previewer" + + " may be different from that on a real device.") + } +} + +export const Window = { + 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() + }) + } + }, + setForbidSplitMove: function(...args) { + console.warn("Window.setForbidSplitMove interface mocked in the Previewer. How this interface works on the" + + " Previewer may be different from that on a 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, WindowProperties) + } else { + return new Promise((resolve) => { + resolve(WindowProperties) + }) + } + }, + 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, AvoidArea) + } else { + return new Promise((resolve) => { + resolve(AvoidArea) + }) + } + }, + 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() + }) + } + }, + 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() + }) + } + }, + 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; + if (typeof args[len - 1] === 'function') { + if (args[0] === 'keyboardHeightChange'|| args[0] === 'systemAvoidAreaChange' + || args[0] === 'windowSizeChange'|| args[0] === 'touchOutside'|| args[0] === 'avoidAreaChange' + ){ + console.warn(`you has registered ${args[0]} event`) + } else { + console.warn("on:please check first param!") + } + } else { + console.warn("on:please check param!") + } + }, + off: function(...args) { + console.warn("Window.off interface mocked in the Previewer. How this interface works on the Previewer may be" + + " different from that on a real device.") + const len = args.length; + if (typeof args[len - 1] === 'function') { + if (args[0] === 'keyboardHeightChange'|| args[0] === 'systemAvoidAreaChange' + || args[0] === 'windowSizeChange'|| args[0] === 'touchOutside'|| args[0] === 'avoidAreaChange' + ){ + console.warn(`you has registered ${args[0]} event`) + } else { + console.warn("off:please check first param!") + } + } else { + console.warn("off:please check param!") + } + }, + setColorSpace: function(...args) { + console.warn("Window.setColorSpace interface mocked in the Previewer. How this interface works on the Previewer" + + " may be different from that on a 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() + }) + } + }, + getColorSpace: function(...args) { + console.warn("Window.getColorSpace interface mocked in the Previewer. How this interface works on the Previewer" + + " may be different 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) + }) + } + }, + isSupportWideGamut: function(...args) { + console.warn("Window.isSupportWideGamut interface mocked in the Previewer. How this interface works on the" + + " Previewer may be different from that on a real device.") + const len = args.length + if (typeof args[len - 1] === 'function') { + args[len - 1].call(this, paramMock.businessErrorMock, paramMock.paramBooleanMock) + } else { + return new Promise((resolve) => { + resolve(paramMock.paramBooleanMock) + }) + } + }, +} + +export function mockWindow() { + + const window = { + getTopWindow: function(...args) { + console.warn( + "Window.getTopWindow interface mocked in the Previewer. How this interface works on the Previewer" + " may be different from that on a real device.") + const len = args.length + if (typeof args[len - 1] === 'function') { + args[len - 1].call(this, paramMock.businessErrorMock, Window) + } else { + return new Promise((resolve) => { + resolve(Window) + }) + } + }, + create: function(...args) { + console.warn( + "Window.create interface mocked in the Previewer. How this interface works on the" + " Previewer may be different from that on a real device.") + const len = args.length + if (typeof args[len - 1] === 'function') { + args[len - 1].call(this, paramMock.businessErrorMock, Window) + } else { + return new Promise((resolve) => { + resolve(Window) + }) + } + }, + find: function(...args) { + console.warn( + "Window.find interface mocked in the Previewer. How this interface works on the" + " Previewer may be different from that on a real device.") + const len = args.length + if (typeof args[len - 1] === 'function') { + args[len - 1].call(this, paramMock.businessErrorMock, Window) + } else { + return new Promise((resolve) => { + resolve(Window) + }) + } + }, + isFloatingAbilityWindowVisible: function(...args) { + console.warn( + "Window.isFloatingAbilityWindowVisible interface mocked in the Previewer. How this interface works on the Previewer" + " may be different from that on a real device.") + const len = args.length + if (typeof args[len - 1] === 'function') { + args[len - 1].call(this, paramMock.businessErrorMock, paramMock.paramBooleanMock) + } else { + return new Promise((resolve) => { + resolve(paramMock.paramBooleanMock) + }) + } + }, + setSplitBarVisibility: function(...args) { + console.warn( + "Window.setSplitBarVisibility interface mocked in the Previewer. How this interface works on the Previewer" + " may be different from that on a real device.") + const len = args.length + if (typeof args[len - 1] === 'function') { + args[len - 1].call(this, paramMock.businessErrorMock) + } else { + return new Promise((resolve) => { + resolve() + }) + } + }, + minimizeAll: function(...args) { + console.warn( + "Window.minimizeAll interface mocked in the Previewer. How this interface works on the Previewer" + " may be different from that on a real device.") + const len = args.length + if (typeof args[len - 1] === 'function') { + args[len - 1].call(this, paramMock.businessErrorMock) + } else { + return new Promise((resolve) => { + resolve() + }) + } + }, + toggleShownStateForAllAppWindows: function(...args) { + console.warn( + "Window.toggleShownStateForAllAppWindows interface mocked in the Previewer. How this interface works on the Previewer" + " may be different from that on a real device.") + const len = args.length + if (typeof args[len - 1] === 'function') { + args[len - 1].call(this, paramMock.businessErrorMock) + } else { + return new Promise((resolve) => { + resolve() + }) + } + }, + setWindowLayoutMode: function(...args) { + console.warn( + "Window.setWindowLayoutMode interface mocked in the Previewer. How this interface works on the Previewer" + " may be different from that on a real device.") + const len = args.length + if (typeof args[len - 1] === 'function') { + args[len - 1].call(this, paramMock.businessErrorMock) + } else { + return new Promise((resolve) => { + resolve() + }) + } + }, + on: function(...args) { + console.warn( + "Window.on interface mocked in the Previewer. How this interface works on the Previewer" + " may be different from that on a real device.") + const len = args.length + if (typeof args[len - 1] === 'function') { + if (args[0] === 'systemBarTintChange') { + console.warn(`you has registered ${args[0]} event`) + } else { + console.warn("on:please check first param!") + } + } else { + console.warn("on:please check param!") + } + }, + off: function(...args) { + console.warn( + "Window.off interface mocked in the Previewer. How this interface works on the Previewer" + " may be different from that on a real device.") + const len = args.length + if (typeof args[len - 1] === 'function') { + if (args[0] === 'systemBarTintChange') { + console.warn(`you has registered ${args[0]} event`) + } else { + console.warn("off:please check first param!") + } + } else { + console.warn("off:please check param!") + } + }, + WindowType: WindowType, + AvoidAreaType: AvoidAreaType, + WindowMode: WindowMode, + WindowLayoutMode: WindowLayoutMode, + SystemBarProperties: SystemBarProperties, + SystemBarRegionTint: SystemBarRegionTint, + SystemBarTintState: SystemBarTintState, + Rect: Rect, + AvoidArea: AvoidArea, + Size: Size, + WindowProperties: WindowProperties, + ColorSpace: ColorSpace, + WindowStageEventType: WindowStageEventType, + WindowStage: WindowStage + } + return window +} From b9bddd7e228cc83f4f852ce0557f08ffc67c92ba Mon Sep 17 00:00:00 2001 From: houdisheng Date: Tue, 12 Jul 2022 10:51:12 +0800 Subject: [PATCH 057/109] =?UTF-8?q?=E4=BF=AE=E6=94=B9mock?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: houdisheng --- .../systemplugin/napi/ohos_bundleState.js | 44 ++++++++++++------- 1 file changed, 27 insertions(+), 17 deletions(-) diff --git a/runtime/main/extend/systemplugin/napi/ohos_bundleState.js b/runtime/main/extend/systemplugin/napi/ohos_bundleState.js index 92d909f3..a333f1e7 100644 --- a/runtime/main/extend/systemplugin/napi/ohos_bundleState.js +++ b/runtime/main/extend/systemplugin/napi/ohos_bundleState.js @@ -16,7 +16,7 @@ import { paramMock } from "../utils" export function mockBundleState() { - const BundleStateInfo = [{ + const BundleStateInfo = { abilityInFgTotalTime: '[PC preview] unknown abilityInFgTotalTime', abilityPrevAccessTime: '[PC preview] unknown abilityPrevAccessTime', abilityPrevSeenTime: '[PC preview] unknown abilityPrevSeenTime', @@ -32,20 +32,23 @@ export function mockBundleState() { console.warn("bundleState.merge interface mocked in the Previewer. How this interface works on the" + " Previewer may be different from that on a real device."); }, - }] - const BundleActiveState = [{ + } + const BundleStateInfoArray = [BundleStateInfo] + const BundleActiveState = { appUsagePriorityGroup: '[PC preview] unknown appUsagePriorityGroup', bundleName: '[PC preview] unknown bundleName', indexOfLink: '[PC preview] unknown indexOfLink', nameOfClass: '[PC preview] unknown nameOfClass', stateOccurredTime: '[PC preview] unknown stateOccurredTime', stateType: '[PC preview] unknown stateType', - }] - const BundleActiveEventState = [{ + } + const BundleActiveStateArray = [BundleActiveState] + const BundleActiveEventState = { name: '[PC preview] unknown name', eventId: '[PC preview] unknown eventId', count: '[PC preview] unknown count', - }] + } + const BundleActiveEventStateArray = [BundleActiveEventState] const BundleActiveInfoResponse = { "key": BundleStateInfo } @@ -56,6 +59,13 @@ export function mockBundleState() { changeReason : '[PC preview] unknown changeReason', bundleName : '[PC preview] unknown bundleName', } + const BundleActiveFormInfo = { + count : '[PC preview] unknown count', + formLastUsedTime : '[PC preview] unknown formLastUsedTime', + formId : '[PC preview] unknown formId', + formDimension : '[PC preview] unknown formDimension', + formName : '[PC preview] unknown formName', + } const BundleActiveModuleInfo = { deviceId : '[PC preview] unknown deviceId', bundleName : '[PC preview] unknown bundleName', @@ -69,7 +79,7 @@ export function mockBundleState() { abilityIconId : '[PC preview] unknown abilityIconId', launchedCount : '[PC preview] unknown launchedCount', lastModuleUsedTime : '[PC preview] unknown lastModuleUsedTime', - formRecords : '[PC preview] unknown formRecords', + formRecords : BundleActiveFormInfo, } const IntervalType = { BY_OPTIMIZED: 0, @@ -128,10 +138,10 @@ export function mockBundleState() { " Previewer may be different from that on a real device."); const len = args.length; if (typeof args[len - 1] === 'function') { - args[len - 1].call(this, paramMock.businessErrorMock, BundleStateInfo); + args[len - 1].call(this, paramMock.businessErrorMock, BundleStateInfoArray); } else { return new Promise((resolve) => { - resolve(BundleStateInfo) + resolve(BundleStateInfoArray) }); } }, @@ -140,10 +150,10 @@ export function mockBundleState() { " Previewer may be different from that on a real device."); const len = args.length; if (typeof args[len - 1] === 'function') { - args[len - 1].call(this, paramMock.businessErrorMock, BundleActiveState); + args[len - 1].call(this, paramMock.businessErrorMock, BundleActiveStateArray); } else { return new Promise((resolve) => { - resolve(BundleActiveState) + resolve(BundleActiveStateArray) }); } }, @@ -152,10 +162,10 @@ export function mockBundleState() { " Previewer may be different from that on a real device."); const len = args.length; if (typeof args[len - 1] === 'function') { - args[len - 1].call(this, paramMock.businessErrorMock, BundleActiveState); + args[len - 1].call(this, paramMock.businessErrorMock, BundleActiveStateArray); } else { return new Promise((resolve) => { - resolve(BundleActiveState) + resolve(BundleActiveStateArray) }); } }, @@ -164,10 +174,10 @@ export function mockBundleState() { " Previewer may be different from that on a real device."); const len = args.length; if (typeof args[len - 1] === 'function') { - args[len - 1].call(this, paramMock.businessErrorMock, BundleActiveEventState); + args[len - 1].call(this, paramMock.businessErrorMock, BundleActiveEventStateArray); } else { return new Promise((resolve) => { - resolve(BundleActiveEventState) + resolve(BundleActiveEventStateArray) }); } }, @@ -176,10 +186,10 @@ export function mockBundleState() { " Previewer may be different from that on a real device."); const len = args.length; if (typeof args[len - 1] === 'function') { - args[len - 1].call(this, paramMock.businessErrorMock, BundleActiveEventState); + args[len - 1].call(this, paramMock.businessErrorMock, BundleActiveEventStateArray); } else { return new Promise((resolve) => { - resolve(BundleActiveEventState) + resolve(BundleActiveEventStateArray) }); } }, From 3cfd5fedb3c98d7fa6848d63381ebbacd660bf2c Mon Sep 17 00:00:00 2001 From: houdisheng Date: Tue, 12 Jul 2022 11:26:30 +0800 Subject: [PATCH 058/109] =?UTF-8?q?=E4=BF=AE=E6=94=B9mock?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: houdisheng --- runtime/main/extend/systemplugin/napi/ohos_bundleState.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/runtime/main/extend/systemplugin/napi/ohos_bundleState.js b/runtime/main/extend/systemplugin/napi/ohos_bundleState.js index a333f1e7..f7bb772d 100644 --- a/runtime/main/extend/systemplugin/napi/ohos_bundleState.js +++ b/runtime/main/extend/systemplugin/napi/ohos_bundleState.js @@ -79,7 +79,7 @@ export function mockBundleState() { abilityIconId : '[PC preview] unknown abilityIconId', launchedCount : '[PC preview] unknown launchedCount', lastModuleUsedTime : '[PC preview] unknown lastModuleUsedTime', - formRecords : BundleActiveFormInfo, + formRecords : [BundleActiveFormInfo], } const IntervalType = { BY_OPTIMIZED: 0, From 8b34c90e7226d9993ddeb9cbaf06e7b0f151052f Mon Sep 17 00:00:00 2001 From: huangjie Date: Tue, 12 Jul 2022 10:33:31 +0800 Subject: [PATCH 059/109] =?UTF-8?q?=E5=85=A8=E7=90=83=E5=8C=96=E8=A1=A5?= =?UTF-8?q?=E5=85=85API=20mock?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: huangjie --- .../systemplugin/napi/global/resource.js | 20 +++++++++++++++++++ .../systemplugin/napi/ohos_resourceManager.js | 3 ++- 2 files changed, 22 insertions(+), 1 deletion(-) create mode 100644 runtime/main/extend/systemplugin/napi/global/resource.js diff --git a/runtime/main/extend/systemplugin/napi/global/resource.js b/runtime/main/extend/systemplugin/napi/global/resource.js new file mode 100644 index 00000000..8d2d8906 --- /dev/null +++ b/runtime/main/extend/systemplugin/napi/global/resource.js @@ -0,0 +1,20 @@ +/* + * Copyright (c) 2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +export const Resource = { + bundleName : '[PC Preview] unknow string', + moduleName : '[PC Preview] unknow string', + id : '[PC Preview] unknow number' +} \ No newline at end of file diff --git a/runtime/main/extend/systemplugin/napi/ohos_resourceManager.js b/runtime/main/extend/systemplugin/napi/ohos_resourceManager.js index 5d5b5283..d6bb618e 100644 --- a/runtime/main/extend/systemplugin/napi/ohos_resourceManager.js +++ b/runtime/main/extend/systemplugin/napi/ohos_resourceManager.js @@ -36,7 +36,8 @@ export function mockResourceManager() { SCREEN_MDPI : 160, SCREEN_LDPI : 240, SCREEN_XLDPI : 320, - SCREEN_XXLDPI : 480 + SCREEN_XXLDPI : 480, + SCREEN_XXXLDPI : 640 } const DeviceType = { From e07758c96e07ed16c863e4b6e1cfc5a2f924ab54 Mon Sep 17 00:00:00 2001 From: yinyong Date: Tue, 12 Jul 2022 14:39:38 +0800 Subject: [PATCH 060/109] =?UTF-8?q?=E6=96=B0=E5=A2=9E=E5=8A=A0=20multimedi?= =?UTF-8?q?a=5Favsession=5Fstandard=20=E6=A8=A1=E5=9D=97MOCK?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: yinyong --- .../main/extend/systemplugin/napi/index.js | 3 + .../napi/ohos_multimedia_av_session.js | 435 ++++++++++++++++++ 2 files changed, 438 insertions(+) create mode 100644 runtime/main/extend/systemplugin/napi/ohos_multimedia_av_session.js diff --git a/runtime/main/extend/systemplugin/napi/index.js b/runtime/main/extend/systemplugin/napi/index.js index 6f709cac..ec9c739f 100644 --- a/runtime/main/extend/systemplugin/napi/index.js +++ b/runtime/main/extend/systemplugin/napi/index.js @@ -100,6 +100,7 @@ import { mockStack } from './ohos_util_Stack' import { mockTreeMap } from './ohos_util_TreeMap' import { mockTreeSet } from './ohos_util_TreeSet' import { mockVector } from './ohos_util_Vector' +import { mockMultimediaAVSession } from './ohos_multimedia_av_session' import { mockMultimediaCamera } from './ohos_multimedia_camera' import { mockMultimediaAudio } from './ohos_multimedia_audio' import { mockMultimediaImage } from './ohos_multimedia_image' @@ -452,6 +453,8 @@ export function mockRequireNapiFun() { return mockMultimediaMedia(); case "multimedia.image": return mockMultimediaImage(); + case "multimedia.avsession": + return mockMultimediaAVSession(); case "multimedia.camera": return mockMultimediaCamera(); case "multimedia.audio": diff --git a/runtime/main/extend/systemplugin/napi/ohos_multimedia_av_session.js b/runtime/main/extend/systemplugin/napi/ohos_multimedia_av_session.js new file mode 100644 index 00000000..89d89f11 --- /dev/null +++ b/runtime/main/extend/systemplugin/napi/ohos_multimedia_av_session.js @@ -0,0 +1,435 @@ +/* + * Copyright (c) 2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { paramMock } from "../utils" + +export function mockMultimediaAVSession() { + const AVMetadataMock = { + assetId: "[PC Preview] unknow assetId", + title: "[PC Preview] unknow title", + artist: "[PC Preview] unknow artist", + author: "[PC Preview] unknow author", + album: "[PC Preview] unknow album", + writer: "[PC Preview] unknow writer", + composer: "[PC Preview] unknow composer", + duration: "[PC Preview] unknow duration", + mediaImage: "[PC Preview] unknow mediaImage", + publishDate: "[PC Preview] unknow publishDate", + subtitle: "[PC Preview] unknow subtitle", + description: "[PC Preview] unknow description", + lyric: "[PC Preview] unknow lyric", + previousAssetId: "[PC Preview] unknow previousAssetId", + nextAssetId: "[PC Preview] unknow nextAssetId" + } + + const AVPlaybackStateMock = { + state: "[PC Preview] unknow state", + speed: "[PC Preview] unknow speed", + position: PlaybackPositionMock, + bufferedTime: "[PC Preview] unknow bufferedTime", + loopMode: "[PC Preview] unknow loopMode", + isFavorite: "[PC Preview] unknow isFavorite" + } + + const PlaybackPositionMock = { + elapsedTime: "[PC Preview] unknow elapsedTime", + updateTime: "[PC Preview] unknow updateTime" + } + + const OutputDeviceInfoMock = { + isRemote: "[PC Preview] unknow isRemote", + deviceId: [paramMock.paramStringMock], + deviceName: [paramMock.paramStringMock] + } + + const AVSessionDescriptorMock = { + sessionId: "[PC Preview] unknow sessionId", + type: "[PC Preview] unknow type", + sessionTag: "[PC Preview] unknow sessionTag", + elementName: "[PC Preview] unknow elementName", + isActive: "[PC Preview] unknow isActive", + isTopSession: "[PC Preview] unknow isTopSession", + outputDevice: "[PC Preview] unknow outputDevice" + } + + const AVSessionMock = { + sessionId: "[PC Preview] unknow sessionId", + setAVMetadata: function (...args) { + console.warn("AVSession.setAVMetadata interface mocked in the Previewer. How this interface works on the Previewer" + + " may be different from that on a real device.") + const len = args.length + if (typeof args[len - 1] === 'function') { + args[len - 1].call(this, paramMock.businessErrorMock); + } else { + return new Promise((resolve, reject) => { + resolve(); + }) + } + }, + setAVPlaybackState: function (...args) { + console.warn("AVSession.setAVPlaybackState interface mocked in the Previewer. How this interface works on the Previewer" + + " may be different from that on a real device.") + const len = args.length + if (typeof args[len - 1] === 'function') { + args[len - 1].call(this, paramMock.businessErrorMock); + } else { + return new Promise((resolve, reject) => { + resolve(); + }) + } + }, + setLaunchAbility: function (...args) { + console.warn("AVSession.setLaunchAbility interface mocked in the Previewer. How this interface works on the Previewer" + + " may be different from that on a real device.") + const len = args.length + if (typeof args[len - 1] === 'function') { + args[len - 1].call(this, paramMock.businessErrorMock); + } else { + return new Promise((resolve, reject) => { + resolve(); + }) + } + }, + setAudioStreamId: function (...args) { + console.warn("AVSession.setAudioStreamId interface mocked in the Previewer. How this interface works on the Previewer" + + " may be different from that on a real device.") + const len = args.length + if (typeof args[len - 1] === 'function') { + args[len - 1].call(this, paramMock.businessErrorMock); + } else { + return new Promise((resolve, reject) => { + resolve(); + }) + } + }, + getController: function (...args) { + console.warn("AVSession.getController interface mocked in the Previewer. How this interface works on the Previewer" + + " may be different from that on a real device.") + const len = args.length + if (typeof args[len - 1] === 'function') { + args[len - 1].call(this, paramMock.businessErrorMock, AVSessionControllerMock); + } else { + return new Promise((resolve, reject) => { + resolve(AVSessionControllerMock); + }) + } + }, + getOutputDevice: function (...args) { + console.warn("AVSession.getOutputDevice interface mocked in the Previewer. How this interface works on the Previewer" + + " may be different from that on a real device.") + const len = args.length + if (typeof args[len - 1] === 'function') { + args[len - 1].call(this, paramMock.businessErrorMock, OutputDeviceInfoMock); + } else { + return new Promise((resolve, reject) => { + resolve(OutputDeviceInfoMock); + }) + } + }, + on: function (...args) { + console.warn("AVSession.on interface mocked in the Previewer. How this interface works on the Previewer" + + " may be different from that on a real device.") + const len = args.length + if (args[0] == 'play' || args[0] == 'pause' ||args[0] == 'stop' ||args[0] == 'playNext' + ||args[0] == 'playPrevious' ||args[0] == 'fastForward' ||args[0] == 'rewind') { + args[len - 1].call(this); + } else if(args[0] == 'seek' || args[0] == 'setSpeed') { + args[len - 1].call(this, paramMock.paramNumberMock); + } else if(args[0] == 'setLoopMode') { + var loopModeMock = "[PC Preview] unknow LoopMode"; + args[len - 1].call(this, loopModeMock); + } else if(args[0] == 'toggleFavorite') { + args[len - 1].call(this, paramMock.paramStringMock); + } else if(args[0] == 'handleKeyEvent') { + args[len - 1].call(this, paramMock.paramObjectMock); + } else if(args[0] == 'outputDeviceChanged') { + args[len - 1].call(this, OutputDeviceInfoMock); + } + }, + off: function (...args) { + console.warn("AVSession.off interface mocked in the Previewer. How this interface works on the Previewer" + + " may be different from that on a real device.") + }, + activate: function (...args) { + console.warn("AVSession.activate interface mocked in the Previewer. How this interface works on the Previewer" + + " may be different from that on a real device.") + const len = args.length + if (typeof args[len - 1] === 'function') { + args[len - 1].call(this, paramMock.businessErrorMock); + } else { + return new Promise((resolve, reject) => { + resolve(); + }) + } + }, + deactivate: function (...args) { + console.warn("AVSession.deactivate interface mocked in the Previewer. How this interface works on the Previewer" + + " may be different from that on a real device.") + const len = args.length + if (typeof args[len - 1] === 'function') { + args[len - 1].call(this, paramMock.businessErrorMock); + } else { + return new Promise((resolve, reject) => { + resolve(); + }) + } + }, + destroy: function (...args) { + console.warn("AVSession.destroy interface mocked in the Previewer. How this interface works on the Previewer" + + " may be different from that on a real device.") + const len = args.length + if (typeof args[len - 1] === 'function') { + args[len - 1].call(this, paramMock.businessErrorMock); + } else { + return new Promise((resolve, reject) => { + resolve(); + }) + } + } + } + + const AVSessionControllerMock = { + sessionId: "[PC Preview] unknow sessionId", + getAVPlaybackState: function (...args) { + console.warn("AVSessionController.getAVPlaybackState interface mocked in the Previewer. How this interface works on the Previewer" + + " may be different from that on a real device.") + const len = args.length + if (typeof args[len - 1] === 'function') { + args[len - 1].call(this, paramMock.businessErrorMock, AVPlaybackStateMock); + } else { + return new Promise((resolve, reject) => { + resolve(AVPlaybackStateMock); + }) + } + }, + getAVMetadata: function (...args) { + console.warn("AVSessionController.getAVMetadata interface mocked in the Previewer. How this interface works on the Previewer" + + " may be different from that on a real device.") + const len = args.length + if (typeof args[len - 1] === 'function') { + args[len - 1].call(this, paramMock.businessErrorMock, AVMetadataMock); + } else { + return new Promise((resolve, reject) => { + resolve(AVMetadataMock); + }) + } + }, + getOutputDevice: function (...args) { + console.warn("AVSessionController.getOutputDevice interface mocked in the Previewer. How this interface works on the Previewer" + + " may be different from that on a real device.") + const len = args.length + if (typeof args[len - 1] === 'function') { + args[len - 1].call(this, paramMock.businessErrorMock, OutputDeviceInfoMock); + } else { + return new Promise((resolve, reject) => { + resolve(OutputDeviceInfoMock); + }) + } + }, + sendAVKeyEvent: function (...args) { + console.warn("AVSessionController.sendAVKeyEvent interface mocked in the Previewer. How this interface works on the Previewer" + + " may be different from that on a real device.") + const len = args.length + if (typeof args[len - 1] === 'function') { + args[len - 1].call(this, paramMock.businessErrorMock); + } else { + return new Promise((resolve, reject) => { + resolve(); + }) + } + }, + getLaunchAbility: function (...args) { + console.warn("AVSessionController.getLaunchAbility interface mocked in the Previewer. How this interface works on the Previewer" + + " may be different from that on a real device.") + const len = args.length + if (typeof args[len - 1] === 'function') { + args[len - 1].call(this, paramMock.businessErrorMock, paramMock.paramObjectMock); + } else { + return new Promise((resolve, reject) => { + resolve(paramMock.paramObjectMock); + }) + } + }, + getRealPlaybackPositionSync: function (...args) { + console.warn("AVSessionController.getRealPlaybackPositionSync interface mocked in the Previewer. How this interface works on the Previewer" + + " may be different from that on a real device.") + return paramMock.paramNumberMock; + }, + isActive: function (...args) { + console.warn("AVSessionController.isActive interface mocked in the Previewer. How this interface works on the Previewer" + + " may be different from that on a real device.") + const len = args.length + if (typeof args[len - 1] === 'function') { + args[len - 1].call(this, paramMock.businessErrorMock, paramMock.paramBooleanMock); + } else { + return new Promise((resolve, reject) => { + resolve(paramMock.paramBooleanMock); + }) + } + }, + destroy: function (...args) { + console.warn("AVSessionController.destroy interface mocked in the Previewer. How this interface works on the Previewer" + + " may be different from that on a real device.") + const len = args.length + if (typeof args[len - 1] === 'function') { + args[len - 1].call(this, paramMock.businessErrorMock); + } else { + return new Promise((resolve, reject) => { + resolve(); + }) + } + }, + getValidCommands: function (...args) { + console.warn("AVSessionController.getValidCommands interface mocked in the Previewer. How this interface works on the Previewer" + + " may be different from that on a real device.") + const len = args.length + let AVControlCommandType = ['play','pause','stop', 'playNext', 'playPrevious', 'fastForward', 'rewind', 'seek', 'setSpeed', 'setLoopMode', 'toggleFavorite']; + if (typeof args[len - 1] === 'function') { + args[len - 1].call(this, paramMock.businessErrorMock, AVControlCommandType); + } else { + return new Promise((resolve, reject) => { + resolve(AVControlCommandType); + }) + } + }, + sendControlCommand: function (...args) { + console.warn("AVSessionController.sendControlCommand interface mocked in the Previewer. How this interface works on the Previewer" + + " may be different from that on a real device.") + const len = args.length + if (typeof args[len - 1] === 'function') { + args[len - 1].call(this, paramMock.businessErrorMock); + } else { + return new Promise((resolve, reject) => { + resolve(); + }) + } + }, + on: function (...args) { + console.warn("AVSessionController.on interface mocked in the Previewer. How this interface works on the Previewer" + + " may be different from that on a real device.") + const len = args.length + if (args[0] == 'metadataChanged') { + args[len-1].call(this, AVMetadataMock); + } else if (args[0] == 'playbackStateChanged') { + args[len-1].call(this, AVPlaybackStateMock); + } else if (args[0] == 'sessionDestroyed') { + args[len-1].call(this); + } else if (args[0] == 'activeStateChanged') { + args[len-1].call(this, paramMock.paramBooleanMock); + } else if (args[0] == 'validCommandChanged') { + let AVControlCommandType = ['play', 'pause', 'stop', 'playNext', 'playPrevious', 'fastForward', 'rewind', 'seek', 'setSpeed', 'setLoopMode', 'toggleFavorite']; + args[len-1].call(this, AVControlCommandType); + } else if (args[0] == 'outputDeviceChanged') { + args[len-1].call(this, OutputDeviceInfoMock); + } + }, + off: function (...args) { + console.warn("AVSessionController.off interface mocked in the Previewer. How this interface works on the Previewer" + + " may be different from that on a real device.") + } + } + + const avsession = { + createAVSession: function (...args) { + console.warn("AVSession.createAVSession interface mocked in the Previewer. How this interface works on the Previewer" + + " may be different from that on a real device.") + const len = args.length + if (typeof args[len - 1] === 'function') { + args[len - 1].call(this, paramMock.businessErrorMock, AVSessionMock); + } else { + return new Promise((resolve, reject) => { + resolve(AVSessionMock); + }) + } + + }, + getAllSessionDescriptors: function (...args) { + console.warn("AVSession.getAllSessionDescriptors interface mocked in the Previewer. How this interface works on the Previewer" + + " may be different from that on a real device.") + const len = args.length + var desArr = Array(AVSessionDescriptorMock); + if (typeof args[len - 1] === 'function') { + args[len - 1].call(this, paramMock.businessErrorMock, desArr); + } else { + return new Promise((resolve, reject) => { + resolve(desArr); + }) + } + }, + createController: function (...args) { + console.warn("AVSession.createController interface mocked in the Previewer. How this interface works on the Previewer" + + " may be different from that on a real device.") + const len = args.length + if (typeof args[len - 1] === 'function') { + args[len - 1].call(this, paramMock.businessErrorMock, AVSessionControllerMock); + } else { + return new Promise((resolve, reject) => { + resolve(AVSessionControllerMock); + }) + } + }, + castAudio: function (...args) { + console.warn("AVSession.castAudio interface mocked in the Previewer. How this interface works on the Previewer" + + " may be different from that on a real device.") + const len = args.length + if (typeof args[len - 1] === 'function') { + args[len - 1].call(this, paramMock.businessErrorMock); + } else { + return new Promise((resolve, reject) => { + resolve(); + }) + } + }, + on: function (...args) { + console.warn("AVSession.on interface mocked in the Previewer. How this interface works on the Previewer" + + " may be different from that on a real device.") + const len = args.length + if (args[0] == 'sessionCreated' || args[0] == 'sessionDestroyed' || args[0] == 'topSessionChanged') { + args[len - 1].call(this, AVSessionDescriptorMock); + } else if (args[0] == 'sessionServiceDied') { + args[len - 1].call(this); + } + }, + off: function (...args) { + console.warn("AVSession.off interface mocked in the Previewer. How this interface works on the Previewer" + + " may be different from that on a real device.") + }, + sendSystemAVKeyEvent: function (...args) { + console.warn("AVSession.sendSystemAVKeyEvent interface mocked in the Previewer. How this interface works on the Previewer" + + " may be different from that on a real device.") + const len = args.length + if (typeof args[len - 1] === 'function') { + args[len - 1].call(this, paramMock.businessErrorMock); + } else { + return new Promise((resolve, reject) => { + resolve(); + }) + } + }, + sendSystemControlCommand: function (...args) { + console.warn("AVSession.sendSystemControlCommand interface mocked in the Previewer. How this interface works on the Previewer" + + " may be different from that on a real device.") + const len = args.length + if (typeof args[len - 1] === 'function') { + args[len - 1].call(this, paramMock.businessErrorMock); + } else { + return new Promise((resolve, reject) => { + resolve(); + }) + } + } + } + return avsession +} From f4bc32ed6232da4705e1717f4cc8c57cc32f3652 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=80=BF=E6=96=87=E5=B9=BF?= Date: Fri, 8 Jul 2022 16:24:47 +0800 Subject: [PATCH 061/109] =?UTF-8?q?=E5=8C=85=E7=AE=A1=E7=90=86api-mock?= =?UTF-8?q?=E8=A1=A5=E9=BD=90?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 耿文广 --- .../systemplugin/napi/bundle/abilityInfo.js | 18 +- .../napi/bundle/applicationInfo.js | 21 +- .../systemplugin/napi/bundle/bundleInfo.js | 163 ++++++------- .../napi/bundle/bundleInstaller.js | 67 ++++++ .../napi/bundle/bundleStatusCallback.js | 32 +++ .../systemplugin/napi/bundle/customizeData.js | 20 ++ .../napi/bundle/defaultAppManager.js | 2 +- .../systemplugin/napi/bundle/dispatchInfo.js | 19 ++ .../systemplugin/napi/bundle/elementName.js | 23 ++ .../napi/bundle/extensionAbilityInfo.js | 98 ++++++++ .../systemplugin/napi/bundle/hapModuleInfo.js | 101 ++++++++ .../napi/bundle/launcherAbilityInfo.js | 8 +- .../systemplugin/napi/bundle/metadata.js | 20 ++ .../systemplugin/napi/bundle/moduleInfo.js | 19 ++ .../systemplugin/napi/bundle/packInfo.js | 157 +++++++++++++ .../systemplugin/napi/bundle/permissionDef.js | 21 ++ .../napi/bundle/remoteAbilityInfo.js | 22 ++ .../systemplugin/napi/bundle/shortcutInfo.js | 41 ++++ .../extend/systemplugin/napi/ohos_bundle.js | 220 +++++++++++------- .../napi/ohos_bundle_defaultAppManager.js | 6 +- .../napi/ohos_bundle_innerBundleManager.js | 16 +- 21 files changed, 893 insertions(+), 201 deletions(-) create mode 100755 runtime/main/extend/systemplugin/napi/bundle/bundleInstaller.js create mode 100755 runtime/main/extend/systemplugin/napi/bundle/bundleStatusCallback.js create mode 100755 runtime/main/extend/systemplugin/napi/bundle/customizeData.js create mode 100755 runtime/main/extend/systemplugin/napi/bundle/dispatchInfo.js create mode 100755 runtime/main/extend/systemplugin/napi/bundle/elementName.js create mode 100755 runtime/main/extend/systemplugin/napi/bundle/extensionAbilityInfo.js create mode 100755 runtime/main/extend/systemplugin/napi/bundle/hapModuleInfo.js create mode 100755 runtime/main/extend/systemplugin/napi/bundle/metadata.js create mode 100755 runtime/main/extend/systemplugin/napi/bundle/moduleInfo.js create mode 100755 runtime/main/extend/systemplugin/napi/bundle/packInfo.js create mode 100755 runtime/main/extend/systemplugin/napi/bundle/permissionDef.js create mode 100755 runtime/main/extend/systemplugin/napi/bundle/remoteAbilityInfo.js create mode 100755 runtime/main/extend/systemplugin/napi/bundle/shortcutInfo.js diff --git a/runtime/main/extend/systemplugin/napi/bundle/abilityInfo.js b/runtime/main/extend/systemplugin/napi/bundle/abilityInfo.js index ee690e17..9bc0920f 100644 --- a/runtime/main/extend/systemplugin/napi/bundle/abilityInfo.js +++ b/runtime/main/extend/systemplugin/napi/bundle/abilityInfo.js @@ -13,7 +13,9 @@ * limitations under the License. */ -export const AbilityInfoMock = { +import { paramMock } from "../../utils" + +export const AbilityInfo = { name: "[PC preview] unknown name", bundleName: "[PC preview] unknown bundleName", moduleName: "[PC preview] unknown moduleName", @@ -51,9 +53,9 @@ export const AbilityInfoMock = { SINGLETON: 0, STANDARD: 1, }, - permissions: ['[PC Preview] unknow permissions'], - deviceTypes: ['[PC Preview] unknow deviceTypes'], - deviceCapabilities: ['[PC Preview] unknow deviceCapabilities'], + permissions: [paramMock.paramStringMock], + deviceTypes: [paramMock.paramStringMock], + deviceCapabilities: [paramMock.paramNumberMock], readPermission: '[PC Preview] unknow readPermission', writePermission: '[PC Preview] unknow writePermission', appId: '[PC Preview] unknow appId', @@ -77,14 +79,14 @@ export const AbilityInfoMock = { iconId: "[PC preview] unknown iconId", process: "[PC preview] unknown process", sourceDir: "[PC preview] unknown sourceDir", - moduleSourceDirs: ["[PC preview] unknown moduleSourceDirs"], - permissions: ["[PC preview] unknown permissions"], + moduleSourceDirs: [paramMock.paramStringMock], + permissions: [paramMock.paramStringMock], moduleInfos: [{ moduleName: "[PC preview] unknown moduleName", moduleSourceDir: "[PC preview] unknown moduleSourceDir", }], - entryDir: ["[PC preview] unknown entryDir"], - codePath: ["[PC preview] unknown codePath"], + entryDir: "[PC preview] unknown entryDir", + codePath: "[PC preview] unknown codePath", metaData: [{ name: "[PC preview] unknown name", value: "[PC preview] unknown value", diff --git a/runtime/main/extend/systemplugin/napi/bundle/applicationInfo.js b/runtime/main/extend/systemplugin/napi/bundle/applicationInfo.js index cd6b17a1..953227c3 100644 --- a/runtime/main/extend/systemplugin/napi/bundle/applicationInfo.js +++ b/runtime/main/extend/systemplugin/napi/bundle/applicationInfo.js @@ -13,7 +13,9 @@ * limitations under the License. */ -export const ApplicationInfoMock = { +import { paramMock } from "../../utils" + +export const ApplicationInfo = { name: "[PC preview] unknown name", description: "[PC preview] unknown description", descriptionId: "[PC preview] unknown descriptionId", @@ -25,8 +27,8 @@ export const ApplicationInfoMock = { iconId: "[PC preview] unknown iconId", process: "[PC preview] unknown process", supportedModes: "[PC preview] unknown supportedModes", - moduleSourceDirs: ["[PC preview] unknown moduleSourceDirs"], - permissions: ["[PC preview] unknown permissions"], + moduleSourceDirs: [paramMock.paramNumberMock], + permissions: [paramMock.paramNumberMock], moduleInfos: [ { moduleName: "[PC preview] unknown moduleName", @@ -69,7 +71,7 @@ export const ApplicationInfoMock = { appProvisionType: "[PC preview] unknown appProvisionType", } -export const WantMock = { +export const Want = { deviceId: "[PC Preview] unknow deviceId", bundleName: "[PC Preview] unknow bundleName", abilityName: "[PC Preview] unknow abilityName", @@ -77,12 +79,12 @@ export const WantMock = { type: "[PC Preview] unknow type", flag: "[PC Preview] unknow flag", action: "[PC Preview] unknow action", - parameters: ["[PC Preview] unknow parameters"], - entities: ["[PC Preview] unknow entities"], + parameters: [paramMock.paramStringMock], + entities: [paramMock.paramStringMock], moduleName: "[PC Preview] unknow moduleName", } -export const ShortcutInfoMock = { +export const ShortcutInfo = { id: "[PC preview] unknown id", bundleName: "[PC preview] unknown bundleName", hostAbility: "[PC preview] unknown hostAbility", @@ -96,14 +98,15 @@ export const ShortcutInfoMock = { targetBundle: "[PC preview] unknown targetBundle", targetModule: "[PC preview] unknown targetModule", targetClass: "[PC preview] unknown targetClass", - }], + } + ], isStatic: "[PC preview] unknown isStatic", isHomeShortcut: "[PC preview] unknown isHomeShortcut", isEnabled: "[PC preview] unknown isEnabled", moduleName: "[PC preview] unknown moduleName", } -export const ModuleUsageRecordMock = { +export const ModuleUsageRecord = { bundleName: "[PC preview] unknown bundleName", appLabelId: "[PC preview] unknown appLabelId", name: "[PC preview] unknown name", diff --git a/runtime/main/extend/systemplugin/napi/bundle/bundleInfo.js b/runtime/main/extend/systemplugin/napi/bundle/bundleInfo.js index ab73c42a..97112a5c 100644 --- a/runtime/main/extend/systemplugin/napi/bundle/bundleInfo.js +++ b/runtime/main/extend/systemplugin/napi/bundle/bundleInfo.js @@ -13,7 +13,9 @@ * limitations under the License. */ -export const BundleInfoMock = { +import { paramMock } from "../../utils" + +export const BundleInfo = { name: "[PC preview] unknown name", type: "[PC preview] unknown type", appId: "[PC preview] unknown appId", @@ -34,8 +36,8 @@ export const BundleInfoMock = { iconId: "[PC preview] unknown iconId", process: "[PC preview] unknown process", supportedModes: "[PC preview] unknown supportedModes", - moduleSourceDirs: ["[PC preview] unknown moduleSourceDirs"], - permissions: ["[PC preview] unknown permissions"], + moduleSourceDirs: [paramMock.paramStringMock], + permissions: [paramMock.paramStringMock], sourceDir: "[PC preview] unknown sourceDir", moduleInfos: [{ moduleName: "[PC preview] unknown moduleName", @@ -125,9 +127,9 @@ export const BundleInfoMock = { SINGLETON: 0, STANDARD: 1, }, - permissions: ['[PC Preview] unknow permissions'], - deviceTypes: ['[PC Preview] unknow deviceTypes'], - deviceCapabilities: ['[PC Preview] unknow deviceCapabilities'], + permissions: [paramMock.paramStringMock], + deviceTypes: [paramMock.paramStringMock], + deviceCapabilities: [paramMock.paramStringMock], readPermission: '[PC Preview] unknow readPermission', writePermission: '[PC Preview] unknow writePermission', appId: '[PC Preview] unknow appId', @@ -151,14 +153,14 @@ export const BundleInfoMock = { iconId: "[PC preview] unknown iconId", process: "[PC preview] unknown process", sourceDir: "[PC preview] unknown sourceDir", - moduleSourceDirs: ["[PC preview] unknown moduleSourceDirs"], - permissions: ["[PC preview] unknown permissions"], + moduleSourceDirs: [paramMock.paramStringMock], + permissions: [paramMock.paramStringMock], moduleInfos: [{ moduleName: "[PC preview] unknown moduleName", moduleSourceDir: "[PC preview] unknown moduleSourceDir", }], - entryDir: ["[PC preview] unknown entryDir"], - codePath: ["[PC preview] unknown codePath"], + entryDir: [paramMock.paramStringMock], + codePath: [paramMock.paramStringMock], metaData: [{ name: "[PC preview] unknown name", value: "[PC preview] unknown value", @@ -238,14 +240,14 @@ export const BundleInfoMock = { }, } ], - reqPermissions: ["[PC preview] unknown repermission"], + reqPermissions: [paramMock.paramStringMock], reqPermissionDetails: [ { name: "[PC preview] unknown name", reason: "[PC preview] unknown reason", reasonId: "[PC preview] unknown reasonId", usedScene: { - abilities: ["[PC preview] unknown ability"], + abilities: [paramMock.paramStringMock], when: "[PC preview] unknown when", } } @@ -266,8 +268,8 @@ export const BundleInfoMock = { iconId: "[PC preview] unknown iconId", backgroundImg: "[PC preview] unknown backgroundImg", supportedModes: "[PC preview] unknown supportedModes", - reqCapabilities: ["[PC preview] unknown reqCapabilities"], - deviceTypes: ["[PC preview] unknown deviceTypes"], + reqCapabilities: [paramMock.paramStringMock], + deviceTypes: [paramMock.paramStringMock], abilityInfo: [ { name: "[PC preview] unknown name", @@ -307,9 +309,9 @@ export const BundleInfoMock = { SINGLETON: 0, STANDARD: 1, }, - permissions: ['[PC Preview] unknow permissions'], - deviceTypes: ['[PC Preview] unknow deviceTypes'], - deviceCapabilities: ['[PC Preview] unknow deviceCapabilities'], + permissions: [paramMock.paramNumberMock], + deviceTypes: [paramMock.paramNumberMock], + deviceCapabilities: [paramMock.paramNumberMock], readPermission: '[PC Preview] unknow readPermission', writePermission: '[PC Preview] unknow writePermission', appId: '[PC Preview] unknow appId', @@ -333,14 +335,14 @@ export const BundleInfoMock = { iconId: "[PC preview] unknown iconId", process: "[PC preview] unknown process", sourceDir: "[PC preview] unknown sourceDir", - moduleSourceDirs: ["[PC preview] unknown moduleSourceDirs"], - permissions: ["[PC preview] unknown permissions"], + moduleSourceDirs: [paramMock.paramStringMock], + permissions: [paramMock.paramStringMock], moduleInfos: [{ moduleName: "[PC preview] unknown moduleName", moduleSourceDir: "[PC preview] unknown moduleSourceDir", }], - entryDir: ["[PC preview] unknown entryDir"], - codePath: ["[PC preview] unknown codePath"], + entryDir: [paramMock.paramStringMock], + codePath: [paramMock.paramStringMock], metaData: [{ name: "[PC preview] unknown name", value: "[PC preview] unknown value", @@ -461,50 +463,50 @@ export const BundleInfoMock = { }], hapModuleInfo: [ { - name: "string", - description: "string", - descriptionId: 1, - icon: "string", - label: "string", - labelId: 2, - iconId: 3, - backgroundImg: "string", - supportedModes: 4, - reqCapabilities: ["1", "2"], - deviceTypes: ["1", "2"], + name: "[PC preview] unknown name", + description: "[PC preview] unknown description", + descriptionId: "[PC preview] unknown descriptionId", + icon: "[PC preview] unknown icon", + label: "[PC preview] unknown label", + labelId: "[PC preview] unknown labelId", + iconId: "[PC preview] unknown iconId", + backgroundImg: "[PC preview] unknown backgroundImg", + supportedModes: "[PC preview] unknown supportedModes", + reqCapabilities: [paramMock.paramStringMock], + deviceTypes: [paramMock.paramStringMock], abilityInfo: [ { - bundleName: "string", - name: "string", - label: "string", - description: "string", - icon: "string", - labelId: 1, - descriptionId: 2, - iconId: 3, - moduleName: "string", - process: "string", - targetAbility: "string", - backgroundModes: 4, - isVisible: true, - formEnabled: true, - type: "bundle.AbilityType", - subType: "bundle.AbilitySubType", - orientation: "bundle.DisplayOrientation", - launchMode: "bundle.LaunchMode", - permissions: ["1"], - deviceTypes: ["2"], - deviceCapabilities: ["3"], - readPermission: "string", - writePermission: "string", + bundleName: "[PC preview] unknown bundleName", + name: "[PC preview] unknown name", + label: "[PC preview] unknown label", + description: "[PC preview] unknown description", + icon: "[PC preview] unknown icon", + labelId: "[PC preview] unknown labelId", + descriptionId: "[PC preview] unknown descriptionId", + iconId: "[PC preview] unknown iconId", + moduleName: "[PC preview] unknown moduleName", + process: "[PC preview] unknown process", + targetAbility: "[PC preview] unknown targetAbility", + backgroundModes: "[PC preview] unknown backgroundModes", + isVisible: "[PC preview] unknown isVisible", + formEnabled: "[PC preview] unknown formEnabled", + type: "[PC preview] unknown type", + subType: "[PC preview] unknown subType", + orientation: "[PC preview] unknown orientation", + launchMode: "[PC preview] unknown launchMode", + permissions: [paramMock.paramStringMock], + deviceTypes: [paramMock.paramStringMock], + deviceCapabilities: [paramMock.paramStringMock], + readPermission: "[PC preview] unknown readPermission", + writePermission: "[PC preview] unknown writePermission", applicationInfo: { packageName: "[PC preview] unknown packageName", className: "[PC preview] unknown className", name: "[PC preview] unknown name", - labelId: 2, - iconId: 3, + labelId: "[PC preview] unknown labelId", + iconId: "[PC preview] unknown iconId", sourceDir: "[PC preview] unknown sourceDir", - flags: 1, + flags: "[PC preview] unknown flags", customizeData: { key: "[PC preview] unknown key", value: { @@ -515,12 +517,12 @@ export const BundleInfoMock = { } } }, - formEntity: 5, - minFormHeight: 6, - defaultFormHeight: 7, - minFormWidth: 8, - defaultFormWidth: 9, - uri: "string", + formEntity: "[PC preview] unknown formEntity", + minFormHeight: "[PC preview] unknown minFormHeight", + defaultFormHeight: "[PC preview] unknown defaultFormHeight", + minFormWidth: "[PC preview] unknown minFormWidth", + defaultFormWidth: "[PC preview] unknown defaultFormWidth", + uri: "[PC preview] unknown uri", customizeData: { key: "[PC preview] unknown key", value: [ @@ -540,9 +542,9 @@ export const BundleInfoMock = { }, } ], - moduleName: "string", - mainAbilityName: "string", - installationFree: true, + moduleName: "[PC preview] unknown moduleName", + mainAbilityName: "[PC preview] unknown mainAbilityName", + installationFree: "[PC preview] unknown installationFree", } ], entryModuleName: "string", @@ -550,7 +552,7 @@ export const BundleInfoMock = { isSilentInstallation: "string", minCompatibleVersionCode: 7, entryInstallationFree: true, - reqPermissionStates: ["[PC preview] unknown reqPermissionStates"], + reqPermissionStates: [paramMock.paramStringMock], extensionAbilityInfo: [{ bundleName: "[PC preview] unknown bundleName", moduleName: "[PC preview] unknown moduleName", @@ -579,7 +581,7 @@ export const BundleInfoMock = { value: "[PC preview] unknown value", resource: "[PC preview] unknown resource", }], - permissions: ["[PC preview] unknown hashValue"], + permissions: [paramMock.paramStringMock], applicationInfo: { packageName: "[PC preview] unknown packageName", description: "[PC preview] unknown description", @@ -593,14 +595,14 @@ export const BundleInfoMock = { icon: "[PC preview] unknown icon", iconId: "[PC preview] unknown iconId", process: "[PC preview] unknown process", - moduleSourceDirs: ["[PC preview] unknown moduleSourceDirs"], - permissions: ["[PC preview] unknown permissions"], + moduleSourceDirs: [paramMock.paramStringMock], + permissions: [paramMock.paramStringMock], moduleInfos: [{ moduleName: "[PC preview] unknown moduleName", moduleSourceDir: "[PC preview] unknown moduleSourceDir", }], - entryDir: ["[PC preview] unknown entryDir"], - codePath: ["[PC preview] unknown codePath"], + entryDir: [paramMock.paramStringMock], + codePath: [paramMock.paramStringMock], metaData: [{ name: "[PC preview] unknown name", value: "[PC preview] unknown value", @@ -636,7 +638,7 @@ export const BundleInfoMock = { export const BundlePackInfo = { packages: [{ - deviceType: ["[PC preview] unknown deviceType"], + deviceType: [paramMock.paramStringMock], name: "[PC preview] unknown name", moduleType: "[PC preview] unknown moduleType", deliveryWithInstall: "[PC preview] unknown deliveryWithInstall", @@ -657,7 +659,7 @@ export const BundlePackInfo = { compatible: "[PC preview] unknown compatible", target: "[PC preview] unknown target", }, - deviceType: ["[PC preview] unknown deviceType"], + deviceType: [paramMock.paramStringMock], distro: { mainAbility: "[PC preview] unknown mainAbility", deliveryWithInstall: "[PC preview] unknown deliveryWithInstall", @@ -677,7 +679,7 @@ export const BundlePackInfo = { updateEnabled: "[PC preview] unknown updateEnabled", scheduledUpdateTime: "[PC preview] unknown scheduledUpdateTime", updateDuration: "[PC preview] unknown updateDuration", - supportDimensions: ["[PC preview] unknown supportDimensions"], + supportDimensions: [paramMock.paramNumberMock], defaultDimension: "[PC preview] unknown defaultDimension", } ], @@ -694,7 +696,7 @@ export const BundlePackInfo = { updateEnabled: "[PC preview] unknown updateEnabled", scheduledUpdateTime: "[PC preview] unknown scheduledUpdateTime", updateDuration: "[PC preview] unknown updateDuration", - supportDimensions: ["[PC preview] unknown supportDimensions"], + supportDimensions: [paramMock.paramNumberMock], defaultDimension: "[PC preview] unknown defaultDimension", } ], @@ -705,7 +707,8 @@ export const BundlePackInfo = { } }; -export const DispatchInfoMock = { - verison: "[PC preview] unknown verison", - dispatchAPI: "[PC preview] unknown dispatchAPI", +export const PixelMapFormat = { + UNKNOWN: 0, + RGB_565: 2, + RGBA_8888: 3, } \ No newline at end of file diff --git a/runtime/main/extend/systemplugin/napi/bundle/bundleInstaller.js b/runtime/main/extend/systemplugin/napi/bundle/bundleInstaller.js new file mode 100755 index 00000000..c7e5d512 --- /dev/null +++ b/runtime/main/extend/systemplugin/napi/bundle/bundleInstaller.js @@ -0,0 +1,67 @@ +/* + * Copyright (c) 2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { paramMock } from "../../utils" +import { InstallErrorCode } from '../ohos_bundle.js' + +export const HashParam = { + moduleName: "[PC preview] unknown moduleName", + hashValue: "[PC preview] unknown hashValue", +} + +export const InstallParam = { + userId: "[PC preview] unknown userId", + installFlag: "[PC preview] unknown installFlag", + hashParams: [ + HashParam + ], + crowdtestDeadline: "[PC preview] unknown crowdtestDeadline", +} + +export const InstallStatus = { + status: { + InstallErrorCode + }, + statusMessage: "[PC preview] unknown statusMessage", +} + +export const BundleInstaller = { + moduleName: "[PC preview] unknown moduleName", + hashValue: "[PC preview] unknown hashValue", +} + +export function mockBundleInstaller() { + const bundleInstaller = { + install: function(...args){ + console.warn("bundleInstaller.install interface 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, InstallStatus); + }, + uninstall: function(...args){ + console.warn("bundleInstaller.uninstall interface 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, InstallStatus); + }, + recover: function(...args){ + console.warn("bundleInstaller.recover interface 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, InstallStatus); + } + }; + return bundleInstaller; +} \ No newline at end of file diff --git a/runtime/main/extend/systemplugin/napi/bundle/bundleStatusCallback.js b/runtime/main/extend/systemplugin/napi/bundle/bundleStatusCallback.js new file mode 100755 index 00000000..2215a05f --- /dev/null +++ b/runtime/main/extend/systemplugin/napi/bundle/bundleStatusCallback.js @@ -0,0 +1,32 @@ +/* + * Copyright (c) 2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +export function mockBundleStatusCallback() { + const bundleStatusCallback = { + add: function(){ + console.warn("bundleStatusCallback.add interface mocked in the Previewer. How this interface works on the" + + " Previewer may be different from that on a real device.") + }, + update: function(){ + console.warn("bundleStatusCallback.update interface mocked in the Previewer. How this interface works on the" + + " Previewer may be different from that on a real device.") + }, + remove: function(){ + console.warn("bundleStatusCallback.remove interface mocked in the Previewer. How this interface works on the" + + " Previewer may be different from that on a real device.") + } + }; + return bundleStatusCallback; +} \ No newline at end of file diff --git a/runtime/main/extend/systemplugin/napi/bundle/customizeData.js b/runtime/main/extend/systemplugin/napi/bundle/customizeData.js new file mode 100755 index 00000000..dce34591 --- /dev/null +++ b/runtime/main/extend/systemplugin/napi/bundle/customizeData.js @@ -0,0 +1,20 @@ +/* + * Copyright (c) 2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +export const CustomizeData = { + name: "[PC preview] unknown name", + value: "[PC preview] unknown value", + extra: "[PC preview] unknown extra", +} \ No newline at end of file diff --git a/runtime/main/extend/systemplugin/napi/bundle/defaultAppManager.js b/runtime/main/extend/systemplugin/napi/bundle/defaultAppManager.js index 0e47ba4b..f66db7aa 100755 --- a/runtime/main/extend/systemplugin/napi/bundle/defaultAppManager.js +++ b/runtime/main/extend/systemplugin/napi/bundle/defaultAppManager.js @@ -13,7 +13,7 @@ * limitations under the License. */ -export const DefaultAppManagerMock = { +export const DefaultAppManager = { BROWSER: "[PC preview] unknown BROWSER", IMAGE: "[PC preview] unknown IMAGE", AUDIO: "[PC preview] unknown AUDIO", diff --git a/runtime/main/extend/systemplugin/napi/bundle/dispatchInfo.js b/runtime/main/extend/systemplugin/napi/bundle/dispatchInfo.js new file mode 100755 index 00000000..36c5110d --- /dev/null +++ b/runtime/main/extend/systemplugin/napi/bundle/dispatchInfo.js @@ -0,0 +1,19 @@ +/* + * Copyright (c) 2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +export const DispatchInfo = { + verison: "[PC preview] unknown verison", + dispatchAPI: "[PC preview] unknown dispatchAPI", +} \ No newline at end of file diff --git a/runtime/main/extend/systemplugin/napi/bundle/elementName.js b/runtime/main/extend/systemplugin/napi/bundle/elementName.js new file mode 100755 index 00000000..ffa0992a --- /dev/null +++ b/runtime/main/extend/systemplugin/napi/bundle/elementName.js @@ -0,0 +1,23 @@ +/* + * Copyright (c) 2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +export const ElementName = { + deviceId: "[PC preview] unknown deviceId", + bundleName: "[PC preview] unknown bundleName", + abilityName: "[PC preview] unknown abilityName", + uri: "[PC preview] unknown uri", + shortName: "[PC preview] unknown shortName", + moduleName: "[PC preview] unknown moduleName", +} \ No newline at end of file diff --git a/runtime/main/extend/systemplugin/napi/bundle/extensionAbilityInfo.js b/runtime/main/extend/systemplugin/napi/bundle/extensionAbilityInfo.js new file mode 100755 index 00000000..ba8738ed --- /dev/null +++ b/runtime/main/extend/systemplugin/napi/bundle/extensionAbilityInfo.js @@ -0,0 +1,98 @@ +/* + * Copyright (c) 2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { paramMock } from "../../utils" + +export const ExtensionAbilityInfo = { + bundleName: "[PC preview] unknown bundleName", + moduleName: "[PC preview] unknown moduleName", + name: "[PC preview] unknown name", + labelId: "[PC preview] unknown labelId", + descriptionId: "[PC preview] unknown descriptionId", + iconId: "[PC preview] unknown iconId", + isVisible: "[PC preview] unknown isVisible", + extensionAbilityType: { + FORM: 0, + WORK_SCHEDULER: 1, + INPUT_METHOD: 2, + SERVICE: 3, + ACCESSIBILITY: 4, + DATA_SHARE: 5, + FILE_SHARE: 6, + STATIC_SUBSCRIBER: 7, + WALLPAPER: 8, + BACKUP: 9, + WINDOW: 10, + ENTERPRISE_ADMIN: 11, + UNSPECIFIED: 20, + }, + metadata: [{ + name: "[PC preview] unknown name", + value: "[PC preview] unknown value", + resource: "[PC preview] unknown resource", + }], + permissions: [paramMock.paramStringMock], + applicationInfo: { + packageName: "[PC preview] unknown packageName", + description: "[PC preview] unknown description", + descriptionId: "[PC preview] unknown descriptionId", + enabled: "[PC preview] unknown enabled", + systemApp: "[PC preview] unknown systemApp", + className: "[PC preview] unknown className", + name: "[PC preview] unknown name", + label: "[PC preview] unknown label", + labelId: "[PC preview] unknown labelId", + icon: "[PC preview] unknown icon", + iconId: "[PC preview] unknown iconId", + process: "[PC preview] unknown process", + moduleSourceDirs: [paramMock.paramStringMock], + permissions: [paramMock.paramStringMock], + moduleInfos: [{ + moduleName: "[PC preview] unknown moduleName", + moduleSourceDir: "[PC preview] unknown moduleSourceDir", + }], + entryDir: "[PC preview] unknown entryDir", + codePath: "[PC preview] unknown codePath", + metaData: [{ + name: "[PC preview] unknown name", + value: "[PC preview] unknown value", + extra: "[PC preview] unknown extra", + }], + metadata: [{ + name: "[PC preview] unknown name", + value: "[PC preview] unknown value", + resource: "[PC preview] unknown resource", + }], + removable: "[PC preview] unknown removable", + accessTokenId: "[PC preview] unknown accessTokenId", + uid: "[PC preview] unknown uid", + entityType: "[PC preview] unknown entityType", + fingerprint: "[PC preview] unknown fingerprint", + iconResource: "[PC preview] unknown iconResource", + labelResource: "[PC preview] unknown labelResource", + descriptionResource: "[PC preview] unknown descriptionResource", + appDistributionType: "[PC preview] unknown appDistributionType", + appProvisionType: "[PC preview] unknown appProvisionType", + supportedModes: "[PC preview] unknown supportedModes", + }, + metadata: [{ + name: "[PC preview] unknown name", + value: "[PC preview] unknown value", + resource: "[PC preview] unknown resource", + }], + enabled: "[PC preview] unknown enabled", + readPermission: "[PC preview] unknown readPermission", + writePermission: "[PC preview] unknown writePermission", +} \ No newline at end of file diff --git a/runtime/main/extend/systemplugin/napi/bundle/hapModuleInfo.js b/runtime/main/extend/systemplugin/napi/bundle/hapModuleInfo.js new file mode 100755 index 00000000..f7a699f8 --- /dev/null +++ b/runtime/main/extend/systemplugin/napi/bundle/hapModuleInfo.js @@ -0,0 +1,101 @@ +/* + * Copyright (c) 2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { paramMock } from "../../utils" + +export const HapModuleInfo = { + name: "[PC preview] unknown name", + description: "[PC preview] unknown description", + descriptionId: "[PC preview] unknown descriptionId", + icon: "[PC preview] unknown icon", + label: "[PC preview] unknown label", + labelId: "[PC preview] unknown labelId", + iconId: "[PC preview] unknown iconId", + backgroundImg: "[PC preview] unknown backgroundImg", + supportedModes: "[PC preview] unknown supportedModes", + reqCapabilities: [paramMock.paramStringMock], + deviceTypes: [paramMock.paramStringMock], + abilityInfo: [ + { + bundleName: "[PC preview] unknown bundleName", + name: "[PC preview] unknown name", + label: "[PC preview] unknown label", + description: "[PC preview] unknown description", + icon: "[PC preview] unknown icon", + labelId: "[PC preview] unknown labelId", + descriptionId: "[PC preview] unknown descriptionId", + iconId: "[PC preview] unknown iconId", + moduleName: "[PC preview] unknown moduleName", + process: "[PC preview] unknown process", + targetAbility: "[PC preview] unknown targetAbility", + backgroundModes: "[PC preview] unknown backgroundModes", + isVisible: "[PC preview] unknown isVisible", + formEnabled: "[PC preview] unknown formEnabled", + type: "[PC preview] unknown type", + subType: "[PC preview] unknown subType", + orientation: "[PC preview] unknown orientation", + launchMode: "[PC preview] unknown launchMode", + permissions: [paramMock.paramStringMock], + deviceTypes: [paramMock.paramStringMock], + deviceCapabilities: [paramMock.paramStringMock], + readPermission: "[PC preview] unknown readPermission", + writePermission: "[PC preview] unknown writePermission", + applicationInfo: { + packageName: "[PC preview] unknown packageName", + className: "[PC preview] unknown className", + name: "[PC preview] unknown name", + labelId: "[PC preview] unknown name", + iconId: "[PC preview] unknown name", + sourceDir: "[PC preview] unknown sourceDir", + flags: "[PC preview] unknown name", + customizeData: { + key: "[PC preview] unknown key", + value: { + CustomizeData: { + name: "[PC preview] unknown name", + value: "[PC preview] unknown value", + } + } + } + }, + formEntity: "[PC preview] unknown formEntity", + minFormHeight: "[PC preview] unknown minFormHeight", + defaultFormHeight: "[PC preview] unknown defaultFormHeight", + minFormWidth: "[PC preview] unknown minFormWidth", + defaultFormWidth: "[PC preview] unknown defaultFormWidth", + uri: "[PC preview] unknown uri", + customizeData: { + key: "[PC preview] unknown key", + value: [ + { + CustomizeData: { + name: "[PC preview] unknown name", + value: "[PC preview] unknown value", + }, + }, + { + CustomizeData: { + name: "[PC preview] unknown name", + value: "[PC preview] unknown value", + }, + } + ] + }, + } + ], + moduleName: "[PC preview] unknown moduleName", + mainAbilityName: "[PC preview] unknown mainAbilityName", + installationFree: "[PC preview] unknown installationFree", +} \ No newline at end of file diff --git a/runtime/main/extend/systemplugin/napi/bundle/launcherAbilityInfo.js b/runtime/main/extend/systemplugin/napi/bundle/launcherAbilityInfo.js index 720915a6..25564dda 100644 --- a/runtime/main/extend/systemplugin/napi/bundle/launcherAbilityInfo.js +++ b/runtime/main/extend/systemplugin/napi/bundle/launcherAbilityInfo.js @@ -13,7 +13,9 @@ * limitations under the License. */ -export const LauncherAbilityInfoMock = { +import { paramMock } from "../../utils" + +export const LauncherAbilityInfo = { applicationInfo: { packageName: "[PC preview] unknown packageName", description: "[PC preview] unknown description", @@ -28,8 +30,8 @@ export const LauncherAbilityInfoMock = { iconId: "[PC preview] unknown iconId", process: "[PC preview] unknown process", supportedModes: "[PC preview] unknown supportedModes", - moduleSourceDirs: ["[PC preview] unknown moduleSourceDirs"], - permissions: ["[PC preview] unknown permissions"], + moduleSourceDirs: [paramMock.paramStringMock], + permissions: [paramMock.paramStringMock], sourceDir: "[PC preview] unknown sourceDir", moduleInfos: [{ moduleName: "[PC preview] unknown moduleName", diff --git a/runtime/main/extend/systemplugin/napi/bundle/metadata.js b/runtime/main/extend/systemplugin/napi/bundle/metadata.js new file mode 100755 index 00000000..6157307c --- /dev/null +++ b/runtime/main/extend/systemplugin/napi/bundle/metadata.js @@ -0,0 +1,20 @@ +/* + * Copyright (c) 2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +export const Metadata = { + name: "[PC preview] unknown name", + value: "[PC preview] unknown value", + resource: "[PC preview] unknown resource", +} \ No newline at end of file diff --git a/runtime/main/extend/systemplugin/napi/bundle/moduleInfo.js b/runtime/main/extend/systemplugin/napi/bundle/moduleInfo.js new file mode 100755 index 00000000..4b0193f6 --- /dev/null +++ b/runtime/main/extend/systemplugin/napi/bundle/moduleInfo.js @@ -0,0 +1,19 @@ +/* + * Copyright (c) 2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +export const ModuleInfo = { + moduleName: "[PC preview] unknown moduleName", + moduleSourceDir: "[PC preview] unknown moduleSourceDir", +} \ No newline at end of file diff --git a/runtime/main/extend/systemplugin/napi/bundle/packInfo.js b/runtime/main/extend/systemplugin/napi/bundle/packInfo.js new file mode 100755 index 00000000..aca7df89 --- /dev/null +++ b/runtime/main/extend/systemplugin/napi/bundle/packInfo.js @@ -0,0 +1,157 @@ +/* + * Copyright (c) 2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { paramMock } from "../../utils" + +export const BundlePackInfo = { + packages: [{ + deviceType: [paramMock.paramStringMock], + name: "[PC preview] unknown name", + moduleType: "[PC preview] unknown moduleType", + deliveryWithInstall: "[PC preview] unknown deliveryWithInstall", + }], + summary: { + app: { + bundleName: "[PC preview] unknown bundleName", + version: { + minCompatibleVersionCode: "[PC preview] unknown minCompatibleVersionCode", + name: "[PC preview] unknown name", + code: "[PC preview] unknown code", + }, + }, + modules: [ + { + apiVersion: { + releaseType: "[PC preview] unknown releaseType", + compatible: "[PC preview] unknown compatible", + target: "[PC preview] unknown target", + }, + deviceType: [paramMock.paramStringMock], + distro: { + mainAbility: "[PC preview] unknown mainAbility", + deliveryWithInstall: "[PC preview] unknown deliveryWithInstall", + installationFree: "[PC preview] unknown installationFree", + moduleName: "[PC preview] unknown moduleName", + moduleType: "[PC preview] unknown moduleType", + }, + abilities: [ + { + name: "[PC preview] unknown name", + label: "[PC preview] unknown label", + visible: "[PC preview] unknown visible", + forms: [ + { + name: "[PC preview] unknown name", + type: "[PC preview] unknown type", + updateEnabled: "[PC preview] unknown updateEnabled", + scheduledUpdateTime: "[PC preview] unknown scheduledUpdateTime", + updateDuration: "[PC preview] unknown updateDuration", + supportDimensions: [paramMock.paramNumberMock], + defaultDimension: "[PC preview] unknown defaultDimension", + } + ], + + } + ], + extensionAbilities: [ + { + name: "[PC preview] unknown name", + forms: [ + { + name: "[PC preview] unknown name", + type: "[PC preview] unknown type", + updateEnabled: "[PC preview] unknown updateEnabled", + scheduledUpdateTime: "[PC preview] unknown scheduledUpdateTime", + updateDuration: "[PC preview] unknown updateDuration", + supportDimensions: [paramMock.paramNumberMock], + defaultDimension: "[PC preview] unknown defaultDimension", + } + ], + } + ] + } + ] + } +} + +export const PackageConfig = { + deviceType: [paramMock.paramStringMock], + name: "[PC preview] unknown name", + moduleType: "[PC preview] unknown moduleType", + deliveryWithInstall: "[PC preview] unknown deliveryWithInstall", +} + +export const PackageSummary = { + app: { + bundleName: "[PC preview] unknown bundleName", + version: { + minCompatibleVersionCode: "[PC preview] unknown minCompatibleVersionCode", + name: "[PC preview] unknown name", + code: "[PC preview] unknown code", + }, + }, + modules: [ + { + apiVersion: { + releaseType: "[PC preview] unknown releaseType", + compatible: "[PC preview] unknown compatible", + target: "[PC preview] unknown target", + }, + deviceType: [paramMock.paramStringMock], + distro: { + mainAbility: "[PC preview] unknown mainAbility", + deliveryWithInstall: "[PC preview] unknown deliveryWithInstall", + installationFree: "[PC preview] unknown installationFree", + moduleName: "[PC preview] unknown moduleName", + moduleType: "[PC preview] unknown moduleType", + }, + abilities: [ + { + name: "[PC preview] unknown name", + label: "[PC preview] unknown label", + visible: "[PC preview] unknown visible", + forms: [ + { + name: "[PC preview] unknown name", + type: "[PC preview] unknown type", + updateEnabled: "[PC preview] unknown updateEnabled", + scheduledUpdateTime: "[PC preview] unknown scheduledUpdateTime", + updateDuration: "[PC preview] unknown updateDuration", + supportDimensions: [paramMock.paramNumberMock], + defaultDimension: "[PC preview] unknown defaultDimension", + } + ], + + } + ], + extensionAbilities: [ + { + name: "[PC preview] unknown name", + forms: [ + { + name: "[PC preview] unknown name", + type: "[PC preview] unknown type", + updateEnabled: "[PC preview] unknown updateEnabled", + scheduledUpdateTime: "[PC preview] unknown scheduledUpdateTime", + updateDuration: "[PC preview] unknown updateDuration", + supportDimensions: [paramMock.paramNumberMock], + defaultDimension: "[PC preview] unknown defaultDimension", + } + ], + } + ] + } + ] +} \ No newline at end of file diff --git a/runtime/main/extend/systemplugin/napi/bundle/permissionDef.js b/runtime/main/extend/systemplugin/napi/bundle/permissionDef.js new file mode 100755 index 00000000..3caaf73d --- /dev/null +++ b/runtime/main/extend/systemplugin/napi/bundle/permissionDef.js @@ -0,0 +1,21 @@ +/* + * Copyright (c) 2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +export const PermissionDef = { + permissionName: "[PC preview] unknown permissionName", + grantMode: "[PC preview] unknown grantMode", + labelId: "[PC preview] unknown labelId", + descriptionId: "[PC preview] unknown descriptionId", +} \ No newline at end of file diff --git a/runtime/main/extend/systemplugin/napi/bundle/remoteAbilityInfo.js b/runtime/main/extend/systemplugin/napi/bundle/remoteAbilityInfo.js new file mode 100755 index 00000000..ab31d377 --- /dev/null +++ b/runtime/main/extend/systemplugin/napi/bundle/remoteAbilityInfo.js @@ -0,0 +1,22 @@ +/* + * Copyright (c) 2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { ElementName } from './elementName'; + +export const RemoteAbilityInfo = { + elementName: ElementName, + label: "[PC preview] unknown IMAGE", + icon: "[PC preview] unknown AUDIO", +} \ No newline at end of file diff --git a/runtime/main/extend/systemplugin/napi/bundle/shortcutInfo.js b/runtime/main/extend/systemplugin/napi/bundle/shortcutInfo.js new file mode 100755 index 00000000..934d65a2 --- /dev/null +++ b/runtime/main/extend/systemplugin/napi/bundle/shortcutInfo.js @@ -0,0 +1,41 @@ +/* + * Copyright (c) 2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +export const ShortcutWant = { + targetBundle: "[PC preview] unknown targetBundle", + targetModule: "[PC preview] unknown targetModule", + targetClass: "[PC preview] unknown targetClass", +} + +export const ShortcutInfo = { + id: "[PC preview] unknown id", + bundleName: "[PC preview] unknown bundleName", + hostAbility: "[PC preview] unknown hostAbility", + icon: "[PC preview] unknown icon", + iconId: "[PC preview] unknown iconId", + label: "[PC preview] unknown label", + labelId: "[PC preview] unknown labelId", + disableMessage: "[PC preview] unknown disableMessage", + wants: [ + { + targetBundle: "[PC preview] unknown targetBundle", + targetModule: "[PC preview] unknown targetModule", + targetClass: "[PC preview] unknown targetClass", + }], + isStatic: "[PC preview] unknown isStatic", + isHomeShortcut: "[PC preview] unknown isHomeShortcut", + isEnabled: "[PC preview] unknown isEnabled", + moduleName: "[PC preview] unknown moduleName", +} \ No newline at end of file diff --git a/runtime/main/extend/systemplugin/napi/ohos_bundle.js b/runtime/main/extend/systemplugin/napi/ohos_bundle.js index cba24dee..e07715c9 100644 --- a/runtime/main/extend/systemplugin/napi/ohos_bundle.js +++ b/runtime/main/extend/systemplugin/napi/ohos_bundle.js @@ -14,89 +14,47 @@ */ import { paramMock } from "../utils" -import { BundleInfoMock, BundlePackInfo, DispatchInfoMock } from './bundle/bundleInfo' -import { ApplicationInfoMock } from './bundle/applicationInfo' -import { WantMock } from './bundle/applicationInfo' +import { BundleInfo, BundlePackInfo, PixelMapFormat} from './bundle/bundleInfo' +import { DispatchInfo } from './bundle/dispatchInfo' +import { ApplicationInfo, Want } from './bundle/applicationInfo' +import { AbilityInfo } from './bundle/abilityInfo' +import { PermissionDef } from './bundle/permissionDef' +import { ExtensionAbilityInfo } from './bundle/extensionAbilityInfo' + +export const InstallErrorCode = { + SUCCESS: 0, + STATUS_INSTALL_FAILURE: 1, + STATUS_INSTALL_FAILURE_ABORTED: 2, + STATUS_INSTALL_FAILURE_INVALID: 3, + STATUS_INSTALL_FAILURE_CONFLICT: 4, + STATUS_INSTALL_FAILURE_STORAGE: 5, + STATUS_INSTALL_FAILURE_INCOMPATIBLE: 6, + STATUS_UNINSTALL_FAILURE: 7, + STATUS_UNINSTALL_FAILURE_BLOCKED: 8, + STATUS_UNINSTALL_FAILURE_ABORTED: 9, + STATUS_INSTALL_FAILURE_DOWNLOAD_TIMEOUT: 10, + STATUS_INSTALL_FAILURE_DOWNLOAD_FAILED: 0x0B, + STATUS_RECOVER_FAILURE_INVALID: 0x0C, + STATUS_INSTALL_FAILURE_DOWNLOAD_FAILED: 0x0D, + STATUS_ABILITY_NOT_FOUND: 0x40, + STATUS_BMS_SERVICE_ERROR: 0x41, + STATUS_FAILED_NO_SPACE_LEFT: 0x42, + STATUS_GRANT_REQUEST_PERMISSIONS_FAILED: 0x43, + STATUS_INSTALL_PERMISSION_DENIED: 0x44, + STATUS_UNINSTALL_PERMISSION_DENIED: 0x45, +} export function mockBundle() { - const extensionAbilityType = { - FORM: 0, - WORK_SCHEDULER: 1, - INPUT_METHOD: 2, - SERVICE: 3, - ACCESSIBILITY: 4, - DATA_SHARE: 5, - FILE_SHARE: 6, - STATIC_SUBSCRIBER: 7, - WALLPAPER: 8, - BACKUP: 9, - WINDOW: 10, - UNSPECIFIED: 20, - } - - const ExtensionAbilityInfoMock = [ - { - bundleName: "[PC preview] unknown bundle name", - moduleName: "[PC preview] unknown module name", - name: "[PC preview] unknown name", - labelId: "[PC preview] unknown label id", - descriptionId: "[PC preview] unknown description id", - iconId: "[PC preview] unknown icon id", - isVisible: "[PC preview] unknown is visible", - extensionAbilityType: extensionAbilityType, - permissions: ["[PC preview] unknown permissions"], - applicationInfo: { - name: "[PC preview] unknown is name", - description: "[PC preview] unknown is description", - descriptionId: "[PC preview] unknown is descriptionId", - systemApp: "[PC preview] unknown is systemApp", - enabled: "[PC preview] unknown is enabled", - labelId: "[PC preview] unknown is labelId", - icon: "[PC preview] unknown is icon", - iconId: "[PC preview] unknown is iconId", - process: "[PC preview] unknown is process", - supportedModes: "[PC preview] unknown is supportedModes", - moduleSourceDirs: "[PC preview] unknown is moduleSourceDirs", - permissions: ["[PC preview] unknown is permissions"], - moduleInfos: ["[PC preview] unknown is moduleSourceDirs"], - entryDir: "[PC preview] unknown is entryDir", - metaData: [{ - name: "[PC preview] unknown name", - value: "[PC preview] unknown value", - resource: "[PC preview] unknown resource", - }], - metadata: [{ - name: "[PC preview] unknown name", - value: "[PC preview] unknown value", - resource: "[PC preview] unknown resource", - }], - removable: "[PC preview] unknown is removable", - accessTokenId: "[PC preview] unknown is accessTokenId", - uid: "[PC preview] unknown is uid", - entityType: "[PC preview] unknown is entityType", - fingerprint: "[PC preview] unknown is fingerprint", - }, - metadata: [{ - name: "[PC preview] unknown name", - value: "[PC preview] unknown value", - resource: "[PC preview] unknown resource", - }], - enabled: "[PC preview] unknown enabled", - readPermission: "[PC preview] unknown read permission", - writePermission: "[PC preview] unknown write permission", - } - ] - const bundle = { getBundleInfo: function(...args) { console.warn("bundle.getBundleInfo interface mocked in the Previewer. How this interface works on the" + " Previewer may be different from that on a real device.") const len = args.length; if (typeof args[len - 1] === 'function') { - args[len - 1].call(this, paramMock.businessErrorMock, BundleInfoMock); + args[len - 1].call(this, paramMock.businessErrorMock, BundleInfo); } else { return new Promise((resolve) => { - resolve(BundleInfoMock); + resolve(BundleInfo); }) } }, @@ -117,10 +75,10 @@ export function mockBundle() { " Previewer may be different from that on a real device.") const len = args.length; if (typeof args[len - 1] === 'function') { - args[len - 1].call(this, paramMock.businessErrorMock, ApplicationInfoMock); + args[len - 1].call(this, paramMock.businessErrorMock, ApplicationInfo); } else { return new Promise((resolve) => { - resolve(ApplicationInfoMock); + resolve(ApplicationInfo); }) } }, @@ -129,10 +87,10 @@ export function mockBundle() { " Previewer may be different from that on a real device.") const len = args.length; if (typeof args[len - 1] === 'function') { - args[len - 1].call(this, paramMock.businessErrorMock, Array(BundleInfoMock)); + args[len - 1].call(this, paramMock.businessErrorMock, Array(BundleInfo)); } else { return new Promise((resolve) => { - resolve(Array(BundleInfoMock)); + resolve(Array(BundleInfo)); }) } }, @@ -141,10 +99,10 @@ export function mockBundle() { " Previewer may be different from that on a real device.") const len = args.length; if (typeof args[len - 1] === 'function') { - args[len - 1].call(this, paramMock.businessErrorMock, Array(BundleInfoMock)); + args[len - 1].call(this, paramMock.businessErrorMock, Array(BundleInfo)); } else { return new Promise((resolve) => { - resolve(Array(BundleInfoMock)); + resolve(Array(BundleInfo)); }) } }, @@ -153,10 +111,10 @@ export function mockBundle() { " Previewer may be different from that on a real device.") const len = args.length; if (typeof args[len - 1] === 'function') { - args[len - 1].call(this, paramMock.businessErrorMock, Array(ApplicationInfoMock)); + args[len - 1].call(this, paramMock.businessErrorMock, Array(ApplicationInfo)); } else { return new Promise((resolve) => { - resolve(Array(ApplicationInfoMock)); + resolve(Array(ApplicationInfo)); }) } }, @@ -165,10 +123,10 @@ export function mockBundle() { " Previewer may be different from that on a real device.") const len = args.length; if (typeof args[len - 1] === 'function') { - args[len - 1].call(this, paramMock.businessErrorMock, Array(BundleInfoMock)); + args[len - 1].call(this, paramMock.businessErrorMock, Array(BundleInfo)); } else { return new Promise((resolve) => { - resolve(Array(BundleInfoMock)); + resolve(Array(BundleInfo)); }) } }, @@ -177,10 +135,10 @@ export function mockBundle() { " Previewer may be different from that on a real device.") const len = args.length; if (typeof args[len - 1] === 'function') { - args[len - 1].call(this, paramMock.businessErrorMock, Array(WantMock)); + args[len - 1].call(this, paramMock.businessErrorMock, Array(Want)); } else { return new Promise((resolve) => { - resolve(Array(WantMock)); + resolve(Array(Want)); }) } }, @@ -273,10 +231,10 @@ export function mockBundle() { " Previewer may be different from that on a real device.") const len = args.length if (typeof args[len - 1] === 'function') { - args[len - 1].call(this,paramMock.businessErrorMock, Array(ExtensionAbilityInfoMock)) + args[len - 1].call(this,paramMock.businessErrorMock, Array(ExtensionAbilityInfo)) } else { return new Promise((resolve) => { - resolve(Array(ExtensionAbilityInfoMock)) + resolve(Array(ExtensionAbilityInfo)) }); } }, @@ -297,10 +255,10 @@ export function mockBundle() { " Previewer may be different from that on a real device.") const len = args.length; if (typeof args[len - 1] === 'function') { - args[len - 1].call(this, paramMock.businessErrorMock, DispatchInfoMock); + args[len - 1].call(this, paramMock.businessErrorMock, DispatchInfo); } else { return new Promise((resolve) => { - resolve(DispatchInfoMock); + resolve(DispatchInfo); }) } }, @@ -328,6 +286,90 @@ export function mockBundle() { }); } }, + isAbilityEnabled: function(...args) { + console.warn("bundle.isAbilityEnabled interface mocked in the Previewer. How this interface works on the" + + " Previewer may be different 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); + }) + } + }, + isApplicationEnabled: function(...args) { + console.warn("bundle.isApplicationEnabled interface mocked in the Previewer. How this interface works on the" + + " Previewer may be different 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); + }) + } + }, + getAbilityIcon: function(...args) { + console.warn("bundle.getAbilityIcon interface mocked in the Previewer. How this interface works on the" + + " Previewer may be different from that on a real device.") + const len = args.length; + if (typeof args[len - 1] === 'function') { + args[len - 1].call(this, paramMock.businessErrorMock, PixelMapFormat); + } else { + return new Promise((resolve) => { + resolve(PixelMapFormat); + }) + } + }, + getAbilityLabel: function(...args) { + console.warn("bundle.getAbilityLabel interface mocked in the Previewer. How this interface works on the" + + " Previewer may be different 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); + }) + } + }, + getPermissionDef: function(...args) { + console.warn("bundle.getPermissionDef interface mocked in the Previewer. How this interface works on the" + + " Previewer may be different from that on a real device.") + const len = args.length; + if (typeof args[len - 1] === 'function') { + args[len - 1].call(this, paramMock.businessErrorMock, PermissionDef); + } else { + return new Promise((resolve) => { + resolve(PermissionDef); + }) + } + }, + getNameForUid: function(...args) { + console.warn("bundle.getNameForUid interface mocked in the Previewer. How this interface works on the" + + " Previewer may be different 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); + }) + } + }, + getAbilityInfo: function(...args) { + console.warn("bundle.getAbilityInfo interface mocked in the Previewer. How this interface works on the" + + " Previewer may be different from that on a real device.") + const len = args.length; + if (typeof args[len - 1] === 'function') { + args[len - 1].call(this, paramMock.businessErrorMock, AbilityInfo); + } else { + return new Promise((resolve) => { + resolve(AbilityInfo); + }) + } + }, }; return bundle; } \ No newline at end of file diff --git a/runtime/main/extend/systemplugin/napi/ohos_bundle_defaultAppManager.js b/runtime/main/extend/systemplugin/napi/ohos_bundle_defaultAppManager.js index d5487114..d5f65973 100755 --- a/runtime/main/extend/systemplugin/napi/ohos_bundle_defaultAppManager.js +++ b/runtime/main/extend/systemplugin/napi/ohos_bundle_defaultAppManager.js @@ -14,7 +14,7 @@ */ import { paramMock } from "../utils" -import { BundleInfoMock } from './bundle/bundleInfo' +import { BundleInfo } from './bundle/bundleInfo' export function mockDefaultAppManager() { const defaultAppManager = { @@ -35,10 +35,10 @@ export function mockDefaultAppManager() { " Previewer may be different from that on a real device.") const len = args.length; if (typeof args[len - 1] === 'function') { - args[len - 1].call(this, paramMock.businessErrorMock, BundleInfoMock); + args[len - 1].call(this, paramMock.businessErrorMock, BundleInfo); } else { return new Promise((resolve) => { - resolve(BundleInfoMock); + resolve(BundleInfo); }) } }, diff --git a/runtime/main/extend/systemplugin/napi/ohos_bundle_innerBundleManager.js b/runtime/main/extend/systemplugin/napi/ohos_bundle_innerBundleManager.js index 8487432b..13893410 100644 --- a/runtime/main/extend/systemplugin/napi/ohos_bundle_innerBundleManager.js +++ b/runtime/main/extend/systemplugin/napi/ohos_bundle_innerBundleManager.js @@ -14,8 +14,8 @@ */ import { paramMock } from "../utils" -import { ShortcutInfoMock } from './bundle/applicationInfo' -import { LauncherAbilityInfoMock } from './bundle/launcherAbilityInfo' +import { ShortcutInfo } from './bundle/applicationInfo' +import { LauncherAbilityInfo } from './bundle/launcherAbilityInfo' export function mockInnerBundle() { const innerBundleManager = { @@ -24,10 +24,10 @@ export function mockInnerBundle() { " Previewer may be different from that on a real device.") const len = args.length; if (typeof args[len - 1] === 'function') { - args[len - 1].call(this, paramMock.businessErrorMock, LauncherAbilityInfoMock); + args[len - 1].call(this, paramMock.businessErrorMock, LauncherAbilityInfo); } else { return new Promise((resolve) => { - resolve(LauncherAbilityInfoMock); + resolve(LauncherAbilityInfo); }) } }, @@ -44,10 +44,10 @@ export function mockInnerBundle() { " Previewer may be different from that on a real device.") const len = args.length; if (typeof args[len - 1] === 'function') { - args[len - 1].call(this, paramMock.businessErrorMock, Array(LauncherAbilityInfoMock)); + args[len - 1].call(this, paramMock.businessErrorMock, Array(LauncherAbilityInfo)); } else { return new Promise((resolve) => { - resolve(Array(LauncherAbilityInfoMock)); + resolve(Array(LauncherAbilityInfo)); }) } }, @@ -56,10 +56,10 @@ export function mockInnerBundle() { " Previewer may be different from that on a real device.") const len = args.length; if (typeof args[len - 1] === 'function') { - args[len - 1].call(this, paramMock.businessErrorMock, Array(ShortcutInfoMock)); + args[len - 1].call(this, paramMock.businessErrorMock, Array(ShortcutInfo)); } else { return new Promise((resolve) => { - resolve(Array(ShortcutInfoMock)); + resolve(Array(ShortcutInfo)); }) } }, From 1b275b8b62b8d1902fb66649e57a385a8a13a4ba Mon Sep 17 00:00:00 2001 From: yinyong Date: Tue, 12 Jul 2022 16:18:07 +0800 Subject: [PATCH 062/109] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E8=A7=84=E8=8C=83?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: yinyong --- .../napi/ohos_multimedia_av_session.js | 69 ++++++++++--------- 1 file changed, 35 insertions(+), 34 deletions(-) diff --git a/runtime/main/extend/systemplugin/napi/ohos_multimedia_av_session.js b/runtime/main/extend/systemplugin/napi/ohos_multimedia_av_session.js index 89d89f11..8cf529a9 100644 --- a/runtime/main/extend/systemplugin/napi/ohos_multimedia_av_session.js +++ b/runtime/main/extend/systemplugin/napi/ohos_multimedia_av_session.js @@ -16,7 +16,7 @@ import { paramMock } from "../utils" export function mockMultimediaAVSession() { - const AVMetadataMock = { + const AVMetadata = { assetId: "[PC Preview] unknow assetId", title: "[PC Preview] unknow title", artist: "[PC Preview] unknow artist", @@ -34,37 +34,40 @@ export function mockMultimediaAVSession() { nextAssetId: "[PC Preview] unknow nextAssetId" } - const AVPlaybackStateMock = { + const AVPlaybackState = { state: "[PC Preview] unknow state", speed: "[PC Preview] unknow speed", - position: PlaybackPositionMock, + position: PlaybackPosition, bufferedTime: "[PC Preview] unknow bufferedTime", loopMode: "[PC Preview] unknow loopMode", isFavorite: "[PC Preview] unknow isFavorite" } - const PlaybackPositionMock = { + const PlaybackPosition = { elapsedTime: "[PC Preview] unknow elapsedTime", updateTime: "[PC Preview] unknow updateTime" } - const OutputDeviceInfoMock = { + const OutputDeviceInfo = { isRemote: "[PC Preview] unknow isRemote", deviceId: [paramMock.paramStringMock], deviceName: [paramMock.paramStringMock] } - const AVSessionDescriptorMock = { + const AVSessionDescriptor = { sessionId: "[PC Preview] unknow sessionId", type: "[PC Preview] unknow type", sessionTag: "[PC Preview] unknow sessionTag", elementName: "[PC Preview] unknow elementName", isActive: "[PC Preview] unknow isActive", isTopSession: "[PC Preview] unknow isTopSession", - outputDevice: "[PC Preview] unknow outputDevice" + outputDevice: + "[PC Preview] unknow outputDevice" } - - const AVSessionMock = { + + const AVControlCommandType = ['play', 'pause', 'stop', 'playNext', 'playPrevious', 'fastForward', 'rewind', 'seek', 'setSpeed', 'setLoopMode', 'toggleFavorite']; + + const AVSession = { sessionId: "[PC Preview] unknow sessionId", setAVMetadata: function (...args) { console.warn("AVSession.setAVMetadata interface mocked in the Previewer. How this interface works on the Previewer" + @@ -119,10 +122,10 @@ export function mockMultimediaAVSession() { " may be different from that on a real device.") const len = args.length if (typeof args[len - 1] === 'function') { - args[len - 1].call(this, paramMock.businessErrorMock, AVSessionControllerMock); + args[len - 1].call(this, paramMock.businessErrorMock, AVSessionController); } else { return new Promise((resolve, reject) => { - resolve(AVSessionControllerMock); + resolve(AVSessionController); }) } }, @@ -131,10 +134,10 @@ export function mockMultimediaAVSession() { " may be different from that on a real device.") const len = args.length if (typeof args[len - 1] === 'function') { - args[len - 1].call(this, paramMock.businessErrorMock, OutputDeviceInfoMock); + args[len - 1].call(this, paramMock.businessErrorMock, OutputDeviceInfo); } else { return new Promise((resolve, reject) => { - resolve(OutputDeviceInfoMock); + resolve(OutputDeviceInfo); }) } }, @@ -148,14 +151,14 @@ export function mockMultimediaAVSession() { } else if(args[0] == 'seek' || args[0] == 'setSpeed') { args[len - 1].call(this, paramMock.paramNumberMock); } else if(args[0] == 'setLoopMode') { - var loopModeMock = "[PC Preview] unknow LoopMode"; - args[len - 1].call(this, loopModeMock); + var loopMode = "[PC Preview] unknow LoopMode"; + args[len - 1].call(this, loopMode); } else if(args[0] == 'toggleFavorite') { args[len - 1].call(this, paramMock.paramStringMock); } else if(args[0] == 'handleKeyEvent') { args[len - 1].call(this, paramMock.paramObjectMock); } else if(args[0] == 'outputDeviceChanged') { - args[len - 1].call(this, OutputDeviceInfoMock); + args[len - 1].call(this, OutputDeviceInfo); } }, off: function (...args) { @@ -200,17 +203,17 @@ export function mockMultimediaAVSession() { } } - const AVSessionControllerMock = { + const AVSessionController = { sessionId: "[PC Preview] unknow sessionId", getAVPlaybackState: function (...args) { console.warn("AVSessionController.getAVPlaybackState interface mocked in the Previewer. How this interface works on the Previewer" + " may be different from that on a real device.") const len = args.length if (typeof args[len - 1] === 'function') { - args[len - 1].call(this, paramMock.businessErrorMock, AVPlaybackStateMock); + args[len - 1].call(this, paramMock.businessErrorMock, AVPlaybackState); } else { return new Promise((resolve, reject) => { - resolve(AVPlaybackStateMock); + resolve(AVPlaybackState); }) } }, @@ -219,10 +222,10 @@ export function mockMultimediaAVSession() { " may be different from that on a real device.") const len = args.length if (typeof args[len - 1] === 'function') { - args[len - 1].call(this, paramMock.businessErrorMock, AVMetadataMock); + args[len - 1].call(this, paramMock.businessErrorMock, AVMetadata); } else { return new Promise((resolve, reject) => { - resolve(AVMetadataMock); + resolve(AVMetadata); }) } }, @@ -231,10 +234,10 @@ export function mockMultimediaAVSession() { " may be different from that on a real device.") const len = args.length if (typeof args[len - 1] === 'function') { - args[len - 1].call(this, paramMock.businessErrorMock, OutputDeviceInfoMock); + args[len - 1].call(this, paramMock.businessErrorMock, OutputDeviceInfo); } else { return new Promise((resolve, reject) => { - resolve(OutputDeviceInfoMock); + resolve(OutputDeviceInfo); }) } }, @@ -295,7 +298,6 @@ export function mockMultimediaAVSession() { console.warn("AVSessionController.getValidCommands interface mocked in the Previewer. How this interface works on the Previewer" + " may be different from that on a real device.") const len = args.length - let AVControlCommandType = ['play','pause','stop', 'playNext', 'playPrevious', 'fastForward', 'rewind', 'seek', 'setSpeed', 'setLoopMode', 'toggleFavorite']; if (typeof args[len - 1] === 'function') { args[len - 1].call(this, paramMock.businessErrorMock, AVControlCommandType); } else { @@ -321,18 +323,17 @@ export function mockMultimediaAVSession() { " may be different from that on a real device.") const len = args.length if (args[0] == 'metadataChanged') { - args[len-1].call(this, AVMetadataMock); + args[len-1].call(this, AVMetadata); } else if (args[0] == 'playbackStateChanged') { - args[len-1].call(this, AVPlaybackStateMock); + args[len-1].call(this, AVPlaybackState); } else if (args[0] == 'sessionDestroyed') { args[len-1].call(this); } else if (args[0] == 'activeStateChanged') { args[len-1].call(this, paramMock.paramBooleanMock); } else if (args[0] == 'validCommandChanged') { - let AVControlCommandType = ['play', 'pause', 'stop', 'playNext', 'playPrevious', 'fastForward', 'rewind', 'seek', 'setSpeed', 'setLoopMode', 'toggleFavorite']; args[len-1].call(this, AVControlCommandType); } else if (args[0] == 'outputDeviceChanged') { - args[len-1].call(this, OutputDeviceInfoMock); + args[len-1].call(this, OutputDeviceInfo); } }, off: function (...args) { @@ -347,10 +348,10 @@ export function mockMultimediaAVSession() { " may be different from that on a real device.") const len = args.length if (typeof args[len - 1] === 'function') { - args[len - 1].call(this, paramMock.businessErrorMock, AVSessionMock); + args[len - 1].call(this, paramMock.businessErrorMock, AVSession); } else { return new Promise((resolve, reject) => { - resolve(AVSessionMock); + resolve(AVSession); }) } @@ -359,7 +360,7 @@ export function mockMultimediaAVSession() { console.warn("AVSession.getAllSessionDescriptors interface mocked in the Previewer. How this interface works on the Previewer" + " may be different from that on a real device.") const len = args.length - var desArr = Array(AVSessionDescriptorMock); + var desArr = Array(AVSessionDescriptor); if (typeof args[len - 1] === 'function') { args[len - 1].call(this, paramMock.businessErrorMock, desArr); } else { @@ -373,10 +374,10 @@ export function mockMultimediaAVSession() { " may be different from that on a real device.") const len = args.length if (typeof args[len - 1] === 'function') { - args[len - 1].call(this, paramMock.businessErrorMock, AVSessionControllerMock); + args[len - 1].call(this, paramMock.businessErrorMock, AVSessionController); } else { return new Promise((resolve, reject) => { - resolve(AVSessionControllerMock); + resolve(AVSessionController); }) } }, @@ -397,7 +398,7 @@ export function mockMultimediaAVSession() { " may be different from that on a real device.") const len = args.length if (args[0] == 'sessionCreated' || args[0] == 'sessionDestroyed' || args[0] == 'topSessionChanged') { - args[len - 1].call(this, AVSessionDescriptorMock); + args[len - 1].call(this, AVSessionDescriptor); } else if (args[0] == 'sessionServiceDied') { args[len - 1].call(this); } From 91f0a288501c8161636ce46d418b67efd52b97ba Mon Sep 17 00:00:00 2001 From: binny1024 Date: Tue, 12 Jul 2022 11:08:18 +0800 Subject: [PATCH 063/109] =?UTF-8?q?=E6=96=B0=E5=A2=9E=E4=B8=80=E4=B8=AA?= =?UTF-8?q?=E5=8F=98=E9=87=8F=E5=85=BC=E5=AE=B9=E5=A4=96=E9=83=A8=E5=BC=95?= =?UTF-8?q?=E7=94=A8,=E6=95=B4=E6=94=B9=E6=A0=BC=E5=BC=8F=E9=97=AE?= =?UTF-8?q?=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: zhouyaoying Change-Id: I13d2fdcc56fa2b07e36afaaf3c0076b0f33d8aaf --- .../extend/systemplugin/napi/ohos_display.js | 22 +- .../extend/systemplugin/napi/ohos_screen.js | 69 ++++-- .../extend/systemplugin/napi/ohos_window.js | 198 ++++++++++-------- 3 files changed, 173 insertions(+), 116 deletions(-) diff --git a/runtime/main/extend/systemplugin/napi/ohos_display.js b/runtime/main/extend/systemplugin/napi/ohos_display.js index b3123826..cd7c5f84 100644 --- a/runtime/main/extend/systemplugin/napi/ohos_display.js +++ b/runtime/main/extend/systemplugin/napi/ohos_display.js @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021 Huawei Device Co., Ltd. + * Copyright (c) 2021-2022 Huawei Device Co., Ltd. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at @@ -34,7 +34,7 @@ export const Display = { id: '[PC preview] unknow id', name: '[PC preview] unknow name', alive: '[PC preview] unknow alive', - state: '[PC preview] unknow state', + state: DisplayState, refreshRate: '[PC preview] unknow refreshRate', rotation: '[PC preview] unknow rotation', width: '[PC preview] unknow width', @@ -50,8 +50,8 @@ export function mockDisplay() { const display = { getDefaultDisplay: function (...args) { - console.warn("Display.getDefaultDisplay interface mocked in the Previewer. How this interface works on the Previewer" + - " may be different from that on a real device.") + console.warn("Display.getDefaultDisplay interface mocked in the Previewer. How this interface works on the" + + " Previewer may be different from that on a real device.") const len = args.length if (typeof args[len - 1] === 'function') { args[len - 1].call(this, paramMock.businessErrorMock, Display) @@ -61,9 +61,14 @@ export function mockDisplay() { }) } }, + getDefaultDisplaySync: function (...args) { + console.warn("Display.getDefaultDisplay interface mocked in the Previewer. How this interface works on the Previewer" + + " may be different from that on a real device.") + return Display + }, getAllDisplay: function (...args) { console.warn("Display.getAllDisplay interface mocked in the Previewer. How this interface works on the Previewer" + - " may be different from that on a real device.") + " may be different from that on a real device.") const len = args.length if (typeof args[len - 1] === 'function') { args[len - 1].call(this, paramMock.businessErrorMock, [Display]) @@ -75,7 +80,7 @@ export function mockDisplay() { }, on: function (...args) { console.warn("Display.on interface mocked in the Previewer. How this interface works on the Previewer may be" + - " different from that on a real device.") + " different from that on a real device.") const len = args.length if (len!==2){ console.warn("Display.on:please check params !") @@ -93,7 +98,7 @@ export function mockDisplay() { }, off: function (...args) { console.warn("Display.off interface mocked in the Previewer. How this interface works on the Previewer may be" + - " different from that on a real device.") + " different from that on a real device.") const len = args.length if (len!==2){ console.warn("Display.off:please check params!") @@ -109,8 +114,7 @@ export function mockDisplay() { console.warn("Display.off:please check params, the second parma must be a function!") } }, - DisplayState: DisplayState, - Type: DisplayType + DisplayState } return display } \ No newline at end of file diff --git a/runtime/main/extend/systemplugin/napi/ohos_screen.js b/runtime/main/extend/systemplugin/napi/ohos_screen.js index 577a1225..3740235b 100644 --- a/runtime/main/extend/systemplugin/napi/ohos_screen.js +++ b/runtime/main/extend/systemplugin/napi/ohos_screen.js @@ -46,7 +46,7 @@ export const Screen = { }, setScreenActiveMode: function(...args) { console.warn('Screen.setScreenActiveMode 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); @@ -58,7 +58,7 @@ export const Screen = { }, setDensityDpi: function(...args) { console.warn('Screen.setDensityDpi 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); @@ -105,14 +105,13 @@ const EventTypeMock = { } export function mockScreen() { const screen = { - ExpandOption: ExpandOption, - VirtualScreenOption: VirtualScreenOption, - Orientation: Orientation, - ScreenModeInfo: ScreenModeInfo, - EventType: EventTypeMock, + ExpandOption, + VirtualScreenOption, + Orientation, + ScreenModeInfo, getAllScreens: function(...args) { - console.warn( - 'Screen.getAllScreens interface mocked in the Previewer. How this interface works on the' + ' Previewer may be different from that on a real device.'); + console.warn('Screen.getAllScreens interface mocked in the Previewer. How this interface works on the' + + ' Previewer may be different from that on a real device.'); const len = args.length; if (typeof args[len - 1] === 'function') { args[len - 1].call(this, paramMock.businessErrorMock, allScreenMock); @@ -123,8 +122,8 @@ export function mockScreen() { } }, on: function(...args) { - console.warn( - 'Screen.on interface mocked in the Previewer. How this interface works on the Previewer may be' + ' different from that on a real device.'); + console.warn('Screen.on interface mocked in the Previewer. How this interface works on the Previewer may be' + + ' different from that on a real device.'); const len = args.length; if (len!==2){ console.warn("Screen.on please check params!") @@ -141,8 +140,8 @@ export function mockScreen() { } }, off: function(...args) { - console.warn( - 'Screen.off interface mocked in the Previewer. How this interface works on the Previewer may be' + ' different from that on a real device.'); + console.warn('Screen.off interface mocked in the Previewer. How this interface works on the Previewer may be' + + ' different from that on a real device.'); const len = args.length; if (len!==2){ console.warn("Screen.off please check params!") @@ -159,8 +158,8 @@ export function mockScreen() { } }, makeExpand: function(...args) { - console.warn( - 'Screen.makeExpand interface mocked in the Previewer. How this interface works on the' + ' Previewer may be different from that on a real device.'); + console.warn('Screen.makeExpand interface mocked in the Previewer. How this interface works on the Previewer' + + ' may be different 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); @@ -171,8 +170,8 @@ export function mockScreen() { } }, makeMirror: function(...args) { - console.warn( - 'Screen.makeMirror interface mocked in the Previewer. How this interface works on the' + ' Previewer may be different from that on a real device.'); + console.warn( 'Screen.makeMirror interface mocked in the Previewer. How this interface works on the Previewer' + + ' may be different 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); @@ -183,8 +182,8 @@ export function mockScreen() { } }, createVirtualScreen: function(...args) { - console.warn( - 'Screen.createVirtualScreen interface mocked in the Previewer. How this interface works on the' + ' Previewer may be different from that on a real device.'); + console.warn( 'Screen.createVirtualScreen interface mocked in the Previewer. How this interface works on the' + + ' Previewer may be different from that on a real device.'); const len = args.length; if (typeof args[len - 1] === 'function') { args[len - 1].call(this, paramMock.businessErrorMock, Screen); @@ -195,8 +194,8 @@ export function mockScreen() { } }, destroyVirtualScreen: function(...args) { - console.warn( - 'Screen.destroyVirtualScreen interface mocked in the Previewer. How this interface works on the' + ' Previewer may be different from that on a real device.'); + console.warn('Screen.destroyVirtualScreen interface mocked in the Previewer. How this interface works on the' + + ' Previewer may be different from that on a real device.'); const len = args.length; if (typeof args[len - 1] === 'function') { args[len - 1].call(this, paramMock.businessErrorMock); @@ -207,8 +206,8 @@ export function mockScreen() { } }, setVirtualScreenSurface: function(...args) { - console.warn( - 'Screen.setVirtualScreenSurface interface mocked in the Previewer. How this interface works on the' + ' Previewer may be different from that on a real device.'); + console.warn( 'Screen.setVirtualScreenSurface interface mocked in the Previewer. How this interface works on' + + ' the Previewer may be different from that on a real device.'); const len = args.length; if (typeof args[len - 1] === 'function') { args[len - 1].call(this, paramMock.businessErrorMock); @@ -217,6 +216,30 @@ export function mockScreen() { resolve(); }); } + }, + isScreenRotationLocked: function(...args) { + console.warn( 'Screen.setVirtualScreenSurface interface mocked in the Previewer. How this interface works on' + + ' the Previewer may be different 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); + }); + } + }, + setScreenRotationLocked: function(...args) { + console.warn( 'Screen.setVirtualScreenSurface interface mocked in the Previewer. How this interface works on' + + ' the Previewer may be different 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); + }); + } } } return screen diff --git a/runtime/main/extend/systemplugin/napi/ohos_window.js b/runtime/main/extend/systemplugin/napi/ohos_window.js index 2e3279f9..58327ee4 100644 --- a/runtime/main/extend/systemplugin/napi/ohos_window.js +++ b/runtime/main/extend/systemplugin/napi/ohos_window.js @@ -40,6 +40,22 @@ export const AvoidAreaType= { TYPE_KEYBOARD: 3 } +export const Orientation = { + UNSPECIFIED: 0, + PORTRAIT: 1, + LANDSCAPE: 2, + PORTRAIT_INVERTED: 3, + LANDSCAPE_INVERTED: 4, + AUTO_ROTATION: 5, + AUTO_ROTATION_PORTRAIT: 6, + AUTO_ROTATION_LANDSCAPE: 7, + AUTO_ROTATION_RESTRICTED: 8, + AUTO_ROTATION_PORTRAIT_RESTRICTED: 9, + AUTO_ROTATION_LANDSCAPE_RESTRICTED: 10, + LOCKED: 11 +} + + export const WindowMode= { UNDEFINED: 1, FULLSCREEN: 2, @@ -89,6 +105,7 @@ export const AvoidArea = { rightRect: Rect, bottomRect: Rect } + export const Size = { width: '[PC preview] unknow width', height: '[PC preview] unknow height' @@ -124,7 +141,7 @@ export const WindowStageEventType = { export const WindowStage = { getMainWindow: function(...args) { console.warn("WindowStage.getMainWindow 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, Window) @@ -136,7 +153,7 @@ export const WindowStage = { }, createSubWindow: function(...args) { console.warn("WindowStage.createSubWindow 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, Window) @@ -148,7 +165,7 @@ export const WindowStage = { }, getSubWindow: function(...args) { console.warn("WindowStage.getSubWindow 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, [Window]) @@ -160,7 +177,7 @@ export const WindowStage = { }, loadContent: function(...args) { console.warn("WindowStage.loadContent 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) @@ -172,7 +189,7 @@ export const WindowStage = { }, on: function(...args) { console.warn("WindowStage.on 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') { if (args[0] === 'windowStageEvent') { @@ -186,7 +203,7 @@ export const WindowStage = { }, off: function(...args) { console.warn("WindowStage.off 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') { if (args[0] === 'windowStageEvent') { @@ -200,19 +217,18 @@ export const WindowStage = { }, disableWindowDecor: function() { console.warn("WindowStage.disableWindowDecor 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.") }, setShowOnLockScreen: function() { console.warn("WindowStage.setShowOnLockScreen 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.") } } export const Window = { 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.") + " Previewer may be different from that on a real device.") const len = args.length if (typeof args[len - 1] === 'function') { args[len - 1].call(this, paramMock.businessErrorMock) @@ -224,7 +240,7 @@ export const Window = { }, 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.") + " Previewer may be different from that on a real device.") const len = args.length if (typeof args[len - 1] === 'function') { args[len - 1].call(this, paramMock.businessErrorMock) @@ -236,7 +252,7 @@ export const Window = { }, 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.") + " Previewer may be different from that on a real device.") const len = args.length if (typeof args[len - 1] === 'function') { args[len - 1].call(this, paramMock.businessErrorMock) @@ -248,7 +264,7 @@ export const Window = { }, 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.") + " Previewer may be different from that on a real device.") const len = args.length if (typeof args[len - 1] === 'function') { args[len - 1].call(this, paramMock.businessErrorMock) @@ -260,7 +276,7 @@ export const Window = { }, 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.") + " Previewer may be different from that on a real device.") const len = args.length if (typeof args[len - 1] === 'function') { args[len - 1].call(this, paramMock.businessErrorMock) @@ -272,7 +288,7 @@ export const Window = { }, 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.") + " Previewer may be different from that on a real device.") const len = args.length if (typeof args[len - 1] === 'function') { args[len - 1].call(this, paramMock.businessErrorMock) @@ -284,7 +300,7 @@ export const Window = { }, 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.") + " Previewer may be different from that on a real device.") const len = args.length if (typeof args[len - 1] === 'function') { args[len - 1].call(this, paramMock.businessErrorMock) @@ -296,7 +312,7 @@ export const Window = { }, 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.") + " Previewer may be different from that on a real device.") const len = args.length if (typeof args[len - 1] === 'function') { args[len - 1].call(this, paramMock.businessErrorMock) @@ -308,7 +324,7 @@ export const Window = { }, 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.") + " Previewer may be different from that on a real device.") const len = args.length if (typeof args[len - 1] === 'function') { args[len - 1].call(this, paramMock.businessErrorMock) @@ -320,7 +336,7 @@ export const Window = { }, 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.") + " Previewer may be different from that on a real device.") const len = args.length if (typeof args[len - 1] === 'function') { args[len - 1].call(this, paramMock.businessErrorMock) @@ -332,7 +348,7 @@ export const Window = { }, 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.") + " Previewer may be different from that on a real device.") const len = args.length if (typeof args[len - 1] === 'function') { args[len - 1].call(this, paramMock.businessErrorMock) @@ -344,7 +360,7 @@ export const Window = { }, 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.") + " Previewer may be different from that on a real device.") const len = args.length if (typeof args[len - 1] === 'function') { args[len - 1].call(this, paramMock.businessErrorMock) @@ -354,9 +370,21 @@ export const Window = { }) } }, + setPreferredOrientation: function(...args) { + console.warn("Window.setPreferredOrientation interface mocked in the Previewer. How this interface works on the" + + " Previewer may be different from that on a real device.") + const len = args.length + if (typeof args[len - 1] === 'function') { + args[len - 1].call(this, paramMock.businessErrorMock,Orientation) + } else { + return new Promise((resolve) => { + resolve(Orientation) + }) + } + }, setForbidSplitMove: function(...args) { console.warn("Window.setForbidSplitMove 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) @@ -368,7 +396,7 @@ export const Window = { }, 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.") + " Previewer may be different from that on a real device.") const len = args.length if (typeof args[len - 1] === 'function') { args[len - 1].call(this, paramMock.businessErrorMock, WindowProperties) @@ -380,7 +408,7 @@ export const Window = { }, 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.") + " Previewer may be different from that on a real device.") const len = args.length if (typeof args[len - 1] === 'function') { args[len - 1].call(this, paramMock.businessErrorMock, AvoidArea) @@ -392,7 +420,7 @@ export const Window = { }, 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.") + " Previewer may be different from that on a real device.") const len = args.length if (typeof args[len - 1] === 'function') { args[len - 1].call(this, paramMock.businessErrorMock) @@ -404,7 +432,7 @@ export const Window = { }, 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.") + " Previewer may be different from that on a real device.") const len = args.length if (typeof args[len - 1] === 'function') { args[len - 1].call(this, paramMock.businessErrorMock) @@ -416,7 +444,7 @@ export const Window = { }, 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.") + " Previewer may be different from that on a real device.") const len = args.length if (typeof args[len - 1] === 'function') { args[len - 1].call(this, paramMock.businessErrorMock) @@ -428,7 +456,7 @@ export const Window = { }, 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.") + " Previewer may be different from that on a real device.") const len = args.length if (typeof args[len - 1] === 'function') { args[len - 1].call(this, paramMock.businessErrorMock) @@ -440,7 +468,7 @@ export const Window = { }, 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.") + " Previewer may be different from that on a real device.") const len = args.length if (typeof args[len - 1] === 'function') { args[len - 1].call(this, paramMock.businessErrorMock) @@ -452,7 +480,7 @@ export const Window = { }, 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.") + " Previewer may be different from that on a real device.") const len = args.length if (typeof args[len - 1] === 'function') { args[len - 1].call(this, paramMock.businessErrorMock) @@ -464,7 +492,7 @@ export const Window = { }, 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.") + " Previewer may be different 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) @@ -476,7 +504,7 @@ export const Window = { }, 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.") + " Previewer may be different from that on a real device.") const len = args.length if (typeof args[len - 1] === 'function') { args[len - 1].call(this, paramMock.businessErrorMock) @@ -488,7 +516,7 @@ export const Window = { }, 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.") + " Previewer may be different from that on a real device.") const len = args.length if (typeof args[len - 1] === 'function') { args[len - 1].call(this, paramMock.businessErrorMock) @@ -500,39 +528,39 @@ export const Window = { }, 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.") + " different from that on a real device.") const len = args.length; if (typeof args[len - 1] === 'function') { if (args[0] === 'keyboardHeightChange'|| args[0] === 'systemAvoidAreaChange' || args[0] === 'windowSizeChange'|| args[0] === 'touchOutside'|| args[0] === 'avoidAreaChange' ){ - console.warn(`you has registered ${args[0]} event`) + console.warn(`Window.on you has registered ${args[0]} event`) } else { - console.warn("on:please check first param!") + console.warn("Window.on please check first param!") } } else { - console.warn("on:please check param!") + console.warn("Window.on please check param!") } }, off: function(...args) { console.warn("Window.off interface mocked in the Previewer. How this interface works on the Previewer may be" + - " different from that on a real device.") + " different from that on a real device.") const len = args.length; if (typeof args[len - 1] === 'function') { if (args[0] === 'keyboardHeightChange'|| args[0] === 'systemAvoidAreaChange' || args[0] === 'windowSizeChange'|| args[0] === 'touchOutside'|| args[0] === 'avoidAreaChange' ){ - console.warn(`you has registered ${args[0]} event`) + console.warn(`Window.off you has registered ${args[0]} event`) } else { - console.warn("off:please check first param!") + console.warn("Window.off please check first param!") } } else { - console.warn("off:please check param!") + console.warn("Window.off please check param!") } }, setColorSpace: function(...args) { console.warn("Window.setColorSpace 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) @@ -544,7 +572,7 @@ export const Window = { }, getColorSpace: function(...args) { console.warn("Window.getColorSpace 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, paramMock.paramNumberMock) @@ -556,7 +584,7 @@ export const Window = { }, isSupportWideGamut: function(...args) { console.warn("Window.isSupportWideGamut interface mocked in the Previewer. How this interface works on the" + - " Previewer may be different from that on a real device.") + " Previewer may be different from that on a real device.") const len = args.length if (typeof args[len - 1] === 'function') { args[len - 1].call(this, paramMock.businessErrorMock, paramMock.paramBooleanMock) @@ -568,12 +596,14 @@ export const Window = { }, } +export const windowMock = Window + export function mockWindow() { const window = { getTopWindow: function(...args) { - console.warn( - "Window.getTopWindow interface mocked in the Previewer. How this interface works on the Previewer" + " may be different from that on a real device.") + console.warn("Window.getTopWindow interface mocked in the Previewer. How this interface works on the Previewer" + + "may be different from that on a real device.") const len = args.length if (typeof args[len - 1] === 'function') { args[len - 1].call(this, paramMock.businessErrorMock, Window) @@ -584,8 +614,8 @@ 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.") + console.warn("Window.create interface mocked in the Previewer. How this interface works on the Previewer may" + + " be different from that on a real device.") const len = args.length if (typeof args[len - 1] === 'function') { args[len - 1].call(this, paramMock.businessErrorMock, Window) @@ -596,8 +626,8 @@ 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.") + console.warn("Window.find interface mocked in the Previewer. How this interface works on the Previewer may be" + + " different from that on a real device.") const len = args.length if (typeof args[len - 1] === 'function') { args[len - 1].call(this, paramMock.businessErrorMock, Window) @@ -608,8 +638,8 @@ export function mockWindow() { } }, 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.") + 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) @@ -620,8 +650,8 @@ export function mockWindow() { } }, 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.") + 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) @@ -632,8 +662,8 @@ export function mockWindow() { } }, minimizeAll: function(...args) { - console.warn( - "Window.minimizeAll interface mocked in the Previewer. How this interface works on the Previewer" + " may be different from that on a real device.") + console.warn("Window.minimizeAll interface mocked in the Previewer. How this interface works on the Previewer" + + " may be different from that on a real device.") const len = args.length if (typeof args[len - 1] === 'function') { args[len - 1].call(this, paramMock.businessErrorMock) @@ -644,8 +674,8 @@ export function mockWindow() { } }, toggleShownStateForAllAppWindows: function(...args) { - console.warn( - "Window.toggleShownStateForAllAppWindows interface mocked in the Previewer. How this interface works on the Previewer" + " may be different from that on a real device.") + console.warn("Window.toggleShownStateForAllAppWindows interface mocked in the Previewer. How this interface" + + " works on the Previewer may be different from that on a real device.") const len = args.length if (typeof args[len - 1] === 'function') { args[len - 1].call(this, paramMock.businessErrorMock) @@ -656,8 +686,8 @@ export function mockWindow() { } }, setWindowLayoutMode: function(...args) { - console.warn( - "Window.setWindowLayoutMode interface mocked in the Previewer. How this interface works on the Previewer" + " may be different from that on a real device.") + console.warn("Window.setWindowLayoutMode interface mocked in the Previewer. How this interface works on the" + + " Previewer may be different from that on a real device.") const len = args.length if (typeof args[len - 1] === 'function') { args[len - 1].call(this, paramMock.businessErrorMock) @@ -668,47 +698,47 @@ export function mockWindow() { } }, 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.") + console.warn("Window.on interface mocked in the Previewer. How this interface works on the Previewer may be" + + " different from that on a real device.") const len = args.length if (typeof args[len - 1] === 'function') { if (args[0] === 'systemBarTintChange') { - console.warn(`you has registered ${args[0]} event`) + console.warn(`Window.on you has registered ${args[0]} event`) } else { - console.warn("on:please check first param!") + console.warn("Window.on please check first param!") } } else { - console.warn("on:please check param!") + console.warn("Window.on please check param!") } }, off: function(...args) { - console.warn( - "Window.off interface mocked in the Previewer. How this interface works on the Previewer" + " may be different from that on a real device.") + console.warn("Window.off interface mocked in the Previewer. How this interface works on the Previewer may be" + + " different from that on a real device.") const len = args.length if (typeof args[len - 1] === 'function') { if (args[0] === 'systemBarTintChange') { - console.warn(`you has registered ${args[0]} event`) + console.warn(`Window.off you has registered ${args[0]} event`) } else { - console.warn("off:please check first param!") + console.warn("Window.off please check first param!") } } else { - console.warn("off:please check param!") + console.warn("Window.off please check param!") } }, - WindowType: WindowType, - AvoidAreaType: AvoidAreaType, - WindowMode: WindowMode, - WindowLayoutMode: WindowLayoutMode, - SystemBarProperties: SystemBarProperties, - SystemBarRegionTint: SystemBarRegionTint, - SystemBarTintState: SystemBarTintState, - Rect: Rect, - AvoidArea: AvoidArea, - Size: Size, - WindowProperties: WindowProperties, - ColorSpace: ColorSpace, - WindowStageEventType: WindowStageEventType, - WindowStage: WindowStage + WindowType, + AvoidAreaType, + WindowMode, + WindowLayoutMode, + SystemBarProperties, + SystemBarRegionTint, + SystemBarTintState, + Rect, + AvoidArea, + Size, + WindowProperties, + ColorSpace, + WindowStageEventType, + WindowStage } return window } From e46bb4f3ec2e4e085c177bad822a35fa60a0e63c Mon Sep 17 00:00:00 2001 From: ruan-shaofei Date: Mon, 11 Jul 2022 17:33:30 +0800 Subject: [PATCH 064/109] location js api mock Signed-off-by: ruan-shaofei --- .../systemplugin/napi/ohos_geolocation.js | 210 ++++++++++++++++-- 1 file changed, 194 insertions(+), 16 deletions(-) diff --git a/runtime/main/extend/systemplugin/napi/ohos_geolocation.js b/runtime/main/extend/systemplugin/napi/ohos_geolocation.js index c234ce77..011a3f7b 100644 --- a/runtime/main/extend/systemplugin/napi/ohos_geolocation.js +++ b/runtime/main/extend/systemplugin/napi/ohos_geolocation.js @@ -16,7 +16,7 @@ import { paramMock } from "../utils" export function mockOhosGeolocation() { - const LocationMock = { + const Location = { latitude: '[PC preview] unknow latitude', longitude: '[PC preview] unknow longitude', altitude: '[PC preview] unknow altitude', @@ -25,10 +25,10 @@ export function mockOhosGeolocation() { timeStamp: '[PC preview] unknow timeStamp', direction: '[PC preview] unknow direction', timeSinceBoot: '[PC preview] unknow timeSinceBoot', - additions: '[PC preview] unknow additions', + additions: [paramMock.paramStringMock], additionSize: '[PC preview] unknow additionSize', } - const GeoAddressMock = { + const GeoAddress = { latitude: '[PC preview] unknow latitude', longitude: '[PC preview] unknow longitude', locale: '[PC preview] unknow locale', @@ -45,9 +45,27 @@ export function mockOhosGeolocation() { postalCode: '[PC preview] unknow postalCode', phoneNumber: '[PC preview] unknow phoneNumber', addressUrl: '[PC preview] unknow addressUrl', - descriptions: '[PC preview] unknow descriptions', + descriptions: [paramMock.paramStringMock], descriptionsSize: '[PC preview] unknow descriptionsSize', } + const SatelliteStatusInfo = { + satellitesNumber: '[PC preview] unknow satellitesNumber', + satelliteIds: [paramMock.paramNumberMock], + carrierToNoiseDensitys: [paramMock.paramNumberMock], + altitudes: [paramMock.paramNumberMock], + azimuths: [paramMock.paramNumberMock], + carrierFrequencies: [paramMock.paramNumberMock], + } + const CountryCodeType = { + COUNTRY_CODE_FROM_LOCALE: 1, + COUNTRY_CODE_FROM_SIM: 2, + COUNTRY_CODE_FROM_LOCATION: 3, + COUNTRY_CODE_FROM_NETWORK: 4, + } + const CountryCode = { + country: '[PC preview] unknow country', + type: CountryCodeType, + } const geolocation = { on: function (...args) { console.warn("geolocation.on interface mocked in the Previewer. How this interface works on the" + @@ -55,9 +73,17 @@ export function mockOhosGeolocation() { const len = args.length; if (typeof args[len - 1] === 'function') { if (args[0] == 'locationChange') { - args[len - 1].call(this, LocationMock); + args[len - 1].call(this, Location); } else if (args[0] == 'locationServiceState') { - args[len - 1].call(this, paramMock.paramBooleanMock); + args[len - 1].call(this, paramMock.paramBooleanMock); + } else if (args[0] == 'cachedGnssLocationsReporting') { + args[len - 1].call(this, [Location]); + } else if (args[0] == 'gnssStatusChange') { + args[len - 1].call(this, SatelliteStatusInfo); + } else if (args[0] == 'nmeaMessageChange') { + args[len - 1].call(this, paramMock.paramStringMock); + } else if (args[0] == 'countryCodeChange') { + args[len - 1].call(this, CountryCode); } } }, @@ -67,9 +93,17 @@ export function mockOhosGeolocation() { const len = args.length; if (typeof args[len - 1] === 'function') { if (args[0] == 'locationChange') { - args[len - 1].call(this, LocationMock); + args[len - 1].call(this, Location); } else if (args[0] == 'locationServiceState') { - args[len - 1].call(this, paramMock.paramBooleanMock); + args[len - 1].call(this, paramMock.paramBooleanMock); + } else if (args[0] == 'cachedGnssLocationsReporting') { + args[len - 1].call(this, [Location]); + } else if (args[0] == 'gnssStatusChange') { + args[len - 1].call(this, SatelliteStatusInfo); + } else if (args[0] == 'nmeaMessageChange') { + args[len - 1].call(this, paramMock.paramStringMock); + } else if (args[0] == 'countryCodeChange') { + args[len - 1].call(this, CountryCode); } } }, @@ -78,10 +112,10 @@ export function mockOhosGeolocation() { " Previewer may be different from that on a real device."); const len = args.length; if (typeof args[len - 1] === 'function') { - args[len - 1].call(this, paramMock.businessErrorMock, LocationMock); + args[len - 1].call(this, paramMock.businessErrorMock, Location); } else { return new Promise((resolve) => { - resolve(LocationMock); + resolve(Location); }); } }, @@ -90,10 +124,10 @@ export function mockOhosGeolocation() { " Previewer may be different from that on a real device."); const len = args.length; if (typeof args[len - 1] === 'function') { - args[len - 1].call(this, paramMock.businessErrorMock, LocationMock); + args[len - 1].call(this, paramMock.businessErrorMock, Location); } else { return new Promise((resolve) => { - resolve(LocationMock); + resolve(Location); }); } }, @@ -150,10 +184,10 @@ export function mockOhosGeolocation() { " Previewer may be different from that on a real device."); const len = args.length; if (typeof args[len - 1] === 'function') { - args[len - 1].call(this, paramMock.businessErrorMock, [GeoAddressMock]); + args[len - 1].call(this, paramMock.businessErrorMock, [GeoAddress]); } else { return new Promise((resolve) => { - resolve([GeoAddressMock]); + resolve([GeoAddress]); }); } }, @@ -162,10 +196,10 @@ export function mockOhosGeolocation() { " Previewer may be different from that on a real device."); const len = args.length; if (typeof args[len - 1] === 'function') { - args[len - 1].call(this, paramMock.businessErrorMock, [GeoAddressMock]); + args[len - 1].call(this, paramMock.businessErrorMock, [GeoAddress]); } else { return new Promise((resolve) => { - resolve([GeoAddressMock]); + resolve([GeoAddress]); }); } }, @@ -181,6 +215,150 @@ export function mockOhosGeolocation() { }); } }, + getCachedGnssLocationsSize: function (...args) { + console.warn("geolocation.getCachedGnssLocationsSize interface mocked in the Previewer. How this interface works on the" + + " Previewer may be different 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); + }); + } + }, + flushCachedGnssLocations: function (...args) { + console.warn("geolocation.flushCachedGnssLocations interface mocked in the Previewer. How this interface works on the" + + " Previewer may be different 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); + }); + } + }, + sendCommand: function (...args) { + console.warn("geolocation.sendCommand interface mocked in the Previewer. How this interface works on the" + + " Previewer may be different 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); + }); + } + }, + getCountryCode: function (...args) { + console.warn("geolocation.getCountryCode interface mocked in the Previewer. How this interface works on the" + + " Previewer may be different from that on a real device."); + const len = args.length; + if (typeof args[len - 1] === 'function') { + args[len - 1].call(this, paramMock.businessErrorMock, CountryCode); + } else { + return new Promise((resolve) => { + resolve(CountryCode); + }); + } + }, + enableLocationMock: function (...args) { + console.warn("geolocation.enableLocationMock interface mocked in the Previewer. How this interface works on the" + + " Previewer may be different from that on a 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(); + }); + } + }, + disableLocationMock: function (...args) { + console.warn("geolocation.disableLocationMock interface mocked in the Previewer. How this interface works on the" + + " Previewer may be different from that on a 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(); + }); + } + }, + setMockedLocations: function (...args) { + console.warn("geolocation.setMockedLocations interface mocked in the Previewer. How this interface works on the" + + " Previewer may be different from that on a 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(); + }); + } + }, + enableReverseGeocodingMock: function (...args) { + console.warn("geolocation.enableReverseGeocodingMock interface mocked in the Previewer. How this interface works on the" + + " Previewer may be different from that on a 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(); + }); + } + }, + disableReverseGeocodingMock: function (...args) { + console.warn("geolocation.disableReverseGeocodingMock interface mocked in the Previewer. How this interface works on the" + + " Previewer may be different from that on a 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(); + }); + } + }, + setReverseGeocodingMockInfo: function (...args) { + console.warn("geolocation.setReverseGeocodingMockInfo interface mocked in the Previewer. How this interface works on the" + + " Previewer may be different from that on a 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(); + }); + } + }, + isLocationPrivacyConfirmed: function (...args) { + console.warn("geolocation.isLocationPrivacyConfirmed interface mocked in the Previewer. How this interface works on the" + + " Previewer may be different 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); + }); + } + }, + setLocationPrivacyConfirmStatus: function (...args) { + console.warn("geolocation.setLocationPrivacyConfirmStatus interface mocked in the Previewer. How this interface works on the" + + " Previewer may be different 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); + }); + } + }, } return geolocation } From 7f69923f8a81ebb1fe32b635bc77d14655bb2148 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=A9=AC=E6=A0=B9=E5=A0=82?= Date: Tue, 12 Jul 2022 12:10:05 +0000 Subject: [PATCH 065/109] update runtime/main/extend/systemplugin/napi/ohos_rpc.js. Signed-off-by: magentang --- .../main/extend/systemplugin/napi/ohos_rpc.js | 29 ++++++++++--------- 1 file changed, 16 insertions(+), 13 deletions(-) diff --git a/runtime/main/extend/systemplugin/napi/ohos_rpc.js b/runtime/main/extend/systemplugin/napi/ohos_rpc.js index a5141d9c..f8f0d322 100644 --- a/runtime/main/extend/systemplugin/napi/ohos_rpc.js +++ b/runtime/main/extend/systemplugin/napi/ohos_rpc.js @@ -428,12 +428,12 @@ export const MessageOptionClass = class MessageOption { console.warn("MessageOption.setWaitTime interface mocked in the Previewer. How this interface works on the" + " Previewer may be different from that on a real device.") }; + this.TF_SYNC = 0; + this.TF_ASYNC = 1; + this.TF_ACCEPT_FDS = 0x10; + this.TF_WAIT_TIME = 4; } }; -MessageOptionClass.TF_SYNC = '[PC preview] unknow TF_SYNC'; -MessageOptionClass.TF_ASYNC = '[PC preview] unknow TF_ASYNC'; -MessageOptionClass.TF_ACCEPT_FDS = '[PC preview] unknow TF_ACCEPT_FDS'; -MessageOptionClass.TF_WAIT_TIME = '[PC preview] unknow TF_WAIT_TIME'; export const AshmemClass = class Ashmem { constructor() { console.warn('rpc.Ashmem constructor interface mocked in the Previewer. How this interface works on the' + @@ -481,6 +481,10 @@ export const AshmemClass = class Ashmem { ' Previewer may be different from that on a real device.') return paramMock.paramArrayMock }; + this.PROT_EXEC = 4; + this.PROT_NONE = 0; + this.PROT_READ = 1; + this.PROT_WRITE = 2; } }; AshmemClass.createAshmem = function (...args) { @@ -493,10 +497,6 @@ AshmemClass.createAshmemFromExisting = function (...args) { ' Previewer may be different from that on a real device.') return new AshmemClass() }; -AshmemClass.PROT_EXEC = '[PC preview] unknow PROT_EXEC'; -AshmemClass.PROT_NONE = '[PC preview] unknow PROT_NONE'; -AshmemClass.PROT_READ = '[PC preview] unknow PROT_READ'; -AshmemClass.PROT_WRITE = '[PC preview] unknow PROT_WRITE'; export const RemoteObjectClass = class RemoteObject { constructor(...args) { console.warn("rpc.RemoteObject constructor interface mocked in the Previewer. How this interface works on the" + @@ -600,13 +600,16 @@ export const RemoteProxyClass = class RemoteProxy { }) } }; + this.PING_TRANSACTION = ('_'.charCodeAt(0) << 24) | ('P'.charCodeAt(0) << 16) | + ('N'.charCodeAt(0) << 8) | 'G'.charCodeAt(0); + this.DUMP_TRANSACTION = ('_'.charCodeAt(0) << 24) | ('D'.charCodeAt(0) << 16) | + ('M'.charCodeAt(0) << 8) | 'P'.charCodeAt(0); + this.INTERFACE_TRANSACTION = ('_'.charCodeAt(0) << 24) | ('N'.charCodeAt(0) << 16) | + ('T'.charCodeAt(0) << 8) | 'F'.charCodeAt(0); + this.MIN_TRANSACTION_ID = 0x1; + this.MAX_TRANSACTION_ID = 0x00FFFFFF; } }; -RemoteProxyClass.PING_TRANSACTION = '[PC preview] unknow PING_TRANSACTION'; -RemoteProxyClass.DUMP_TRANSACTION = '[PC preview] unknow DUMP_TRANSACTION'; -RemoteProxyClass.INTERFACE_TRANSACTION = '[PC preview] unknow INTERFACE_TRANSACTION'; -RemoteProxyClass.MIN_TRANSACTION_ID = '[PC preview] unknow MIN_TRANSACTION_ID'; -RemoteProxyClass.MAX_TRANSACTION_ID = '[PC preview] unknow MAX_TRANSACTION_ID'; export const IRemoteObjectMock = { queryLocalInterface: function (...args) { console.warn("IRemoteObject.queryLocalInterface interface mocked in the Previewer. How this interface works on the" + From 18ad3d513afd7b59a974c54458f2d9220b725efe Mon Sep 17 00:00:00 2001 From: zhangxingxia Date: Wed, 13 Jul 2022 19:28:47 +0800 Subject: [PATCH 066/109] update js mock Signed-off-by: zhangxingxia --- runtime/main/extend/systemplugin/napi/index.js | 4 ++-- .../extend/systemplugin/napi/ohos_fileManager.js | 16 ++++++++++++---- .../systemplugin/napi/ohos_securitylabel.js | 9 +++++++++ 3 files changed, 23 insertions(+), 6 deletions(-) diff --git a/runtime/main/extend/systemplugin/napi/index.js b/runtime/main/extend/systemplugin/napi/index.js index 6f709cac..704dc192 100644 --- a/runtime/main/extend/systemplugin/napi/index.js +++ b/runtime/main/extend/systemplugin/napi/index.js @@ -390,7 +390,7 @@ export function mockRequireNapiFun() { return mockConvertXml(); case "statfs": return mockStatfs(); - case "filemanager": + case "fileManager": return mockFileManager(); case "environment": return mockEnvironment(); @@ -410,7 +410,7 @@ export function mockRequireNapiFun() { return mockBackgroundTaskManager(); case "bundleState": return mockBundleState(); - case "securitylabel": + case "securityLabel": return mockSecurityLabel(); case "workScheduler": return mockWorkScheduler(); diff --git a/runtime/main/extend/systemplugin/napi/ohos_fileManager.js b/runtime/main/extend/systemplugin/napi/ohos_fileManager.js index f06e905c..47ae70a4 100644 --- a/runtime/main/extend/systemplugin/napi/ohos_fileManager.js +++ b/runtime/main/extend/systemplugin/napi/ohos_fileManager.js @@ -16,16 +16,24 @@ import { paramMock } from "../utils" export function mockFileManager() { + const fileInfoMock = { + name: '[PC preview] unknow name', + path: '[PC preview] unknow path', + type: '[PC preview] unknow type', + size: '[PC preview] unknow size', + addedTime: '[PC preview] unknow addedTime', + modifiedTime: '[PC preview] unknow modifiedTime', + }; const filemanager = { getRoot: function (...args) { console.warn("filemanager.getRoot interface mocked in the Previewer. How this interface works on the" + " Previewer may be different from that on a real device.") const len = args.length if (typeof args[len - 1] === 'function') { - args[len - 1].call(this, paramMock.businessErrorMock, paramMock.paramArrayMock) + args[len - 1].call(this, paramMock.businessErrorMock, Array(fileInfoMock)) } else { return new Promise((resolve, reject) => { - resolve(paramMock.paramArrayMock); + resolve(Array(fileInfoMock)); }) } }, @@ -34,10 +42,10 @@ export function mockFileManager() { " Previewer may be different from that on a real device.") const len = args.length if (typeof args[len - 1] === 'function') { - args[len - 1].call(this, paramMock.businessErrorMock, paramMock.paramArrayMock) + args[len - 1].call(this, paramMock.businessErrorMock, Array(fileInfoMock)) } else { return new Promise((resolve, reject) => { - resolve(paramMock.paramArrayMock); + resolve(Array(fileInfoMock)); }) } }, diff --git a/runtime/main/extend/systemplugin/napi/ohos_securitylabel.js b/runtime/main/extend/systemplugin/napi/ohos_securitylabel.js index 3189193f..3270c0a2 100644 --- a/runtime/main/extend/systemplugin/napi/ohos_securitylabel.js +++ b/runtime/main/extend/systemplugin/napi/ohos_securitylabel.js @@ -29,6 +29,10 @@ export function mockSecurityLabel() { }) } }, + setSecurityLabelSync: function (...args) { + console.warn("securitylabel.setSecurityLabelSync interface mocked in the Previewer. How this interface works on the" + + " Previewer may be different from that on a real device.") + }, getSecurityLabel: function (...args) { console.warn("securitylabel.getSecurityLabel interface mocked in the Previewer. How this interface works on the" + " Previewer may be different from that on a real device.") @@ -41,6 +45,11 @@ export function mockSecurityLabel() { }) } }, + getSecurityLabelSync: function (...args) { + console.warn("securitylabel.getSecurityLabelSync interface mocked in the Previewer. How this interface works on the" + + " Previewer may be different from that on a real device.") + return paramMock.paramStringMock; + }, } return securitylabel; } From 94b4d6951a7dbee616ec7a8c1dd29b582275215b Mon Sep 17 00:00:00 2001 From: wuyongning Date: Wed, 13 Jul 2022 19:26:25 +0800 Subject: [PATCH 067/109] =?UTF-8?q?=E6=95=B4=E6=94=B9rdb=20mock?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 修改检视意见 modify copyright Signed-off-by: wuyongning --- .../systemplugin/napi/data/rdb/resultSet.js | 97 +++++++++++++++++ .../extend/systemplugin/napi/ohos_data_rdb.js | 102 ++++-------------- 2 files changed, 115 insertions(+), 84 deletions(-) create mode 100644 runtime/main/extend/systemplugin/napi/data/rdb/resultSet.js diff --git a/runtime/main/extend/systemplugin/napi/data/rdb/resultSet.js b/runtime/main/extend/systemplugin/napi/data/rdb/resultSet.js new file mode 100644 index 00000000..25a16440 --- /dev/null +++ b/runtime/main/extend/systemplugin/napi/data/rdb/resultSet.js @@ -0,0 +1,97 @@ +/* + * Copyright (c) 2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { paramMock } from "../../../utils" + +export const resultSet = { + columnNames: [paramMock.paramStringMock], + columnCount: "[PC Preview] unknow columnCount", + rowCount: "[PC Preview] unknow rowCount", + rowIndex: "[PC Preview] unknow rowIndex", + isAtFirstRow: "[PC Preview] unknow isAtFirstRow", + isAtLastRow: "[PC Preview] unknow isAtLastRow", + isEnded: "[PC Preview] unknow isEnded", + isStarted: "[PC Preview] unknow isStarted", + isClosed: "[PC Preview] unknow isClosed", + getColumnIndex: function (...args) { + console.warn("ResultSet.getColumnIndex interface mocked in the Previewer. How this interface works on the" + + " Previewer may be different from that on a real device.") + return paramMock.paramNumberMock; + }, + getColumnName: function (...args) { + console.warn("ResultSet.getColumnName interface mocked in the Previewer. How this interface works on the" + + " Previewer may be different from that on a real device.") + return paramMock.paramStringMock; + }, + goTo: function (...args) { + console.warn("ResultSet.goTo interface mocked in the Previewer. How this interface works on the" + + " Previewer may be different from that on a real device.") + return paramMock.paramBooleanMock; + }, + goToRow: function (...args) { + console.warn("ResultSet.goToRow interface mocked in the Previewer. How this interface works on the" + + " Previewer may be different from that on a real device.") + return paramMock.paramBooleanMock; + }, + goToFirstRow: function (...args) { + console.warn("ResultSet.goToFirstRow interface mocked in the Previewer. How this interface works on the" + + " Previewer may be different from that on a real device.") + return paramMock.paramBooleanMock; + }, + goToLastRow: function (...args) { + console.warn("ResultSet.goToLastRow interface mocked in the Previewer. How this interface works on the" + + " Previewer may be different from that on a real device.") + return paramMock.paramBooleanMock; + }, + goToNextRow: function (...args) { + console.warn("ResultSet.goToNextRow interface mocked in the Previewer. How this interface works on the" + + " Previewer may be different from that on a real device.") + return paramMock.paramBooleanMock; + }, + goToPreviousRow: function (...args) { + console.warn("ResultSet.goToPreviousRow interface mocked in the Previewer. How this interface works on the" + + " Previewer may be different from that on a real device.") + return paramMock.paramBooleanMock; + }, + getBlob: function (...args) { + console.warn("ResultSet.getBlob interface mocked in the Previewer. How this interface works on the" + + " Previewer may be different from that on a real device.") + return paramMock.paramObjectMock; + }, + getString: function (...args) { + console.warn("ResultSet.getString interface mocked in the Previewer. How this interface works on the" + + " Previewer may be different from that on a real device.") + return paramMock.paramStringMock; + }, + getLong: function (...args) { + console.warn("ResultSet.getLong interface mocked in the Previewer. How this interface works on the" + + " Previewer may be different from that on a real device.") + return paramMock.paramNumberMock; + }, + getDouble: function (...args) { + console.warn("ResultSet.getDouble interface mocked in the Previewer. How this interface works on the" + + " Previewer may be different from that on a real device.") + return paramMock.paramNumberMock; + }, + isColumnNull: function (...args) { + console.warn("ResultSet.isColumnNull interface mocked in the Previewer. How this interface works on the" + + " Previewer may be different from that on a real device.") + return paramMock.paramBooleanMock; + }, + close: function (...args) { + console.warn("ResultSet.close interface mocked in the Previewer. How this interface works on the" + + " Previewer may be different from that on a real device.") + }, +} diff --git a/runtime/main/extend/systemplugin/napi/ohos_data_rdb.js b/runtime/main/extend/systemplugin/napi/ohos_data_rdb.js index 403eefdd..795a2642 100644 --- a/runtime/main/extend/systemplugin/napi/ohos_data_rdb.js +++ b/runtime/main/extend/systemplugin/napi/ohos_data_rdb.js @@ -14,6 +14,7 @@ */ import { paramMock } from "../utils" +import { resultSet } from "./data/rdb/resultSet" export const RdbPredicatesClass = class RdbPredicates { constructor(...args) { @@ -200,86 +201,7 @@ export function mockRdb() { }, RdbPredicates: RdbPredicatesClass }; - const resultSetMock = { - columnNames: "[[PC Preview] unknow columnNames]", - columnCount: "[PC Preview] unknow columnCount", - rowCount: "[PC Preview] unknow rowCount", - rowIndex: "[PC Preview] unknow rowIndex", - isAtFirstRow: "[PC Preview] unknow isAtFirstRow", - isAtLastRow: "[PC Preview] unknow isAtLastRow", - isEnded: "[PC Preview] unknow isEnded", - isStarted: "[PC Preview] unknow isStarted", - isClosed: "[PC Preview] unknow isClosed", - getColumnIndex: function (...args) { - console.warn("ResultSet.getColumnIndex interface mocked in the Previewer. How this interface works on the" + - " Previewer may be different from that on a real device.") - return paramMock.paramNumberMock; - }, - getColumnName: function (...args) { - console.warn("ResultSet.getColumnName interface mocked in the Previewer. How this interface works on the" + - " Previewer may be different from that on a real device.") - return paramMock.paramStringMock; - }, - goTo: function (...args) { - console.warn("ResultSet.goTo interface mocked in the Previewer. How this interface works on the" + - " Previewer may be different from that on a real device.") - return paramMock.paramBooleanMock; - }, - goToRow: function (...args) { - console.warn("ResultSet.goToRow interface mocked in the Previewer. How this interface works on the" + - " Previewer may be different from that on a real device.") - return paramMock.paramBooleanMock; - }, - goToFirstRow: function (...args) { - console.warn("ResultSet.goToFirstRow interface mocked in the Previewer. How this interface works on the" + - " Previewer may be different from that on a real device.") - return paramMock.paramBooleanMock; - }, - goToLastRow: function (...args) { - console.warn("ResultSet.goToLastRow interface mocked in the Previewer. How this interface works on the" + - " Previewer may be different from that on a real device.") - return paramMock.paramBooleanMock; - }, - goToNextRow: function (...args) { - console.warn("ResultSet.goToNextRow interface mocked in the Previewer. How this interface works on the" + - " Previewer may be different from that on a real device.") - return paramMock.paramBooleanMock; - }, - goToPreviousRow: function (...args) { - console.warn("ResultSet.goToPreviousRow interface mocked in the Previewer. How this interface works on the" + - " Previewer may be different from that on a real device.") - return paramMock.paramBooleanMock; - }, - getBlob: function (...args) { - console.warn("ResultSet.getBlob interface mocked in the Previewer. How this interface works on the" + - " Previewer may be different from that on a real device.") - return paramMock.paramObjectMock; - }, - getString: function (...args) { - console.warn("ResultSet.getString interface mocked in the Previewer. How this interface works on the" + - " Previewer may be different from that on a real device.") - return paramMock.paramStringMock; - }, - getLong: function (...args) { - console.warn("ResultSet.getLong interface mocked in the Previewer. How this interface works on the" + - " Previewer may be different from that on a real device.") - return paramMock.paramNumberMock; - }, - getDouble: function (...args) { - console.warn("ResultSet.getDouble interface mocked in the Previewer. How this interface works on the" + - " Previewer may be different from that on a real device.") - return paramMock.paramNumberMock; - }, - isColumnNull: function (...args) { - console.warn("ResultSet.isColumnNull interface mocked in the Previewer. How this interface works on the" + - " Previewer may be different from that on a real device.") - return paramMock.paramBooleanMock; - }, - close: function (...args) { - console.warn("ResultSet.close interface mocked in the Previewer. How this interface works on the" + - " Previewer may be different from that on a real device.") - } - } + const storeConfig = { name: "[PC Preview] unknown name" } @@ -325,10 +247,10 @@ export function mockRdb() { " Previewer may be different from that on a real device.") const len = args.length if (len > 0 && typeof args[len - 1] === 'function') { - args[len - 1].call(this, paramMock.businessErrorMock, resultSetMock); + args[len - 1].call(this, paramMock.businessErrorMock, resultSet); } else { return new Promise((resolve, reject) => { - resolve(resultSetMock); + resolve(resultSet); }) } }, @@ -337,10 +259,10 @@ export function mockRdb() { " Previewer may be different from that on a real device.") const len = args.length if (len > 0 && typeof args[len - 1] === 'function') { - args[len - 1].call(this, paramMock.businessErrorMock, resultSetMock); + args[len - 1].call(this, paramMock.businessErrorMock, resultSet); } else { return new Promise((resolve, reject) => { - resolve(resultSetMock); + resolve(resultSet); }) } }, @@ -356,6 +278,18 @@ export function mockRdb() { }) } }, + beginTransaction: function () { + console.warn("RdbStore.beginTransaction interface mocked in the Previewer. How this interface works on the" + + " Previewer may be different from that on a real device.") + }, + commit: function () { + console.warn("RdbStore.commit interface mocked in the Previewer. How this interface works on the" + + " Previewer may be different from that on a real device.") + }, + rollBack: function () { + console.warn("RdbStore.rollBack interface mocked in the Previewer. How this interface works on the" + + " Previewer may be different from that on a real device.") + }, backup: function (...args) { console.warn("RdbStore.backup interface mocked in the Previewer. How this interface works on the" + " Previewer may be different from that on a real device.") From 13c93e92412c56dcf7624d2a419bfeda3f1629bf Mon Sep 17 00:00:00 2001 From: duanweiling Date: Thu, 14 Jul 2022 11:55:27 +0800 Subject: [PATCH 068/109] =?UTF-8?q?DataShare=20mock=20=E6=95=B4=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: duanweiling --- runtime/main/extend/systemplugin/napi/index.js | 6 +++--- .../napi/ohos_application_DataShareExtensionAbility.js | 7 ++++++- .../systemplugin/napi/ohos_data_DataShareResultSet.js | 2 +- .../systemplugin/napi/ohos_data_dataSharePredicates.js | 4 ++-- 4 files changed, 12 insertions(+), 7 deletions(-) diff --git a/runtime/main/extend/systemplugin/napi/index.js b/runtime/main/extend/systemplugin/napi/index.js index 6f709cac..cfdf9c8c 100644 --- a/runtime/main/extend/systemplugin/napi/index.js +++ b/runtime/main/extend/systemplugin/napi/index.js @@ -59,7 +59,7 @@ import { mockStorage } from './system_storage' import { mockRdb } from './ohos_data_rdb' import { mockPreferences } from './ohos_data_preferences' import { mockDataShare } from './ohos_data_dataShare' -import { DataSharePredicates } from './ohos_data_dataSharePredicates' +import { mockDataSharePredicates } from './ohos_data_dataSharePredicates' import { DataShareResultSet } from './ohos_data_DataShareResultSet' import { mockInputDevice } from './ohos_multimodalInput_inputDevice' import { mockVibrator } from './ohos_vibrator' @@ -358,8 +358,8 @@ export function mockRequireNapiFun() { return mockPreferences(); case "data.dataShare": return mockDataShare(); - case "data.DataSharePredicates": - return DataSharePredicates(); + case "data.dataSharePredicates": + return mockDataSharePredicates(); case "data.DataShareResultSet": return DataShareResultSet(); case "data.dataAbility": diff --git a/runtime/main/extend/systemplugin/napi/ohos_application_DataShareExtensionAbility.js b/runtime/main/extend/systemplugin/napi/ohos_application_DataShareExtensionAbility.js index 28fd0a32..bb2ccab0 100644 --- a/runtime/main/extend/systemplugin/napi/ohos_application_DataShareExtensionAbility.js +++ b/runtime/main/extend/systemplugin/napi/ohos_application_DataShareExtensionAbility.js @@ -31,6 +31,11 @@ export function mockDataShareExtensionAbility() { console.warn("application.DataShareExtensionAbility.getFileTypes interface mocked in the Previewer. How this interface works on the Previewer" + " may be different from that on a real device.") return [paramMock.paramStringMock]; + }; + this.openFile = function () { + console.warn("application.DataShareExtensionAbility.openFile interface mocked in the Previewer. How this interface works on the Previewer" + + " may be different from that on a real device.") + return paramMock.paramNumberMock; }; this.insert = function () { console.warn("application.DataShareExtensionAbility.insert interface mocked in the Previewer. How this interface works on the Previewer" + @@ -74,5 +79,5 @@ export function mockDataShareExtensionAbility() { }; } } - return new DataShareExtensionAbilityClass(); + return DataShareExtensionAbilityClass; } diff --git a/runtime/main/extend/systemplugin/napi/ohos_data_DataShareResultSet.js b/runtime/main/extend/systemplugin/napi/ohos_data_DataShareResultSet.js index 6dc2f411..65f07654 100644 --- a/runtime/main/extend/systemplugin/napi/ohos_data_DataShareResultSet.js +++ b/runtime/main/extend/systemplugin/napi/ohos_data_DataShareResultSet.js @@ -98,7 +98,7 @@ export const DataShareResultSetMock = { return paramMock.paramNumberMock; }, close: function () { - console.warn("ResultSet.isColumnNull interface mocked in the Previewer. How this interface works on the Previewer" + + console.warn("ResultSet.close interface mocked in the Previewer. How this interface works on the Previewer" + " may be different from that on a real device.") } } diff --git a/runtime/main/extend/systemplugin/napi/ohos_data_dataSharePredicates.js b/runtime/main/extend/systemplugin/napi/ohos_data_dataSharePredicates.js index 0faa8777..7febfb95 100644 --- a/runtime/main/extend/systemplugin/napi/ohos_data_dataSharePredicates.js +++ b/runtime/main/extend/systemplugin/napi/ohos_data_dataSharePredicates.js @@ -14,8 +14,8 @@ */ import { paramMock } from "../utils" -export function DataSharePredicates() { - const DataSharePredicatesClass = class data_DataSharePredicates { +export function mockDataSharePredicates() { + const DataSharePredicatesClass = class DataSharePredicate { constructor() { this.equalTo = function (...args) { console.warn("DataSharePredicates.equalTo interface mocked in the Previewer. How this interface works on the" + From 3e6315b5fa7bb3447bfb321326a7f6118beb1ec4 Mon Sep 17 00:00:00 2001 From: sufeng6 Date: Tue, 12 Jul 2022 18:36:36 +0800 Subject: [PATCH 069/109] application mock Signed-off-by: sufeng6 --- .../main/extend/systemplugin/napi/webgl.js | 575 +++++++++++++----- .../main/extend/systemplugin/napi/webgl2.js | 485 +++++++++++---- 2 files changed, 809 insertions(+), 251 deletions(-) mode change 100644 => 100755 runtime/main/extend/systemplugin/napi/webgl.js mode change 100644 => 100755 runtime/main/extend/systemplugin/napi/webgl2.js diff --git a/runtime/main/extend/systemplugin/napi/webgl.js b/runtime/main/extend/systemplugin/napi/webgl.js old mode 100644 new mode 100755 index 62372732..f007becf --- a/runtime/main/extend/systemplugin/napi/webgl.js +++ b/runtime/main/extend/systemplugin/napi/webgl.js @@ -76,266 +76,565 @@ export function mockwebgl() { glBooleanArray: '[PC preview] unknow glBooleanArray', WebGLShaderArray: '[PC preview] unknow WebGLShaderArray', } - const webglmock = { + const WebGLRenderingContext = { + DEPTH_BUFFER_BIT: 0x00000100, + STENCIL_BUFFER_BIT: 0x00000400, + COLOR_BUFFER_BIT: 0x00004000, + POINTS: 0x0000, + LINES: 0x0001, + LINE_LOOP: 0x0002, + LINE_STRIP: 0x0003, + TRIANGLES: 0x0004, + TRIANGLE_STRIP: 0x0005, + TRIANGLE_FAN: 0x0006, + ZERO: 0, + ONE: 1, + SRC_COLOR: 0x0300, + ONE_MINUS_SRC_COLOR: 0x0301, + SRC_ALPHA: 0x0302, + ONE_MINUS_SRC_ALPHA: 0x0303, + DST_ALPHA: 0x0304, + ONE_MINUS_DST_ALPHA: 0x0305, + DST_COLOR: 0x0306, + ONE_MINUS_DST_COLOR: 0x0307, + SRC_ALPHA_SATURATE: 0x0308, + FUNC_ADD: 0x8006, + BLEND_EQUATION: 0x8009, + BLEND_EQUATION_RGB: 0x8009, + BLEND_EQUATION_ALPHA: 0x883D, + FUNC_SUBTRACT: 0x800A, + FUNC_REVERSE_SUBTRACT: 0x800B, + BLEND_DST_RGB: 0x80C8, + BLEND_SRC_RGB: 0x80C9, + BLEND_DST_ALPHA: 0x80CA, + BLEND_SRC_ALPHA: 0x80CB, + CONSTANT_COLOR: 0x8001, + ONE_MINUS_CONSTANT_COLOR: 0x8002, + CONSTANT_ALPHA: 0x8003, + ONE_MINUS_CONSTANT_ALPHA: 0x8004, + BLEND_COLOR: 0x8005, + ARRAY_BUFFER: 0x8892, + ELEMENT_ARRAY_BUFFER: 0x8893, + ARRAY_BUFFER_BINDING: 0x8894, + ELEMENT_ARRAY_BUFFER_BINDING: 0x8895, + STREAM_DRAW: 0x88E0, + STATIC_DRAW: 0x88E4, + DYNAMIC_DRAW: 0x88E8, + BUFFER_SIZE: 0x8764, + BUFFER_USAGE: 0x8765, + CURRENT_VERTEX_ATTRIB: 0x8626, + FRONT: 0x0404, + BACK: 0x0405, + FRONT_AND_BACK: 0x0408, + CULL_FACE: 0x0B44, + BLEND: 0x0BE2, + DITHER: 0x0BD0, + STENCIL_TEST: 0x0B90, + DEPTH_TEST: 0x0B71, + SCISSOR_TEST: 0x0C11, + POLYGON_OFFSET_FILL: 0x8037, + SAMPLE_ALPHA_TO_COVERAGE: 0x809E, + SAMPLE_COVERAGE: 0x80A0, + NO_ERROR: 0, + INVALID_ENUM: 0x0500, + INVALID_VALUE: 0x0501, + INVALID_OPERATION: 0x0502, + OUT_OF_MEMORY: 0x0505, + CW: 0x0900, + CCW: 0x0901, + LINE_WIDTH: 0x0B21, + ALIASED_POINT_SIZE_RANGE: 0x846D, + ALIASED_LINE_WIDTH_RANGE: 0x846E, + CULL_FACE_MODE: 0x0B45, + FRONT_FACE: 0x0B46, + DEPTH_RANGE: 0x0B70, + DEPTH_WRITEMASK: 0x0B72, + DEPTH_CLEAR_VALUE: 0x0B73, + DEPTH_FUNC: 0x0B74, + STENCIL_CLEAR_VALUE: 0x0B91, + STENCIL_FUNC: 0x0B92, + STENCIL_FAIL: 0x0B94, + STENCIL_PASS_DEPTH_FAIL: 0x0B95, + STENCIL_PASS_DEPTH_PASS: 0x0B96, + STENCIL_REF: 0x0B97, + STENCIL_VALUE_MASK: 0x0B93, + STENCIL_WRITEMASK: 0x0B98, + STENCIL_BACK_FUNC: 0x8800, + STENCIL_BACK_FAIL: 0x8801, + STENCIL_BACK_PASS_DEPTH_FAIL: 0x8802, + STENCIL_BACK_PASS_DEPTH_PASS: 0x8803, + STENCIL_BACK_REF: 0x8CA3, + STENCIL_BACK_VALUE_MASK: 0x8CA4, + STENCIL_BACK_WRITEMASK: 0x8CA5, + VIEWPORT: 0x0BA2, + SCISSOR_BOX: 0x0C10, + COLOR_CLEAR_VALUE: 0x0C22, + COLOR_WRITEMASK: 0x0C23, + UNPACK_ALIGNMENT: 0x0CF5, + PACK_ALIGNMENT: 0x0D05, + MAX_TEXTURE_SIZE: 0x0D33, + MAX_VIEWPORT_DIMS: 0x0D3A, + SUBPIXEL_BITS: 0x0D50, + RED_BITS: 0x0D52, + GREEN_BITS: 0x0D53, + BLUE_BITS: 0x0D54, + ALPHA_BITS: 0x0D55, + DEPTH_BITS: 0x0D56, + STENCIL_BITS: 0x0D57, + POLYGON_OFFSET_UNITS: 0x2A00, + POLYGON_OFFSET_FACTOR: 0x8038, + TEXTURE_BINDING_2D: 0x8069, + SAMPLE_BUFFERS: 0x80A8, + SAMPLES: 0x80A9, + SAMPLE_COVERAGE_VALUE: 0x80AA, + SAMPLE_COVERAGE_INVERT: 0x80AB, + COMPRESSED_TEXTURE_FORMATS: 0x86A3, + DONT_CARE: 0x1100, + FASTEST: 0x1101, + NICEST: 0x1102, + GENERATE_MIPMAP_HINT: 0x8192, + BYTE: 0x1400, + UNSIGNED_BYTE: 0x1401, + SHORT: 0x1402, + UNSIGNED_SHORT: 0x1403, + INT: 0x1404, + UNSIGNED_INT: 0x1405, + FLOAT: 0x1406, + DEPTH_COMPONENT: 0x1902, + ALPHA: 0x1906, + RGB: 0x1907, + RGBA: 0x1908, + LUMINANCE: 0x1909, + LUMINANCE_ALPHA: 0x190A, + UNSIGNED_SHORT_4_4_4_4: 0x8033, + UNSIGNED_SHORT_5_5_5_1: 0x8034, + UNSIGNED_SHORT_5_6_5: 0x8363, + FRAGMENT_SHADER: 0x8B30, + VERTEX_SHADER: 0x8B31, + MAX_VERTEX_ATTRIBS: 0x8869, + MAX_VERTEX_UNIFORM_VECTORS: 0x8DFB, + MAX_VARYING_VECTORS: 0x8DFC, + MAX_COMBINED_TEXTURE_IMAGE_UNITS: 0x8B4D, + MAX_VERTEX_TEXTURE_IMAGE_UNITS: 0x8B4C, + MAX_TEXTURE_IMAGE_UNITS: 0x8872, + MAX_FRAGMENT_UNIFORM_VECTORS: 0x8DFD, + SHADER_TYPE: 0x8B4F, + DELETE_STATUS: 0x8B80, + LINK_STATUS: 0x8B82, + VALIDATE_STATUS: 0x8B83, + ATTACHED_SHADERS: 0x8B85, + ACTIVE_UNIFORMS: 0x8B86, + ACTIVE_ATTRIBUTES: 0x8B89, + SHADING_LANGUAGE_VERSION: 0x8B8C, + CURRENT_PROGRAM: 0x8B8D, + NEVER: 0x0200, + LESS: 0x0201, + EQUAL: 0x0202, + LEQUAL: 0x0203, + GREATER: 0x0204, + NOTEQUAL: 0x0205, + GEQUAL: 0x0206, + ALWAYS: 0x0207, + KEEP: 0x1E00, + REPLACE: 0x1E01, + INCR: 0x1E02, + DECR: 0x1E03, + INVERT: 0x150A, + INCR_WRAP: 0x8507, + DECR_WRAP: 0x8508, + VENDOR: 0x1F00, + RENDERER: 0x1F01, + VERSION: 0x1F02, + NEAREST: 0x2600, + LINEAR: 0x2601, + NEAREST_MIPMAP_NEAREST: 0x2700, + LINEAR_MIPMAP_NEAREST: 0x2701, + NEAREST_MIPMAP_LINEAR: 0x2702, + LINEAR_MIPMAP_LINEAR: 0x2703, + TEXTURE_MAG_FILTER: 0x2800, + TEXTURE_MIN_FILTER: 0x2801, + TEXTURE_WRAP_S: 0x2802, + TEXTURE_WRAP_T: 0x2803, + TEXTURE_2D: 0x0DE1, + TEXTURE: 0x1702, + TEXTURE_CUBE_MAP: 0x8513, + TEXTURE_BINDING_CUBE_MAP: 0x8514, + TEXTURE_CUBE_MAP_POSITIVE_X: 0x8515, + TEXTURE_CUBE_MAP_NEGATIVE_X: 0x8516, + TEXTURE_CUBE_MAP_POSITIVE_Y: 0x8517, + TEXTURE_CUBE_MAP_NEGATIVE_Y: 0x8518, + TEXTURE_CUBE_MAP_POSITIVE_Z: 0x8519, + TEXTURE_CUBE_MAP_NEGATIVE_Z: 0x851A, + MAX_CUBE_MAP_TEXTURE_SIZE: 0x851C, + TEXTURE0: 0x84C0, + TEXTURE1: 0x84C1, + TEXTURE2: 0x84C2, + TEXTURE3: 0x84C3, + TEXTURE4: 0x84C4, + TEXTURE5: 0x84C5, + TEXTURE6: 0x84C6, + TEXTURE7: 0x84C7, + TEXTURE8: 0x84C8, + TEXTURE9: 0x84C9, + TEXTURE10: 0x84CA, + TEXTURE11: 0x84CB, + TEXTURE12: 0x84CC, + TEXTURE13: 0x84CD, + TEXTURE14: 0x84CE, + TEXTURE15: 0x84CF, + TEXTURE16: 0x84D0, + TEXTURE17: 0x84D1, + TEXTURE18: 0x84D2, + TEXTURE19: 0x84D3, + TEXTURE20: 0x84D4, + TEXTURE21: 0x84D5, + TEXTURE22: 0x84D6, + TEXTURE23: 0x84D7, + TEXTURE24: 0x84D8, + TEXTURE25: 0x84D9, + TEXTURE26: 0x84DA, + TEXTURE27: 0x84DB, + TEXTURE28: 0x84DC, + TEXTURE29: 0x84DD, + TEXTURE30: 0x84DE, + TEXTURE31: 0x84DF, + ACTIVE_TEXTURE: 0x84E0, + REPEAT: 0x2901, + CLAMP_TO_EDGE: 0x812F, + MIRRORED_REPEAT: 0x8370, + FLOAT_VEC2: 0x8B50, + FLOAT_VEC3: 0x8B51, + FLOAT_VEC4: 0x8B52, + INT_VEC2: 0x8B53, + INT_VEC3: 0x8B54, + INT_VEC4: 0x8B55, + BOOL: 0x8B56, + BOOL_VEC2: 0x8B57, + BOOL_VEC3: 0x8B58, + BOOL_VEC4: 0x8B59, + FLOAT_MAT2: 0x8B5A, + FLOAT_MAT3: 0x8B5B, + FLOAT_MAT4: 0x8B5C, + SAMPLER_2D: 0x8B5E, + SAMPLER_CUBE: 0x8B60, + VERTEX_ATTRIB_ARRAY_ENABLED: 0x8622, + VERTEX_ATTRIB_ARRAY_SIZE: 0x8623, + VERTEX_ATTRIB_ARRAY_STRIDE: 0x8624, + VERTEX_ATTRIB_ARRAY_TYPE: 0x8625, + VERTEX_ATTRIB_ARRAY_NORMALIZED: 0x886A, + VERTEX_ATTRIB_ARRAY_POINTER: 0x8645, + VERTEX_ATTRIB_ARRAY_BUFFER_BINDING: 0x889F, + IMPLEMENTATION_COLOR_READ_TYPE: 0x8B9A, + IMPLEMENTATION_COLOR_READ_FORMAT: 0x8B9B, + COMPILE_STATUS: 0x8B81, + LOW_FLOAT: 0x8DF0, + MEDIUM_FLOAT: 0x8DF1, + HIGH_FLOAT: 0x8DF2, + LOW_INT: 0x8DF3, + MEDIUM_INT: 0x8DF4, + HIGH_INT: 0x8DF5, + FRAMEBUFFER: 0x8D40, + RENDERBUFFER: 0x8D41, + RGBA4: 0x8056, + RGB5_A1: 0x8057, + RGB565: 0x8D62, + DEPTH_COMPONENT16: 0x81A5, + STENCIL_INDEX8: 0x8D48, + DEPTH_STENCIL: 0x84F9, + RENDERBUFFER_WIDTH: 0x8D42, + RENDERBUFFER_HEIGHT: 0x8D43, + RENDERBUFFER_INTERNAL_FORMAT: 0x8D44, + RENDERBUFFER_RED_SIZE: 0x8D50, + RENDERBUFFER_GREEN_SIZE: 0x8D51, + RENDERBUFFER_BLUE_SIZE: 0x8D52, + RENDERBUFFER_ALPHA_SIZE: 0x8D53, + RENDERBUFFER_DEPTH_SIZE: 0x8D54, + RENDERBUFFER_STENCIL_SIZE: 0x8D55, + FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE: 0x8CD0, + FRAMEBUFFER_ATTACHMENT_OBJECT_NAME: 0x8CD1, + FRAMEBUFFER_ATTACHMENT_TEXTURE_LEVEL: 0x8CD2, + FRAMEBUFFER_ATTACHMENT_TEXTURE_CUBE_MAP_FACE: 0x8CD3, + COLOR_ATTACHMENT0: 0x8CE0, + DEPTH_ATTACHMENT: 0x8D00, + STENCIL_ATTACHMENT: 0x8D20, + DEPTH_STENCIL_ATTACHMENT: 0x821A, + NONE: 0, + FRAMEBUFFER_COMPLETE: 0x8CD5, + FRAMEBUFFER_INCOMPLETE_ATTACHMENT: 0x8CD6, + FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT: 0x8CD7, + FRAMEBUFFER_INCOMPLETE_DIMENSIONS: 0x8CD9, + FRAMEBUFFER_UNSUPPORTED: 0x8CDD, + FRAMEBUFFER_BINDING: 0x8CA6, + RENDERBUFFER_BINDING: 0x8CA7, + MAX_RENDERBUFFER_SIZE: 0x84E8, + INVALID_FRAMEBUFFER_OPERATION: 0x0506, + UNPACK_FLIP_Y_WEBGL: 0x9240, + UNPACK_PREMULTIPLY_ALPHA_WEBGL: 0x9241, + CONTEXT_LOST_WEBGL: 0x9242, + UNPACK_COLORSPACE_CONVERSION_WEBGL: 0x9243, + BROWSER_DEFAULT_WEBGL: 0x9244, + canvas: '[PC preview] unknow canvas', + drawingBufferWidth:'[PC preview] unknow drawingBufferWidth', + drawingBufferHeight:'[PC preview] unknow drawingBufferHeight', getContextAttributes: function (...args) { - console.warn("webgl.getContextAttributes interface mocked in the Previewer. How this interface works on the" + + console.warn("WebGLRenderingContext.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" + + console.warn("WebGLRenderingContext.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" + + console.warn("WebGLRenderingContext.getSupportedExtensions interface mocked in the Previewer. How this interface works on the" + " Previewer may be different from that on a real device.") return glParamMock.stringArray }, getExtension: function (...args) { - console.warn("webgl.getExtension interface mocked in the Previewer. How this interface works on the" + + console.warn("WebGLRenderingContext.getExtension interface mocked in the Previewer. How this interface works on the" + " Previewer may be different from that on a real device.") return glParamMock.paramAnyMock }, activeTexture: function (...args) { - console.warn("webgl.activeTexture interface mocked in the Previewer. How this interface works on the" + + console.warn("WebGLRenderingContext.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" + + console.warn("WebGLRenderingContext.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" + + console.warn("WebGLRenderingContext.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" + + console.warn("WebGLRenderingContext.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" + + console.warn("WebGLRenderingContext.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" + + console.warn("WebGLRenderingContext.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" + + console.warn("WebGLRenderingContext.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" + + console.warn("WebGLRenderingContext.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" + + console.warn("WebGLRenderingContext.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" + + console.warn("WebGLRenderingContext.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" + + console.warn("WebGLRenderingContext.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" + + console.warn("WebGLRenderingContext.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" + + console.warn("WebGLRenderingContext.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" + + console.warn("WebGLRenderingContext.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" + + console.warn("WebGLRenderingContext.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" + + console.warn("WebGLRenderingContext.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" + + console.warn("WebGLRenderingContext.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" + + console.warn("WebGLRenderingContext.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" + + console.warn("WebGLRenderingContext.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" + + console.warn("WebGLRenderingContext.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" + + console.warn("WebGLRenderingContext.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" + + console.warn("WebGLRenderingContext.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" + + console.warn("WebGLRenderingContext.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" + + console.warn("WebGLRenderingContext.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" + + console.warn("WebGLRenderingContext.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" + + console.warn("WebGLRenderingContext.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" + + console.warn("WebGLRenderingContext.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" + + console.warn("WebGLRenderingContext.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" + + console.warn("WebGLRenderingContext.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" + + console.warn("WebGLRenderingContext.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" + + console.warn("WebGLRenderingContext.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" + + console.warn("WebGLRenderingContext.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" + + console.warn("WebGLRenderingContext.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" + + console.warn("WebGLRenderingContext.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" + + console.warn("WebGLRenderingContext.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" + + console.warn("WebGLRenderingContext.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" + + console.warn("WebGLRenderingContext.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" + + console.warn("WebGLRenderingContext.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" + + console.warn("WebGLRenderingContext.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" + + console.warn("WebGLRenderingContext.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" + + console.warn("WebGLRenderingContext.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" + + console.warn("WebGLRenderingContext.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" + + console.warn("WebGLRenderingContext.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" + + console.warn("WebGLRenderingContext.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" + + console.warn("WebGLRenderingContext.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" + + console.warn("WebGLRenderingContext.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" + + console.warn("WebGLRenderingContext.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" + + console.warn("WebGLRenderingContext.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" + + console.warn("WebGLRenderingContext.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" + + console.warn("WebGLRenderingContext.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" + + console.warn("WebGLRenderingContext.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" + + console.warn("WebGLRenderingContext.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" + + console.warn("WebGLRenderingContext.getActiveAttrib interface mocked in the Previewer. How this interface works on the" + " Previewer may be different from that on a real device.") return glParamMock.WebGLShaderArray; }, getAttribLocation: function (...args) { - console.warn("webgl.getActiveAttrib interface mocked in the Previewer. How this interface works on the" + + console.warn("WebGLRenderingContext.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" + + console.warn("WebGLRenderingContext.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" + + console.warn("WebGLRenderingContext.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 || @@ -379,12 +678,12 @@ export function mockwebgl() { } }, getError: function (...args) { - console.warn("webgl.getError interface mocked in the Previewer. How this interface works on the" + + console.warn("WebGLRenderingContext.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" + + console.warn("WebGLRenderingContext.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 || @@ -404,7 +703,7 @@ export function mockwebgl() { } }, getProgramParameter: function (...args) { - console.warn("webgl.getProgramParameter interface mocked in the Previewer. How this interface works on the" + + console.warn("WebGLRenderingContext.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; @@ -413,18 +712,18 @@ export function mockwebgl() { } }, getProgramInfoLog: function (...args) { - console.warn("webgl.getProgramInfoLog interface mocked in the Previewer. How this interface works on the" + + console.warn("WebGLRenderingContext.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" + + console.warn("WebGLRenderingContext.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" + + console.warn("WebGLRenderingContext.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; @@ -433,22 +732,22 @@ export function mockwebgl() { } }, getShaderPrecisionFormat: function (...args) { - console.warn("webgl.getShaderPrecisionFormat interface mocked in the Previewer. How this interface works on the" + + console.warn("WebGLRenderingContext.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" + + console.warn("WebGLRenderingContext.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" + + console.warn("WebGLRenderingContext.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" + + console.warn("WebGLRenderingContext.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 glParamMock.paramDoubleMock; @@ -457,293 +756,293 @@ export function mockwebgl() { } }, getUniform: function (...args) { - console.warn("webgl.getUniform interface mocked in the Previewer. How this interface works on the" + + console.warn("WebGLRenderingContext.getUniform interface mocked in the Previewer. How this interface works on the" + " Previewer may be different from that on a real device.") return glParamMock.paramAnyMock; }, getUniformLocation: function (...args) { - console.warn("webgl.getUniformLocation interface mocked in the Previewer. How this interface works on the" + + console.warn("WebGLRenderingContext.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" + + console.warn("WebGLRenderingContext.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" + + console.warn("WebGLRenderingContext.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" + + console.warn("WebGLRenderingContext.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" + + console.warn("WebGLRenderingContext.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" + + console.warn("WebGLRenderingContext.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" + + console.warn("WebGLRenderingContext.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" + + console.warn("WebGLRenderingContext.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" + + console.warn("WebGLRenderingContext.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" + + console.warn("WebGLRenderingContext.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" + + console.warn("WebGLRenderingContext.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" + + console.warn("WebGLRenderingContext.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" + + console.warn("WebGLRenderingContext.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" + + console.warn("WebGLRenderingContext.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" + + console.warn("WebGLRenderingContext.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" + + console.warn("WebGLRenderingContext.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" + + console.warn("WebGLRenderingContext.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" + + console.warn("WebGLRenderingContext.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" + + console.warn("WebGLRenderingContext.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" + + console.warn("WebGLRenderingContext.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" + + console.warn("WebGLRenderingContext.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" + + console.warn("WebGLRenderingContext.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" + + console.warn("WebGLRenderingContext.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" + + console.warn("WebGLRenderingContext.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" + + console.warn("WebGLRenderingContext.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" + + console.warn("WebGLRenderingContext.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" + + console.warn("WebGLRenderingContext.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" + + console.warn("WebGLRenderingContext.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" + + console.warn("WebGLRenderingContext.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" + + console.warn("WebGLRenderingContext.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" + + console.warn("WebGLRenderingContext.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" + + console.warn("WebGLRenderingContext.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" + + console.warn("WebGLRenderingContext.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" + + console.warn("WebGLRenderingContext.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" + + console.warn("WebGLRenderingContext.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" + + console.warn("WebGLRenderingContext.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" + + console.warn("WebGLRenderingContext.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" + + console.warn("WebGLRenderingContext.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" + + console.warn("WebGLRenderingContext.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" + + console.warn("WebGLRenderingContext.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" + + console.warn("WebGLRenderingContext.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" + + console.warn("WebGLRenderingContext.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" + + console.warn("WebGLRenderingContext.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" + + console.warn("WebGLRenderingContext.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" + + console.warn("WebGLRenderingContext.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" + + console.warn("WebGLRenderingContext.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" + + console.warn("WebGLRenderingContext.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" + + console.warn("WebGLRenderingContext.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" + + console.warn("WebGLRenderingContext.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" + + console.warn("WebGLRenderingContext.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" + + console.warn("WebGLRenderingContext.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" + + console.warn("WebGLRenderingContext.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" + + console.warn("WebGLRenderingContext.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" + + console.warn("WebGLRenderingContext.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" + + console.warn("WebGLRenderingContext.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" + + console.warn("WebGLRenderingContext.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" + + console.warn("WebGLRenderingContext.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" + + console.warn("WebGLRenderingContext.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" + + console.warn("WebGLRenderingContext.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" + + console.warn("WebGLRenderingContext.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" + + console.warn("WebGLRenderingContext.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" + + console.warn("WebGLRenderingContext.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" + + console.warn("WebGLRenderingContext.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" + + console.warn("WebGLRenderingContext.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" + + console.warn("WebGLRenderingContext.uniformMatrix4fv interface mocked in the Previewer. How this interface works on the" + " Previewer may be different from that on a real device.") } } - return webglmock + return WebGLRenderingContext; } \ No newline at end of file diff --git a/runtime/main/extend/systemplugin/napi/webgl2.js b/runtime/main/extend/systemplugin/napi/webgl2.js old mode 100644 new mode 100755 index 4888c98d..966199a5 --- a/runtime/main/extend/systemplugin/napi/webgl2.js +++ b/runtime/main/extend/systemplugin/napi/webgl2.js @@ -40,225 +40,484 @@ export function mockwebgl2() { int32Array: '[PC preview] unknow int32Array', uintArray: '[PC preview] unknow uintArray' } - const GL_SAMPLES = 0x80A9; - const GL_QUERY_RESULT = 0x8866; - const GL_QUERY_RESULT_AVAILABLE = 0x8867; - const GL_TEXTURE_MAX_LOD = 0x813B; - const GL_TEXTURE_MIN_LOD = 0x813A; - const webgl2Mock = { + + const WebGL2RenderingContext = { + READ_BUFFER: 0x0C02, + UNPACK_ROW_LENGTH: 0x0CF2, + UNPACK_SKIP_ROWS: 0x0CF3, + UNPACK_SKIP_PIXELS: 0x0CF4, + PACK_ROW_LENGTH: 0x0D02, + PACK_SKIP_ROWS: 0x0D03, + PACK_SKIP_PIXELS: 0x0D04, + COLOR: 0x1800, + DEPTH: 0x1801, + STENCIL: 0x1802, + RED: 0x1903, + RGB8: 0x8051, + RGBA8: 0x8058, + RGB10_A2: 0x8059, + TEXTURE_BINDING_3D: 0x806A, + UNPACK_SKIP_IMAGES: 0x806D, + UNPACK_IMAGE_HEIGHT: 0x806E, + TEXTURE_3D: 0x806F, + TEXTURE_WRAP_R: 0x8072, + MAX_3D_TEXTURE_SIZE: 0x8073, + UNSIGNED_INT_2_10_10_10_REV: 0x8368, + MAX_ELEMENTS_VERTICES: 0x80E8, + MAX_ELEMENTS_INDICES: 0x80E9, + TEXTURE_MIN_LOD: 0x813A, + TEXTURE_MAX_LOD: 0x813B, + TEXTURE_BASE_LEVEL: 0x813C, + TEXTURE_MAX_LEVEL: 0x813D, + MIN: 0x8007, + MAX: 0x8008, + DEPTH_COMPONENT24: 0x81A6, + MAX_TEXTURE_LOD_BIAS: 0x84FD, + TEXTURE_COMPARE_MODE: 0x884C, + TEXTURE_COMPARE_FUNC: 0x884D, + CURRENT_QUERY: 0x8865, + QUERY_RESULT: 0x8866, + QUERY_RESULT_AVAILABLE: 0x8867, + STREAM_READ: 0x88E1, + STREAM_COPY: 0x88E2, + STATIC_READ: 0x88E5, + STATIC_COPY: 0x88E6, + DYNAMIC_READ: 0x88E9, + DYNAMIC_COPY: 0x88EA, + MAX_DRAW_BUFFERS: 0x8824, + DRAW_BUFFER0: 0x8825, + DRAW_BUFFER1: 0x8826, + DRAW_BUFFER2: 0x8827, + DRAW_BUFFER3: 0x8828, + DRAW_BUFFER4: 0x8829, + DRAW_BUFFER5: 0x882A, + DRAW_BUFFER6: 0x882B, + DRAW_BUFFER7: 0x882C, + DRAW_BUFFER8: 0x882D, + DRAW_BUFFER9: 0x882E, + DRAW_BUFFER10: 0x882F, + DRAW_BUFFER11: 0x8830, + DRAW_BUFFER12: 0x8831, + DRAW_BUFFER13: 0x8832, + DRAW_BUFFER14: 0x8833, + DRAW_BUFFER15: 0x8834, + MAX_FRAGMENT_UNIFORM_COMPONENTS: 0x8B49, + MAX_VERTEX_UNIFORM_COMPONENTS: 0x8B4A, + SAMPLER_3D: 0x8B5F, + SAMPLER_2D_SHADOW: 0x8B62, + FRAGMENT_SHADER_DERIVATIVE_HINT: 0x8B8B, + PIXEL_PACK_BUFFER: 0x88EB, + PIXEL_UNPACK_BUFFER: 0x88EC, + PIXEL_PACK_BUFFER_BINDING: 0x88ED, + PIXEL_UNPACK_BUFFER_BINDING: 0x88EF, + FLOAT_MAT2x3: 0x8B65, + FLOAT_MAT2x4: 0x8B66, + FLOAT_MAT3x2: 0x8B67, + FLOAT_MAT3x4: 0x8B68, + FLOAT_MAT4x2: 0x8B69, + FLOAT_MAT4x3: 0x8B6A, + SRGB: 0x8C40, + SRGB8: 0x8C41, + SRGB8_ALPHA8: 0x8C43, + COMPARE_REF_TO_TEXTURE: 0x884E, + RGBA32F: 0x8814, + RGB32F: 0x8815, + RGBA16F: 0x881A, + RGB16F: 0x881B, + VERTEX_ATTRIB_ARRAY_INTEGER: 0x88FD, + MAX_ARRAY_TEXTURE_LAYERS: 0x88FF, + MIN_PROGRAM_TEXEL_OFFSET: 0x8904, + MAX_PROGRAM_TEXEL_OFFSET: 0x8905, + MAX_VARYING_COMPONENTS: 0x8B4B, + TEXTURE_2D_ARRAY: 0x8C1A, + TEXTURE_BINDING_2D_ARRAY: 0x8C1D, + R11F_G11F_B10F: 0x8C3A, + UNSIGNED_INT_10F_11F_11F_REV: 0x8C3B, + RGB9_E5: 0x8C3D, + UNSIGNED_INT_5_9_9_9_REV: 0x8C3E, + TRANSFORM_FEEDBACK_BUFFER_MODE: 0x8C7F, + MAX_TRANSFORM_FEEDBACK_SEPARATE_COMPONENTS: 0x8C80, + TRANSFORM_FEEDBACK_VARYINGS: 0x8C83, + TRANSFORM_FEEDBACK_BUFFER_START: 0x8C84, + TRANSFORM_FEEDBACK_BUFFER_SIZE: 0x8C85, + TRANSFORM_FEEDBACK_PRIMITIVES_WRITTEN: 0x8C88, + RASTERIZER_DISCARD: 0x8C89, + MAX_TRANSFORM_FEEDBACK_INTERLEAVED_COMPONENTS: 0x8C8A, + MAX_TRANSFORM_FEEDBACK_SEPARATE_ATTRIBS: 0x8C8B, + INTERLEAVED_ATTRIBS: 0x8C8C, + SEPARATE_ATTRIBS: 0x8C8D, + TRANSFORM_FEEDBACK_BUFFER: 0x8C8E, + TRANSFORM_FEEDBACK_BUFFER_BINDING: 0x8C8F, + RGBA32UI: 0x8D70, + RGB32UI: 0x8D71, + RGBA16UI: 0x8D76, + RGB16UI: 0x8D77, + RGBA8UI: 0x8D7C, + RGB8UI: 0x8D7D, + RGBA32I: 0x8D82, + RGB32I: 0x8D83, + RGBA16I: 0x8D88, + RGB16I: 0x8D89, + RGBA8I: 0x8D8E, + RGB8I: 0x8D8F, + RED_INTEGER: 0x8D94, + RGB_INTEGER: 0x8D98, + RGBA_INTEGER: 0x8D99, + SAMPLER_2D_ARRAY: 0x8DC1, + SAMPLER_2D_ARRAY_SHADOW: 0x8DC4, + SAMPLER_CUBE_SHADOW: 0x8DC5, + UNSIGNED_INT_VEC2: 0x8DC6, + UNSIGNED_INT_VEC3: 0x8DC7, + UNSIGNED_INT_VEC4: 0x8DC8, + INT_SAMPLER_2D: 0x8DCA, + INT_SAMPLER_3D: 0x8DCB, + INT_SAMPLER_CUBE: 0x8DCC, + INT_SAMPLER_2D_ARRAY: 0x8DCF, + UNSIGNED_INT_SAMPLER_2D: 0x8DD2, + UNSIGNED_INT_SAMPLER_3D: 0x8DD3, + UNSIGNED_INT_SAMPLER_CUBE: 0x8DD4, + UNSIGNED_INT_SAMPLER_2D_ARRAY: 0x8DD7, + DEPTH_COMPONENT32F: 0x8CAC, + DEPTH32F_STENCIL8: 0x8CAD, + FLOAT_32_UNSIGNED_INT_24_8_REV: 0x8DAD, + FRAMEBUFFER_ATTACHMENT_COLOR_ENCODING: 0x8210, + FRAMEBUFFER_ATTACHMENT_COMPONENT_TYPE: 0x8211, + FRAMEBUFFER_ATTACHMENT_RED_SIZE: 0x8212, + FRAMEBUFFER_ATTACHMENT_GREEN_SIZE: 0x8213, + FRAMEBUFFER_ATTACHMENT_BLUE_SIZE: 0x8214, + FRAMEBUFFER_ATTACHMENT_ALPHA_SIZE: 0x8215, + FRAMEBUFFER_ATTACHMENT_DEPTH_SIZE: 0x8216, + FRAMEBUFFER_ATTACHMENT_STENCIL_SIZE: 0x8217, + FRAMEBUFFER_DEFAULT: 0x8218, + UNSIGNED_INT_24_8: 0x84FA, + DEPTH24_STENCIL8: 0x88F0, + UNSIGNED_NORMALIZED: 0x8C17, + DRAW_FRAMEBUFFER_BINDING: 0x8CA6, + READ_FRAMEBUFFER: 0x8CA8, + DRAW_FRAMEBUFFER: 0x8CA9, + READ_FRAMEBUFFER_BINDING: 0x8CAA, + RENDERBUFFER_SAMPLES: 0x8CAB, + FRAMEBUFFER_ATTACHMENT_TEXTURE_LAYER: 0x8CD4, + MAX_COLOR_ATTACHMENTS: 0x8CDF, + COLOR_ATTACHMENT1: 0x8CE1, + COLOR_ATTACHMENT2: 0x8CE2, + COLOR_ATTACHMENT3: 0x8CE3, + COLOR_ATTACHMENT4: 0x8CE4, + COLOR_ATTACHMENT5: 0x8CE5, + COLOR_ATTACHMENT6: 0x8CE6, + COLOR_ATTACHMENT7: 0x8CE7, + COLOR_ATTACHMENT8: 0x8CE8, + COLOR_ATTACHMENT9: 0x8CE9, + COLOR_ATTACHMENT10: 0x8CEA, + COLOR_ATTACHMENT11: 0x8CEB, + COLOR_ATTACHMENT12: 0x8CEC, + COLOR_ATTACHMENT13: 0x8CED, + COLOR_ATTACHMENT14: 0x8CEE, + COLOR_ATTACHMENT15: 0x8CEF, + FRAMEBUFFER_INCOMPLETE_MULTISAMPLE: 0x8D56, + MAX_SAMPLES: 0x8D57, + HALF_FLOAT: 0x140B, + RG: 0x8227, + RG_INTEGER: 0x8228, + R8: 0x8229, + RG8: 0x822B, + R16F: 0x822D, + R32F: 0x822E, + RG16F: 0x822F, + RG32F: 0x8230, + R8I: 0x8231, + R8UI: 0x8232, + R16I: 0x8233, + R16UI: 0x8234, + R32I: 0x8235, + R32UI: 0x8236, + RG8I: 0x8237, + RG8UI: 0x8238, + RG16I: 0x8239, + RG16UI: 0x823A, + RG32I: 0x823B, + RG32UI: 0x823C, + VERTEX_ARRAY_BINDING: 0x85B5, + R8_SNORM: 0x8F94, + RG8_SNORM: 0x8F95, + RGB8_SNORM: 0x8F96, + RGBA8_SNORM: 0x8F97, + SIGNED_NORMALIZED: 0x8F9C, + COPY_READ_BUFFER: 0x8F36, + COPY_WRITE_BUFFER: 0x8F37, + COPY_READ_BUFFER_BINDING: 0x8F36, + COPY_WRITE_BUFFER_BINDING: 0x8F37, + UNIFORM_BUFFER: 0x8A11, + UNIFORM_BUFFER_BINDING: 0x8A28, + UNIFORM_BUFFER_START: 0x8A29, + UNIFORM_BUFFER_SIZE: 0x8A2A, + MAX_VERTEX_UNIFORM_BLOCKS: 0x8A2B, + MAX_FRAGMENT_UNIFORM_BLOCKS: 0x8A2D, + MAX_COMBINED_UNIFORM_BLOCKS: 0x8A2E, + MAX_UNIFORM_BUFFER_BINDINGS: 0x8A2F, + MAX_UNIFORM_BLOCK_SIZE: 0x8A30, + MAX_COMBINED_VERTEX_UNIFORM_COMPONENTS: 0x8A31, + MAX_COMBINED_FRAGMENT_UNIFORM_COMPONENTS: 0x8A33, + UNIFORM_BUFFER_OFFSET_ALIGNMENT: 0x8A34, + ACTIVE_UNIFORM_BLOCKS: 0x8A36, + UNIFORM_TYPE: 0x8A37, + UNIFORM_SIZE: 0x8A38, + UNIFORM_BLOCK_INDEX: 0x8A3A, + UNIFORM_OFFSET: 0x8A3B, + UNIFORM_ARRAY_STRIDE: 0x8A3C, + UNIFORM_MATRIX_STRIDE: 0x8A3D, + UNIFORM_IS_ROW_MAJOR: 0x8A3E, + UNIFORM_BLOCK_BINDING: 0x8A3F, + UNIFORM_BLOCK_DATA_SIZE: 0x8A40, + UNIFORM_BLOCK_ACTIVE_UNIFORMS: 0x8A42, + UNIFORM_BLOCK_ACTIVE_UNIFORM_INDICES: 0x8A43, + UNIFORM_BLOCK_REFERENCED_BY_VERTEX_SHADER: 0x8A44, + UNIFORM_BLOCK_REFERENCED_BY_FRAGMENT_SHADER: 0x8A46, + INVALID_INDEX: 0xFFFFFFFF, + MAX_VERTEX_OUTPUT_COMPONENTS: 0x9122, + MAX_FRAGMENT_INPUT_COMPONENTS: 0x9125, + MAX_SERVER_WAIT_TIMEOUT: 0x9111, + OBJECT_TYPE: 0x9112, + SYNC_CONDITION: 0x9113, + SYNC_STATUS: 0x9114, + SYNC_FLAGS: 0x9115, + SYNC_FENCE: 0x9116, + SYNC_GPU_COMMANDS_COMPLETE: 0x9117, + UNSIGNALED: 0x9118, + SIGNALED: 0x9119, + ALREADY_SIGNALED: 0x911A, + TIMEOUT_EXPIRED: 0x911B, + CONDITION_SATISFIED: 0x911C, + WAIT_FAILED: 0x911D, + SYNC_FLUSH_COMMANDS_BIT: 0x00000001, + VERTEX_ATTRIB_ARRAY_DIVISOR: 0x88FE, + ANY_SAMPLES_PASSED: 0x8C2F, + ANY_SAMPLES_PASSED_CONSERVATIVE: 0x8D6A, + SAMPLER_BINDING: 0x8919, + RGB10_A2UI: 0x906F, + INT_2_10_10_10_REV: 0x8D9F, + TRANSFORM_FEEDBACK: 0x8E22, + TRANSFORM_FEEDBACK_PAUSED: 0x8E23, + TRANSFORM_FEEDBACK_ACTIVE: 0x8E24, + TRANSFORM_FEEDBACK_BINDING: 0x8E25, + TEXTURE_IMMUTABLE_FORMAT: 0x912F, + MAX_ELEMENT_INDEX: 0x8D6B, + TEXTURE_IMMUTABLE_LEVELS: 0x82DF, + TIMEOUT_IGNORED: -1, + MAX_CLIENT_WAIT_TIMEOUT_WEBGL: 0x9247, copyBufferSubData: function (...args) { - console.warn("webgl.copyBufferSubData interface mocked in the Previewer. How this interface works on the" + + console.warn("WebGL2RenderingContext.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" + + console.warn("WebGL2RenderingContext.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" + + console.warn("WebGL2RenderingContext.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" + + console.warn("WebGL2RenderingContext.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" + + console.warn("WebGL2RenderingContext.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" + + console.warn("WebGL2RenderingContext.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" + + console.warn("WebGL2RenderingContext.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" + + console.warn("WebGL2RenderingContext.getInternalformatParameter interface mocked in the Previewer. How this interface works on the" + " Previewer may be different from that on a real device.") if (args[2] == GL_SAMPLES) { return glParamMock.int32Array } }, renderbufferStorageMultisample: function (...args) { - console.warn("webgl.renderbufferStorageMultisample interface mocked in the Previewer. How this interface works on the" + + console.warn("WebGL2RenderingContext.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" + + console.warn("WebGL2RenderingContext.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" + + console.warn("WebGL2RenderingContext.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" + + console.warn("WebGL2RenderingContext.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" + + console.warn("WebGL2RenderingContext.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" + + console.warn("WebGL2RenderingContext.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" + + console.warn("WebGL2RenderingContext.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" + + console.warn("WebGL2RenderingContext.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" + + console.warn("WebGL2RenderingContext.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" + + console.warn("WebGL2RenderingContext.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" + + console.warn("WebGL2RenderingContext.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" + + console.warn("WebGL2RenderingContext.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" + + console.warn("WebGL2RenderingContext.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" + + console.warn("WebGL2RenderingContext.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" + + console.warn("WebGL2RenderingContext.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" + + console.warn("WebGL2RenderingContext.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" + + console.warn("WebGL2RenderingContext.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" + + console.warn("WebGL2RenderingContext.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" + + console.warn("WebGL2RenderingContext.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" + + console.warn("WebGL2RenderingContext.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" + + console.warn("WebGL2RenderingContext.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" + + console.warn("WebGL2RenderingContext.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" + + console.warn("WebGL2RenderingContext.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" + + console.warn("WebGL2RenderingContext.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" + + console.warn("WebGL2RenderingContext.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" + + console.warn("WebGL2RenderingContext.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" + + console.warn("WebGL2RenderingContext.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" + + console.warn("WebGL2RenderingContext.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" + + console.warn("WebGL2RenderingContext.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" + + console.warn("WebGL2RenderingContext.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" + + console.warn("WebGL2RenderingContext.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" + + console.warn("WebGL2RenderingContext.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" + + console.warn("WebGL2RenderingContext.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" + + console.warn("WebGL2RenderingContext.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" + + console.warn("WebGL2RenderingContext.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" + + console.warn("WebGL2RenderingContext.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" + + console.warn("WebGL2RenderingContext.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" + + console.warn("WebGL2RenderingContext.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" + + console.warn("WebGL2RenderingContext.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" + + console.warn("WebGL2RenderingContext.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" + + console.warn("WebGL2RenderingContext.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" + + console.warn("WebGL2RenderingContext.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" + + console.warn("WebGL2RenderingContext.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" + + console.warn("WebGL2RenderingContext.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; @@ -267,34 +526,34 @@ export function mockwebgl2() { } }, createSampler: function (...args) { - console.warn("webgl2.createSampler interface mocked in the Previewer. How this interface works on the" + + console.warn("WebGL2RenderingContext.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" + + console.warn("WebGL2RenderingContext.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" + + console.warn("WebGL2RenderingContext.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" + + console.warn("WebGL2RenderingContext.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" + + console.warn("WebGL2RenderingContext.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" + + console.warn("WebGL2RenderingContext.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" + + console.warn("WebGL2RenderingContext.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 || args[1] == GL_TEXTURE_MIN_LOD) { return glParamMock.paramDoubleMock; @@ -303,209 +562,209 @@ export function mockwebgl2() { } }, fenceSync: function (...args) { - console.warn("webgl2.fenceSync interface mocked in the Previewer. How this interface works on the" + + console.warn("WebGL2RenderingContext.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" + + console.warn("WebGL2RenderingContext.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" + + console.warn("WebGL2RenderingContext.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" + + console.warn("WebGL2RenderingContext.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" + + console.warn("WebGL2RenderingContext.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" + + console.warn("WebGL2RenderingContext.getSyncParameter interface mocked in the Previewer. How this interface works on the" + " Previewer may be different from that on a real device.") return glParamMock.paramAnyMock; }, createTransformFeedback: function (...args) { - console.warn("webgl2.createTransformFeedback interface mocked in the Previewer. How this interface works on the" + + console.warn("WebGL2RenderingContext.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" + + console.warn("WebGL2RenderingContext.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" + + console.warn("WebGL2RenderingContext.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" + + console.warn("WebGL2RenderingContext.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" + + console.warn("WebGL2RenderingContext.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" + + console.warn("WebGL2RenderingContext.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" + + console.warn("WebGL2RenderingContext.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" + + console.warn("WebGL2RenderingContext.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" + + console.warn("WebGL2RenderingContext.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" + + console.warn("WebGL2RenderingContext.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" + + console.warn("WebGL2RenderingContext.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" + + console.warn("WebGL2RenderingContext.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" + + console.warn("WebGL2RenderingContext.getIndexedParameter interface mocked in the Previewer. How this interface works on the" + " Previewer may be different from that on a real device.") return glParamMock.paramAnyMock; }, getUniformIndices: function (...args) { - console.warn("webgl2.getUniformIndices interface mocked in the Previewer. How this interface works on the" + + console.warn("WebGL2RenderingContext.getUniformIndices interface mocked in the Previewer. How this interface works on the" + " Previewer may be different from that on a real device.") return glParamMock.uintArray; }, getActiveUniforms: function (...args) { - console.warn("webgl2.getActiveUniforms interface mocked in the Previewer. How this interface works on the" + + console.warn("WebGL2RenderingContext.getActiveUniforms interface mocked in the Previewer. How this interface works on the" + " Previewer may be different from that on a real device.") return glParamMock.paramAnyMock; }, getUniformBlockIndex: function (...args) { - console.warn("webgl2.getUniformBlockIndex interface mocked in the Previewer. How this interface works on the" + + console.warn("WebGL2RenderingContext.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" + + console.warn("WebGL2RenderingContext.getActiveUniformBlockParameter interface mocked in the Previewer. How this interface works on the" + " Previewer may be different from that on a real device.") return glParamMock.paramAnyMock; }, getActiveUniformBlockName: function (...args) { - console.warn("webgl2.getActiveUniformBlockName interface mocked in the Previewer. How this interface works on the" + + console.warn("WebGL2RenderingContext.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" + + console.warn("WebGL2RenderingContext.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" + + console.warn("WebGL2RenderingContext.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" + + console.warn("WebGL2RenderingContext.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" + + console.warn("WebGL2RenderingContext.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" + + console.warn("WebGL2RenderingContext.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" + + console.warn("WebGL2RenderingContext.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" + + console.warn("WebGL2RenderingContext.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" + + console.warn("WebGL2RenderingContext.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" + + console.warn("WebGL2RenderingContext.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" + + console.warn("WebGL2RenderingContext.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" + + console.warn("WebGL2RenderingContext.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" + + console.warn("WebGL2RenderingContext.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" + + console.warn("WebGL2RenderingContext.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" + + console.warn("WebGL2RenderingContext.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" + + console.warn("WebGL2RenderingContext.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" + + console.warn("WebGL2RenderingContext.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" + + console.warn("WebGL2RenderingContext.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" + + console.warn("WebGL2RenderingContext.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" + + console.warn("WebGL2RenderingContext.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" + + console.warn("WebGL2RenderingContext.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" + + console.warn("WebGL2RenderingContext.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" + + console.warn("WebGL2RenderingContext.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" + + console.warn("WebGL2RenderingContext.readPixels interface mocked in the Previewer. How this interface works on the" + " Previewer may be different from that on a real device.") } } - return webgl2Mock; + return WebGL2RenderingContext; } \ No newline at end of file From 3ad391576d515d11bf7cb2db355c0d70b26e4b02 Mon Sep 17 00:00:00 2001 From: zhangxingxia Date: Thu, 14 Jul 2022 14:50:23 +0800 Subject: [PATCH 070/109] update jsmock Signed-off-by: zhangxingxia --- .../main/extend/systemplugin/napi/index.js | 4 +- .../systemplugin/napi/ohos_fileManager.js | 19 +++-- .../napi/ohos_storageStatistics.js | 69 ++++++++++++++++++ .../systemplugin/napi/ohos_volumeManager.js | 70 ++++++++++++++++++- .../systemplugin/napi/volume/volumeInfo.js | 23 ------ 5 files changed, 152 insertions(+), 33 deletions(-) delete mode 100644 runtime/main/extend/systemplugin/napi/volume/volumeInfo.js diff --git a/runtime/main/extend/systemplugin/napi/index.js b/runtime/main/extend/systemplugin/napi/index.js index 704dc192..4ebe5be6 100644 --- a/runtime/main/extend/systemplugin/napi/index.js +++ b/runtime/main/extend/systemplugin/napi/index.js @@ -394,9 +394,9 @@ export function mockRequireNapiFun() { return mockFileManager(); case "environment": return mockEnvironment(); - case "storagestatistics": + case "storageStatistics": return mockStorageStatistics(); - case "volumemanager": + case "volumeManager": return mockVolumeManager(); case "settings": return mockSettings(); diff --git a/runtime/main/extend/systemplugin/napi/ohos_fileManager.js b/runtime/main/extend/systemplugin/napi/ohos_fileManager.js index 47ae70a4..b753134e 100644 --- a/runtime/main/extend/systemplugin/napi/ohos_fileManager.js +++ b/runtime/main/extend/systemplugin/napi/ohos_fileManager.js @@ -16,24 +16,29 @@ import { paramMock } from "../utils" export function mockFileManager() { - const fileInfoMock = { + const FileInfoMock = { name: '[PC preview] unknow name', path: '[PC preview] unknow path', type: '[PC preview] unknow type', size: '[PC preview] unknow size', addedTime: '[PC preview] unknow addedTime', - modifiedTime: '[PC preview] unknow modifiedTime', + modifiedTime: '[PC preview] unknow modifiedTime' + }; + const DevInfoMock = { + name: '[PC preview] unknow name' }; const filemanager = { + FileInfo: FileInfoMock, + DevInfo: DevInfoMock, getRoot: function (...args) { console.warn("filemanager.getRoot interface mocked in the Previewer. How this interface works on the" + " Previewer may be different from that on a real device.") const len = args.length if (typeof args[len - 1] === 'function') { - args[len - 1].call(this, paramMock.businessErrorMock, Array(fileInfoMock)) + args[len - 1].call(this, paramMock.businessErrorMock, Array(FileInfoMock)) } else { return new Promise((resolve, reject) => { - resolve(Array(fileInfoMock)); + resolve(Array(FileInfoMock)); }) } }, @@ -42,10 +47,10 @@ export function mockFileManager() { " Previewer may be different from that on a real device.") const len = args.length if (typeof args[len - 1] === 'function') { - args[len - 1].call(this, paramMock.businessErrorMock, Array(fileInfoMock)) + args[len - 1].call(this, paramMock.businessErrorMock, Array(FileInfoMock)) } else { return new Promise((resolve, reject) => { - resolve(Array(fileInfoMock)); + resolve(Array(FileInfoMock)); }) } }, @@ -60,7 +65,7 @@ export function mockFileManager() { resolve(paramMock.paramStringMock); }) } - }, + } } return filemanager; } diff --git a/runtime/main/extend/systemplugin/napi/ohos_storageStatistics.js b/runtime/main/extend/systemplugin/napi/ohos_storageStatistics.js index c954be1e..d8e5ded9 100644 --- a/runtime/main/extend/systemplugin/napi/ohos_storageStatistics.js +++ b/runtime/main/extend/systemplugin/napi/ohos_storageStatistics.js @@ -21,8 +21,17 @@ export function mockStorageStatistics() { cacheSize: '[PC preview] unknow cacheSize', dataSize: '[PC preview] unknow dataSize' }; + const StorageStatsMock = { + total: '[PC preview] unknow total', + audio: '[PC preview] unknow audio', + video: '[PC preview] unknow video', + image: '[PC preview] unknow image', + file: '[PC preview] unknow file', + app: '[PC preview] unknow app' + } const storageStatistics = { BundleStats: BundleStatsMock, + StorageStats: StorageStatsMock, getTotalSizeOfVolume: function(...args) { console.warn('storageStatistics.getTotalSizeOfVolume interface mocked in the Previewer. How this interface works on the' + ' Previewer may be different from that on a real device.'); @@ -58,6 +67,66 @@ export function mockStorageStatistics() { resolve(BundleStatsMock); }); } + }, + getCurrentBundleStats: function(...args) { + console.warn('storageStatistics.getCurrentBundleStats interface mocked in the Previewer. How this interface works on the' + + ' Previewer may be different from that on a real device.'); + const len = args.length; + if (typeof args[len - 1] === 'function') { + args[len - 1].call(this, paramMock.businessErrorMock, BundleStatsMock); + } else { + return new Promise((resolve, reject) => { + resolve(BundleStatsMock); + }); + } + }, + getSystemSize: function(...args) { + console.warn('storageStatistics.getSystemSize interface mocked in the Previewer. How this interface works on the' + + ' Previewer may be different 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); + }); + } + }, + getUserStorageStats: function(...args) { + console.warn('storageStatistics.getUserStorageStats interface mocked in the Previewer. How this interface works on the' + + ' Previewer may be different from that on a real device.'); + const len = args.length; + if (typeof args[len - 1] === 'function') { + args[len - 1].call(this, paramMock.businessErrorMock, StorageStatsMock); + } else { + return new Promise((resolve, reject) => { + resolve(StorageStatsMock); + }); + } + }, + getTotalSize: function(...args) { + console.warn('storageStatistics.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, paramMock.paramNumberMock); + } else { + return new Promise((resolve, reject) => { + resolve(paramMock.paramNumberMock); + }); + } + }, + getFreeSize: function(...args) { + console.warn('storageStatistics.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, paramMock.paramNumberMock); + } else { + return new Promise((resolve, reject) => { + resolve(paramMock.paramNumberMock); + }); + } } }; return storageStatistics; diff --git a/runtime/main/extend/systemplugin/napi/ohos_volumeManager.js b/runtime/main/extend/systemplugin/napi/ohos_volumeManager.js index 9adf2ac3..f7d0e5ac 100644 --- a/runtime/main/extend/systemplugin/napi/ohos_volumeManager.js +++ b/runtime/main/extend/systemplugin/napi/ohos_volumeManager.js @@ -14,10 +14,18 @@ */ import { paramMock } from "../utils" -import {VolumeMock} from './volume/volumeInfo' export function mockVolumeManager() { + const VolumeMock = { + id: '[PC preview] unknow id', + uuid: '[PC preview] unknow uuid', + description: '[PC preview] unknow description', + removeAble: '[PC preview] unknow removeAble', + path: '[PC preview] unknow path', + state: '[PC preview] unknow state' + }; const volumeManager = { + Volume: VolumeMock, getAllVolumes: function (...args) { console.warn("volumeManager.getAllVolumes interface mocked in the Previewer. How this interface works on the" + " Previewer may be different from that on a real device."); @@ -54,6 +62,66 @@ export function mockVolumeManager() { }) } }, + getVolumeByUuid: function (...args) { + console.warn("volumeManager.getVolumeByUuid interface mocked in the Previewer. How this interface works on the" + + " Previewer may be different from that on a real device."); + const len = args.length; + if (typeof args[len - 1] === 'function') { + args[len - 1].call(this, paramMock.businessErrorMock, VolumeMock); + } else { + return new Promise((resolve, reject) => { + resolve(VolumeMock); + }) + } + }, + getVolumeById: function (...args) { + console.warn("volumeManager.getVolumeById interface mocked in the Previewer. How this interface works on the" + + " Previewer may be different from that on a real device."); + const len = args.length; + if (typeof args[len - 1] === 'function') { + args[len - 1].call(this, paramMock.businessErrorMock, VolumeMock); + } else { + return new Promise((resolve, reject) => { + resolve(VolumeMock); + }) + } + }, + setVolumeDescription: function (...args) { + console.warn("volumeManager.setVolumeDescription interface mocked in the Previewer. How this interface works on the" + + " Previewer may be different from that on a 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(); + }) + } + }, + format: function (...args) { + console.warn("volumeManager.format interface mocked in the Previewer. How this interface works on the" + + " Previewer may be different from that on a 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(); + }) + } + }, + partition: function (...args) { + console.warn("volumeManager.partition interface mocked in the Previewer. How this interface works on the" + + " Previewer may be different from that on a real device."); + const len = args.length; + if (typeof args[len - 1] === 'function') { + args[len - 1].call(this, paramMock.businessErrorMock); + } else { + return new Promise((resolve, reject) => { + resolve(); + }) + } + } } return volumeManager; } diff --git a/runtime/main/extend/systemplugin/napi/volume/volumeInfo.js b/runtime/main/extend/systemplugin/napi/volume/volumeInfo.js deleted file mode 100644 index 529b1fe8..00000000 --- a/runtime/main/extend/systemplugin/napi/volume/volumeInfo.js +++ /dev/null @@ -1,23 +0,0 @@ -/* - * Copyright (c) 2022 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -export const VolumeMock = { - id: '[PC preview] unknow id', - uuid: '[PC preview] unknow uuid', - description: '[PC preview] unknow description', - removeAble: '[PC preview] unknow removeAble', - path: '[PC preview] unknow path', - state: '[PC preview] unknow state', -}; \ No newline at end of file From 0baecaabfad53b6743a1a08c74866a89f2f53db3 Mon Sep 17 00:00:00 2001 From: duanweiling Date: Thu, 14 Jul 2022 14:55:45 +0800 Subject: [PATCH 071/109] =?UTF-8?q?DataShare=20=E5=88=A0=E9=99=A4=E9=87=8D?= =?UTF-8?q?=E5=A4=8D=E6=89=93=E5=8D=B0mock?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: duanweiling --- .../extend/systemplugin/napi/ohos_data_DataShareResultSet.js | 4 ---- 1 file changed, 4 deletions(-) diff --git a/runtime/main/extend/systemplugin/napi/ohos_data_DataShareResultSet.js b/runtime/main/extend/systemplugin/napi/ohos_data_DataShareResultSet.js index 65f07654..c444525d 100644 --- a/runtime/main/extend/systemplugin/napi/ohos_data_DataShareResultSet.js +++ b/runtime/main/extend/systemplugin/napi/ohos_data_DataShareResultSet.js @@ -20,10 +20,6 @@ export const DataShareResultSetMock = { columnCount: "[PC Preview] unknow columnCount", rowCount: "[PC Preview] unknow rowCount", rowIndex: "[PC Preview] unknow rowIndex", - goToFirstRow: "[PC Preview] unknow goToFirstRow", - goToLastRow: "[PC Preview] unknow goToLastRow", - goToNextRow: "[PC Preview] unknow goToNextRow", - goToPreviousRow: "[PC Preview] unknow goToPreviousRow", isEnded: "[PC Preview] unknow isEnded", isStarted: "[PC Preview] unknow isStarted", isClosed: "[PC Preview] unknow isClosed", From 5c4f8c9c3b61203b54639c31586cf67d49cae3d6 Mon Sep 17 00:00:00 2001 From: zhangxingxia Date: Thu, 14 Jul 2022 14:55:49 +0800 Subject: [PATCH 072/109] update jsmock Signed-off-by: zhangxingxia --- .../systemplugin/napi/ohos_fileManager.js | 18 +++++++++--------- .../napi/ohos_storageStatistics.js | 16 ++++++++-------- .../systemplugin/napi/ohos_volumeManager.js | 16 ++++++++-------- 3 files changed, 25 insertions(+), 25 deletions(-) diff --git a/runtime/main/extend/systemplugin/napi/ohos_fileManager.js b/runtime/main/extend/systemplugin/napi/ohos_fileManager.js index b753134e..6491bda7 100644 --- a/runtime/main/extend/systemplugin/napi/ohos_fileManager.js +++ b/runtime/main/extend/systemplugin/napi/ohos_fileManager.js @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021 Huawei Device Co., Ltd. + * Copyright (c) 2021-2022 Huawei Device Co., Ltd. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at @@ -16,7 +16,7 @@ import { paramMock } from "../utils" export function mockFileManager() { - const FileInfoMock = { + const FileInfo = { name: '[PC preview] unknow name', path: '[PC preview] unknow path', type: '[PC preview] unknow type', @@ -24,21 +24,21 @@ export function mockFileManager() { addedTime: '[PC preview] unknow addedTime', modifiedTime: '[PC preview] unknow modifiedTime' }; - const DevInfoMock = { + const DevInfo = { name: '[PC preview] unknow name' }; const filemanager = { - FileInfo: FileInfoMock, - DevInfo: DevInfoMock, + FileInfo: FileInfo, + DevInfo: DevInfo, getRoot: function (...args) { console.warn("filemanager.getRoot interface mocked in the Previewer. How this interface works on the" + " Previewer may be different from that on a real device.") const len = args.length if (typeof args[len - 1] === 'function') { - args[len - 1].call(this, paramMock.businessErrorMock, Array(FileInfoMock)) + args[len - 1].call(this, paramMock.businessErrorMock, Array(FileInfo)) } else { return new Promise((resolve, reject) => { - resolve(Array(FileInfoMock)); + resolve(Array(FileInfo)); }) } }, @@ -47,10 +47,10 @@ export function mockFileManager() { " Previewer may be different from that on a real device.") const len = args.length if (typeof args[len - 1] === 'function') { - args[len - 1].call(this, paramMock.businessErrorMock, Array(FileInfoMock)) + args[len - 1].call(this, paramMock.businessErrorMock, Array(FileInfo)) } else { return new Promise((resolve, reject) => { - resolve(Array(FileInfoMock)); + resolve(Array(FileInfo)); }) } }, diff --git a/runtime/main/extend/systemplugin/napi/ohos_storageStatistics.js b/runtime/main/extend/systemplugin/napi/ohos_storageStatistics.js index d8e5ded9..4f4c7511 100644 --- a/runtime/main/extend/systemplugin/napi/ohos_storageStatistics.js +++ b/runtime/main/extend/systemplugin/napi/ohos_storageStatistics.js @@ -16,12 +16,12 @@ import { paramMock } from '../utils'; export function mockStorageStatistics() { - const BundleStatsMock = { + const BundleStats = { appSize: '[PC preview] unknow appSize', cacheSize: '[PC preview] unknow cacheSize', dataSize: '[PC preview] unknow dataSize' }; - const StorageStatsMock = { + const StorageStats= { total: '[PC preview] unknow total', audio: '[PC preview] unknow audio', video: '[PC preview] unknow video', @@ -30,8 +30,8 @@ export function mockStorageStatistics() { app: '[PC preview] unknow app' } const storageStatistics = { - BundleStats: BundleStatsMock, - StorageStats: StorageStatsMock, + BundleStats: BundleStats, + StorageStats: StorageStats, getTotalSizeOfVolume: function(...args) { console.warn('storageStatistics.getTotalSizeOfVolume interface mocked in the Previewer. How this interface works on the' + ' Previewer may be different from that on a real device.'); @@ -73,10 +73,10 @@ export function mockStorageStatistics() { ' Previewer may be different from that on a real device.'); const len = args.length; if (typeof args[len - 1] === 'function') { - args[len - 1].call(this, paramMock.businessErrorMock, BundleStatsMock); + args[len - 1].call(this, paramMock.businessErrorMock, BundleStats); } else { return new Promise((resolve, reject) => { - resolve(BundleStatsMock); + resolve(BundleStats); }); } }, @@ -97,10 +97,10 @@ export function mockStorageStatistics() { ' Previewer may be different from that on a real device.'); const len = args.length; if (typeof args[len - 1] === 'function') { - args[len - 1].call(this, paramMock.businessErrorMock, StorageStatsMock); + args[len - 1].call(this, paramMock.businessErrorMock, StorageStats); } else { return new Promise((resolve, reject) => { - resolve(StorageStatsMock); + resolve(StorageStats); }); } }, diff --git a/runtime/main/extend/systemplugin/napi/ohos_volumeManager.js b/runtime/main/extend/systemplugin/napi/ohos_volumeManager.js index f7d0e5ac..412dda53 100644 --- a/runtime/main/extend/systemplugin/napi/ohos_volumeManager.js +++ b/runtime/main/extend/systemplugin/napi/ohos_volumeManager.js @@ -16,7 +16,7 @@ import { paramMock } from "../utils" export function mockVolumeManager() { - const VolumeMock = { + const Volume = { id: '[PC preview] unknow id', uuid: '[PC preview] unknow uuid', description: '[PC preview] unknow description', @@ -25,16 +25,16 @@ export function mockVolumeManager() { state: '[PC preview] unknow state' }; const volumeManager = { - Volume: VolumeMock, + Volume: Volume, getAllVolumes: function (...args) { console.warn("volumeManager.getAllVolumes interface mocked in the Previewer. How this interface works on the" + " Previewer may be different from that on a real device."); const len = args.length; if (typeof args[len - 1] === 'function') { - args[len - 1].call(this, paramMock.businessErrorMock, Array(VolumeMock)); + args[len - 1].call(this, paramMock.businessErrorMock, Array(Volume)); } else { return new Promise((resolve, reject) => { - resolve(Array(VolumeMock)); + resolve(Array(Volume)); }) } }, @@ -67,10 +67,10 @@ export function mockVolumeManager() { " Previewer may be different from that on a real device."); const len = args.length; if (typeof args[len - 1] === 'function') { - args[len - 1].call(this, paramMock.businessErrorMock, VolumeMock); + args[len - 1].call(this, paramMock.businessErrorMock, Volume); } else { return new Promise((resolve, reject) => { - resolve(VolumeMock); + resolve(Volume); }) } }, @@ -79,10 +79,10 @@ export function mockVolumeManager() { " Previewer may be different from that on a real device."); const len = args.length; if (typeof args[len - 1] === 'function') { - args[len - 1].call(this, paramMock.businessErrorMock, VolumeMock); + args[len - 1].call(this, paramMock.businessErrorMock, Volume); } else { return new Promise((resolve, reject) => { - resolve(VolumeMock); + resolve(Volume); }) } }, From 39d99bf12e51f976d59bd4b9426d34b3e982c849 Mon Sep 17 00:00:00 2001 From: wangkai Date: Thu, 14 Jul 2022 16:25:39 +0800 Subject: [PATCH 073/109] api mock change Signed-off-by: wangkai --- .../napi/ohos_data_distributedData.js | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/runtime/main/extend/systemplugin/napi/ohos_data_distributedData.js b/runtime/main/extend/systemplugin/napi/ohos_data_distributedData.js index 1e420cb4..0f3e7711 100644 --- a/runtime/main/extend/systemplugin/napi/ohos_data_distributedData.js +++ b/runtime/main/extend/systemplugin/napi/ohos_data_distributedData.js @@ -229,13 +229,13 @@ export function mockDistributedData() { S4: 6, }, - SyncMode :{ + SyncMode: { PULL_ONLY: 0, PUSH_ONLY: 1, PUSH_PULL: 2, }, - SubscribeType : { + SubscribeType: { SUBSCRIBE_TYPE_LOCAL: 0, SUBSCRIBE_TYPE_REMOTE: 1, SUBSCRIBE_TYPE_ALL: 2, @@ -275,6 +275,17 @@ export function mockDistributedData() { MAX_QUERY_LENGTH: "[PC Preview] unknown MAX_QUERY_LENGTH", MAX_BATCH_SIZE: "[PC Preview] unknown MAX_BATCH_SIZE" }; + const schemaMock = { + root: "[PC Preview] unknown root", + indexes: "[PC Preview] unknown indexes", + mode: "[PC Preview] unknown mode", + skip: "[PC Preview] unknown skip" + }; + const fieldnodeMock = { + default: "[PC Preview] unknown default", + nullable: "[PC Preview] unknown nullable", + type: "[PC Preview] unknown type" + }; const valueTypeMock = { STRING: "[PC Preview] unknown STRING", INTEGER: "[PC Preview] unknown INTEGER", @@ -304,6 +315,7 @@ export function mockDistributedData() { autoSync: "[PC Preview] unknown autoSync", kvStoreType: "[PC Preview] unknown kvStoreType", securityLevel: "[PC Preview] unknown securityLevel", + schema : "[PC Preview] unknown schema" }; const KVStoreClass = class KVStore { From e19a624349d33a89a2bbf7ab3d46e2e6770530f9 Mon Sep 17 00:00:00 2001 From: wangkai Date: Fri, 15 Jul 2022 15:04:05 +0800 Subject: [PATCH 074/109] =?UTF-8?q?api=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: wangkai --- .../extend/systemplugin/napi/ohos_data_distributedData.js | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/runtime/main/extend/systemplugin/napi/ohos_data_distributedData.js b/runtime/main/extend/systemplugin/napi/ohos_data_distributedData.js index 0f3e7711..8480ae59 100644 --- a/runtime/main/extend/systemplugin/napi/ohos_data_distributedData.js +++ b/runtime/main/extend/systemplugin/napi/ohos_data_distributedData.js @@ -368,6 +368,9 @@ export function mockDistributedData() { if (typeof args[len - 1] === 'function') { if (args[0] == 'dataChange') { args[len - 1].call(this, paramMock.businessErrorMock, changeNotificationMock) + } else if (args[0] === 'syncComplete') { + var array = new Array([paramMock.paramStringMock, paramMock.paramNumberMock]); + args[len - 1].call(this, array); } } }; @@ -379,6 +382,9 @@ export function mockDistributedData() { if (typeof args[len - 1] === 'function') { if (args[0] == 'dataChange') { args[len - 1].call(this, paramMock.businessErrorMock, changeNotificationMock) + } else if (args[0] === 'syncComplete') { + var array = new Array([paramMock.paramStringMock, paramMock.paramNumberMock]); + args[len - 1].call(this, array); } } }; From 49f291d5a05382094eb385bbf17b508ff0bacbbb Mon Sep 17 00:00:00 2001 From: magekkkk Date: Fri, 15 Jul 2022 15:14:43 +0800 Subject: [PATCH 075/109] add missing mock for audio interfaces Signed-off-by: magekkkk --- .../extend/systemplugin/napi/ohos_multimedia_audio.js | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/runtime/main/extend/systemplugin/napi/ohos_multimedia_audio.js b/runtime/main/extend/systemplugin/napi/ohos_multimedia_audio.js index b94ce59b..8de8a9c0 100644 --- a/runtime/main/extend/systemplugin/napi/ohos_multimedia_audio.js +++ b/runtime/main/extend/systemplugin/napi/ohos_multimedia_audio.js @@ -70,7 +70,16 @@ export function mockMultimediaAudio() { } const AudioState = '[PC Preview] unknow AudioState' const AudioRendererRate = '[PC Preview] unknow AudioRendererRate' - const InterruptEvent = '[PC Preview] unknow InterruptEvent' + const InterruptEvent = { + eventType: "[PC Preview] unknow eventType", + forceType: "[PC Preview] unknow forceType", + hintType: "[PC Preview] unknow hintType", + } + const AudioInterrupt = { + streamUsage: "[PC Preview] unknow streamUsage", + contentType: "[PC Preview] unknow contentType", + pauseWhenDucked: "[PC Preview] unknow pauseWhenDucked", + } const AudioRendererChangeInfo = { streamId: "[PC Preview] unknow streamId", clientUid: "[PC Preview] unknow clientUid", From c704d07e11bcde9374be42694a5f87d28a51bebc Mon Sep 17 00:00:00 2001 From: liuyanzhi Date: Thu, 14 Jul 2022 09:56:16 +0800 Subject: [PATCH 076/109] add ability mock Signed-off-by: liuyanzhi Change-Id: I7cf4f2069053cade066c17233ac53a99d64d6d1f --- .../napi/@internal/ets/lifecycle.js | 253 +++++++++++ .../napi/ability/abilityResult.js | 20 + .../napi/ability/connectOptions.js | 29 ++ .../napi/ability/startAbilityParameter.js | 20 + .../extend/systemplugin/napi/ability/want.js | 27 ++ .../systemplugin/napi/app/appVersionInfo.js | 20 + .../extend/systemplugin/napi/app/context.js | 317 +++++++++++++ .../systemplugin/napi/app/processInfo.js | 19 + .../{abilityContext.js => AbilityContext.js} | 97 ++-- .../napi/application/BaseContext.js | 18 + .../systemplugin/napi/application/Context.js | 311 +++++++++++++ .../napi/application/FormExtensionContext.js | 34 ++ .../napi/application/abilityMonitor.js | 45 ++ .../napi/common/full/featureability.js | 156 +++++++ .../continuation/continuationExtraParams.js | 27 ++ .../napi/continuation/continuationResult.js | 19 + .../main/extend/systemplugin/napi/index.js | 15 + .../napi/ohos_ability_errorCode.js | 20 + .../napi/ohos_ability_featureAbility.js | 425 ++++++++++++++++++ .../napi/ohos_ability_wantConstant.js | 68 +++ .../napi/ohos_application_Ability.js | 31 +- .../napi/ohos_application_AbilityConstant.js | 15 + .../napi/ohos_application_AbilityStage.js | 10 +- .../napi/ohos_application_Configuration.js | 22 + .../ohos_application_ConfigurationConstant.js | 33 ++ ...s_application_DataShareExtensionAbility.js | 2 +- .../napi/ohos_application_FormExtension.js | 14 +- ...hos_application_ServiceExtensionAbility.js | 7 +- .../napi/ohos_application_StartOptions.js | 22 + ...cation_StaticSubscriberExtensionAbility.js | 27 ++ .../napi/ohos_application_abilityManager.js | 27 ++ .../napi/ohos_application_appManager.js | 24 + .../napi/ohos_application_errorManager.js | 38 ++ .../napi/ohos_application_formBindingData.js | 13 +- .../napi/ohos_application_formError.js | 39 ++ .../napi/ohos_application_formHost.js | 219 +++++++++ .../napi/ohos_application_formInfo.js | 66 +++ .../napi/ohos_application_formProvider.js | 58 ++- .../napi/ohos_application_testRunner.js | 27 ++ .../systemplugin/napi/ohos_commonEvent.js | 4 +- .../systemplugin/napi/ohos_wantAgent.js | 88 ++-- 41 files changed, 2606 insertions(+), 120 deletions(-) create mode 100644 runtime/main/extend/systemplugin/napi/@internal/ets/lifecycle.js create mode 100644 runtime/main/extend/systemplugin/napi/ability/abilityResult.js create mode 100644 runtime/main/extend/systemplugin/napi/ability/connectOptions.js create mode 100644 runtime/main/extend/systemplugin/napi/ability/startAbilityParameter.js create mode 100644 runtime/main/extend/systemplugin/napi/ability/want.js create mode 100644 runtime/main/extend/systemplugin/napi/app/appVersionInfo.js create mode 100644 runtime/main/extend/systemplugin/napi/app/context.js create mode 100644 runtime/main/extend/systemplugin/napi/app/processInfo.js rename runtime/main/extend/systemplugin/napi/application/{abilityContext.js => AbilityContext.js} (82%) create mode 100644 runtime/main/extend/systemplugin/napi/application/BaseContext.js create mode 100644 runtime/main/extend/systemplugin/napi/application/Context.js create mode 100644 runtime/main/extend/systemplugin/napi/application/FormExtensionContext.js create mode 100644 runtime/main/extend/systemplugin/napi/application/abilityMonitor.js create mode 100644 runtime/main/extend/systemplugin/napi/common/full/featureability.js create mode 100644 runtime/main/extend/systemplugin/napi/continuation/continuationExtraParams.js create mode 100644 runtime/main/extend/systemplugin/napi/continuation/continuationResult.js create mode 100644 runtime/main/extend/systemplugin/napi/ohos_ability_errorCode.js create mode 100644 runtime/main/extend/systemplugin/napi/ohos_ability_featureAbility.js create mode 100644 runtime/main/extend/systemplugin/napi/ohos_ability_wantConstant.js create mode 100644 runtime/main/extend/systemplugin/napi/ohos_application_Configuration.js create mode 100644 runtime/main/extend/systemplugin/napi/ohos_application_ConfigurationConstant.js create mode 100644 runtime/main/extend/systemplugin/napi/ohos_application_StartOptions.js create mode 100644 runtime/main/extend/systemplugin/napi/ohos_application_StaticSubscriberExtensionAbility.js create mode 100644 runtime/main/extend/systemplugin/napi/ohos_application_errorManager.js create mode 100644 runtime/main/extend/systemplugin/napi/ohos_application_formError.js create mode 100644 runtime/main/extend/systemplugin/napi/ohos_application_formHost.js create mode 100644 runtime/main/extend/systemplugin/napi/ohos_application_formInfo.js create mode 100644 runtime/main/extend/systemplugin/napi/ohos_application_testRunner.js diff --git a/runtime/main/extend/systemplugin/napi/@internal/ets/lifecycle.js b/runtime/main/extend/systemplugin/napi/@internal/ets/lifecycle.js new file mode 100644 index 00000000..ae8cf1c1 --- /dev/null +++ b/runtime/main/extend/systemplugin/napi/@internal/ets/lifecycle.js @@ -0,0 +1,253 @@ +/* + * Copyright (c) 2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import { FormBindingData } from "../ohos_application_formBindingData" +import { FormState } from "../ohos_application_formInfo" +import { paramMock } from "../../utils" +import { RemoteObjectClass } from "../ohos_rpc" +import { ResultSet, PacMapType } from "../ohos_ability_featureAbility" + +const DataAbilityResult = { + uri: "[PC Preview] unknow uri", + count: "[PC Preview] unknow count", +} +export const LifecycleForm = { + onCreate: function (...args) { + console.warn("LifecycleForm.onCreate interface mocked in the Previewer. How this interface works on the Previewer may" + + " be different from that on a real device.") + return FormBindingData; + }, + onCastToNormal: function (...args) { + console.warn("LifecycleForm.onCastToNormal interface mocked in the Previewer. How this interface works on the Previewer may" + + " be different from that on a real device.") + }, + onUpdate: function (...args) { + console.warn("LifecycleForm.onUpdate interface mocked in the Previewer. How this interface works on the Previewer may" + + " be different from that on a real device.") + }, + onVisibilityChange: function (...args) { + console.warn("LifecycleForm.onVisibilityChange interface mocked in the Previewer. How this interface works on the Previewer may" + + " be different from that on a real device.") + }, + onEvent: function (...args) { + console.warn("LifecycleForm.onEvent interface mocked in the Previewer. How this interface works on the Previewer may" + + " be different from that on a real device.") + }, + onDestroy: function (...args) { + console.warn("LifecycleForm.onDestroy interface mocked in the Previewer. How this interface works on the Previewer may" + + " be different from that on a real device.") + }, + onAcquireFormState: function (...args) { + console.warn("LifecycleForm.onAcquireFormState interface mocked in the Previewer. How this interface works on the Previewer may" + + " be different from that on a real device.") + return FormState; + }, +} +export const LifecycleApp = { + onShow: function () { + console.warn("LifecycleApp.onShow interface mocked in the Previewer. How this interface works on the Previewer may" + + " be different from that on a real device.") + }, + onHide: function () { + console.warn("LifecycleApp.onHide interface mocked in the Previewer. How this interface works on the Previewer may" + + " be different from that on a real device.") + }, + onDestroy: function () { + console.warn("LifecycleApp.onDestroy interface mocked in the Previewer. How this interface works on the Previewer may" + + " be different from that on a real device.") + }, + onCreate: function () { + console.warn("LifecycleApp.onCreate interface mocked in the Previewer. How this interface works on the Previewer may" + + " be different from that on a real device.") + }, + onWindowDisplayModeChanged: function (...args) { + console.warn("LifecycleApp.onWindowDisplayModeChanged interface mocked in the Previewer. How this interface works on the Previewer may" + + " be different from that on a real device.") + }, + onStartContinuation: function () { + console.warn("LifecycleApp.onStartContinuation interface mocked in the Previewer. How this interface works on the Previewer may" + + " be different from that on a real device.") + return paramMock.paramBooleanMock; + }, + onSaveData: function (...args) { + console.warn("LifecycleApp.onSaveData interface mocked in the Previewer. How this interface works on the Previewer may" + + " be different from that on a real device.") + return paramMock.paramBooleanMock; + }, + onCompleteContinuation: function (...args) { + console.warn("LifecycleApp.onCompleteContinuation interface mocked in the Previewer. How this interface works on the Previewer may" + + " be different from that on a real device.") + }, + onRestoreData: function (...args) { + console.warn("LifecycleApp.onRestoreData interface mocked in the Previewer. How this interface works on the Previewer may" + + " be different from that on a real device.") + }, + onRemoteTerminated: function () { + console.warn("LifecycleApp.onRemoteTerminated interface mocked in the Previewer. How this interface works on the Previewer may" + + " be different from that on a real device.") + }, + onSaveAbilityState: function (...args) { + console.warn("LifecycleApp.onSaveAbilityState interface mocked in the Previewer. How this interface works on the Previewer may" + + " be different from that on a real device.") + }, + onRestoreAbilityState: function (...args) { + console.warn("LifecycleApp.onRestoreAbilityState interface mocked in the Previewer. How this interface works on the Previewer may" + + " be different from that on a real device.") + }, + onInactive: function () { + console.warn("LifecycleApp.onInactive interface mocked in the Previewer. How this interface works on the Previewer may" + + " be different from that on a real device.") + }, + onActive: function () { + console.warn("LifecycleApp.onActive interface mocked in the Previewer. How this interface works on the Previewer may" + + " be different from that on a real device.") + }, + onNewWant: function (...args) { + console.warn("LifecycleApp.onNewWant interface mocked in the Previewer. How this interface works on the Previewer may" + + " be different from that on a real device.") + }, + onMemoryLevel: function (...args) { + console.warn("LifecycleApp.onMemoryLevel interface mocked in the Previewer. How this interface works on the Previewer may" + + " be different from that on a real device.") + }, +} +export const LifecycleService = { + onStart: function () { + console.warn("LifecycleService.onStart interface mocked in the Previewer. How this interface works on the Previewer may" + + " be different from that on a real device.") + }, + onCommand: function (...args) { + console.warn("LifecycleService.onCommand interface mocked in the Previewer. How this interface works on the Previewer may" + + " be different from that on a real device.") + }, + onStop: function () { + console.warn("LifecycleService.onStop interface mocked in the Previewer. How this interface works on the Previewer may" + + " be different from that on a real device.") + }, + onConnect: function (...args) { + console.warn("LifecycleService.onConnect interface mocked in the Previewer. How this interface works on the Previewer may" + + " be different from that on a real device.") + return new RemoteObjectClass(); + }, + onDisconnect: function (...args) { + console.warn("LifecycleService.onDisconnect interface mocked in the Previewer. How this interface works on the Previewer may" + + " be different from that on a real device.") + }, + onReconnect: function (...args) { + console.warn("LifecycleService.onReconnect interface mocked in the Previewer. How this interface works on the Previewer may" + + " be different from that on a real device.") + }, +} +export const LifecycleData = { + update: function (...args) { + console.warn("LifecycleData.update interface mocked in the Previewer. How this interface works on the Previewer" + + " may be different from that on a real device.") + const len = args.length + if (typeof args[len - 1] === 'function') { + args[len - 1].call(this, paramMock.businessErrorMock, paramMock.paramNumberMock); + } + }, + query: function (...args) { + console.warn("LifecycleData.query interface mocked in the Previewer. How this interface works on the Previewer" + + " may be different from that on a real device.") + const len = args.length + if (typeof args[len - 1] === 'function') { + args[len - 1].call(this, paramMock.businessErrorMock, ResultSet); + } + }, + delete: function (...args) { + console.warn("LifecycleData.delete interface mocked in the Previewer. How this interface works on the Previewer" + + " may be different from that on a real device.") + const len = args.length + if (typeof args[len - 1] === 'function') { + args[len - 1].call(this, paramMock.businessErrorMock, paramMock.paramNumberMock); + } + }, + normalizeUri: function (...args) { + console.warn("LifecycleData.normalizeUri interface mocked in the Previewer. How this interface works on the Previewer" + + " may be different from that on a real device.") + const len = args.length + if (typeof args[len - 1] === 'function') { + args[len - 1].call(this, paramMock.businessErrorMock, paramMock.paramStringMock); + } + }, + batchInsert: function (...args) { + console.warn("LifecycleData.batchInsert interface mocked in the Previewer. How this interface works on the Previewer" + + " may be different from that on a real device.") + const len = args.length + if (typeof args[len - 1] === 'function') { + args[len - 1].call(this, paramMock.businessErrorMock, paramMock.paramNumberMock); + } + }, + denormalizeUri: function (...args) { + console.warn("LifecycleData.denormalizeUri interface mocked in the Previewer. How this interface works on the Previewer" + + " may be different from that on a real device.") + const len = args.length + if (typeof args[len - 1] === 'function') { + args[len - 1].call(this, paramMock.businessErrorMock, paramMock.paramStringMock); + } + }, + insert: function (...args) { + console.warn("LifecycleData.insert interface mocked in the Previewer. How this interface works on the Previewer" + + " may be different from that on a real device.") + const len = args.length + if (typeof args[len - 1] === 'function') { + args[len - 1].call(this, paramMock.businessErrorMock, paramMock.paramNumberMock); + } + }, + openFile: function (...args) { + console.warn("LifecycleData.openFile interface mocked in the Previewer. How this interface works on the Previewer" + + " may be different from that on a real device.") + const len = args.length + if (typeof args[len - 1] === 'function') { + args[len - 1].call(this, paramMock.businessErrorMock, paramMock.paramNumberMock); + } + }, + getFileTypes: function (...args) { + console.warn("LifecycleData.getFileTypes interface mocked in the Previewer. How this interface works on the Previewer" + + " may be different from that on a real device.") + const len = args.length + if (typeof args[len - 1] === 'function') { + args[len - 1].call(this, paramMock.businessErrorMock, [paramMock.paramStringMock]); + } + }, + onInitialized: function (...args) { + console.warn("LifecycleData.onInitialized interface mocked in the Previewer. How this interface works on the Previewer may" + + " be different from that on a real device.") + }, + getType: function (...args) { + console.warn("LifecycleData.getType interface mocked in the Previewer. How this interface works on the Previewer" + + " may be different from that on a real device.") + const len = args.length + if (typeof args[len - 1] === 'function') { + args[len - 1].call(this, paramMock.businessErrorMock, paramMock.paramStringMock); + } + }, + executeBatch: function (...args) { + console.warn("LifecycleData.executeBatch interface mocked in the Previewer. How this interface works on the Previewer" + + " may be different from that on a real device.") + const len = args.length + if (typeof args[len - 1] === 'function') { + args[len - 1].call(this, paramMock.businessErrorMock, [DataAbilityResult]); + } + }, + call: function (...args) { + console.warn("LifecycleData.call interface mocked in the Previewer. How this interface works on the Previewer" + + " may be different from that on a real device.") + const len = args.length + if (typeof args[len - 1] === 'function') { + args[len - 1].call(this, paramMock.businessErrorMock, PacMapType); + } + }, +} \ No newline at end of file diff --git a/runtime/main/extend/systemplugin/napi/ability/abilityResult.js b/runtime/main/extend/systemplugin/napi/ability/abilityResult.js new file mode 100644 index 00000000..ce560932 --- /dev/null +++ b/runtime/main/extend/systemplugin/napi/ability/abilityResult.js @@ -0,0 +1,20 @@ +/* + * Copyright (c) 2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import { WantClass } from "../ohos_application_Want" + +export const AbilityResult = { + resultCode: "[PC Preview] unknow resultCode", + want: new WantClass(), +} \ No newline at end of file diff --git a/runtime/main/extend/systemplugin/napi/ability/connectOptions.js b/runtime/main/extend/systemplugin/napi/ability/connectOptions.js new file mode 100644 index 00000000..b07a5d9a --- /dev/null +++ b/runtime/main/extend/systemplugin/napi/ability/connectOptions.js @@ -0,0 +1,29 @@ +/* + * Copyright (c) 2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +export const ConnectOptions = { + onConnect: function (...args) { + console.warn("ConnectOptions.onConnect interface mocked in the Previewer. How this interface works" + + " on the Previewer may be different from that on a real device.") + }, + onDisconnect: function (...args) { + console.warn("ConnectOptions.onDisconnect interface mocked in the Previewer. How this interface works" + + " on the Previewer may be different from that on a real device.") + }, + onFailed: function (...args) { + console.warn("ConnectOptions.onFailed interface mocked in the Previewer. How this interface works" + + " on the Previewer may be different from that on a real device.") + }, +} \ No newline at end of file diff --git a/runtime/main/extend/systemplugin/napi/ability/startAbilityParameter.js b/runtime/main/extend/systemplugin/napi/ability/startAbilityParameter.js new file mode 100644 index 00000000..626ad3ac --- /dev/null +++ b/runtime/main/extend/systemplugin/napi/ability/startAbilityParameter.js @@ -0,0 +1,20 @@ +/* + * Copyright (c) 2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import { WantClass } from "../ohos_application_Want" + +export const StartAbilityParameter = { + want: new WantClass(), + abilityStartSetting: {}, +} \ No newline at end of file diff --git a/runtime/main/extend/systemplugin/napi/ability/want.js b/runtime/main/extend/systemplugin/napi/ability/want.js new file mode 100644 index 00000000..57e17e11 --- /dev/null +++ b/runtime/main/extend/systemplugin/napi/ability/want.js @@ -0,0 +1,27 @@ +/* + * Copyright (c) 2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import { paramMock } from "../../utils" + +export const Want = { + deviceId: "[PC Preview] unknow deviceId", + bundleName: "[PC Preview] unknow bundleName", + abilityName: "[PC Preview] unknow abilityName", + uri: "[PC Preview] unknow uri", + type: "[PC Preview] unknow type", + flags: "[PC Preview] unknow flags", + action: "[PC Preview] unknow action", + parameters: {}, + entities: [paramMock.paramStringMock] +} \ No newline at end of file diff --git a/runtime/main/extend/systemplugin/napi/app/appVersionInfo.js b/runtime/main/extend/systemplugin/napi/app/appVersionInfo.js new file mode 100644 index 00000000..b482c73b --- /dev/null +++ b/runtime/main/extend/systemplugin/napi/app/appVersionInfo.js @@ -0,0 +1,20 @@ +/* + * Copyright (c) 2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +export const AppVersionInfo = { + appName: "[PC Preview] unknow appName", + versionCode: "[PC Preview] unknow versionCode", + versionName: "[PC Preview] unknow versionName", +} \ No newline at end of file diff --git a/runtime/main/extend/systemplugin/napi/app/context.js b/runtime/main/extend/systemplugin/napi/app/context.js new file mode 100644 index 00000000..a6c2338f --- /dev/null +++ b/runtime/main/extend/systemplugin/napi/app/context.js @@ -0,0 +1,317 @@ +/* + * Copyright (c) 2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import { paramMock } from "../../utils" +import { ProcessInfo } from "./processInfo" +import { AppVersionInfo } from "./appVersionInfo" +import { AbilityInfo } from "../bundle/abilityInfo" +import { ApplicationInfo } from "../bundle/applicationInfo" +import { ElementName } from "../bundle/elementName" +import { HapModuleInfo } from "../bundle/hapModuleInfo" + +const DisplayOrientation = { + UNSPECIFIED: "[PC preview] unknown is UNSPECIFIED", + LANDSCAPE: "[PC preview] unknown is LANDSCAPE", + PORTRAIT: "[PC preview] unknown is PORTRAIT", + FOLLOW_RECENT: "[PC preview] unknown is FOLLOW_RECENT", + LANDSCAPE_INVERTED: "[PC preview] unknown is LANDSCAPE_INVERTED", + PORTRAIT_INVERTED: "[PC preview] unknown is PORTRAIT_INVERTED", + AUTO_ROTATION: "[PC preview] unknown is AUTO_ROTATION", + AUTO_ROTATION_LANDSCAPE: "[PC preview] unknown is AUTO_ROTATION_LANDSCAPE", + AUTO_ROTATION_PORTRAIT: "[PC preview] unknown is AUTO_ROTATION_PORTRAIT", + AUTO_ROTATION_RESTRICTED: "[PC preview] unknown is AUTO_ROTATION_RESTRICTED", + AUTO_ROTATION_LANDSCAPE_RESTRICTED: "[PC preview] unknown is AUTO_ROTATION_LANDSCAPE_RESTRICTED", + AUTO_ROTATION_PORTRAIT_RESTRICTED: "[PC preview] unknown is AUTO_ROTATION_PORTRAIT_RESTRICTED", + LOCKED: "[PC preview] unknown is LOCKED", +} +export const Context = { + getOrCreateLocalDir: function (...args) { + console.warn("Context.getOrCreateLocalDir interface mocked in the Previewer." + + " How this interface works on the Previewer may be different from that on a real device.") + const len = args.length + if (len > 0 && typeof args[len - 1] === 'function') { + args[len - 1].call(this, paramMock.businessErrorMock, paramMock.paramStringMock); + } else { + return new Promise((resolve, reject) => { + resolve(paramMock.paramStringMock); + }) + } + }, + verifyPermission: function (...args) { + console.warn("Context.verifyPermission interface mocked in the Previewer." + + " How this interface works on the Previewer may be different from that on a real device.") + const len = args.length + if (len > 0 && typeof args[len - 1] === 'function') { + args[len - 1].call(this, paramMock.businessErrorMock, paramMock.paramNumberMock); + } else { + return new Promise((resolve, reject) => { + resolve(paramMock.paramNumberMock); + }) + } + }, + requestPermissionsFromUser: function (...args) { + console.warn("Context.requestPermissionsFromUser interface mocked in the Previewer." + + " How this interface works on the Previewer may be different from that on a real device.") + const len = args.length + if (len > 0 && typeof args[len - 1] === 'function') { + args[len - 1].call(this, paramMock.businessErrorMock, PermissionRequestResult); + } else { + return new Promise((resolve, reject) => { + resolve(PermissionRequestResult); + }) + } + }, + getApplicationInfo: function (...args) { + console.warn("Context.getApplicationInfo interface mocked in the Previewer." + + " How this interface works on the Previewer may be different from that on a real device.") + const len = args.length + if (len > 0 && typeof args[len - 1] === 'function') { + args[len - 1].call(this, paramMock.businessErrorMock, ApplicationInfo); + } else { + return new Promise((resolve, reject) => { + resolve(ApplicationInfo); + }) + } + }, + getBundleName: function (...args) { + console.warn("Context.getBundleName interface mocked in the Previewer." + + " How this interface works on the Previewer may be different from that on a real device.") + const len = args.length + if (len > 0 && typeof args[len - 1] === 'function') { + args[len - 1].call(this, paramMock.businessErrorMock, paramMock.paramStringMock); + } else { + return new Promise((resolve, reject) => { + resolve(paramMock.paramStringMock); + }) + } + }, + getDisplayOrientation: function (...args) { + console.warn("Context.getDisplayOrientation interface mocked in the Previewer." + + " How this interface works on the Previewer may be different from that on a real device.") + const len = args.length + if (len > 0 && typeof args[len - 1] === 'function') { + args[len - 1].call(this, paramMock.businessErrorMock, DisplayOrientation); + } else { + return new Promise((resolve, reject) => { + resolve(DisplayOrientation); + }) + } + }, + setDisplayOrientation: function (...args) { + console.warn("Context.setDisplayOrientation interface mocked in the Previewer." + + " How this interface works on the Previewer may be different from that on a real device.") + const len = args.length + if (len > 0 && typeof args[len - 1] === 'function') { + args[len - 1].call(this, paramMock.businessErrorMock); + } else { + return new Promise((resolve, reject) => { + resolve(); + }) + } + }, + setShowOnLockScreen: function (...args) { + console.warn("Context.setShowOnLockScreen interface mocked in the Previewer." + + " How this interface works on the Previewer may be different from that on a real device.") + const len = args.length + if (len > 0 && typeof args[len - 1] === 'function') { + args[len - 1].call(this, paramMock.businessErrorMock); + } else { + return new Promise((resolve, reject) => { + resolve(); + }) + } + }, + setWakeUpScreen: function (...args) { + console.warn("Context.setWakeUpScreen interface mocked in the Previewer." + + " How this interface works on the Previewer may be different from that on a real device.") + const len = args.length + if (len > 0 && typeof args[len - 1] === 'function') { + args[len - 1].call(this, paramMock.businessErrorMock); + } else { + return new Promise((resolve, reject) => { + resolve(); + }) + } + }, + getProcessInfo: function (...args) { + console.warn("Context.getProcessInfo interface mocked in the Previewer." + + " How this interface works on the Previewer may be different from that on a real device.") + const len = args.length + if (len > 0 && typeof args[len - 1] === 'function') { + args[len - 1].call(this, paramMock.businessErrorMock, ProcessInfo); + } else { + return new Promise((resolve, reject) => { + resolve(ProcessInfo); + }) + } + }, + getElementName: function (...args) { + console.warn("Context.getElementName interface mocked in the Previewer." + + " How this interface works on the Previewer may be different from that on a real device.") + const len = args.length + if (len > 0 && typeof args[len - 1] === 'function') { + args[len - 1].call(this, paramMock.businessErrorMock, ElementName); + } else { + return new Promise((resolve, reject) => { + resolve(ElementName); + }) + } + }, + getProcessName: function (...args) { + console.warn("Context.getProcessName interface mocked in the Previewer." + + " How this interface works on the Previewer may be different from that on a real device.") + const len = args.length + if (len > 0 && typeof args[len - 1] === 'function') { + args[len - 1].call(this, paramMock.businessErrorMock, paramMock.paramStringMock); + } else { + return new Promise((resolve, reject) => { + resolve(paramMock.paramStringMock); + }) + } + }, + getCallingBundle: function (...args) { + console.warn("Context.getCallingBundle interface mocked in the Previewer." + + " How this interface works on the Previewer may be different from that on a real device.") + const len = args.length + if (len > 0 && typeof args[len - 1] === 'function') { + args[len - 1].call(this, paramMock.businessErrorMock, paramMock.paramStringMock); + } else { + return new Promise((resolve, reject) => { + resolve(paramMock.paramStringMock); + }) + } + }, + getFilesDir: function (...args) { + console.warn("Context.getFilesDir interface mocked in the Previewer." + + " How this interface works on the Previewer may be different from that on a real device.") + const len = args.length + if (len > 0 && typeof args[len - 1] === 'function') { + args[len - 1].call(this, paramMock.businessErrorMock, paramMock.paramStringMock); + } else { + return new Promise((resolve, reject) => { + resolve(paramMock.paramStringMock); + }) + } + }, + getCacheDir: function (...args) { + console.warn("Context.getCacheDir interface mocked in the Previewer." + + " How this interface works on the Previewer may be different from that on a real device.") + const len = args.length + if (len > 0 && typeof args[len - 1] === 'function') { + args[len - 1].call(this, paramMock.businessErrorMock, paramMock.paramStringMock); + } else { + return new Promise((resolve, reject) => { + resolve(paramMock.paramStringMock); + }) + } + }, + getOrCreateDistributedDir: function (...args) { + console.warn("Context.getOrCreateDistributedDir interface mocked in the Previewer." + + " How this interface works on the Previewer may be different from that on a real device.") + const len = args.length + if (len > 0 && typeof args[len - 1] === 'function') { + args[len - 1].call(this, paramMock.businessErrorMock, paramMock.paramStringMock); + } else { + return new Promise((resolve, reject) => { + resolve(paramMock.paramStringMock); + }) + } + }, + getAppType: function (...args) { + console.warn("Context.getAppType interface mocked in the Previewer." + + " How this interface works on the Previewer may be different from that on a real device.") + const len = args.length + if (len > 0 && typeof args[len - 1] === 'function') { + args[len - 1].call(this, paramMock.businessErrorMock, paramMock.paramStringMock); + } else { + return new Promise((resolve, reject) => { + resolve(paramMock.paramStringMock); + }) + } + }, + getHapModuleInfo: function (...args) { + console.warn("Context.getHapModuleInfo interface mocked in the Previewer." + + " How this interface works on the Previewer may be different from that on a real device.") + const len = args.length + if (len > 0 && typeof args[len - 1] === 'function') { + args[len - 1].call(this, paramMock.businessErrorMock, HapModuleInfo); + } else { + return new Promise((resolve, reject) => { + resolve(HapModuleInfo); + }) + } + }, + getAppVersionInfo: function (...args) { + console.warn("Context.getAppVersionInfo interface mocked in the Previewer." + + " How this interface works on the Previewer may be different from that on a real device.") + const len = args.length + if (len > 0 && typeof args[len - 1] === 'function') { + args[len - 1].call(this, paramMock.businessErrorMock, AppVersionInfo); + } else { + return new Promise((resolve, reject) => { + resolve(AppVersionInfo); + }) + } + }, + getApplicationContext: function () { + console.warn("Context.getApplicationContext interface mocked in the Previewer." + + " How this interface works on the Previewer may be different from that on a real device.") + return Context; + }, + getAbilityInfo: function (...args) { + console.warn("Context.getAbilityInfo interface mocked in the Previewer." + + " How this interface works on the Previewer may be different from that on a real device.") + const len = args.length + if (len > 0 && typeof args[len - 1] === 'function') { + args[len - 1].call(this, paramMock.businessErrorMock, AbilityInfo); + } else { + return new Promise((resolve, reject) => { + resolve(AbilityInfo); + }) + } + }, + isUpdatingConfigurations: function (...args) { + console.warn("Context.isUpdatingConfigurations interface mocked in the Previewer." + + " How this interface works on the Previewer may be different from that on a real device.") + const len = args.length + if (len > 0 && typeof args[len - 1] === 'function') { + args[len - 1].call(this, paramMock.businessErrorMock, paramMock.paramBooleanMock); + } else { + return new Promise((resolve, reject) => { + resolve(paramMock.paramBooleanMock); + }) + } + }, + printDrawnCompleted: function (...args) { + console.warn("Context.printDrawnCompleted interface mocked in the Previewer." + + " How this interface works on the Previewer may be different from that on a real device.") + const len = args.length + if (len > 0 && typeof args[len - 1] === 'function') { + args[len - 1].call(this, paramMock.businessErrorMock); + } else { + return new Promise((resolve, reject) => { + resolve(); + }) + } + } +} +export const PermissionRequestResult = { + requestCode: "[PC Preview] unknow requestCode", + permissions: [paramMock.paramStringMock], + authResults: [paramMock.paramNumberMock], +} +export const PermissionOptions = { + pid: "[PC Preview] unknow pid", + uid: "[PC Preview] unknow uid", +} \ No newline at end of file diff --git a/runtime/main/extend/systemplugin/napi/app/processInfo.js b/runtime/main/extend/systemplugin/napi/app/processInfo.js new file mode 100644 index 00000000..0fcda95b --- /dev/null +++ b/runtime/main/extend/systemplugin/napi/app/processInfo.js @@ -0,0 +1,19 @@ +/* + * Copyright (c) 2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +export const ProcessInfo = { + pid: "[PC Preview] unknow pid", + processName: "[PC Preview] unknow processName", +} \ No newline at end of file diff --git a/runtime/main/extend/systemplugin/napi/application/abilityContext.js b/runtime/main/extend/systemplugin/napi/application/AbilityContext.js similarity index 82% rename from runtime/main/extend/systemplugin/napi/application/abilityContext.js rename to runtime/main/extend/systemplugin/napi/application/AbilityContext.js index d8ca6563..1b7a9305 100644 --- a/runtime/main/extend/systemplugin/napi/application/abilityContext.js +++ b/runtime/main/extend/systemplugin/napi/application/AbilityContext.js @@ -16,6 +16,8 @@ import { paramMock } from "../../utils" import { MessageParcelClass } from "../ohos_rpc" import { ContextClass } from "../ohos_application_ServiceExtAbility" +import { Configuration } from "../ohos_application_Configuration" +import { Caller } from "../ohos_application_Ability" const ModuleInfoMock = { moduleName: '[PC preview] unknow moduleName', @@ -240,37 +242,10 @@ export const ExtensionContextClass = class ExtensionContext extends ContextClass export const AbilityResultMock = { resultCode: "[PC Preview] unknow resultCode", } -const ConfigurationMock = { - language: '[PC preview] unknow language' -} const PermissionRequestResultMock = { permissions: [paramMock.paramStringMock], authResults: [paramMock.paramNumberMock] } -const CallerMock = { - call: function (...args) { - console.warn("AbilityContext.Caller.call interface mocked in the Previewer." + - " How this interface works on the Previewer may be different from that on a real device.") - return new Promise((resolve, reject) => { - resolve(); - }) - }, - callWithResult: function (...args) { - console.warn("AbilityContext.Caller.callWithResult interface mocked in the Previewer." + - " How this interface works on the Previewer may be different from that on a real device.") - return new Promise((resolve, reject) => { - resolve(new MessageParcelClass()); - }) - }, - release: function (...args) { - console.warn("AbilityContext.Caller.release interface mocked in the Previewer. How this interface works on the Previewer" + - " may be different from that on a real device.") - }, - onRelease: function (...args) { - console.warn("AbilityContext.Caller.onRelease interface mocked in the Previewer. How this interface works on the Previewer" + - " may be different from that on a real device.") - }, -} export const AbilityContextClass = class AbilityContext extends ContextClass { constructor() { super(); @@ -278,7 +253,7 @@ export const AbilityContextClass = class AbilityContext extends ContextClass { ' the Previewer may be different from that on a real device.'); this.abilityInfo = AbilityInfoMock; this.currentHapModuleInfo = HapModuleInfoMock; - this.config = ConfigurationMock; + this.config = Configuration; this.startAbility = function (...args) { console.warn("Ability.AbilityContext.startAbility interface mocked in the Previewer." + " How this interface works on the Previewer may be different from that on a real device.") @@ -295,7 +270,7 @@ export const AbilityContextClass = class AbilityContext extends ContextClass { console.warn("Ability.AbilityContext.startAbilityByCall interface mocked in the Previewer." + " How this interface works on the Previewer may be different from that on a real device.") return new Promise((resolve, reject) => { - resolve(CallerMock); + resolve(Caller); }) }; this.startAbilityWithAccount = function (...args) { @@ -334,6 +309,54 @@ export const AbilityContextClass = class AbilityContext extends ContextClass { }) } }; + this.startServiceExtensionAbility = function (...args) { + console.warn("Ability.AbilityContext.startServiceExtensionAbility interface mocked in the Previewer." + + " How this interface works on the Previewer may be different from that on a real device.") + const len = args.length + if (len > 0 && typeof args[len - 1] === 'function') { + args[len - 1].call(this, paramMock.businessErrorMock); + } else { + return new Promise((resolve, reject) => { + resolve(); + }) + } + }; + this.startServiceExtensionAbilityWithAccount = function (...args) { + console.warn("Ability.AbilityContext.startServiceExtensionAbilityWithAccount interface mocked in the Previewer." + + " How this interface works on the Previewer may be different from that on a real device.") + const len = args.length + if (len > 0 && typeof args[len - 1] === 'function') { + args[len - 1].call(this, paramMock.businessErrorMock); + } else { + return new Promise((resolve, reject) => { + resolve(); + }) + } + }; + this.stopServiceExtensionAbility = function (...args) { + console.warn("Ability.AbilityContext.stopServiceExtensionAbility interface mocked in the Previewer." + + " How this interface works on the Previewer may be different from that on a real device.") + const len = args.length + if (len > 0 && typeof args[len - 1] === 'function') { + args[len - 1].call(this, paramMock.businessErrorMock); + } else { + return new Promise((resolve, reject) => { + resolve(); + }) + } + }; + this.stopServiceExtensionAbilityWithAccount = function (...args) { + console.warn("Ability.AbilityContext.stopServiceExtensionAbilityWithAccount interface mocked in the Previewer." + + " How this interface works on the Previewer may be different from that on a real device.") + const len = args.length + if (len > 0 && typeof args[len - 1] === 'function') { + args[len - 1].call(this, paramMock.businessErrorMock); + } else { + return new Promise((resolve, reject) => { + resolve(); + }) + } + }; this.terminateSelf = function (...args) { console.warn("Ability.AbilityContext.terminateSelf interface mocked in the Previewer." + " How this interface works on the Previewer may be different from that on a real device.") @@ -392,6 +415,18 @@ export const AbilityContextClass = class AbilityContext extends ContextClass { }) } }; + this.setMissionIcon = function (...args) { + console.warn("Ability.AbilityContext.setMissionIcon interface mocked in the Previewer." + + " How this interface works on the Previewer may be different from that on a real device.") + const len = args.length + if (len > 0 && typeof args[len - 1] === 'function') { + args[len - 1].call(this, paramMock.businessErrorMock); + } else { + return new Promise((resolve, reject) => { + resolve(); + }) + } + }; this.requestPermissionsFromUser = function (...args) { console.warn("Ability.AbilityContext.requestPermissionsFromUser interface mocked in the Previewer." + " How this interface works on the Previewer may be different from that on a real device.") @@ -404,6 +439,10 @@ export const AbilityContextClass = class AbilityContext extends ContextClass { }) } }; + this.restoreWindowStage = function (...args) { + console.warn("Ability.AbilityContext.restoreWindowStage interface mocked in the Previewer. How this interface works on the Previewer" + + " may be different from that on a real device.") + }; this.isTerminating = function () { console.warn("Ability.AbilityContext.isTerminating interface mocked in the Previewer. How this interface works on the Previewer" + " may be different from that on a real device.") diff --git a/runtime/main/extend/systemplugin/napi/application/BaseContext.js b/runtime/main/extend/systemplugin/napi/application/BaseContext.js new file mode 100644 index 00000000..7d8b0e82 --- /dev/null +++ b/runtime/main/extend/systemplugin/napi/application/BaseContext.js @@ -0,0 +1,18 @@ +/* + * Copyright (c) 2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +export const BaseContext = { + stageMode: "[PC Preview] unknow stageMode", +} \ No newline at end of file diff --git a/runtime/main/extend/systemplugin/napi/application/Context.js b/runtime/main/extend/systemplugin/napi/application/Context.js new file mode 100644 index 00000000..bc9339ef --- /dev/null +++ b/runtime/main/extend/systemplugin/napi/application/Context.js @@ -0,0 +1,311 @@ +/* + * Copyright (c) 2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import { ApplicationInfo } from "../bundle/applicationInfo" +import { BaseContext } from "./BaseContext" +const ResourceManager = { + getString: function(...args) { + console.warn("ResourceManager.getString interface mocked in the Previewer. " + + "How this interface works on the Previewer may be different from that on a real device.") + const len = args.length + if (typeof args[len - 1] === 'function') { + args[len - 1].call(this, paramMock.businessErrorMock, paramMock.paramStringMock); + } else { + return new Promise((resolve, reject) => { + resolve(paramMock.paramStringMock); + }) + } + }, + + getStringArray: function(...args) { + console.warn("ResourceManager.getStringArray interface mocked in the Previewer. " + + "How this interface works on the Previewer may be different from that on a real device.") + const len = args.length + if (typeof args[len - 1] === 'function') { + args[len - 1].call(this, paramMock.businessErrorMock, [paramMock.paramStringMock]); + } else { + return new Promise((resolve, reject) => { + resolve([paramMock.paramStringMock]); + }) + } + }, + + getMedia: function(...args) { + console.warn("ResourceManager.getMedia interface mocked in the Previewer. " + + "How this interface works on the Previewer may be different from that on a real device.") + const len = args.length + if (typeof args[len - 1] === 'function') { + args[len - 1].call(this, paramMock.businessErrorMock, paramMock.paramArrayMock); + } else { + return new Promise((resolve, reject) => { + resolve(paramMock.paramArrayMock); + }) + } + }, + + getMediaBase64: function(...args) { + console.warn("ResourceManager.getMediaBase64 interface mocked in the Previewer. " + + "How this interface works on the Previewer may be different from that on a real device.") + const len = args.length + if (typeof args[len - 1] === 'function') { + args[len - 1].call(this, paramMock.businessErrorMock, paramMock.paramArrayMock); + } else { + return new Promise((resolve, reject) => { + resolve(paramMock.paramArrayMock); + }) + } + }, + + getPluralString: function(...args) { + console.warn("ResourceManager.getPluralString interface mocked in the Previewer. " + + "How this interface works on the Previewer may be different from that on a real device.") + const len = args.length + if (typeof args[len - 1] === 'function') { + args[len - 1].call(this, paramMock.businessErrorMock, paramMock.paramStringMock); + } else { + return new Promise((resolve, reject) => { + resolve(paramMock.paramStringMock); + }) + } + }, + + getConfiguration: function(...args) { + console.warn("ResourceManager.getConfiguration interface mocked in the Previewer. " + + "How this interface works on the Previewer may be different from that on a real device.") + const len = args.length + if (typeof args[len - 1] === 'function') { + args[len - 1].call(this, paramMock.businessErrorMock, new ConfigurationClass()); + } else { + return new Promise((resolve, reject) => { + resolve(new ConfigurationClass()); + }) + } + }, + + getDeviceCapability: function(...args) { + console.warn("ResourceManager.getDeviceCapability interface mocked in the Previewer. " + + "How this interface works on the Previewer may be different from that on a real device.") + const len = args.length + if (typeof args[len - 1] === 'function') { + args[len - 1].call(this, paramMock.businessErrorMock, new DeviceCapabilityClass()); + } else { + return new Promise((resolve, reject) => { + resolve(new DeviceCapabilityClass()); + }) + } + }, + + release: function() { + console.warn("ResourceManager.release interface mocked in the Previewer. " + + "How this interface works on the Previewer may be different from that on a real device.") + }, + + getRawFile: function(...args) { + console.warn("ResourceManager.getRawFile interface mocked in the Previewer. " + + "How this interface works on the Previewer may be different from that on a real device.") + const len = args.length + if (typeof args[len - 1] === 'function') { + args[len - 1].call(this, paramMock.businessErrorMock, paramMock.paramArrayMock); + } else { + return new Promise((resolve, reject) => { + resolve(paramMock.paramArrayMock); + }) + } + }, + + getRawFileDescriptor: function(...args) { + console.warn("ResourceManager.getRawFileDescriptor interface mocked in the Previewer. " + + "How this interface works on the Previewer may be different from that on a real device.") + const len = args.length + if (typeof args[len - 1] === 'function') { + args[len - 1].call(this, paramMock.businessErrorMock, RawFileDescriptor); + } else { + return new Promise((resolve, reject) => { + resolve(RawFileDescriptor); + }) + } + }, + + closeRawFileDescriptor: function(...args) { + console.warn("ResourceManager.closeRawFileDescriptor interface mocked in the Previewer. " + + "How this interface works on the Previewer may be different from that on a real device.") + const len = args.length + if (typeof args[len - 1] === 'function') { + args[len - 1].call(this, paramMock.businessErrorMock, paramMock.paramStringMock); + } else { + return new Promise((resolve, reject) => { + resolve(paramMock.paramStringMock); + }) + } + }, + + getStringByName: function(...args) { + console.warn("ResourceManager.getStringByName interface mocked in the Previewer. " + + "How this interface works on the Previewer may be different from that on a real device.") + const len = args.length + if (typeof args[len - 1] === 'function') { + args[len - 1].call(this, paramMock.businessErrorMock, paramMock.paramStringMock); + } else { + return new Promise((resolve, reject) => { + resolve(paramMock.paramStringMock); + }) + } + }, + + getStringArrayByName: function(...args) { + console.warn("ResourceManager.getStringArrayByName interface mocked in the Previewer. " + + "How this interface works on the Previewer may be different from that on a real device.") + const len = args.length + if (typeof args[len - 1] === 'function') { + args[len - 1].call(this, paramMock.businessErrorMock, [paramMock.paramStringMock]); + } else { + return new Promise((resolve, reject) => { + resolve([paramMock.paramStringMock]); + }) + } + }, + + getMediaByName: function(...args) { + console.warn("ResourceManager.getMediaByName interface mocked in the Previewer. " + + "How this interface works on the Previewer may be different from that on a real device.") + const len = args.length + if (typeof args[len - 1] === 'function') { + args[len - 1].call(this, paramMock.businessErrorMock, paramMock.paramArrayMock); + } else { + return new Promise((resolve, reject) => { + resolve(paramMock.paramArrayMock); + }) + } + }, + + getMediaBase64ByName: function(...args) { + console.warn("ResourceManager.getMediaBase64ByName interface mocked in the Previewer. " + + "How this interface works on the Previewer may be different from that on a real device.") + const len = args.length + if (typeof args[len - 1] === 'function') { + args[len - 1].call(this, paramMock.businessErrorMock, paramMock.paramArrayMock); + } else { + return new Promise((resolve, reject) => { + resolve(paramMock.paramArrayMock); + }) + } + }, + + getPluralStringByName: function(...args) { + console.warn("ResourceManager.getPluralStringByName interface mocked in the Previewer. " + + "How this interface works on the Previewer may be different from that on a real device.") + const len = args.length + if (typeof args[len - 1] === 'function') { + args[len - 1].call(this, paramMock.businessErrorMock, paramMock.paramStringMock); + } else { + return new Promise((resolve, reject) => { + resolve(paramMock.paramStringMock); + }) + } + }, + + getStringSync: function(...args) { + console.warn("ResourceManager.getStringSync interface mocked in the Previewer. " + + "How this interface works on the Previewer may be different from that on a real device.") + return paramMock.paramStringMock; + }, + + getStringByNameSync: function(...args) { + console.warn("ResourceManager.getStringByNameSync interface mocked in the Previewer. " + + "How this interface works on the Previewer may be different from that on a real device.") + return paramMock.paramStringMock; + }, + + getBoolean: function(...args) { + console.warn("ResourceManager.getBoolean interface mocked in the Previewer. " + + "How this interface works on the Previewer may be different from that on a real device.") + return paramMock.paramBooleanMock; + }, + + getBooleanByName: function(...args) { + console.warn("ResourceManager.getBooleanByName interface mocked in the Previewer. " + + "How this interface works on the Previewer may be different from that on a real device.") + return paramMock.paramBooleanMock; + }, + + getNumber: function(...args) { + console.warn("ResourceManager.getNumber interface mocked in the Previewer. " + + "How this interface works on the Previewer may be different from that on a real device.") + return paramMock.paramNumberMock; + }, + + getNumberByName: function(...args) { + console.warn("ResourceManager.getNumberByName interface mocked in the Previewer. " + + "How this interface works on the Previewer may be different from that on a real device.") + return paramMock.paramNumberMock; + } +} +const EventHubClass = class EventHub { + constructor() { + console.warn('EventHub.constructor interface mocked in the Previewer. How this interface works on' + + ' the Previewer may be different from that on a real device.'); + this.on = function (...args) { + console.warn("EventHub.on interface mocked in the Previewer. How this interface works on the Previewer" + + " may be different from that on a real device.") + }; + this.off = function (...args) { + console.warn("EventHub.off interface mocked in the Previewer. How this interface works on the Previewer" + + " may be different from that on a real device.") + }; + this.emit = function (...args) { + console.warn("EventHub.emit interface mocked in the Previewer. How this interface works on the Previewer" + + " may be different from that on a real device.") + }; + } +} +export const ContextClass = class Context extends BaseContext { + constructor() { + super(); + console.warn('Context.constructor interface mocked in the Previewer. How this interface works on' + + ' the Previewer may be different from that on a real device.'); + this.resourceManager = ResourceManager; + this.applicationInfo = ApplicationInfo; + this.cacheDir = "[PC Preview] unknow cacheDir"; + this.tempDir = "[PC Preview] unknow tempDir"; + this.filesDir = "[PC Preview] unknow filesDir"; + this.databaseDir = "[PC Preview] unknow databaseDir"; + this.storageDir = "[PC Preview] unknow storageDir"; + this.bundleCodeDir = "[PC Preview] unknow bundleCodeDir"; + this.distributedFilesDir = "[PC Preview] unknow distributedFilesDir"; + this.eventHub = new EventHubClass(); + this.createBundleContext = function (...args) { + console.warn("Context.createBundleContext interface mocked in the Previewer. How this interface works on the Previewer" + + " may be different from that on a real device.") + return new ContextClass(); + }; + this.createModuleContext = function (...args) { + console.warn("Context.createModuleContext interface mocked in the Previewer. How this interface works on the Previewer" + + " may be different from that on a real device.") + return new ContextClass(); + }; + this.getApplicationContext = function () { + console.warn("Context.getApplicationContext interface mocked in the Previewer. How this interface works on the Previewer" + + " may be different from that on a real device.") + return new ContextClass(); + }; + this.switchArea = function (...args) { + console.warn("Context.switchArea interface mocked in the Previewer. How this interface works on the Previewer" + + " may be different from that on a real device.") + }; + } +} +export const AreaMode = { + EL1: 0, + EL2: 1 +} \ No newline at end of file diff --git a/runtime/main/extend/systemplugin/napi/application/FormExtensionContext.js b/runtime/main/extend/systemplugin/napi/application/FormExtensionContext.js new file mode 100644 index 00000000..7dc55b19 --- /dev/null +++ b/runtime/main/extend/systemplugin/napi/application/FormExtensionContext.js @@ -0,0 +1,34 @@ +/* + * Copyright (c) 2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import { ExtensionContextClass } from "./abilityContext" +export const formExtensionContextClass = class formExtensionContext extends ExtensionContextClass { + constructor() { + super(); + console.warn('formExtensionContext.constructor interface mocked in the Previewer. How this interface works on' + + ' the Previewer may be different from that on a real device.'); + this.startAbility = function (...args) { + console.warn("formExtensionContext.startAbility interface mocked in the Previewer." + + " How this interface works on the Previewer may be different from that on a real device."); + const len = args.length; + if (len > 0 && typeof args[len - 1] === 'function') { + args[len - 1].call(this, paramMock.businessErrorMock); + } else { + return new Promise((resolve, reject) => { + resolve(); + }) + } + }; + } +} \ No newline at end of file diff --git a/runtime/main/extend/systemplugin/napi/application/abilityMonitor.js b/runtime/main/extend/systemplugin/napi/application/abilityMonitor.js new file mode 100644 index 00000000..22195d2b --- /dev/null +++ b/runtime/main/extend/systemplugin/napi/application/abilityMonitor.js @@ -0,0 +1,45 @@ +/* + * Copyright (c) 2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +export const AbilityMonitor = { + abilityName: "[PC Preview] unknow abilityName", + onAbilityCreate: function (...args) { + console.warn("AbilityMonitor.onAbilityCreate interface mocked in the Previewer." + + " How this interface works on the Previewer may be different from that on a real device.") + }, + onAbilityForeground: function (...args) { + console.warn("AbilityMonitor.onAbilityForeground interface mocked in the Previewer." + + " How this interface works on the Previewer may be different from that on a real device.") + }, + onAbilityBackground: function (...args) { + console.warn("AbilityMonitor.onAbilityBackground interface mocked in the Previewer." + + " How this interface works on the Previewer may be different from that on a real device.") + }, + onAbilityDestroy: function (...args) { + console.warn("AbilityMonitor.onAbilityDestroy interface mocked in the Previewer." + + " How this interface works on the Previewer may be different from that on a real device.") + }, + onWindowStageCreate: function (...args) { + console.warn("AbilityMonitor.onWindowStageCreate interface mocked in the Previewer." + + " How this interface works on the Previewer may be different from that on a real device.") + }, + onWindowStageRestore: function (...args) { + console.warn("AbilityMonitor.onWindowStageRestore interface mocked in the Previewer." + + " How this interface works on the Previewer may be different from that on a real device.") + }, + onWindowStageDestroy: function (...args) { + console.warn("AbilityMonitor.onWindowStageDestroy interface mocked in the Previewer." + + " How this interface works on the Previewer may be different from that on a real device.") + }, +} \ No newline at end of file diff --git a/runtime/main/extend/systemplugin/napi/common/full/featureability.js b/runtime/main/extend/systemplugin/napi/common/full/featureability.js new file mode 100644 index 00000000..084bf211 --- /dev/null +++ b/runtime/main/extend/systemplugin/napi/common/full/featureability.js @@ -0,0 +1,156 @@ +/* + * Copyright (c) 2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import { paramMock } from "../../../utils" +export const Result = { + code: "[PC Preview] unknow code", + data: "[PC Preview] unknow data", +} +export const SubscribeMessageResponse = { + deviceId: "[PC Preview] unknow deviceId", + bundleName: "[PC Preview] unknow bundleName", + abilityName: "[PC Preview] unknow abilityName", + message: "[PC Preview] unknow message", +} +export const CallAbilityParam = { + bundleName: "[PC Preview] unknow bundleName", + abilityName: "[PC Preview] unknow abilityName", + messageCode: "[PC Preview] unknow messageCode", + abilityType: "[PC Preview] unknow abilityType", + data: "[PC Preview] unknow data", + syncOption: "[PC Preview] unknow syncOption", +} +export const SubscribeAbilityEventParam = { + bundleName: "[PC Preview] unknow bundleName", + abilityName: "[PC Preview] unknow abilityName", + messageCode: "[PC Preview] unknow messageCode", + abilityType: "[PC Preview] unknow abilityType", + syncOption: "[PC Preview] unknow syncOption", +} +export const SendMessageOptions = { + deviceId: "[PC Preview] unknow deviceId", + bundleName: "[PC Preview] unknow bundleName", + abilityName: "[PC Preview] unknow abilityName", + message: "[PC Preview] unknow message", + success: function () { + console.warn("SendMessageOptions.success interface mocked in the Previewer." + + " How this interface works on the Previewer may be different from that on a real device.") + }, + fail: function (...args) { + console.warn("SendMessageOptions.fail interface mocked in the Previewer." + + " How this interface works on the Previewer may be different from that on a real device.") + }, + complete: function () { + console.warn("SendMessageOptions.complete interface mocked in the Previewer." + + " How this interface works on the Previewer may be different from that on a real device.") + } +} +export const SubscribeMessageOptions = { + success: function (...args) { + console.warn("SubscribeMessageOptions.success interface mocked in the Previewer." + + " How this interface works on the Previewer may be different from that on a real device.") + }, + fail: function (...args) { + console.warn("SubscribeMessageOptions.fail interface mocked in the Previewer." + + " How this interface works on the Previewer may be different from that on a real device.") + }, +} +export const RequestParams = { + bundleName: "[PC Preview] unknow bundleName", + abilityName: "[PC Preview] unknow abilityName", + entities: [paramMock.paramStringMock], + action: "[PC Preview] unknow action", + deviceType: "[PC Preview] unknow deviceType", + data: "[PC Preview] unknow data", + flag: "[PC Preview] unknow flag", + url: "[PC Preview] unknow url", +} +export const FinishWithResultParams = { + code: "[PC Preview] unknow code", + result: "[PC Preview] unknow result", +} +export const FeatureAbilityClass = class FeatureAbility { + constructor() { + console.warn('FeatureAbility.constructor interface mocked in the Previewer. How this interface works on' + + ' the Previewer may be different from that on a real device.'); + this.startAbility = function (...args) { + console.warn("FeatureAbility.startAbility interface mocked in the Previewer. How this interface works on the Previewer" + + " may be different from that on a real device.") + return new Promise((resolve, reject) => { + resolve(Result); + }) + }; + this.startAbilityForResult = function (...args) { + console.warn("FeatureAbility.startAbilityForResult interface mocked in the Previewer. How this interface works on the Previewer" + + " may be different from that on a real device.") + return new Promise((resolve, reject) => { + resolve(Result); + }) + }; + this.finishWithResult = function (...args) { + console.warn("FeatureAbility.finishWithResult interface mocked in the Previewer. How this interface works on the Previewer" + + " may be different from that on a real device.") + return new Promise((resolve, reject) => { + resolve(Result); + }) + }; + this.getDeviceList = function (...args) { + console.warn("FeatureAbility.getDeviceList interface mocked in the Previewer. How this interface works on the Previewer" + + " may be different from that on a real device.") + return new Promise((resolve, reject) => { + resolve(Result); + }) + }; + this.callAbility = function (...args) { + console.warn("FeatureAbility.callAbility interface mocked in the Previewer. How this interface works on the Previewer" + + " may be different from that on a real device.") + return new Promise((resolve, reject) => { + resolve(paramMock.paramStringMock); + }) + }; + this.continueAbility = function () { + console.warn("FeatureAbility.continueAbility interface mocked in the Previewer. How this interface works on the Previewer" + + " may be different from that on a real device.") + return new Promise((resolve, reject) => { + resolve(Result); + }) + }; + this.subscribeAbilityEvent = function (...args) { + console.warn("FeatureAbility.subscribeAbilityEvent interface mocked in the Previewer. How this interface works on the Previewer" + + " may be different from that on a real device.") + return new Promise((resolve, reject) => { + resolve(paramMock.paramStringMock); + }) + }; + this.unsubscribeAbilityEvent = function (...args) { + console.warn("FeatureAbility.unsubscribeAbilityEvent interface mocked in the Previewer. How this interface works on the Previewer" + + " may be different from that on a real device.") + return new Promise((resolve, reject) => { + resolve(paramMock.paramStringMock); + }) + }; + this.sendMsg = function (...args) { + console.warn("FeatureAbility.sendMsg interface mocked in the Previewer. How this interface works on the Previewer" + + " may be different from that on a real device.") + }; + this.subscribeMsg = function (...args) { + console.warn("FeatureAbility.subscribeMsg interface mocked in the Previewer. How this interface works on the Previewer" + + " may be different from that on a real device.") + }; + this.unsubscribeMsg = function () { + console.warn("FeatureAbility.unsubscribeMsg interface mocked in the Previewer. How this interface works on the Previewer" + + " may be different from that on a real device.") + }; + } +} \ No newline at end of file diff --git a/runtime/main/extend/systemplugin/napi/continuation/continuationExtraParams.js b/runtime/main/extend/systemplugin/napi/continuation/continuationExtraParams.js new file mode 100644 index 00000000..7d494bf6 --- /dev/null +++ b/runtime/main/extend/systemplugin/napi/continuation/continuationExtraParams.js @@ -0,0 +1,27 @@ +/* + * Copyright (c) 2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import { paramMock } from "../../utils" +const ContinuationMode = { + COLLABORATION_SINGLE: 0, + COLLABORATION_MULTIPLE: 1 +} +export const ContinuationExtraParams = { + deviceType: [paramMock.paramStringMock], + targetBundle: "[PC Preview] unknow targetBundle", + description: "[PC Preview] unknow description", + filter: "[PC Preview] unknow filter", + continuationMode: ContinuationMode, + authInfo: {} +} \ No newline at end of file diff --git a/runtime/main/extend/systemplugin/napi/continuation/continuationResult.js b/runtime/main/extend/systemplugin/napi/continuation/continuationResult.js new file mode 100644 index 00000000..1d8521f2 --- /dev/null +++ b/runtime/main/extend/systemplugin/napi/continuation/continuationResult.js @@ -0,0 +1,19 @@ +/* + * Copyright (c) 2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +export const ContinuationResult = { + id: "[PC Preview] unknow id", + type: "[PC Preview] unknow type", + name: "[PC Preview] unknow name", +} \ No newline at end of file diff --git a/runtime/main/extend/systemplugin/napi/index.js b/runtime/main/extend/systemplugin/napi/index.js index 6f709cac..e1ec299a 100644 --- a/runtime/main/extend/systemplugin/napi/index.js +++ b/runtime/main/extend/systemplugin/napi/index.js @@ -15,10 +15,15 @@ import { mockSystemParameter } from './ohos_systemparameter' import { mockAbility } from './ohos_application_Ability' +import { mockFeatureAbility } from './ohos_ability_featureAbility' import { mockDataUriUtils } from './ohos_ability_dataUriUtils' import { mockAbilityDelegatorRegistry } from './ohos_application_abilityDelegatorRegistry' import { mockAbilityLifecycleCallback } from './ohos_application_AbilityLifecycleCallback' import { mockFormExtension } from './ohos_application_FormExtension' +import { mockStaticSubscriberExtensionAbility } from './ohos_application_StaticSubscriberExtensionAbility' +import { mockFormHost } from './ohos_application_formHost' +import { mockErrorManager } from './ohos_application_errorManager' +import { mockTestRunner } from './ohos_application_testRunner' import { mockServiceExtensionAbility } from './ohos_application_ServiceExtensionAbility' import { mockAbilityStage } from './ohos_application_AbilityStage' import { mockFormBindingData } from './ohos_application_formBindingData' @@ -272,12 +277,22 @@ export function mockRequireNapiFun() { return mockSystemParameter(); case "ability.dataUriUtils": return mockDataUriUtils(); + case "ability.featureAbility": + return mockFeatureAbility(); case "application.Ability": return mockAbility(); + case "application.formHost": + return mockFormHost(); case "application.FormExtension": return mockFormExtension(); case "application.ServiceExtensionAbility": return mockServiceExtensionAbility(); + case "application.errorManager": + return mockErrorManager(); + case "application.testRunner": + return mockTestRunner(); + case "application.StaticSubscriberExtensionAbility": + return mockStaticSubscriberExtensionAbility(); case "application.abilityDelegatorRegistry": return mockAbilityDelegatorRegistry(); case "application.AbilityLifecycleCallback": diff --git a/runtime/main/extend/systemplugin/napi/ohos_ability_errorCode.js b/runtime/main/extend/systemplugin/napi/ohos_ability_errorCode.js new file mode 100644 index 00000000..59f0bd7a --- /dev/null +++ b/runtime/main/extend/systemplugin/napi/ohos_ability_errorCode.js @@ -0,0 +1,20 @@ +/* + * Copyright (c) 2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +export const ErrorCode = { + PERMISSION_DENY: -3, + ABILITY_NOT_FOUND: -2, + INVALID_PARAMETER: -1, + NO_ERROR: 0, +} \ No newline at end of file diff --git a/runtime/main/extend/systemplugin/napi/ohos_ability_featureAbility.js b/runtime/main/extend/systemplugin/napi/ohos_ability_featureAbility.js new file mode 100644 index 00000000..ae1aa3cd --- /dev/null +++ b/runtime/main/extend/systemplugin/napi/ohos_ability_featureAbility.js @@ -0,0 +1,425 @@ +/* + * Copyright (c) 2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { paramMock } from "../utils" +import { WantClass } from "./ohos_application_Want" +import { Context } from "./app/context" +import { AbilityResult } from "./ability/abilityResult" +import { windowMock } from "./ohos_window" + +const DataAbilityResult = { + uri: "[PC Preview] unknow uri", + count: "[PC Preview] unknow count" +} +const DataAbilityResultArray = [ + DataAbilityResult +] +export const PacMapType = { + PacMap: {key:{}} +} +export const ResultSet = { + columnNames: [paramMock.paramStringMock], + columnCount: "[PC Preview] unknow columnCount", + rowCount: "[PC Preview] unknow rowCount", + rowIndex: "[PC Preview] unknow rowIndex", + isAtFirstRow: "[PC Preview] unknow isAtFirstRow", + isAtLastRow: "[PC Preview] unknow isAtLastRow", + isEnded: "[PC Preview] unknow isEnded", + isStarted: "[PC Preview] unknow isStarted", + isClose: "[PC Preview] unknow isClose", + getColumnIndex: function (...args) { + console.warn("ResultSet.getColumnIndex interface mocked in the Previewer. How this interface works on the Previewer" + + " may be different from that on a real device.") + return paramMock.paramNumberMock; + }, + getColumnName: function (...args) { + console.warn("ResultSet.getColumnName interface mocked in the Previewer. How this interface works on the Previewer" + + " may be different from that on a real device.") + return paramMock.paramStringMock; + }, + goTo: function (...args) { + console.warn("ResultSet.goTo interface mocked in the Previewer. How this interface works on the Previewer" + + " may be different from that on a real device.") + return paramMock.paramBooleanMock; + }, + goToRow: function (...args) { + console.warn("ResultSet.goToRow interface mocked in the Previewer. How this interface works on the Previewer" + + " may be different from that on a real device.") + return paramMock.paramBooleanMock; + }, + goToLastRow: function (...args) { + console.warn("ResultSet.goToLastRow interface mocked in the Previewer. How this interface works on the Previewer" + + " may be different from that on a real device.") + return paramMock.paramBooleanMock; + }, + goToFirstRow: function (...args) { + console.warn("ResultSet.goToFirstRow interface mocked in the Previewer. How this interface works on the Previewer" + + " may be different from that on a real device.") + return paramMock.paramBooleanMock; + }, + goToNextRow: function (...args) { + console.warn("ResultSet.goToNextRow interface mocked in the Previewer. How this interface works on the Previewer" + + " may be different from that on a real device.") + return paramMock.paramBooleanMock; + }, + goToPreviousRow: function (...args) { + console.warn("ResultSet.goToPreviousRow interface mocked in the Previewer. How this interface works on the Previewer" + + " may be different from that on a real device.") + return paramMock.paramBooleanMock; + }, + getBlob: function (...args) { + console.warn("ResultSet.getBlob interface mocked in the Previewer. How this interface works on the Previewer" + + " may be different from that on a real device.") + return paramMock.paramArrayMock; + }, + getString: function (...args) { + console.warn("ResultSet.getString interface mocked in the Previewer. How this interface works on the Previewer" + + " may be different from that on a real device.") + return paramMock.paramStringMock; + }, + getLong: function (...args) { + console.warn("ResultSet.getLong interface mocked in the Previewer. How this interface works on the Previewer" + + " may be different from that on a real device.") + return paramMock.paramNumberMock; + }, + getDouble: function (...args) { + console.warn("ResultSet.getDouble interface mocked in the Previewer. How this interface works on the Previewer" + + " may be different from that on a real device.") + return paramMock.paramNumberMock; + }, + isColumnNull: function (...args) { + console.warn("ResultSet.isColumnNull interface mocked in the Previewer. How this interface works on the Previewer" + + " may be different from that on a real device.") + return paramMock.paramBooleanMock; + }, + close: function () { + console.warn("ResultSet.isColumnNull interface mocked in the Previewer. How this interface works on the Previewer" + + " may be different from that on a real device.") + } +} +const DataAbilityHelper = { + openFile: function (...args) { + console.warn("DataAbilityHelper.openFile interface mocked in the Previewer. How this interface works on the Previewer" + + " may be different from that on a real device.") + const len = args.length + if (typeof args[len - 1] === 'function') { + args[len - 1].call(this, paramMock.businessErrorMock, paramMock.paramNumberMock) + } else { + return new Promise((resolve) => { + resolve(paramMock.paramNumberMock); + }) + } + }, + on: function (...args) { + console.warn("DataAbilityHelper.on interface mocked in the Previewer. How this interface works on the Previewer" + + " may be different from that on a real device.") + const len = args.length + if (typeof args[len - 1] === 'function') { + args[len - 1].call(this, paramMock.businessErrorMock) + } + }, + off: function (...args) { + console.warn("DataAbilityHelper.off interface mocked in the Previewer. How this interface works on the Previewer" + + " may be different from that on a real device.") + const len = args.length + if (typeof args[len - 1] === 'function') { + args[len - 1].call(this, paramMock.businessErrorMock) + } + }, + getType: function (...args) { + console.warn("DataAbilityHelper.getType interface mocked in the Previewer. How this interface works on the Previewer" + + " may be different from that on a real device.") + const len = args.length + if (typeof args[len - 1] === 'function') { + args[len - 1].call(this, paramMock.businessErrorMock, paramMock.paramStringMock) + } else { + return new Promise((resolve) => { + resolve(paramMock.paramStringMock); + }) + } + }, + getFileTypes: function (...args) { + console.warn("DataAbilityHelper.getFileTypes interface mocked in the Previewer. How this interface works on the Previewer" + + " may be different from that on a real device.") + const len = args.length + if (typeof args[len - 1] === 'function') { + args[len - 1].call(this, paramMock.businessErrorMock, [paramMock.paramStringMock]) + } else { + return new Promise((resolve) => { + resolve([paramMock.paramStringMock]); + }) + } + }, + normalizeUri: function (...args) { + console.warn("DataAbilityHelper.normalizeUri interface mocked in the Previewer. How this interface works on the Previewer" + + " may be different from that on a real device.") + const len = args.length + if (typeof args[len - 1] === 'function') { + args[len - 1].call(this, paramMock.businessErrorMock, paramMock.paramStringMock) + } else { + return new Promise((resolve) => { + resolve(paramMock.paramStringMock); + }) + } + }, + denormalizeUri: function (...args) { + console.warn("DataAbilityHelper.denormalizeUri interface mocked in the Previewer. How this interface works on the Previewer" + + " may be different from that on a real device.") + const len = args.length + if (typeof args[len - 1] === 'function') { + args[len - 1].call(this, paramMock.businessErrorMock, paramMock.paramStringMock) + } else { + return new Promise((resolve) => { + resolve(paramMock.paramStringMock); + }) + } + }, + notifyChange: function (...args) { + console.warn("DataAbilityHelper.notifyChange interface mocked in the Previewer. How this interface works on the Previewer" + + " may be different from that on a real device.") + const len = args.length + if (typeof args[len - 1] === 'function') { + args[len - 1].call(this, paramMock.businessErrorMock) + } else { + return new Promise((resolve) => { + resolve(); + }) + } + }, + insert: function (...args) { + console.warn("DataAbilityHelper.insert interface mocked in the Previewer. How this interface works on the Previewer" + + " may be different from that on a real device.") + const len = args.length + if (typeof args[len - 1] === 'function') { + args[len - 1].call(this, paramMock.businessErrorMock, paramMock.paramNumberMock) + } else { + return new Promise((resolve) => { + resolve(paramMock.paramNumberMock); + }) + } + }, + batchInsert: function (...args) { + console.warn("DataAbilityHelper.batchInsert interface mocked in the Previewer. How this interface works on the Previewer" + + " may be different from that on a real device.") + const len = args.length + if (typeof args[len - 1] === 'function') { + args[len - 1].call(this, paramMock.businessErrorMock, paramMock.paramNumberMock) + } else { + return new Promise((resolve) => { + resolve(paramMock.paramNumberMock); + }) + } + }, + delete: function (...args) { + console.warn("DataAbilityHelper.delete interface mocked in the Previewer. How this interface works on the Previewer" + + " may be different from that on a real device.") + const len = args.length + if (typeof args[len - 1] === 'function') { + args[len - 1].call(this, paramMock.businessErrorMock, paramMock.paramNumberMock) + } else { + return new Promise((resolve) => { + resolve(paramMock.paramNumberMock); + }) + } + }, + update: function (...args) { + console.warn("DataAbilityHelper.update interface mocked in the Previewer. How this interface works on the Previewer" + + " may be different from that on a real device.") + const len = args.length + if (typeof args[len - 1] === 'function') { + args[len - 1].call(this, paramMock.businessErrorMock, paramMock.paramNumberMock) + } else { + return new Promise((resolve) => { + resolve(paramMock.paramNumberMock); + }) + } + }, + query: function (...args) { + console.warn("DataAbilityHelper.query interface mocked in the Previewer. How this interface works on the Previewer" + + " may be different from that on a real device.") + const len = args.length + if (typeof args[len - 1] === 'function') { + args[len - 1].call(this, paramMock.businessErrorMock, ResultSet) + } else { + return new Promise((resolve) => { + resolve(ResultSet); + }) + } + }, + call: function (...args) { + console.warn("DataAbilityHelper.call interface mocked in the Previewer. How this interface works on the Previewer" + + " may be different from that on a real device.") + const len = args.length + if (typeof args[len - 1] === 'function') { + args[len - 1].call(this, paramMock.businessErrorMock, PacMapType) + } else { + return new Promise((resolve) => { + resolve(PacMapType); + }) + } + }, + executeBatch: function (...args) { + console.warn("DataAbilityHelper.executeBatch interface mocked in the Previewer. How this interface works on the Previewer" + + " may be different from that on a real device.") + const len = args.length + if (typeof args[len - 1] === 'function') { + args[len - 1].call(this, paramMock.businessErrorMock, DataAbilityResultArray) + } else { + return new Promise((resolve) => { + resolve(DataAbilityResultArray); + }) + } + } +} +export function mockFeatureAbility() { + const featureAbility = { + getWant: function (...args) { + console.warn("featureAbility.getWant interface mocked in the Previewer." + + " How this interface works on the Previewer may be different from that on a real device.") + const len = args.length + if (len > 0 && typeof args[len - 1] === 'function') { + args[len - 1].call(this, paramMock.businessErrorMock, new WantClass()); + } else { + return new Promise((resolve, reject) => { + resolve(new WantClass()); + }) + } + }, + startAbility: function (...args) { + console.warn("featureAbility.startAbility interface mocked in the Previewer." + + " How this interface works on the Previewer may be different from that on a real device.") + const len = args.length + if (len > 0 && typeof args[len - 1] === 'function') { + args[len - 1].call(this, paramMock.businessErrorMock, paramMock.paramNumberMock); + } else { + return new Promise((resolve, reject) => { + resolve(paramMock.paramNumberMock); + }) + } + }, + getContext: function () { + console.warn("featureAbility.getContext interface mocked in the Previewer." + + " How this interface works on the Previewer may be different from that on a real device.") + return Context; + }, + startAbilityForResult: function (...args) { + console.warn("featureAbility.startAbilityForResult interface mocked in the Previewer." + + " How this interface works on the Previewer may be different from that on a real device.") + const len = args.length + if (len > 0 && typeof args[len - 1] === 'function') { + args[len - 1].call(this, paramMock.businessErrorMock, AbilityResult); + } else { + return new Promise((resolve, reject) => { + resolve(AbilityResult); + }) + } + }, + terminateSelfWithResult: function (...args) { + console.warn("featureAbility.terminateSelfWithResult interface mocked in the Previewer." + + " How this interface works on the Previewer may be different from that on a real device.") + const len = args.length + if (len > 0 && typeof args[len - 1] === 'function') { + args[len - 1].call(this, paramMock.businessErrorMock); + } else { + return new Promise((resolve, reject) => { + resolve(); + }) + } + }, + terminateSelf: function () { + console.warn("featureAbility.terminateSelf interface mocked in the Previewer." + + " How this interface works on the Previewer may be different from that on a real device.") + const len = args.length + if (len > 0 && typeof args[len - 1] === 'function') { + args[len - 1].call(this, paramMock.businessErrorMock); + } else { + return new Promise((resolve, reject) => { + resolve(); + }) + } + }, + acquireDataAbilityHelper: function (...args) { + console.warn("featureAbility.acquireDataAbilityHelper interface mocked in the Previewer." + + " How this interface works on the Previewer may be different from that on a real device.") + return DataAbilityHelper; + }, + hasWindowFocus: function (...args) { + console.warn("featureAbility.hasWindowFocus interface mocked in the Previewer." + + " How this interface works on the Previewer may be different from that on a real device.") + const len = args.length + if (len > 0 && typeof args[len - 1] === 'function') { + args[len - 1].call(this, paramMock.businessErrorMock, paramMock.paramBooleanMock); + } else { + return new Promise((resolve, reject) => { + resolve(paramMock.paramBooleanMock); + }) + } + }, + connectAbility: function (...args) { + console.warn("featureAbility.connectAbility interface mocked in the Previewer." + + " How this interface works on the Previewer may be different from that on a real device.") + return paramMock.paramNumberMock; + }, + disconnectAbility: function (...args) { + console.warn("featureAbility.disconnectAbility interface mocked in the Previewer." + + " How this interface works on the Previewer may be different from that on a real device.") + const len = args.length + if (len > 0 && typeof args[len - 1] === 'function') { + args[len - 1].call(this, paramMock.businessErrorMock); + } else { + return new Promise((resolve, reject) => { + resolve(); + }) + } + }, + getWindow: function (...args) { + console.warn("featureAbility.getWindow interface mocked in the Previewer." + + " How this interface works on the Previewer may be different from that on a real device.") + const len = args.length + if (len > 0 && typeof args[len - 1] === 'function') { + args[len - 1].call(this, paramMock.businessErrorMock, windowMock); + } else { + return new Promise((resolve, reject) => { + resolve(windowMock); + }) + } + }, + } + return featureAbility; +} +export const AbilityWindowConfiguration = { + WINDOW_MODE_UNDEFINED: 0, + WINDOW_MODE_FULLSCREEN: 1, + WINDOW_MODE_SPLIT_PRIMARY: 100, + WINDOW_MODE_SPLIT_SECONDARY: 101, + WINDOW_MODE_FLOATING: 102 +} +export const AbilityStartSetting = { + BOUNDS_KEY: "abilityBounds", + WINDOW_MODE_KEY: "windowMode", + DISPLAY_ID_KEY: "displayId" +} +export const ErrorCode = { + NO_ERROR: 0, + INVALID_PARAMETER: -1, + ABILITY_NOT_FOUND: -2, + PERMISSION_DENY: -3 +} +export const DataAbilityOperationType = { + TYPE_INSERT: 1, + TYPE_UPDATE: 2, + TYPE_DELETE: 3, + TYPE_ASSERT: 4, +} \ No newline at end of file diff --git a/runtime/main/extend/systemplugin/napi/ohos_ability_wantConstant.js b/runtime/main/extend/systemplugin/napi/ohos_ability_wantConstant.js new file mode 100644 index 00000000..7f469b89 --- /dev/null +++ b/runtime/main/extend/systemplugin/napi/ohos_ability_wantConstant.js @@ -0,0 +1,68 @@ +/* + * Copyright (c) 2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +export const Action = { + ACTION_HOME: "ohos.want.action.home", + ACTION_DIAL: "ohos.want.action.dial", + ACTION_SEARCH: "ohos.want.action.search", + ACTION_WIRELESS_SETTINGS: "ohos.settings.wireless", + ACTION_MANAGE_APPLICATIONS_SETTINGS: "ohos.settings.manage.applications", + ACTION_APPLICATION_DETAILS_SETTINGS: "ohos.settings.application.details", + ACTION_SET_ALARM: "ohos.want.action.setAlarm", + ACTION_SHOW_ALARMS: "ohos.want.action.showAlarms", + ACTION_SNOOZE_ALARM: "ohos.want.action.snoozeAlarm", + ACTION_DISMISS_ALARM: "ohos.want.action.dismissAlarm", + ACTION_DISMISS_TIMER: "ohos.want.action.dismissTimer", + ACTION_SEND_SMS: "ohos.want.action.sendSms", + ACTION_CHOOSE: "ohos.want.action.choose", + ACTION_IMAGE_CAPTURE: "ohos.want.action.imageCapture", + ACTION_VIDEO_CAPTURE: "ohos.want.action.videoCapture", + ACTION_SELECT: "ohos.want.action.select", + ACTION_SEND_DATA: "ohos.want.action.sendData", + ACTION_SEND_MULTIPLE_DATA: "ohos.want.action.sendMultipleData", + ACTION_SCAN_MEDIA_FILE: "ohos.want.action.scanMediaFile", + ACTION_VIEW_DATA: "ohos.want.action.viewData", + ACTION_EDIT_DATA: "ohos.want.action.editData", + INTENT_PARAMS_INTENT: "ability.want.params.INTENT", + INTENT_PARAMS_TITLE: "ability.want.params.TITLE", + ACTION_FILE_SELECT: "ohos.action.fileSelect", + PARAMS_STREAM: "ability.params.stream", + ACTION_APP_ACCOUNT_OAUTH: "ohos.account.appAccount.action.oauth", + ACTION_MARKER_DOWNLOAD: "ohos.want.action.marketDownload" +} +export const Entity = { + ENTITY_DEFAULT: "entity.system.default", + ENTITY_HOME: "entity.system.home", + ENTITY_VOICE: "entity.system.voice", + ENTITY_BROWSABLE: "entity.system.browsable", + ENTITY_VIDEO: "entity.system.video" +} +export const Flags = { + FLAG_AUTH_READ_URI_PERMISSION: 0x00000001, + FLAG_AUTH_WRITE_URI_PERMISSION: 0x00000002, + FLAG_ABILITY_FORWARD_RESULT: 0x00000004, + FLAG_ABILITY_CONTINUATION: 0x00000008, + FLAG_NOT_OHOS_COMPONENT: 0x00000010, + FLAG_ABILITY_FORM_ENABLED: 0x00000020, + FLAG_AUTH_PERSISTABLE_URI_PERMISSION: 0x00000040, + FLAG_AUTH_PREFIX_URI_PERMISSION: 0x00000080, + FLAG_ABILITYSLICE_MULTI_DEVICE: 0x00000100, + FLAG_START_FOREGROUND_ABILITY: 0x00000200, + FLAG_ABILITY_CONTINUATION_REVERSIBLE: 0x00000400, + FLAG_INSTALL_ON_DEMAND: 0x00000800, + FLAG_INSTALL_WITH_BACKGROUND_MODE: 0x80000000, + FLAG_ABILITY_CLEAR_MISSION: 0x00008000, + FLAG_ABILITY_NEW_MISSION: 0x10000000, + FLAG_ABILITY_MISSION_TOP: 0x20000000 +} \ No newline at end of file diff --git a/runtime/main/extend/systemplugin/napi/ohos_application_Ability.js b/runtime/main/extend/systemplugin/napi/ohos_application_Ability.js index 51b30eb8..66e3015a 100644 --- a/runtime/main/extend/systemplugin/napi/ohos_application_Ability.js +++ b/runtime/main/extend/systemplugin/napi/ohos_application_Ability.js @@ -14,11 +14,36 @@ */ import { paramMock } from "../utils" -import { AbilityContextClass } from "./application/abilityContext" +import { AbilityContextClass } from "./application/AbilityContext" import { WantClass } from "./ohos_application_Want" import { OnContinueResult } from "./ohos_application_AbilityConstant" +import { MessageParcelClass } from "./ohos_rpc" -const calleeMock = { +export const Caller = { + call: function (...args) { + console.warn("Caller.call interface mocked in the Previewer." + + " How this interface works on the Previewer may be different from that on a real device.") + return new Promise((resolve, reject) => { + resolve(); + }) + }, + callWithResult: function (...args) { + console.warn("Caller.callWithResult interface mocked in the Previewer." + + " How this interface works on the Previewer may be different from that on a real device.") + return new Promise((resolve, reject) => { + resolve(new MessageParcelClass()); + }) + }, + release: function () { + console.warn("Caller.release interface mocked in the Previewer. How this interface works on the Previewer" + + " may be different from that on a real device.") + }, + onRelease: function (...args) { + console.warn("Caller.onRelease interface mocked in the Previewer. How this interface works on the Previewer" + + " may be different from that on a real device.") + }, +} +export const Callee = { on: function (...args) { console.warn("Ability.calleeClass.on interface mocked in the Previewer. How this interface works on the Previewer" + " may be different from that on a real device.") @@ -35,7 +60,7 @@ export const AbilityClass = class Ability { this.context = new AbilityContextClass(); this.launchWant = new WantClass(); this.lastRequestWant = new WantClass(); - this.callee = calleeMock; + this.callee = Callee; this.onCreate = function (...args) { console.warn("application.Ability.onCreate interface mocked in the Previewer. How this interface works on the Previewer" + " may be different from that on a real device.") diff --git a/runtime/main/extend/systemplugin/napi/ohos_application_AbilityConstant.js b/runtime/main/extend/systemplugin/napi/ohos_application_AbilityConstant.js index 4d1f9623..f32f7d60 100644 --- a/runtime/main/extend/systemplugin/napi/ohos_application_AbilityConstant.js +++ b/runtime/main/extend/systemplugin/napi/ohos_application_AbilityConstant.js @@ -13,6 +13,21 @@ * limitations under the License. */ +export const LaunchParam = { + launchReason: LaunchReason, + lastExitReason: LastExitReason, +} +export const LaunchReason = { + UNKNOWN: 0, + START_ABILITY: 1, + CALL: 2, + CONTINUATION: 3, +} +export const LastExitReason = { + UNKNOWN: 0, + ABILITY_NOT_RESPONDING: 1, + NORMAL: 2, +} export const OnContinueResult = { AGREE: 0, REJECT: 1, diff --git a/runtime/main/extend/systemplugin/napi/ohos_application_AbilityStage.js b/runtime/main/extend/systemplugin/napi/ohos_application_AbilityStage.js index 192e9a4e..526875db 100644 --- a/runtime/main/extend/systemplugin/napi/ohos_application_AbilityStage.js +++ b/runtime/main/extend/systemplugin/napi/ohos_application_AbilityStage.js @@ -13,7 +13,7 @@ * limitations under the License. */ -import { abilityStageContextClass } from "./application/abilityContext" +import { abilityStageContextClass } from "./application/AbilityContext" import { paramMock } from "../utils" export function mockAbilityStage() { @@ -26,11 +26,15 @@ export function mockAbilityStage() { console.warn("application.AbilityStage.onCreate interface mocked in the Previewer. How this interface works on the Previewer" + " may be different from that on a real device.") }; - this.onAcceptWant = function () { + this.onAcceptWant = function (...args) { console.warn("application.AbilityStage.onAcceptWant interface mocked in the Previewer. How this interface works on the Previewer" + " may be different from that on a real device.") return paramMock.paramStringMock; - } + }; + this.onConfigurationUpdated = function (...args) { + console.warn("application.AbilityStage.onConfigurationUpdated interface mocked in the Previewer. How this interface works on the Previewer" + + " may be different from that on a real device.") + }; } } return new AbilityStageClass(); diff --git a/runtime/main/extend/systemplugin/napi/ohos_application_Configuration.js b/runtime/main/extend/systemplugin/napi/ohos_application_Configuration.js new file mode 100644 index 00000000..487bf868 --- /dev/null +++ b/runtime/main/extend/systemplugin/napi/ohos_application_Configuration.js @@ -0,0 +1,22 @@ +/* + * Copyright (c) 2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import { ColorMode, Direction, ScreenDensity} from "./ohos_application_ConfigurationConstant" +export const Configuration = { + language: '[PC preview] unknow language', + colorMode: ColorMode, + direction: Direction, + screenDensity: ScreenDensity, + displayId: '[PC preview] unknow displayId', +} diff --git a/runtime/main/extend/systemplugin/napi/ohos_application_ConfigurationConstant.js b/runtime/main/extend/systemplugin/napi/ohos_application_ConfigurationConstant.js new file mode 100644 index 00000000..e4f874a9 --- /dev/null +++ b/runtime/main/extend/systemplugin/napi/ohos_application_ConfigurationConstant.js @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +export const ColorMode = { + COLOR_MODE_NOT_SET: -1, + COLOR_MODE_DARK: 0, + COLOR_MODE_LIGHT: 1, +} +export const Direction = { + DIRECTION_NOT_SET: -1, + DIRECTION_VERTICAL: 0, + DIRECTION_HORIZONTAL: 1, +} +export const ScreenDensity = { + SCREEN_DENSITY_NOT_SET: 0, + SCREEN_DENSITY_SDPI: 120, + SCREEN_DENSITY_MDPI: 160, + SCREEN_DENSITY_LDPI: 240, + SCREEN_DENSITY_XLDPI: 320, + SCREEN_DENSITY_XXLDPI: 480, + SCREEN_DENSITY_XXXLDPI: 640, +} \ No newline at end of file diff --git a/runtime/main/extend/systemplugin/napi/ohos_application_DataShareExtensionAbility.js b/runtime/main/extend/systemplugin/napi/ohos_application_DataShareExtensionAbility.js index 28fd0a32..79b4c464 100644 --- a/runtime/main/extend/systemplugin/napi/ohos_application_DataShareExtensionAbility.js +++ b/runtime/main/extend/systemplugin/napi/ohos_application_DataShareExtensionAbility.js @@ -14,7 +14,7 @@ */ import { paramMock } from "../utils" -import { ExtensionContextClass } from "./application/abilityContext" +import { ExtensionContextClass } from "./application/AbilityContext" import { DataShareResultSetMock } from "./ohos_data_DataShareResultSet" export function mockDataShareExtensionAbility() { diff --git a/runtime/main/extend/systemplugin/napi/ohos_application_FormExtension.js b/runtime/main/extend/systemplugin/napi/ohos_application_FormExtension.js index 64a7de63..d1aa94ca 100644 --- a/runtime/main/extend/systemplugin/napi/ohos_application_FormExtension.js +++ b/runtime/main/extend/systemplugin/napi/ohos_application_FormExtension.js @@ -14,7 +14,8 @@ */ import { paramMock } from "../utils" -import { ExtensionContextClass } from "./application/abilityContext" +import { ExtensionContextClass } from "./application/AbilityContext" +import { FormState } from "./ohos_application_formInfo" export function mockFormExtension() { const formBindingDataMock = { @@ -81,7 +82,16 @@ export function mockFormExtension() { console.warn("application.formExtension.onDestroy interface mocked in the Previewer. How this interface works on the Previewer" + " may be different from that on a real device.") }; + this.onConfigurationUpdated = function (...args) { + console.warn("application.formExtension.onConfigurationUpdated interface mocked in the Previewer. How this interface works on the Previewer" + + " may be different from that on a real device.") + }; + this.onAcquireFormState = function (...args) { + console.warn("application.formExtension.onAcquireFormState interface mocked in the Previewer. How this interface works on the Previewer" + + " may be different from that on a real device.") + return FormState; + }; } } - return formExtensionClass; + return new formExtensionClass(); } \ No newline at end of file diff --git a/runtime/main/extend/systemplugin/napi/ohos_application_ServiceExtensionAbility.js b/runtime/main/extend/systemplugin/napi/ohos_application_ServiceExtensionAbility.js index 23146d19..3fc1e183 100644 --- a/runtime/main/extend/systemplugin/napi/ohos_application_ServiceExtensionAbility.js +++ b/runtime/main/extend/systemplugin/napi/ohos_application_ServiceExtensionAbility.js @@ -14,7 +14,7 @@ */ import { paramMock } from "../utils" -import { ExtensionContextClass } from "./application/abilityContext" +import { ExtensionContextClass } from "./application/AbilityContext" export const RemoteObjectClass = class RemoteObject { constructor() { @@ -231,6 +231,11 @@ export function mockServiceExtensionAbility() { console.warn("application.ServiceExtensionAbility.onConfigurationUpdated interface mocked in the Previewer. How this interface works on the Previewer" + " may be different from that on a real device.") }; + this.dump = function (...args) { + console.warn("application.ServiceExtensionAbility.dump interface mocked in the Previewer. How this interface works on the Previewer" + + " may be different from that on a real device.") + return [paramMock.paramStringMock]; + }; } } return new ServiceExtensionAbilityClass(); diff --git a/runtime/main/extend/systemplugin/napi/ohos_application_StartOptions.js b/runtime/main/extend/systemplugin/napi/ohos_application_StartOptions.js new file mode 100644 index 00000000..530bd319 --- /dev/null +++ b/runtime/main/extend/systemplugin/napi/ohos_application_StartOptions.js @@ -0,0 +1,22 @@ +/* + * Copyright (c) 2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +export const StartOptionsClass = class StartOptions { + constructor() { + console.warn('StartOptions.constructor interface mocked in the Previewer. How this interface works on' + + ' the Previewer may be different from that on a real device.'); + this.windowMode = "[PC Preview] unknow windowMode"; + this.displayId = "[PC Preview] unknow displayId"; + } +} \ No newline at end of file diff --git a/runtime/main/extend/systemplugin/napi/ohos_application_StaticSubscriberExtensionAbility.js b/runtime/main/extend/systemplugin/napi/ohos_application_StaticSubscriberExtensionAbility.js new file mode 100644 index 00000000..45c9875f --- /dev/null +++ b/runtime/main/extend/systemplugin/napi/ohos_application_StaticSubscriberExtensionAbility.js @@ -0,0 +1,27 @@ +/* + * Copyright (c) 2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +export function mockStaticSubscriberExtensionAbility() { + const StaticSubscriberExtensionAbilityClass = class StaticSubscriberExtensionAbility { + constructor() { + console.warn('StaticSubscriberExtensionAbility.constructor interface mocked in the Previewer. How this interface works on' + + ' the Previewer may be different from that on a real device.'); + this.onReceiveEvent = function (...args) { + console.warn("StaticSubscriberExtensionAbility.onReceiveEvent interface mocked in the Previewer. How this interface works on the Previewer" + + " may be different from that on a real device.") + }; + } + } + return new StaticSubscriberExtensionAbilityClass(); +} \ No newline at end of file diff --git a/runtime/main/extend/systemplugin/napi/ohos_application_abilityManager.js b/runtime/main/extend/systemplugin/napi/ohos_application_abilityManager.js index 29613408..c438205c 100644 --- a/runtime/main/extend/systemplugin/napi/ohos_application_abilityManager.js +++ b/runtime/main/extend/systemplugin/napi/ohos_application_abilityManager.js @@ -15,6 +15,13 @@ import { paramMock } from "../utils" +export const AbilityState = { + INITIAL: 0, + FOREGROUND: 9, + BACKGROUND: 10, + FOREGROUNDING: 11, + BACKGROUNDING: 12 +} export function mockAbilityManager() { const AbilityRunningInfoMock = { ability: ElementNameMock, @@ -40,6 +47,14 @@ export function mockAbilityManager() { clientPackage: [paramMock.paramStringMock], ExtensionAbilityTypeMock: '[PC preview] unknow ExtensionAbilityTypeMock', } + const elementName = { + deviceId: "[PC preview] unknown deviceId", + bundleName: "[PC preview] unknown bundleName", + abilityName: "[PC preview] unknown abilityName", + uri: "[PC preview] unknown uri", + shortName: "[PC preview] unknown shortName", + moduleName: "[PC preview] unknown moduleName", + } const abilityManager = { updateConfiguration: function (...args) { console.warn('abilityManager.updateConfiguration interface mocked in the Previewer. How this interface works on the' + @@ -76,6 +91,18 @@ export function mockAbilityManager() { resolve([ExtensionRunningInfoMock]); }); } + }, + getTopAbility: function (...args) { + console.warn('abilityManager.getTopAbility interface mocked in the Previewer. How this interface works on the' + + ' Previewer may be different from that on a real device.'); + const len = args.length; + if (typeof args[len - 1] === 'function') { + args[len - 1].call(this, paramMock.businessErrorMock, elementName); + } else { + return new Promise((resolve) => { + resolve(elementName); + }); + } } } return abilityManager diff --git a/runtime/main/extend/systemplugin/napi/ohos_application_appManager.js b/runtime/main/extend/systemplugin/napi/ohos_application_appManager.js index 14241881..7c3dfdf0 100644 --- a/runtime/main/extend/systemplugin/napi/ohos_application_appManager.js +++ b/runtime/main/extend/systemplugin/napi/ohos_application_appManager.js @@ -116,6 +116,30 @@ export function mockAppManager() { resolve(); }); } + }, + isRamConstrainedDevice: function (...args) { + console.warn('appManager.isRamConstrainedDevice interface mocked in the Previewer. How this interface works on the' + + ' Previewer may be different from that on a real device.'); + const len = args.length; + if (typeof args[len - 1] === 'function') { + args[len - 1].call(this, paramMock.businessErrorMock, paramMock.paramBooleanMock); + } else { + return new Promise((resolve) => { + resolve(paramMock.paramBooleanMock); + }); + } + }, + getAppMemorySize: function (...args) { + console.warn('appManager.getAppMemorySize interface mocked in the Previewer. How this interface works on the' + + ' Previewer may be different from that on a real device.'); + const len = args.length; + if (typeof args[len - 1] === 'function') { + args[len - 1].call(this, paramMock.businessErrorMock, paramMock.paramNumberMock); + } else { + return new Promise((resolve) => { + resolve(paramMock.paramNumberMock); + }); + } } } return appManager diff --git a/runtime/main/extend/systemplugin/napi/ohos_application_errorManager.js b/runtime/main/extend/systemplugin/napi/ohos_application_errorManager.js new file mode 100644 index 00000000..ae82557b --- /dev/null +++ b/runtime/main/extend/systemplugin/napi/ohos_application_errorManager.js @@ -0,0 +1,38 @@ +/* + * Copyright (c) 2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import { paramMock } from "../utils" + +export function mockErrorManager() { + const errorManager = { + registerErrorObserver: function (...args) { + console.warn('errorManager.registerErrorObserver interface mocked in the Previewer. How this interface works on the' + + ' Previewer may be different from that on a real device.'); + return paramMock.paramNumberMock; + }, + unregisterErrorObserver: function (...args) { + console.warn('errorManager.unregisterErrorObserver interface mocked in the Previewer. How this interface works on the' + + ' Previewer may be different from that on a real device.'); + const len = args.length; + if (typeof args[len - 1] === 'function') { + args[len - 1].call(this, paramMock.businessErrorMock); + } else { + return new Promise((resolve, reject) => { + resolve(); + }); + } + }, + } + return errorManager +} \ No newline at end of file diff --git a/runtime/main/extend/systemplugin/napi/ohos_application_formBindingData.js b/runtime/main/extend/systemplugin/napi/ohos_application_formBindingData.js index ee6a78a0..da8ffa55 100644 --- a/runtime/main/extend/systemplugin/napi/ohos_application_formBindingData.js +++ b/runtime/main/extend/systemplugin/napi/ohos_application_formBindingData.js @@ -14,17 +14,16 @@ */ import { paramMock } from "../utils" - +export const FormBindingData = { + data: paramMock.paramObjectMock +} export function mockFormBindingData() { - const formBindingDatasMock = { - data: paramMock.paramObjectMock - } - const formBindingDataMock = { + const formBindingData = { createFormBindingData: function (...args) { console.warn("formBindingData.createFormBindingData interface mocked in the Previewer. How this interface works on the Previewer" + " may be different from that on a real device.") - return formBindingDatasMock; + return FormBindingData; }, } - return formBindingDataMock; + return formBindingData; } \ No newline at end of file diff --git a/runtime/main/extend/systemplugin/napi/ohos_application_formError.js b/runtime/main/extend/systemplugin/napi/ohos_application_formError.js new file mode 100644 index 00000000..431d7166 --- /dev/null +++ b/runtime/main/extend/systemplugin/napi/ohos_application_formError.js @@ -0,0 +1,39 @@ +/* + * Copyright (c) 2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +export const FormError = { + ERR_COMMON: 1, + ERR_PERMISSION_DENY: 2, + ERR_GET_INFO_FAILED: 4, + ERR_GET_BUNDLE_FAILED: 5, + ERR_GET_LAYOUT_FAILED: 6, + ERR_ADD_INVALID_PARAM: 7, + ERR_CFG_NOT_MATCH_ID: 8, + ERR_NOT_EXIST_ID: 9, + ERR_BIND_PROVIDER_FAILED: 10, + ERR_MAX_SYSTEM_FORMS: 11, + ERR_MAX_INSTANCES_PER_FORM: 12, + ERR_OPERATION_FORM_NOT_SELF: 13, + ERR_PROVIDER_DEL_FAIL: 14, + ERR_MAX_FORMS_PER_CLIENT: 15, + ERR_MAX_SYSTEM_TEMP_FORMS: 16, + ERR_FORM_NO_SUCH_MODULE: 17, + ERR_FORM_NO_SUCH_ABILITY: 18, + ERR_FORM_NO_SUCH_DIMENSION: 19, + ERR_FORM_FA_NOT_INSTALLED: 20, + ERR_SYSTEM_RESPONSES_FAILED: 30, + ERR_FORM_DUPLICATE_ADDED: 31, + ERR_IN_RECOVERY: 36 +} \ No newline at end of file diff --git a/runtime/main/extend/systemplugin/napi/ohos_application_formHost.js b/runtime/main/extend/systemplugin/napi/ohos_application_formHost.js new file mode 100644 index 00000000..ae11360d --- /dev/null +++ b/runtime/main/extend/systemplugin/napi/ohos_application_formHost.js @@ -0,0 +1,219 @@ +/* + * Copyright (c) 2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { paramMock } from "../utils" +import { FormInfo, FormStateInfo } from "./ohos_application_formInfo" + +export function mockFormHost() { + const formHost = { + deleteForm: function (...args) { + console.warn('formHost.deleteForm interface mocked in the Previewer. How this interface works on the' + + ' Previewer may be different from that on a real device.'); + const len = args.length; + if (typeof args[len - 1] === 'function') { + args[len - 1].call(this, paramMock.businessErrorMock); + } else { + return new Promise((resolve) => { + resolve(); + }); + } + }, + releaseForm: function (...args) { + console.warn('formHost.releaseForm interface mocked in the Previewer. How this interface works on the' + + ' Previewer may be different from that on a real device.'); + const len = args.length; + if (typeof args[len - 1] === 'function') { + args[len - 1].call(this, paramMock.businessErrorMock); + } else { + return new Promise((resolve) => { + resolve(); + }); + } + }, + requestForm: function (...args) { + console.warn('formHost.requestForm interface mocked in the Previewer. How this interface works on the' + + ' Previewer may be different from that on a real device.'); + const len = args.length; + if (typeof args[len - 1] === 'function') { + args[len - 1].call(this, paramMock.businessErrorMock); + } else { + return new Promise((resolve) => { + resolve(); + }); + } + }, + castTempForm: function (...args) { + console.warn('formHost.castTempForm interface mocked in the Previewer. How this interface works on the' + + ' Previewer may be different from that on a real device.'); + const len = args.length; + if (typeof args[len - 1] === 'function') { + args[len - 1].call(this, paramMock.businessErrorMock); + } else { + return new Promise((resolve) => { + resolve(); + }); + } + }, + notifyVisibleForms: function (...args) { + console.warn('formHost.notifyVisibleForms interface mocked in the Previewer. How this interface works on the' + + ' Previewer may be different from that on a real device.'); + const len = args.length; + if (typeof args[len - 1] === 'function') { + args[len - 1].call(this, paramMock.businessErrorMock); + } else { + return new Promise((resolve) => { + resolve(); + }); + } + }, + notifyInvisibleForms: function (...args) { + console.warn('formHost.notifyInvisibleForms interface mocked in the Previewer. How this interface works on the' + + ' Previewer may be different from that on a real device.'); + const len = args.length; + if (typeof args[len - 1] === 'function') { + args[len - 1].call(this, paramMock.businessErrorMock); + } else { + return new Promise((resolve) => { + resolve(); + }); + } + }, + enableFormsUpdate: function (...args) { + console.warn('formHost.enableFormsUpdate interface mocked in the Previewer. How this interface works on the' + + ' Previewer may be different from that on a real device.'); + const len = args.length; + if (typeof args[len - 1] === 'function') { + args[len - 1].call(this, paramMock.businessErrorMock); + } else { + return new Promise((resolve) => { + resolve(); + }); + } + }, + disableFormsUpdate: function (...args) { + console.warn('formHost.disableFormsUpdate interface mocked in the Previewer. How this interface works on the' + + ' Previewer may be different from that on a real device.'); + const len = args.length; + if (typeof args[len - 1] === 'function') { + args[len - 1].call(this, paramMock.businessErrorMock); + } else { + return new Promise((resolve) => { + resolve(); + }); + } + }, + isSystemReady: function (...args) { + console.warn('formHost.isSystemReady interface mocked in the Previewer. How this interface works on the' + + ' Previewer may be different from that on a real device.'); + const len = args.length; + if (typeof args[len - 1] === 'function') { + args[len - 1].call(this, paramMock.businessErrorMock); + } else { + return new Promise((resolve) => { + resolve(); + }); + } + }, + getAllFormsInfo: function (...args) { + console.warn('formHost.getAllFormsInfo interface mocked in the Previewer. How this interface works on the' + + ' Previewer may be different from that on a real device.'); + const len = args.length; + if (typeof args[len - 1] === 'function') { + args[len - 1].call(this, paramMock.businessErrorMock, [FormInfo]); + } else { + return new Promise((resolve) => { + resolve([FormInfo]); + }); + } + }, + getFormsInfo: function (...args) { + console.warn('formHost.getFormsInfo interface mocked in the Previewer. How this interface works on the' + + ' Previewer may be different from that on a real device.'); + const len = args.length; + if (typeof args[len - 1] === 'function') { + args[len - 1].call(this, paramMock.businessErrorMock, [FormInfo]); + } else { + return new Promise((resolve) => { + resolve([FormInfo]); + }); + } + }, + deleteInvalidForms: function (...args) { + console.warn('formHost.deleteInvalidForms interface mocked in the Previewer. How this interface works on the' + + ' Previewer may be different from that on a real device.'); + const len = args.length; + if (typeof args[len - 1] === 'function') { + args[len - 1].call(this, paramMock.businessErrorMock, [paramMock.paramNumberMock]); + } else { + return new Promise((resolve) => { + resolve([paramMock.paramNumberMock]); + }); + } + }, + acquireFormState: function (...args) { + console.warn('formHost.acquireFormState interface mocked in the Previewer. How this interface works on the' + + ' Previewer may be different from that on a real device.'); + const len = args.length; + if (typeof args[len - 1] === 'function') { + args[len - 1].call(this, paramMock.businessErrorMock, FormStateInfo); + } else { + return new Promise((resolve) => { + resolve(FormStateInfo); + }); + } + }, + on: function (...args) { + console.warn("formHost.on interface mocked in the Previewer. How this interface works on the Previewer" + + " may be different from that on a real device.") + const len = args.length + if (typeof args[len - 1] === 'function') { + args[len - 1].call(this, paramMock.paramStringMock); + } + }, + off: function (...args) { + console.warn("formHost.off interface mocked in the Previewer. How this interface works on the Previewer" + + " may be different from that on a real device.") + const len = args.length + if (typeof args[len - 1] === 'function') { + args[len - 1].call(this, paramMock.paramStringMock); + } + }, + notifyFormsVisible: function (...args) { + console.warn('formHost.notifyFormsVisible interface mocked in the Previewer. How this interface works on the' + + ' Previewer may be different from that on a real device.'); + const len = args.length; + if (typeof args[len - 1] === 'function') { + args[len - 1].call(this, paramMock.businessErrorMock); + } else { + return new Promise((resolve) => { + resolve(); + }); + } + }, + notifyFormsEnableUpdate: function (...args) { + console.warn('formHost.notifyFormsEnableUpdate interface mocked in the Previewer. How this interface works on the' + + ' Previewer may be different from that on a real device.'); + const len = args.length; + if (typeof args[len - 1] === 'function') { + args[len - 1].call(this, paramMock.businessErrorMock); + } else { + return new Promise((resolve) => { + resolve(); + }); + } + }, + } + return formHost +} \ No newline at end of file diff --git a/runtime/main/extend/systemplugin/napi/ohos_application_formInfo.js b/runtime/main/extend/systemplugin/napi/ohos_application_formInfo.js new file mode 100644 index 00000000..23a551b8 --- /dev/null +++ b/runtime/main/extend/systemplugin/napi/ohos_application_formInfo.js @@ -0,0 +1,66 @@ +/* + * Copyright (c) 2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import { paramMock } from "../utils" +import { WantClass } from "./ohos_application_Want" + +export const FormInfo = { + bundleName: '[PC preview] unknow bundleName', + moduleName: '[PC preview] unknow moduleName', + abilityName: '[PC preview] unknow abilityName', + name: '[PC preview] unknow name', + description: '[PC preview] unknow description', + type: FormType, + jsComponentName: '[PC preview] unknow jsComponentName', + colorMode: ColorMode, + isDefault: '[PC preview] unknow isDefault', + updateEnabled: '[PC preview] unknow updateEnabled', + formVisibleNotify: '[PC preview] unknow formVisibleNotify', + relatedBundleName: '[PC preview] unknow relatedBundleName', + scheduledUpdateTime: '[PC preview] unknow scheduledUpdateTime', + formConfigAbility: '[PC preview] unknow formConfigAbility', + updateDuration: '[PC preview] unknow updateDuration', + defaultDimension: '[PC preview] unknow defaultDimension', + supportDimensions: [paramMock.paramNumberMock], + customizeData: {"key": paramMock.paramStringMock}, +} +export const FormType = { + JS: 1, +} +export const ColorMode = { + MODE_AUTO: -1, + MODE_DARK: 0, + MODE_LIGHT: 1 +} +export const FormStateInfo = { + formState: FormState, + want: new WantClass(), +} +export const FormState = { + UNKNOWN: -1, + DEFAULT: 0, + READY: 1, +} +export const FormParam = { + IDENTITY_KEY: "ohos.extra.param.key.form_identity", + DIMENSION_KEY: "ohos.extra.param.key.form_dimension", + NAME_KEY: "ohos.extra.param.key.form_name", + MODULE_NAME_KEY: "ohos.extra.param.key.module_name", + WIDTH_KEY: "ohos.extra.param.key.form_width", + HEIGHT_KEY: "ohos.extra.param.key.form_height", + TEMPORARY_KEY: "ohos.extra.param.key.form_temporary" +} +export const FormInfoFilter = { + moduleName: '[PC preview] unknow moduleName', +} \ No newline at end of file diff --git a/runtime/main/extend/systemplugin/napi/ohos_application_formProvider.js b/runtime/main/extend/systemplugin/napi/ohos_application_formProvider.js index 2492537e..078f3e77 100644 --- a/runtime/main/extend/systemplugin/napi/ohos_application_formProvider.js +++ b/runtime/main/extend/systemplugin/napi/ohos_application_formProvider.js @@ -13,44 +13,42 @@ * limitations under the License. */ import { paramMock } from "../utils" +import { FormInfo } from "./ohos_application_formInfo" export function mockFormProvider() { - const FormType = { - JS: 1, - } - const ColorMode = { - MODE_AUTO : -1, - MODE_DARK : 0, - MODE_LIGHT : 1, - } - // A mock version of formInfo. - const FormInfoMock = { - bundleName: '[PC preview] unknow bundleName', - moduleName: '[PC preview] unknow moduleName', - abilityName: '[PC preview] unknow abilityName', - name: '[PC preview] unknow name', - description: '[PC preview] unknow description', - type: FormType, - jsComponentName: '[PC preview] unknow jsComponentName', - colorMode: ColorMode, - isDefault: '[PC preview] unknow isDefault', - updateEnabled: '[PC preview] unknow updateEnabled', - formVisibleNotify: '[PC preview] unknow formVisibleNotify', - relatedBundleName: '[PC preview] unknow relatedBundleName', - scheduledUpdateTime: '[PC preview] unknow scheduledUpdateTime', - formConfigAbility: '[PC preview] unknow formConfigAbility', - updateDuration: '[PC preview] unknow updateDuration', - defaultDimension: '[PC preview] unknow defaultDimension', - supportDimensions: [paramMock.paramNumberMock], - customizeData: {"key": paramMock.paramStringMock}, - } const formProvider = { + setFormNextRefreshTime: function (...args) { + console.warn('formProvider.setFormNextRefreshTime interface mocked in the Previewer. How this interface works on' + + ' the Previewer may be different from that on a real device.'); + const len = args.length; + // callback + if (typeof args[len - 1] === 'function') { + args[len - 1].call(this, paramMock.businessErrorMock); + } else { + return new Promise((resolve) => { + resolve(); + }); + } + }, + updateForm: function (...args) { + console.warn('formProvider.updateForm interface mocked in the Previewer. How this interface works on' + + ' the Previewer may be different from that on a real device.'); + const len = args.length; + // callback + if (typeof args[len - 1] === 'function') { + args[len - 1].call(this, paramMock.businessErrorMock); + } else { + return new Promise((resolve) => { + resolve(); + }); + } + }, getFormsInfo: function (...args) { console.warn('formProvider.getFormsInfo interface mocked in the Previewer. How this interface works on the' + ' Previewer may be different from that on a real device.'); const len = args.length; var array = new Array(); - array.push(FormInfoMock); + array.push(FormInfo); // promise without option. if (len == 0) { return new Promise((resolve) => { diff --git a/runtime/main/extend/systemplugin/napi/ohos_application_testRunner.js b/runtime/main/extend/systemplugin/napi/ohos_application_testRunner.js new file mode 100644 index 00000000..21abc4d6 --- /dev/null +++ b/runtime/main/extend/systemplugin/napi/ohos_application_testRunner.js @@ -0,0 +1,27 @@ +/* + * Copyright (c) 2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +export function mockTestRunner() { + const TestRunner = { + onPrepare: function () { + console.warn('TestRunner.onPrepare interface mocked in the Previewer. How this interface works on the' + + ' Previewer may be different from that on a real device.'); + }, + onRun: function () { + console.warn('TestRunner.onRun interface mocked in the Previewer. How this interface works on the' + + ' Previewer may be different from that on a real device.'); + }, + } + return TestRunner; +} \ No newline at end of file diff --git a/runtime/main/extend/systemplugin/napi/ohos_commonEvent.js b/runtime/main/extend/systemplugin/napi/ohos_commonEvent.js index fe3a0e6f..0c08af9b 100644 --- a/runtime/main/extend/systemplugin/napi/ohos_commonEvent.js +++ b/runtime/main/extend/systemplugin/napi/ohos_commonEvent.js @@ -202,7 +202,9 @@ export const Support = { COMMON_EVENT_ACCOUNT_DELETED: "usual.event.data.ACCOUNT_DELETED", COMMON_EVENT_FOUNDATION_READY: "common.event.FOUNDATION_READY", COMMON_EVENT_AIRPLANE_MODE_CHANGED: "usual.event.AIRPLANE_MODE", - COMMON_EVENT_SPLIT_SCREEN: "common.event.SPLIT_SCREEN" + COMMON_EVENT_SPLIT_SCREEN: "common.event.SPLIT_SCREEN", + COMMON_EVENT_SLOT_CHANGE: "usual.event.SLOT_CHANGE", + COMMON_EVENT_SPN_INFO_CHANGED: "usual.event.SPN_INFO_CHANGED" } export function mockCommonEvent() { const commonEvent = { diff --git a/runtime/main/extend/systemplugin/napi/ohos_wantAgent.js b/runtime/main/extend/systemplugin/napi/ohos_wantAgent.js index 25072ba4..0ec5aa2b 100644 --- a/runtime/main/extend/systemplugin/napi/ohos_wantAgent.js +++ b/runtime/main/extend/systemplugin/napi/ohos_wantAgent.js @@ -14,47 +14,37 @@ */ import { paramMock } from "../utils" +import { WantClass } from "./ohos_application_Want" +export const WantAgentFlags = { + ONE_TIME_FLAG: 0, + NO_BUILD_FLAG: 1, + CANCEL_PRESENT_FLAG: 2, + UPDATE_PRESENT_FLAG: 3, + CONSTANT_FLAG: 4, + REPLACE_ELEMENT: 5, + REPLACE_ACTION: 6, + REPLACE_URI: 7, + REPLACE_ENTITIES: 8, + REPLACE_BUNDLE: 9 +} +export const OperationType = { + UNKNOWN_TYPE: 0, + START_ABILITY: 1, + START_ABILITIES: 2, + START_SERVICE: 3, + SEND_COMMON_EVENT: 4 +} +export const CompleteData = { + info: WantAgent, + want: new WantClass(), + finalCode: '[PC preview] unknow finalCode', + finalData: '[PC preview] unknow finalData', + extraInfo: {}, +} +export const WantAgent = {} export function mockWantAgent() { - const WantMock = { - deviceId: '[PC preview] unknow deviceId', - bundleName: '[PC preview] unknow bundleName', - abilityName: '[PC preview] unknow abilityName', - uri: '[PC preview] unknow uri', - type: '[PC preview] unknow type', - flags: '[PC preview] unknow flags', - action: '[PC preview] unknow action', - parameters: '[PC preview] unknow parameters', - entities: '[PC preview] unknow entities', - } - const CompleteDataMock = { - info: '[PC preview] unknow info', - want: '[PC preview] unknow want', - finalCode: '[PC preview] unknow finalCode', - finalData: '[PC preview] unknow finalData', - extraInfo: '[PC preview] unknow extraInfo', - } - const WantAgentMock = {} const wantAgent = { - OperationType: { - UNKNOWN_TYPE: 0, - START_ABILITY: 1, - START_ABILITIES: 2, - START_SERVICE: 3, - SEND_COMMON_EVENT: 4 - }, - WantAgentFlags: { - ONE_TIME_FLAG: 0, - NO_BUILD_FLAG: 1, - CANCEL_PRESENT_FLAG: 2, - UPDATE_PRESENT_FLAG: 3, - CONSTANT_FLAG: 4, - REPLACE_ELEMENT: 5, - REPLACE_ACTION: 6, - REPLACE_URI: 7, - REPLACE_ENTITIES: 8, - REPLACE_BUNDLE: 9 - }, getBundleName: function (...args) { console.warn("wantAgent.getBundleName interface mocked in the Previewer. How this interface works on the" + " Previewer may be different from that on a real device."); @@ -84,10 +74,10 @@ export function mockWantAgent() { " Previewer may be different from that on a real device."); const len = args.length; if (typeof args[len - 1] === 'function') { - args[len - 1].call(this, paramMock.businessErrorMock, WantMock); + args[len - 1].call(this, paramMock.businessErrorMock, new WantClass()); } else { return new Promise((resolve) => { - resolve(WantMock); + resolve(new WantClass()); }); } }, @@ -108,7 +98,7 @@ export function mockWantAgent() { " Previewer may be different from that on a real device."); const len = args.length; if (typeof args[len - 1] === 'function') { - args[len - 1].call(this, paramMock.businessErrorMock, CompleteDataMock); + args[len - 1].call(this, paramMock.businessErrorMock, CompleteData); } }, equal: function (...args) { @@ -128,10 +118,22 @@ export function mockWantAgent() { " Previewer may be different from that on a real device."); const len = args.length; if (typeof args[len - 1] === 'function') { - args[len - 1].call(this, paramMock.businessErrorMock, WantAgentMock); + args[len - 1].call(this, paramMock.businessErrorMock, WantAgent); } else { return new Promise((resolve) => { - resolve(WantAgentMock); + resolve(WantAgent); + }); + } + }, + getOperationType: function (...args) { + console.warn("wantAgent.getOperationType interface mocked in the Previewer. How this interface works on the" + + " Previewer may be different from that on a real device."); + const len = args.length; + if (typeof args[len - 1] === 'function') { + args[len - 1].call(this, paramMock.businessErrorMock, paramMock.paramNumberMock); + } else { + return new Promise((resolve) => { + resolve(paramMock.paramNumberMock); }); } }, From 81d0bdbb70099b8960aa9354af691a5edf585232 Mon Sep 17 00:00:00 2001 From: wangkai Date: Fri, 15 Jul 2022 16:44:41 +0800 Subject: [PATCH 077/109] api mock Signed-off-by: wangkai --- .../main/extend/systemplugin/napi/ohos_data_distributedData.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/runtime/main/extend/systemplugin/napi/ohos_data_distributedData.js b/runtime/main/extend/systemplugin/napi/ohos_data_distributedData.js index 8480ae59..17c6cd9f 100644 --- a/runtime/main/extend/systemplugin/napi/ohos_data_distributedData.js +++ b/runtime/main/extend/systemplugin/napi/ohos_data_distributedData.js @@ -315,7 +315,7 @@ export function mockDistributedData() { autoSync: "[PC Preview] unknown autoSync", kvStoreType: "[PC Preview] unknown kvStoreType", securityLevel: "[PC Preview] unknown securityLevel", - schema : "[PC Preview] unknown schema" + schema: "[PC Preview] unknown schema" }; const KVStoreClass = class KVStore { From cbaf71cc7ce2f29dd7ff4882dd89909c25c0d9e8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=80=BF=E6=96=87=E5=B9=BF?= Date: Thu, 14 Jul 2022 11:39:55 +0800 Subject: [PATCH 078/109] =?UTF-8?q?api-mock=E8=A1=A5=E9=BD=90?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 耿文广 --- .../{permissionDef.js => PermissionDef.js} | 0 .../systemplugin/napi/bundle/abilityInfo.js | 113 +-- .../napi/bundle/applicationInfo.js | 79 +- .../systemplugin/napi/bundle/bundleInfo.js | 701 +----------------- .../napi/bundle/bundleInstaller.js | 8 +- .../napi/bundle/extensionAbilityInfo.js | 75 +- .../systemplugin/napi/bundle/hapModuleInfo.js | 71 +- .../napi/bundle/launcherAbilityInfo.js | 69 +- .../systemplugin/napi/bundle/packInfo.js | 200 ++--- .../systemplugin/napi/bundle/shortcutInfo.js | 7 +- .../extend/systemplugin/napi/ohos_bundle.js | 114 ++- .../napi/ohos_bundle_defaultAppManager.js | 11 + .../napi/ohos_bundle_innerBundleManager.js | 2 +- .../extend/systemplugin/napi/ohos_zlib.js | 8 +- 14 files changed, 263 insertions(+), 1195 deletions(-) rename runtime/main/extend/systemplugin/napi/bundle/{permissionDef.js => PermissionDef.js} (100%) diff --git a/runtime/main/extend/systemplugin/napi/bundle/permissionDef.js b/runtime/main/extend/systemplugin/napi/bundle/PermissionDef.js similarity index 100% rename from runtime/main/extend/systemplugin/napi/bundle/permissionDef.js rename to runtime/main/extend/systemplugin/napi/bundle/PermissionDef.js diff --git a/runtime/main/extend/systemplugin/napi/bundle/abilityInfo.js b/runtime/main/extend/systemplugin/napi/bundle/abilityInfo.js index 9bc0920f..3bcd1e31 100644 --- a/runtime/main/extend/systemplugin/napi/bundle/abilityInfo.js +++ b/runtime/main/extend/systemplugin/napi/bundle/abilityInfo.js @@ -14,6 +14,11 @@ */ import { paramMock } from "../../utils" +import { AbilityType, AbilitySubType, DisplayOrientation, LaunchMode, SupportWindowMode } from "./../ohos_bundle" +import { ApplicationInfo } from "./applicationInfo" +import { CustomizeData } from "./customizeData" +import { Metadata } from "./metadata" + export const AbilityInfo = { name: "[PC preview] unknown name", @@ -24,35 +29,10 @@ export const AbilityInfo = { backgroundModes: "[PC preview] unknown backgroundModes", isVisible: "[PC preview] unknown isVisible", formEnabled: "[PC preview] unknown formEnabled", - type: { - UNKNOWN: 0, - PAGE: 2, - SERVICE: 3, - DATA: 4, - }, - subType: { - UNSPECIFIED: 0, - CA: 1, - }, - orientation: { - UNSPECIFIED: 0, - LANDSCAPE: 2, - PORTRAIT: 1, - FOLLOW_RECENT: 2, - LANDSCAPE_INVERTED: 4, - PORTRAIT_INVERTED: 3, - AUTO_ROTATION: 5, - AUTO_ROTATION_LANDSCAPE: 7, - AUTO_ROTATION_PORTRAIT: 6, - AUTO_ROTATION_RESTRICTED: 8, - AUTO_ROTATION_LANDSCAPE_RESTRICTED: 10, - AUTO_ROTATION_PORTRAIT_RESTRICTED: 9, - LOCKED: 11, - }, - launchMode: { - SINGLETON: 0, - STANDARD: 1, - }, + type: AbilityType, + subType: AbilitySubType, + orientation: DisplayOrientation, + launchMode: LaunchMode, permissions: [paramMock.paramStringMock], deviceTypes: [paramMock.paramStringMock], deviceCapabilities: [paramMock.paramNumberMock], @@ -65,76 +45,12 @@ export const AbilityInfo = { installTime: '[PC Preview] unknow installTime', updateTime: '[PC Preview] unknow updateTime', descriptionId: '[PC Preview] unknow descriptionId', - applicationInfo: { - packageName: "[PC preview] unknown packageName", - description: "[PC preview] unknown description", - descriptionId: "[PC preview] unknown descriptionId", - enabled: "[PC preview] unknown enabled", - systemApp: "[PC preview] unknown systemApp", - className: "[PC preview] unknown className", - name: "[PC preview] unknown name", - label: "[PC preview] unknown label", - labelId: "[PC preview] unknown labelId", - icon: "[PC preview] unknown icon", - iconId: "[PC preview] unknown iconId", - process: "[PC preview] unknown process", - sourceDir: "[PC preview] unknown sourceDir", - moduleSourceDirs: [paramMock.paramStringMock], - permissions: [paramMock.paramStringMock], - moduleInfos: [{ - moduleName: "[PC preview] unknown moduleName", - moduleSourceDir: "[PC preview] unknown moduleSourceDir", - }], - entryDir: "[PC preview] unknown entryDir", - codePath: "[PC preview] unknown codePath", - metaData: [{ - name: "[PC preview] unknown name", - value: "[PC preview] unknown value", - extra: "[PC preview] unknown extra", - }], - metadata: [{ - name: "[PC preview] unknown name", - value: "[PC preview] unknown value", - resource: "[PC preview] unknown resource", - }], - removable: "[PC preview] unknown removable", - accessTokenId: "[PC preview] unknown accessTokenId", - uid: "[PC preview] unknown uid", - entityType: "[PC preview] unknown entityType", - fingerprint: "[PC preview] unknown fingerprint", - iconResource: "[PC preview] unknown iconResource", - labelResource: "[PC preview] unknown labelResource", - descriptionResource: "[PC preview] unknown descriptionResource", - appDistributionType: "[PC preview] unknown appDistributionType", - appProvisionType: "[PC preview] unknown appProvisionType", - supportedModes: "[PC preview] unknown supportedModes", - flags: "[PC preview] unknown flags", - customizeData: { - key: "[PC preview] unknown key", - value: { - CustomizeData: { - name: "[PC preview] unknown name", - value: "[PC preview] unknown value", - } - } - } - }, - metaData: [{ - name: "[PC preview] unknown name", - value: "[PC preview] unknown value", - extra: "[PC preview] unknown extra", - }], - metadata: [{ - name: "[PC preview] unknown name", - value: "[PC preview] unknown value", - resource: "[PC preview] unknown resource", - }], + applicationInfo: ApplicationInfo, + metaData: [CustomizeData], + uri: "[PC preview] unknown uri", + metadata: [Metadata], enabled: "[PC preview] unknown enabled", - supportWindowMode: [{ - FULL_SCREEN: 0, - SPLIT: 1, - FLOATING: 2, - }], + supportWindowMode: [SupportWindowMode], maxWindowRatio: "[PC preview] unknown maxWindowRatio", minWindowRatio: "[PC preview] unknown minWindowRatio", maxWindowWidth: "[PC preview] unknown maxWindowWidth", @@ -146,5 +62,4 @@ export const AbilityInfo = { defaultFormHeight: "[PC preview] unknown defaultFormHeight", minFormWidth: "[PC preview] unknown minFormWidth", defaultFormWidth: "[PC preview] unknown defaultFormWidth", - uri: "[PC preview] unknown uri", } \ No newline at end of file diff --git a/runtime/main/extend/systemplugin/napi/bundle/applicationInfo.js b/runtime/main/extend/systemplugin/napi/bundle/applicationInfo.js index 953227c3..a2b65f88 100644 --- a/runtime/main/extend/systemplugin/napi/bundle/applicationInfo.js +++ b/runtime/main/extend/systemplugin/napi/bundle/applicationInfo.js @@ -14,6 +14,10 @@ */ import { paramMock } from "../../utils" +import { ModuleInfo } from './moduleInfo'; +import { CustomizeData } from './customizeData'; +import { Metadata } from './metadata'; +import { Resource } from './../global/resource'; export const ApplicationInfo = { name: "[PC preview] unknown name", @@ -29,44 +33,19 @@ export const ApplicationInfo = { supportedModes: "[PC preview] unknown supportedModes", moduleSourceDirs: [paramMock.paramNumberMock], permissions: [paramMock.paramNumberMock], - moduleInfos: [ - { - moduleName: "[PC preview] unknown moduleName", - moduleSourceDir: "[PC preview] unknown moduleSourceDir", - } - ], + moduleInfos: [ModuleInfo], entryDir: "[PC preview] unknown entryDir", codePath: "[PC preview] unknown codePath", - metaData: [{ - name: "[PC preview] unknown name", - value: "[PC preview] unknown value", - extra: "[PC preview] unknown extra", - }], - metadata: [{ - name: "[PC preview] unknown name", - value: "[PC preview] unknown value", - resource: "[PC preview] unknown resource", - }], + metaData: [CustomizeData], + metadata: [Metadata], removable: "[PC preview] unknown removable", accessTokenId: "[PC preview] unknown accessTokenId", uid: "[PC preview] unknown uid", entityType: "[PC preview] unknown entityType", fingerprint: "[PC preview] unknown fingerprint", - iconResource: { - bundleName: "[PC preview] unknown bundleName", - moduleName: "[PC preview] unknown moduleName", - id: "[PC preview] unknown id" - }, - labelResource: { - bundleName: "[PC preview] unknown bundleName", - moduleName: "[PC preview] unknown moduleName", - id: "[PC preview] unknown id" - }, - descriptionResource: { - bundleName: "[PC preview] unknown bundleName", - moduleName: "[PC preview] unknown moduleName", - id: "[PC preview] unknown id" - }, + iconResource: Resource, + labelResource: Resource, + descriptionResource: Resource, appDistributionType: "[PC preview] unknown appDistributionType", appProvisionType: "[PC preview] unknown appProvisionType", } @@ -82,42 +61,4 @@ export const Want = { parameters: [paramMock.paramStringMock], entities: [paramMock.paramStringMock], moduleName: "[PC Preview] unknow moduleName", -} - -export const ShortcutInfo = { - id: "[PC preview] unknown id", - bundleName: "[PC preview] unknown bundleName", - hostAbility: "[PC preview] unknown hostAbility", - icon: "[PC preview] unknown icon", - iconId: "[PC preview] unknown iconId", - label: "[PC preview] unknown label", - labelId: "[PC preview] unknown labelId", - disableMessage: "[PC preview] unknown disableMessage", - wants: [ - { - targetBundle: "[PC preview] unknown targetBundle", - targetModule: "[PC preview] unknown targetModule", - targetClass: "[PC preview] unknown targetClass", - } - ], - isStatic: "[PC preview] unknown isStatic", - isHomeShortcut: "[PC preview] unknown isHomeShortcut", - isEnabled: "[PC preview] unknown isEnabled", - moduleName: "[PC preview] unknown moduleName", -} - -export const ModuleUsageRecord = { - bundleName: "[PC preview] unknown bundleName", - appLabelId: "[PC preview] unknown appLabelId", - name: "[PC preview] unknown name", - labelId: "[PC preview] unknown labelId", - descriptionId: "[PC preview] unknown descriptionId", - abilityName: "[PC preview] unknown abilityName", - abilityLabelId: "[PC preview] unknown abilityLabelId", - abilityDescriptionId: "[PC preview] unknown abilityDescriptionId", - abilityIconId: "[PC preview] unknown abilityIconId", - launchedCount: "[PC preview] unknown launchedCount", - lastLaunchTime: "[PC preview] unknown lastLaunchTime", - isRemoved: "[PC preview] unknown isRemoved", - installationFreeSupported: "[PC preview] unknown installationFreeSupported", } \ No newline at end of file diff --git a/runtime/main/extend/systemplugin/napi/bundle/bundleInfo.js b/runtime/main/extend/systemplugin/napi/bundle/bundleInfo.js index 97112a5c..c55193b6 100644 --- a/runtime/main/extend/systemplugin/napi/bundle/bundleInfo.js +++ b/runtime/main/extend/systemplugin/napi/bundle/bundleInfo.js @@ -14,6 +14,22 @@ */ import { paramMock } from "../../utils" +import { AbilityInfo } from './abilityInfo'; +import { ApplicationInfo } from './applicationInfo'; +import { ExtensionAbilityInfo } from './extensionAbilityInfo'; +import { HapModuleInfo } from './hapModuleInfo'; + +export const UsedScene = { + abilities: [paramMock.paramStringMock], + when: "[PC preview] unknown when", +} + +export const ReqPermissionDetail = { + name: "[PC preview] unknown name", + reason: "[PC preview] unknown reason", + reasonId: "[PC preview] unknown reasonId", + usedScene: UsedScene, +} export const BundleInfo = { name: "[PC preview] unknown name", @@ -22,689 +38,24 @@ export const BundleInfo = { uid: "[PC preview] unknown uid", installTime: "[PC preview] unknown installTime", updateTime: "[PC preview] unknown updateTime", - appInfo: { - packageName: "[PC preview] unknown packageName", - description: "[PC preview] unknown description", - descriptionId: "[PC preview] unknown descriptionId", - systemApp: "[PC preview] unknown systemApp", - enabled: "[PC preview] unknown enabled", - className: "[PC preview] unknown className", - name: "[PC preview] unknown name", - labelId: "[PC preview] unknown labelId", - label: "[PC preview] unknown label", - icon: "[PC preview] unknown icon", - iconId: "[PC preview] unknown iconId", - process: "[PC preview] unknown process", - supportedModes: "[PC preview] unknown supportedModes", - moduleSourceDirs: [paramMock.paramStringMock], - permissions: [paramMock.paramStringMock], - sourceDir: "[PC preview] unknown sourceDir", - moduleInfos: [{ - moduleName: "[PC preview] unknown moduleName", - moduleSourceDir: "[PC preview] unknown moduleSourceDir", - }], - flags: "[PC preview] unknown flags", - entryDir: "[PC preview] unknown entryDir", - codePath: "[PC preview] unknown codePath", - metaData: [{ - name: "[PC preview] unknown name", - value: "[PC preview] unknown value", - extra: "[PC preview] unknown extra", - }], - metadata: [{ - name: "[PC preview] unknown name", - value: "[PC preview] unknown value", - resource: "[PC preview] unknown resource", - }], - removable: "[PC preview] unknown removable", - accessTokenId: "[PC preview] unknown accessTokenId", - uid: "[PC preview] unknown uid", - entityType: "[PC preview] unknown entityType", - fingerprint: "[PC preview] unknown fingerprint", - iconResource: { - bundleName: "[PC preview] unknown bundleName", - moduleName: "[PC preview] unknown moduleName", - id: "[PC preview] unknown id", - }, - labelResource: { - bundleName: "[PC preview] unknown bundleName", - moduleName: "[PC preview] unknown moduleName", - id: "[PC preview] unknown id", - }, - descriptionResource: { - bundleName: "[PC preview] unknown bundleName", - moduleName: "[PC preview] unknown moduleName", - id: "[PC preview] unknown id", - }, - appDistributionType: "[PC preview] unknown appDistributionType", - appProvisionType: "[PC preview] unknown appProvisionType", - customizeData: { - key: "[PC preview] unknown key", - value: { - CustomizeData: { - name: "[PC preview] unknown name", - value: "[PC preview] unknown value", - } - } - } - }, - abilityInfo: [ - { - name: "[PC preview] unknown name", - bundleName: "[PC preview] unknown bundleName", - moduleName: "[PC preview] unknown moduleName", - process: "[PC preview] unknown process", - targetAbility: "[PC preview] unknown targetAbility", - backgroundModes: "[PC preview] unknown backgroundModes", - isVisible: "[PC preview] unknown isVisible", - formEnabled: "[PC preview] unknown formEnabled", - type: { - UNKNOWN: 0, - PAGE: 2, - SERVICE: 3, - DATA: 4, - }, - subType: { - UNSPECIFIED: 0, - CA: 1, - }, - orientation: { - UNSPECIFIED: 0, - LANDSCAPE: 2, - PORTRAIT: 1, - FOLLOW_RECENT: 2, - LANDSCAPE_INVERTED: 4, - PORTRAIT_INVERTED: 3, - AUTO_ROTATION: 5, - AUTO_ROTATION_LANDSCAPE: 7, - AUTO_ROTATION_PORTRAIT: 6, - AUTO_ROTATION_RESTRICTED: 8, - AUTO_ROTATION_LANDSCAPE_RESTRICTED: 10, - AUTO_ROTATION_PORTRAIT_RESTRICTED: 9, - LOCKED: 11, - }, - launchMode: { - SINGLETON: 0, - STANDARD: 1, - }, - permissions: [paramMock.paramStringMock], - deviceTypes: [paramMock.paramStringMock], - deviceCapabilities: [paramMock.paramStringMock], - readPermission: '[PC Preview] unknow readPermission', - writePermission: '[PC Preview] unknow writePermission', - appId: '[PC Preview] unknow appId', - label: "[PC preview] unknown label", - description: "[PC preview] unknown description", - uid: '[PC Preview] unknow uid', - installTime: '[PC Preview] unknow installTime', - updateTime: '[PC Preview] unknow updateTime', - descriptionId: '[PC Preview] unknow descriptionId', - applicationInfo: { - packageName: "[PC preview] unknown packageName", - description: "[PC preview] unknown description", - descriptionId: "[PC preview] unknown descriptionId", - enabled: "[PC preview] unknown enabled", - systemApp: "[PC preview] unknown systemApp", - className: "[PC preview] unknown className", - name: "[PC preview] unknown name", - label: "[PC preview] unknown label", - labelId: "[PC preview] unknown labelId", - icon: "[PC preview] unknown icon", - iconId: "[PC preview] unknown iconId", - process: "[PC preview] unknown process", - sourceDir: "[PC preview] unknown sourceDir", - moduleSourceDirs: [paramMock.paramStringMock], - permissions: [paramMock.paramStringMock], - moduleInfos: [{ - moduleName: "[PC preview] unknown moduleName", - moduleSourceDir: "[PC preview] unknown moduleSourceDir", - }], - entryDir: [paramMock.paramStringMock], - codePath: [paramMock.paramStringMock], - metaData: [{ - name: "[PC preview] unknown name", - value: "[PC preview] unknown value", - extra: "[PC preview] unknown extra", - }], - metadata: [{ - name: "[PC preview] unknown name", - value: "[PC preview] unknown value", - resource: "[PC preview] unknown resource", - }], - removable: "[PC preview] unknown removable", - accessTokenId: "[PC preview] unknown accessTokenId", - uid: "[PC preview] unknown uid", - entityType: "[PC preview] unknown entityType", - fingerprint: "[PC preview] unknown fingerprint", - iconResource: "[PC preview] unknown iconResource", - labelResource: "[PC preview] unknown labelResource", - descriptionResource: "[PC preview] unknown descriptionResource", - appDistributionType: "[PC preview] unknown appDistributionType", - appProvisionType: "[PC preview] unknown appProvisionType", - supportedModes: "[PC preview] unknown supportedModes", - flags: "[PC preview] unknown flags", - customizeData: { - key: "[PC preview] unknown key", - value: { - CustomizeData: { - name: "[PC preview] unknown name", - value: "[PC preview] unknown value", - } - } - } - }, - metaData: [{ - name: "[PC preview] unknown name", - value: "[PC preview] unknown value", - extra: "[PC preview] unknown extra", - }], - metadata: [{ - name: "[PC preview] unknown name", - value: "[PC preview] unknown value", - resource: "[PC preview] unknown resource", - }], - enabled: "[PC preview] unknown enabled", - supportWindowMode: [{ - FULL_SCREEN: 0, - SPLIT: 1, - FLOATING: 2, - }], - maxWindowRatio: "[PC preview] unknown maxWindowRatio", - minWindowRatio: "[PC preview] unknown minWindowRatio", - maxWindowWidth: "[PC preview] unknown maxWindowWidth", - minWindowWidth: "[PC preview] unknown minWindowWidth", - maxWindowHeight: "[PC preview] unknown maxWindowHeight", - minWindowHeight: "[PC preview] unknown minWindowHeight", - formEntity: "[PC preview] unknown formEntity", - minFormHeight: "[PC preview] unknown minFormHeight", - defaultFormHeight: "[PC preview] unknown defaultFormHeight", - minFormWidth: "[PC preview] unknown minFormWidth", - defaultFormWidth: "[PC preview] unknown defaultFormWidth", - uri: "[PC preview] unknown uri", - customizeData: { - key: "[PC preview] unknown key", - value: [ - { - CustomizeData: { - name: "[PC preview] unknown name", - value: "[PC preview] unknown value", - }, - }, - { - CustomizeData: { - name: "[PC preview] unknown name", - value: "[PC preview] unknown value", - }, - } - ] - }, - } - ], + appInfo: ApplicationInfo, + abilityInfo: [AbilityInfo], reqPermissions: [paramMock.paramStringMock], - reqPermissionDetails: [ - { - name: "[PC preview] unknown name", - reason: "[PC preview] unknown reason", - reasonId: "[PC preview] unknown reasonId", - usedScene: { - abilities: [paramMock.paramStringMock], - when: "[PC preview] unknown when", - } - } - ], + reqPermissionDetails: [ReqPermissionDetail], vendor: "[PC preview] unknown vendor", versionCode: "[PC preview] unknown versionCode", versionName: "[PC preview] unknown versionName", compatibleVersion: "[PC preview] unknown compatibleVersion", targetVersion: "[PC preview] unknown targetVersion", isCompressNativeLibs: "[PC preview] unknown isCompressNativeLibs", - hapModuleInfos: [{ - name: "[PC preview] unknown name", - description: "[PC preview] unknown description", - descriptionId: "[PC preview] unknown descriptionId", - icon: "[PC preview] unknown icon", - label: "[PC preview] unknown label", - labelId: "[PC preview] unknown labelId", - iconId: "[PC preview] unknown iconId", - backgroundImg: "[PC preview] unknown backgroundImg", - supportedModes: "[PC preview] unknown supportedModes", - reqCapabilities: [paramMock.paramStringMock], - deviceTypes: [paramMock.paramStringMock], - abilityInfo: [ - { - name: "[PC preview] unknown name", - bundleName: "[PC preview] unknown bundleName", - moduleName: "[PC preview] unknown moduleName", - process: "[PC preview] unknown process", - targetAbility: "[PC preview] unknown targetAbility", - backgroundModes: "[PC preview] unknown backgroundModes", - isVisible: "[PC preview] unknown isVisible", - formEnabled: "[PC preview] unknown formEnabled", - type: { - UNKNOWN: 0, - PAGE: 2, - SERVICE: 3, - DATA: 4, - }, - subType: { - UNSPECIFIED: 0, - CA: 1, - }, - orientation: { - UNSPECIFIED: 0, - LANDSCAPE: 2, - PORTRAIT: 1, - FOLLOW_RECENT: 2, - LANDSCAPE_INVERTED: 4, - PORTRAIT_INVERTED: 3, - AUTO_ROTATION: 5, - AUTO_ROTATION_LANDSCAPE: 7, - AUTO_ROTATION_PORTRAIT: 6, - AUTO_ROTATION_RESTRICTED: 8, - AUTO_ROTATION_LANDSCAPE_RESTRICTED: 10, - AUTO_ROTATION_PORTRAIT_RESTRICTED: 9, - LOCKED: 11, - }, - launchMode: { - SINGLETON: 0, - STANDARD: 1, - }, - permissions: [paramMock.paramNumberMock], - deviceTypes: [paramMock.paramNumberMock], - deviceCapabilities: [paramMock.paramNumberMock], - readPermission: '[PC Preview] unknow readPermission', - writePermission: '[PC Preview] unknow writePermission', - appId: '[PC Preview] unknow appId', - label: "[PC preview] unknown label", - description: "[PC preview] unknown description", - uid: '[PC Preview] unknow uid', - installTime: '[PC Preview] unknow installTime', - updateTime: '[PC Preview] unknow updateTime', - descriptionId: '[PC Preview] unknow descriptionId', - applicationInfo: { - packageName: "[PC preview] unknown packageName", - description: "[PC preview] unknown description", - descriptionId: "[PC preview] unknown descriptionId", - enabled: "[PC preview] unknown enabled", - systemApp: "[PC preview] unknown systemApp", - className: "[PC preview] unknown className", - name: "[PC preview] unknown name", - label: "[PC preview] unknown label", - labelId: "[PC preview] unknown labelId", - icon: "[PC preview] unknown icon", - iconId: "[PC preview] unknown iconId", - process: "[PC preview] unknown process", - sourceDir: "[PC preview] unknown sourceDir", - moduleSourceDirs: [paramMock.paramStringMock], - permissions: [paramMock.paramStringMock], - moduleInfos: [{ - moduleName: "[PC preview] unknown moduleName", - moduleSourceDir: "[PC preview] unknown moduleSourceDir", - }], - entryDir: [paramMock.paramStringMock], - codePath: [paramMock.paramStringMock], - metaData: [{ - name: "[PC preview] unknown name", - value: "[PC preview] unknown value", - extra: "[PC preview] unknown extra", - }], - metadata: [{ - name: "[PC preview] unknown name", - value: "[PC preview] unknown value", - resource: "[PC preview] unknown resource", - }], - removable: "[PC preview] unknown removable", - accessTokenId: "[PC preview] unknown accessTokenId", - uid: "[PC preview] unknown uid", - entityType: "[PC preview] unknown entityType", - fingerprint: "[PC preview] unknown fingerprint", - iconResource: "[PC preview] unknown iconResource", - labelResource: "[PC preview] unknown labelResource", - descriptionResource: "[PC preview] unknown descriptionResource", - appDistributionType: "[PC preview] unknown appDistributionType", - appProvisionType: "[PC preview] unknown appProvisionType", - supportedModes: "[PC preview] unknown supportedModes", - flags: "[PC preview] unknown flags", - customizeData: { - key: "[PC preview] unknown key", - value: { - CustomizeData: { - name: "[PC preview] unknown name", - value: "[PC preview] unknown value", - } - } - } - }, - metaData: [{ - name: "[PC preview] unknown name", - value: "[PC preview] unknown value", - extra: "[PC preview] unknown extra", - }], - metadata: [{ - name: "[PC preview] unknown name", - value: "[PC preview] unknown value", - resource: "[PC preview] unknown resource", - }], - enabled: "[PC preview] unknown enabled", - supportWindowMode: [{ - FULL_SCREEN: 0, - SPLIT: 1, - FLOATING: 2, - }], - maxWindowRatio: "[PC preview] unknown maxWindowRatio", - minWindowRatio: "[PC preview] unknown minWindowRatio", - maxWindowWidth: "[PC preview] unknown maxWindowWidth", - minWindowWidth: "[PC preview] unknown minWindowWidth", - maxWindowHeight: "[PC preview] unknown maxWindowHeight", - minWindowHeight: "[PC preview] unknown minWindowHeight", - formEntity: "[PC preview] unknown formEntity", - minFormHeight: "[PC preview] unknown minFormHeight", - defaultFormHeight: "[PC preview] unknown defaultFormHeight", - minFormWidth: "[PC preview] unknown minFormWidth", - defaultFormWidth: "[PC preview] unknown defaultFormWidth", - uri: "[PC preview] unknown uri", - customizeData: { - key: "[PC preview] unknown key", - value: [ - { - CustomizeData: { - name: "[PC preview] unknown name", - value: "[PC preview] unknown value", - }, - }, - { - CustomizeData: { - name: "[PC preview] unknown name", - value: "[PC preview] unknown value", - }, - } - ] - }, - } - ], - moduleName: "[PC preview] unknown moduleName", - mainAbilityName: "[PC preview] unknown mainAbilityName", - installationFree: "[PC preview] unknown installationFree", - mainElementName: "[PC preview] unknown mainElementName", - extensionAbilityInfo: [ - { - bundleName: "[PC preview] unknown bundleName", - moduleName: "[PC preview] unknown moduleName", - name: "[PC preview] unknown name", - labelId: "[PC preview] unknown labelId", - descriptionId: "[PC preview] unknown descriptionId", - iconId: "[PC preview] unknown iconId", - isVisible: "[PC preview] unknown isVisible", - extensionAbilityType: { - FORM: 0, - WORK_SCHEDULER: 1, - INPUT_METHOD: 2, - SERVICE: 3, - ACCESSIBILITY: 4, - DATA_SHARE: 5, - FILE_SHARE: 6, - STATIC_SUBSCRIBER: 7, - WALLPAPER: 8, - BACKUP: 9, - WINDOW: 10, - ENTERPRISE_ADMIN: 11, - UNSPECIFIED: 20, - }, - metadata: [{ - name: "[PC preview] unknown name", - value: "[PC preview] unknown value", - resource: "[PC preview] unknown resource", - }], - hashValue: "[PC preview] unknown hashValue", - } - ], - metadata: "[PC preview] unknown mainElementName", - hashValue: "[PC preview] unknown hashValue", - }], - hapModuleInfo: [ - { - name: "[PC preview] unknown name", - description: "[PC preview] unknown description", - descriptionId: "[PC preview] unknown descriptionId", - icon: "[PC preview] unknown icon", - label: "[PC preview] unknown label", - labelId: "[PC preview] unknown labelId", - iconId: "[PC preview] unknown iconId", - backgroundImg: "[PC preview] unknown backgroundImg", - supportedModes: "[PC preview] unknown supportedModes", - reqCapabilities: [paramMock.paramStringMock], - deviceTypes: [paramMock.paramStringMock], - abilityInfo: [ - { - bundleName: "[PC preview] unknown bundleName", - name: "[PC preview] unknown name", - label: "[PC preview] unknown label", - description: "[PC preview] unknown description", - icon: "[PC preview] unknown icon", - labelId: "[PC preview] unknown labelId", - descriptionId: "[PC preview] unknown descriptionId", - iconId: "[PC preview] unknown iconId", - moduleName: "[PC preview] unknown moduleName", - process: "[PC preview] unknown process", - targetAbility: "[PC preview] unknown targetAbility", - backgroundModes: "[PC preview] unknown backgroundModes", - isVisible: "[PC preview] unknown isVisible", - formEnabled: "[PC preview] unknown formEnabled", - type: "[PC preview] unknown type", - subType: "[PC preview] unknown subType", - orientation: "[PC preview] unknown orientation", - launchMode: "[PC preview] unknown launchMode", - permissions: [paramMock.paramStringMock], - deviceTypes: [paramMock.paramStringMock], - deviceCapabilities: [paramMock.paramStringMock], - readPermission: "[PC preview] unknown readPermission", - writePermission: "[PC preview] unknown writePermission", - applicationInfo: { - packageName: "[PC preview] unknown packageName", - className: "[PC preview] unknown className", - name: "[PC preview] unknown name", - labelId: "[PC preview] unknown labelId", - iconId: "[PC preview] unknown iconId", - sourceDir: "[PC preview] unknown sourceDir", - flags: "[PC preview] unknown flags", - customizeData: { - key: "[PC preview] unknown key", - value: { - CustomizeData: { - name: "[PC preview] unknown name", - value: "[PC preview] unknown value", - } - } - } - }, - formEntity: "[PC preview] unknown formEntity", - minFormHeight: "[PC preview] unknown minFormHeight", - defaultFormHeight: "[PC preview] unknown defaultFormHeight", - minFormWidth: "[PC preview] unknown minFormWidth", - defaultFormWidth: "[PC preview] unknown defaultFormWidth", - uri: "[PC preview] unknown uri", - customizeData: { - key: "[PC preview] unknown key", - value: [ - { - CustomizeData: { - name: "[PC preview] unknown name", - value: "[PC preview] unknown value", - }, - }, - { - CustomizeData: { - name: "[PC preview] unknown name", - value: "[PC preview] unknown value", - }, - } - ] - }, - } - ], - moduleName: "[PC preview] unknown moduleName", - mainAbilityName: "[PC preview] unknown mainAbilityName", - installationFree: "[PC preview] unknown installationFree", - } - ], - entryModuleName: "string", - cpuAbi: "string", - isSilentInstallation: "string", - minCompatibleVersionCode: 7, - entryInstallationFree: true, + hapModuleInfos: [HapModuleInfo], + entryModuleName: "[PC preview] unknown entryModuleName", + cpuAbi: "[PC preview] unknown cpuAbi", + isSilentInstallation: "[PC preview] unknown isSilentInstallation", + minCompatibleVersionCode: "[PC preview] unknown minCompatibleVersionCode", + entryInstallationFree: "[PC preview] unknown entryInstallationFree", reqPermissionStates: [paramMock.paramStringMock], - extensionAbilityInfo: [{ - bundleName: "[PC preview] unknown bundleName", - moduleName: "[PC preview] unknown moduleName", - name: "[PC preview] unknown name", - labelId: "[PC preview] unknown labelId", - descriptionId: "[PC preview] unknown descriptionId", - iconId: "[PC preview] unknown iconId", - isVisible: "[PC preview] unknown isVisible", - extensionAbilityType: { - FORM: 0, - WORK_SCHEDULER: 1, - INPUT_METHOD: 2, - SERVICE: 3, - ACCESSIBILITY: 4, - DATA_SHARE: 5, - FILE_SHARE: 6, - STATIC_SUBSCRIBER: 7, - WALLPAPER: 8, - BACKUP: 9, - WINDOW: 10, - ENTERPRISE_ADMIN: 11, - UNSPECIFIED: 20, - }, - metadata: [{ - name: "[PC preview] unknown name", - value: "[PC preview] unknown value", - resource: "[PC preview] unknown resource", - }], - permissions: [paramMock.paramStringMock], - applicationInfo: { - packageName: "[PC preview] unknown packageName", - description: "[PC preview] unknown description", - descriptionId: "[PC preview] unknown descriptionId", - enabled: "[PC preview] unknown enabled", - systemApp: "[PC preview] unknown systemApp", - className: "[PC preview] unknown className", - name: "[PC preview] unknown name", - label: "[PC preview] unknown label", - labelId: "[PC preview] unknown labelId", - icon: "[PC preview] unknown icon", - iconId: "[PC preview] unknown iconId", - process: "[PC preview] unknown process", - moduleSourceDirs: [paramMock.paramStringMock], - permissions: [paramMock.paramStringMock], - moduleInfos: [{ - moduleName: "[PC preview] unknown moduleName", - moduleSourceDir: "[PC preview] unknown moduleSourceDir", - }], - entryDir: [paramMock.paramStringMock], - codePath: [paramMock.paramStringMock], - metaData: [{ - name: "[PC preview] unknown name", - value: "[PC preview] unknown value", - extra: "[PC preview] unknown extra", - }], - metadata: [{ - name: "[PC preview] unknown name", - value: "[PC preview] unknown value", - resource: "[PC preview] unknown resource", - }], - removable: "[PC preview] unknown removable", - accessTokenId: "[PC preview] unknown accessTokenId", - uid: "[PC preview] unknown uid", - entityType: "[PC preview] unknown entityType", - fingerprint: "[PC preview] unknown fingerprint", - iconResource: "[PC preview] unknown iconResource", - labelResource: "[PC preview] unknown labelResource", - descriptionResource: "[PC preview] unknown descriptionResource", - appDistributionType: "[PC preview] unknown appDistributionType", - appProvisionType: "[PC preview] unknown appProvisionType", - supportedModes: "[PC preview] unknown supportedModes", - }, - metadata: [{ - name: "[PC preview] unknown name", - value: "[PC preview] unknown value", - resource: "[PC preview] unknown resource", - }], - enabled: "[PC preview] unknown enabled", - readPermission: "[PC preview] unknown readPermission", - writePermission: "[PC preview] unknown writePermission", - }], -}; - -export const BundlePackInfo = { - packages: [{ - deviceType: [paramMock.paramStringMock], - name: "[PC preview] unknown name", - moduleType: "[PC preview] unknown moduleType", - deliveryWithInstall: "[PC preview] unknown deliveryWithInstall", - }], - summary: { - app: { - bundleName: "[PC preview] unknown bundleName", - version: { - minCompatibleVersionCode: "[PC preview] unknown minCompatibleVersionCode", - name: "[PC preview] unknown name", - code: "[PC preview] unknown code", - }, - }, - modules: [ - { - apiVersion: { - releaseType: "[PC preview] unknown releaseType", - compatible: "[PC preview] unknown compatible", - target: "[PC preview] unknown target", - }, - deviceType: [paramMock.paramStringMock], - distro: { - mainAbility: "[PC preview] unknown mainAbility", - deliveryWithInstall: "[PC preview] unknown deliveryWithInstall", - installationFree: "[PC preview] unknown installationFree", - moduleName: "[PC preview] unknown moduleName", - moduleType: "[PC preview] unknown moduleType", - }, - abilities: [ - { - name: "[PC preview] unknown name", - label: "[PC preview] unknown label", - visible: "[PC preview] unknown visible", - forms: [ - { - name: "[PC preview] unknown name", - type: "[PC preview] unknown type", - updateEnabled: "[PC preview] unknown updateEnabled", - scheduledUpdateTime: "[PC preview] unknown scheduledUpdateTime", - updateDuration: "[PC preview] unknown updateDuration", - supportDimensions: [paramMock.paramNumberMock], - defaultDimension: "[PC preview] unknown defaultDimension", - } - ], - - } - ], - extensionAbilities: [ - { - name: "[PC preview] unknown name", - forms: [ - { - name: "[PC preview] unknown name", - type: "[PC preview] unknown type", - updateEnabled: "[PC preview] unknown updateEnabled", - scheduledUpdateTime: "[PC preview] unknown scheduledUpdateTime", - updateDuration: "[PC preview] unknown updateDuration", - supportDimensions: [paramMock.paramNumberMock], - defaultDimension: "[PC preview] unknown defaultDimension", - } - ], - } - ] - } - ] - } + extensionAbilityInfo: [ExtensionAbilityInfo], }; export const PixelMapFormat = { diff --git a/runtime/main/extend/systemplugin/napi/bundle/bundleInstaller.js b/runtime/main/extend/systemplugin/napi/bundle/bundleInstaller.js index c7e5d512..801d5d8e 100755 --- a/runtime/main/extend/systemplugin/napi/bundle/bundleInstaller.js +++ b/runtime/main/extend/systemplugin/napi/bundle/bundleInstaller.js @@ -24,16 +24,12 @@ export const HashParam = { export const InstallParam = { userId: "[PC preview] unknown userId", installFlag: "[PC preview] unknown installFlag", - hashParams: [ - HashParam - ], + hashParams: [HashParam], crowdtestDeadline: "[PC preview] unknown crowdtestDeadline", } export const InstallStatus = { - status: { - InstallErrorCode - }, + status: InstallErrorCode, statusMessage: "[PC preview] unknown statusMessage", } diff --git a/runtime/main/extend/systemplugin/napi/bundle/extensionAbilityInfo.js b/runtime/main/extend/systemplugin/napi/bundle/extensionAbilityInfo.js index ba8738ed..ebbb9f78 100755 --- a/runtime/main/extend/systemplugin/napi/bundle/extensionAbilityInfo.js +++ b/runtime/main/extend/systemplugin/napi/bundle/extensionAbilityInfo.js @@ -14,6 +14,10 @@ */ import { paramMock } from "../../utils" +import { ApplicationInfo } from './applicationInfo'; +import { Metadata } from './metadata' +import { ExtensionAbilityType } from "./../ohos_bundle" + export const ExtensionAbilityInfo = { bundleName: "[PC preview] unknown bundleName", @@ -23,75 +27,10 @@ export const ExtensionAbilityInfo = { descriptionId: "[PC preview] unknown descriptionId", iconId: "[PC preview] unknown iconId", isVisible: "[PC preview] unknown isVisible", - extensionAbilityType: { - FORM: 0, - WORK_SCHEDULER: 1, - INPUT_METHOD: 2, - SERVICE: 3, - ACCESSIBILITY: 4, - DATA_SHARE: 5, - FILE_SHARE: 6, - STATIC_SUBSCRIBER: 7, - WALLPAPER: 8, - BACKUP: 9, - WINDOW: 10, - ENTERPRISE_ADMIN: 11, - UNSPECIFIED: 20, - }, - metadata: [{ - name: "[PC preview] unknown name", - value: "[PC preview] unknown value", - resource: "[PC preview] unknown resource", - }], + extensionAbilityType: ExtensionAbilityType, + metadata: [Metadata], permissions: [paramMock.paramStringMock], - applicationInfo: { - packageName: "[PC preview] unknown packageName", - description: "[PC preview] unknown description", - descriptionId: "[PC preview] unknown descriptionId", - enabled: "[PC preview] unknown enabled", - systemApp: "[PC preview] unknown systemApp", - className: "[PC preview] unknown className", - name: "[PC preview] unknown name", - label: "[PC preview] unknown label", - labelId: "[PC preview] unknown labelId", - icon: "[PC preview] unknown icon", - iconId: "[PC preview] unknown iconId", - process: "[PC preview] unknown process", - moduleSourceDirs: [paramMock.paramStringMock], - permissions: [paramMock.paramStringMock], - moduleInfos: [{ - moduleName: "[PC preview] unknown moduleName", - moduleSourceDir: "[PC preview] unknown moduleSourceDir", - }], - entryDir: "[PC preview] unknown entryDir", - codePath: "[PC preview] unknown codePath", - metaData: [{ - name: "[PC preview] unknown name", - value: "[PC preview] unknown value", - extra: "[PC preview] unknown extra", - }], - metadata: [{ - name: "[PC preview] unknown name", - value: "[PC preview] unknown value", - resource: "[PC preview] unknown resource", - }], - removable: "[PC preview] unknown removable", - accessTokenId: "[PC preview] unknown accessTokenId", - uid: "[PC preview] unknown uid", - entityType: "[PC preview] unknown entityType", - fingerprint: "[PC preview] unknown fingerprint", - iconResource: "[PC preview] unknown iconResource", - labelResource: "[PC preview] unknown labelResource", - descriptionResource: "[PC preview] unknown descriptionResource", - appDistributionType: "[PC preview] unknown appDistributionType", - appProvisionType: "[PC preview] unknown appProvisionType", - supportedModes: "[PC preview] unknown supportedModes", - }, - metadata: [{ - name: "[PC preview] unknown name", - value: "[PC preview] unknown value", - resource: "[PC preview] unknown resource", - }], + applicationInfo: ApplicationInfo, enabled: "[PC preview] unknown enabled", readPermission: "[PC preview] unknown readPermission", writePermission: "[PC preview] unknown writePermission", diff --git a/runtime/main/extend/systemplugin/napi/bundle/hapModuleInfo.js b/runtime/main/extend/systemplugin/napi/bundle/hapModuleInfo.js index f7a699f8..7496aef6 100755 --- a/runtime/main/extend/systemplugin/napi/bundle/hapModuleInfo.js +++ b/runtime/main/extend/systemplugin/napi/bundle/hapModuleInfo.js @@ -14,6 +14,8 @@ */ import { paramMock } from "../../utils" +import { AbilityInfo } from './abilityInfo'; + export const HapModuleInfo = { name: "[PC preview] unknown name", @@ -27,74 +29,7 @@ export const HapModuleInfo = { supportedModes: "[PC preview] unknown supportedModes", reqCapabilities: [paramMock.paramStringMock], deviceTypes: [paramMock.paramStringMock], - abilityInfo: [ - { - bundleName: "[PC preview] unknown bundleName", - name: "[PC preview] unknown name", - label: "[PC preview] unknown label", - description: "[PC preview] unknown description", - icon: "[PC preview] unknown icon", - labelId: "[PC preview] unknown labelId", - descriptionId: "[PC preview] unknown descriptionId", - iconId: "[PC preview] unknown iconId", - moduleName: "[PC preview] unknown moduleName", - process: "[PC preview] unknown process", - targetAbility: "[PC preview] unknown targetAbility", - backgroundModes: "[PC preview] unknown backgroundModes", - isVisible: "[PC preview] unknown isVisible", - formEnabled: "[PC preview] unknown formEnabled", - type: "[PC preview] unknown type", - subType: "[PC preview] unknown subType", - orientation: "[PC preview] unknown orientation", - launchMode: "[PC preview] unknown launchMode", - permissions: [paramMock.paramStringMock], - deviceTypes: [paramMock.paramStringMock], - deviceCapabilities: [paramMock.paramStringMock], - readPermission: "[PC preview] unknown readPermission", - writePermission: "[PC preview] unknown writePermission", - applicationInfo: { - packageName: "[PC preview] unknown packageName", - className: "[PC preview] unknown className", - name: "[PC preview] unknown name", - labelId: "[PC preview] unknown name", - iconId: "[PC preview] unknown name", - sourceDir: "[PC preview] unknown sourceDir", - flags: "[PC preview] unknown name", - customizeData: { - key: "[PC preview] unknown key", - value: { - CustomizeData: { - name: "[PC preview] unknown name", - value: "[PC preview] unknown value", - } - } - } - }, - formEntity: "[PC preview] unknown formEntity", - minFormHeight: "[PC preview] unknown minFormHeight", - defaultFormHeight: "[PC preview] unknown defaultFormHeight", - minFormWidth: "[PC preview] unknown minFormWidth", - defaultFormWidth: "[PC preview] unknown defaultFormWidth", - uri: "[PC preview] unknown uri", - customizeData: { - key: "[PC preview] unknown key", - value: [ - { - CustomizeData: { - name: "[PC preview] unknown name", - value: "[PC preview] unknown value", - }, - }, - { - CustomizeData: { - name: "[PC preview] unknown name", - value: "[PC preview] unknown value", - }, - } - ] - }, - } - ], + abilityInfo: [AbilityInfo], moduleName: "[PC preview] unknown moduleName", mainAbilityName: "[PC preview] unknown mainAbilityName", installationFree: "[PC preview] unknown installationFree", diff --git a/runtime/main/extend/systemplugin/napi/bundle/launcherAbilityInfo.js b/runtime/main/extend/systemplugin/napi/bundle/launcherAbilityInfo.js index 25564dda..54ca8cc3 100644 --- a/runtime/main/extend/systemplugin/napi/bundle/launcherAbilityInfo.js +++ b/runtime/main/extend/systemplugin/napi/bundle/launcherAbilityInfo.js @@ -14,73 +14,12 @@ */ import { paramMock } from "../../utils" +import { ApplicationInfo } from './applicationInfo'; +import { ElementName } from './elementName' export const LauncherAbilityInfo = { - applicationInfo: { - packageName: "[PC preview] unknown packageName", - description: "[PC preview] unknown description", - descriptionId: "[PC preview] unknown descriptionId", - systemApp: "[PC preview] unknown systemApp", - enabled: "[PC preview] unknown enabled", - className: "[PC preview] unknown className", - name: "[PC preview] unknown name", - labelId: "[PC preview] unknown labelId", - label: "[PC preview] unknown label", - icon: "[PC preview] unknown icon", - iconId: "[PC preview] unknown iconId", - process: "[PC preview] unknown process", - supportedModes: "[PC preview] unknown supportedModes", - moduleSourceDirs: [paramMock.paramStringMock], - permissions: [paramMock.paramStringMock], - sourceDir: "[PC preview] unknown sourceDir", - moduleInfos: [{ - moduleName: "[PC preview] unknown moduleName", - moduleSourceDir: "[PC preview] unknown moduleSourceDir", - }], - flags: "[PC preview] unknown flags", - entryDir: "[PC preview] unknown entryDir", - codePath: "[PC preview] unknown codePath", - metaData: [{ - name: "[PC preview] unknown name", - value: "[PC preview] unknown value", - extra: "[PC preview] unknown extra", - }], - metadata: [{ - name: "[PC preview] unknown name", - value: "[PC preview] unknown value", - resource: "[PC preview] unknown resource", - }], - removable: "[PC preview] unknown removable", - accessTokenId: "[PC preview] unknown accessTokenId", - uid: "[PC preview] unknown uid", - entityType: "[PC preview] unknown entityType", - fingerprint: "[PC preview] unknown fingerprint", - iconResource: { - bundleName: "[PC preview] unknown bundleName", - moduleName: "[PC preview] unknown moduleName", - id: "[PC preview] unknown id", - }, - labelResource: { - bundleName: "[PC preview] unknown bundleName", - moduleName: "[PC preview] unknown moduleName", - id: "[PC preview] unknown id", - }, - descriptionResource: { - bundleName: "[PC preview] unknown bundleName", - moduleName: "[PC preview] unknown moduleName", - id: "[PC preview] unknown id", - }, - appDistributionType: "[PC preview] unknown appDistributionType", - appProvisionType: "[PC preview] unknown appProvisionType", - }, - elementName: { - deviceId: "[PC preview] unknown deviceId", - bundleName: "[PC preview] unknown bundleName", - abilityName: "[PC preview] unknown abilityName", - uri: "[PC preview] unknown uri", - shortName: "[PC preview] unknown shortName", - moduleName: "[PC preview] unknown moduleName", - }, + applicationInfo: {ApplicationInfo}, + elementName: {ElementName}, labelId: "[PC preview] unknown labelId", iconId: "[PC preview] unknown iconId", userId: "[PC preview] unknown userId", diff --git a/runtime/main/extend/systemplugin/napi/bundle/packInfo.js b/runtime/main/extend/systemplugin/napi/bundle/packInfo.js index aca7df89..8a7bfebf 100755 --- a/runtime/main/extend/systemplugin/napi/bundle/packInfo.js +++ b/runtime/main/extend/systemplugin/napi/bundle/packInfo.js @@ -15,77 +15,6 @@ import { paramMock } from "../../utils" -export const BundlePackInfo = { - packages: [{ - deviceType: [paramMock.paramStringMock], - name: "[PC preview] unknown name", - moduleType: "[PC preview] unknown moduleType", - deliveryWithInstall: "[PC preview] unknown deliveryWithInstall", - }], - summary: { - app: { - bundleName: "[PC preview] unknown bundleName", - version: { - minCompatibleVersionCode: "[PC preview] unknown minCompatibleVersionCode", - name: "[PC preview] unknown name", - code: "[PC preview] unknown code", - }, - }, - modules: [ - { - apiVersion: { - releaseType: "[PC preview] unknown releaseType", - compatible: "[PC preview] unknown compatible", - target: "[PC preview] unknown target", - }, - deviceType: [paramMock.paramStringMock], - distro: { - mainAbility: "[PC preview] unknown mainAbility", - deliveryWithInstall: "[PC preview] unknown deliveryWithInstall", - installationFree: "[PC preview] unknown installationFree", - moduleName: "[PC preview] unknown moduleName", - moduleType: "[PC preview] unknown moduleType", - }, - abilities: [ - { - name: "[PC preview] unknown name", - label: "[PC preview] unknown label", - visible: "[PC preview] unknown visible", - forms: [ - { - name: "[PC preview] unknown name", - type: "[PC preview] unknown type", - updateEnabled: "[PC preview] unknown updateEnabled", - scheduledUpdateTime: "[PC preview] unknown scheduledUpdateTime", - updateDuration: "[PC preview] unknown updateDuration", - supportDimensions: [paramMock.paramNumberMock], - defaultDimension: "[PC preview] unknown defaultDimension", - } - ], - - } - ], - extensionAbilities: [ - { - name: "[PC preview] unknown name", - forms: [ - { - name: "[PC preview] unknown name", - type: "[PC preview] unknown type", - updateEnabled: "[PC preview] unknown updateEnabled", - scheduledUpdateTime: "[PC preview] unknown scheduledUpdateTime", - updateDuration: "[PC preview] unknown updateDuration", - supportDimensions: [paramMock.paramNumberMock], - defaultDimension: "[PC preview] unknown defaultDimension", - } - ], - } - ] - } - ] - } -} - export const PackageConfig = { deviceType: [paramMock.paramStringMock], name: "[PC preview] unknown name", @@ -93,65 +22,74 @@ export const PackageConfig = { deliveryWithInstall: "[PC preview] unknown deliveryWithInstall", } -export const PackageSummary = { - app: { - bundleName: "[PC preview] unknown bundleName", - version: { - minCompatibleVersionCode: "[PC preview] unknown minCompatibleVersionCode", - name: "[PC preview] unknown name", - code: "[PC preview] unknown code", - }, - }, - modules: [ - { - apiVersion: { - releaseType: "[PC preview] unknown releaseType", - compatible: "[PC preview] unknown compatible", - target: "[PC preview] unknown target", - }, - deviceType: [paramMock.paramStringMock], - distro: { - mainAbility: "[PC preview] unknown mainAbility", - deliveryWithInstall: "[PC preview] unknown deliveryWithInstall", - installationFree: "[PC preview] unknown installationFree", - moduleName: "[PC preview] unknown moduleName", - moduleType: "[PC preview] unknown moduleType", - }, - abilities: [ - { - name: "[PC preview] unknown name", - label: "[PC preview] unknown label", - visible: "[PC preview] unknown visible", - forms: [ - { - name: "[PC preview] unknown name", - type: "[PC preview] unknown type", - updateEnabled: "[PC preview] unknown updateEnabled", - scheduledUpdateTime: "[PC preview] unknown scheduledUpdateTime", - updateDuration: "[PC preview] unknown updateDuration", - supportDimensions: [paramMock.paramNumberMock], - defaultDimension: "[PC preview] unknown defaultDimension", - } - ], +export const ModuleDistroInfo = { + mainAbility: "[PC preview] unknown mainAbility", + deliveryWithInstall: "[PC preview] unknown deliveryWithInstall", + installationFree: "[PC preview] unknown installationFree", + moduleName: "[PC preview] unknown moduleName", + moduleType: "[PC preview] unknown moduleType", +} - } - ], - extensionAbilities: [ - { - name: "[PC preview] unknown name", - forms: [ - { - name: "[PC preview] unknown name", - type: "[PC preview] unknown type", - updateEnabled: "[PC preview] unknown updateEnabled", - scheduledUpdateTime: "[PC preview] unknown scheduledUpdateTime", - updateDuration: "[PC preview] unknown updateDuration", - supportDimensions: [paramMock.paramNumberMock], - defaultDimension: "[PC preview] unknown defaultDimension", - } - ], - } - ] - } - ] +export const AbilityFormInfo = { + name: "[PC preview] unknown name", + type: "[PC preview] unknown type", + updateEnabledtype: "[PC preview] unknown updateEnabled", + scheduledUpdateTime: "[PC preview] unknown scheduledUpdateTime", + updateDuration: "[PC preview] unknown updateDuration", + supportDimensions: [paramMock.paramNumberMock], + defaultDimension: "[PC preview] unknown defaultDimension", +} + +export const ApiVersion = { + releaseType: "[PC preview] unknown releaseType", + compatible: "[PC preview] unknown compatible", + target: "[PC preview] unknown target", +} + +export const Version = { + minCompatibleVersionCode: "[PC preview] unknown minCompatibleVersionCode", + name: "[PC preview] unknown name", + code: "[PC preview] unknown code", +} + +export const ModuleAbilityInfo = { + name: "[PC preview] unknown name", + label: "[PC preview] unknown label", + visible: "[PC preview] unknown visible", + forms: [AbilityFormInfo], +} + +export const ExtensionAbilities = { + name: "[PC preview] unknown name", + forms: [AbilityFormInfo], +} + +export const ModuleConfigInfo = { + apiVersion: ApiVersion, + deviceType: [paramMock.paramStringMock], + distro: [paramMock.paramStringMock], + abilities: [ModuleAbilityInfo], + extensionAbilities: [ExtensionAbilities], +} + +export const BundleConfigInfo = { + bundleName: "[PC preview] unknown bundleName", + version: Version, +} + +export const PackageSummary = { + app: BundleConfigInfo, + modules: [ModuleConfigInfo] +} + +export const BundlePackFlag = { + GET_PACK_INFO_ALL: 0x00000000, + GET_PACKAGES: 0x00000001, + GET_BUNDLE_SUMMARY: 0x00000002, + GET_MODULE_SUMMARY: 0x00000004, +} + +export const BundlePackInfo = { + packages: [PackageConfig], + summary: PackageSummary } \ No newline at end of file diff --git a/runtime/main/extend/systemplugin/napi/bundle/shortcutInfo.js b/runtime/main/extend/systemplugin/napi/bundle/shortcutInfo.js index 934d65a2..e90805ca 100755 --- a/runtime/main/extend/systemplugin/napi/bundle/shortcutInfo.js +++ b/runtime/main/extend/systemplugin/napi/bundle/shortcutInfo.js @@ -28,12 +28,7 @@ export const ShortcutInfo = { label: "[PC preview] unknown label", labelId: "[PC preview] unknown labelId", disableMessage: "[PC preview] unknown disableMessage", - wants: [ - { - targetBundle: "[PC preview] unknown targetBundle", - targetModule: "[PC preview] unknown targetModule", - targetClass: "[PC preview] unknown targetClass", - }], + wants: [ShortcutWant], isStatic: "[PC preview] unknown isStatic", isHomeShortcut: "[PC preview] unknown isHomeShortcut", isEnabled: "[PC preview] unknown isEnabled", diff --git a/runtime/main/extend/systemplugin/napi/ohos_bundle.js b/runtime/main/extend/systemplugin/napi/ohos_bundle.js index e07715c9..3003706b 100644 --- a/runtime/main/extend/systemplugin/napi/ohos_bundle.js +++ b/runtime/main/extend/systemplugin/napi/ohos_bundle.js @@ -14,13 +14,103 @@ */ import { paramMock } from "../utils" -import { BundleInfo, BundlePackInfo, PixelMapFormat} from './bundle/bundleInfo' +import { BundleInfo, PixelMapFormat } from './bundle/bundleInfo' +import { BundlePackInfo } from './bundle/packInfo' import { DispatchInfo } from './bundle/dispatchInfo' import { ApplicationInfo, Want } from './bundle/applicationInfo' import { AbilityInfo } from './bundle/abilityInfo' -import { PermissionDef } from './bundle/permissionDef' +import { PermissionDef } from './bundle/PermissionDef' import { ExtensionAbilityInfo } from './bundle/extensionAbilityInfo' +export const BundleFlag = { + GET_BUNDLE_DEFAULT: 0x00000000, + GET_BUNDLE_WITH_ABILITIES: 0x00000001, + GET_ABILITY_INFO_WITH_PERMISSION: 0x00000002, + GET_ABILITY_INFO_WITH_APPLICATION: 0x00000004, + GET_APPLICATION_INFO_WITH_PERMISSION: 0x00000008, + GET_BUNDLE_WITH_REQUESTED_PERMISSION: 0x00000010, + GET_ALL_APPLICATION_INFO: 0xFFFF0000, + GET_ABILITY_INFO_WITH_METADATA: 0x00000020, + GET_BUNDLE_WITH_EXTENSION_ABILITY: 0x00000020, + GET_BUNDLE_WITH_HASH_VALUE: 0x00000030, + GET_APPLICATION_INFO_WITH_METADATA: 0x00000040, + GET_ABILITY_INFO_SYSTEMAPP_ONLY: 0x00000080, + GET_ABILITY_INFO_WITH_DISABLE: 0x00000100, + GET_APPLICATION_INFO_WITH_DISABLE: 0x00000200, + GET_APPLICATION_INFO_WITH_CERTIFICATE_FINGERPRINT: 0x00000400, +} + +export const ExtensionFlag = { + GET_EXTENSION_INFO_DEFAULT: 0x00000000, + GET_EXTENSION_INFO_WITH_PERMISSION: 0x00000002, + GET_EXTENSION_INFO_WITH_APPLICATION: 0x00000004, + GET_EXTENSION_INFO_WITH_METADATA: 0x00000020, +} + +export const ColorMode = { + AUTO_MODE: -1, + DARK_MODE: 0, + LIGHT_MODE: 1, +} + +export const GrantStatus = { + PERMISSION_DENIED: -1, + PERMISSION_GRANTED: 0, +} + +export const AbilityType = { + UNKNOWN: 0, + PAGE: 1, + SERVICE: 2, + DATA: 3, +} + +export const AbilitySubType = { + UNSPECIFIED: 0, + CA: 1, +} + +export const DisplayOrientation = { + UNSPECIFIED: 0, + LANDSCAPE: 0, + PORTRAIT: 1, + FOLLOW_RECENT: 2, + LANDSCAPE_INVERTED: 3, + PORTRAIT_INVERTED: 4, + AUTO_ROTATION: 5, + AUTO_ROTATION_LANDSCAPE: 6, + AUTO_ROTATION_PORTRAIT: 7, + AUTO_ROTATION_RESTRICTED: 8, + AUTO_ROTATION_LANDSCAPE_RESTRICTED: 9, + AUTO_ROTATION_PORTRAIT_RESTRICTED: 10, + LOCKED: 11, +} + +export const LaunchMode = { + SINGLETON: 0, + STANDARD: 1, +} + +export const ExtensionAbilityType = { + FORM: 0, + WORK_SCHEDULER: 1, + INPUT_METHOD: 2, + SERVICE: 3, + ACCESSIBILITY: 4, + DATA_SHARE: 5, + FILE_SHARE: 6, + STATIC_SUBSCRIBER: 7, + WALLPAPER: 8, + BACKUP: 9, + WINDOW: 10, + ENTERPRISE_ADMIN: 11, + UNSPECIFIED: 20, +} + +export const BundleOptions = { + userId: "[PC preview] unknown userId", +} + export const InstallErrorCode = { SUCCESS: 0, STATUS_INSTALL_FAILURE: 1, @@ -32,10 +122,10 @@ export const InstallErrorCode = { STATUS_UNINSTALL_FAILURE: 7, STATUS_UNINSTALL_FAILURE_BLOCKED: 8, STATUS_UNINSTALL_FAILURE_ABORTED: 9, - STATUS_INSTALL_FAILURE_DOWNLOAD_TIMEOUT: 10, - STATUS_INSTALL_FAILURE_DOWNLOAD_FAILED: 0x0B, - STATUS_RECOVER_FAILURE_INVALID: 0x0C, - STATUS_INSTALL_FAILURE_DOWNLOAD_FAILED: 0x0D, + STATUS_UNINSTALL_FAILURE_CONFLICT: 10, + STATUS_INSTALL_FAILURE_DOWNLOAD_TIMEOUT: 0x0B, + STATUS_INSTALL_FAILURE_DOWNLOAD_FAILED: 0x0C, + STATUS_RECOVER_FAILURE_INVALID: 0x0D, STATUS_ABILITY_NOT_FOUND: 0x40, STATUS_BMS_SERVICE_ERROR: 0x41, STATUS_FAILED_NO_SPACE_LEFT: 0x42, @@ -44,6 +134,18 @@ export const InstallErrorCode = { STATUS_UNINSTALL_PERMISSION_DENIED: 0x45, } +export const UpgradeFlag = { + NOT_UPGRADE: 0, + SINGLE_UPGRADE: 1, + RELATION_UPGRADE: 2, +} + +export const SupportWindowMode = { + FULL_SCREEN: 0, + SPLIT: 1, + FLOATING: 2, +} + export function mockBundle() { const bundle = { getBundleInfo: function(...args) { diff --git a/runtime/main/extend/systemplugin/napi/ohos_bundle_defaultAppManager.js b/runtime/main/extend/systemplugin/napi/ohos_bundle_defaultAppManager.js index d5f65973..6d35a272 100755 --- a/runtime/main/extend/systemplugin/napi/ohos_bundle_defaultAppManager.js +++ b/runtime/main/extend/systemplugin/napi/ohos_bundle_defaultAppManager.js @@ -16,6 +16,17 @@ import { paramMock } from "../utils" import { BundleInfo } from './bundle/bundleInfo' +export const ApplicationType = { + BROWSER: "BROWSER", + IMAGE: "IMAGE", + AUDIO: "AUDIO", + VIDEO: "VIDEO", + PDF: "PDF", + WORD: "WORD", + EXCEL: "EXCEL", + PPT: "PPT", + }; + export function mockDefaultAppManager() { const defaultAppManager = { isDefaultApplication: function(...args){ diff --git a/runtime/main/extend/systemplugin/napi/ohos_bundle_innerBundleManager.js b/runtime/main/extend/systemplugin/napi/ohos_bundle_innerBundleManager.js index 13893410..175a0249 100644 --- a/runtime/main/extend/systemplugin/napi/ohos_bundle_innerBundleManager.js +++ b/runtime/main/extend/systemplugin/napi/ohos_bundle_innerBundleManager.js @@ -14,7 +14,7 @@ */ import { paramMock } from "../utils" -import { ShortcutInfo } from './bundle/applicationInfo' +import { ShortcutInfo } from './bundle/shortcutInfo' import { LauncherAbilityInfo } from './bundle/launcherAbilityInfo' export function mockInnerBundle() { diff --git a/runtime/main/extend/systemplugin/napi/ohos_zlib.js b/runtime/main/extend/systemplugin/napi/ohos_zlib.js index 0caab86f..3ad3a5d7 100644 --- a/runtime/main/extend/systemplugin/napi/ohos_zlib.js +++ b/runtime/main/extend/systemplugin/napi/ohos_zlib.js @@ -19,7 +19,7 @@ export const MemLevel = { }; export const ErrorCode = { ERROR_CODE_OK: 0, - ERROR_CODE_ERRND: -1, + ERROR_CODE_ERRNO: -1, }; export const CompressLevel = { COMPRESS_LEVEL_NO_COMPRESSION: 0, @@ -34,6 +34,11 @@ export const CompressStrategy = { COMPRESS_STRATEGY_RLE: 3, COMPRESS_STRATEGY_FIXED: 4 }; +export const Options = { + level: CompressLevel, + memLevel: MemLevel, + strategy: CompressStrategy, +}; export function mockZlib() { const zlib = { ErrorCode, @@ -45,6 +50,7 @@ export function mockZlib() { memLevel: MemLevel, strategy: CompressStrategy, }, + zipFile(...args) { console.warn("zlib.zipFile interface mocked in the Previewer. How this interface works on the Previewer may be different from that on a real device.") return new Promise((resolve, reject) => { From 4fba819d0a734ad2248acdadc2e18f4125c89482 Mon Sep 17 00:00:00 2001 From: Your Name Date: Sat, 16 Jul 2022 12:40:42 +0800 Subject: [PATCH 079/109] =?UTF-8?q?uitest=20MockAPI=E5=A2=9E=E5=8A=A0.=20S?= =?UTF-8?q?igned-off-by:=20?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Your Name --- .../main/extend/systemplugin/napi/index.js | 3 + .../extend/systemplugin/napi/ohos_uitest.js | 350 ++++++++++++++++++ 2 files changed, 353 insertions(+) create mode 100644 runtime/main/extend/systemplugin/napi/ohos_uitest.js diff --git a/runtime/main/extend/systemplugin/napi/index.js b/runtime/main/extend/systemplugin/napi/index.js index 5d7c060e..0d1a921b 100644 --- a/runtime/main/extend/systemplugin/napi/index.js +++ b/runtime/main/extend/systemplugin/napi/index.js @@ -172,6 +172,7 @@ import { mockMouseEvent } from './ohos_multimodalInput_mouseEvent' import { mockTouchEvent } from './ohos_multimodalInput_touchEvent' import { mockUiAppearance } from './ohos_uiAppearance' import { mockContinationManager } from './ohos_continuation_continuationManager' +import { mockUiTest } from './ohos_uitest' export function mockRequireNapiFun() { global.requireNapi = function (...args) { switch (args[0]) { @@ -493,6 +494,8 @@ export function mockRequireNapiFun() { return mockTouchEvent(); case "continuation.continuationManager": return mockContinationManager(); + case "uitest": + return mockUiTest(); default: return global.requireNapiPreview(...args); } diff --git a/runtime/main/extend/systemplugin/napi/ohos_uitest.js b/runtime/main/extend/systemplugin/napi/ohos_uitest.js new file mode 100644 index 00000000..16000859 --- /dev/null +++ b/runtime/main/extend/systemplugin/napi/ohos_uitest.js @@ -0,0 +1,350 @@ +/* + * Copyright (c) 2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import {paramMock} from '../utils' + +const warnMessage = + ' interface mocked in the Previewer. How this interface works on the' + + ' Previewer may be different from that on a real device.' + +const MatchPatternMock = { + EQUALS: 0, + CONTAINS: 1, + STARTS_WITH: 2, + ENDS_WITH: 3 +} + +const ByMockClass = class ByMock { + constructor() { + console.warn('uitest.By.constructor' + warnMessage); + this.id = function(...args) { + console.warn('uitest.By.id' + warnMessage) + return paramMock.paramObjectMock + }; + this.text = function(...args) { + console.warn('uitest.By.text' + warnMessage) + return paramMock.paramObjectMock + }; + this.key = function(...args) { + console.warn('uitest.By.key' + warnMessage) + return paramMock.paramObjectMock + }; + this.type = function(...args) { + console.warn('uitest.By.type' + warnMessage) + return paramMock.paramObjectMock + }; + this.enabled = function(...args) { + console.warn('uitest.By.enabled' + warnMessage) + return paramMock.paramObjectMock + }; + this.focused = function(...args) { + console.warn('uitest.By.focused' + warnMessage) + return paramMock.paramObjectMock + }; + this.selected = function(...args) { + console.warn('uitest.By.selected' + warnMessage) + return paramMock.paramObjectMock + }; + this.clickable = function(...args) { + console.warn('uitest.By.clickable' + warnMessage) + return paramMock.paramObjectMock + }; + this.enabled = function(...args) { + console.warn('uitest.By.enabled' + warnMessage) + return paramMock.paramObjectMock + }; + this.longClickable = function(...args) { + console.warn('uitest.By.longClickable' + warnMessage) + return paramMock.paramObjectMock + }; + this.scrollable = function(...args) { + console.warn('uitest.By.scrollable' + warnMessage) + return paramMock.paramObjectMock + }; + this.checkable = function(...args) { + console.warn('uitest.By.checkable' + warnMessage) + return paramMock.paramObjectMock + }; + this.checked = function(...args) { + console.warn('uitest.By.checked' + warnMessage) + return paramMock.paramObjectMock + }; + this.isBefore = function(...args) { + console.warn('uitest.By.isBefore' + warnMessage) + return paramMock.paramObjectMock + }; + this.isAfter = function(...args) { + console.warn('uitest.By.isAfter' + warnMessage) + return paramMock.paramObjectMock + }; + } +} + +const BYMock = new ByMockClass() + +const UiDriverMockClass = class UiDriverMock { + constructor() { + console.warn('uitest.UiDriver.constructor' + warnMessage); + this.create = function(...args) { + console.warn('uitest.UiDriver.create' + warnMessage) + return paramMock.paramObjectMock + }; + this.delayMs = function(...args) { + console.warn('uitest.UiDriver.delayMs' + warnMessage) + return paramMock.paramObjectMock + }; + this.findComponent = function(...args) { + console.warn('uitest.UiDriver.findComponent' + warnMessage) + return paramMock.paramObjectMock + }; + this.findWindow = function(...args) { + console.warn('uitest.UiDriver.findWindow' + warnMessage) + return paramMock.paramObjectMock + }; + this.findComponents = function(...args) { + console.warn('uitest.UiDriver.findComponents' + warnMessage) + return paramMock.paramObjectMock + }; + this.waitForComponent = function(...args) { + console.warn('uitest.UiDriver.waitForComponent' + warnMessage) + return paramMock.paramObjectMock + }; + this.screenCap = function(...args) { + console.warn('uitest.UiDriver.screenCap' + warnMessage) + return paramMock.paramObjectMock + }; + this.assertComponentExist = function(...args) { + console.warn('uitest.UiDriver.assertComponentExist' + warnMessage) + return paramMock.paramObjectMock + }; + this.pressBack = function(...args) { + console.warn('uitest.UiDriver.pressBack' + warnMessage) + return paramMock.paramObjectMock + }; + this.triggerKey = function(...args) { + console.warn('uitest.UiDriver.triggerKey' + warnMessage) + return paramMock.paramObjectMock + }; + this.triggerCombineKeys = function(...args) { + console.warn('uitest.UiDriver.triggerCombineKeys' + warnMessage) + return paramMock.paramObjectMock + }; + this.click = function(...args) { + console.warn('uitest.UiDriver.click' + warnMessage) + return paramMock.paramObjectMock + }; + this.longClick = function(...args) { + console.warn('uitest.UiDriver.longClick' + warnMessage) + return paramMock.paramObjectMock + }; + this.doubleClick = function(...args) { + console.warn('uitest.UiDriver.doubleClick' + warnMessage) + return paramMock.paramObjectMock + }; + this.swipe = function(...args) { + console.warn('uitest.UiDriver.swipe' + warnMessage) + return paramMock.paramObjectMock + }; + this.drag = function(...args) { + console.warn('uitest.UiDriver.drag' + warnMessage) + return paramMock.paramObjectMock + }; + } +} + +const UIDriverMock = new UiDriverMockClass() + +const UiComponentMockClass = class UiComponentMock { + constructor() { + console.warn('uitest.UiComponent.constructor' + warnMessage); + this.getId = function(...args) { + console.warn('uitest.UiComponent.getId.warn' + warnMessage) + return paramMock.paramObjectMock + }; + this.getText = function(...args) { + console.warn('uitest.UiComponent.getText.warn' + warnMessage) + return paramMock.paramObjectMock + }; + this.getKey = function(...args) { + console.warn('uitest.UiComponent.getKey.warn' + warnMessage) + return paramMock.paramObjectMock + }; + this.getType = function(...args) { + console.warn('uitest.UiComponent.getType.warn' + warnMessage) + return paramMock.paramObjectMock + }; + this.isEnabled = function(...args) { + console.warn('uitest.UiComponent.isEnabled.warn' + warnMessage) + return paramMock.paramObjectMock + }; + this.isFocused = function(...args) { + console.warn('uitest.UiComponent.isFocused.warn' + warnMessage) + return paramMock.paramObjectMock + }; + this.isSelected = function(...args) { + console.warn('uitest.UiComponent.isSelected.warn' + warnMessage) + return paramMock.paramObjectMock + }; + this.isClickable = function(...args) { + console.warn('uitest.UiComponent.isClickable.warn' + warnMessage) + return paramMock.paramObjectMock + }; + this.isLongClickable = function(...args) { + console.warn('uitest.UiComponent.isLongClickable.warn' + warnMessage) + return paramMock.paramObjectMock + }; + this.isScrollable = function(...args) { + console.warn('uitest.UiComponent.isScrollable.warn' + warnMessage) + return paramMock.paramObjectMock + }; + this.isCheckable = function(...args) { + console.warn('uitest.UiComponent.isCheckable.warn' + warnMessage) + return paramMock.paramObjectMock + }; + this.isChecked = function(...args) { + console.warn('uitest.UiComponent.isChecked.warn' + warnMessage) + return paramMock.paramObjectMock + }; + this.getBounds = function(...args) { + console.warn('uitest.UiComponent.getBounds.warn' + warnMessage) + return paramMock.paramObjectMock + }; + this.getBoundsCenter = function(...args) { + console.warn('uitest.UiComponent.getBoundsCenter.warn' + warnMessage) + return paramMock.paramObjectMock + }; + this.click = function(...args) { + console.warn('uitest.UiComponent.click.warn' + warnMessage) + return paramMock.paramObjectMock + }; + this.longClick = function(...args) { + console.warn('uitest.UiComponent.longClick.warn' + warnMessage) + return paramMock.paramObjectMock + }; + this.doubleClick = function(...args) { + console.warn('uitest.UiComponent.doubleClick.warn' + warnMessage) + return paramMock.paramObjectMock + }; + this.scrollToTop = function(...args) { + console.warn('uitest.UiComponent.scrollToTop.warn' + warnMessage) + return paramMock.paramObjectMock + }; + this.scrollToBottom = function(...args) { + console.warn('uitest.UiComponent.scrollToBottom.warn' + warnMessage) + return paramMock.paramObjectMock + }; + this.inputText = function(...args) { + console.warn('uitest.UiComponent.inputText.warn' + warnMessage) + return paramMock.paramObjectMock + }; + this.clearText = function(...args) { + console.warn('uitest.UiComponent.clearText.warn' + warnMessage) + return paramMock.paramObjectMock + }; + this.scrollSearch = function(...args) { + console.warn('uitest.UiComponent.scrollSearch.warn' + warnMessage) + return paramMock.paramObjectMock + }; + this.dragTo = function(...args) { + console.warn('uitest.UiComponent.dragTo.warn' + warnMessage) + return paramMock.paramObjectMock + }; + this.pinchOut = function(...args) { + console.warn('uitest.UiComponent.pinchOut.warn' + warnMessage) + return paramMock.paramObjectMock + }; + this.pinchIn = function(...args) { + console.warn('uitest.UiComponent.pinchIn.warn' + warnMessage) + return paramMock.paramObjectMock + }; + } +} + +const UIComponentMock = new UiComponentMockClass() + +const UiWindowMockClass = class UiWindowMock { + constructor() { + console.warn('uitest.UiWindowMock.constructor' + warnMessage); + this.getBundleName = function(...args) { + console.warn('uitest.UiWindowMock.getBundleName.warn' + warnMessage) + return paramMock.paramObjectMock + }; + this.getBounds = function(...args) { + console.warn('uitest.UiWindowMock.getBounds.warn' + warnMessage) + return paramMock.paramObjectMock + }; + this.getTitle = function(...args) { + console.warn('uitest.UiWindowMock.getTitle.warn' + warnMessage) + return paramMock.paramObjectMock + }; + this.getWindowMode = function(...args) { + console.warn('uitest.UiWindowMock.getWindowMode.warn' + warnMessage) + return paramMock.paramObjectMock + }; + this.isFocused = function(...args) { + console.warn('uitest.UiWindowMock.isFocused.warn' + warnMessage) + return paramMock.paramObjectMock + }; + this.isActived = function(...args) { + console.warn('uitest.UiWindowMock.isActived.warn' + warnMessage) + return paramMock.paramObjectMock + }; + this.focuse = function(...args) { + console.warn('uitest.UiWindowMock.focuse.warn' + warnMessage) + return paramMock.paramObjectMock + }; + this.moveTo = function(...args) { + console.warn('uitest.UiWindowMock.moveTo.warn' + warnMessage) + return paramMock.paramObjectMock + }; + this.resize = function(...args) { + console.warn('uitest.UiWindowMock.resize.warn' + warnMessage) + return paramMock.paramObjectMock + }; + this.split = function(...args) { + console.warn('uitest.UiWindowMock.split.warn' + warnMessage) + return paramMock.paramObjectMock + }; + this.maximize = function(...args) { + console.warn('uitest.UiWindowMock.maximize.warn' + warnMessage) + return paramMock.paramObjectMock + }; + this.resume = function(...args) { + console.warn('uitest.UiWindowMock.resume.warn' + warnMessage) + return paramMock.paramObjectMock + }; + this.minimize = function(...args) { + console.warn('uitest.UiWindowMock.minimize.warn' + warnMessage) + return paramMock.paramObjectMock + }; + this.close = function(...args) { + console.warn('uitest.UiWindowMock.close.warn' + warnMessage) + return paramMock.paramObjectMock + }; + }; +} + +const UIWindowMock = new UiWindowMockClass() + +export function mockUiTest() { + const module = { + MatchPattern: MatchPatternMock, + BY: BYMock, + UiDriver: UIDriverMock, + UiComponent: UIComponentMock, + UiWindow: UIWindowMock + }; + return module +} \ No newline at end of file From b44e95f0f51eea8280f5a274ca449dcf1d9d5e00 Mon Sep 17 00:00:00 2001 From: lovechinamo Date: Sat, 16 Jul 2022 15:23:31 +0800 Subject: [PATCH 080/109] Signed-off-by: lovechinamo Changes to be committed: --- .../systemplugin/napi/ohos_screenLock.js | 39 +++++++++++++++++++ 1 file changed, 39 insertions(+) diff --git a/runtime/main/extend/systemplugin/napi/ohos_screenLock.js b/runtime/main/extend/systemplugin/napi/ohos_screenLock.js index 893f232c..7aefba1e 100644 --- a/runtime/main/extend/systemplugin/napi/ohos_screenLock.js +++ b/runtime/main/extend/systemplugin/napi/ohos_screenLock.js @@ -52,6 +52,45 @@ export function mockScreenLock() { resolve(); }) } + }, + on: function (...args) { + console.warn("screenLock.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] == 'beginWakeUp' || args[0] == 'endWakeUp' || args[0] == 'beginScreenOn' || args[0] == 'endScreenOn' + || args[0] == 'beginScreenOff' || args[0] == 'endScreenOff' || args[0] == 'unlockScreen' || args[0] == 'beginExitAnimation') { + args[len - 1].call(this, paramMock.businessErrorMock); + } else if (args[0] == 'beginSleep' || args[0] == 'endSleep' || args[0] == 'changeUser') { + args[len - 1].call(this, paramMock.paramNumberMock); + } else if (args[0] == 'screenlockEnabled') { + args[len - 1].call(this, paramMock.paramBooleanMock); + } + } + }, + off: function (...args) { + console.warn("screenLock.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] == 'beginWakeUp' || args[0] == 'endWakeUp' || args[0] == 'beginScreenOn' || args[0] == 'endScreenOn' + || args[0] == 'beginScreenOff' || args[0] == 'endScreenOff' || args[0] == 'unlockScreen' || args[0] == 'beginExitAnimation' + || args[0] == 'screenlockEnabled' || args[0] == 'beginSleep' || args[0] == 'endSleep' || args[0] == 'changeUser') { + args[len - 1].call(this, paramMock.businessErrorMock); + } + } + }, + sendScreenLockEvent: function (...args) { + console.warn("screenLock.sendScreenLockEvent interface mocked in the Previewer. How this interface works on the" + + " Previewer may be different 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); + }) + } } } return screenLock From 49fdfc3e4aa58a174bfae00f5b4400aa73869473 Mon Sep 17 00:00:00 2001 From: lovechinamo Date: Sat, 16 Jul 2022 17:38:57 +0800 Subject: [PATCH 081/109] Signed-off-by: lovechinamo Changes to be committed: --- runtime/main/extend/systemplugin/napi/ohos_screenLock.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/runtime/main/extend/systemplugin/napi/ohos_screenLock.js b/runtime/main/extend/systemplugin/napi/ohos_screenLock.js index 7aefba1e..edf5f1d1 100644 --- a/runtime/main/extend/systemplugin/napi/ohos_screenLock.js +++ b/runtime/main/extend/systemplugin/napi/ohos_screenLock.js @@ -60,7 +60,7 @@ export function mockScreenLock() { if (typeof args[len - 1] === 'function') { if (args[0] == 'beginWakeUp' || args[0] == 'endWakeUp' || args[0] == 'beginScreenOn' || args[0] == 'endScreenOn' || args[0] == 'beginScreenOff' || args[0] == 'endScreenOff' || args[0] == 'unlockScreen' || args[0] == 'beginExitAnimation') { - args[len - 1].call(this, paramMock.businessErrorMock); + args[len - 1].call(this); } else if (args[0] == 'beginSleep' || args[0] == 'endSleep' || args[0] == 'changeUser') { args[len - 1].call(this, paramMock.paramNumberMock); } else if (args[0] == 'screenlockEnabled') { @@ -76,7 +76,7 @@ export function mockScreenLock() { if (args[0] == 'beginWakeUp' || args[0] == 'endWakeUp' || args[0] == 'beginScreenOn' || args[0] == 'endScreenOn' || args[0] == 'beginScreenOff' || args[0] == 'endScreenOff' || args[0] == 'unlockScreen' || args[0] == 'beginExitAnimation' || args[0] == 'screenlockEnabled' || args[0] == 'beginSleep' || args[0] == 'endSleep' || args[0] == 'changeUser') { - args[len - 1].call(this, paramMock.businessErrorMock); + args[len - 1].call(this); } } }, From 8f6e17018dfb8d93ef95053b5549cffe03e523c8 Mon Sep 17 00:00:00 2001 From: Your Name Date: Sat, 16 Jul 2022 18:24:12 +0800 Subject: [PATCH 082/109] =?UTF-8?q?uitest=20MockAPI=E6=8E=A5=E5=8F=A3?= =?UTF-8?q?=E5=A2=9E=E5=8A=A0.=20Signed-off-by:=20?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Your Name --- .../extend/systemplugin/napi/ohos_uitest.js | 327 +++++++++++++----- 1 file changed, 239 insertions(+), 88 deletions(-) diff --git a/runtime/main/extend/systemplugin/napi/ohos_uitest.js b/runtime/main/extend/systemplugin/napi/ohos_uitest.js index 16000859..736530f7 100644 --- a/runtime/main/extend/systemplugin/napi/ohos_uitest.js +++ b/runtime/main/extend/systemplugin/napi/ohos_uitest.js @@ -19,332 +19,483 @@ const warnMessage = ' interface mocked in the Previewer. How this interface works on the' + ' Previewer may be different from that on a real device.' -const MatchPatternMock = { +export const ResizeDirectionMock = { + LEFT: 0, + RIGHT: 1, + UP: 2, + DOWN: 3, + LEFT_UP: 4, + LEFT_DOWN: 5, + RIGHT_UP: 6, + RIGHT_DOWN: 7 +} + +export const MatchPatternMock = { EQUALS: 0, CONTAINS: 1, STARTS_WITH: 2, ENDS_WITH: 3 } +export const WindowModeMock = { + FULLSCREEN: 0, + PRIMARY: 1, + SECONDARY: 2, + FLOATING: 3 +} + +const PointMockClass = class PointMock { + constructor() { + X: '[PC Preview] unknown X'; + Y: '[PC Preview] unknown Y'; + } +} + +const RectMockClass = class RectMock { + constructor() { + leftX: '[PC Preview] unknown leftX'; + topY: '[PC Preview] unknown topY'; + rightX: '[PC Preview] unknown rightX'; + bottomY: '[PC Preview] unknown bottomY'; + } +} + +const WindowFilterMockClass = class WindowFilterMock { + constructor() { + bundleName: '[PC Preview] unknown bundleName'; + title: '[PC Preview] unknown title'; + focused: '[PC Preview] unknown focused'; + actived: '[PC Preview] unknown actived'; + } +} + const ByMockClass = class ByMock { constructor() { console.warn('uitest.By.constructor' + warnMessage); this.id = function(...args) { console.warn('uitest.By.id' + warnMessage) - return paramMock.paramObjectMock + return new BYMock() }; this.text = function(...args) { console.warn('uitest.By.text' + warnMessage) - return paramMock.paramObjectMock + return new BYMock() }; this.key = function(...args) { console.warn('uitest.By.key' + warnMessage) - return paramMock.paramObjectMock + return new BYMock() }; this.type = function(...args) { console.warn('uitest.By.type' + warnMessage) - return paramMock.paramObjectMock + return new BYMock() }; this.enabled = function(...args) { console.warn('uitest.By.enabled' + warnMessage) - return paramMock.paramObjectMock + return new BYMock() }; this.focused = function(...args) { console.warn('uitest.By.focused' + warnMessage) - return paramMock.paramObjectMock + return new BYMock() }; this.selected = function(...args) { console.warn('uitest.By.selected' + warnMessage) - return paramMock.paramObjectMock + return new BYMock() }; this.clickable = function(...args) { console.warn('uitest.By.clickable' + warnMessage) - return paramMock.paramObjectMock + return new BYMock() }; this.enabled = function(...args) { console.warn('uitest.By.enabled' + warnMessage) - return paramMock.paramObjectMock + return new BYMock() }; this.longClickable = function(...args) { console.warn('uitest.By.longClickable' + warnMessage) - return paramMock.paramObjectMock + return new BYMock() }; this.scrollable = function(...args) { console.warn('uitest.By.scrollable' + warnMessage) - return paramMock.paramObjectMock + return new BYMock() }; this.checkable = function(...args) { console.warn('uitest.By.checkable' + warnMessage) - return paramMock.paramObjectMock + return new BYMock() }; this.checked = function(...args) { console.warn('uitest.By.checked' + warnMessage) - return paramMock.paramObjectMock + return new BYMock() }; this.isBefore = function(...args) { console.warn('uitest.By.isBefore' + warnMessage) - return paramMock.paramObjectMock + return new BYMock() }; this.isAfter = function(...args) { console.warn('uitest.By.isAfter' + warnMessage) - return paramMock.paramObjectMock + return new BYMock() }; } } -const BYMock = new ByMockClass() - -const UiDriverMockClass = class UiDriverMock { +const UiDriverClass = class UiDriverMock { constructor() { console.warn('uitest.UiDriver.constructor' + warnMessage); - this.create = function(...args) { - console.warn('uitest.UiDriver.create' + warnMessage) - return paramMock.paramObjectMock - }; this.delayMs = function(...args) { console.warn('uitest.UiDriver.delayMs' + warnMessage) - return paramMock.paramObjectMock + return new Promise((resolve) => { + resolve() + }); }; this.findComponent = function(...args) { console.warn('uitest.UiDriver.findComponent' + warnMessage) - return paramMock.paramObjectMock + return new Promise((resolve) => { + resolve(new UiComponentMock()) + }); }; this.findWindow = function(...args) { console.warn('uitest.UiDriver.findWindow' + warnMessage) - return paramMock.paramObjectMock + return new Promise((resolve) => { + resolve(new UiWindowMock()) + }); }; this.findComponents = function(...args) { console.warn('uitest.UiDriver.findComponents' + warnMessage) - return paramMock.paramObjectMock + return new Promise((resolve) => { + resolve(new UiComponentMock()) + }); }; this.waitForComponent = function(...args) { console.warn('uitest.UiDriver.waitForComponent' + warnMessage) - return paramMock.paramObjectMock + return new Promise((resolve) => { + resolve(new UiComponentMock()) + }); }; this.screenCap = function(...args) { console.warn('uitest.UiDriver.screenCap' + warnMessage) - return paramMock.paramObjectMock + return new Promise((resolve) => { + resolve(paramMock.paramBoolMock) + }); }; this.assertComponentExist = function(...args) { console.warn('uitest.UiDriver.assertComponentExist' + warnMessage) - return paramMock.paramObjectMock + return new Promise((resolve) => { + resolve() + }); }; this.pressBack = function(...args) { console.warn('uitest.UiDriver.pressBack' + warnMessage) - return paramMock.paramObjectMock + return new Promise((resolve) => { + resolve() + }); }; this.triggerKey = function(...args) { console.warn('uitest.UiDriver.triggerKey' + warnMessage) - return paramMock.paramObjectMock + return new Promise((resolve) => { + resolve() + }); }; this.triggerCombineKeys = function(...args) { console.warn('uitest.UiDriver.triggerCombineKeys' + warnMessage) - return paramMock.paramObjectMock + return new Promise((resolve) => { + resolve() + }); }; this.click = function(...args) { console.warn('uitest.UiDriver.click' + warnMessage) - return paramMock.paramObjectMock + return new Promise((resolve) => { + resolve() + }); }; this.longClick = function(...args) { console.warn('uitest.UiDriver.longClick' + warnMessage) - return paramMock.paramObjectMock + return new Promise((resolve) => { + resolve() + }); }; this.doubleClick = function(...args) { console.warn('uitest.UiDriver.doubleClick' + warnMessage) - return paramMock.paramObjectMock + return new Promise((resolve) => { + resolve() + }); }; this.swipe = function(...args) { console.warn('uitest.UiDriver.swipe' + warnMessage) - return paramMock.paramObjectMock + return new Promise((resolve) => { + resolve() + }); }; this.drag = function(...args) { console.warn('uitest.UiDriver.drag' + warnMessage) - return paramMock.paramObjectMock + return new Promise((resolve) => { + resolve() + }); }; } } -const UIDriverMock = new UiDriverMockClass() +UiDriverClass.create = function () { + this.create = function(...args) { + console.warn('uitest.UiDriver.create' + warnMessage) + return new UiDriverMock() + } +} -const UiComponentMockClass = class UiComponentMock { +const UiComponentClass = class UiComponentMock { constructor() { console.warn('uitest.UiComponent.constructor' + warnMessage); this.getId = function(...args) { console.warn('uitest.UiComponent.getId.warn' + warnMessage) - return paramMock.paramObjectMock + return new Promise((resolve) => { + resolve(paramMock.paramNumberMock) + }); }; this.getText = function(...args) { console.warn('uitest.UiComponent.getText.warn' + warnMessage) - return paramMock.paramObjectMock + return new Promise((resolve) => { + resolve(paramMock.paramStringMock) + }); }; this.getKey = function(...args) { console.warn('uitest.UiComponent.getKey.warn' + warnMessage) - return paramMock.paramObjectMock + return new Promise((resolve) => { + resolve(paramMock.paramStringMock) + }); }; this.getType = function(...args) { console.warn('uitest.UiComponent.getType.warn' + warnMessage) - return paramMock.paramObjectMock + return new Promise((resolve) => { + resolve(paramMock.paramStringMock) + }); }; this.isEnabled = function(...args) { console.warn('uitest.UiComponent.isEnabled.warn' + warnMessage) - return paramMock.paramObjectMock + return new Promise((resolve) => { + resolve(paramMock.paramBoolMock) + }); }; this.isFocused = function(...args) { console.warn('uitest.UiComponent.isFocused.warn' + warnMessage) - return paramMock.paramObjectMock + return new Promise((resolve) => { + resolve(paramMock.paramBoolMock) + }); }; this.isSelected = function(...args) { console.warn('uitest.UiComponent.isSelected.warn' + warnMessage) - return paramMock.paramObjectMock + return new Promise((resolve) => { + resolve(paramMock.paramBoolMock) + }); }; this.isClickable = function(...args) { console.warn('uitest.UiComponent.isClickable.warn' + warnMessage) - return paramMock.paramObjectMock + return new Promise((resolve) => { + resolve(paramMock.paramBoolMock) + }); }; this.isLongClickable = function(...args) { console.warn('uitest.UiComponent.isLongClickable.warn' + warnMessage) - return paramMock.paramObjectMock + return new Promise((resolve) => { + resolve(paramMock.paramBoolMock) + }); }; this.isScrollable = function(...args) { console.warn('uitest.UiComponent.isScrollable.warn' + warnMessage) - return paramMock.paramObjectMock + return new Promise((resolve) => { + resolve(paramMock.paramBoolMock) + }); }; this.isCheckable = function(...args) { console.warn('uitest.UiComponent.isCheckable.warn' + warnMessage) - return paramMock.paramObjectMock + return new Promise((resolve) => { + resolve(paramMock.paramBoolMock) + }); }; this.isChecked = function(...args) { console.warn('uitest.UiComponent.isChecked.warn' + warnMessage) - return paramMock.paramObjectMock + return new Promise((resolve) => { + resolve(paramMock.paramBoolMock) + }); }; this.getBounds = function(...args) { console.warn('uitest.UiComponent.getBounds.warn' + warnMessage) - return paramMock.paramObjectMock + return new Promise((resolve) => { + resolve(RectMock) + }); }; this.getBoundsCenter = function(...args) { console.warn('uitest.UiComponent.getBoundsCenter.warn' + warnMessage) - return paramMock.paramObjectMock + return new Promise((resolve) => { + resolve(PointMock) + }); }; this.click = function(...args) { console.warn('uitest.UiComponent.click.warn' + warnMessage) - return paramMock.paramObjectMock + return new Promise((resolve) => { + resolve() + }); }; this.longClick = function(...args) { console.warn('uitest.UiComponent.longClick.warn' + warnMessage) - return paramMock.paramObjectMock + return new Promise((resolve) => { + resolve() + }); }; this.doubleClick = function(...args) { console.warn('uitest.UiComponent.doubleClick.warn' + warnMessage) - return paramMock.paramObjectMock + return new Promise((resolve) => { + resolve() + }); }; this.scrollToTop = function(...args) { console.warn('uitest.UiComponent.scrollToTop.warn' + warnMessage) - return paramMock.paramObjectMock + return new Promise((resolve) => { + resolve() + }); }; this.scrollToBottom = function(...args) { console.warn('uitest.UiComponent.scrollToBottom.warn' + warnMessage) - return paramMock.paramObjectMock + return new Promise((resolve) => { + resolve() + }); }; this.inputText = function(...args) { console.warn('uitest.UiComponent.inputText.warn' + warnMessage) - return paramMock.paramObjectMock + return new Promise((resolve) => { + resolve() + }); }; this.clearText = function(...args) { console.warn('uitest.UiComponent.clearText.warn' + warnMessage) - return paramMock.paramObjectMock + return new Promise((resolve) => { + resolve() + }); }; this.scrollSearch = function(...args) { console.warn('uitest.UiComponent.scrollSearch.warn' + warnMessage) - return paramMock.paramObjectMock + return new Promise((resolve) => { + resolve(new UiComponentMock()) + }); }; this.dragTo = function(...args) { console.warn('uitest.UiComponent.dragTo.warn' + warnMessage) - return paramMock.paramObjectMock + return new Promise((resolve) => { + resolve() + }); }; this.pinchOut = function(...args) { console.warn('uitest.UiComponent.pinchOut.warn' + warnMessage) - return paramMock.paramObjectMock + return new Promise((resolve) => { + resolve() + }); }; this.pinchIn = function(...args) { console.warn('uitest.UiComponent.pinchIn.warn' + warnMessage) - return paramMock.paramObjectMock + return new Promise((resolve) => { + resolve() + }); }; } } -const UIComponentMock = new UiComponentMockClass() - -const UiWindowMockClass = class UiWindowMock { +const UiWindowClass = class UiWindowMock { constructor() { console.warn('uitest.UiWindowMock.constructor' + warnMessage); this.getBundleName = function(...args) { console.warn('uitest.UiWindowMock.getBundleName.warn' + warnMessage) - return paramMock.paramObjectMock + return new Promise((resolve) => { + resolve(paramMock.paramStringMock) + }); }; this.getBounds = function(...args) { console.warn('uitest.UiWindowMock.getBounds.warn' + warnMessage) - return paramMock.paramObjectMock + return new Promise((resolve) => { + resolve(RectMock) + }); }; this.getTitle = function(...args) { console.warn('uitest.UiWindowMock.getTitle.warn' + warnMessage) - return paramMock.paramObjectMock + return new Promise((resolve) => { + resolve(paramMock.paramStringMock) + }); }; this.getWindowMode = function(...args) { console.warn('uitest.UiWindowMock.getWindowMode.warn' + warnMessage) - return paramMock.paramObjectMock + return new Promise((resolve) => { + resolve(WindowModeMock) + }); }; this.isFocused = function(...args) { console.warn('uitest.UiWindowMock.isFocused.warn' + warnMessage) - return paramMock.paramObjectMock + return new Promise((resolve) => { + resolve(paramMock.paramBoolMock) + }); }; this.isActived = function(...args) { console.warn('uitest.UiWindowMock.isActived.warn' + warnMessage) - return paramMock.paramObjectMock + return new Promise((resolve) => { + resolve(paramMock.paramBoolMock) + }); }; this.focuse = function(...args) { console.warn('uitest.UiWindowMock.focuse.warn' + warnMessage) - return paramMock.paramObjectMock + return new Promise((resolve) => { + resolve(paramMock.paramBoolMock) + }); }; this.moveTo = function(...args) { console.warn('uitest.UiWindowMock.moveTo.warn' + warnMessage) - return paramMock.paramObjectMock + return new Promise((resolve) => { + resolve(paramMock.paramBoolMock) + }); }; this.resize = function(...args) { console.warn('uitest.UiWindowMock.resize.warn' + warnMessage) - return paramMock.paramObjectMock + return new Promise((resolve) => { + resolve(paramMock.paramBoolMock) + }); }; this.split = function(...args) { console.warn('uitest.UiWindowMock.split.warn' + warnMessage) - return paramMock.paramObjectMock + return new Promise((resolve) => { + resolve(paramMock.paramBoolMock) + }); }; this.maximize = function(...args) { console.warn('uitest.UiWindowMock.maximize.warn' + warnMessage) - return paramMock.paramObjectMock + return new Promise((resolve) => { + resolve(paramMock.paramBoolMock) + }); }; this.resume = function(...args) { console.warn('uitest.UiWindowMock.resume.warn' + warnMessage) - return paramMock.paramObjectMock + return new Promise((resolve) => { + resolve(paramMock.paramBoolMock) + }); }; this.minimize = function(...args) { console.warn('uitest.UiWindowMock.minimize.warn' + warnMessage) - return paramMock.paramObjectMock + return new Promise((resolve) => { + resolve(paramMock.paramBoolMock) + }); }; this.close = function(...args) { console.warn('uitest.UiWindowMock.close.warn' + warnMessage) - return paramMock.paramObjectMock + return new Promise((resolve) => { + resolve(paramMock.paramBoolMock) + }); }; }; } -const UIWindowMock = new UiWindowMockClass() - export function mockUiTest() { const module = { + ResizeDirection: ResizeDirectionMock, MatchPattern: MatchPatternMock, - BY: BYMock, - UiDriver: UIDriverMock, - UiComponent: UIComponentMock, - UiWindow: UIWindowMock + WindowMode: WindowModeMock, + Point: PointMockClass, + Rect: RectMockClass, + WindowFilter: WindowFilterMockClass, + BY: ByMockClass, + UiDriver: UiDriverClass, + UiComponent: UiComponentClass, + UiWindow: UiWindowClass }; return module } \ No newline at end of file From 3399f33eb7ec5e56d6bd845837c6dc5a6395a6b5 Mon Sep 17 00:00:00 2001 From: ma-shaoyin Date: Sat, 16 Jul 2022 18:35:24 +0800 Subject: [PATCH 083/109] Signed-off-by: ma-shaoyin Changes to be committed: --- .../napi/ohos_inputmethodengine.js | 66 +++++++++---------- 1 file changed, 31 insertions(+), 35 deletions(-) diff --git a/runtime/main/extend/systemplugin/napi/ohos_inputmethodengine.js b/runtime/main/extend/systemplugin/napi/ohos_inputmethodengine.js index 7024338b..d6b55a6e 100644 --- a/runtime/main/extend/systemplugin/napi/ohos_inputmethodengine.js +++ b/runtime/main/extend/systemplugin/napi/ohos_inputmethodengine.js @@ -15,36 +15,6 @@ import { paramMock } from "../utils" -const NOTIFY = "[PC Preview] unknow" -const Properties = [ - 'ENTER_KEY_TYPE_NEXT', - 'ENTER_KEY_TYPE_PREVIOUS', - 'ENTER_KEY_TYPE_UNSPECIFIED', - 'ENTER_KEY_TYPE_SEARCH', - 'ENTER_KEY_TYPE_GO', - 'ENTER_KEY_TYPE_SEND', - 'ENTER_KEY_TYPE_DONE', - 'DISPLAY_MODE_PART', - 'DISPLAY_MODE_FULL', - 'OPTION_AUTO_CAP_CHARACTERS', - 'OPTION_AUTO_CAP_WORDS', - 'OPTION_AUTO_CAP_SENTENCES', - 'OPTION_NO_FULLSCREEN', - 'OPTION_ASCII', - 'OPTION_NONE', - 'OPTION_MULTI_LINE', - 'FLAG_SINGLE_LINE', - 'FLAG_SELECTING', - 'PATTERN_TEXT', - 'PATTERN_NUMBER', - 'PATTERN_NULL', - 'PATTERN_PHONE', - 'PATTERN_DATETIME', - 'PATTERN_URI', - 'PATTERN_EMAIL', - 'PATTERN_PASSWORD' -] - export function mockInputMethodEngine() { const EditingText = { textContent: "[PC Preview] unknow textContent", @@ -65,6 +35,10 @@ export function mockInputMethodEngine() { enterKeyType: 2, inputOption: 3 } + const KeyEvent = { + keyCode: 1, + keyAction: 2, + } const RichContent = { contentURI: "[PC Preview] unknow contentURI", linkURI: "[PC Preview] unknow linkURI", @@ -413,11 +387,33 @@ export function mockInputMethodEngine() { console.warn("inputMethodEngine.createKeyboardDelegate interface mocked in the Previewer. How this interface works" + " on the Previewer may be different from that on a real device.") return KeyboardDelegateMock; - } - } - - for (let Property of Properties) { - inputMethodEngine[Property] = NOTIFY + " " + Property + }, + ENTER_KEY_TYPE_UNSPECIFIED: "[PC Preview] unknow ENTER_KEY_TYPE_UNSPECIFIED", + ENTER_KEY_TYPE_GO: "[PC Preview] unknow ENTER_KEY_TYPE_GO", + ENTER_KEY_TYPE_SEARCH: "[PC Preview] unknow ENTER_KEY_TYPE_SEARCH", + ENTER_KEY_TYPE_SEND: "[PC Preview] unknow ENTER_KEY_TYPE_SEND", + ENTER_KEY_TYPE_NEXT: "[PC Preview] unknow ENTER_KEY_TYPE_NEXT", + ENTER_KEY_TYPE_DONE: "[PC Preview] unknow ENTER_KEY_TYPE_DONE", + ENTER_KEY_TYPE_PREVIOUS: "[PC Preview] unknow ENTER_KEY_TYPE_PREVIOUS", + PATTERN_NULL: "[PC Preview] unknow PATTERN_NULL", + PATTERN_TEXT: "[PC Preview] unknow PATTERN_TEXT", + PATTERN_NUMBER: "[PC Preview] unknow PATTERN_NUMBER", + PATTERN_PHONE: "[PC Preview] unknow PATTERN_PHONE", + PATTERN_DATETIME: "[PC Preview] unknow PATTERN_DATETIME", + PATTERN_EMAIL: "[PC Preview] unknow PATTERN_EMAIL", + PATTERN_URI: "[PC Preview] unknow PATTERN_URI", + PATTERN_PASSWORD: "[PC Preview] unknow PATTERN_PASSWORD", + FLAG_SELECTING: "[PC Preview] unknow FLAG_SELECTING", + FLAG_SINGLE_LINE: "[PC Preview] unknow FLAG_SINGLE_LINE", + DISPLAY_MODE_PART: "[PC Preview] unknow DISPLAY_MODE_PART", + DISPLAY_MODE_FULL: "[PC Preview] unknow DISPLAY_MODE_FULL", + OPTION_ASCII: "[PC Preview] unknow OPTION_ASCII", + OPTION_NONE: "[PC Preview] unknow OPTION_NONE", + OPTION_AUTO_CAP_CHARACTERS: "[PC Preview] unknow OPTION_AUTO_CAP_CHARACTERS", + OPTION_AUTO_CAP_SENTENCES: "[PC Preview] unknow OPTION_AUTO_CAP_SENTENCES", + OPTION_AUTO_WORDS: "[PC Preview] unknow OPTION_AUTO_WORDS", + OPTION_MULTI_LINE: "[PC Preview] unknow OPTION_MULTI_LINE", + OPTION_NO_FULLSCREEN: "[PC Preview] unknow OPTION_NO_FULLSCREEN" } return inputMethodEngine } \ No newline at end of file From acd75033edcfe6f75562308280bdc42e4cd1e32b Mon Sep 17 00:00:00 2001 From: ma-shaoyin Date: Sat, 16 Jul 2022 18:51:38 +0800 Subject: [PATCH 084/109] Signed-off-by: ma-shaoyin Changes to be committed: --- runtime/main/extend/systemplugin/napi/ohos_inputmethodengine.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/runtime/main/extend/systemplugin/napi/ohos_inputmethodengine.js b/runtime/main/extend/systemplugin/napi/ohos_inputmethodengine.js index d6b55a6e..f7d6c51a 100644 --- a/runtime/main/extend/systemplugin/napi/ohos_inputmethodengine.js +++ b/runtime/main/extend/systemplugin/napi/ohos_inputmethodengine.js @@ -350,7 +350,7 @@ export function mockInputMethodEngine() { const len = args.length if (typeof args[len - 1] === 'function') { if (args[0] == 'keyDown' || args[0] == 'keyUp') { - args[len - 1].call(this, paramMock.paramObjectMock); + args[len - 1].call(this, KeyEvent); } else if (args[0] == 'selectionChange') { args[len - 1].call(this, paramMock.paramNumberMock, paramMock.paramNumberMock, paramMock.paramNumberMock, paramMock.paramNumberMock); } else if (args[0] == 'cursorContextChange') { From f5666bd5f8e4d42e32d396fdf8bafba51dd80c1a Mon Sep 17 00:00:00 2001 From: duanweiling Date: Sat, 16 Jul 2022 18:59:49 +0800 Subject: [PATCH 085/109] =?UTF-8?q?DataShareExtensionAbility=20=E4=BF=AE?= =?UTF-8?q?=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: duanweiling --- ...s_application_DataShareExtensionAbility.js | 120 +++++++++++------- 1 file changed, 77 insertions(+), 43 deletions(-) diff --git a/runtime/main/extend/systemplugin/napi/ohos_application_DataShareExtensionAbility.js b/runtime/main/extend/systemplugin/napi/ohos_application_DataShareExtensionAbility.js index 3b99c79a..47db15f3 100644 --- a/runtime/main/extend/systemplugin/napi/ohos_application_DataShareExtensionAbility.js +++ b/runtime/main/extend/systemplugin/napi/ohos_application_DataShareExtensionAbility.js @@ -23,60 +23,94 @@ export function mockDataShareExtensionAbility() { console.warn('application.DataShareExtensionAbility interface mocked in the Previewer. How this interface works on' + ' the Previewer may be different from that on a real device.'); this.context = new ExtensionContextClass(); - this.onCreate = function () { + this.onCreate = function (...args) { console.warn("application.DataShareExtensionAbility.onCreate interface mocked in the Previewer. How this interface works on the Previewer" + - " may be different from that on a real device.") - }; - this.getFileTypes = function () { + " may be different from that on a real device.") + const len = args.length + if (typeof args[len - 1] === 'function') { + args[len - 1].call(this, paramMock.businessErrorMock) + } + }, + this.getFileTypes = function (...args) { console.warn("application.DataShareExtensionAbility.getFileTypes interface mocked in the Previewer. How this interface works on the Previewer" + - " may be different from that on a real device.") - return [paramMock.paramStringMock]; - }; - this.openFile = function () { + " may be different 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]) + } + }, + this.openFile = function (...args) { console.warn("application.DataShareExtensionAbility.openFile interface mocked in the Previewer. How this interface works on the Previewer" + - " may be different from that on a real device.") - return paramMock.paramNumberMock; - }; - this.insert = function () { + " may be different 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) + } + }, + this.insert = function (...args) { console.warn("application.DataShareExtensionAbility.insert interface mocked in the Previewer. How this interface works on the Previewer" + - " may be different from that on a real device.") - return paramMock.paramNumberMock; - }; - this.update = function () { + " may be different 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) + } + }, + this.update = function (...args) { console.warn("application.DataShareExtensionAbility.update interface mocked in the Previewer. How this interface works on the Previewer" + - " may be different from that on a real device.") - return paramMock.paramNumberMock; - }; - this.delete = function () { + " may be different 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, paramMock.paramNumberMock) + } + }, + this.delete = function (...args) { console.warn("application.DataShareExtensionAbility.delete interface mocked in the Previewer. How this interface works on the Previewer" + - " may be different from that on a real device.") - return paramMock.paramNumberMock; - }; - this.query = function () { + " may be different 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) + } + }, + this.query = function (...args) { console.warn("application.DataShareExtensionAbility.query interface mocked in the Previewer. How this interface works on the Previewer" + - " may be different from that on a real device.") - return DataShareResultSetMock; - }; - this.getType = function () { + " may be different 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) + } + }, + this.getType = function (...args) { console.warn("application.DataShareExtensionAbility.getType interface mocked in the Previewer. How this interface works on the Previewer" + - " may be different from that on a real device.") - return paramMock.paramStringMock; - }; - this.batchInsert = function () { + " may be different 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) + } + }, + this.batchInsert = function (...args) { console.warn("application.DataShareExtensionAbility.batchInsert interface mocked in the Previewer. How this interface works on the Previewer" + - " may be different from that on a real device.") - return paramMock.paramNumberMock; - }; - this.normalizeUri = function () { + " may be different 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) + } + }, + this.normalizeUri = function (...args) { console.warn("application.DataShareExtensionAbility.normalizeUri interface mocked in the Previewer. How this interface works on the Previewer" + - " may be different from that on a real device.") - return paramMock.paramStringMock; - }; - this.denormalizeUri = function () { + " may be different from that on a real device.") + const len = args.length + if (typeof args[len - 1] === 'function') { + args[len - 1].call(this, paramMock.businessErrorMock) + } + }, + this.denormalizeUri = function (...args) { console.warn("application.DataShareExtensionAbility.denormalizeUri interface mocked in the Previewer. How this interface works on the Previewer" + - " may be different from that on a real device.") - return paramMock.paramStringMock; - }; + " may be 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 DataShareExtensionAbilityClass; From 2acb01f913899b0babc9127533b4d8044c769dab Mon Sep 17 00:00:00 2001 From: Your Name Date: Sat, 16 Jul 2022 19:40:34 +0800 Subject: [PATCH 086/109] =?UTF-8?q?uitest=20MockAPI=E6=8E=A5=E5=8F=A3?= =?UTF-8?q?=E5=A2=9E=E5=8A=A0.=20Signed-off-by:=20?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Your Name --- .../extend/systemplugin/napi/ohos_uitest.js | 32 +++++++++---------- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/runtime/main/extend/systemplugin/napi/ohos_uitest.js b/runtime/main/extend/systemplugin/napi/ohos_uitest.js index 736530f7..f5fb094c 100644 --- a/runtime/main/extend/systemplugin/napi/ohos_uitest.js +++ b/runtime/main/extend/systemplugin/napi/ohos_uitest.js @@ -74,63 +74,63 @@ const ByMockClass = class ByMock { console.warn('uitest.By.constructor' + warnMessage); this.id = function(...args) { console.warn('uitest.By.id' + warnMessage) - return new BYMock() + return new ByMock() }; this.text = function(...args) { console.warn('uitest.By.text' + warnMessage) - return new BYMock() + return new ByMock() }; this.key = function(...args) { console.warn('uitest.By.key' + warnMessage) - return new BYMock() + return new ByMock() }; this.type = function(...args) { console.warn('uitest.By.type' + warnMessage) - return new BYMock() + return new ByMock() }; this.enabled = function(...args) { console.warn('uitest.By.enabled' + warnMessage) - return new BYMock() + return new ByMock() }; this.focused = function(...args) { console.warn('uitest.By.focused' + warnMessage) - return new BYMock() + return new ByMock() }; this.selected = function(...args) { console.warn('uitest.By.selected' + warnMessage) - return new BYMock() + return new ByMock() }; this.clickable = function(...args) { console.warn('uitest.By.clickable' + warnMessage) - return new BYMock() + return new ByMock() }; this.enabled = function(...args) { console.warn('uitest.By.enabled' + warnMessage) - return new BYMock() + return new ByMock() }; this.longClickable = function(...args) { console.warn('uitest.By.longClickable' + warnMessage) - return new BYMock() + return new ByMock() }; this.scrollable = function(...args) { console.warn('uitest.By.scrollable' + warnMessage) - return new BYMock() + return new ByMock() }; this.checkable = function(...args) { console.warn('uitest.By.checkable' + warnMessage) - return new BYMock() + return new ByMock() }; this.checked = function(...args) { console.warn('uitest.By.checked' + warnMessage) - return new BYMock() + return new ByMock() }; this.isBefore = function(...args) { console.warn('uitest.By.isBefore' + warnMessage) - return new BYMock() + return new ByMock() }; this.isAfter = function(...args) { console.warn('uitest.By.isAfter' + warnMessage) - return new BYMock() + return new ByMock() }; } } @@ -492,7 +492,7 @@ export function mockUiTest() { Point: PointMockClass, Rect: RectMockClass, WindowFilter: WindowFilterMockClass, - BY: ByMockClass, + BY: new ByMockClass(), UiDriver: UiDriverClass, UiComponent: UiComponentClass, UiWindow: UiWindowClass From 26260a77c934653531fc5a6921456b4dd6d7bb77 Mon Sep 17 00:00:00 2001 From: duanweiling Date: Sat, 16 Jul 2022 20:03:07 +0800 Subject: [PATCH 087/109] =?UTF-8?q?mock=20=E8=AF=84=E8=AE=BA=E4=BF=AE?= =?UTF-8?q?=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: duanweiling --- .../napi/ohos_application_DataShareExtensionAbility.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/runtime/main/extend/systemplugin/napi/ohos_application_DataShareExtensionAbility.js b/runtime/main/extend/systemplugin/napi/ohos_application_DataShareExtensionAbility.js index 47db15f3..69cccc55 100644 --- a/runtime/main/extend/systemplugin/napi/ohos_application_DataShareExtensionAbility.js +++ b/runtime/main/extend/systemplugin/napi/ohos_application_DataShareExtensionAbility.js @@ -60,7 +60,7 @@ export function mockDataShareExtensionAbility() { " may be different 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, paramMock.paramNumberMock) + args[len - 1].call(this, paramMock.businessErrorMock, paramMock.paramNumberMock) } }, this.delete = function (...args) { From 1770385fc2f004a83f11f60676c66175ddc1e0ca Mon Sep 17 00:00:00 2001 From: Your Name Date: Mon, 18 Jul 2022 09:36:12 +0800 Subject: [PATCH 088/109] =?UTF-8?q?uitest=20MockAPI=E6=8E=A5=E5=8F=A3?= =?UTF-8?q?=E5=A2=9E=E5=8A=A0.=20Signed-off-by:=20?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Your Name --- runtime/main/extend/systemplugin/napi/ohos_uitest.js | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/runtime/main/extend/systemplugin/napi/ohos_uitest.js b/runtime/main/extend/systemplugin/napi/ohos_uitest.js index f5fb094c..961ce571 100644 --- a/runtime/main/extend/systemplugin/napi/ohos_uitest.js +++ b/runtime/main/extend/systemplugin/napi/ohos_uitest.js @@ -69,7 +69,7 @@ const WindowFilterMockClass = class WindowFilterMock { } } -const ByMockClass = class ByMock { +const ByClass = class ByMock { constructor() { console.warn('uitest.By.constructor' + warnMessage); this.id = function(...args) { @@ -159,7 +159,7 @@ const UiDriverClass = class UiDriverMock { this.findComponents = function(...args) { console.warn('uitest.UiDriver.findComponents' + warnMessage) return new Promise((resolve) => { - resolve(new UiComponentMock()) + resolve(new Array(new UiComponentMock())) }); }; this.waitForComponent = function(...args) { @@ -232,10 +232,8 @@ const UiDriverClass = class UiDriverMock { } UiDriverClass.create = function () { - this.create = function(...args) { console.warn('uitest.UiDriver.create' + warnMessage) - return new UiDriverMock() - } + return new UiDriverClass() } const UiComponentClass = class UiComponentMock { @@ -492,7 +490,7 @@ export function mockUiTest() { Point: PointMockClass, Rect: RectMockClass, WindowFilter: WindowFilterMockClass, - BY: new ByMockClass(), + BY: new ByClass(), UiDriver: UiDriverClass, UiComponent: UiComponentClass, UiWindow: UiWindowClass From 4475793a31289c325ff5c97ff127c3ec133274e6 Mon Sep 17 00:00:00 2001 From: qiuxiangdong Date: Fri, 15 Jul 2022 09:45:13 +0800 Subject: [PATCH 089/109] fix: lacking the power mock Signed-off-by: qiuxiangdong Change-Id: I4149bc9f8a5bf1ec3ff1f1f839f07356b7739c77 --- .../main/extend/systemplugin/brightness.js | 61 +++++++++++++++++ runtime/main/extend/systemplugin/index.js | 2 + .../main/extend/systemplugin/napi/index.js | 6 +- .../systemplugin/napi/ohos_batteryInfo.js | 68 +++++++++++++------ .../napi/ohos_batteryStatistics.js | 16 ++--- .../systemplugin/napi/ohos_brightness.js | 38 +---------- 6 files changed, 123 insertions(+), 68 deletions(-) create mode 100755 runtime/main/extend/systemplugin/brightness.js diff --git a/runtime/main/extend/systemplugin/brightness.js b/runtime/main/extend/systemplugin/brightness.js new file mode 100755 index 00000000..d8bf446b --- /dev/null +++ b/runtime/main/extend/systemplugin/brightness.js @@ -0,0 +1,61 @@ +/* + * Copyright (c) 2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { hasComplete } from "./utils" + +export function mockBrightness() { + global.systemplugin.brightness = { + argsV: { + value: 80 + }, + argsM: { + mode: 0 + }, + getValue: function (...args) { + console.warn("brightness.getValue interface mocked in the Previewer. How this interface works on the Previewer" + + " may be different from that on a real device.") + args[0].success(this.argsV) + hasComplete(args[0].complete) + }, + setValue: function (...args) { + console.warn("brightness.setValue interface mocked in the Previewer. How this interface works on the Previewer" + + " may be different from that on a real device.") + if (args[0].value) { + this.argsV.value = args[0].value + args[0].success() + hasComplete(args[0].complete) + } + }, + getMode: function (...args) { + console.warn("brightness.getMode interface mocked in the Previewer. How this interface works on the Previewer" + + " may be different from that on a real device.") + args[0].success(this.argsM) + hasComplete(args[0].complete) + }, + setMode: function (...args) { + console.warn("brightness.setMode interface mocked in the Previewer. How this interface works on the Previewer" + + " may be different from that on a real device.") + this.argsM.mode = args[0].mode + args[0].success() + hasComplete(args[0].complete) + }, + setKeepScreenOn: function (...args) { + console.warn("brightness.setKeepScreenOn interface mocked in the Previewer. How this interface works on the" + + " Previewer may be different from that on a real device.") + args[0].success() + hasComplete(args[0].complete) + } + } +} diff --git a/runtime/main/extend/systemplugin/index.js b/runtime/main/extend/systemplugin/index.js index 6bb85b48..08455ecf 100644 --- a/runtime/main/extend/systemplugin/index.js +++ b/runtime/main/extend/systemplugin/index.js @@ -26,6 +26,7 @@ import { import { mockAppAbilityManager } from './ohos/app' import { mockBattery } from './battery' +import { mockBrightness } from './brightness' import { mockOhosBluetooth } from './ohos/bluetooth' import { mockDistributedSchedule } from './distributedSchedule' import { mockFetch } from './fetch' @@ -63,6 +64,7 @@ export function mockSystemPlugin() { mockSensor() mockGeolocation() mockBattery() + mockBrightness() mockSystemPackage() mockFeatureAbility() mockOhosBluetooth() diff --git a/runtime/main/extend/systemplugin/napi/index.js b/runtime/main/extend/systemplugin/napi/index.js index 6f709cac..64be552d 100644 --- a/runtime/main/extend/systemplugin/napi/index.js +++ b/runtime/main/extend/systemplugin/napi/index.js @@ -105,7 +105,7 @@ import { mockMultimediaAudio } from './ohos_multimedia_audio' import { mockMultimediaImage } from './ohos_multimedia_image' import { mockMultimediaMedia } from './ohos_multimedia_media' import { mockMultimediaMediaLibrary } from './ohos_multimedia_mediaLibrary' -import { mockOhosBatteryinfo } from './ohos_batteryInfo' +import { mockBatteryinfo } from './ohos_batteryInfo' import { mockBluetooth } from './ohos_bluetooth' import { mockBrightness } from './ohos_brightness' import { mockBytrace } from './ohos_bytrace' @@ -266,8 +266,8 @@ export function mockRequireNapiFun() { return mockBrightness(); case "bluetooth": return mockBluetooth(); - case "batteryInfo": - return mockOhosBatteryinfo(); + case "batteryinfo": + return mockBatteryinfo(); case "systemParameter": return mockSystemParameter(); case "ability.dataUriUtils": diff --git a/runtime/main/extend/systemplugin/napi/ohos_batteryInfo.js b/runtime/main/extend/systemplugin/napi/ohos_batteryInfo.js index fa2d3348..8c0c9340 100644 --- a/runtime/main/extend/systemplugin/napi/ohos_batteryInfo.js +++ b/runtime/main/extend/systemplugin/napi/ohos_batteryInfo.js @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021 Huawei Device Co., Ltd. + * Copyright (c) 2021-2022 Huawei Device Co., Ltd. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at @@ -13,39 +13,67 @@ * limitations under the License. */ -export function mockOhosBatteryinfo() { +export function mockBatteryinfo() { const BatteryPluggedType = { - NONE: '[PC preview] unknow NONE', - AC: '[PC preview] unknow AC', - USB: '[PC preview] unknow USB', - WIRELESS: '[PC preview] unknow WIRELESS' + NONE: 0, + AC: 1, + USB: 2, + WIRELESS: 3 } const BatteryChargeState = { - NONE: '[PC preview] unknow NONE', - ENABLE: '[PC preview] unknow ENABLE', - DISABLE: '[PC preview] unknow DISABLE', - FULL: '[PC preview] unknow FULL' + NONE: 0, + ENABLE: 1, + DISABLE: 2, + FULL: 3 } 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' + UNKNOWN: 0, + GOOD: 1, + OVERHEAT: 2, + OVERVOLTAGE: 3, + COLD: 4, + DEAD: 5 + } + const BatteryCapacityLevel = { + LEVEL_NONE: 0, + LEVEL_FULL: 1, + LEVEL_HIGH: 2, + LEVEL_NORMAL: 3, + LEVEL_LOW: 4, + LEVEL_CRITICAL: 5 + } + const CommonEventBatteryChangedCode = { + EXTRA_SOC: 0, + EXTRA_VOLTAGE: 1, + EXTRA_TEMPERATURE: 2, + EXTRA_HEALTH_STATE: 3, + EXTRA_PLUGGED_TYPE: 4, + EXTRA_MAX_CURRENT: 5, + EXTRA_MAX_VOLTAGE: 6, + EXTRA_CHARGE_STATE: 7, + EXTRA_CHARGE_COUNTER: 8, + EXTRA_PRESENT: 9, + EXTRA_TECHNOLOGY: 10, } const batteryInfo = { BatteryPluggedType, BatteryChargeState, BatteryHealthState, + BatteryCapacityLevel, + CommonEventBatteryChangedCode, batterySOC: "[PC Preview] unknow batterySOC", - chargingStatus: "[PC Preview] unknow chargingStatus", - healthStatus: "[PC Preview] unknow healthStatus", - pluggedType: "[PC Preview] unknow pluggedType", + chargingStatus: BatteryChargeState, + healthStatus: BatteryHealthState, + pluggedType: BatteryPluggedType, voltage: "[PC Preview] unknow voltage", technology: "[PC Preview] unknow technology", batteryTemperature: "[PC Preview] unknow batteryTemperature", - isBatteryPresent: "[PC Preview] unknow isBatteryPresent" + isBatteryPresent: "[PC Preview] unknow isBatteryPresent", + batteryCapacityLevel: BatteryCapacityLevel, + estimatedRemainingChargeTime: "[PC Preview] unknow estimatedRemainingChargeTime", + totalEnergy: "[PC Preview] unknow totalEnergy", + nowCurrent: "[PC Preview] unknow nowCurrent", + remainingEnergy: "[PC Preview] unknow remainingEnergy" } return batteryInfo } diff --git a/runtime/main/extend/systemplugin/napi/ohos_batteryStatistics.js b/runtime/main/extend/systemplugin/napi/ohos_batteryStatistics.js index 7e771254..41ac82b0 100644 --- a/runtime/main/extend/systemplugin/napi/ohos_batteryStatistics.js +++ b/runtime/main/extend/systemplugin/napi/ohos_batteryStatistics.js @@ -29,14 +29,14 @@ export function mockBatteryStatistics() { } const BatteryStatsInfo = { uid: '[PC preview] unknow uid', - type: '[PC preview] unknow type', + type: ConsumptionType, power: '[PC preview] unknow power', } - const batteryStatistics = { + const batteryStats = { ConsumptionType, BatteryStatsInfo, getBatteryStats: function (...args) { - console.warn("batteryStatistics.getBatteryStats interface mocked in the Previewer. How this interface works on the" + + console.warn("batteryStats.getBatteryStats interface mocked in the Previewer. How this interface works on the" + " Previewer may be different from that on a real device.") var batteryStatsInfos = new Array(BatteryStatsInfo) const len = args.length @@ -49,27 +49,27 @@ export function mockBatteryStatistics() { } }, getAppPowerValue: function (...args) { - console.warn("batteryStatistics.getAppPowerValue interface mocked in the Previewer. How this interface works on the" + + console.warn("batteryStats.getAppPowerValue interface mocked in the Previewer. How this interface works on the" + " Previewer may be different from that on a real device.") return paramMock.paramNumberMock; }, getAppPowerPercent: function (...args) { - console.warn("batteryStatistics.getAppPowerPercent interface mocked in the Previewer. How this interface works on the" + + console.warn("batteryStats.getAppPowerPercent interface mocked in the Previewer. How this interface works on the" + " Previewer may be different from that on a real device.") return paramMock.paramNumberMock; }, getHardwareUnitPowerValue: function (...args) { - console.warn("batteryStatistics.getHardwareUnitPowerValue interface mocked in the Previewer. How this interface works on the" + + console.warn("batteryStats.getHardwareUnitPowerValue interface mocked in the Previewer. How this interface works on the" + " Previewer may be different from that on a real device.") return paramMock.paramNumberMock; }, getHardwareUnitPowerPercent: function (...args) { - console.warn("batteryStatistics.getHardwareUnitPowerPercent interface mocked in the Previewer. How this interface works on the" + + console.warn("batteryStats.getHardwareUnitPowerPercent interface mocked in the Previewer. How this interface works on the" + " Previewer may be different from that on a real device.") return paramMock.paramNumberMock; } } - return batteryStatistics + return batteryStats } \ No newline at end of file diff --git a/runtime/main/extend/systemplugin/napi/ohos_brightness.js b/runtime/main/extend/systemplugin/napi/ohos_brightness.js index f2aaea3b..37e2fa58 100644 --- a/runtime/main/extend/systemplugin/napi/ohos_brightness.js +++ b/runtime/main/extend/systemplugin/napi/ohos_brightness.js @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021 Huawei Device Co., Ltd. + * Copyright (c) 2021-2022 Huawei Device Co., Ltd. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at @@ -17,45 +17,9 @@ import { hasComplete } from "../utils" export function mockBrightness() { const brightness = { - argsV: { - value: 80 - }, - argsM: { - mode: 0 - }, - getValue: function (...args) { - console.warn("brightness.getValue interface mocked in the Previewer. How this interface works on the Previewer" + - " may be different from that on a real device.") - args[0].success(this.argsV) - hasComplete(args[0].complete) - }, setValue: function (...args) { console.warn("brightness.setValue interface mocked in the Previewer. How this interface works on the Previewer" + " may be different from that on a real device.") - if (args[0].value) { - this.argsV.value = args[0].value - args[0].success("brightness setValue successfully") - hasComplete(args[0].complete) - } - }, - getMode: function (...args) { - console.warn("brightness.getMode interface mocked in the Previewer. How this interface works on the Previewer" + - " may be different from that on a real device.") - args[0].success(this.argsM) - hasComplete(args[0].complete) - }, - setMode: function (...args) { - console.warn("brightness.setMode interface mocked in the Previewer. How this interface works on the Previewer" + - " may be different from that on a real device.") - this.argsM.mode = args[0].mode - args[0].success("brightness setMode successfully") - hasComplete(args[0].complete) - }, - setKeepScreenOn: function (...args) { - console.warn("brightness.setKeepScreenOn interface mocked in the Previewer. How this interface works on the" + - " Previewer may be different from that on a real device.") - args[0].success("brightness setKeepScreenOn successfully") - hasComplete(args[0].complete) } } return brightness From 28a48d84a48ac25b762c51b4579b67a3202388ff Mon Sep 17 00:00:00 2001 From: liuyanzhi Date: Mon, 18 Jul 2022 09:40:00 +0800 Subject: [PATCH 090/109] add notification Signed-off-by: liuyanzhi Change-Id: I06b56ee3a883a55c566b954b6b63da76bbd6f1d7 --- .../napi/notification/notificationRequest.js | 2 +- .../systemplugin/napi/ohos_commonEvent.js | 1 + .../napi/wantAgent/triggerInfo.js | 21 ++++++++++++++++ .../napi/wantAgent/wantAgentInfo.js | 24 +++++++++++++++++++ 4 files changed, 47 insertions(+), 1 deletion(-) create mode 100644 runtime/main/extend/systemplugin/napi/wantAgent/triggerInfo.js create mode 100644 runtime/main/extend/systemplugin/napi/wantAgent/wantAgentInfo.js diff --git a/runtime/main/extend/systemplugin/napi/notification/notificationRequest.js b/runtime/main/extend/systemplugin/napi/notification/notificationRequest.js index 4507b3d6..ccb0bb7b 100644 --- a/runtime/main/extend/systemplugin/napi/notification/notificationRequest.js +++ b/runtime/main/extend/systemplugin/napi/notification/notificationRequest.js @@ -50,7 +50,7 @@ export const NotificationRequest = { creatorUserId: '[PC preview] unknow creatorUserId', classification: '[PC preview] unknow classification', hashCode: '[PC preview] unknow hashCode', - isRemveAllowd: '[PC preview] unknow isRemveAllowd', + isRemoveAllowed: '[PC preview] unknow isRemveAllowd', source: '[PC preview] unknow source', template: NotificationTemplate, distributedOption: DistributedOptions, diff --git a/runtime/main/extend/systemplugin/napi/ohos_commonEvent.js b/runtime/main/extend/systemplugin/napi/ohos_commonEvent.js index 0c08af9b..9dbe65dd 100644 --- a/runtime/main/extend/systemplugin/napi/ohos_commonEvent.js +++ b/runtime/main/extend/systemplugin/napi/ohos_commonEvent.js @@ -44,6 +44,7 @@ export const Support = { COMMON_EVENT_PACKAGE_CHANGED: "usual.event.PACKAGE_CHANGED", COMMON_EVENT_PACKAGE_RESTARTED: "usual.event.PACKAGE_RESTARTED", COMMON_EVENT_PACKAGE_DATA_CLEARED: "usual.event.PACKAGE_DATA_CLEARED", + COMMON_EVENT_PACKAGE_CACHE_CLEARED: "usual.event.PACKAGE_CACHE_CLEARED", COMMON_EVENT_PACKAGES_SUSPENDED: "usual.event.PACKAGES_SUSPENDED", COMMON_EVENT_PACKAGES_UNSUSPENDED: "usual.event.PACKAGES_UNSUSPENDED", COMMON_EVENT_MY_PACKAGE_SUSPENDED: "usual.event.MY_PACKAGE_SUSPENDED", diff --git a/runtime/main/extend/systemplugin/napi/wantAgent/triggerInfo.js b/runtime/main/extend/systemplugin/napi/wantAgent/triggerInfo.js new file mode 100644 index 00000000..d3acf68f --- /dev/null +++ b/runtime/main/extend/systemplugin/napi/wantAgent/triggerInfo.js @@ -0,0 +1,21 @@ +/* + * Copyright (c) 2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import { WantClass } from "../ohos_application_Want" +export const TriggerInfo = { + code: '[PC preview] unknow code', + want: new WantClass(), + permission: '[PC preview] unknow permission', + extraInfo: {}, +}; \ No newline at end of file diff --git a/runtime/main/extend/systemplugin/napi/wantAgent/wantAgentInfo.js b/runtime/main/extend/systemplugin/napi/wantAgent/wantAgentInfo.js new file mode 100644 index 00000000..c0e91b07 --- /dev/null +++ b/runtime/main/extend/systemplugin/napi/wantAgent/wantAgentInfo.js @@ -0,0 +1,24 @@ +/* + * Copyright (c) 2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import { WantClass } from "../ohos_application_Want" +import { OperationType, WantAgentFlags } from "../ohos_wantAgent" + +export const WantAgentInfo = { + wants: [new WantClass()], + operationType: OperationType, + requestCode: '[PC preview] unknow requestCode', + wantAgentFlags: [WantAgentFlags], + extraInfo: {}, +}; \ No newline at end of file From e0244cd308ba8a603e8bac963ee610b838f3a0e3 Mon Sep 17 00:00:00 2001 From: Your Name Date: Mon, 18 Jul 2022 10:48:36 +0800 Subject: [PATCH 091/109] =?UTF-8?q?uitest=20MockAPI=E6=8E=A5=E5=8F=A3?= =?UTF-8?q?=E5=A2=9E=E5=8A=A0.=20Signed-off-by:=20?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Your Name --- .../extend/systemplugin/napi/ohos_uitest.js | 72 +++++++++---------- 1 file changed, 36 insertions(+), 36 deletions(-) diff --git a/runtime/main/extend/systemplugin/napi/ohos_uitest.js b/runtime/main/extend/systemplugin/napi/ohos_uitest.js index 961ce571..780032c0 100644 --- a/runtime/main/extend/systemplugin/napi/ohos_uitest.js +++ b/runtime/main/extend/systemplugin/napi/ohos_uitest.js @@ -19,7 +19,7 @@ const warnMessage = ' interface mocked in the Previewer. How this interface works on the' + ' Previewer may be different from that on a real device.' -export const ResizeDirectionMock = { +export const ResizeDirection = { LEFT: 0, RIGHT: 1, UP: 2, @@ -30,28 +30,28 @@ export const ResizeDirectionMock = { RIGHT_DOWN: 7 } -export const MatchPatternMock = { +export const MatchPattern = { EQUALS: 0, CONTAINS: 1, STARTS_WITH: 2, ENDS_WITH: 3 } -export const WindowModeMock = { +export const WindowMode = { FULLSCREEN: 0, PRIMARY: 1, SECONDARY: 2, FLOATING: 3 } -const PointMockClass = class PointMock { +export const Point = { constructor() { X: '[PC Preview] unknown X'; Y: '[PC Preview] unknown Y'; } } -const RectMockClass = class RectMock { +export const Rect = { constructor() { leftX: '[PC Preview] unknown leftX'; topY: '[PC Preview] unknown topY'; @@ -60,7 +60,7 @@ const RectMockClass = class RectMock { } } -const WindowFilterMockClass = class WindowFilterMock { +export const WindowFilter = { constructor() { bundleName: '[PC Preview] unknown bundleName'; title: '[PC Preview] unknown title'; @@ -74,63 +74,63 @@ const ByClass = class ByMock { console.warn('uitest.By.constructor' + warnMessage); this.id = function(...args) { console.warn('uitest.By.id' + warnMessage) - return new ByMock() + return new ByClass() }; this.text = function(...args) { console.warn('uitest.By.text' + warnMessage) - return new ByMock() + return new ByClass() }; this.key = function(...args) { console.warn('uitest.By.key' + warnMessage) - return new ByMock() + return new ByClass() }; this.type = function(...args) { console.warn('uitest.By.type' + warnMessage) - return new ByMock() + return new ByClass() }; this.enabled = function(...args) { console.warn('uitest.By.enabled' + warnMessage) - return new ByMock() + return new ByClass() }; this.focused = function(...args) { console.warn('uitest.By.focused' + warnMessage) - return new ByMock() + return new ByClass() }; this.selected = function(...args) { console.warn('uitest.By.selected' + warnMessage) - return new ByMock() + return new ByClass() }; this.clickable = function(...args) { console.warn('uitest.By.clickable' + warnMessage) - return new ByMock() + return new ByClass() }; this.enabled = function(...args) { console.warn('uitest.By.enabled' + warnMessage) - return new ByMock() + return new ByClass() }; this.longClickable = function(...args) { console.warn('uitest.By.longClickable' + warnMessage) - return new ByMock() + return new ByClass() }; this.scrollable = function(...args) { console.warn('uitest.By.scrollable' + warnMessage) - return new ByMock() + return new ByClass() }; this.checkable = function(...args) { console.warn('uitest.By.checkable' + warnMessage) - return new ByMock() + return new ByClass() }; this.checked = function(...args) { console.warn('uitest.By.checked' + warnMessage) - return new ByMock() + return new ByClass() }; this.isBefore = function(...args) { console.warn('uitest.By.isBefore' + warnMessage) - return new ByMock() + return new ByClass() }; this.isAfter = function(...args) { console.warn('uitest.By.isAfter' + warnMessage) - return new ByMock() + return new ByClass() }; } } @@ -147,25 +147,25 @@ const UiDriverClass = class UiDriverMock { this.findComponent = function(...args) { console.warn('uitest.UiDriver.findComponent' + warnMessage) return new Promise((resolve) => { - resolve(new UiComponentMock()) + resolve(new UiComponentClass()) }); }; this.findWindow = function(...args) { console.warn('uitest.UiDriver.findWindow' + warnMessage) return new Promise((resolve) => { - resolve(new UiWindowMock()) + resolve(new UiWindowClass()) }); }; this.findComponents = function(...args) { console.warn('uitest.UiDriver.findComponents' + warnMessage) return new Promise((resolve) => { - resolve(new Array(new UiComponentMock())) + resolve(new Array(new UiComponentClass())) }); }; this.waitForComponent = function(...args) { console.warn('uitest.UiDriver.waitForComponent' + warnMessage) return new Promise((resolve) => { - resolve(new UiComponentMock()) + resolve(new UiComponentClass()) }); }; this.screenCap = function(...args) { @@ -314,13 +314,13 @@ const UiComponentClass = class UiComponentMock { this.getBounds = function(...args) { console.warn('uitest.UiComponent.getBounds.warn' + warnMessage) return new Promise((resolve) => { - resolve(RectMock) + resolve(Rect) }); }; this.getBoundsCenter = function(...args) { console.warn('uitest.UiComponent.getBoundsCenter.warn' + warnMessage) return new Promise((resolve) => { - resolve(PointMock) + resolve(Point) }); }; this.click = function(...args) { @@ -368,7 +368,7 @@ const UiComponentClass = class UiComponentMock { this.scrollSearch = function(...args) { console.warn('uitest.UiComponent.scrollSearch.warn' + warnMessage) return new Promise((resolve) => { - resolve(new UiComponentMock()) + resolve(new UiComponentClass()) }); }; this.dragTo = function(...args) { @@ -404,7 +404,7 @@ const UiWindowClass = class UiWindowMock { this.getBounds = function(...args) { console.warn('uitest.UiWindowMock.getBounds.warn' + warnMessage) return new Promise((resolve) => { - resolve(RectMock) + resolve(Rect) }); }; this.getTitle = function(...args) { @@ -416,7 +416,7 @@ const UiWindowClass = class UiWindowMock { this.getWindowMode = function(...args) { console.warn('uitest.UiWindowMock.getWindowMode.warn' + warnMessage) return new Promise((resolve) => { - resolve(WindowModeMock) + resolve(WindowMode) }); }; this.isFocused = function(...args) { @@ -484,12 +484,12 @@ const UiWindowClass = class UiWindowMock { export function mockUiTest() { const module = { - ResizeDirection: ResizeDirectionMock, - MatchPattern: MatchPatternMock, - WindowMode: WindowModeMock, - Point: PointMockClass, - Rect: RectMockClass, - WindowFilter: WindowFilterMockClass, + ResizeDirection: ResizeDirection, + MatchPattern: MatchPattern, + WindowMode: WindowMode, + Point: Point, + Rect: Rect, + WindowFilter: WindowFilter, BY: new ByClass(), UiDriver: UiDriverClass, UiComponent: UiComponentClass, From a48eadad3eae9f8e583400218c1f98e70195c1ce Mon Sep 17 00:00:00 2001 From: hwx1119949 <3052854011@qq.com> Date: Mon, 18 Jul 2022 11:04:26 +0800 Subject: [PATCH 092/109] delete mediaquery mock Signed-off-by: hwx1119949 <3052854011@qq.com> Change-Id: I42734678272bbb0a2856408eb4a24737dddb825d --- .../main/extend/systemplugin/napi/index.js | 3 -- .../systemplugin/napi/ohos_mediaquery.js | 40 ------------------- 2 files changed, 43 deletions(-) delete mode 100644 runtime/main/extend/systemplugin/napi/ohos_mediaquery.js diff --git a/runtime/main/extend/systemplugin/napi/index.js b/runtime/main/extend/systemplugin/napi/index.js index 676e452e..e2f4d589 100644 --- a/runtime/main/extend/systemplugin/napi/index.js +++ b/runtime/main/extend/systemplugin/napi/index.js @@ -150,7 +150,6 @@ import { mockScreen } from './ohos_screen' import { mockDistributedBundle } from './ohos_distributedBundle' import { mockInputConsumer } from './ohos_multimodalInput_inputConsumer' import { mockDocument } from './ohos_document' -import { mockMediaQuery } from './ohos_mediaquery' import { mockResourceManager } from './ohos_resourceManager' import { mockFile } from './system_file' import { mockEnterpriseDeviceManager } from './ohos_enterpriseDeviceManager' @@ -172,8 +171,6 @@ export function mockRequireNapiFun() { return mockUiAppearance(); case "resourceManager": return mockResourceManager(); - case "mediaquery": - return mockMediaQuery(); case "document": return mockDocument(); case "screen": diff --git a/runtime/main/extend/systemplugin/napi/ohos_mediaquery.js b/runtime/main/extend/systemplugin/napi/ohos_mediaquery.js deleted file mode 100644 index 2045071f..00000000 --- a/runtime/main/extend/systemplugin/napi/ohos_mediaquery.js +++ /dev/null @@ -1,40 +0,0 @@ -/* - * Copyright (c) 2021 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -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 -} \ No newline at end of file From 528a60ff6c6cfab67ac28f4f9be8c05d6c3cb4db Mon Sep 17 00:00:00 2001 From: Your Name Date: Mon, 18 Jul 2022 14:23:07 +0800 Subject: [PATCH 093/109] =?UTF-8?q?uitest=20MockAPI=E6=8E=A5=E5=8F=A3?= =?UTF-8?q?=E5=A2=9E=E5=8A=A0.=20Signed-off-by:=20?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Your Name --- .../extend/systemplugin/napi/ohos_uitest.js | 78 +++++++++---------- 1 file changed, 39 insertions(+), 39 deletions(-) diff --git a/runtime/main/extend/systemplugin/napi/ohos_uitest.js b/runtime/main/extend/systemplugin/napi/ohos_uitest.js index 780032c0..a7e236f8 100644 --- a/runtime/main/extend/systemplugin/napi/ohos_uitest.js +++ b/runtime/main/extend/systemplugin/napi/ohos_uitest.js @@ -240,151 +240,151 @@ const UiComponentClass = class UiComponentMock { constructor() { console.warn('uitest.UiComponent.constructor' + warnMessage); this.getId = function(...args) { - console.warn('uitest.UiComponent.getId.warn' + warnMessage) + console.warn('uitest.UiComponent.getId' + warnMessage) return new Promise((resolve) => { resolve(paramMock.paramNumberMock) }); }; this.getText = function(...args) { - console.warn('uitest.UiComponent.getText.warn' + warnMessage) + console.warn('uitest.UiComponent.getText' + warnMessage) return new Promise((resolve) => { resolve(paramMock.paramStringMock) }); }; this.getKey = function(...args) { - console.warn('uitest.UiComponent.getKey.warn' + warnMessage) + console.warn('uitest.UiComponent.getKey' + warnMessage) return new Promise((resolve) => { resolve(paramMock.paramStringMock) }); }; this.getType = function(...args) { - console.warn('uitest.UiComponent.getType.warn' + warnMessage) + console.warn('uitest.UiComponent.getType' + warnMessage) return new Promise((resolve) => { resolve(paramMock.paramStringMock) }); }; this.isEnabled = function(...args) { - console.warn('uitest.UiComponent.isEnabled.warn' + warnMessage) + console.warn('uitest.UiComponent.isEnabled' + warnMessage) return new Promise((resolve) => { resolve(paramMock.paramBoolMock) }); }; this.isFocused = function(...args) { - console.warn('uitest.UiComponent.isFocused.warn' + warnMessage) + console.warn('uitest.UiComponent.isFocused' + warnMessage) return new Promise((resolve) => { resolve(paramMock.paramBoolMock) }); }; this.isSelected = function(...args) { - console.warn('uitest.UiComponent.isSelected.warn' + warnMessage) + console.warn('uitest.UiComponent.isSelected' + warnMessage) return new Promise((resolve) => { resolve(paramMock.paramBoolMock) }); }; this.isClickable = function(...args) { - console.warn('uitest.UiComponent.isClickable.warn' + warnMessage) + console.warn('uitest.UiComponent.isClickable' + warnMessage) return new Promise((resolve) => { resolve(paramMock.paramBoolMock) }); }; this.isLongClickable = function(...args) { - console.warn('uitest.UiComponent.isLongClickable.warn' + warnMessage) + console.warn('uitest.UiComponent.isLongClickable' + warnMessage) return new Promise((resolve) => { resolve(paramMock.paramBoolMock) }); }; this.isScrollable = function(...args) { - console.warn('uitest.UiComponent.isScrollable.warn' + warnMessage) + console.warn('uitest.UiComponent.isScrollable' + warnMessage) return new Promise((resolve) => { resolve(paramMock.paramBoolMock) }); }; this.isCheckable = function(...args) { - console.warn('uitest.UiComponent.isCheckable.warn' + warnMessage) + console.warn('uitest.UiComponent.isCheckable' + warnMessage) return new Promise((resolve) => { resolve(paramMock.paramBoolMock) }); }; this.isChecked = function(...args) { - console.warn('uitest.UiComponent.isChecked.warn' + warnMessage) + console.warn('uitest.UiComponent.isChecked' + warnMessage) return new Promise((resolve) => { resolve(paramMock.paramBoolMock) }); }; this.getBounds = function(...args) { - console.warn('uitest.UiComponent.getBounds.warn' + warnMessage) + console.warn('uitest.UiComponent.getBounds' + warnMessage) return new Promise((resolve) => { resolve(Rect) }); }; this.getBoundsCenter = function(...args) { - console.warn('uitest.UiComponent.getBoundsCenter.warn' + warnMessage) + console.warn('uitest.UiComponent.getBoundsCenter' + warnMessage) return new Promise((resolve) => { resolve(Point) }); }; this.click = function(...args) { - console.warn('uitest.UiComponent.click.warn' + warnMessage) + console.warn('uitest.UiComponent.click' + warnMessage) return new Promise((resolve) => { resolve() }); }; this.longClick = function(...args) { - console.warn('uitest.UiComponent.longClick.warn' + warnMessage) + console.warn('uitest.UiComponent.longClick' + warnMessage) return new Promise((resolve) => { resolve() }); }; this.doubleClick = function(...args) { - console.warn('uitest.UiComponent.doubleClick.warn' + warnMessage) + console.warn('uitest.UiComponent.doubleClick' + warnMessage) return new Promise((resolve) => { resolve() }); }; this.scrollToTop = function(...args) { - console.warn('uitest.UiComponent.scrollToTop.warn' + warnMessage) + console.warn('uitest.UiComponent.scrollToTop' + warnMessage) return new Promise((resolve) => { resolve() }); }; this.scrollToBottom = function(...args) { - console.warn('uitest.UiComponent.scrollToBottom.warn' + warnMessage) + console.warn('uitest.UiComponent.scrollToBottom' + warnMessage) return new Promise((resolve) => { resolve() }); }; this.inputText = function(...args) { - console.warn('uitest.UiComponent.inputText.warn' + warnMessage) + console.warn('uitest.UiComponent.inputText' + warnMessage) return new Promise((resolve) => { resolve() }); }; this.clearText = function(...args) { - console.warn('uitest.UiComponent.clearText.warn' + warnMessage) + console.warn('uitest.UiComponent.clearText' + warnMessage) return new Promise((resolve) => { resolve() }); }; this.scrollSearch = function(...args) { - console.warn('uitest.UiComponent.scrollSearch.warn' + warnMessage) + console.warn('uitest.UiComponent.scrollSearch' + warnMessage) return new Promise((resolve) => { resolve(new UiComponentClass()) }); }; this.dragTo = function(...args) { - console.warn('uitest.UiComponent.dragTo.warn' + warnMessage) + console.warn('uitest.UiComponent.dragTo' + warnMessage) return new Promise((resolve) => { resolve() }); }; this.pinchOut = function(...args) { - console.warn('uitest.UiComponent.pinchOut.warn' + warnMessage) + console.warn('uitest.UiComponent.pinchOut' + warnMessage) return new Promise((resolve) => { resolve() }); }; this.pinchIn = function(...args) { - console.warn('uitest.UiComponent.pinchIn.warn' + warnMessage) + console.warn('uitest.UiComponent.pinchIn' + warnMessage) return new Promise((resolve) => { resolve() }); @@ -396,85 +396,85 @@ const UiWindowClass = class UiWindowMock { constructor() { console.warn('uitest.UiWindowMock.constructor' + warnMessage); this.getBundleName = function(...args) { - console.warn('uitest.UiWindowMock.getBundleName.warn' + warnMessage) + console.warn('uitest.UiWindowMock.getBundleName' + warnMessage) return new Promise((resolve) => { resolve(paramMock.paramStringMock) }); }; this.getBounds = function(...args) { - console.warn('uitest.UiWindowMock.getBounds.warn' + warnMessage) + console.warn('uitest.UiWindowMock.getBounds' + warnMessage) return new Promise((resolve) => { resolve(Rect) }); }; this.getTitle = function(...args) { - console.warn('uitest.UiWindowMock.getTitle.warn' + warnMessage) + console.warn('uitest.UiWindowMock.getTitle' + warnMessage) return new Promise((resolve) => { resolve(paramMock.paramStringMock) }); }; this.getWindowMode = function(...args) { - console.warn('uitest.UiWindowMock.getWindowMode.warn' + warnMessage) + console.warn('uitest.UiWindowMock.getWindowMode' + warnMessage) return new Promise((resolve) => { resolve(WindowMode) }); }; this.isFocused = function(...args) { - console.warn('uitest.UiWindowMock.isFocused.warn' + warnMessage) + console.warn('uitest.UiWindowMock.isFocused' + warnMessage) return new Promise((resolve) => { resolve(paramMock.paramBoolMock) }); }; this.isActived = function(...args) { - console.warn('uitest.UiWindowMock.isActived.warn' + warnMessage) + console.warn('uitest.UiWindowMock.isActived' + warnMessage) return new Promise((resolve) => { resolve(paramMock.paramBoolMock) }); }; this.focuse = function(...args) { - console.warn('uitest.UiWindowMock.focuse.warn' + warnMessage) + console.warn('uitest.UiWindowMock.focuse' + warnMessage) return new Promise((resolve) => { resolve(paramMock.paramBoolMock) }); }; this.moveTo = function(...args) { - console.warn('uitest.UiWindowMock.moveTo.warn' + warnMessage) + console.warn('uitest.UiWindowMock.moveTo' + warnMessage) return new Promise((resolve) => { resolve(paramMock.paramBoolMock) }); }; this.resize = function(...args) { - console.warn('uitest.UiWindowMock.resize.warn' + warnMessage) + console.warn('uitest.UiWindowMock.resize' + warnMessage) return new Promise((resolve) => { resolve(paramMock.paramBoolMock) }); }; this.split = function(...args) { - console.warn('uitest.UiWindowMock.split.warn' + warnMessage) + console.warn('uitest.UiWindowMock.split' + warnMessage) return new Promise((resolve) => { resolve(paramMock.paramBoolMock) }); }; this.maximize = function(...args) { - console.warn('uitest.UiWindowMock.maximize.warn' + warnMessage) + console.warn('uitest.UiWindowMock.maximize' + warnMessage) return new Promise((resolve) => { resolve(paramMock.paramBoolMock) }); }; this.resume = function(...args) { - console.warn('uitest.UiWindowMock.resume.warn' + warnMessage) + console.warn('uitest.UiWindowMock.resume' + warnMessage) return new Promise((resolve) => { resolve(paramMock.paramBoolMock) }); }; this.minimize = function(...args) { - console.warn('uitest.UiWindowMock.minimize.warn' + warnMessage) + console.warn('uitest.UiWindowMock.minimize' + warnMessage) return new Promise((resolve) => { resolve(paramMock.paramBoolMock) }); }; this.close = function(...args) { - console.warn('uitest.UiWindowMock.close.warn' + warnMessage) + console.warn('uitest.UiWindowMock.close' + warnMessage) return new Promise((resolve) => { resolve(paramMock.paramBoolMock) }); From ba4e7501ac5fc59093074f1ff8051d04d804a03c Mon Sep 17 00:00:00 2001 From: duanweiling Date: Mon, 18 Jul 2022 15:30:39 +0800 Subject: [PATCH 094/109] =?UTF-8?q?mock=20=E6=95=B4=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: duanweiling --- .../extend/systemplugin/napi/ohos_data_dataSharePredicates.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/runtime/main/extend/systemplugin/napi/ohos_data_dataSharePredicates.js b/runtime/main/extend/systemplugin/napi/ohos_data_dataSharePredicates.js index 7febfb95..a803141b 100644 --- a/runtime/main/extend/systemplugin/napi/ohos_data_dataSharePredicates.js +++ b/runtime/main/extend/systemplugin/napi/ohos_data_dataSharePredicates.js @@ -15,7 +15,7 @@ import { paramMock } from "../utils" export function mockDataSharePredicates() { - const DataSharePredicatesClass = class DataSharePredicate { + const DataSharePredicatesClass = class DataSharePredicates { constructor() { this.equalTo = function (...args) { console.warn("DataSharePredicates.equalTo interface mocked in the Previewer. How this interface works on the" + From 2711b1b6e89b70a7252b30ec7c19fec9026971e0 Mon Sep 17 00:00:00 2001 From: ma-shaoyin Date: Mon, 18 Jul 2022 15:55:02 +0800 Subject: [PATCH 095/109] Signed-off-by: ma-shaoyin Changes to be committed: --- .../main/extend/systemplugin/napi/ohos_inputmethodengine.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/runtime/main/extend/systemplugin/napi/ohos_inputmethodengine.js b/runtime/main/extend/systemplugin/napi/ohos_inputmethodengine.js index f7d6c51a..d7722b82 100644 --- a/runtime/main/extend/systemplugin/napi/ohos_inputmethodengine.js +++ b/runtime/main/extend/systemplugin/napi/ohos_inputmethodengine.js @@ -36,8 +36,8 @@ export function mockInputMethodEngine() { inputOption: 3 } const KeyEvent = { - keyCode: 1, - keyAction: 2, + keyCode: "[PC Preview] unknow keyCode", + keyAction: "[PC Preview] unknow keyAction" } const RichContent = { contentURI: "[PC Preview] unknow contentURI", From 4e75350066001a2c465e7c5b41a8738eee484cfb Mon Sep 17 00:00:00 2001 From: PaDaBoo Date: Mon, 18 Jul 2022 15:55:38 +0800 Subject: [PATCH 096/109] update Storage mock file Signed-off-by: PaDaBoo --- .../systemplugin/napi/ohos_data_Storage.js | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/runtime/main/extend/systemplugin/napi/ohos_data_Storage.js b/runtime/main/extend/systemplugin/napi/ohos_data_Storage.js index 23aa2fc2..53f373b3 100644 --- a/runtime/main/extend/systemplugin/napi/ohos_data_Storage.js +++ b/runtime/main/extend/systemplugin/napi/ohos_data_Storage.js @@ -15,6 +15,17 @@ import { paramMock } from "../utils" +const ValueTypes = { + unknow: '[PC Preview] unknow value type' +}; + +const StorageObserverMock = { + key: '[PC Preview] unknown key' +}; +const MAX_KEY_LENGTH = 80; + +const MAX_VALUE_LENGTH = 8192; + export function mockDataStorage() { const storage = { storageMock, @@ -72,17 +83,17 @@ export function mockDataStorage() { getSync: function () { console.warn("Storage.getSync interface mocked in the Previewer. How this interface works on the Previewer may" + " be different from that on a real device.") - return paramValueTypeMock + return ValueTypes.unknow }, get: function (...args) { console.warn("Storage.get interface mocked in the Previewer. How this interface works on the Previewer may be" + " different from that on a real device.") const len = args.length if (typeof args[len - 1] === 'function') { - args[len - 1].call(this, paramMock.businessErrorMock, paramValueTypeMock) + args[len - 1].call(this, paramMock.businessErrorMock, ValueTypes.unknow) } else { return new Promise((resolve) => { - resolve(paramValueTypeMock) + resolve(ValueTypes.unknow) }) } }, @@ -171,7 +182,7 @@ export function mockDataStorage() { console.warn("Storage.on interface mocked in the Previewer. How this interface works on the Previewer may be" + " different from that on a real device.") const len = args.length - args[len - 1].call(this, storageObserverMock) + args[len - 1].call(this, StorageObserverMock) }, off: function (...args) { console.warn("Storage.off interface mocked in the Previewer. How this interface works on the Previewer may be" + From fe66bf7d0bc3d9f1e808f6cbafd14df22b19cad1 Mon Sep 17 00:00:00 2001 From: Your Name Date: Mon, 18 Jul 2022 15:59:30 +0800 Subject: [PATCH 097/109] =?UTF-8?q?uitest=20MockAPI=E6=8E=A5=E5=8F=A3?= =?UTF-8?q?=E5=A2=9E=E5=8A=A0.=20Signed-off-by:=20?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Your Name --- runtime/main/extend/systemplugin/napi/ohos_uitest.js | 6 ------ 1 file changed, 6 deletions(-) diff --git a/runtime/main/extend/systemplugin/napi/ohos_uitest.js b/runtime/main/extend/systemplugin/napi/ohos_uitest.js index a7e236f8..738af166 100644 --- a/runtime/main/extend/systemplugin/napi/ohos_uitest.js +++ b/runtime/main/extend/systemplugin/napi/ohos_uitest.js @@ -45,28 +45,22 @@ export const WindowMode = { } export const Point = { - constructor() { X: '[PC Preview] unknown X'; Y: '[PC Preview] unknown Y'; - } } export const Rect = { - constructor() { leftX: '[PC Preview] unknown leftX'; topY: '[PC Preview] unknown topY'; rightX: '[PC Preview] unknown rightX'; bottomY: '[PC Preview] unknown bottomY'; - } } export const WindowFilter = { - constructor() { bundleName: '[PC Preview] unknown bundleName'; title: '[PC Preview] unknown title'; focused: '[PC Preview] unknown focused'; actived: '[PC Preview] unknown actived'; - } } const ByClass = class ByMock { From d698d8aee19bb72566c57d4ff7874fa11756ca1d Mon Sep 17 00:00:00 2001 From: PaDaBoo Date: Mon, 18 Jul 2022 16:45:01 +0800 Subject: [PATCH 098/109] update Storage mock file Signed-off-by: PaDaBoo --- .../systemplugin/napi/ohos_data_Storage.js | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/runtime/main/extend/systemplugin/napi/ohos_data_Storage.js b/runtime/main/extend/systemplugin/napi/ohos_data_Storage.js index 53f373b3..36977af0 100644 --- a/runtime/main/extend/systemplugin/napi/ohos_data_Storage.js +++ b/runtime/main/extend/systemplugin/napi/ohos_data_Storage.js @@ -15,11 +15,9 @@ import { paramMock } from "../utils" -const ValueTypes = { - unknow: '[PC Preview] unknow value type' -}; +const ValueTypes = '[PC Preview] unknow value type' -const StorageObserverMock = { +const StorageObserver = { key: '[PC Preview] unknown key' }; const MAX_KEY_LENGTH = 80; @@ -83,17 +81,17 @@ export function mockDataStorage() { getSync: function () { console.warn("Storage.getSync interface mocked in the Previewer. How this interface works on the Previewer may" + " be different from that on a real device.") - return ValueTypes.unknow + return ValueTypes }, get: function (...args) { console.warn("Storage.get interface mocked in the Previewer. How this interface works on the Previewer may be" + " different from that on a real device.") const len = args.length if (typeof args[len - 1] === 'function') { - args[len - 1].call(this, paramMock.businessErrorMock, ValueTypes.unknow) + args[len - 1].call(this, paramMock.businessErrorMock, ValueTypes) } else { return new Promise((resolve) => { - resolve(ValueTypes.unknow) + resolve(ValueTypes) }) } }, @@ -182,13 +180,13 @@ export function mockDataStorage() { console.warn("Storage.on interface mocked in the Previewer. How this interface works on the Previewer may be" + " different from that on a real device.") const len = args.length - args[len - 1].call(this, StorageObserverMock) + args[len - 1].call(this, StorageObserver) }, off: function (...args) { console.warn("Storage.off interface mocked in the Previewer. How this interface works on the Previewer may be" + " different from that on a real device.") const len = args.length - args[len - 1].call(this, storageObserverMock) + args[len - 1].call(this, storageObserver) } } return storage From e06e2cf3927aeeeb63d1b4e3d20ac2b8b28eea86 Mon Sep 17 00:00:00 2001 From: Your Name Date: Mon, 18 Jul 2022 18:09:56 +0800 Subject: [PATCH 099/109] =?UTF-8?q?uitest=20MockAPI=E6=8E=A5=E5=8F=A3?= =?UTF-8?q?=E5=A2=9E=E5=8A=A0.=20Signed-off-by:=20?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Your Name --- .../extend/systemplugin/napi/ohos_uitest.js | 24 +++++++++---------- 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/runtime/main/extend/systemplugin/napi/ohos_uitest.js b/runtime/main/extend/systemplugin/napi/ohos_uitest.js index 738af166..20eb6313 100644 --- a/runtime/main/extend/systemplugin/napi/ohos_uitest.js +++ b/runtime/main/extend/systemplugin/napi/ohos_uitest.js @@ -45,22 +45,22 @@ export const WindowMode = { } export const Point = { - X: '[PC Preview] unknown X'; - Y: '[PC Preview] unknown Y'; + X: '[PC Preview] unknown X', + Y: '[PC Preview] unknown Y' } export const Rect = { - leftX: '[PC Preview] unknown leftX'; - topY: '[PC Preview] unknown topY'; - rightX: '[PC Preview] unknown rightX'; - bottomY: '[PC Preview] unknown bottomY'; + leftX: '[PC Preview] unknown leftX', + topY: '[PC Preview] unknown topY', + rightX: '[PC Preview] unknown rightX', + bottomY: '[PC Preview] unknown bottomY' } export const WindowFilter = { - bundleName: '[PC Preview] unknown bundleName'; - title: '[PC Preview] unknown title'; - focused: '[PC Preview] unknown focused'; - actived: '[PC Preview] unknown actived'; + bundleName: '[PC Preview] unknown bundleName', + title: '[PC Preview] unknown title', + focused: '[PC Preview] unknown focused', + actived: '[PC Preview] unknown actived' } const ByClass = class ByMock { @@ -425,8 +425,8 @@ const UiWindowClass = class UiWindowMock { resolve(paramMock.paramBoolMock) }); }; - this.focuse = function(...args) { - console.warn('uitest.UiWindowMock.focuse' + warnMessage) + this.focus = function(...args) { + console.warn('uitest.UiWindowMock.focus' + warnMessage) return new Promise((resolve) => { resolve(paramMock.paramBoolMock) }); From 79e8669c0a772ce86a8a398523141e6555d156f9 Mon Sep 17 00:00:00 2001 From: ma-shaoyin Date: Tue, 19 Jul 2022 09:03:29 +0800 Subject: [PATCH 100/109] Signed-off-by: ma-shaoyin Changes to be committed: --- .../systemplugin/napi/ohos_inputmethod.js | 31 +++++++++++++------ 1 file changed, 21 insertions(+), 10 deletions(-) diff --git a/runtime/main/extend/systemplugin/napi/ohos_inputmethod.js b/runtime/main/extend/systemplugin/napi/ohos_inputmethod.js index ca1a920b..4596334c 100644 --- a/runtime/main/extend/systemplugin/napi/ohos_inputmethod.js +++ b/runtime/main/extend/systemplugin/napi/ohos_inputmethod.js @@ -39,14 +39,8 @@ export function mockInputMethod() { } ] const InputMethodProperty = { - methodId: "[PC Preview] unknow method id", - bundleName: "[PC Preview] unknow bundle name", - abilityName: "[PC Preview] unknow ability name", - configurationPage: "[PC Preview] unknow configuration page", - isSystemIme: true, - typeCount: 1, - defaultImeId: 2, - keyboardTypes: KeyboardTypeArry + packageName :"[PC Preview] unknow packageName", + methodId: "[PC Preview] unknow method id" } const InputMethodPropertyArry = [ { @@ -137,7 +131,7 @@ export function mockInputMethod() { }, } const inputMethod = { - MAX_TYPE_MUN: 128, + MAX_TYPE_NUM: 128, getInputMethodController: function () { console.warn("inputmethod.getInputMethodController interface mocked in the Previewer. How this interface works" + " on the Previewer may be different from that on a real device.") @@ -147,7 +141,24 @@ export function mockInputMethod() { console.warn("inputmethod.getInputMethodSetting interface mocked in the Previewer. How this interface works" + " on the Previewer may be different from that on a real device.") return InputMethodSettingMock; - } + }, + getCurrentInputMethod: function () { + console.warn("inputmethod.getCurrentInputMethod interface mocked in the Previewer. How this interface works" + + " on the Previewer may be different from that on a real device.") + return InputMethodProperty; + }, + switchInputMethod: function (...args) { + console.warn("inputMethod.switchInputMethod interface mocked in the Previewer. How this interface works on" + + " the Previewer may be different from that on a real device.") + const len = args.length + if (typeof args[len - 1] === 'function') { + args[len - 1].call(this, paramMock.businessErrorMock, paramMock.paramBooleanMock); + } else { + return new Promise((resolve, reject) => { + resolve(paramMock.paramBooleanMock); + }) + } + }, } return inputMethod } \ No newline at end of file From 1a773d225eeed846b67aec5a66ba84fe7629ca27 Mon Sep 17 00:00:00 2001 From: lovechinamo Date: Tue, 19 Jul 2022 09:31:07 +0800 Subject: [PATCH 101/109] Signed-off-by: lovechinamo Changes to be committed: --- runtime/main/extend/systemplugin/napi/ohos_screenLock.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/runtime/main/extend/systemplugin/napi/ohos_screenLock.js b/runtime/main/extend/systemplugin/napi/ohos_screenLock.js index edf5f1d1..2d3c9501 100644 --- a/runtime/main/extend/systemplugin/napi/ohos_screenLock.js +++ b/runtime/main/extend/systemplugin/napi/ohos_screenLock.js @@ -69,7 +69,7 @@ export function mockScreenLock() { } }, off: function (...args) { - console.warn("screenLock.ofF interface mocked in the Previewer. How this interface works on the" + + console.warn("screenLock.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') { From e289be0665a3e330ee571c30d9ffbff3e21c5936 Mon Sep 17 00:00:00 2001 From: Your Name Date: Tue, 19 Jul 2022 09:54:34 +0800 Subject: [PATCH 102/109] =?UTF-8?q?uitest=20MockAPI=E6=8E=A5=E5=8F=A3?= =?UTF-8?q?=E5=A2=9E=E5=8A=A0.=20Signed-off-by:=20?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Your Name --- .../extend/systemplugin/napi/ohos_uitest.js | 30 +++++++++---------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/runtime/main/extend/systemplugin/napi/ohos_uitest.js b/runtime/main/extend/systemplugin/napi/ohos_uitest.js index 20eb6313..c0be4ccd 100644 --- a/runtime/main/extend/systemplugin/napi/ohos_uitest.js +++ b/runtime/main/extend/systemplugin/napi/ohos_uitest.js @@ -388,87 +388,87 @@ const UiComponentClass = class UiComponentMock { const UiWindowClass = class UiWindowMock { constructor() { - console.warn('uitest.UiWindowMock.constructor' + warnMessage); + console.warn('uitest.UiWindow.constructor' + warnMessage); this.getBundleName = function(...args) { - console.warn('uitest.UiWindowMock.getBundleName' + warnMessage) + console.warn('uitest.UiWindow.getBundleName' + warnMessage) return new Promise((resolve) => { resolve(paramMock.paramStringMock) }); }; this.getBounds = function(...args) { - console.warn('uitest.UiWindowMock.getBounds' + warnMessage) + console.warn('uitest.UiWindow.getBounds' + warnMessage) return new Promise((resolve) => { resolve(Rect) }); }; this.getTitle = function(...args) { - console.warn('uitest.UiWindowMock.getTitle' + warnMessage) + console.warn('uitest.UiWindow.getTitle' + warnMessage) return new Promise((resolve) => { resolve(paramMock.paramStringMock) }); }; this.getWindowMode = function(...args) { - console.warn('uitest.UiWindowMock.getWindowMode' + warnMessage) + console.warn('uitest.UiWindow.getWindowMode' + warnMessage) return new Promise((resolve) => { resolve(WindowMode) }); }; this.isFocused = function(...args) { - console.warn('uitest.UiWindowMock.isFocused' + warnMessage) + console.warn('uitest.UiWindow.isFocused' + warnMessage) return new Promise((resolve) => { resolve(paramMock.paramBoolMock) }); }; this.isActived = function(...args) { - console.warn('uitest.UiWindowMock.isActived' + warnMessage) + console.warn('uitest.UiWindow.isActived' + warnMessage) return new Promise((resolve) => { resolve(paramMock.paramBoolMock) }); }; this.focus = function(...args) { - console.warn('uitest.UiWindowMock.focus' + warnMessage) + console.warn('uitest.UiWindow.focus' + warnMessage) return new Promise((resolve) => { resolve(paramMock.paramBoolMock) }); }; this.moveTo = function(...args) { - console.warn('uitest.UiWindowMock.moveTo' + warnMessage) + console.warn('uitest.UiWindow.moveTo' + warnMessage) return new Promise((resolve) => { resolve(paramMock.paramBoolMock) }); }; this.resize = function(...args) { - console.warn('uitest.UiWindowMock.resize' + warnMessage) + console.warn('uitest.UiWindow.resize' + warnMessage) return new Promise((resolve) => { resolve(paramMock.paramBoolMock) }); }; this.split = function(...args) { - console.warn('uitest.UiWindowMock.split' + warnMessage) + console.warn('uitest.UiWindow.split' + warnMessage) return new Promise((resolve) => { resolve(paramMock.paramBoolMock) }); }; this.maximize = function(...args) { - console.warn('uitest.UiWindowMock.maximize' + warnMessage) + console.warn('uitest.UiWindow.maximize' + warnMessage) return new Promise((resolve) => { resolve(paramMock.paramBoolMock) }); }; this.resume = function(...args) { - console.warn('uitest.UiWindowMock.resume' + warnMessage) + console.warn('uitest.UiWindow.resume' + warnMessage) return new Promise((resolve) => { resolve(paramMock.paramBoolMock) }); }; this.minimize = function(...args) { - console.warn('uitest.UiWindowMock.minimize' + warnMessage) + console.warn('uitest.UiWindow.minimize' + warnMessage) return new Promise((resolve) => { resolve(paramMock.paramBoolMock) }); }; this.close = function(...args) { - console.warn('uitest.UiWindowMock.close' + warnMessage) + console.warn('uitest.UiWindow.close' + warnMessage) return new Promise((resolve) => { resolve(paramMock.paramBoolMock) }); From 02d2642b6518e48473a5df1acd5739dfc66f5e1b Mon Sep 17 00:00:00 2001 From: wuyongning Date: Tue, 19 Jul 2022 11:02:15 +0800 Subject: [PATCH 103/109] add enum mock Signed-off-by: wuyongning --- runtime/main/extend/systemplugin/napi/ohos_data_rdb.js | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/runtime/main/extend/systemplugin/napi/ohos_data_rdb.js b/runtime/main/extend/systemplugin/napi/ohos_data_rdb.js index 795a2642..3a4f1208 100644 --- a/runtime/main/extend/systemplugin/napi/ohos_data_rdb.js +++ b/runtime/main/extend/systemplugin/napi/ohos_data_rdb.js @@ -205,6 +205,16 @@ export function mockRdb() { const storeConfig = { name: "[PC Preview] unknown name" } + + const SyncMode = { + SYNC_MODE_PUSH: "[PC Preview] unknown SYNC_MODE_PUSH", + SYNC_MODE_PULL: "[PC Preview] unknown SYNC_MODE_PULL" + } + + const SubscribeType = { + SUBSCRIBE_TYPE_REMOTE: "[PC Preview] unknown SUBSCRIBE_TYPE_REMOTE" + } + const rdbStore = { insert: function (...args) { console.warn("RdbStore.insert interface mocked in the Previewer. How this interface works on the" + From 83c4a195cf53fcf12f013fda0d6c50c511b17821 Mon Sep 17 00:00:00 2001 From: wuyongning Date: Tue, 19 Jul 2022 11:18:44 +0800 Subject: [PATCH 104/109] fix err Signed-off-by: wuyongning --- runtime/main/extend/systemplugin/napi/ohos_data_rdb.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/runtime/main/extend/systemplugin/napi/ohos_data_rdb.js b/runtime/main/extend/systemplugin/napi/ohos_data_rdb.js index 3a4f1208..e9ac4c8c 100644 --- a/runtime/main/extend/systemplugin/napi/ohos_data_rdb.js +++ b/runtime/main/extend/systemplugin/napi/ohos_data_rdb.js @@ -207,12 +207,12 @@ export function mockRdb() { } const SyncMode = { - SYNC_MODE_PUSH: "[PC Preview] unknown SYNC_MODE_PUSH", - SYNC_MODE_PULL: "[PC Preview] unknown SYNC_MODE_PULL" + SYNC_MODE_PUSH: 0, + SYNC_MODE_PULL: 1 } const SubscribeType = { - SUBSCRIBE_TYPE_REMOTE: "[PC Preview] unknown SUBSCRIBE_TYPE_REMOTE" + SUBSCRIBE_TYPE_REMOTE: 0 } const rdbStore = { From 3094173b3f6825a290cc9303f8ea3dfe19bbd183 Mon Sep 17 00:00:00 2001 From: duanweiling Date: Tue, 19 Jul 2022 11:20:43 +0800 Subject: [PATCH 105/109] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E6=9E=9A=E4=B8=BE?= =?UTF-8?q?=E7=B1=BB=E5=9E=8B=E7=9A=84mock?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: duanweiling --- .../systemplugin/napi/ohos_data_DataShareResultSet.js | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/runtime/main/extend/systemplugin/napi/ohos_data_DataShareResultSet.js b/runtime/main/extend/systemplugin/napi/ohos_data_DataShareResultSet.js index c444525d..26f86584 100644 --- a/runtime/main/extend/systemplugin/napi/ohos_data_DataShareResultSet.js +++ b/runtime/main/extend/systemplugin/napi/ohos_data_DataShareResultSet.js @@ -15,6 +15,13 @@ import {paramMock} from "../utils" +export const DataType = { + TYPE_NULL: 0, + TYPE_LONG: 1, + TYPE_DOUBLE: 2, + TYPE_STRING: 3, + TYPE_BLOB: 4 +}; export const DataShareResultSetMock = { columnNames: "[PC Preview] unknow columnNames", columnCount: "[PC Preview] unknow columnCount", From 5204d3e4a5a337793b711ca74894c9dfffb0ad2f Mon Sep 17 00:00:00 2001 From: Your Name Date: Tue, 19 Jul 2022 14:20:49 +0800 Subject: [PATCH 106/109] =?UTF-8?q?uitest=20MockAPI=E6=8E=A5=E5=8F=A3?= =?UTF-8?q?=E5=A2=9E=E5=8A=A0.=20Signed-off-by:=20?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Your Name --- .../extend/systemplugin/napi/ohos_uitest.js | 38 +++++++++---------- 1 file changed, 19 insertions(+), 19 deletions(-) diff --git a/runtime/main/extend/systemplugin/napi/ohos_uitest.js b/runtime/main/extend/systemplugin/napi/ohos_uitest.js index c0be4ccd..550bd76e 100644 --- a/runtime/main/extend/systemplugin/napi/ohos_uitest.js +++ b/runtime/main/extend/systemplugin/napi/ohos_uitest.js @@ -165,7 +165,7 @@ const UiDriverClass = class UiDriverMock { this.screenCap = function(...args) { console.warn('uitest.UiDriver.screenCap' + warnMessage) return new Promise((resolve) => { - resolve(paramMock.paramBoolMock) + resolve(paramMock.paramBooleanMock) }); }; this.assertComponentExist = function(...args) { @@ -260,49 +260,49 @@ const UiComponentClass = class UiComponentMock { this.isEnabled = function(...args) { console.warn('uitest.UiComponent.isEnabled' + warnMessage) return new Promise((resolve) => { - resolve(paramMock.paramBoolMock) + resolve(paramMock.paramBooleanMock) }); }; this.isFocused = function(...args) { console.warn('uitest.UiComponent.isFocused' + warnMessage) return new Promise((resolve) => { - resolve(paramMock.paramBoolMock) + resolve(paramMock.paramBooleanMock) }); }; this.isSelected = function(...args) { console.warn('uitest.UiComponent.isSelected' + warnMessage) return new Promise((resolve) => { - resolve(paramMock.paramBoolMock) + resolve(paramMock.paramBooleanMock) }); }; this.isClickable = function(...args) { console.warn('uitest.UiComponent.isClickable' + warnMessage) return new Promise((resolve) => { - resolve(paramMock.paramBoolMock) + resolve(paramMock.paramBooleanMock) }); }; this.isLongClickable = function(...args) { console.warn('uitest.UiComponent.isLongClickable' + warnMessage) return new Promise((resolve) => { - resolve(paramMock.paramBoolMock) + resolve(paramMock.paramBooleanMock) }); }; this.isScrollable = function(...args) { console.warn('uitest.UiComponent.isScrollable' + warnMessage) return new Promise((resolve) => { - resolve(paramMock.paramBoolMock) + resolve(paramMock.paramBooleanMock) }); }; this.isCheckable = function(...args) { console.warn('uitest.UiComponent.isCheckable' + warnMessage) return new Promise((resolve) => { - resolve(paramMock.paramBoolMock) + resolve(paramMock.paramBooleanMock) }); }; this.isChecked = function(...args) { console.warn('uitest.UiComponent.isChecked' + warnMessage) return new Promise((resolve) => { - resolve(paramMock.paramBoolMock) + resolve(paramMock.paramBooleanMock) }); }; this.getBounds = function(...args) { @@ -416,61 +416,61 @@ const UiWindowClass = class UiWindowMock { this.isFocused = function(...args) { console.warn('uitest.UiWindow.isFocused' + warnMessage) return new Promise((resolve) => { - resolve(paramMock.paramBoolMock) + resolve(paramMock.paramBooleanMock) }); }; this.isActived = function(...args) { console.warn('uitest.UiWindow.isActived' + warnMessage) return new Promise((resolve) => { - resolve(paramMock.paramBoolMock) + resolve(paramMock.paramBooleanMock) }); }; this.focus = function(...args) { console.warn('uitest.UiWindow.focus' + warnMessage) return new Promise((resolve) => { - resolve(paramMock.paramBoolMock) + resolve(paramMock.paramBooleanMock) }); }; this.moveTo = function(...args) { console.warn('uitest.UiWindow.moveTo' + warnMessage) return new Promise((resolve) => { - resolve(paramMock.paramBoolMock) + resolve(paramMock.paramBooleanMock) }); }; this.resize = function(...args) { console.warn('uitest.UiWindow.resize' + warnMessage) return new Promise((resolve) => { - resolve(paramMock.paramBoolMock) + resolve(paramMock.paramBooleanMock) }); }; this.split = function(...args) { console.warn('uitest.UiWindow.split' + warnMessage) return new Promise((resolve) => { - resolve(paramMock.paramBoolMock) + resolve(paramMock.paramBooleanMock) }); }; this.maximize = function(...args) { console.warn('uitest.UiWindow.maximize' + warnMessage) return new Promise((resolve) => { - resolve(paramMock.paramBoolMock) + resolve(paramMock.paramBooleanMock) }); }; this.resume = function(...args) { console.warn('uitest.UiWindow.resume' + warnMessage) return new Promise((resolve) => { - resolve(paramMock.paramBoolMock) + resolve(paramMock.paramBooleanMock) }); }; this.minimize = function(...args) { console.warn('uitest.UiWindow.minimize' + warnMessage) return new Promise((resolve) => { - resolve(paramMock.paramBoolMock) + resolve(paramMock.paramBooleanMock) }); }; this.close = function(...args) { console.warn('uitest.UiWindow.close' + warnMessage) return new Promise((resolve) => { - resolve(paramMock.paramBoolMock) + resolve(paramMock.paramBooleanMock) }); }; }; From e4c6942aed07f7e6f6efc4509fda46aba7afb255 Mon Sep 17 00:00:00 2001 From: zhangxingxia Date: Tue, 19 Jul 2022 14:45:41 +0800 Subject: [PATCH 107/109] update mock Signed-off-by: zhangxingxia --- runtime/main/extend/systemplugin/napi/ohos_fileManager.js | 8 ++++---- .../main/extend/systemplugin/napi/ohos_volumeManager.js | 4 ++-- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/runtime/main/extend/systemplugin/napi/ohos_fileManager.js b/runtime/main/extend/systemplugin/napi/ohos_fileManager.js index 6491bda7..d9fc9eb9 100644 --- a/runtime/main/extend/systemplugin/napi/ohos_fileManager.js +++ b/runtime/main/extend/systemplugin/napi/ohos_fileManager.js @@ -35,10 +35,10 @@ export function mockFileManager() { " Previewer may be different from that on a real device.") const len = args.length if (typeof args[len - 1] === 'function') { - args[len - 1].call(this, paramMock.businessErrorMock, Array(FileInfo)) + args[len - 1].call(this, paramMock.businessErrorMock, new Array(FileInfo)) } else { return new Promise((resolve, reject) => { - resolve(Array(FileInfo)); + resolve(new Array(FileInfo)); }) } }, @@ -47,10 +47,10 @@ export function mockFileManager() { " Previewer may be different from that on a real device.") const len = args.length if (typeof args[len - 1] === 'function') { - args[len - 1].call(this, paramMock.businessErrorMock, Array(FileInfo)) + args[len - 1].call(this, paramMock.businessErrorMock, new Array(FileInfo)) } else { return new Promise((resolve, reject) => { - resolve(Array(FileInfo)); + resolve(new Array(FileInfo)); }) } }, diff --git a/runtime/main/extend/systemplugin/napi/ohos_volumeManager.js b/runtime/main/extend/systemplugin/napi/ohos_volumeManager.js index 412dda53..4854b912 100644 --- a/runtime/main/extend/systemplugin/napi/ohos_volumeManager.js +++ b/runtime/main/extend/systemplugin/napi/ohos_volumeManager.js @@ -31,10 +31,10 @@ export function mockVolumeManager() { " Previewer may be different from that on a real device."); const len = args.length; if (typeof args[len - 1] === 'function') { - args[len - 1].call(this, paramMock.businessErrorMock, Array(Volume)); + args[len - 1].call(this, paramMock.businessErrorMock, new Array(Volume)); } else { return new Promise((resolve, reject) => { - resolve(Array(Volume)); + resolve(new Array(Volume)); }) } }, From 804dc39caea7b562bb42501a14637f87ea47fbfe Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=80=BF=E6=96=87=E5=B9=BF?= Date: Tue, 19 Jul 2022 15:15:38 +0800 Subject: [PATCH 108/109] =?UTF-8?q?=E5=8C=85=E7=AE=A1=E8=A1=A5=E9=BD=90moc?= =?UTF-8?q?k?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 耿文广 --- .../systemplugin/napi/bundle/abilityInfo.js | 3 + .../systemplugin/napi/bundle/bundleInfo.js | 2 +- .../napi/bundle/bundleInstaller.js | 1 + .../systemplugin/napi/bundle/hapModuleInfo.js | 5 ++ .../napi/bundle/launcherAbilityInfo.js | 4 +- .../systemplugin/napi/bundle/packInfo.js | 2 +- .../extend/systemplugin/napi/ohos_zlib.js | 79 +++++++++---------- 7 files changed, 50 insertions(+), 46 deletions(-) diff --git a/runtime/main/extend/systemplugin/napi/bundle/abilityInfo.js b/runtime/main/extend/systemplugin/napi/bundle/abilityInfo.js index 3bcd1e31..3a0bbf33 100644 --- a/runtime/main/extend/systemplugin/napi/bundle/abilityInfo.js +++ b/runtime/main/extend/systemplugin/napi/bundle/abilityInfo.js @@ -41,6 +41,9 @@ export const AbilityInfo = { appId: '[PC Preview] unknow appId', label: "[PC preview] unknown label", description: "[PC preview] unknown description", + icon: "[PC preview] unknown icon", + labelId: "[PC preview] unknown labelId", + iconId: "[PC preview] unknown iconId", uid: '[PC Preview] unknow uid', installTime: '[PC Preview] unknow installTime', updateTime: '[PC Preview] unknow updateTime', diff --git a/runtime/main/extend/systemplugin/napi/bundle/bundleInfo.js b/runtime/main/extend/systemplugin/napi/bundle/bundleInfo.js index c55193b6..68793e40 100644 --- a/runtime/main/extend/systemplugin/napi/bundle/bundleInfo.js +++ b/runtime/main/extend/systemplugin/napi/bundle/bundleInfo.js @@ -39,7 +39,7 @@ export const BundleInfo = { installTime: "[PC preview] unknown installTime", updateTime: "[PC preview] unknown updateTime", appInfo: ApplicationInfo, - abilityInfo: [AbilityInfo], + abilityInfos: [AbilityInfo], reqPermissions: [paramMock.paramStringMock], reqPermissionDetails: [ReqPermissionDetail], vendor: "[PC preview] unknown vendor", diff --git a/runtime/main/extend/systemplugin/napi/bundle/bundleInstaller.js b/runtime/main/extend/systemplugin/napi/bundle/bundleInstaller.js index 801d5d8e..d0c85129 100755 --- a/runtime/main/extend/systemplugin/napi/bundle/bundleInstaller.js +++ b/runtime/main/extend/systemplugin/napi/bundle/bundleInstaller.js @@ -24,6 +24,7 @@ export const HashParam = { export const InstallParam = { userId: "[PC preview] unknown userId", installFlag: "[PC preview] unknown installFlag", + isKeepData: "[PC preview] unknown isKeepData", hashParams: [HashParam], crowdtestDeadline: "[PC preview] unknown crowdtestDeadline", } diff --git a/runtime/main/extend/systemplugin/napi/bundle/hapModuleInfo.js b/runtime/main/extend/systemplugin/napi/bundle/hapModuleInfo.js index 7496aef6..d137641f 100755 --- a/runtime/main/extend/systemplugin/napi/bundle/hapModuleInfo.js +++ b/runtime/main/extend/systemplugin/napi/bundle/hapModuleInfo.js @@ -15,6 +15,8 @@ import { paramMock } from "../../utils" import { AbilityInfo } from './abilityInfo'; +import { ExtensionAbilityInfo } from './extensionAbilityInfo'; +import { Metadata } from './metadata'; export const HapModuleInfo = { @@ -33,4 +35,7 @@ export const HapModuleInfo = { moduleName: "[PC preview] unknown moduleName", mainAbilityName: "[PC preview] unknown mainAbilityName", installationFree: "[PC preview] unknown installationFree", + mainElementName: "[PC preview] unknown mainElementName", + extensionAbilityInfo: [ExtensionAbilityInfo], + metadata: [Metadata], } \ No newline at end of file diff --git a/runtime/main/extend/systemplugin/napi/bundle/launcherAbilityInfo.js b/runtime/main/extend/systemplugin/napi/bundle/launcherAbilityInfo.js index 54ca8cc3..830d0533 100644 --- a/runtime/main/extend/systemplugin/napi/bundle/launcherAbilityInfo.js +++ b/runtime/main/extend/systemplugin/napi/bundle/launcherAbilityInfo.js @@ -18,8 +18,8 @@ import { ApplicationInfo } from './applicationInfo'; import { ElementName } from './elementName' export const LauncherAbilityInfo = { - applicationInfo: {ApplicationInfo}, - elementName: {ElementName}, + applicationInfo: ApplicationInfo, + elementName: ElementName, labelId: "[PC preview] unknown labelId", iconId: "[PC preview] unknown iconId", userId: "[PC preview] unknown userId", diff --git a/runtime/main/extend/systemplugin/napi/bundle/packInfo.js b/runtime/main/extend/systemplugin/napi/bundle/packInfo.js index 8a7bfebf..fd6e7dc8 100755 --- a/runtime/main/extend/systemplugin/napi/bundle/packInfo.js +++ b/runtime/main/extend/systemplugin/napi/bundle/packInfo.js @@ -33,7 +33,7 @@ export const ModuleDistroInfo = { export const AbilityFormInfo = { name: "[PC preview] unknown name", type: "[PC preview] unknown type", - updateEnabledtype: "[PC preview] unknown updateEnabled", + updateEnabled: "[PC preview] unknown updateEnabled", scheduledUpdateTime: "[PC preview] unknown scheduledUpdateTime", updateDuration: "[PC preview] unknown updateDuration", supportDimensions: [paramMock.paramNumberMock], diff --git a/runtime/main/extend/systemplugin/napi/ohos_zlib.js b/runtime/main/extend/systemplugin/napi/ohos_zlib.js index 3ad3a5d7..d0a632c1 100644 --- a/runtime/main/extend/systemplugin/napi/ohos_zlib.js +++ b/runtime/main/extend/systemplugin/napi/ohos_zlib.js @@ -13,57 +13,52 @@ * limitations under the License. */ export const MemLevel = { - MEM_LEVEL_MIN: 1, - MEM_LEVEL_MAX: 9, - MEM_LEVEL_DEFAULT: 8 + MEM_LEVEL_MIN: 1, + MEM_LEVEL_MAX: 9, + MEM_LEVEL_DEFAULT: 8 }; export const ErrorCode = { - ERROR_CODE_OK: 0, - ERROR_CODE_ERRNO: -1, + ERROR_CODE_OK: 0, + ERROR_CODE_ERRNO: -1, }; export const CompressLevel = { - COMPRESS_LEVEL_NO_COMPRESSION: 0, - COMPRESS_LEVEL_BEST_SPEED: 1, - COMPRESS_LEVEL_BEST_COMPRESSION: 9, - COMPRESS_LEVEL_DEFAULT_COMPRESSION: -1 + COMPRESS_LEVEL_NO_COMPRESSION: 0, + COMPRESS_LEVEL_BEST_SPEED: 1, + COMPRESS_LEVEL_BEST_COMPRESSION: 9, + COMPRESS_LEVEL_DEFAULT_COMPRESSION: -1 }; export const CompressStrategy = { - COMPRESS_STRATEGY_DEFAULT_STRATEGY: 0, - COMPRESS_STRATEGY_FILTERED: 1, - COMPRESS_STRATEGY_HUFFMAN_ONLY: 2, - COMPRESS_STRATEGY_RLE: 3, - COMPRESS_STRATEGY_FIXED: 4 + COMPRESS_STRATEGY_DEFAULT_STRATEGY: 0, + COMPRESS_STRATEGY_FILTERED: 1, + COMPRESS_STRATEGY_HUFFMAN_ONLY: 2, + COMPRESS_STRATEGY_RLE: 3, + COMPRESS_STRATEGY_FIXED: 4 }; export const Options = { - level: CompressLevel, - memLevel: MemLevel, - strategy: CompressStrategy, + level: CompressLevel, + memLevel: MemLevel, + strategy: CompressStrategy, }; -export function mockZlib() { - const zlib = { - ErrorCode, - MemLevel, - CompressLevel, - CompressStrategy, - Options: { - level: CompressLevel, - memLevel: MemLevel, - strategy: CompressStrategy, - }, - - zipFile(...args) { - console.warn("zlib.zipFile interface mocked in the Previewer. How this interface works on the Previewer may be different from that on a real device.") - return new Promise((resolve, reject) => { - resolve() - }) - }, +export function mockZlib() { + const zlib = { + ErrorCode, + MemLevel, + CompressLevel, + CompressStrategy, + Options, + zipFile: function(...args) { + console.warn("zlib.zipFile interface mocked in the Previewer. How this interface works on the Previewer may be different from that on a real device.") + return new Promise((resolve) => { + resolve(); + }) + }, - unzipFile(...args) { - console.warn("zlib.unzipFile interface mocked in the Previewer. How this interface works on the Previewer may be different from that on a real device.") - return new Promise((resolve, reject) => { - resolve() - }) + unzipFile: function(...args) { + console.warn("zlib.unzipFile interface mocked in the Previewer. How this interface works on the Previewer may be different from that on a real device.") + return new Promise((resolve) => { + resolve(); + }) + } } - } - return zlib; + return zlib; } \ No newline at end of file From 6f8ccb580b536c40ad840eaa8512a6e0dc5c8f40 Mon Sep 17 00:00:00 2001 From: wangxiyue Date: Wed, 20 Jul 2022 16:45:16 +0800 Subject: [PATCH 109/109] amend interface description Signed-off-by: wangxiyue --- .../systemplugin/napi/ohos_data_distributedDataObject.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/runtime/main/extend/systemplugin/napi/ohos_data_distributedDataObject.js b/runtime/main/extend/systemplugin/napi/ohos_data_distributedDataObject.js index 0c2335d0..ad34651e 100644 --- a/runtime/main/extend/systemplugin/napi/ohos_data_distributedDataObject.js +++ b/runtime/main/extend/systemplugin/napi/ohos_data_distributedDataObject.js @@ -62,7 +62,7 @@ export function mockDistributedObject() { const RevokeSaveSuccessResponse = { sessionId: "[[PC Preview] unknow sessionId]" }; - const distributedObjectMock = { + const distributedDataObject = { createDistributedObject: function (...args) { console.warn("distributedObject.createDistributedObject interface mocked in the Previewer." + " How this interface works on the Previewer may be different from that on a real device."); @@ -74,5 +74,5 @@ export function mockDistributedObject() { return 'just test'; } }; - return distributedObjectMock; -} \ No newline at end of file + return distributedDataObject; +}