mirror of
https://github.com/openharmony/third_party_jsframework.git
synced 2026-07-19 22:43:32 -04:00
@@ -26,7 +26,6 @@ import { mockDataAbility } from './dataAbility'
|
||||
import { mockStorage } from './storage'
|
||||
import { mockRdb } from './rdb'
|
||||
import { mockInputDevice } from './inputDevice'
|
||||
import { mockLight } from './light'
|
||||
import { mockVibrator } from './vibrator'
|
||||
import { mockSensor } from './sensor'
|
||||
|
||||
@@ -89,8 +88,6 @@ export function mockRequireNapiFun() {
|
||||
return mockDataAbility();
|
||||
case "multimodalInput.inputDevice":
|
||||
return mockInputDevice();
|
||||
case "light":
|
||||
return mockLight();
|
||||
case "vibrator":
|
||||
return mockVibrator();
|
||||
case "sensor":
|
||||
|
||||
@@ -1,93 +0,0 @@
|
||||
import { paramMock } from "../utils"
|
||||
|
||||
export function mockLight() {
|
||||
const LightId = {
|
||||
LIGHT_ID_LED: 0,
|
||||
LIGHT_ID_KEYBOARD: 1,
|
||||
LIGHT_ID_BUTTONS: 2,
|
||||
LIGHT_ID_BELT: 3,
|
||||
UNKNOWN: 4
|
||||
}
|
||||
const LightEffectId = {
|
||||
LIGHT_ID_LED: "0",
|
||||
LIGHT_ID_KEYBOARD: "1",
|
||||
LIGHT_ID_BUTTONS: "2",
|
||||
LIGHT_ID_BELT: "3",
|
||||
UNKNOWN: "4"
|
||||
}
|
||||
const LightBrightness = {
|
||||
redBrightness: "[PC preview] unknown redBrightness",
|
||||
greenBrightness: "[PC preview] unknown greenBrightness",
|
||||
blueBrightness: "[PC preview] unknown blueBrightness"
|
||||
}
|
||||
const LightEffect = {
|
||||
lightBrightness: "[PC preview] unknown lightBrightness",
|
||||
onDuration: "[PC preview] unknown onDuration",
|
||||
offDuration: "[PC preview] unknown offDuration"
|
||||
}
|
||||
const light = {
|
||||
turnOn: function (...args) {
|
||||
console.warn("light.turnOn interface mocked in the Previewer. How this interface works on the" +
|
||||
" Previewer may be different from that on a 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();
|
||||
})
|
||||
}
|
||||
},
|
||||
turnOff: function (...args) {
|
||||
console.warn("light.turnOff interface mocked in the Previewer. How this interface works on the" +
|
||||
" Previewer may be different from that on a 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();
|
||||
})
|
||||
}
|
||||
},
|
||||
getLightIdList: function (...args) {
|
||||
console.warn("light.getLightIdList interface mocked in the Previewer. How this interface works on the" +
|
||||
" Previewer may be different from that on a real device.")
|
||||
var lightIdArray = new Array();
|
||||
lightIdArray.push(paramMock.paramNumberMock);
|
||||
const len = args.length
|
||||
if (typeof args[len - 1] === 'function') {
|
||||
args[len - 1].call(this, paramMock.businessErrorMock, lightIdArray);
|
||||
} else {
|
||||
return new Promise((resolve) => {
|
||||
resolve(lightIdArray);
|
||||
})
|
||||
}
|
||||
},
|
||||
isSupport: function (...args) {
|
||||
console.warn("light.isSupport interface mocked in the Previewer. How this interface works on the" +
|
||||
" Previewer may be different 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);
|
||||
})
|
||||
}
|
||||
},
|
||||
isEffectSupport: function (...args) {
|
||||
console.warn("light.isEffectSupport interface mocked in the Previewer. How this interface works on the" +
|
||||
" Previewer may be different 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 light
|
||||
}
|
||||
@@ -1,3 +1,18 @@
|
||||
/*
|
||||
* Copyright (c) 2021 Huawei Device Co., Ltd.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import { paramMock } from "../utils"
|
||||
|
||||
export function mockSensor() {
|
||||
@@ -109,10 +124,6 @@ export function mockSensor() {
|
||||
longitude: "[PC preview] unknown longitude",
|
||||
altitude: "[PC preview] unknown altitude",
|
||||
}
|
||||
const CoordinatesOptions = {
|
||||
x: "[PC preview] unknown x",
|
||||
y: "[PC preview] unknown y"
|
||||
}
|
||||
const SensorType = {
|
||||
SENSOR_TYPE_ID_ACCELEROMETER: 1,
|
||||
SENSOR_TYPE_ID_GYROSCOPE: 2,
|
||||
@@ -251,90 +262,6 @@ 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.")
|
||||
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);
|
||||
})
|
||||
}
|
||||
},
|
||||
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);
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
return sensor
|
||||
|
||||
@@ -1,3 +1,18 @@
|
||||
/*
|
||||
* Copyright (c) 2021 Huawei Device Co., Ltd.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import { paramMock } from "../utils"
|
||||
|
||||
export function mockVibrator() {
|
||||
|
||||
Reference in New Issue
Block a user