Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
OpenHarmony
Xts Acts
提交
1c688540
X
Xts Acts
项目概览
OpenHarmony
/
Xts Acts
1 年多 前同步成功
通知
9
Star
22
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
X
Xts Acts
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
未验证
提交
1c688540
编写于
5月 27, 2022
作者:
O
openharmony_ci
提交者:
Gitee
5月 27, 2022
浏览文件
操作
浏览文件
下载
差异文件
!3313 【Sensor】【Master】新增环境光 加速器,陀螺仪,霍尔,接近光,getOnBodyState,subscribeBarometer等用例
Merge pull request !3313 from ldy/master
上级
7fda93b3
ac258bd9
变更
21
显示空白变更内容
内联
并排
Showing
21 changed file
with
809 addition
and
2449 deletion
+809
-2449
sensors/miscdevice_standard/src/main/js/default/test/Subscribe_vibrate.js
...ce_standard/src/main/js/default/test/Subscribe_vibrate.js
+8
-15
sensors/sensor_standard/src/main/js/default/test/SensorGeomagneticTest.test.js
...rd/src/main/js/default/test/SensorGeomagneticTest.test.js
+378
-379
sensors/sensor_standard/src/main/js/default/test/SensorOnOffTest.test_Accelerometer.js
...ain/js/default/test/SensorOnOffTest.test_Accelerometer.js
+0
-610
sensors/sensor_standard/src/main/js/default/test/SensorOnOffTest.test_Ambient_Light.js
...ain/js/default/test/SensorOnOffTest.test_Ambient_Light.js
+0
-586
sensors/sensor_standard/src/main/js/default/test/SensorOnOffTest.test_Gyroscope.js
...rc/main/js/default/test/SensorOnOffTest.test_Gyroscope.js
+0
-609
sensors/sensor_standard/src/main/js/default/test/SensorOnOffTest.test_Hall.js
...ard/src/main/js/default/test/SensorOnOffTest.test_Hall.js
+0
-126
sensors/sensor_standard/src/main/js/default/test/SensorOnOffTest_Accelerometer.js
...src/main/js/default/test/SensorOnOffTest_Accelerometer.js
+2
-9
sensors/sensor_standard/src/main/js/default/test/SensorOnOffTest_Ambient_light.js
...src/main/js/default/test/SensorOnOffTest_Ambient_light.js
+324
-0
sensors/sensor_standard/src/main/js/default/test/SensorOnOffTest_GyroScope.js
...ard/src/main/js/default/test/SensorOnOffTest_GyroScope.js
+1
-4
sensors/sensor_standard/src/main/js/default/test/SensorOnOffTest_Hall.js
...standard/src/main/js/default/test/SensorOnOffTest_Hall.js
+1
-3
sensors/sensor_standard/src/main/js/default/test/Subscribe_getOnBodyState.js
...dard/src/main/js/default/test/Subscribe_getOnBodyState.js
+1
-0
sensors/sensor_standard/src/main/js/default/test/Subscribe_subscribeAccelerometer.js
.../main/js/default/test/Subscribe_subscribeAccelerometer.js
+11
-12
sensors/sensor_standard/src/main/js/default/test/Subscribe_subscribeBarometer.js
.../src/main/js/default/test/Subscribe_subscribeBarometer.js
+3
-5
sensors/sensor_standard/src/main/js/default/test/Subscribe_subscribeCompass.js
...rd/src/main/js/default/test/Subscribe_subscribeCompass.js
+1
-4
sensors/sensor_standard/src/main/js/default/test/Subscribe_subscribeDeviceOrientation.js
...n/js/default/test/Subscribe_subscribeDeviceOrientation.js
+3
-3
sensors/sensor_standard/src/main/js/default/test/Subscribe_subscribeGyroscope.js
.../src/main/js/default/test/Subscribe_subscribeGyroscope.js
+10
-13
sensors/sensor_standard/src/main/js/default/test/Subscribe_subscribeHeartRate.js
.../src/main/js/default/test/Subscribe_subscribeHeartRate.js
+1
-1
sensors/sensor_standard/src/main/js/default/test/Subscribe_subscribeLight.js
...dard/src/main/js/default/test/Subscribe_subscribeLight.js
+22
-24
sensors/sensor_standard/src/main/js/default/test/Subscribe_subscribeOnBodyState.js
...rc/main/js/default/test/Subscribe_subscribeOnBodyState.js
+1
-3
sensors/sensor_standard/src/main/js/default/test/Subscribe_subscribeProximity.js
.../src/main/js/default/test/Subscribe_subscribeProximity.js
+20
-21
sensors/sensor_standard/src/main/js/default/test/Subscribe_subscribeStepCounter.js
...rc/main/js/default/test/Subscribe_subscribeStepCounter.js
+22
-22
未找到文件。
sensors/miscdevice_standard/src/main/js/default/test/vibrate.js
→
sensors/miscdevice_standard/src/main/js/default/test/
Subscribe_
vibrate.js
浏览文件 @
1c688540
...
@@ -48,7 +48,10 @@ describe("VibratorJsTest", function () {
...
@@ -48,7 +48,10 @@ describe("VibratorJsTest", function () {
console
.
info
(
'
afterEach caled
'
)
console
.
info
(
'
afterEach caled
'
)
})
})
var
errMessages
=
[
'
Param number is invalid
'
,
'
Wrong argument type. function expected
'
,
'
Wrong argument type
'
,
'
Wrong argument number
'
]
let
errMessages
=
[
'
Param number is invalid
'
,
'
Wrong argument type. function expected
'
,
'
Wrong argument type
'
,
'
Wrong argument number
'
]
let
errMessage
;
/*
/*
* @tc.name:VibratorJsTest0001
* @tc.name:VibratorJsTest0001
...
@@ -62,7 +65,6 @@ describe("VibratorJsTest", function () {
...
@@ -62,7 +65,6 @@ describe("VibratorJsTest", function () {
mode
:
'
long
'
,
mode
:
'
long
'
,
success
:
function
()
{
success
:
function
()
{
console
.
info
(
"
VibratorJsTest0001 success
"
);
console
.
info
(
"
VibratorJsTest0001 success
"
);
expect
(
true
).
assertTrue
();
done
();
done
();
},
},
fail
:
function
(
data
,
code
)
{
fail
:
function
(
data
,
code
)
{
...
@@ -87,7 +89,6 @@ describe("VibratorJsTest", function () {
...
@@ -87,7 +89,6 @@ describe("VibratorJsTest", function () {
mode
:
'
short
'
,
mode
:
'
short
'
,
success
:
function
()
{
success
:
function
()
{
console
.
info
(
"
VibratorJsTest0002 success
"
);
console
.
info
(
"
VibratorJsTest0002 success
"
);
expect
(
true
).
assertTrue
();
done
();
done
();
},
},
fail
:
function
(
data
,
code
)
{
fail
:
function
(
data
,
code
)
{
...
@@ -112,7 +113,6 @@ describe("VibratorJsTest", function () {
...
@@ -112,7 +113,6 @@ describe("VibratorJsTest", function () {
mode
:
'
short
'
,
mode
:
'
short
'
,
success
:
function
()
{
success
:
function
()
{
console
.
info
(
"
VibratorJsTest0003 success
"
);
console
.
info
(
"
VibratorJsTest0003 success
"
);
expect
(
true
).
assertTrue
();
done
();
done
();
},
},
fail
:
function
(
data
,
code
)
{
fail
:
function
(
data
,
code
)
{
...
@@ -134,7 +134,6 @@ describe("VibratorJsTest", function () {
...
@@ -134,7 +134,6 @@ describe("VibratorJsTest", function () {
mode
:
'
short
'
,
mode
:
'
short
'
,
success
:
function
()
{
success
:
function
()
{
console
.
info
(
"
VibratorJsTest0004 success
"
);
console
.
info
(
"
VibratorJsTest0004 success
"
);
expect
(
true
).
assertTrue
();
done
();
done
();
},
},
});
});
...
@@ -151,7 +150,6 @@ describe("VibratorJsTest", function () {
...
@@ -151,7 +150,6 @@ describe("VibratorJsTest", function () {
vibrator
.
vibrate
({
vibrator
.
vibrate
({
success
:
function
()
{
success
:
function
()
{
console
.
info
(
"
VibratorJsTest0005 success
"
);
console
.
info
(
"
VibratorJsTest0005 success
"
);
expect
(
true
).
assertTrue
();
done
();
done
();
},
},
fail
:
function
(
data
,
code
)
{
fail
:
function
(
data
,
code
)
{
...
@@ -174,7 +172,6 @@ describe("VibratorJsTest", function () {
...
@@ -174,7 +172,6 @@ describe("VibratorJsTest", function () {
inInvalid
:
2
,
inInvalid
:
2
,
success
:
function
()
{
success
:
function
()
{
console
.
info
(
"
VibratorJsTest0006 success
"
);
console
.
info
(
"
VibratorJsTest0006 success
"
);
expect
(
true
).
assertTrue
();
done
();
done
();
},
},
fail
:
function
(
data
,
code
)
{
fail
:
function
(
data
,
code
)
{
...
@@ -202,7 +199,7 @@ describe("VibratorJsTest", function () {
...
@@ -202,7 +199,7 @@ describe("VibratorJsTest", function () {
},
},
},
25
);
},
25
);
}
catch
(
error
)
{
}
catch
(
error
)
{
var
errMessage
=
error
.
toString
().
slice
(
39
);
errMessage
=
error
.
toString
().
slice
(
39
);
console
.
info
(
'
VibratorJsTest0007 error:
'
+
error
);
console
.
info
(
'
VibratorJsTest0007 error:
'
+
error
);
expect
(
errMessage
).
assertEqual
(
errMessages
[
0
]);
expect
(
errMessage
).
assertEqual
(
errMessages
[
0
]);
done
();
done
();
...
@@ -221,26 +218,22 @@ describe("VibratorJsTest", function () {
...
@@ -221,26 +218,22 @@ describe("VibratorJsTest", function () {
mode
:
'
short
'
,
mode
:
'
short
'
,
success
:
function
()
{
success
:
function
()
{
console
.
info
(
"
VibratorJsTest0008 success
"
);
console
.
info
(
"
VibratorJsTest0008 success
"
);
expect
(
true
).
assertTrue
();
},
},
fail
:
function
(
data
,
code
)
{
fail
:
function
(
data
,
code
)
{
console
.
error
(
'
VibratorJsTest0008 failed. Code:
'
+
code
+
'
; Data:
'
+
data
);
console
.
error
(
'
VibratorJsTest0008 failed. Code:
'
+
code
+
'
; Data:
'
+
data
);
expect
(
false
).
assertTrue
();
expect
(
false
).
assertTrue
();
},
},
});
});
vibrator
.
vibrate
({
vibrator
.
vibrate
({
mode
:
'
short
'
,
mode
:
'
short
'
,
success
:
function
()
{
success
:
function
()
{
console
.
info
(
"
VibratorJsTest0008_1 success
"
);
console
.
info
(
"
VibratorJsTest0008_1 success
"
);
expect
(
true
).
assertTrue
();
},
},
fail
:
function
(
data
,
code
)
{
fail
:
function
(
data
,
code
)
{
console
.
error
(
'
VibratorJsTest0008_1 failed. Code:
'
+
code
+
'
; Data:
'
+
data
);
console
.
error
(
'
VibratorJsTest0008_1 failed. Code:
'
+
code
+
'
; Data:
'
+
data
);
expect
(
false
).
assertTrue
();
expect
(
false
).
assertTrue
();
},
},
});
});
setTimeout
(()
=>
{
setTimeout
(()
=>
{
done
();
done
();
},
500
);
},
500
);
...
@@ -258,7 +251,7 @@ describe("VibratorJsTest", function () {
...
@@ -258,7 +251,7 @@ describe("VibratorJsTest", function () {
vibrator
.
vibrate
(
'
xxx
'
,
done
);
vibrator
.
vibrate
(
'
xxx
'
,
done
);
}
catch
(
error
)
{
}
catch
(
error
)
{
console
.
info
(
'
VibratorJsTest0009 error:
'
+
error
);
console
.
info
(
'
VibratorJsTest0009 error:
'
+
error
);
var
errMessage
=
error
.
toString
().
slice
(
68
);
errMessage
=
error
.
toString
().
slice
(
68
);
expect
(
errMessage
).
assertEqual
(
errMessages
[
1
]);
expect
(
errMessage
).
assertEqual
(
errMessages
[
1
]);
done
();
done
();
}
}
...
@@ -275,7 +268,7 @@ describe("VibratorJsTest", function () {
...
@@ -275,7 +268,7 @@ describe("VibratorJsTest", function () {
try
{
try
{
vibrator
.
vibrate
(
done
);
vibrator
.
vibrate
(
done
);
}
catch
(
error
)
{
}
catch
(
error
)
{
var
errMessage
=
error
.
toString
().
slice
(
7
);
errMessage
=
error
.
toString
().
slice
(
7
);
console
.
info
(
'
VibratorJsTest0010 error:
'
+
error
);
console
.
info
(
'
VibratorJsTest0010 error:
'
+
error
);
expect
(
errMessage
).
assertEqual
(
errMessages
[
2
]);
expect
(
errMessage
).
assertEqual
(
errMessages
[
2
]);
done
();
done
();
...
@@ -301,7 +294,7 @@ describe("VibratorJsTest", function () {
...
@@ -301,7 +294,7 @@ describe("VibratorJsTest", function () {
},
function
()
{
},
function
()
{
},
25
);
},
25
);
}
catch
(
error
)
{
}
catch
(
error
)
{
var
errMessage
=
error
.
toString
().
slice
(
39
);
errMessage
=
error
.
toString
().
slice
(
39
);
console
.
info
(
'
VibratorJsTest0011 error:
'
+
error
);
console
.
info
(
'
VibratorJsTest0011 error:
'
+
error
);
expect
(
errMessage
).
assertEqual
(
errMessages
[
3
]);
expect
(
errMessage
).
assertEqual
(
errMessages
[
3
]);
done
();
done
();
...
...
sensors/sensor_standard/src/main/js/default/test/SensorGeomagneticTest.test.js
浏览文件 @
1c688540
...
@@ -13,7 +13,6 @@
...
@@ -13,7 +13,6 @@
* limitations under the License.
* limitations under the License.
*/
*/
import
sensor
from
'
@ohos.sensor
'
import
sensor
from
'
@ohos.sensor
'
import
{
describe
,
beforeAll
,
beforeEach
,
afterEach
,
afterAll
,
it
,
expect
}
from
'
deccjsunit/index
'
import
{
describe
,
beforeAll
,
beforeEach
,
afterEach
,
afterAll
,
it
,
expect
}
from
'
deccjsunit/index
'
describe
(
"
SensorJsTest
"
,
function
()
{
describe
(
"
SensorJsTest
"
,
function
()
{
...
@@ -173,8 +172,8 @@ describe("SensorJsTest", function () {
...
@@ -173,8 +172,8 @@ describe("SensorJsTest", function () {
*/
*/
it
(
'
SUB_SensorsSystem_GeomagneticAlgorithm_JSTest_0030
'
,
0
,
async
function
(
done
)
{
it
(
'
SUB_SensorsSystem_GeomagneticAlgorithm_JSTest_0030
'
,
0
,
async
function
(
done
)
{
console
.
info
(
"
------------------SUB_SensorsSystem_GeomagneticAlgorithm_JSTest_0030-------------------------
"
);
console
.
info
(
"
------------------SUB_SensorsSystem_GeomagneticAlgorithm_JSTest_0030-------------------------
"
);
let
geomagneticComponent
=
[
27779.234375
,
-
6214.9794921875
,
-
14924.6611328125
,
-
27.667943954467773
,
let
geomagneticComponent
=
[
-
1417119616
,
23146989568
,
-
6406359552
,
-
15.442885398864746
,
-
12.610970497131348
,
28465.9765625
,
32141.2109375
]
93.50342559814453
,
23190329344
,
24058943488
]
sensor
.
getGeomagneticField
({
'
latitude
'
:
0
,
'
longitude
'
:
0
,
'
altitude
'
:
0
},
Number
.
MAX_VALUE
,
sensor
.
getGeomagneticField
({
'
latitude
'
:
0
,
'
longitude
'
:
0
,
'
altitude
'
:
0
},
Number
.
MAX_VALUE
,
(
error
,
data
)
=>
{
(
error
,
data
)
=>
{
if
(
error
)
{
if
(
error
)
{
...
@@ -840,8 +839,8 @@ describe("SensorJsTest", function () {
...
@@ -840,8 +839,8 @@ describe("SensorJsTest", function () {
*/
*/
it
(
"
SUB_SensorsSystem_GeomagneticAlgorithm_JSTest_0270
"
,
0
,
async
function
(
done
)
{
it
(
"
SUB_SensorsSystem_GeomagneticAlgorithm_JSTest_0270
"
,
0
,
async
function
(
done
)
{
console
.
info
(
'
------------------SUB_SensorsSystem_GeomagneticAlgorithm_JSTest_0270------------------
'
);
console
.
info
(
'
------------------SUB_SensorsSystem_GeomagneticAlgorithm_JSTest_0270------------------
'
);
let
geomagneticComponent
=
[
27779.234375
,
-
6214.9794921875
,
-
14924.6611328125
,
-
27.667943954467773
,
let
geomagneticComponent
=
[
-
1417119616
,
23146989568
,
-
6406359552
,
-
15.442885398864746
,
-
12.610970497131348
,
28465.9765625
,
32141.2109375
]
93.50342559814453
,
23190329344
,
24058943488
]
await
sensor
.
getGeomagneticField
({
'
latitude
'
:
0
,
'
longitude
'
:
0
,
'
altitude
'
:
0
},
await
sensor
.
getGeomagneticField
({
'
latitude
'
:
0
,
'
longitude
'
:
0
,
'
altitude
'
:
0
},
Number
.
MAX_VALUE
).
then
((
data
)
=>
{
Number
.
MAX_VALUE
).
then
((
data
)
=>
{
console
.
info
(
'
SensorGeomagenticAlgorithmJSTest027 x:
'
+
data
.
x
+
'
,y:
'
+
data
.
y
+
'
,z:
'
+
data
.
z
console
.
info
(
'
SensorGeomagenticAlgorithmJSTest027 x:
'
+
data
.
x
+
'
,y:
'
+
data
.
y
+
'
,z:
'
+
data
.
z
...
...
sensors/sensor_standard/src/main/js/default/test/SensorOnOffTest.test_Accelerometer.js
已删除
100755 → 0
浏览文件 @
7fda93b3
/*
* 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
sensor
from
'
@ohos.sensor
'
import
{
describe
,
beforeAll
,
beforeEach
,
afterEach
,
afterAll
,
it
,
expect
}
from
'
deccjsunit/index
'
describe
(
"
SensorJsTest
"
,
function
()
{
beforeAll
(
function
()
{
/*
* @tc.setup: setup invoked before all testcases
*/
console
.
info
(
'
beforeAll caled
'
)
})
afterAll
(
function
()
{
/*
* @tc.teardown: teardown invoked after all testcases
*/
console
.
info
(
'
afterAll caled
'
)
})
beforeEach
(
function
()
{
/*
* @tc.setup: setup invoked before each testcases
*/
console
.
info
(
'
beforeEach caled
'
)
})
afterEach
(
function
()
{
/*
* @tc.teardown: teardown invoked after each testcases
*/
console
.
info
(
'
afterEach caled
'
)
})
/*
* @tc.number: SUB_SensorsSystem_Accelerometer_JSTest_0010
* @tc.name: SensorAccelerometerJSTest001
* @tc.desc:verify app info is not null
*/
it
(
"
SUB_SensorsSystem_Accelerometer_JSTest_0010
"
,
0
,
async
function
(
done
)
{
console
.
info
(
'
----------------------SUB_SensorsSystem_Accelerometer_JSTest_0010---------------------------
'
);
function
offPromise
()
{
return
new
Promise
((
resolve
,
reject
)
=>
{
sensor
.
off
(
sensor
.
SensorType
.
SENSOR_TYPE_ID_ACCELEROMETER
,
(
error
)
=>
{
if
(
error
)
{
console
.
info
(
'
SensorAccelerometerJSTest001 off error
'
);
expect
(
false
).
assertTrue
();
console
.
info
(
'
setTimeout ..start
'
)
setTimeout
((
err
)
=>
{
reject
(
err
);
},
500
);
}
else
{
console
.
info
(
'
SensorAccelerometerJSTest001 off success
'
);
expect
(
true
).
assertTrue
();
setTimeout
(()
=>
{
resolve
();
},
500
);
}
},
1000
)
})
}
let
promise
=
new
Promise
((
resolve
,
reject
)
=>
{
sensor
.
on
(
sensor
.
SensorType
.
SENSOR_TYPE_ID_ACCELEROMETER
,
function
(
error
,
data
)
{
if
(
error
)
{
console
.
info
(
'
SensorAccelerometerJSTest001 on error
'
);
expect
(
false
).
assertTrue
();
setTimeout
((
err
)
=>
{
reject
(
err
);
},
500
);
}
else
{
console
.
info
(
'
SensorAccelerometerJSTest001 on success, x:
'
+
data
.
x
+
"
y:
"
+
data
.
y
+
"
z:
"
+
data
.
z
);
expect
(
typeof
(
data
.
x
)).
assertEqual
(
"
number
"
);
expect
(
typeof
(
data
.
y
)).
assertEqual
(
"
number
"
);
expect
(
typeof
(
data
.
z
)).
assertEqual
(
"
number
"
);
setTimeout
(()
=>
{
resolve
();
},
500
);
}
});
})
await
promise
.
then
(()
=>
{
return
offPromise
();
},
()
=>
{
console
.
info
(
"
SensorAccelerometerJSTest001 reject
"
);
})
done
();
})
/*
* @tc.number: SUB_SensorsSystem_Accelerometer_JSTest_0020
* @tc.name: SensorAccelerometerJSTest002
* @tc.desc:verify app info is not null
*/
it
(
"
SUB_SensorsSystem_Accelerometer_JSTest_0020
"
,
0
,
async
function
(
done
)
{
console
.
info
(
'
----------------------SUB_SensorsSystem_Accelerometer_JSTest_0020---------------------------
'
);
function
onSensorCallback
(
error
,
data
)
{
if
(
error
)
{
console
.
info
(
'
SensorAccelerometerJSTest002 on success
'
);
expect
(
true
).
assertTrue
();
}
else
{
console
.
info
(
'
SensorAccelerometerJSTest002 on error
'
);
expect
(
false
).
assertTrue
();
}
setTimeout
(()
=>
{
done
();
},
500
);
}
sensor
.
on
(
-
1
,
onSensorCallback
);
})
/*
* @tc.number: SUB_SensorsSystem_Accelerometer_JSTest_0030
* @tc.name: SensorAccelerometerJSTest003
* @tc.desc:verify app info is not null
*/
it
(
"
SUB_SensorsSystem_Accelerometer_JSTest_0030
"
,
0
,
async
function
(
done
)
{
console
.
info
(
'
----------------------SUB_SensorsSystem_Accelerometer_JSTest_0030---------------------------
'
);
function
offPromise
()
{
return
new
Promise
((
resolve
,
reject
)
=>
{
sensor
.
off
(
1
,
(
error
)
=>
{
if
(
error
)
{
console
.
info
(
'
SensorAccelerometerJSTest003 off error
'
);
expect
(
false
).
assertTrue
();
setTimeout
((
err
)
=>
{
done
();
reject
(
err
);
},
500
);
}
else
{
console
.
info
(
'
SensorAccelerometerJSTest003 off success
'
);
expect
(
true
).
assertTrue
();
setTimeout
(()
=>
{
done
();
resolve
();
},
500
);
}
},
1000
)
})
}
let
promise
=
new
Promise
((
resolve
,
reject
)
=>
{
sensor
.
on
(
1
,
function
(
error
,
data
)
{
if
(
error
)
{
console
.
info
(
'
SensorAccelerometerJSTest003 on error
'
);
expect
(
false
).
assertTrue
();
setTimeout
((
err
)
=>
{
reject
(
err
);
},
500
);
}
else
{
console
.
info
(
'
SensorAccelerometerJSTest003 on success x:
'
+
data
.
x
+
"
y:
"
+
data
.
y
+
"
z:
"
+
data
.
z
);
expect
(
typeof
(
data
.
x
)).
assertEqual
(
"
number
"
);
expect
(
typeof
(
data
.
y
)).
assertEqual
(
"
number
"
);
expect
(
typeof
(
data
.
z
)).
assertEqual
(
"
number
"
);
setTimeout
(()
=>
{
resolve
();
},
500
);
}
},
{
'
interval
'
:
200000000
});
})
await
promise
.
then
(()
=>
{
return
offPromise
();
},
()
=>
{
console
.
info
(
"
SensorAccelerometerJSTest003 reject
"
);
})
done
();
})
/*
* @tc.number: SUB_SensorsSystem_Accelerometer_JSTest_0040
* @tc.name: SensorAccelerometerJSTest004
* @tc.desc:verify app info is not null
*/
it
(
"
SUB_SensorsSystem_Accelerometer_JSTest_0040
"
,
0
,
function
()
{
console
.
info
(
'
----------------------SUB_SensorsSystem_Accelerometer_JSTest_0040---------------------------
'
);
sensor
.
on
(
1
,
function
()
{
},
{
'
interval
'
:
100000000
},
5
);
expect
(
true
).
assertTrue
();
console
.
info
(
'
----------------------SensorAccelerometerJSTest004--------------------------- end
'
);
})
/*
* @tc.number: SUB_SensorsSystem_Accelerometer_JSTest_0050
* @tc.name: SensorAccelerometerJSTest005
* @tc.desc:verify app info is not null
*/
it
(
"
SUB_SensorsSystem_Accelerometer_JSTest_0050
"
,
0
,
async
function
(
done
)
{
function
onceSensorCallback
(
error
,
data
)
{
if
(
error
)
{
console
.
info
(
'
SensorAccelerometerJSTest005 once error
'
);
expect
(
false
).
assertTrue
();
}
else
{
console
.
info
(
'
SensorAccelerometerJSTest005 once success x:
'
+
data
.
x
+
"
y:
"
+
data
.
y
+
"
z:
"
+
data
.
z
);
expect
(
typeof
(
data
.
x
)).
assertEqual
(
"
number
"
);
expect
(
typeof
(
data
.
y
)).
assertEqual
(
"
number
"
);
expect
(
typeof
(
data
.
z
)).
assertEqual
(
"
number
"
);
}
setTimeout
(()
=>
{
done
();
},
500
);
}
sensor
.
once
(
sensor
.
SensorType
.
SENSOR_TYPE_ID_ACCELEROMETER
,
onceSensorCallback
);
})
/*
* @tc.number: SUB_SensorsSystem_Accelerometer_JSTest_0060
* @tc.name: SensorAccelerometerJSTest006
* @tc.desc:verify app info is not null
*/
it
(
"
SUB_SensorsSystem_Accelerometer_JSTest_0060
"
,
0
,
async
function
(
done
)
{
function
onceSensorCallback
(
error
,
data
)
{
if
(
error
)
{
console
.
info
(
'
SensorAccelerometerJSTest006 on success
'
);
expect
(
true
).
assertTrue
();
}
else
{
console
.
info
(
'
SensorAccelerometerJSTest006 on error
'
);
expect
(
false
).
assertTrue
();
}
setTimeout
(()
=>
{
done
();
},
500
);
}
sensor
.
once
(
-
1
,
onceSensorCallback
);
})
/*
* @tc.number: SUB_SensorsSystem_Accelerometer_JSTest_0070
* @tc.name: SensorAccelerometerJSTest007
* @tc.desc:verify app info is not null
*/
it
(
"
SUB_SensorsSystem_Accelerometer_JSTest_0070
"
,
0
,
function
()
{
sensor
.
once
(
1
,
function
()
{
},
5
);
expect
(
true
).
assertTrue
();
})
/*
* @tc.number: SUB_SensorsSystem_Accelerometer_JSTest_0080
* @tc.name: SensorAccelerometerJSTest008
* @tc.desc:verify app info is not null
*/
it
(
"
SUB_SensorsSystem_Accelerometer_JSTest_0080
"
,
0
,
async
function
(
done
)
{
function
offCallback
(
error
)
{
if
(
error
)
{
console
.
info
(
'
SensorAccelerometerJSTest008 off success
'
);
expect
(
true
).
assertTrue
();
}
else
{
console
.
info
(
'
SensorAccelerometerJSTest008 off error
'
);
expect
(
false
).
assertTrue
();
}
setTimeout
(()
=>
{
done
();
},
500
);
}
sensor
.
off
(
-
1
,
offCallback
);
})
/*
* @tc.number: SUB_SensorsSystem_Accelerometer_JSTest_0090
* @tc.name: SensorAccelerometerJSTest009
* @tc.desc:verify app info is not null
*/
it
(
"
SUB_SensorsSystem_Accelerometer_JSTest_0090
"
,
0
,
async
function
(
done
)
{
function
offCallback
(
error
)
{
if
(
error
)
{
console
.
info
(
'
SensorAccelerometerJSTest009 off success
'
);
expect
(
true
).
assertTrue
();
}
else
{
console
.
info
(
'
SensorAccelerometerJSTest009 off error
'
);
expect
(
false
).
assertTrue
();
}
setTimeout
(()
=>
{
done
();
},
500
);
}
sensor
.
off
(
1
,
offCallback
);
})
/*
* @tc.number: SUB_SensorsSystem_Accelerometer_JSTest_0100
* @tc.name: SensorAccelerometerJSTest010
* @tc.desc:verify app info is not null
*/
it
(
"
SUB_SensorsSystem_Accelerometer_JSTest_0100
"
,
0
,
async
function
(
done
)
{
function
offCallback
(
error
)
{
if
(
error
)
{
console
.
info
(
'
SensorAccelerometerJSTest010 off success
'
);
expect
(
true
).
assertTrue
();
}
else
{
console
.
info
(
'
SensorAccelerometerJSTest010 off error
'
);
expect
(
false
).
assertTrue
();
}
setTimeout
(()
=>
{
done
();
},
500
);
}
sensor
.
off
(
1000000
,
offCallback
);
})
/*
* @tc.number: SUB_SensorsSystem_Accelerometer_JSTest_0110
* @tc.name: SensorAccelerometerJSTest011
* @tc.desc:verify app info is not null
*/
it
(
"
SUB_SensorsSystem_Accelerometer_JSTest_0110
"
,
0
,
async
function
(
done
)
{
function
onceSensorCallback
(
error
,
data
)
{
if
(
error
)
{
console
.
info
(
'
SensorAccelerometerJSTest011 once success
'
);
expect
(
true
).
assertTrue
();
}
else
{
console
.
info
(
'
SensorAccelerometerJSTest011 once error
'
);
expect
(
false
).
assertTrue
();
}
setTimeout
(()
=>
{
done
();
},
500
);
}
sensor
.
once
(
1000000
,
onceSensorCallback
);
})
/*
* @tc.number: SUB_SensorsSystem_Accelerometer_JSTest_0120
* @tc.name: SensorAccelerometerJSTest012
* @tc.desc:verify app info is not null
*/
it
(
"
SUB_SensorsSystem_Accelerometer_JSTest_0120
"
,
0
,
async
function
(
done
)
{
function
onCallback
(
error
)
{
if
(
error
)
{
console
.
info
(
'
SensorAccelerometerJSTest012 on success
'
);
expect
(
true
).
assertTrue
();
}
else
{
console
.
info
(
'
SensorAccelerometerJSTest012 on error
'
);
expect
(
false
).
assertTrue
();
}
setTimeout
(()
=>
{
done
();
},
500
);
}
sensor
.
on
(
1000000
,
onCallback
);
})
/*
* @tc.number: SUB_SensorsSystem_Accelerometer_JSTest_0130
* @tc.name: SensorAccelerometerJSTest013
* @tc.desc:verify app info is not null
*/
it
(
"
SUB_SensorsSystem_Accelerometer_JSTest_0130
"
,
0
,
function
()
{
sensor
.
off
(
1
,
5
);
expect
(
true
).
assertTrue
();
})
/*
* @tc.number: SUB_SensorsSystem_Accelerometer_JSTest_0140
* @tc.name: SensorAccelerometerJSTest014
* @tc.desc:verify app info is not null
*/
it
(
"
SUB_SensorsSystem_Accelerometer_JSTest_0140
"
,
0
,
async
function
(
done
)
{
console
.
info
(
'
----------------------SUB_SensorsSystem_Accelerometer_JSTest_0140---------------------------
'
);
function
offPromise2
()
{
return
new
Promise
((
resolve
,
reject
)
=>
{
sensor
.
off
(
1
,
(
error
)
=>
{
if
(
error
)
{
console
.
info
(
'
SensorAccelerometerJSTest014 off2 success
'
);
expect
(
true
).
assertTrue
();
setTimeout
(()
=>
{
done
(
err
);
reject
(
err
)
},
500
);
}
else
{
console
.
info
(
'
SensorAccelerometerJSTest014 off2 error
'
);
expect
(
false
).
assertTrue
();
setTimeout
(()
=>
{
done
();
resolve
()
},
500
);
}
});
})
}
function
offPromise1
()
{
return
new
Promise
((
resolve
,
reject
)
=>
{
sensor
.
off
(
1
,
(
error
)
=>
{
if
(
error
)
{
console
.
info
(
'
SensorAccelerometerJSTest014 off1 error
'
);
expect
(
false
).
assertTrue
();
setTimeout
((
err
)
=>
{
reject
(
err
);
},
500
);
}
else
{
console
.
info
(
'
SensorAccelerometerJSTest014 off1 success
'
);
expect
(
true
).
assertTrue
();
setTimeout
(()
=>
{
resolve
();
},
500
);
}
});
})
}
let
promise
=
new
Promise
((
resolve
,
reject
)
=>
{
sensor
.
on
(
1
,
function
(
error
,
data
)
{
if
(
error
)
{
console
.
info
(
'
SensorAccelerometerJSTest014 on error
'
);
expect
(
false
).
assertTrue
();
setTimeout
((
err
)
=>
{
reject
(
err
);
},
500
);
}
else
{
console
.
info
(
'
SensorAccelerometerJSTest014 on success x:
'
+
data
.
x
+
"
y:
"
+
data
.
y
+
"
z:
"
+
data
.
z
);
expect
(
typeof
(
data
.
x
)).
assertEqual
(
"
number
"
);
expect
(
typeof
(
data
.
y
)).
assertEqual
(
"
number
"
);
expect
(
typeof
(
data
.
z
)).
assertEqual
(
"
number
"
);
setTimeout
(()
=>
{
resolve
();
},
500
);
}
});
})
await
promise
.
then
(()
=>
{
return
offPromise1
();
}).
then
(()
=>
{
return
offPromise2
();
});
done
();
})
/*
* @tc.number: SUB_SensorsSystem_Accelerometer_JSTest_0150
* @tc.name: SensorAccelerometerJSTest015
* @tc.desc:verify app info is not null
*/
it
(
"
SUB_SensorsSystem_Accelerometer_JSTest_0150
"
,
0
,
async
function
(
done
)
{
console
.
info
(
'
----------------------SUB_SensorsSystem_Accelerometer_JSTest_0150---------------------------
'
);
function
offPromise
()
{
return
new
Promise
((
resolve
,
reject
)
=>
{
sensor
.
off
(
1
,
(
error
)
=>
{
if
(
error
)
{
console
.
info
(
'
SensorAccelerometerJSTest015 off error
'
);
expect
(
false
).
assertTrue
();
setTimeout
((
err
)
=>
{
done
();
reject
(
err
);
},
500
);
}
else
{
console
.
info
(
'
SensorAccelerometerJSTest015 off success
'
);
expect
(
true
).
assertTrue
();
setTimeout
(()
=>
{
done
();
resolve
();
},
500
);
}
});
})
}
function
onPromise2
()
{
return
new
Promise
((
resolve
,
reject
)
=>
{
sensor
.
on
(
1
,
function
(
error
,
data
)
{
if
(
error
)
{
console
.
info
(
'
SensorAccelerometerJSTest015 on2 error
'
);
expect
(
false
).
assertTrue
();
setTimeout
((
err
)
=>
{
reject
(
err
);
},
500
);
}
else
{
console
.
info
(
'
SensorAccelerometerJSTest015 on2 success x:
'
+
data
.
x
+
"
y:
"
+
data
.
y
+
"
z:
"
+
data
.
z
);
expect
(
typeof
(
data
.
x
)).
assertEqual
(
"
number
"
);
expect
(
typeof
(
data
.
y
)).
assertEqual
(
"
number
"
);
expect
(
typeof
(
data
.
z
)).
assertEqual
(
"
number
"
);
setTimeout
(()
=>
{
resolve
();
},
500
);
}
});
})
}
let
onPromise1
=
new
Promise
((
resolve
,
reject
)
=>
{
sensor
.
on
(
1
,
function
(
error
,
data
)
{
if
(
error
)
{
console
.
info
(
'
SensorAccelerometerJSTest015 on1 error
'
);
expect
(
false
).
assertTrue
();
setTimeout
((
err
)
=>
{
reject
(
err
);
},
500
);
}
else
{
console
.
info
(
'
SensorAccelerometerJSTest015 on1 success x:
'
+
data
.
x
+
"
y:
"
+
data
.
y
+
"
z:
"
+
data
.
z
);
expect
(
typeof
(
data
.
x
)).
assertEqual
(
"
number
"
);
expect
(
typeof
(
data
.
y
)).
assertEqual
(
"
number
"
);
expect
(
typeof
(
data
.
z
)).
assertEqual
(
"
number
"
);
setTimeout
(()
=>
{
resolve
();
},
500
);
}
});
})
await
onPromise1
.
then
(()
=>
{
return
onPromise2
();
}).
then
(()
=>
{
return
offPromise
();
});
done
();
})
/*
* @tc.number: SUB_SensorsSystem_Accelerometer_JSTest_0160
* @tc.name: SensorAccelerometerJSTest016
* @tc.desc:verify app info is not null
*/
it
(
"
SUB_SensorsSystem_Accelerometer_JSTest_0160
"
,
0
,
async
function
(
done
)
{
console
.
info
(
'
----------------------SUB_SensorsSystem_Accelerometer_JSTest_0160---------------------------
'
);
function
offPromise
()
{
return
new
Promise
((
resolve
,
reject
)
=>
{
sensor
.
off
(
1
,
(
error
)
=>
{
if
(
error
)
{
console
.
info
(
'
SensorAccelerometerJSTest016 off error
'
);
expect
(
false
).
assertTrue
();
setTimeout
((
err
)
=>
{
done
();
reject
(
err
);
},
500
);
}
else
{
console
.
info
(
'
SensorAccelerometerJSTest016 off success
'
);
expect
(
true
).
assertTrue
();
setTimeout
(()
=>
{
done
();
resolve
();
},
500
);
}
});
})
}
function
oncePromise
()
{
return
new
Promise
((
resolve
,
reject
)
=>
{
sensor
.
once
(
1
,
function
(
error
,
data
)
{
if
(
error
)
{
console
.
info
(
'
SensorAccelerometerJSTest016 once error
'
);
expect
(
false
).
assertTrue
();
setTimeout
((
err
)
=>
{
reject
(
err
);
},
500
);
}
else
{
console
.
info
(
'
SensorAccelerometerJSTest016 once success x:
'
+
data
.
x
+
"
y:
"
+
data
.
y
+
"
z:
"
+
data
.
z
);
expect
(
typeof
(
data
.
x
)).
assertEqual
(
"
number
"
);
expect
(
typeof
(
data
.
y
)).
assertEqual
(
"
number
"
);
expect
(
typeof
(
data
.
z
)).
assertEqual
(
"
number
"
);
setTimeout
(()
=>
{
resolve
();
},
500
);
}
});
})
}
let
onPromise1
=
new
Promise
((
resolve
,
reject
)
=>
{
sensor
.
on
(
1
,
function
(
error
,
data
)
{
if
(
error
)
{
console
.
info
(
'
SensorAccelerometerJSTest016 on1 error
'
);
expect
(
false
).
assertTrue
();
setTimeout
((
err
)
=>
{
reject
(
err
);
},
500
);
}
else
{
console
.
info
(
'
SensorAccelerometerJSTest016 on1 success x:
'
+
data
.
x
+
"
y:
"
+
data
.
y
+
"
z:
"
+
data
.
z
);
expect
(
typeof
(
data
.
x
)).
assertEqual
(
"
number
"
);
expect
(
typeof
(
data
.
y
)).
assertEqual
(
"
number
"
);
expect
(
typeof
(
data
.
z
)).
assertEqual
(
"
number
"
);
setTimeout
(()
=>
{
resolve
();
},
500
);
}
});
})
await
onPromise1
.
then
(()
=>
{
return
oncePromise
();
}).
then
(()
=>
{
return
offPromise
();
});
done
();
})
})
sensors/sensor_standard/src/main/js/default/test/SensorOnOffTest.test_Ambient_Light.js
已删除
100755 → 0
浏览文件 @
7fda93b3
/*
* 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
sensor
from
'
@ohos.sensor
'
import
{
describe
,
beforeAll
,
beforeEach
,
afterEach
,
afterAll
,
it
,
expect
}
from
'
deccjsunit/index
'
describe
(
"
SensorJsTest
"
,
function
()
{
beforeAll
(
function
()
{
/*
* @tc.setup: setup invoked before all testcases
*/
console
.
info
(
'
beforeAll caled
'
)
})
afterAll
(
function
()
{
/*
* @tc.teardown: teardown invoked after all testcases
*/
console
.
info
(
'
afterAll caled
'
)
})
beforeEach
(
function
()
{
/*
* @tc.setup: setup invoked before each testcases
*/
console
.
info
(
'
beforeEach caled
'
)
})
afterEach
(
function
()
{
/*
* @tc.teardown: teardown invoked after each testcases
*/
console
.
info
(
'
afterEach caled
'
)
})
/*
* @tc.number: SUB_SensorsSystem_Ambient_Light_JSTest_0010
* @tc.name: SensorAmbientLightJSTest001
* @tc.desc:verify app info is not null
*/
it
(
"
SUB_SensorsSystem_Ambient_Light_JSTest_0010
"
,
0
,
async
function
(
done
)
{
console
.
info
(
'
----------------------SUB_SensorsSystem_Ambient_Light_JSTest_0010---------------------------
'
);
function
offPromise
()
{
return
new
Promise
((
resolve
,
reject
)
=>
{
sensor
.
off
(
sensor
.
SensorType
.
SENSOR_TYPE_ID_AMBIENT_LIGHT
,
(
error
)
=>
{
if
(
error
)
{
console
.
info
(
'
SensorAmbientLightJSTest001 off error
'
);
expect
(
false
).
assertTrue
();
console
.
info
(
'
setTimeout ..start
'
)
setTimeout
((
err
)
=>
{
reject
(
err
);
},
500
);
}
else
{
console
.
info
(
'
SensorAmbientLightJSTest001 off success
'
);
expect
(
true
).
assertTrue
();
setTimeout
(()
=>
{
resolve
();
},
500
);
}
},
1000
)
})
}
let
promise
=
new
Promise
((
resolve
,
reject
)
=>
{
sensor
.
on
(
sensor
.
SensorType
.
SENSOR_TYPE_ID_AMBIENT_LIGHT
,
function
(
error
,
data
)
{
if
(
error
)
{
console
.
info
(
'
SensorAmbientLightJSTest001 on error
'
);
expect
(
false
).
assertTrue
();
setTimeout
((
err
)
=>
{
reject
(
err
);
},
500
);
}
else
{
console
.
info
(
'
SensorAmbientLightJSTest001 on success, success data:
'
+
data
.
intensity
);
expect
(
typeof
(
data
.
intensity
)).
assertEqual
(
"
number
"
);
setTimeout
(()
=>
{
resolve
();
},
500
);
}
});
})
await
promise
.
then
(()
=>
{
return
offPromise
();
},
()
=>
{
console
.
info
(
"
SensorAmbientLightJSTest001 reject
"
);
})
done
();
})
/*
* @tc.number: SUB_SensorsSystem_Ambient_Light_JSTest_0020
* @tc.name: SensorAmbientLightJSTest002
* @tc.desc:verify app info is not null
*/
it
(
"
SUB_SensorsSystem_Ambient_Light_JSTest_0020
"
,
0
,
async
function
(
done
)
{
console
.
info
(
'
----------------------SUB_SensorsSystem_Ambient_Light_JSTest_0020---------------------------
'
);
function
onSensorCallback
(
error
,
data
)
{
if
(
error
)
{
console
.
info
(
'
SensorAmbientLightJSTest002 on success
'
);
expect
(
true
).
assertTrue
();
}
else
{
console
.
info
(
'
SensorAmbientLightJSTest002 on error
'
);
expect
(
false
).
assertTrue
();
}
setTimeout
(()
=>
{
done
();
},
500
);
}
sensor
.
on
(
-
1
,
onSensorCallback
);
})
/*
* @tc.number: SUB_SensorsSystem_Ambient_Light_JSTest_0030
* @tc.name: SensorAmbientLightJSTest003
* @tc.desc:verify app info is not null
*/
it
(
"
SUB_SensorsSystem_Ambient_Light_JSTest_0030
"
,
0
,
async
function
(
done
)
{
console
.
info
(
'
----------------------SUB_SensorsSystem_Ambient_Light_JSTest_0030---------------------------
'
);
function
offPromise
()
{
return
new
Promise
((
resolve
,
reject
)
=>
{
sensor
.
off
(
5
,
(
error
)
=>
{
if
(
error
)
{
console
.
info
(
'
SensorAmbientLightJSTest003 off error
'
);
expect
(
false
).
assertTrue
();
setTimeout
((
err
)
=>
{
done
();
reject
(
err
);
},
500
);
}
else
{
console
.
info
(
'
SensorAmbientLightJSTest003 off success
'
);
expect
(
true
).
assertTrue
();
setTimeout
(()
=>
{
done
();
resolve
();
},
500
);
}
},
1000
)
})
}
let
promise
=
new
Promise
((
resolve
,
reject
)
=>
{
sensor
.
on
(
5
,
function
(
error
,
data
)
{
if
(
error
)
{
console
.
info
(
'
SensorAmbientLightJSTest003 on error
'
);
expect
(
false
).
assertTrue
();
setTimeout
((
err
)
=>
{
reject
(
err
);
},
500
);
}
else
{
console
.
info
(
'
SensorAmbientLightJSTest003 on success data:
'
+
data
.
intensity
);
expect
(
typeof
(
data
.
intensity
)).
assertEqual
(
"
number
"
);
setTimeout
(()
=>
{
resolve
();
},
500
);
}
},
{
'
interval
'
:
200000000
});
})
await
promise
.
then
(()
=>
{
return
offPromise
();
},
()
=>
{
console
.
info
(
"
SensorAmbientLightJSTest003 reject
"
);
})
done
();
})
/*
* @tc.number: SUB_SensorsSystem_Ambient_Light_JSTest_0040
* @tc.name: SensorAmbientLightJSTest004
* @tc.desc:verify app info is not null
*/
it
(
"
SUB_SensorsSystem_Ambient_Light_JSTest_0040
"
,
0
,
function
()
{
console
.
info
(
'
----------------------SensorAmbientLightJSTest004---------------------------
'
);
sensor
.
on
(
5
,
function
()
{
},
{
'
interval
'
:
100000000
},
5
);
expect
(
true
).
assertTrue
();
console
.
info
(
'
----------------------SensorAmbientLightJSTest004--------------------------- end
'
);
})
/*
* @tc.number: SUB_SensorsSystem_Ambient_Light_JSTest_0050
* @tc.name: SensorAmbientLightJSTest005
* @tc.desc:verify app info is not null
*/
it
(
"
SUB_SensorsSystem_Ambient_Light_JSTest_0050
"
,
0
,
async
function
(
done
)
{
function
onceSensorCallback
(
error
,
data
)
{
if
(
error
)
{
console
.
info
(
'
SensorAmbientLightJSTest005 once error
'
);
expect
(
false
).
assertTrue
();
}
else
{
console
.
info
(
'
SensorAmbientLightJSTest005 once success data:
'
+
data
.
intensity
);
expect
(
typeof
(
data
.
intensity
)).
assertEqual
(
"
number
"
);
}
setTimeout
(()
=>
{
done
();
},
500
);
}
sensor
.
once
(
sensor
.
SensorType
.
SENSOR_TYPE_ID_AMBIENT_LIGHT
,
onceSensorCallback
);
})
/*
* @tc.number: SUB_SensorsSystem_Ambient_Light_JSTest_0060
* @tc.name: SensorAmbientLightJSTest006
* @tc.desc:verify app info is not null
*/
it
(
"
SUB_SensorsSystem_Ambient_Light_JSTest_0060
"
,
0
,
async
function
(
done
)
{
function
onceSensorCallback
(
error
,
data
)
{
if
(
error
)
{
console
.
info
(
'
SensorAmbientLightJSTest006 on success
'
);
expect
(
true
).
assertTrue
();
}
else
{
console
.
info
(
'
SensorAmbientLightJSTest006 on error
'
);
expect
(
false
).
assertTrue
();
}
setTimeout
(()
=>
{
done
();
},
500
);
}
sensor
.
once
(
-
1
,
onceSensorCallback
);
})
/*
* @tc.number: SUB_SensorsSystem_Ambient_Light_JSTest_0070
* @tc.name: SensorAmbientLightJSTest007
* @tc.desc:verify app info is not null
*/
it
(
"
SensorJsTest007
"
,
0
,
function
()
{
sensor
.
once
(
5
,
function
()
{
},
5
);
expect
(
true
).
assertTrue
();
})
/*
* @tc.number: SUB_SensorsSystem_Ambient_Light_JSTest_0080
* @tc.name: SensorAmbientLightJSTest008
* @tc.desc:verify app info is not null
*/
it
(
"
SUB_SensorsSystem_Ambient_Light_JSTest_0080
"
,
0
,
async
function
(
done
)
{
function
offCallback
(
error
)
{
if
(
error
)
{
console
.
info
(
'
SensorAmbientLightJSTest008 off success
'
);
expect
(
true
).
assertTrue
();
}
else
{
console
.
info
(
'
SensorAmbientLightJSTest008 off error
'
);
expect
(
false
).
assertTrue
();
}
setTimeout
(()
=>
{
done
();
},
500
);
}
sensor
.
off
(
-
1
,
offCallback
);
})
/*
* @tc.number: SUB_SensorsSystem_Ambient_Light_JSTest_0090
* @tc.name: SensorAmbientLightJSTest009
* @tc.desc:verify app info is not null
*/
it
(
"
SUB_SensorsSystem_Ambient_Light_JSTest_0090
"
,
0
,
async
function
(
done
)
{
function
offCallback
(
error
)
{
if
(
error
)
{
console
.
info
(
'
SensorAmbientLightJSTest009 off success
'
);
expect
(
true
).
assertTrue
();
}
else
{
console
.
info
(
'
SensorAmbientLightJSTest009 off error
'
);
expect
(
false
).
assertTrue
();
}
setTimeout
(()
=>
{
done
();
},
500
);
}
sensor
.
off
(
5
,
offCallback
);
})
/*
* @tc.number: SUB_SensorsSystem_Ambient_Light_JSTest_0100
* @tc.name: SensorAmbientLightJSTest010
* @tc.desc:verify app info is not null
*/
it
(
"
SUB_SensorsSystem_Ambient_Light_JSTest_0100
"
,
0
,
async
function
(
done
)
{
function
offCallback
(
error
)
{
if
(
error
)
{
console
.
info
(
'
SensorAmbientLightJSTest010 off success
'
);
expect
(
true
).
assertTrue
();
}
else
{
console
.
info
(
'
SensorAmbientLightJSTest010 off error
'
);
expect
(
false
).
assertTrue
();
}
setTimeout
(()
=>
{
done
();
},
500
);
}
sensor
.
off
(
2000000
,
offCallback
);
})
/*
* @tc.number: SUB_SensorsSystem_Ambient_Light_JSTest_0110
* @tc.name: SensorAmbientLightJSTest011
* @tc.desc:verify app info is not null
*/
it
(
"
SUB_SensorsSystem_Ambient_Light_JSTest_0110
"
,
0
,
async
function
(
done
)
{
function
onceSensorCallback
(
error
,
data
)
{
if
(
error
)
{
console
.
info
(
'
SensorAmbientLightJSTest011 once success
'
);
expect
(
true
).
assertTrue
();
}
else
{
console
.
info
(
'
SensorAmbientLightJSTest011 once error
'
);
expect
(
false
).
assertTrue
();
}
setTimeout
(()
=>
{
done
();
},
500
);
}
sensor
.
once
(
2000000
,
onceSensorCallback
);
})
/*
* @tc.number: SUB_SensorsSystem_Ambient_Light_JSTest_0120
* @tc.name: SensorAmbientLightJSTest012
* @tc.desc:verify app info is not null
*/
it
(
"
SUB_SensorsSystem_Ambient_Light_JSTest_0120
"
,
0
,
async
function
(
done
)
{
function
onCallback
(
error
)
{
if
(
error
)
{
console
.
info
(
'
SensorAmbientLightJSTest012 on success
'
);
expect
(
true
).
assertTrue
();
}
else
{
console
.
info
(
'
SensorAmbientLightJSTest012 on error
'
);
expect
(
false
).
assertTrue
();
}
setTimeout
(()
=>
{
done
();
},
500
);
}
sensor
.
on
(
2000000
,
onCallback
);
})
/*
* @tc.number: SUB_SensorsSystem_Ambient_Light_JSTest_0130
* @tc.name: SensorAmbientLightJSTest013
* @tc.desc:verify app info is not null
*/
it
(
"
SUB_SensorsSystem_Ambient_Light_JSTest_0130
"
,
0
,
function
()
{
sensor
.
off
(
5
,
5
);
expect
(
true
).
assertTrue
();
})
/*
* @tc.number: SUB_SensorsSystem_Ambient_Light_JSTest_0140
* @tc.name: SensorAmbientLightJSTest014
* @tc.desc:verify app info is not null
*/
it
(
"
SUB_SensorsSystem_Ambient_Light_JSTest_0140
"
,
0
,
async
function
(
done
)
{
console
.
info
(
'
----------------------SUB_SensorsSystem_Ambient_Light_JSTest_0140---------------------------
'
);
function
offPromise2
()
{
return
new
Promise
((
resolve
,
reject
)
=>
{
sensor
.
off
(
5
,
(
error
)
=>
{
if
(
error
)
{
console
.
info
(
'
SensorAmbientLightJSTest014 off2 success
'
);
expect
(
true
).
assertTrue
();
setTimeout
((
err
)
=>
{
done
();
reject
(
err
)
},
500
);
}
else
{
console
.
info
(
'
SensorAmbientLightJSTest014 off2 error
'
);
expect
(
false
).
assertTrue
();
setTimeout
(()
=>
{
done
();
resolve
()
},
500
);
}
});
})
}
function
offPromise1
()
{
return
new
Promise
((
resolve
,
reject
)
=>
{
sensor
.
off
(
5
,
(
error
)
=>
{
if
(
error
)
{
console
.
info
(
'
SensorAmbientLightJSTest014 off1 error
'
);
expect
(
false
).
assertTrue
();
setTimeout
((
err
)
=>
{
reject
(
err
);
},
500
);
}
else
{
console
.
info
(
'
SensorAmbientLightJSTest014 off1 success
'
);
expect
(
true
).
assertTrue
();
setTimeout
(()
=>
{
resolve
();
},
500
);
}
});
})
}
let
promise
=
new
Promise
((
resolve
,
reject
)
=>
{
sensor
.
on
(
5
,
function
(
error
,
data
)
{
if
(
error
)
{
console
.
info
(
'
SensorAmbientLightJSTest014 on error
'
);
expect
(
false
).
assertTrue
();
setTimeout
((
err
)
=>
{
reject
(
err
);
},
500
);
}
else
{
console
.
info
(
'
SensorAmbientLightJSTest014 on success data:
'
+
data
.
intensity
);
expect
(
typeof
(
data
.
intensity
)).
assertEqual
(
"
number
"
);
setTimeout
(()
=>
{
resolve
();
},
500
);
}
});
})
await
promise
.
then
(()
=>
{
return
offPromise1
();
}).
then
(()
=>
{
return
offPromise2
();
});
done
();
})
/*
* @tc.number: SUB_SensorsSystem_Ambient_Light_JSTest_0150
* @tc.name: SensorAmbientLightJSTest015
* @tc.desc:verify app info is not null
*/
it
(
"
SUB_SensorsSystem_Ambient_Light_JSTest_0150
"
,
0
,
async
function
(
done
)
{
console
.
info
(
'
----------------------SUB_SensorsSystem_Ambient_Light_JSTest_0150---------------------------
'
);
function
offPromise
()
{
return
new
Promise
((
resolve
,
reject
)
=>
{
sensor
.
off
(
5
,
(
error
)
=>
{
if
(
error
)
{
console
.
info
(
'
SensorAmbientLightJSTest015 off error
'
);
expect
(
false
).
assertTrue
();
setTimeout
((
err
)
=>
{
done
();
reject
(
err
);
},
500
);
}
else
{
console
.
info
(
'
SensorAmbientLightJSTest015 off success
'
);
expect
(
true
).
assertTrue
();
setTimeout
(()
=>
{
done
();
resolve
();
},
500
);
}
});
})
}
function
onPromise2
()
{
return
new
Promise
((
resolve
,
reject
)
=>
{
sensor
.
on
(
5
,
function
(
error
,
data
)
{
if
(
error
)
{
console
.
info
(
'
SensorAmbientLightJSTest015 on2 error
'
);
expect
(
false
).
assertTrue
();
setTimeout
((
err
)
=>
{
reject
(
err
);
},
500
);
}
else
{
console
.
info
(
'
SensorAmbientLightJSTest015 on2 success data:
'
+
data
.
intensity
);
expect
(
typeof
(
data
.
intensity
)).
assertEqual
(
"
number
"
);
setTimeout
(()
=>
{
resolve
();
},
500
);
}
});
})
}
let
onPromise1
=
new
Promise
((
resolve
,
reject
)
=>
{
sensor
.
on
(
5
,
function
(
error
,
data
)
{
if
(
error
)
{
console
.
info
(
'
SensorAmbientLightJSTest015 on1 error
'
);
expect
(
false
).
assertTrue
();
setTimeout
((
err
)
=>
{
reject
(
err
);
},
500
);
}
else
{
console
.
info
(
'
SensorAmbientLightJSTest015 on1 success data:
'
+
data
.
intensity
);
expect
(
typeof
(
data
.
intensity
)).
assertEqual
(
"
number
"
);
setTimeout
(()
=>
{
resolve
();
},
500
);
}
});
})
await
onPromise1
.
then
(()
=>
{
return
onPromise2
();
}).
then
(()
=>
{
return
offPromise
();
});
done
();
})
/*
* @tc.number: SUB_SensorsSystem_Ambient_Light_JSTest_0160
* @tc.name: SensorAmbientLightJSTest016
* @tc.desc:verify app info is not null
*/
it
(
"
SUB_SensorsSystem_Ambient_Light_JSTest_0160
"
,
0
,
async
function
(
done
)
{
console
.
info
(
'
----------------------SUB_SensorsSystem_Ambient_Light_JSTest_0160---------------------------
'
);
function
offPromise
()
{
return
new
Promise
((
resolve
,
reject
)
=>
{
sensor
.
off
(
5
,
(
error
)
=>
{
if
(
error
)
{
console
.
info
(
'
SensorAmbientLightJSTest016 off error
'
);
expect
(
false
).
assertTrue
();
setTimeout
((
err
)
=>
{
done
();
reject
(
err
);
},
500
);
}
else
{
console
.
info
(
'
SensorAmbientLightJSTest016 off success
'
);
expect
(
true
).
assertTrue
();
setTimeout
(()
=>
{
done
();
resolve
();
},
500
);
}
});
})
}
function
oncePromise
()
{
return
new
Promise
((
resolve
,
reject
)
=>
{
sensor
.
once
(
5
,
function
(
error
,
data
)
{
if
(
error
)
{
console
.
info
(
'
SensorAmbientLightJSTest016 once error
'
);
expect
(
false
).
assertTrue
();
setTimeout
((
err
)
=>
{
reject
(
err
);
},
500
);
}
else
{
console
.
info
(
'
SensorAmbientLightJSTest016 once success data:
'
+
data
.
intensity
);
expect
(
typeof
(
data
.
intensity
)).
assertEqual
(
"
number
"
);
setTimeout
(()
=>
{
resolve
();
},
500
);
}
});
})
}
let
onPromise1
=
new
Promise
((
resolve
,
reject
)
=>
{
sensor
.
on
(
5
,
function
(
error
,
data
)
{
if
(
error
)
{
console
.
info
(
'
SensorAmbientLightJSTest016 on1 error
'
);
expect
(
false
).
assertTrue
();
setTimeout
((
err
)
=>
{
reject
(
err
);
},
500
);
}
else
{
console
.
info
(
'
SensorAmbientLightJSTest016 on1 success data:
'
+
data
.
intensity
);
expect
(
typeof
(
data
.
intensity
)).
assertEqual
(
"
number
"
);
setTimeout
(()
=>
{
resolve
();
},
500
);
}
});
})
await
onPromise1
.
then
(()
=>
{
return
oncePromise
();
}).
then
(()
=>
{
return
offPromise
();
});
done
();
})
})
sensors/sensor_standard/src/main/js/default/test/SensorOnOffTest.test_Gyroscope.js
已删除
100755 → 0
浏览文件 @
7fda93b3
/*
* 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
sensor
from
'
@ohos.sensor
'
import
{
describe
,
beforeAll
,
beforeEach
,
afterEach
,
afterAll
,
it
,
expect
}
from
'
deccjsunit/index
'
describe
(
"
SensorJsTest
"
,
function
()
{
beforeAll
(
function
()
{
/*
* @tc.setup: setup invoked before all testcases
*/
console
.
info
(
'
beforeAll caled
'
)
})
afterAll
(
function
()
{
/*
* @tc.teardown: teardown invoked after all testcases
*/
console
.
info
(
'
afterAll caled
'
)
})
beforeEach
(
function
()
{
/*
* @tc.setup: setup invoked before each testcases
*/
console
.
info
(
'
beforeEach caled
'
)
})
afterEach
(
function
()
{
/*
* @tc.teardown: teardown invoked after each testcases
*/
console
.
info
(
'
afterEach caled
'
)
})
/*
* @tc.number: SUB_SensorsSystem_Gyroscope_JSTest_0010
* @tc.name: SensorGyroscopeJSTest001
* @tc.desc:verify app info is not null
*/
it
(
"
SUB_SensorsSystem_Gyroscope_JSTest_0010
"
,
0
,
async
function
(
done
)
{
console
.
info
(
'
----------------------SUB_SensorsSystem_Gyroscope_JSTest_0010---------------------------
'
);
function
offPromise
()
{
return
new
Promise
((
resolve
,
reject
)
=>
{
sensor
.
off
(
sensor
.
SensorType
.
SENSOR_TYPE_ID_GYROSCOPE
,
(
error
)
=>
{
if
(
error
)
{
console
.
info
(
'
SensorGyroscopeJSTest001 off error
'
);
expect
(
false
).
assertTrue
();
console
.
info
(
'
setTimeout ..start
'
)
setTimeout
((
err
)
=>
{
reject
(
err
);
},
500
);
}
else
{
console
.
info
(
'
SensorGyroscopeJSTest001 off success
'
);
expect
(
true
).
assertTrue
();
setTimeout
(()
=>
{
resolve
();
},
500
);
}
},
1000
)
})
}
let
promise
=
new
Promise
((
resolve
,
reject
)
=>
{
sensor
.
on
(
sensor
.
SensorType
.
SENSOR_TYPE_ID_GYROSCOPE
,
function
(
error
,
data
)
{
if
(
error
)
{
console
.
info
(
'
SensorGyroscopeJSTest001 on error
'
);
expect
(
false
).
assertTrue
();
setTimeout
((
err
)
=>
{
reject
(
err
);
},
500
);
}
else
{
console
.
info
(
'
SensorGyroscopeJSTest001 on success, x:
'
+
data
.
x
+
"
y:
"
+
data
.
y
+
"
z:
"
+
data
.
z
);
expect
(
typeof
(
data
.
x
)).
assertEqual
(
"
number
"
);
expect
(
typeof
(
data
.
y
)).
assertEqual
(
"
number
"
);
expect
(
typeof
(
data
.
z
)).
assertEqual
(
"
number
"
);
setTimeout
(()
=>
{
resolve
();
},
500
);
}
});
})
await
promise
.
then
(()
=>
{
return
offPromise
();
},
()
=>
{
console
.
info
(
"
SensorGyroscopeJSTest001 reject
"
);
})
done
();
})
/*
* @tc.number: SUB_SensorsSystem_Gyroscope_JSTest_0020
* @tc.name: SensorGyroscopeJSTest002
* @tc.desc:verify app info is not null
*/
it
(
"
SUB_SensorsSystem_Gyroscope_JSTest_0020
"
,
0
,
async
function
(
done
)
{
console
.
info
(
'
----------------------SUB_SensorsSystem_Gyroscope_JSTest_0020---------------------------
'
);
function
onSensorCallback
(
error
,
data
)
{
if
(
error
)
{
console
.
info
(
'
SensorGyroscopeJSTest002 on success
'
);
expect
(
true
).
assertTrue
();
}
else
{
console
.
info
(
'
SensorGyroscopeJSTest002 on error
'
);
expect
(
false
).
assertTrue
();
}
setTimeout
(()
=>
{
done
();
},
500
);
}
sensor
.
on
(
-
1
,
onSensorCallback
);
})
/*
* @tc.number: SUB_SensorsSystem_Gyroscope_JSTest_0030
* @tc.name: SensorGyroscopeJSTest003
* @tc.desc:verify app info is not null
*/
it
(
"
SUB_SensorsSystem_Gyroscope_JSTest_0030
"
,
0
,
async
function
(
done
)
{
console
.
info
(
'
----------------------SUB_SensorsSystem_Gyroscope_JSTest_0030---------------------------
'
);
function
offPromise
()
{
return
new
Promise
((
resolve
,
reject
)
=>
{
sensor
.
off
(
2
,
(
error
)
=>
{
if
(
error
)
{
console
.
info
(
'
SensorGyroscopeJSTest003 off error
'
);
expect
(
false
).
assertTrue
();
setTimeout
((
err
)
=>
{
done
();
reject
(
err
);
},
500
);
}
else
{
console
.
info
(
'
SensorGyroscopeJSTest003 off success
'
);
expect
(
true
).
assertTrue
();
setTimeout
(()
=>
{
done
();
resolve
();
},
500
);
}
},
1000
)
})
}
let
promise
=
new
Promise
((
resolve
,
reject
)
=>
{
sensor
.
on
(
2
,
function
(
error
,
data
)
{
if
(
error
)
{
console
.
info
(
'
SensorGyroscopeJSTest003 on error
'
);
expect
(
false
).
assertTrue
();
setTimeout
((
err
)
=>
{
reject
(
err
);
},
500
);
}
else
{
console
.
info
(
'
SensorGyroscopeJSTest003 on success x:
'
+
data
.
x
+
"
y:
"
+
data
.
y
+
"
z:
"
+
data
.
z
);
expect
(
typeof
(
data
.
x
)).
assertEqual
(
"
number
"
);
expect
(
typeof
(
data
.
y
)).
assertEqual
(
"
number
"
);
expect
(
typeof
(
data
.
z
)).
assertEqual
(
"
number
"
);
setTimeout
(()
=>
{
resolve
();
},
500
);
}
},
{
'
interval
'
:
200000000
});
})
await
promise
.
then
(()
=>
{
return
offPromise
();
},
()
=>
{
console
.
info
(
"
SensorGyroscopeJSTest003 reject
"
);
})
done
();
})
/*
* @tc.number: SUB_SensorsSystem_Gyroscope_JSTest_0040
* @tc.name: SensorGyroscopeJSTest004
* @tc.desc:verify app info is not null
*/
it
(
"
SUB_SensorsSystem_Gyroscope_JSTest_0040
"
,
0
,
function
()
{
console
.
info
(
'
----------------------SensorGyroscopeJSTest004---------------------------
'
);
sensor
.
on
(
2
,
function
()
{
},
{
'
interval
'
:
100000000
},
5
);
expect
(
true
).
assertTrue
();
console
.
info
(
'
----------------------SensorGyroscopeJSTest004--------------------------- end
'
);
})
/*
* @tc.number: SUB_SensorsSystem_Gyroscope_JSTest_0050
* @tc.name: SensorGyroscopeJSTest005
* @tc.desc:verify app info is not null
*/
it
(
"
SUB_SensorsSystem_Gyroscope_JSTest_0050
"
,
0
,
async
function
(
done
)
{
function
onceSensorCallback
(
error
,
data
)
{
if
(
error
)
{
console
.
info
(
'
SensorGyroscopeJSTest005 once error
'
);
expect
(
false
).
assertTrue
();
}
else
{
console
.
info
(
'
SensorGyroscopeJSTest005 once success x:
'
+
data
.
x
+
"
y:
"
+
data
.
y
+
"
z:
"
+
data
.
z
);
expect
(
typeof
(
data
.
x
)).
assertEqual
(
"
number
"
);
expect
(
typeof
(
data
.
y
)).
assertEqual
(
"
number
"
);
expect
(
typeof
(
data
.
z
)).
assertEqual
(
"
number
"
);
}
setTimeout
(()
=>
{
done
();
},
500
);
}
sensor
.
once
(
sensor
.
SensorType
.
SENSOR_TYPE_ID_GYROSCOPE
,
onceSensorCallback
);
})
/*
* @tc.number: SUB_SensorsSystem_Gyroscope_JSTest_0060
* @tc.name: SensorGyroscopeJSTest006
* @tc.desc:verify app info is not null
*/
it
(
"
SUB_SensorsSystem_Gyroscope_JSTest_0060
"
,
0
,
async
function
(
done
)
{
function
onceSensorCallback
(
error
,
data
)
{
if
(
error
)
{
console
.
info
(
'
SensorGyroscopeJSTest006 on success
'
);
expect
(
true
).
assertTrue
();
}
else
{
console
.
info
(
'
SensorGyroscopeJSTest006 on error
'
);
expect
(
false
).
assertTrue
();
}
setTimeout
(()
=>
{
done
();
},
500
);
}
sensor
.
once
(
-
1
,
onceSensorCallback
);
})
/*
* @tc.number: SUB_SensorsSystem_Gyroscope_JSTest_0070
* @tc.name: SensorGyroscopeJSTest007
* @tc.desc:verify app info is not null
*/
it
(
"
SUB_SensorsSystem_Gyroscope_JSTest_0070
"
,
0
,
function
()
{
sensor
.
once
(
2
,
function
()
{
},
5
);
expect
(
true
).
assertTrue
();
})
/*
* @tc.number: SUB_SensorsSystem_Gyroscope_JSTest_0080
* @tc.name: SensorGyroscopeJSTest008
* @tc.desc:verify app info is not null
*/
it
(
"
SUB_SensorsSystem_Gyroscope_JSTest_0080
"
,
0
,
async
function
(
done
)
{
function
offCallback
(
error
)
{
if
(
error
)
{
console
.
info
(
'
SensorGyroscopeJSTest008 off success
'
);
expect
(
true
).
assertTrue
();
}
else
{
console
.
info
(
'
SensorGyroscopeJSTest008 off error
'
);
expect
(
false
).
assertTrue
();
}
setTimeout
(()
=>
{
done
();
},
500
);
}
sensor
.
off
(
-
1
,
offCallback
);
})
/*
* @tc.number: SUB_SensorsSystem_Gyroscope_JSTest_0090
* @tc.name: SensorGyroscopeJSTest009
* @tc.desc:verify app info is not null
*/
it
(
"
SUB_SensorsSystem_Gyroscope_JSTest_0090
"
,
0
,
async
function
(
done
)
{
function
offCallback
(
error
)
{
if
(
error
)
{
console
.
info
(
'
SensorGyroscopeJSTest009 off success
'
);
expect
(
true
).
assertTrue
();
}
else
{
console
.
info
(
'
SensorGyroscopeJSTest009 off error
'
);
expect
(
false
).
assertTrue
();
}
setTimeout
(()
=>
{
done
();
},
500
);
}
sensor
.
off
(
2
,
offCallback
);
})
/*
* @tc.number: SUB_SensorsSystem_Gyroscope_JSTest_0100
* @tc.name: SensorGyroscopeJSTest010
* @tc.desc:verify app info is not null
*/
it
(
"
SUB_SensorsSystem_Gyroscope_JSTest_0100
"
,
0
,
async
function
(
done
)
{
function
offCallback
(
error
)
{
if
(
error
)
{
console
.
info
(
'
SensorGyroscopeJSTest010 off success
'
);
expect
(
true
).
assertTrue
();
}
else
{
console
.
info
(
'
SensorGyroscopeJSTest010 off error
'
);
expect
(
false
).
assertTrue
();
}
setTimeout
(()
=>
{
done
();
},
500
);
}
sensor
.
off
(
1000000
,
offCallback
);
})
/*
* @tc.number: SUB_SensorsSystem_Gyroscope_JSTest_0110
* @tc.name: SensorGyroscopeJSTest011
* @tc.desc:verify app info is not null
*/
it
(
"
SUB_SensorsSystem_Gyroscope_JSTest_0110
"
,
0
,
async
function
(
done
)
{
function
onceSensorCallback
(
error
,
data
)
{
if
(
error
)
{
console
.
info
(
'
SensorGyroscopeJSTest011 once success
'
);
expect
(
true
).
assertTrue
();
}
else
{
console
.
info
(
'
SensorGyroscopeJSTest011 once error
'
);
expect
(
false
).
assertTrue
();
}
setTimeout
(()
=>
{
done
();
},
500
);
}
sensor
.
once
(
1000000
,
onceSensorCallback
);
})
/*
* @tc.number: SUB_SensorsSystem_Gyroscope_JSTest_0120
* @tc.name: SensorGyroscopeJSTest012
* @tc.desc:verify app info is not null
*/
it
(
"
SUB_SensorsSystem_Gyroscope_JSTest_0120
"
,
0
,
async
function
(
done
)
{
function
onCallback
(
error
)
{
if
(
error
)
{
console
.
info
(
'
SensorGyroscopeJSTest012 on success
'
);
expect
(
true
).
assertTrue
();
}
else
{
console
.
info
(
'
SensorGyroscopeJSTest012 on error
'
);
expect
(
false
).
assertTrue
();
}
setTimeout
(()
=>
{
done
();
},
500
);
}
sensor
.
on
(
1000000
,
onCallback
);
})
/*
* @tc.number: SUB_SensorsSystem_Gyroscope_JSTest_0130
* @tc.name: SensorGyroscopeJSTest013
* @tc.desc:verify app info is not null
*/
it
(
"
SUB_SensorsSystem_Gyroscope_JSTest_0130
"
,
0
,
function
()
{
sensor
.
off
(
2
,
5
);
expect
(
true
).
assertTrue
();
})
/*
* @tc.number: SUB_SensorsSystem_Gyroscope_JSTest_0140
* @tc.name: SensorGyroscopeJSTest014
* @tc.desc:verify app info is not null
*/
it
(
"
SUB_SensorsSystem_Gyroscope_JSTest_0140
"
,
0
,
async
function
(
done
)
{
console
.
info
(
'
----------------------SUB_SensorsSystem_Gyroscope_JSTest_0140---------------------------
'
);
function
offPromise2
()
{
return
new
Promise
((
resolve
,
reject
)
=>
{
sensor
.
off
(
2
,
(
error
)
=>
{
if
(
error
)
{
console
.
info
(
'
SensorGyroscopeJSTest014 off2 success
'
);
expect
(
true
).
assertTrue
();
setTimeout
((
err
)
=>
{
done
();
reject
(
err
)
},
500
);
}
else
{
console
.
info
(
'
SensorGyroscopeJSTest014 off2 error
'
);
expect
(
false
).
assertTrue
();
setTimeout
(()
=>
{
done
();
resolve
()
},
500
);
}
});
})
}
function
offPromise1
()
{
return
new
Promise
((
resolve
,
reject
)
=>
{
sensor
.
off
(
2
,
(
error
)
=>
{
if
(
error
)
{
console
.
info
(
'
SensorGyroscopeJSTest014 off1 error
'
);
expect
(
false
).
assertTrue
();
setTimeout
((
err
)
=>
{
reject
(
err
);
},
500
);
}
else
{
console
.
info
(
'
SensorGyroscopeJSTest014 off1 success
'
);
expect
(
true
).
assertTrue
();
setTimeout
(()
=>
{
resolve
();
},
500
);
}
});
})
}
let
promise
=
new
Promise
((
resolve
,
reject
)
=>
{
sensor
.
on
(
2
,
function
(
error
,
data
)
{
if
(
error
)
{
console
.
info
(
'
SensorGyroscopeJSTest014 on error
'
);
expect
(
false
).
assertTrue
();
setTimeout
((
err
)
=>
{
reject
(
err
);
},
500
);
}
else
{
console
.
info
(
'
SensorGyroscopeJSTest014 on success x:
'
+
data
.
x
+
"
y:
"
+
data
.
y
+
"
z:
"
+
data
.
z
);
expect
(
typeof
(
data
.
x
)).
assertEqual
(
"
number
"
);
expect
(
typeof
(
data
.
y
)).
assertEqual
(
"
number
"
);
expect
(
typeof
(
data
.
z
)).
assertEqual
(
"
number
"
);
setTimeout
(()
=>
{
resolve
();
},
500
);
}
});
})
await
promise
.
then
(()
=>
{
return
offPromise1
();
}).
then
(()
=>
{
return
offPromise2
();
});
done
();
})
/*
* @tc.number: SUB_SensorsSystem_Gyroscope_JSTest_0150
* @tc.name: SensorGyroscopeJSTest015
* @tc.desc:verify app info is not null
*/
it
(
"
SUB_SensorsSystem_Gyroscope_JSTest_0150
"
,
0
,
async
function
(
done
)
{
console
.
info
(
'
----------------------SUB_SensorsSystem_Gyroscope_JSTest_0150---------------------------
'
);
function
offPromise
()
{
return
new
Promise
((
resolve
,
reject
)
=>
{
sensor
.
off
(
2
,
(
error
)
=>
{
if
(
error
)
{
console
.
info
(
'
SensorGyroscopeJSTest015 off error
'
);
expect
(
false
).
assertTrue
();
setTimeout
((
err
)
=>
{
done
();
reject
(
err
);
},
500
);
}
else
{
console
.
info
(
'
SensorGyroscopeJSTest015 off success
'
);
expect
(
true
).
assertTrue
();
setTimeout
(()
=>
{
done
();
resolve
();
},
500
);
}
});
})
}
function
onPromise2
()
{
return
new
Promise
((
resolve
,
reject
)
=>
{
sensor
.
on
(
2
,
function
(
error
,
data
)
{
if
(
error
)
{
console
.
info
(
'
SensorGyroscopeJSTest015 on2 error
'
);
expect
(
false
).
assertTrue
();
setTimeout
((
err
)
=>
{
reject
(
err
);
},
500
);
}
else
{
console
.
info
(
'
SensorGyroscopeJSTest015 on2 success x:
'
+
data
.
x
+
"
y:
"
+
data
.
y
+
"
z:
"
+
data
.
z
);
expect
(
typeof
(
data
.
x
)).
assertEqual
(
"
number
"
);
expect
(
typeof
(
data
.
y
)).
assertEqual
(
"
number
"
);
expect
(
typeof
(
data
.
z
)).
assertEqual
(
"
number
"
);
setTimeout
(()
=>
{
resolve
();
},
500
);
}
});
})
}
let
onPromise1
=
new
Promise
((
resolve
,
reject
)
=>
{
sensor
.
on
(
2
,
function
(
error
,
data
)
{
if
(
error
)
{
console
.
info
(
'
SensorGyroscopeJSTest015 on1 error
'
);
expect
(
false
).
assertTrue
();
setTimeout
((
err
)
=>
{
reject
(
err
);
},
500
);
}
else
{
console
.
info
(
'
SensorGyroscopeJSTest015 on1 success x:
'
+
data
.
x
+
"
y:
"
+
data
.
y
+
"
z:
"
+
data
.
z
);
expect
(
typeof
(
data
.
x
)).
assertEqual
(
"
number
"
);
expect
(
typeof
(
data
.
y
)).
assertEqual
(
"
number
"
);
expect
(
typeof
(
data
.
z
)).
assertEqual
(
"
number
"
);
setTimeout
(()
=>
{
resolve
();
},
500
);
}
});
})
await
onPromise1
.
then
(()
=>
{
return
onPromise2
();
}).
then
(()
=>
{
return
offPromise
();
});
done
();
})
/*
* @tc.number: SUB_SensorsSystem_Gyroscope_JSTest_0160
* @tc.name: SensorGyroscopeJSTest016
* @tc.desc:verify app info is not null
*/
it
(
"
SUB_SensorsSystem_Gyroscope_JSTest_0160
"
,
0
,
async
function
(
done
)
{
console
.
info
(
'
----------------------SUB_SensorsSystem_Gyroscope_JSTest_0160---------------------------
'
);
function
offPromise
()
{
return
new
Promise
((
resolve
,
reject
)
=>
{
sensor
.
off
(
2
,
(
error
)
=>
{
if
(
error
)
{
console
.
info
(
'
SensorGyroscopeJSTest016 off error
'
);
expect
(
false
).
assertTrue
();
setTimeout
((
err
)
=>
{
done
();
reject
(
err
);
},
500
);
}
else
{
console
.
info
(
'
SensorGyroscopeJSTest016 off success
'
);
expect
(
true
).
assertTrue
();
setTimeout
(()
=>
{
done
();
resolve
();
},
500
);
}
});
})
}
function
oncePromise
()
{
return
new
Promise
((
resolve
,
reject
)
=>
{
sensor
.
once
(
2
,
function
(
error
,
data
)
{
if
(
error
)
{
console
.
info
(
'
SensorGyroscopeJSTest016 once error
'
);
expect
(
false
).
assertTrue
();
setTimeout
((
err
)
=>
{
reject
(
err
);
},
500
);
}
else
{
console
.
info
(
'
SensorGyroscopeJSTest016 once success x:
'
+
data
.
x
+
"
y:
"
+
data
.
y
+
"
z:
"
+
data
.
z
);
expect
(
typeof
(
data
.
x
)).
assertEqual
(
"
number
"
);
expect
(
typeof
(
data
.
y
)).
assertEqual
(
"
number
"
);
expect
(
typeof
(
data
.
z
)).
assertEqual
(
"
number
"
);
setTimeout
(()
=>
{
resolve
();
},
500
);
}
});
})
}
let
onPromise1
=
new
Promise
((
resolve
,
reject
)
=>
{
sensor
.
on
(
2
,
function
(
error
,
data
)
{
if
(
error
)
{
console
.
info
(
'
SensorGyroscopeJSTest016 on1 error
'
);
expect
(
false
).
assertTrue
();
setTimeout
((
err
)
=>
{
reject
(
err
);
},
500
);
}
else
{
console
.
info
(
'
SensorGyroscopeJSTest016 on1 success x:
'
+
data
.
x
+
"
y:
"
+
data
.
y
+
"
z:
"
+
data
.
z
);
expect
(
typeof
(
data
.
x
)).
assertEqual
(
"
number
"
);
expect
(
typeof
(
data
.
y
)).
assertEqual
(
"
number
"
);
expect
(
typeof
(
data
.
z
)).
assertEqual
(
"
number
"
);
setTimeout
(()
=>
{
resolve
();
},
500
);
}
});
})
await
onPromise1
.
then
(()
=>
{
return
oncePromise
();
}).
then
(()
=>
{
return
offPromise
();
});
done
();
})
})
sensors/sensor_standard/src/main/js/default/test/SensorOnOffTest.test_Hall.js
已删除
100755 → 0
浏览文件 @
7fda93b3
/*
* 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
sensor
from
'
@ohos.sensor
'
import
{
describe
,
beforeAll
,
beforeEach
,
afterEach
,
afterAll
,
it
,
expect
}
from
'
deccjsunit/index
'
describe
(
"
SensorJsTest
"
,
function
()
{
beforeAll
(
function
()
{
/*
* @tc.setup: setup invoked before all testcases
*/
console
.
info
(
'
beforeAll caled
'
)
})
afterAll
(
function
()
{
/*
* @tc.teardown: teardown invoked after all testcases
*/
console
.
info
(
'
afterAll caled
'
)
})
beforeEach
(
function
()
{
/*
* @tc.setup: setup invoked before each testcases
*/
console
.
info
(
'
beforeEach caled
'
)
})
afterEach
(
function
()
{
/*
* @tc.teardown: teardown invoked after each testcases
*/
console
.
info
(
'
afterEach caled
'
)
})
/*
* @tc.number: SUB_SensorsSystem_Hall_JSTest_0010
* @tc.name: SensorHallJSTest001
* @tc.desc:verify app info is not null
*/
it
(
"
SUB_SensorsSystem_Hall_JSTest_0010
"
,
0
,
async
function
(
done
)
{
console
.
info
(
'
----------------------SUB_SensorsSystem_Hall_JSTest_0010---------------------------
'
);
function
offPromise
()
{
return
new
Promise
((
resolve
,
reject
)
=>
{
sensor
.
off
(
sensor
.
SensorType
.
SENSOR_TYPE_ID_HALL
,
(
error
)
=>
{
if
(
error
)
{
console
.
info
(
'
SensorHallJSTest001 off error
'
);
expect
(
false
).
assertTrue
();
console
.
info
(
'
setTimeout ..start
'
)
setTimeout
((
err
)
=>
{
reject
(
err
);
},
500
);
}
else
{
console
.
info
(
'
SensorHallJSTest001 off success
'
);
expect
(
true
).
assertTrue
();
setTimeout
(()
=>
{
resolve
();
},
500
);
}
},
1000
)
})
}
let
promise
=
new
Promise
((
resolve
,
reject
)
=>
{
sensor
.
on
(
sensor
.
SensorType
.
SENSOR_TYPE_ID_HALL
,
function
(
error
,
data
)
{
if
(
error
)
{
console
.
info
(
'
SensorHallJSTest001 on error
'
);
expect
(
false
).
assertTrue
();
setTimeout
((
err
)
=>
{
reject
(
err
);
},
500
);
}
else
{
console
.
info
(
'
SensorHallJSTest001 on success status:
'
+
data
.
status
);
expect
(
typeof
(
data
.
status
)).
assertEqual
(
"
number
"
);
setTimeout
(()
=>
{
resolve
();
},
500
);
}
});
})
await
promise
.
then
(()
=>
{
return
offPromise
();
},
()
=>
{
console
.
info
(
"
SensorHallJSTest001 reject
"
);
})
done
();
})
/*
* @tc.number: SUB_SensorsSystem_Hall_JSTest_0050
* @tc.name: SensorHallJSTest005
* @tc.desc:verify app info is not null
*/
it
(
"
SUB_SensorsSystem_Hall_JSTest_0050
"
,
0
,
async
function
(
done
)
{
function
onceSensorCallback
(
error
,
data
)
{
if
(
error
)
{
console
.
info
(
'
SensorHallJSTest005 once error
'
);
expect
(
false
).
assertTrue
();
}
else
{
console
.
info
(
'
SensorHallJSTest005 once success status:
'
+
data
.
status
);
expect
(
typeof
(
data
.
status
)).
assertEqual
(
"
number
"
);
}
setTimeout
(()
=>
{
done
();
},
500
);
}
sensor
.
once
(
sensor
.
SensorType
.
SENSOR_TYPE_ID_HALL
,
onceSensorCallback
);
})
})
sensors/sensor_standard/src/main/js/default/test/Accelerometer.js
→
sensors/sensor_standard/src/main/js/default/test/
SensorOnOffTest_
Accelerometer.js
浏览文件 @
1c688540
...
@@ -64,6 +64,7 @@ describe("SensorJsTest", function () {
...
@@ -64,6 +64,7 @@ describe("SensorJsTest", function () {
let
errMessages
=
[
'
The number of parameters is not valid
'
,
'
Should subscribe first
'
,
let
errMessages
=
[
'
The number of parameters is not valid
'
,
'
Should subscribe first
'
,
'
string is not defined
'
];
'
string is not defined
'
];
let
errMessage
;
let
errMessage
;
/*
/*
...
@@ -106,13 +107,11 @@ describe("SensorJsTest", function () {
...
@@ -106,13 +107,11 @@ describe("SensorJsTest", function () {
*/
*/
it
(
"
Accelerometer_SensorJsTest003
"
,
0
,
async
function
(
done
)
{
it
(
"
Accelerometer_SensorJsTest003
"
,
0
,
async
function
(
done
)
{
console
.
info
(
'
----------------------Accelerometer_SensorJsTest003---------------------------
'
);
console
.
info
(
'
----------------------Accelerometer_SensorJsTest003---------------------------
'
);
function
onSensorCallback
(
data
)
{
function
onSensorCallback
(
data
)
{
console
.
info
(
'
Accelerometer_SensorJsTest003 on error
'
);
console
.
info
(
'
Accelerometer_SensorJsTest003 on error
'
);
expect
(
false
).
assertTrue
();
expect
(
false
).
assertTrue
();
done
();
done
();
}
}
try
{
try
{
sensor
.
on
(
sensor
.
SensorType
.
SENSOR_TYPE_ID_ACCELEROMETER
,
onSensorCallback
,
{
'
interval
'
:
100000000
},
5
);
sensor
.
on
(
sensor
.
SensorType
.
SENSOR_TYPE_ID_ACCELEROMETER
,
onSensorCallback
,
{
'
interval
'
:
100000000
},
5
);
}
catch
(
error
)
{
}
catch
(
error
)
{
...
@@ -146,13 +145,11 @@ describe("SensorJsTest", function () {
...
@@ -146,13 +145,11 @@ describe("SensorJsTest", function () {
*/
*/
it
(
"
Accelerometer_SensorJsTest005
"
,
0
,
async
function
(
done
)
{
it
(
"
Accelerometer_SensorJsTest005
"
,
0
,
async
function
(
done
)
{
console
.
info
(
'
----------------------Accelerometer_SensorJsTest005---------------------------
'
);
console
.
info
(
'
----------------------Accelerometer_SensorJsTest005---------------------------
'
);
function
onceSensorCallback
(
data
)
{
function
onceSensorCallback
(
data
)
{
console
.
info
(
'
Accelerometer_SensorJsTest005 on error
'
);
console
.
info
(
'
Accelerometer_SensorJsTest005 on error
'
);
expect
(
false
).
assertTrue
();
expect
(
false
).
assertTrue
();
done
();
done
();
}
}
try
{
try
{
sensor
.
once
(
sensor
.
SensorType
.
SENSOR_TYPE_ID_ACCELEROMETER
,
onceSensorCallback
,
5
);
sensor
.
once
(
sensor
.
SensorType
.
SENSOR_TYPE_ID_ACCELEROMETER
,
onceSensorCallback
,
5
);
}
catch
(
error
)
{
}
catch
(
error
)
{
...
@@ -189,13 +186,11 @@ describe("SensorJsTest", function () {
...
@@ -189,13 +186,11 @@ describe("SensorJsTest", function () {
*/
*/
it
(
"
Accelerometer_SensorJsTest007
"
,
0
,
async
function
(
done
)
{
it
(
"
Accelerometer_SensorJsTest007
"
,
0
,
async
function
(
done
)
{
console
.
info
(
'
----------------------Accelerometer_SensorJsTest007---------------------------
'
);
console
.
info
(
'
----------------------Accelerometer_SensorJsTest007---------------------------
'
);
function
onSensorCallback
(
data
)
{
function
onSensorCallback
(
data
)
{
console
.
info
(
'
Accelerometer_SensorJsTest007 on error
'
);
console
.
info
(
'
Accelerometer_SensorJsTest007 on error
'
);
expect
(
false
).
assertTrue
();
expect
(
false
).
assertTrue
();
done
();
done
();
}
}
sensor
.
on
(
sensor
.
SensorType
.
SENSOR_TYPE_ID_ACCELEROMETER
,
onSensorCallback
);
sensor
.
on
(
sensor
.
SensorType
.
SENSOR_TYPE_ID_ACCELEROMETER
,
onSensorCallback
);
sensor
.
off
(
sensor
.
SensorType
.
SENSOR_TYPE_ID_ACCELEROMETER
,
onSensorCallback
);
sensor
.
off
(
sensor
.
SensorType
.
SENSOR_TYPE_ID_ACCELEROMETER
,
onSensorCallback
);
setTimeout
(()
=>
{
setTimeout
(()
=>
{
...
@@ -212,13 +207,11 @@ describe("SensorJsTest", function () {
...
@@ -212,13 +207,11 @@ describe("SensorJsTest", function () {
*/
*/
it
(
"
Accelerometer_SensorJsTest008
"
,
0
,
async
function
(
done
)
{
it
(
"
Accelerometer_SensorJsTest008
"
,
0
,
async
function
(
done
)
{
console
.
info
(
'
----------------------Accelerometer_SensorJsTest008---------------------------
'
);
console
.
info
(
'
----------------------Accelerometer_SensorJsTest008---------------------------
'
);
function
onSensorCallback
(
data
)
{
function
onSensorCallback
(
data
)
{
console
.
info
(
'
Accelerometer_SensorJsTest008 on error
'
);
console
.
info
(
'
Accelerometer_SensorJsTest008 on error
'
);
expect
(
false
).
assertTrue
();
expect
(
false
).
assertTrue
();
done
();
done
();
}
}
try
{
try
{
sensor
.
off
(
1000000
,
onSensorCallback
);
sensor
.
off
(
1000000
,
onSensorCallback
);
}
catch
(
error
)
{
}
catch
(
error
)
{
...
...
sensors/sensor_standard/src/main/js/default/test/SensorOnOffTest_Ambient_light.js
0 → 100644
浏览文件 @
1c688540
/*
* 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
sensor
from
'
@ohos.sensor
'
import
{
describe
,
beforeAll
,
beforeEach
,
afterEach
,
afterAll
,
it
,
expect
}
from
'
deccjsunit/index
'
describe
(
"
SensorJsTest
"
,
function
()
{
function
callback
(
data
)
{
console
.
info
(
"
callback
"
+
JSON
.
stringify
(
data
));
expect
(
typeof
(
data
.
intensity
)).
assertEqual
(
"
number
"
);
}
function
callback2
(
data
)
{
console
.
info
(
"
callback2
"
+
JSON
.
stringify
(
data
));
expect
(
typeof
(
data
.
intensity
)).
assertEqual
(
"
number
"
);
}
beforeAll
(
function
()
{
/*
* @tc.setup: setup invoked before all testcases
*/
console
.
info
(
'
beforeAll caled
'
)
})
afterAll
(
function
()
{
/*
* @tc.teardown: teardown invoked after all testcases
*/
console
.
info
(
'
afterAll caled
'
)
})
beforeEach
(
function
()
{
/*
* @tc.setup: setup invoked before each testcases
*/
console
.
info
(
'
beforeEach caled
'
)
})
afterEach
(
function
()
{
/*
* @tc.teardown: teardown invoked after each testcases
*/
console
.
info
(
'
afterEach caled
'
)
})
let
errMessages
=
[
'
The number of parameters is not valid
'
,
'
Should subscribe first
'
,
'
string is not defined
'
];
let
errMessage
;
/*
* @tc.name:Ambient_Light_SensorJsTest001
* @tc.desc:verify app info is not null
* @tc.type: FUNC
* @tc.require: Issue Number
*/
it
(
"
Ambient_Light_SensorJsTest001
"
,
0
,
async
function
(
done
)
{
console
.
info
(
'
----------------------Ambient_Light_SensorJsTest001---------------------------
'
);
sensor
.
on
(
sensor
.
SensorType
.
SENSOR_TYPE_ID_AMBIENT_LIGHT
,
callback
);
setTimeout
(()
=>
{
sensor
.
off
(
sensor
.
SensorType
.
SENSOR_TYPE_ID_AMBIENT_LIGHT
);
done
();
},
1500
);
})
/*
* @tc.name:Ambient_Light_SensorJsTest002
* @tc.desc:verify app info is not null
* @tc.type: FUNC
* @tc.require: Issue Number
*/
it
(
"
Ambient_Light_SensorJsTest002
"
,
0
,
async
function
(
done
)
{
console
.
info
(
'
----------------------Ambient_Light_SensorJsTest002---------------------------
'
);
sensor
.
on
(
sensor
.
SensorType
.
SENSOR_TYPE_ID_AMBIENT_LIGHT
,
callback
,
{
'
interval
'
:
100000000
});
setTimeout
(()
=>
{
console
.
info
(
'
----------------------Ambient_Light_SensorJsTest002 off in---------------------------
'
);
sensor
.
off
(
sensor
.
SensorType
.
SENSOR_TYPE_ID_AMBIENT_LIGHT
);
console
.
info
(
'
----------------------Ambient_Light_SensorJsTest002 off end---------------------------
'
);
done
();
},
1500
);
})
/*
* @tc.name:Ambient_Light_SensorJsTest003
* @tc.desc:verify app info is not null
* @tc.type: FUNC
* @tc.require: Issue Number
*/
it
(
"
Ambient_Light_SensorJsTest003
"
,
0
,
async
function
(
done
)
{
console
.
info
(
'
----------------------Ambient_Light_SensorJsTest003---------------------------
'
);
function
onSensorCallback
(
data
)
{
console
.
info
(
'
Ambient_Light_SensorJsTest003 on error
'
);
expect
(
false
).
assertTrue
();
done
();
}
try
{
sensor
.
on
(
sensor
.
SensorType
.
SENSOR_TYPE_ID_AMBIENT_LIGHT
,
onSensorCallback
,
{
'
interval
'
:
100000000
},
5
);
}
catch
(
error
)
{
console
.
info
(
"
Ambient_Light_SensorJsTest003 error:
"
+
error
);
errMessage
=
error
.
toString
().
slice
(
12
,
49
);
console
.
info
(
'
Ambient_Light_SensorJsTest003 errMessage:
'
+
errMessage
);
expect
(
errMessage
).
assertEqual
(
errMessages
[
0
]);
done
();
}
})
/*
* @tc.name:Ambient_Light_SensorJsTest004
* @tc.desc:verify app info is not null
* @tc.type: FUNC
* @tc.require: Issue Number
*/
it
(
"
Ambient_Light_SensorJsTest004
"
,
0
,
async
function
(
done
)
{
console
.
info
(
'
----------------------Ambient_Light_SensorJsTest004---------------------------
'
);
sensor
.
once
(
sensor
.
SensorType
.
SENSOR_TYPE_ID_AMBIENT_LIGHT
,
callback
);
setTimeout
(()
=>
{
expect
(
true
).
assertTrue
();
done
();
},
500
);
})
/*
* @tc.name:Ambient_Light_SensorJsTest005
* @tc.desc:verify app info is not null
* @tc.type: FUNC
* @tc.require: Issue Number
*/
it
(
"
Ambient_Light_SensorJsTest005
"
,
0
,
async
function
(
done
)
{
console
.
info
(
'
----------------------Ambient_Light_SensorJsTest005---------------------------
'
);
function
onceSensorCallback
(
data
)
{
console
.
info
(
'
Ambient_Light_SensorJsTest005 on error
'
);
expect
(
false
).
assertTrue
();
done
();
}
try
{
sensor
.
once
(
sensor
.
SensorType
.
SENSOR_TYPE_ID_AMBIENT_LIGHT
,
onceSensorCallback
,
5
);
}
catch
(
error
)
{
console
.
info
(
"
Ambient_Light_SensorJsTest005 error:
"
+
error
);
errMessage
=
error
.
toString
().
slice
(
14
,
51
);
console
.
info
(
'
Ambient_Light_SensorJsTest005 errMessage:
'
+
errMessage
);
expect
(
errMessage
).
assertEqual
(
errMessages
[
0
]);
done
();
}
})
/*
* @tc.name:Ambient_Light_SensorJsTest006
* @tc.desc:verify app info is not null
* @tc.type: FUNC
* @tc.require: Issue Number
*/
it
(
"
Ambient_Light_SensorJsTest006
"
,
0
,
async
function
(
done
)
{
console
.
info
(
'
----------------------Ambient_Light_SensorJsTest006---------------------------
'
);
try
{
sensor
.
off
(
string
,
""
);
}
catch
(
error
)
{
console
.
info
(
"
Ambient_Light_SensorJsTest006 error:
"
+
error
);
errMessage
=
error
.
toString
().
slice
(
16
,
40
);
console
.
info
(
'
Ambient_Light_SensorJsTest006 errMessage:
'
+
errMessage
);
expect
(
errMessage
).
assertEqual
(
errMessages
[
2
]);
done
();
}
})
/*
* @tc.name:Ambient_Light_SensorJsTest007
* @tc.desc:verify app info is not null
* @tc.type: FUNC
* @tc.require: Issue Number
*/
it
(
"
Ambient_Light_SensorJsTest007
"
,
0
,
async
function
(
done
)
{
console
.
info
(
'
----------------------Ambient_Light_SensorJsTest007---------------------------
'
);
function
onSensorCallback
(
data
)
{
console
.
info
(
'
Ambient_Light_SensorJsTest007 on error
'
);
expect
(
false
).
assertTrue
();
done
();
}
sensor
.
on
(
sensor
.
SensorType
.
SENSOR_TYPE_ID_AMBIENT_LIGHT
,
onSensorCallback
);
sensor
.
off
(
sensor
.
SensorType
.
SENSOR_TYPE_ID_AMBIENT_LIGHT
,
onSensorCallback
);
setTimeout
(()
=>
{
expect
(
true
).
assertTrue
();
done
();
},
500
);
})
/*
* @tc.name:Ambient_Light_SensorJsTest008
* @tc.desc:verify app info is not null
* @tc.type: FUNC
* @tc.require: Issue Number
*/
it
(
"
Ambient_Light_SensorJsTest008
"
,
0
,
async
function
(
done
)
{
console
.
info
(
'
----------------------Ambient_Light_SensorJsTest008---------------------------
'
);
function
onSensorCallback
(
data
)
{
console
.
info
(
'
Ambient_Light_SensorJsTest008 on error
'
);
expect
(
false
).
assertTrue
();
done
();
}
try
{
sensor
.
off
(
1000000
,
onSensorCallback
);
}
catch
(
error
)
{
console
.
info
(
"
Ambient_Light_SensorJsTest008 error:
"
+
error
);
errMessage
=
error
.
toString
().
slice
(
13
,
35
);
console
.
info
(
'
Ambient_Light_SensorJsTest008 errMessage:
'
+
errMessage
);
expect
(
errMessage
).
assertEqual
(
errMessages
[
1
]);
done
();
}
})
/*
* @tc.name:Ambient_Light_SensorJsTest009
* @tc.desc:verify app info is not null
* @tc.type: FUNC
* @tc.require: Issue Number
*/
it
(
"
Ambient_Light_SensorJsTest009
"
,
0
,
async
function
(
done
)
{
console
.
info
(
'
----------------------Ambient_Light_SensorJsTest009---------------------------
'
);
sensor
.
on
(
sensor
.
SensorType
.
SENSOR_TYPE_ID_AMBIENT_LIGHT
,
callback
);
sensor
.
on
(
sensor
.
SensorType
.
SENSOR_TYPE_ID_AMBIENT_LIGHT
,
callback2
);
setTimeout
(()
=>
{
console
.
info
(
'
----------------------Ambient_Light_SensorJsTest009 off in---------------------------
'
);
sensor
.
off
(
sensor
.
SensorType
.
SENSOR_TYPE_ID_AMBIENT_LIGHT
);
console
.
info
(
'
----------------------Ambient_Light_SensorJsTest009 off end---------------------------
'
);
done
();
},
2000
);
})
/*
* @tc.name:Ambient_Light_SensorJsTest010
* @tc.desc:verify app info is not null
* @tc.type: FUNC
* @tc.require: Issue Number
*/
it
(
"
Ambient_Light_SensorJsTest010
"
,
0
,
async
function
(
done
)
{
console
.
info
(
'
----------------------Ambient_Light_SensorJsTest010---------------------------
'
);
sensor
.
on
(
sensor
.
SensorType
.
SENSOR_TYPE_ID_AMBIENT_LIGHT
,
callback
);
sensor
.
on
(
sensor
.
SensorType
.
SENSOR_TYPE_ID_AMBIENT_LIGHT
,
callback2
);
setTimeout
(()
=>
{
console
.
info
(
'
----------------------Ambient_Light_SensorJsTest010 off in---------------------------
'
);
sensor
.
off
(
sensor
.
SensorType
.
SENSOR_TYPE_ID_AMBIENT_LIGHT
,
callback
);
console
.
info
(
'
----------------------Ambient_Light_SensorJsTest010 off end---------------------------
'
);
},
1000
);
setTimeout
(()
=>
{
console
.
info
(
'
----------------------Ambient_Light_SensorJsTest010 off in---------------------------
'
);
sensor
.
off
(
sensor
.
SensorType
.
SENSOR_TYPE_ID_AMBIENT_LIGHT
,
callback2
);
console
.
info
(
'
----------------------Ambient_Light_SensorJsTest010 off end---------------------------
'
);
done
();
},
2000
);
})
/*
* @tc.name:Ambient_Light_SensorJsTest011
* @tc.desc:verify app info is not null
* @tc.type: FUNC
* @tc.require: Issue Number
*/
it
(
"
Ambient_Light_SensorJsTest011
"
,
0
,
async
function
(
done
)
{
console
.
info
(
'
----------------------Ambient_Light_SensorJsTest011---------------------------
'
);
sensor
.
on
(
sensor
.
SensorType
.
SENSOR_TYPE_ID_AMBIENT_LIGHT
,
callback
,
{
'
interval
'
:
100000000
});
sensor
.
once
(
sensor
.
SensorType
.
SENSOR_TYPE_ID_AMBIENT_LIGHT
,
callback2
);
setTimeout
(()
=>
{
console
.
info
(
'
----------------------Ambient_Light_SensorJsTest011 off in---------------------------
'
);
sensor
.
off
(
sensor
.
SensorType
.
SENSOR_TYPE_ID_AMBIENT_LIGHT
);
console
.
info
(
'
----------------------Ambient_Light_SensorJsTest011 off end---------------------------
'
);
done
();
},
1000
);
})
/*
* @tc.name:Ambient_Light_SensorJsTest012
* @tc.desc:verify app info is not null
* @tc.type: FUNC
* @tc.require: Issue Number
*/
it
(
"
Ambient_Light_SensorJsTest012
"
,
0
,
async
function
(
done
)
{
console
.
info
(
'
----------------------Ambient_Light_SensorJsTest012---------------------------
'
);
sensor
.
on
(
sensor
.
SensorType
.
SENSOR_TYPE_ID_AMBIENT_LIGHT
,
callback
,
{
'
interval
'
:
100000000
});
sensor
.
on
(
sensor
.
SensorType
.
SENSOR_TYPE_ID_AMBIENT_LIGHT
,
callback2
,
{
'
interval
'
:
100000000
});
setTimeout
(()
=>
{
console
.
info
(
'
----------------------Ambient_Light_SensorJsTest012 off in---------------------------
'
);
sensor
.
off
(
sensor
.
SensorType
.
SENSOR_TYPE_ID_AMBIENT_LIGHT
,
callback
);
console
.
info
(
'
----------------------Ambient_Light_SensorJsTest012 off end---------------------------
'
);
},
500
);
setTimeout
(()
=>
{
console
.
info
(
'
----------------------Ambient_Light_SensorJsTest012 off in---------------------------
'
);
sensor
.
off
(
sensor
.
SensorType
.
SENSOR_TYPE_ID_AMBIENT_LIGHT
,
callback2
);
console
.
info
(
'
----------------------Ambient_Light_SensorJsTest012 off end---------------------------
'
);
done
();
},
1000
);
})
/*
* @tc.name:Ambient_Light_SensorJsTest013
* @tc.desc:verify app info is not null
* @tc.type: FUNC
* @tc.require: Issue Number
*/
it
(
"
Ambient_Light_SensorJsTest013
"
,
0
,
async
function
(
done
)
{
console
.
info
(
'
----------------------Ambient_Light_SensorJsTest013---------------------------
'
);
sensor
.
on
(
sensor
.
SensorType
.
SENSOR_TYPE_ID_AMBIENT_LIGHT
,
callback
,
{
'
interval
'
:
100000000
});
sensor
.
on
(
sensor
.
SensorType
.
SENSOR_TYPE_ID_AMBIENT_LIGHT
,
callback2
,
{
'
interval
'
:
100000000
});
setTimeout
(()
=>
{
console
.
info
(
'
----------------------Ambient_Light_SensorJsTest013 off in---------------------------
'
);
sensor
.
off
(
sensor
.
SensorType
.
SENSOR_TYPE_ID_AMBIENT_LIGHT
);
console
.
info
(
'
----------------------Ambient_Light_SensorJsTest013 off end---------------------------
'
);
done
();
},
1000
);
})
})
\ No newline at end of file
sensors/sensor_standard/src/main/js/default/test/GyroScope.js
→
sensors/sensor_standard/src/main/js/default/test/
SensorOnOffTest_
GyroScope.js
浏览文件 @
1c688540
...
@@ -64,6 +64,7 @@ describe("SensorJsTest", function () {
...
@@ -64,6 +64,7 @@ describe("SensorJsTest", function () {
let
errMessages
=
[
'
The number of parameters is not valid
'
,
'
Should subscribe first
'
,
let
errMessages
=
[
'
The number of parameters is not valid
'
,
'
Should subscribe first
'
,
'
string is not defined
'
];
'
string is not defined
'
];
let
errMessage
;
let
errMessage
;
/*
/*
...
@@ -106,13 +107,11 @@ describe("SensorJsTest", function () {
...
@@ -106,13 +107,11 @@ describe("SensorJsTest", function () {
*/
*/
it
(
"
GYROSCOPE_SensorJsTest003
"
,
0
,
async
function
(
done
)
{
it
(
"
GYROSCOPE_SensorJsTest003
"
,
0
,
async
function
(
done
)
{
console
.
info
(
'
----------------------GYROSCOPE_SensorJsTest003---------------------------
'
);
console
.
info
(
'
----------------------GYROSCOPE_SensorJsTest003---------------------------
'
);
function
onSensorCallback
(
data
)
{
function
onSensorCallback
(
data
)
{
console
.
info
(
'
GYROSCOPE_SensorJsTest003 on error
'
);
console
.
info
(
'
GYROSCOPE_SensorJsTest003 on error
'
);
expect
(
false
).
assertTrue
();
expect
(
false
).
assertTrue
();
done
();
done
();
}
}
try
{
try
{
sensor
.
on
(
sensor
.
SensorType
.
SENSOR_TYPE_ID_GYROSCOPE
,
onSensorCallback
,
{
'
interval
'
:
100000000
},
5
);
sensor
.
on
(
sensor
.
SensorType
.
SENSOR_TYPE_ID_GYROSCOPE
,
onSensorCallback
,
{
'
interval
'
:
100000000
},
5
);
}
catch
(
error
)
{
}
catch
(
error
)
{
...
@@ -146,13 +145,11 @@ describe("SensorJsTest", function () {
...
@@ -146,13 +145,11 @@ describe("SensorJsTest", function () {
*/
*/
it
(
"
GYROSCOPE_SensorJsTest005
"
,
0
,
async
function
(
done
)
{
it
(
"
GYROSCOPE_SensorJsTest005
"
,
0
,
async
function
(
done
)
{
console
.
info
(
'
----------------------GYROSCOPE_SensorJsTest005---------------------------
'
);
console
.
info
(
'
----------------------GYROSCOPE_SensorJsTest005---------------------------
'
);
function
onceSensorCallback
(
data
)
{
function
onceSensorCallback
(
data
)
{
console
.
info
(
'
GYROSCOPE_SensorJsTest005 on error
'
);
console
.
info
(
'
GYROSCOPE_SensorJsTest005 on error
'
);
expect
(
false
).
assertTrue
();
expect
(
false
).
assertTrue
();
done
();
done
();
}
}
try
{
try
{
sensor
.
once
(
sensor
.
SensorType
.
SENSOR_TYPE_ID_GYROSCOPE
,
onceSensorCallback
,
5
);
sensor
.
once
(
sensor
.
SensorType
.
SENSOR_TYPE_ID_GYROSCOPE
,
onceSensorCallback
,
5
);
}
catch
(
error
)
{
}
catch
(
error
)
{
...
...
sensors/sensor_standard/src/main/js/default/test/Hall.js
→
sensors/sensor_standard/src/main/js/default/test/
SensorOnOffTest_
Hall.js
浏览文件 @
1c688540
...
@@ -60,6 +60,7 @@ describe("SensorJsTest", function () {
...
@@ -60,6 +60,7 @@ describe("SensorJsTest", function () {
let
errMessages
=
[
'
The number of parameters is not valid
'
,
'
Should subscribe first
'
,
let
errMessages
=
[
'
The number of parameters is not valid
'
,
'
Should subscribe first
'
,
'
string is not defined
'
];
'
string is not defined
'
];
let
errMessage
;
let
errMessage
;
/*
/*
...
@@ -102,13 +103,11 @@ describe("SensorJsTest", function () {
...
@@ -102,13 +103,11 @@ describe("SensorJsTest", function () {
*/
*/
it
(
"
Hall_SensorJsTest003
"
,
0
,
async
function
(
done
)
{
it
(
"
Hall_SensorJsTest003
"
,
0
,
async
function
(
done
)
{
console
.
info
(
'
----------------------Hall_SensorJsTest003---------------------------
'
);
console
.
info
(
'
----------------------Hall_SensorJsTest003---------------------------
'
);
function
onSensorCallback
(
data
)
{
function
onSensorCallback
(
data
)
{
console
.
info
(
'
Hall_SensorJsTest003 on error
'
);
console
.
info
(
'
Hall_SensorJsTest003 on error
'
);
expect
(
false
).
assertTrue
();
expect
(
false
).
assertTrue
();
done
();
done
();
}
}
try
{
try
{
sensor
.
on
(
sensor
.
SensorType
.
SENSOR_TYPE_ID_HALL
,
onSensorCallback
,
{
'
interval
'
:
100000000
},
5
);
sensor
.
on
(
sensor
.
SensorType
.
SENSOR_TYPE_ID_HALL
,
onSensorCallback
,
{
'
interval
'
:
100000000
},
5
);
}
catch
(
error
)
{
}
catch
(
error
)
{
...
@@ -204,7 +203,6 @@ describe("SensorJsTest", function () {
...
@@ -204,7 +203,6 @@ describe("SensorJsTest", function () {
expect
(
false
).
assertTrue
();
expect
(
false
).
assertTrue
();
done
();
done
();
}
}
try
{
try
{
sensor
.
off
(
1000000
,
onSensorCallback
);
sensor
.
off
(
1000000
,
onSensorCallback
);
}
catch
(
error
)
{
}
catch
(
error
)
{
...
...
sensors/sensor_standard/src/main/js/default/test/getOnBodyState.js
→
sensors/sensor_standard/src/main/js/default/test/
Subscribe_
getOnBodyState.js
浏览文件 @
1c688540
...
@@ -50,6 +50,7 @@ describe("SensorJsTest", function () {
...
@@ -50,6 +50,7 @@ describe("SensorJsTest", function () {
let
errMessages
=
[
'
The number of parameters is not valid
'
,
'
Wrong argument type, function expected
'
,
let
errMessages
=
[
'
The number of parameters is not valid
'
,
'
Wrong argument type, function expected
'
,
'
Wrong argument type, should be object
'
]
'
Wrong argument type, should be object
'
]
let
errMessage
;
let
errMessage
;
/*
/*
...
...
sensors/sensor_standard/src/main/js/default/test/subscribeAccelerometer.js
→
sensors/sensor_standard/src/main/js/default/test/
Subscribe_
subscribeAccelerometer.js
浏览文件 @
1c688540
...
@@ -48,7 +48,10 @@ describe("SensorJsTest", function () {
...
@@ -48,7 +48,10 @@ describe("SensorJsTest", function () {
console
.
info
(
'
afterEach caled
'
)
console
.
info
(
'
afterEach caled
'
)
})
})
var
errMessages
=
[
'
The number of parameters is not valid
'
,
'
Wrong argument type, should be object
'
,
'
UnsubscribeSensor failed
'
];
let
errMessages
=
[
'
The number of parameters is not valid
'
,
'
Wrong argument type, should be object
'
,
'
UnsubscribeSensor failed
'
];
let
errMessage
;
/*
/*
* @tc.name:subscribeAccelerometer_SensorJsTest001
* @tc.name:subscribeAccelerometer_SensorJsTest001
...
@@ -71,7 +74,6 @@ describe("SensorJsTest", function () {
...
@@ -71,7 +74,6 @@ describe("SensorJsTest", function () {
expect
(
false
).
assertTrue
();
expect
(
false
).
assertTrue
();
},
},
});
});
setTimeout
(()
=>
{
setTimeout
(()
=>
{
try
{
try
{
sensor
.
unsubscribeAccelerometer
();
sensor
.
unsubscribeAccelerometer
();
...
@@ -107,7 +109,6 @@ describe("SensorJsTest", function () {
...
@@ -107,7 +109,6 @@ describe("SensorJsTest", function () {
expect
(
false
).
assertTrue
();
expect
(
false
).
assertTrue
();
},
},
});
});
setTimeout
(()
=>
{
setTimeout
(()
=>
{
try
{
try
{
sensor
.
unsubscribeAccelerometer
();
sensor
.
unsubscribeAccelerometer
();
...
@@ -181,7 +182,7 @@ describe("SensorJsTest", function () {
...
@@ -181,7 +182,7 @@ describe("SensorJsTest", function () {
},
},
},
25
);
},
25
);
}
catch
(
error
)
{
}
catch
(
error
)
{
var
errMessage
=
error
.
toString
().
slice
(
19
,
56
);
errMessage
=
error
.
toString
().
slice
(
19
,
56
);
console
.
info
(
'
subscribeAccelerometer_SensorJsTest004 error:
'
+
error
);
console
.
info
(
'
subscribeAccelerometer_SensorJsTest004 error:
'
+
error
);
expect
(
errMessage
).
assertEqual
(
errMessages
[
0
]);
expect
(
errMessage
).
assertEqual
(
errMessages
[
0
]);
done
();
done
();
...
@@ -212,7 +213,7 @@ describe("SensorJsTest", function () {
...
@@ -212,7 +213,7 @@ describe("SensorJsTest", function () {
},
function
()
{
},
function
()
{
},
25
);
},
25
);
}
catch
(
error
)
{
}
catch
(
error
)
{
var
errMessage
=
error
.
toString
().
slice
(
19
,
56
);
errMessage
=
error
.
toString
().
slice
(
19
,
56
);
console
.
info
(
'
subscribeAccelerometer_SensorJsTest005 error:
'
+
error
);
console
.
info
(
'
subscribeAccelerometer_SensorJsTest005 error:
'
+
error
);
expect
(
errMessage
).
assertEqual
(
errMessages
[
0
]);
expect
(
errMessage
).
assertEqual
(
errMessages
[
0
]);
done
();
done
();
...
@@ -280,7 +281,7 @@ describe("SensorJsTest", function () {
...
@@ -280,7 +281,7 @@ describe("SensorJsTest", function () {
try
{
try
{
sensor
.
subscribeAccelerometer
();
sensor
.
subscribeAccelerometer
();
}
catch
(
error
)
{
}
catch
(
error
)
{
var
errMessage
=
error
.
toString
().
slice
(
19
,
56
);
errMessage
=
error
.
toString
().
slice
(
19
,
56
);
console
.
info
(
'
subscribeAccelerometer_SensorJsTest007 error:
'
+
error
);
console
.
info
(
'
subscribeAccelerometer_SensorJsTest007 error:
'
+
error
);
expect
(
errMessage
).
assertEqual
(
errMessages
[
0
]);
expect
(
errMessage
).
assertEqual
(
errMessages
[
0
]);
done
();
done
();
...
@@ -298,7 +299,7 @@ describe("SensorJsTest", function () {
...
@@ -298,7 +299,7 @@ describe("SensorJsTest", function () {
try
{
try
{
sensor
.
subscribeAccelerometer
(
'
xxx
'
);
sensor
.
subscribeAccelerometer
(
'
xxx
'
);
}
catch
(
error
)
{
}
catch
(
error
)
{
var
errMessage
=
error
.
toString
().
slice
(
19
,
56
);
errMessage
=
error
.
toString
().
slice
(
19
,
56
);
console
.
info
(
'
subscribeAccelerometer_SensorJsTest008 error:
'
+
error
);
console
.
info
(
'
subscribeAccelerometer_SensorJsTest008 error:
'
+
error
);
expect
(
errMessage
).
assertEqual
(
errMessages
[
1
]);
expect
(
errMessage
).
assertEqual
(
errMessages
[
1
]);
done
();
done
();
...
@@ -316,7 +317,7 @@ describe("SensorJsTest", function () {
...
@@ -316,7 +317,7 @@ describe("SensorJsTest", function () {
try
{
try
{
sensor
.
unsubscribeAccelerometer
(
'
xxx
'
);
sensor
.
unsubscribeAccelerometer
(
'
xxx
'
);
}
catch
(
error
)
{
}
catch
(
error
)
{
var
errMessage
=
error
.
toString
().
slice
(
21
,
58
);
errMessage
=
error
.
toString
().
slice
(
21
,
58
);
console
.
info
(
'
subscribeAccelerometer_SensorJsTest009 error:
'
+
error
);
console
.
info
(
'
subscribeAccelerometer_SensorJsTest009 error:
'
+
error
);
expect
(
errMessage
).
assertEqual
(
errMessages
[
0
]);
expect
(
errMessage
).
assertEqual
(
errMessages
[
0
]);
done
();
done
();
...
@@ -358,7 +359,7 @@ describe("SensorJsTest", function () {
...
@@ -358,7 +359,7 @@ describe("SensorJsTest", function () {
try
{
try
{
sensor
.
unsubscribeAccelerometer
();
sensor
.
unsubscribeAccelerometer
();
}
catch
(
error
)
{
}
catch
(
error
)
{
var
errMessage
=
error
.
toString
().
slice
(
21
,
45
);
errMessage
=
error
.
toString
().
slice
(
21
,
45
);
console
.
info
(
'
subscribeAccelerometer_SensorJsTest011 error:
'
+
error
);
console
.
info
(
'
subscribeAccelerometer_SensorJsTest011 error:
'
+
error
);
expect
(
errMessage
).
assertEqual
(
errMessages
[
2
]);
expect
(
errMessage
).
assertEqual
(
errMessages
[
2
]);
done
();
done
();
...
@@ -430,12 +431,10 @@ describe("SensorJsTest", function () {
...
@@ -430,12 +431,10 @@ describe("SensorJsTest", function () {
expect
(
false
).
assertTrue
();
expect
(
false
).
assertTrue
();
},
},
});
});
try
{
try
{
sensor
.
unsubscribeAccelerometer
();
sensor
.
unsubscribeAccelerometer
();
}
catch
(
error
)
{
}
catch
(
error
)
{
console
.
info
(
'
subscribeAccelerometer_SensorJsTest014_unsubscribeAccelerometer error
'
+
error
);
console
.
info
(
'
subscribeAccelerometer_SensorJsTest014_unsubscribeAccelerometer error
'
+
error
);
expect
(
true
).
assertTrue
();
}
}
setTimeout
(()
=>
{
setTimeout
(()
=>
{
expect
(
true
).
assertTrue
();
expect
(
true
).
assertTrue
();
...
...
sensors/sensor_standard/src/main/js/default/test/subscribeBarometer.js
→
sensors/sensor_standard/src/main/js/default/test/
Subscribe_
subscribeBarometer.js
浏览文件 @
1c688540
...
@@ -50,6 +50,7 @@ describe("SensorJsTest", function () {
...
@@ -50,6 +50,7 @@ describe("SensorJsTest", function () {
let
errMessages
=
[
'
The number of parameters is not valid
'
,
'
UnsubscribeSensor failed
'
,
let
errMessages
=
[
'
The number of parameters is not valid
'
,
'
UnsubscribeSensor failed
'
,
'
Wrong argument type, should be object
'
];
'
Wrong argument type, should be object
'
];
let
errMessage
;
let
errMessage
;
/*
/*
...
@@ -83,7 +84,6 @@ describe("SensorJsTest", function () {
...
@@ -83,7 +84,6 @@ describe("SensorJsTest", function () {
},
1000
);
},
1000
);
})
})
/*
/*
* @tc.name:subscribeBarometer_SensorJsTest002
* @tc.name:subscribeBarometer_SensorJsTest002
* @tc.desc:verify app info is not null
* @tc.desc:verify app info is not null
...
@@ -221,7 +221,6 @@ describe("SensorJsTest", function () {
...
@@ -221,7 +221,6 @@ describe("SensorJsTest", function () {
expect
(
code
).
assertEqual
(
1001
);
expect
(
code
).
assertEqual
(
1001
);
},
},
});
});
setTimeout
(()
=>
{
setTimeout
(()
=>
{
try
{
try
{
sensor
.
unsubscribeBarometer
();
sensor
.
unsubscribeBarometer
();
...
@@ -246,7 +245,7 @@ describe("SensorJsTest", function () {
...
@@ -246,7 +245,7 @@ describe("SensorJsTest", function () {
try
{
try
{
sensor
.
unsubscribeBarometer
();
sensor
.
unsubscribeBarometer
();
}
catch
(
error
)
{
}
catch
(
error
)
{
var
errMessage
=
error
.
toString
().
slice
(
21
,
45
);
errMessage
=
error
.
toString
().
slice
(
21
,
45
);
console
.
info
(
'
subscribeBarometer_SensorJsTest008 error:
'
+
error
);
console
.
info
(
'
subscribeBarometer_SensorJsTest008 error:
'
+
error
);
expect
(
errMessage
).
assertEqual
(
errMessages
[
1
]);
expect
(
errMessage
).
assertEqual
(
errMessages
[
1
]);
done
();
done
();
...
@@ -271,7 +270,6 @@ describe("SensorJsTest", function () {
...
@@ -271,7 +270,6 @@ describe("SensorJsTest", function () {
expect
(
code
).
assertEqual
(
1001
);
expect
(
code
).
assertEqual
(
1001
);
},
},
});
});
try
{
try
{
sensor
.
unsubscribeBarometer
();
sensor
.
unsubscribeBarometer
();
}
catch
(
error
)
{
}
catch
(
error
)
{
...
...
sensors/sensor_standard/src/main/js/default/test/subscribeCompass.js
→
sensors/sensor_standard/src/main/js/default/test/
Subscribe_
subscribeCompass.js
浏览文件 @
1c688540
...
@@ -50,6 +50,7 @@ describe("SensorJsTest", function () {
...
@@ -50,6 +50,7 @@ describe("SensorJsTest", function () {
let
errMessages
=
[
'
The number of parameters is not valid
'
,
'
UnsubscribeSensor failed
'
,
let
errMessages
=
[
'
The number of parameters is not valid
'
,
'
UnsubscribeSensor failed
'
,
'
Wrong argument type, should be object
'
];
'
Wrong argument type, should be object
'
];
let
errMessage
;
let
errMessage
;
/*
/*
...
@@ -125,7 +126,6 @@ describe("SensorJsTest", function () {
...
@@ -125,7 +126,6 @@ describe("SensorJsTest", function () {
expect
(
typeof
(
data
.
direction
)).
assertEqual
(
"
number
"
);
expect
(
typeof
(
data
.
direction
)).
assertEqual
(
"
number
"
);
},
},
});
});
setTimeout
(()
=>
{
setTimeout
(()
=>
{
try
{
try
{
sensor
.
unsubscribeCompass
();
sensor
.
unsubscribeCompass
();
...
@@ -250,7 +250,6 @@ describe("SensorJsTest", function () {
...
@@ -250,7 +250,6 @@ describe("SensorJsTest", function () {
expect
(
false
).
assertTrue
();
expect
(
false
).
assertTrue
();
},
},
});
});
setTimeout
(()
=>
{
setTimeout
(()
=>
{
try
{
try
{
sensor
.
unsubscribeCompass
();
sensor
.
unsubscribeCompass
();
...
@@ -301,12 +300,10 @@ describe("SensorJsTest", function () {
...
@@ -301,12 +300,10 @@ describe("SensorJsTest", function () {
expect
(
false
).
assertTrue
();
expect
(
false
).
assertTrue
();
},
},
});
});
try
{
try
{
sensor
.
unsubscribeCompass
();
sensor
.
unsubscribeCompass
();
}
catch
(
error
)
{
}
catch
(
error
)
{
console
.
info
(
'
subscribeLight_SensorJsTest010_unsubscribeLight error
'
+
error
);
console
.
info
(
'
subscribeLight_SensorJsTest010_unsubscribeLight error
'
+
error
);
expect
(
true
).
assertTrue
();
}
}
setTimeout
(()
=>
{
setTimeout
(()
=>
{
expect
(
true
).
assertTrue
();
expect
(
true
).
assertTrue
();
...
...
sensors/sensor_standard/src/main/js/default/test/subscribeDeviceOrientation.js
→
sensors/sensor_standard/src/main/js/default/test/
Subscribe_
subscribeDeviceOrientation.js
浏览文件 @
1c688540
...
@@ -50,6 +50,7 @@ describe("SensorJsTest", function () {
...
@@ -50,6 +50,7 @@ describe("SensorJsTest", function () {
let
errMessages
=
[
'
The number of parameters is not valid
'
,
'
Wrong argument type, should be object
'
,
let
errMessages
=
[
'
The number of parameters is not valid
'
,
'
Wrong argument type, should be object
'
,
'
UnsubscribeSensor failed
'
];
'
UnsubscribeSensor failed
'
];
let
errMessage
;
let
errMessage
;
/*
/*
...
@@ -437,7 +438,6 @@ describe("SensorJsTest", function () {
...
@@ -437,7 +438,6 @@ describe("SensorJsTest", function () {
sensor
.
unsubscribeDeviceOrientation
();
sensor
.
unsubscribeDeviceOrientation
();
}
catch
(
error
)
{
}
catch
(
error
)
{
console
.
info
(
'
subscribeDeviceOrientation_SensorJsTest014_unsubscribeDeviceOrientation error
'
+
error
);
console
.
info
(
'
subscribeDeviceOrientation_SensorJsTest014_unsubscribeDeviceOrientation error
'
+
error
);
expect
(
true
).
assertTrue
();
}
}
setTimeout
(()
=>
{
setTimeout
(()
=>
{
expect
(
true
).
assertTrue
();
expect
(
true
).
assertTrue
();
...
...
sensors/sensor_standard/src/main/js/default/test/subscribeGyroscope.js
→
sensors/sensor_standard/src/main/js/default/test/
Subscribe_
subscribeGyroscope.js
浏览文件 @
1c688540
...
@@ -48,7 +48,10 @@ describe("SensorJsTest", function () {
...
@@ -48,7 +48,10 @@ describe("SensorJsTest", function () {
console
.
info
(
'
afterEach caled
'
)
console
.
info
(
'
afterEach caled
'
)
})
})
var
errMessages
=
[
'
The number of parameters is not valid
'
,
'
Wrong argument type, should be object
'
,
'
UnsubscribeSensor failed
'
];
let
errMessages
=
[
'
The number of parameters is not valid
'
,
'
Wrong argument type, should be object
'
,
'
UnsubscribeSensor failed
'
];
let
errMessage
;
/*
/*
* @tc.name:subscribeGyroscope_SensorJsTest001
* @tc.name:subscribeGyroscope_SensorJsTest001
...
@@ -71,7 +74,6 @@ describe("SensorJsTest", function () {
...
@@ -71,7 +74,6 @@ describe("SensorJsTest", function () {
expect
(
false
).
assertTrue
();
expect
(
false
).
assertTrue
();
},
},
});
});
setTimeout
(()
=>
{
setTimeout
(()
=>
{
try
{
try
{
sensor
.
unsubscribeGyroscope
();
sensor
.
unsubscribeGyroscope
();
...
@@ -107,7 +109,6 @@ describe("SensorJsTest", function () {
...
@@ -107,7 +109,6 @@ describe("SensorJsTest", function () {
expect
(
false
).
assertTrue
();
expect
(
false
).
assertTrue
();
},
},
});
});
setTimeout
(()
=>
{
setTimeout
(()
=>
{
try
{
try
{
sensor
.
unsubscribeGyroscope
();
sensor
.
unsubscribeGyroscope
();
...
@@ -229,7 +230,7 @@ describe("SensorJsTest", function () {
...
@@ -229,7 +230,7 @@ describe("SensorJsTest", function () {
},
},
},
25
);
},
25
);
}
catch
(
error
)
{
}
catch
(
error
)
{
var
errMessage
=
error
.
toString
().
slice
(
19
,
56
);
errMessage
=
error
.
toString
().
slice
(
19
,
56
);
console
.
info
(
'
subscribeGyroscope_SensorJsTest006 error:
'
+
error
);
console
.
info
(
'
subscribeGyroscope_SensorJsTest006 error:
'
+
error
);
expect
(
errMessage
).
assertEqual
(
errMessages
[
0
]);
expect
(
errMessage
).
assertEqual
(
errMessages
[
0
]);
done
();
done
();
...
@@ -260,7 +261,7 @@ describe("SensorJsTest", function () {
...
@@ -260,7 +261,7 @@ describe("SensorJsTest", function () {
},
function
()
{
},
function
()
{
},
25
);
},
25
);
}
catch
(
error
)
{
}
catch
(
error
)
{
var
errMessage
=
error
.
toString
().
slice
(
19
,
56
);
errMessage
=
error
.
toString
().
slice
(
19
,
56
);
console
.
info
(
'
subscribeGyroscope_SensorJsTest007 error:
'
+
error
);
console
.
info
(
'
subscribeGyroscope_SensorJsTest007 error:
'
+
error
);
expect
(
errMessage
).
assertEqual
(
errMessages
[
0
]);
expect
(
errMessage
).
assertEqual
(
errMessages
[
0
]);
done
();
done
();
...
@@ -288,7 +289,6 @@ describe("SensorJsTest", function () {
...
@@ -288,7 +289,6 @@ describe("SensorJsTest", function () {
expect
(
false
).
assertTrue
();
expect
(
false
).
assertTrue
();
},
},
});
});
sensor
.
subscribeGyroscope
({
sensor
.
subscribeGyroscope
({
interval
:
'
normal
'
,
interval
:
'
normal
'
,
success
:
function
(
data
)
{
success
:
function
(
data
)
{
...
@@ -302,7 +302,6 @@ describe("SensorJsTest", function () {
...
@@ -302,7 +302,6 @@ describe("SensorJsTest", function () {
expect
(
false
).
assertTrue
();
expect
(
false
).
assertTrue
();
},
},
});
});
setTimeout
(()
=>
{
setTimeout
(()
=>
{
try
{
try
{
sensor
.
unsubscribeGyroscope
();
sensor
.
unsubscribeGyroscope
();
...
@@ -328,7 +327,7 @@ describe("SensorJsTest", function () {
...
@@ -328,7 +327,7 @@ describe("SensorJsTest", function () {
try
{
try
{
sensor
.
subscribeGyroscope
();
sensor
.
subscribeGyroscope
();
}
catch
(
error
)
{
}
catch
(
error
)
{
var
errMessage
=
error
.
toString
().
slice
(
19
,
56
);
errMessage
=
error
.
toString
().
slice
(
19
,
56
);
console
.
info
(
'
subscribeGyroscope_SensorJsTest009 error:
'
+
error
);
console
.
info
(
'
subscribeGyroscope_SensorJsTest009 error:
'
+
error
);
expect
(
errMessage
).
assertEqual
(
errMessages
[
0
]);
expect
(
errMessage
).
assertEqual
(
errMessages
[
0
]);
done
();
done
();
...
@@ -346,7 +345,7 @@ describe("SensorJsTest", function () {
...
@@ -346,7 +345,7 @@ describe("SensorJsTest", function () {
try
{
try
{
sensor
.
subscribeGyroscope
(
'
xxx
'
);
sensor
.
subscribeGyroscope
(
'
xxx
'
);
}
catch
(
error
)
{
}
catch
(
error
)
{
var
errMessage
=
error
.
toString
().
slice
(
19
,
56
);
errMessage
=
error
.
toString
().
slice
(
19
,
56
);
console
.
info
(
'
subscribeGyroscope_SensorJsTest010 error:
'
+
error
);
console
.
info
(
'
subscribeGyroscope_SensorJsTest010 error:
'
+
error
);
expect
(
errMessage
).
assertEqual
(
errMessages
[
1
]);
expect
(
errMessage
).
assertEqual
(
errMessages
[
1
]);
done
();
done
();
...
@@ -364,7 +363,7 @@ describe("SensorJsTest", function () {
...
@@ -364,7 +363,7 @@ describe("SensorJsTest", function () {
try
{
try
{
sensor
.
unsubscribeGyroscope
();
sensor
.
unsubscribeGyroscope
();
}
catch
(
error
)
{
}
catch
(
error
)
{
var
errMessage
=
error
.
toString
().
slice
(
21
,
45
);
errMessage
=
error
.
toString
().
slice
(
21
,
45
);
console
.
info
(
'
subscribeGyroscope_SensorJsTest011 error:
'
+
error
);
console
.
info
(
'
subscribeGyroscope_SensorJsTest011 error:
'
+
error
);
expect
(
errMessage
).
assertEqual
(
errMessages
[
2
]);
expect
(
errMessage
).
assertEqual
(
errMessages
[
2
]);
done
();
done
();
...
@@ -382,7 +381,7 @@ describe("SensorJsTest", function () {
...
@@ -382,7 +381,7 @@ describe("SensorJsTest", function () {
try
{
try
{
sensor
.
unsubscribeGyroscope
(
'
xxx
'
);
sensor
.
unsubscribeGyroscope
(
'
xxx
'
);
}
catch
(
error
)
{
}
catch
(
error
)
{
var
errMessage
=
error
.
toString
().
slice
(
21
,
58
);
errMessage
=
error
.
toString
().
slice
(
21
,
58
);
console
.
info
(
'
subscribeGyroscope_SensorJsTest012 error:
'
+
error
);
console
.
info
(
'
subscribeGyroscope_SensorJsTest012 error:
'
+
error
);
expect
(
errMessage
).
assertEqual
(
errMessages
[
0
]);
expect
(
errMessage
).
assertEqual
(
errMessages
[
0
]);
done
();
done
();
...
@@ -431,12 +430,10 @@ describe("SensorJsTest", function () {
...
@@ -431,12 +430,10 @@ describe("SensorJsTest", function () {
expect
(
false
).
assertTrue
();
expect
(
false
).
assertTrue
();
},
},
});
});
try
{
try
{
sensor
.
unsubscribeGyroscope
();
sensor
.
unsubscribeGyroscope
();
}
catch
(
error
)
{
}
catch
(
error
)
{
console
.
info
(
'
subscribeAccelerometer_SensorJsTest014_unsubscribeAccelerometer error
'
+
error
);
console
.
info
(
'
subscribeAccelerometer_SensorJsTest014_unsubscribeAccelerometer error
'
+
error
);
expect
(
false
).
assertTrue
();
}
}
setTimeout
(()
=>
{
setTimeout
(()
=>
{
expect
(
true
).
assertTrue
();
expect
(
true
).
assertTrue
();
...
...
sensors/sensor_standard/src/main/js/default/test/subscribeHeartRate.js
→
sensors/sensor_standard/src/main/js/default/test/
Subscribe_
subscribeHeartRate.js
浏览文件 @
1c688540
...
@@ -50,6 +50,7 @@ describe("SensorJsTest", function () {
...
@@ -50,6 +50,7 @@ describe("SensorJsTest", function () {
let
errMessages
=
[
'
The number of parameters is not valid
'
,
'
UnsubscribeSensor failed
'
,
let
errMessages
=
[
'
The number of parameters is not valid
'
,
'
UnsubscribeSensor failed
'
,
'
Wrong argument type, should be object
'
];
'
Wrong argument type, should be object
'
];
let
errMessage
;
let
errMessage
;
/*
/*
...
@@ -220,7 +221,6 @@ describe("SensorJsTest", function () {
...
@@ -220,7 +221,6 @@ describe("SensorJsTest", function () {
expect
(
code
).
assertEqual
(
1001
);
expect
(
code
).
assertEqual
(
1001
);
},
},
});
});
setTimeout
(()
=>
{
setTimeout
(()
=>
{
try
{
try
{
sensor
.
unsubscribeHeartRate
();
sensor
.
unsubscribeHeartRate
();
...
...
sensors/sensor_standard/src/main/js/default/test/subscribeLight.js
→
sensors/sensor_standard/src/main/js/default/test/
Subscribe_
subscribeLight.js
浏览文件 @
1c688540
...
@@ -48,7 +48,10 @@ describe("SensorJsTest", function () {
...
@@ -48,7 +48,10 @@ describe("SensorJsTest", function () {
console
.
info
(
'
afterEach caled
'
)
console
.
info
(
'
afterEach caled
'
)
})
})
var
errMessages
=
[
'
The number of parameters is not valid
'
,
'
UnsubscribeSensor failed
'
,
'
Wrong argument type, should be object
'
];
let
errMessages
=
[
'
The number of parameters is not valid
'
,
'
UnsubscribeSensor failed
'
,
'
Wrong argument type, should be object
'
];
let
errMessage
;
/*
/*
* @tc.name:subscribeLight_SensorJsTest001
* @tc.name:subscribeLight_SensorJsTest001
...
@@ -68,7 +71,6 @@ describe("SensorJsTest", function () {
...
@@ -68,7 +71,6 @@ describe("SensorJsTest", function () {
expect
(
false
).
assertTrue
();
expect
(
false
).
assertTrue
();
},
},
});
});
setTimeout
(()
=>
{
setTimeout
(()
=>
{
try
{
try
{
sensor
.
unsubscribeLight
();
sensor
.
unsubscribeLight
();
...
@@ -103,7 +105,7 @@ describe("SensorJsTest", function () {
...
@@ -103,7 +105,7 @@ describe("SensorJsTest", function () {
},
},
},
25
);
},
25
);
}
catch
(
error
)
{
}
catch
(
error
)
{
var
errMessage
=
error
.
toString
().
slice
(
19
,
56
);
errMessage
=
error
.
toString
().
slice
(
19
,
56
);
console
.
info
(
'
subscribeLight_SensorJsTest002 error:
'
+
error
);
console
.
info
(
'
subscribeLight_SensorJsTest002 error:
'
+
error
);
expect
(
errMessage
).
assertEqual
(
errMessages
[
0
]);
expect
(
errMessage
).
assertEqual
(
errMessages
[
0
]);
done
();
done
();
...
@@ -124,7 +126,6 @@ describe("SensorJsTest", function () {
...
@@ -124,7 +126,6 @@ describe("SensorJsTest", function () {
expect
(
typeof
(
data
.
intensity
)).
assertEqual
(
"
number
"
);
expect
(
typeof
(
data
.
intensity
)).
assertEqual
(
"
number
"
);
},
},
});
});
setTimeout
(()
=>
{
setTimeout
(()
=>
{
try
{
try
{
sensor
.
unsubscribeLight
();
sensor
.
unsubscribeLight
();
...
@@ -160,7 +161,7 @@ describe("SensorJsTest", function () {
...
@@ -160,7 +161,7 @@ describe("SensorJsTest", function () {
},
function
()
{
},
function
()
{
},
25
);
},
25
);
}
catch
(
error
)
{
}
catch
(
error
)
{
var
errMessage
=
error
.
toString
().
slice
(
19
,
56
);
errMessage
=
error
.
toString
().
slice
(
19
,
56
);
console
.
info
(
'
subscribeLight_SensorJsTest004 error:
'
+
error
);
console
.
info
(
'
subscribeLight_SensorJsTest004 error:
'
+
error
);
expect
(
errMessage
).
assertEqual
(
errMessages
[
0
]);
expect
(
errMessage
).
assertEqual
(
errMessages
[
0
]);
done
();
done
();
...
@@ -178,7 +179,7 @@ describe("SensorJsTest", function () {
...
@@ -178,7 +179,7 @@ describe("SensorJsTest", function () {
try
{
try
{
sensor
.
unsubscribeLight
(
'
xxx
'
);
sensor
.
unsubscribeLight
(
'
xxx
'
);
}
catch
(
error
)
{
}
catch
(
error
)
{
var
errMessage
=
error
.
toString
().
slice
(
21
,
58
);
errMessage
=
error
.
toString
().
slice
(
21
,
58
);
console
.
info
(
'
subscribeLight_SensorJsTest005 error:
'
+
error
);
console
.
info
(
'
subscribeLight_SensorJsTest005 error:
'
+
error
);
expect
(
errMessage
).
assertEqual
(
errMessages
[
0
]);
expect
(
errMessage
).
assertEqual
(
errMessages
[
0
]);
done
();
done
();
...
@@ -196,7 +197,7 @@ describe("SensorJsTest", function () {
...
@@ -196,7 +197,7 @@ describe("SensorJsTest", function () {
try
{
try
{
sensor
.
subscribeLight
();
sensor
.
subscribeLight
();
}
catch
(
error
)
{
}
catch
(
error
)
{
var
errMessage
=
error
.
toString
().
slice
(
19
,
56
);
errMessage
=
error
.
toString
().
slice
(
19
,
56
);
console
.
info
(
'
subscribeLight_SensorJsTest006 error:
'
+
error
);
console
.
info
(
'
subscribeLight_SensorJsTest006 error:
'
+
error
);
expect
(
errMessage
).
assertEqual
(
errMessages
[
0
]);
expect
(
errMessage
).
assertEqual
(
errMessages
[
0
]);
done
();
done
();
...
@@ -214,7 +215,7 @@ describe("SensorJsTest", function () {
...
@@ -214,7 +215,7 @@ describe("SensorJsTest", function () {
try
{
try
{
sensor
.
subscribeLight
(
'
xxx
'
);
sensor
.
subscribeLight
(
'
xxx
'
);
}
catch
(
error
)
{
}
catch
(
error
)
{
var
errMessage
=
error
.
toString
().
slice
(
19
,
56
);
errMessage
=
error
.
toString
().
slice
(
19
,
56
);
console
.
info
(
'
subscribeLight_SensorJsTest007 error:
'
+
error
);
console
.
info
(
'
subscribeLight_SensorJsTest007 error:
'
+
error
);
expect
(
errMessage
).
assertEqual
(
errMessages
[
2
]);
expect
(
errMessage
).
assertEqual
(
errMessages
[
2
]);
done
();
done
();
...
@@ -249,7 +250,6 @@ describe("SensorJsTest", function () {
...
@@ -249,7 +250,6 @@ describe("SensorJsTest", function () {
expect
(
false
).
assertTrue
();
expect
(
false
).
assertTrue
();
},
},
});
});
setTimeout
(()
=>
{
setTimeout
(()
=>
{
try
{
try
{
sensor
.
unsubscribeLight
();
sensor
.
unsubscribeLight
();
...
@@ -275,7 +275,7 @@ describe("SensorJsTest", function () {
...
@@ -275,7 +275,7 @@ describe("SensorJsTest", function () {
try
{
try
{
sensor
.
unsubscribeLight
();
sensor
.
unsubscribeLight
();
}
catch
(
error
)
{
}
catch
(
error
)
{
var
errMessage
=
error
.
toString
().
slice
(
21
,
45
);
errMessage
=
error
.
toString
().
slice
(
21
,
45
);
console
.
info
(
'
subscribeLight_SensorJsTest009 error:
'
+
error
);
console
.
info
(
'
subscribeLight_SensorJsTest009 error:
'
+
error
);
expect
(
errMessage
).
assertEqual
(
errMessages
[
1
]);
expect
(
errMessage
).
assertEqual
(
errMessages
[
1
]);
done
();
done
();
...
@@ -300,12 +300,10 @@ describe("SensorJsTest", function () {
...
@@ -300,12 +300,10 @@ describe("SensorJsTest", function () {
expect
(
false
).
assertTrue
();
expect
(
false
).
assertTrue
();
},
},
});
});
try
{
try
{
sensor
.
unsubscribeLight
();
sensor
.
unsubscribeLight
();
}
catch
(
error
)
{
}
catch
(
error
)
{
console
.
info
(
'
subscribeLight_SensorJsTest008_unsubscribeLight error
'
+
error
);
console
.
info
(
'
subscribeLight_SensorJsTest008_unsubscribeLight error
'
+
error
);
expect
(
true
).
assertTrue
();
}
}
setTimeout
(()
=>
{
setTimeout
(()
=>
{
expect
(
true
).
assertTrue
();
expect
(
true
).
assertTrue
();
...
...
sensors/sensor_standard/src/main/js/default/test/subscribeOnBodyState.js
→
sensors/sensor_standard/src/main/js/default/test/
Subscribe_
subscribeOnBodyState.js
浏览文件 @
1c688540
...
@@ -50,6 +50,7 @@ describe("SensorJsTest", function () {
...
@@ -50,6 +50,7 @@ describe("SensorJsTest", function () {
let
errMessages
=
[
'
The number of parameters is not valid
'
,
'
UnsubscribeSensor failed
'
,
let
errMessages
=
[
'
The number of parameters is not valid
'
,
'
UnsubscribeSensor failed
'
,
'
Wrong argument type, should be object
'
];
'
Wrong argument type, should be object
'
];
let
errMessage
;
let
errMessage
;
/*
/*
...
@@ -210,7 +211,6 @@ describe("SensorJsTest", function () {
...
@@ -210,7 +211,6 @@ describe("SensorJsTest", function () {
expect
(
code
).
assertEqual
(
1001
);
expect
(
code
).
assertEqual
(
1001
);
},
},
});
});
sensor
.
subscribeOnBodyState
({
sensor
.
subscribeOnBodyState
({
success
:
function
(
data
)
{
success
:
function
(
data
)
{
console
.
info
(
"
subscribeOnBodyState_SensorJsTest007_1 success:
"
+
JSON
.
stringify
(
data
));
console
.
info
(
"
subscribeOnBodyState_SensorJsTest007_1 success:
"
+
JSON
.
stringify
(
data
));
...
@@ -221,7 +221,6 @@ describe("SensorJsTest", function () {
...
@@ -221,7 +221,6 @@ describe("SensorJsTest", function () {
expect
(
code
).
assertEqual
(
1001
);
expect
(
code
).
assertEqual
(
1001
);
},
},
});
});
setTimeout
(()
=>
{
setTimeout
(()
=>
{
try
{
try
{
sensor
.
unsubscribeOnBodyState
();
sensor
.
unsubscribeOnBodyState
();
...
@@ -271,7 +270,6 @@ describe("SensorJsTest", function () {
...
@@ -271,7 +270,6 @@ describe("SensorJsTest", function () {
expect
(
code
).
assertEqual
(
1001
);
expect
(
code
).
assertEqual
(
1001
);
},
},
});
});
try
{
try
{
sensor
.
unsubscribeOnBodyState
();
sensor
.
unsubscribeOnBodyState
();
}
catch
(
error
)
{
}
catch
(
error
)
{
...
...
sensors/sensor_standard/src/main/js/default/test/subscribeProximity.js
→
sensors/sensor_standard/src/main/js/default/test/
Subscribe_
subscribeProximity.js
浏览文件 @
1c688540
...
@@ -50,6 +50,7 @@ describe("SensorJsTest", function () {
...
@@ -50,6 +50,7 @@ describe("SensorJsTest", function () {
let
errMessages
=
[
'
The number of parameters is not valid
'
,
'
UnsubscribeSensor failed
'
,
let
errMessages
=
[
'
The number of parameters is not valid
'
,
'
UnsubscribeSensor failed
'
,
'
Wrong argument type, should be object
'
];
'
Wrong argument type, should be object
'
];
let
errMessage
;
let
errMessage
;
/*
/*
...
@@ -61,22 +62,22 @@ describe("SensorJsTest", function () {
...
@@ -61,22 +62,22 @@ describe("SensorJsTest", function () {
it
(
"
subscribeProximity_SensorJsTest001
"
,
0
,
async
function
(
done
)
{
it
(
"
subscribeProximity_SensorJsTest001
"
,
0
,
async
function
(
done
)
{
console
.
info
(
'
----------------------subscribeProximity_SensorJsTest001---------------------------
'
);
console
.
info
(
'
----------------------subscribeProximity_SensorJsTest001---------------------------
'
);
sensor
.
subscribeProximity
({
sensor
.
subscribeProximity
({
success
:
function
(
data
)
{
success
:
function
(
data
)
{
console
.
info
(
"
subscribeProximity_SensorJsTest001 success
"
+
JSON
.
stringify
(
data
));
console
.
info
(
"
subscribeProximity_SensorJsTest001 success
"
+
JSON
.
stringify
(
data
));
expect
(
typeof
(
data
.
distance
)).
assertEqual
(
"
number
"
);
expect
(
typeof
(
data
.
distance
)).
assertEqual
(
"
number
"
);
},
},
fail
:
function
(
data
,
code
)
{
fail
:
function
(
data
,
code
)
{
console
.
error
(
'
subscribeProximity_SensorJsTest001 failed. Code:
'
+
code
+
'
; Data:
'
+
data
);
console
.
error
(
'
subscribeProximity_SensorJsTest001 failed. Code:
'
+
code
+
'
; Data:
'
+
data
);
expect
(
code
).
assertEqual
(
1001
);
expect
(
code
).
assertEqual
(
1001
);
},
},
});
});
setTimeout
(()
=>
{
setTimeout
(()
=>
{
try
{
try
{
sensor
.
unsubscribeProximity
();
sensor
.
unsubscribeProximity
();
}
catch
(
error
)
{
}
catch
(
error
)
{
console
.
info
(
error
);
console
.
info
(
error
);
}
}
setTimeout
(()
=>
{
setTimeout
(()
=>
{
expect
(
true
).
assertTrue
();
expect
(
true
).
assertTrue
();
done
();
done
();
},
500
);
},
500
);
...
@@ -220,7 +221,6 @@ describe("SensorJsTest", function () {
...
@@ -220,7 +221,6 @@ describe("SensorJsTest", function () {
expect
(
code
).
assertEqual
(
1001
);
expect
(
code
).
assertEqual
(
1001
);
},
},
});
});
setTimeout
(()
=>
{
setTimeout
(()
=>
{
try
{
try
{
sensor
.
unsubscribeProximity
();
sensor
.
unsubscribeProximity
();
...
@@ -245,7 +245,7 @@ describe("SensorJsTest", function () {
...
@@ -245,7 +245,7 @@ describe("SensorJsTest", function () {
try
{
try
{
sensor
.
unsubscribeProximity
();
sensor
.
unsubscribeProximity
();
}
catch
(
error
)
{
}
catch
(
error
)
{
errMessage
=
error
.
toString
().
slice
(
21
,
45
);
errMessage
=
error
.
toString
().
slice
(
21
,
45
);
console
.
info
(
'
subscribeProximity_SensorJsTest008 error:
'
+
error
);
console
.
info
(
'
subscribeProximity_SensorJsTest008 error:
'
+
error
);
expect
(
errMessage
).
assertEqual
(
errMessages
[
1
]);
expect
(
errMessage
).
assertEqual
(
errMessages
[
1
]);
done
();
done
();
...
@@ -270,7 +270,6 @@ describe("SensorJsTest", function () {
...
@@ -270,7 +270,6 @@ describe("SensorJsTest", function () {
expect
(
code
).
assertEqual
(
1001
);
expect
(
code
).
assertEqual
(
1001
);
},
},
});
});
try
{
try
{
sensor
.
unsubscribeProximity
();
sensor
.
unsubscribeProximity
();
}
catch
(
error
)
{
}
catch
(
error
)
{
...
...
sensors/sensor_standard/src/main/js/default/test/subscribeStepCounter.js
→
sensors/sensor_standard/src/main/js/default/test/
Subscribe_
subscribeStepCounter.js
浏览文件 @
1c688540
...
@@ -50,6 +50,7 @@ describe("SensorJsTest", function () {
...
@@ -50,6 +50,7 @@ describe("SensorJsTest", function () {
let
errMessages
=
[
'
The number of parameters is not valid
'
,
'
UnsubscribeSensor failed
'
,
let
errMessages
=
[
'
The number of parameters is not valid
'
,
'
UnsubscribeSensor failed
'
,
'
Wrong argument type, should be object
'
];
'
Wrong argument type, should be object
'
];
let
errMessage
;
let
errMessage
;
/*
/*
...
@@ -61,22 +62,22 @@ describe("SensorJsTest", function () {
...
@@ -61,22 +62,22 @@ describe("SensorJsTest", function () {
it
(
"
subscribeStepCounter_SensorJsTest001
"
,
0
,
async
function
(
done
)
{
it
(
"
subscribeStepCounter_SensorJsTest001
"
,
0
,
async
function
(
done
)
{
console
.
info
(
'
----------------------subscribeStepCounter_SensorJsTest001---------------------------
'
);
console
.
info
(
'
----------------------subscribeStepCounter_SensorJsTest001---------------------------
'
);
sensor
.
subscribeStepCounter
({
sensor
.
subscribeStepCounter
({
success
:
function
(
data
)
{
success
:
function
(
data
)
{
console
.
info
(
"
subscribeStepCounter_SensorJsTest001 success
"
+
JSON
.
stringify
(
data
));
console
.
info
(
"
subscribeStepCounter_SensorJsTest001 success
"
+
JSON
.
stringify
(
data
));
expect
(
typeof
(
data
.
steps
)).
assertEqual
(
"
number
"
);
expect
(
typeof
(
data
.
steps
)).
assertEqual
(
"
number
"
);
},
},
fail
:
function
(
data
,
code
)
{
fail
:
function
(
data
,
code
)
{
console
.
error
(
'
subscribeStepCounter_SensorJsTest001 failed. Code:
'
+
code
+
'
; Data:
'
+
data
);
console
.
error
(
'
subscribeStepCounter_SensorJsTest001 failed. Code:
'
+
code
+
'
; Data:
'
+
data
);
expect
(
code
).
assertEqual
(
1001
);
expect
(
code
).
assertEqual
(
1001
);
},
},
});
});
setTimeout
(()
=>
{
setTimeout
(()
=>
{
try
{
try
{
sensor
.
unsubscribeStepCounter
();
sensor
.
unsubscribeStepCounter
();
}
catch
(
error
)
{
}
catch
(
error
)
{
console
.
info
(
'
subscribeStepCounter_SensorJsTest001_unsubscribeStepCounter error
'
+
error
);
console
.
info
(
'
subscribeStepCounter_SensorJsTest001_unsubscribeStepCounter error
'
+
error
);
}
}
setTimeout
(()
=>
{
setTimeout
(()
=>
{
expect
(
true
).
assertTrue
();
expect
(
true
).
assertTrue
();
done
();
done
();
},
500
);
},
500
);
...
@@ -128,7 +129,8 @@ describe("SensorJsTest", function () {
...
@@ -128,7 +129,8 @@ describe("SensorJsTest", function () {
console
.
error
(
'
subscribeStepCounter_SensorJsTest003 failed. Code:
'
+
code
+
'
; Data:
'
+
data
);
console
.
error
(
'
subscribeStepCounter_SensorJsTest003 failed. Code:
'
+
code
+
'
; Data:
'
+
data
);
expect
(
code
).
assertEqual
(
1001
);
expect
(
code
).
assertEqual
(
1001
);
},
},
},
function
()
{},
25
);
},
function
()
{
},
25
);
}
catch
(
error
)
{
}
catch
(
error
)
{
errMessage
=
error
.
toString
().
slice
(
19
,
56
);
errMessage
=
error
.
toString
().
slice
(
19
,
56
);
console
.
info
(
'
subscribeStepCounter_SensorJsTest003 error:
'
+
error
);
console
.
info
(
'
subscribeStepCounter_SensorJsTest003 error:
'
+
error
);
...
@@ -219,7 +221,6 @@ describe("SensorJsTest", function () {
...
@@ -219,7 +221,6 @@ describe("SensorJsTest", function () {
expect
(
code
).
assertEqual
(
1001
);
expect
(
code
).
assertEqual
(
1001
);
},
},
});
});
setTimeout
(()
=>
{
setTimeout
(()
=>
{
try
{
try
{
sensor
.
unsubscribeStepCounter
();
sensor
.
unsubscribeStepCounter
();
...
@@ -244,7 +245,7 @@ describe("SensorJsTest", function () {
...
@@ -244,7 +245,7 @@ describe("SensorJsTest", function () {
try
{
try
{
sensor
.
unsubscribeStepCounter
();
sensor
.
unsubscribeStepCounter
();
}
catch
(
error
)
{
}
catch
(
error
)
{
errMessage
=
error
.
toString
().
slice
(
21
,
45
);
errMessage
=
error
.
toString
().
slice
(
21
,
45
);
console
.
info
(
'
subscribeStepCounter_SensorJsTest008 error:
'
+
error
);
console
.
info
(
'
subscribeStepCounter_SensorJsTest008 error:
'
+
error
);
expect
(
errMessage
).
assertEqual
(
errMessages
[
1
]);
expect
(
errMessage
).
assertEqual
(
errMessages
[
1
]);
done
();
done
();
...
@@ -269,7 +270,6 @@ describe("SensorJsTest", function () {
...
@@ -269,7 +270,6 @@ describe("SensorJsTest", function () {
expect
(
code
).
assertEqual
(
1001
);
expect
(
code
).
assertEqual
(
1001
);
},
},
});
});
try
{
try
{
sensor
.
unsubscribeStepCounter
();
sensor
.
unsubscribeStepCounter
();
}
catch
(
error
)
{
}
catch
(
error
)
{
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录