Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
OpenHarmony
Xts Acts
提交
cd1fa4e6
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看板
体验新版 GitCode,发现更多精彩内容 >>
提交
cd1fa4e6
编写于
5月 17, 2022
作者:
L
lidanyang16
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
<lidanyang16@huawei.com>
Signed-off-by:
N
lidanyang16
<
lidanyang16@huawei.com
>
上级
5dbf9b24
变更
5
显示空白变更内容
内联
并排
Showing
5 changed file
with
841 addition
and
823 deletion
+841
-823
sensors/miscdevice_standard/src/main/js/default/test/vibrate.js
...s/miscdevice_standard/src/main/js/default/test/vibrate.js
+167
-165
sensors/sensor_standard/src/main/js/default/test/SensorOnOffTest.test.js
...standard/src/main/js/default/test/SensorOnOffTest.test.js
+28
-26
sensors/sensor_standard/src/main/js/default/test/subscribeAccelerometer.js
...andard/src/main/js/default/test/subscribeAccelerometer.js
+241
-241
sensors/sensor_standard/src/main/js/default/test/subscribeGyroscope.js
...r_standard/src/main/js/default/test/subscribeGyroscope.js
+243
-239
sensors/sensor_standard/src/main/js/default/test/subscribeLight.js
...ensor_standard/src/main/js/default/test/subscribeLight.js
+162
-152
未找到文件。
sensors/miscdevice_standard/src/main/js/default/test/vibrate.js
浏览文件 @
cd1fa4e6
...
...
@@ -13,39 +13,43 @@
* limitations under the License.
*/
import
vibrator
from
'
@system.vibrator
'
;
import
{
describe
,
beforeAll
,
beforeEach
,
afterEach
,
afterAll
,
it
,
expect
}
from
'
deccjsunit/index
'
import
{
describe
,
beforeAll
,
beforeEach
,
afterEach
,
afterAll
,
it
,
expect
}
from
'
deccjsunit/index
'
describe
(
"
VibratorJsTest
"
,
function
()
{
beforeAll
(
function
()
{
beforeAll
(
function
()
{
/*
* @tc.setup: setup invoked before all testcases
*/
console
.
info
(
'
beforeAll caled
'
)
})
afterAll
(
function
()
{
afterAll
(
function
()
{
/*
* @tc.teardown: teardown invoked after all testcases
*/
console
.
info
(
'
afterAll caled
'
)
})
beforeEach
(
function
()
{
beforeEach
(
function
()
{
/*
* @tc.setup: setup invoked before each testcases
*/
console
.
info
(
'
beforeEach caled
'
)
})
afterEach
(
function
()
{
afterEach
(
function
()
{
/*
* @tc.teardown: teardown invoked after each testcases
*/
console
.
info
(
'
afterEach caled
'
)
})
var
errMessages
=
[
'
Param number is invalid
'
,
'
Wrong argument type. function expected
'
,
'
Wrong argument type
'
,
'
Wrong argument number
'
]
var
errMessages
=
[
'
Param number is invalid
'
,
'
Wrong argument type. function expected
'
,
'
Wrong argument type
'
,
'
Wrong argument number
'
]
/*
* @tc.name:VibratorJsTest0001
* @tc.desc:verify app info is not null
...
...
@@ -56,16 +60,16 @@ describe("VibratorJsTest", function () {
console
.
info
(
'
----------------------VibratorJsTest0001---------------------------
'
);
vibrator
.
vibrate
({
mode
:
'
long
'
,
success
:
function
()
{
success
:
function
()
{
console
.
info
(
"
VibratorJsTest0001 success
"
);
expect
(
true
).
assertTrue
();
done
();
},
fail
:
function
(
data
,
code
)
{
fail
:
function
(
data
,
code
)
{
console
.
log
(
"
VibratorJsTest0001 is failed, data:
"
+
data
+
"
, code:
"
+
code
);
expect
(
false
).
assertTrue
();
},
complete
:
function
()
{
complete
:
function
()
{
console
.
log
(
'
VibratorJsTest0001 is completed
'
);
}
});
...
...
@@ -81,16 +85,16 @@ describe("VibratorJsTest", function () {
console
.
info
(
'
----------------------VibratorJsTest0002---------------------------
'
);
vibrator
.
vibrate
({
mode
:
'
short
'
,
success
:
function
()
{
success
:
function
()
{
console
.
info
(
"
VibratorJsTest0002 success
"
);
expect
(
true
).
assertTrue
();
done
();
},
fail
:
function
(
data
,
code
)
{
fail
:
function
(
data
,
code
)
{
console
.
log
(
"
VibratorJsTest0002 is failed, data:
"
+
data
+
"
, code:
"
+
code
);
expect
(
false
).
assertTrue
();
},
complete
:
function
()
{
complete
:
function
()
{
console
.
log
(
'
VibratorJsTest0002 is completed
'
);
}
});
...
...
@@ -106,12 +110,12 @@ describe("VibratorJsTest", function () {
console
.
info
(
'
----------------------VibratorJsTest0003---------------------------
'
);
vibrator
.
vibrate
({
mode
:
'
short
'
,
success
:
function
()
{
success
:
function
()
{
console
.
info
(
"
VibratorJsTest0003 success
"
);
expect
(
true
).
assertTrue
();
done
();
},
fail
:
function
(
data
,
code
)
{
fail
:
function
(
data
,
code
)
{
console
.
error
(
'
VibratorJsTest0003 failed. Code:
'
+
code
+
'
; Data:
'
+
data
);
expect
(
false
).
assertTrue
();
},
...
...
@@ -128,7 +132,7 @@ describe("VibratorJsTest", function () {
console
.
info
(
'
----------------------VibratorJsTest0004---------------------------
'
);
vibrator
.
vibrate
({
mode
:
'
short
'
,
success
:
function
()
{
success
:
function
()
{
console
.
info
(
"
VibratorJsTest0004 success
"
);
expect
(
true
).
assertTrue
();
done
();
...
...
@@ -145,12 +149,12 @@ describe("VibratorJsTest", function () {
it
(
"
VibratorJsTest0005
"
,
0
,
async
function
(
done
)
{
console
.
info
(
'
----------------------VibratorJsTest0005---------------------------
'
);
vibrator
.
vibrate
({
success
:
function
()
{
success
:
function
()
{
console
.
info
(
"
VibratorJsTest0005 success
"
);
expect
(
true
).
assertTrue
();
done
();
},
fail
:
function
(
data
,
code
)
{
fail
:
function
(
data
,
code
)
{
console
.
error
(
'
VibratorJsTest0005 failed. Code:
'
+
code
+
'
; Data:
'
+
data
);
expect
(
false
).
assertTrue
();
},
...
...
@@ -167,21 +171,19 @@ describe("VibratorJsTest", function () {
console
.
info
(
'
----------------------VibratorJsTest0006---------------------------
'
);
vibrator
.
vibrate
({
mode
:
'
long
'
,
inInvalid
:
2
,
success
:
function
()
{
inInvalid
:
2
,
success
:
function
()
{
console
.
info
(
"
VibratorJsTest0006 success
"
);
expect
(
true
).
assertTrue
();
done
();
},
fail
:
function
(
data
,
code
)
{
fail
:
function
(
data
,
code
)
{
console
.
error
(
'
VibratorJsTest0006 failed. Code:
'
+
code
+
'
; Data:
'
+
data
);
expect
(
false
).
assertTrue
();
},
});
})
/*
* @tc.name:VibratorJsTest0007
* @tc.desc:verify app info is not null
...
...
@@ -190,15 +192,15 @@ describe("VibratorJsTest", function () {
*/
it
(
"
VibratorJsTest0007
"
,
0
,
async
function
(
done
)
{
console
.
info
(
'
----------------------VibratorJsTest0007---------------------------
'
);
try
{
try
{
vibrator
.
vibrate
({
mode
:
'
short
'
,
success
:
function
()
{
success
:
function
()
{
console
.
info
(
"
VibratorJsTest0007 success
"
);
expect
(
false
).
assertTrue
();
done
();
},
},
25
);
},
25
);
}
catch
(
error
)
{
var
errMessage
=
error
.
toString
().
slice
(
39
);
console
.
info
(
'
VibratorJsTest0007 error:
'
+
error
);
...
...
@@ -207,7 +209,6 @@ describe("VibratorJsTest", function () {
}
})
/*
* @tc.name:VibratorJsTest0008
* @tc.desc:verify app info is not null
...
...
@@ -218,11 +219,11 @@ describe("VibratorJsTest", function () {
console
.
info
(
'
----------------------VibratorJsTest0008---------------------------
'
);
vibrator
.
vibrate
({
mode
:
'
short
'
,
success
:
function
()
{
success
:
function
()
{
console
.
info
(
"
VibratorJsTest0008 success
"
);
expect
(
true
).
assertTrue
();
},
fail
:
function
(
data
,
code
)
{
fail
:
function
(
data
,
code
)
{
console
.
error
(
'
VibratorJsTest0008 failed. Code:
'
+
code
+
'
; Data:
'
+
data
);
expect
(
false
).
assertTrue
();
},
...
...
@@ -230,11 +231,11 @@ describe("VibratorJsTest", function () {
vibrator
.
vibrate
({
mode
:
'
short
'
,
success
:
function
()
{
success
:
function
()
{
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
);
expect
(
false
).
assertTrue
();
},
...
...
@@ -254,9 +255,9 @@ describe("VibratorJsTest", function () {
it
(
"
VibratorJsTest0009
"
,
0
,
async
function
(
done
)
{
console
.
info
(
'
----------------------VibratorJsTest0009---------------------------
'
);
try
{
vibrator
.
vibrate
(
'
xxx
'
,
done
);
vibrator
.
vibrate
(
'
xxx
'
,
done
);
}
catch
(
error
)
{
console
.
info
(
'
VibratorJsTest0009 error:
'
+
error
);
console
.
info
(
'
VibratorJsTest0009 error:
'
+
error
);
var
errMessage
=
error
.
toString
().
slice
(
68
);
expect
(
errMessage
).
assertEqual
(
errMessages
[
1
]);
done
();
...
...
@@ -289,15 +290,16 @@ describe("VibratorJsTest", function () {
*/
it
(
"
VibratorJsTest0011
"
,
0
,
async
function
(
done
)
{
console
.
info
(
'
----------------------VibratorJsTest0011---------------------------
'
);
try
{
try
{
vibrator
.
vibrate
({
mode
:
'
short
'
,
success
:
function
()
{
success
:
function
()
{
console
.
info
(
"
VibratorJsTest0011 success
"
);
expect
(
false
).
assertTrue
();
done
();
},
},
function
(){},
25
);
},
function
()
{
},
25
);
}
catch
(
error
)
{
var
errMessage
=
error
.
toString
().
slice
(
39
);
console
.
info
(
'
VibratorJsTest0011 error:
'
+
error
);
...
...
@@ -305,6 +307,6 @@ describe("VibratorJsTest", function () {
done
();
}
})
})
})
\ No newline at end of file
sensors/sensor_standard/src/main/js/default/test/SensorOnOffTest.test.js
100755 → 100644
浏览文件 @
cd1fa4e6
...
...
@@ -57,7 +57,7 @@ describe('SystemParameterTest', function () {
*/
it
(
'
SUB_SENSORS_Sensor_JSTest_0010
'
,
0
,
async
function
(
done
)
{
console
.
info
(
'
SUB_SENSORS_Sensor_JSTest_0010 start
'
);
try
{
try
{
sensor
.
on
(
testSensorId
,
function
(
data
)
{
if
(
data
)
{
console
.
info
(
'
testRegisterSensortest001 on success
'
);
...
...
@@ -85,11 +85,13 @@ describe('SystemParameterTest', function () {
*/
it
(
'
SUB_SENSORS_Sensor_JSTest_0020
'
,
0
,
async
function
(
done
)
{
console
.
info
(
'
SUB_SENSORS_Sensor_JSTest_0020 start
'
);
function
onSensorCallback
(
data
)
{
console
.
info
(
'
SensorJsTest002 on error
'
);
expect
(
false
).
assertTrue
();
done
();
}
try
{
sensor
.
on
(
testNullSensorId
,
onSensorCallback
);
}
catch
(
error
)
{
...
...
sensors/sensor_standard/src/main/js/default/test/subscribeAccelerometer.js
浏览文件 @
cd1fa4e6
...
...
@@ -13,39 +13,42 @@
* limitations under the License.
*/
import
sensor
from
'
@system.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
()
{
beforeAll
(
function
()
{
beforeAll
(
function
()
{
/*
* @tc.setup: setup invoked before all testcases
*/
console
.
info
(
'
beforeAll caled
'
)
})
afterAll
(
function
()
{
afterAll
(
function
()
{
/*
* @tc.teardown: teardown invoked after all testcases
*/
console
.
info
(
'
afterAll caled
'
)
})
beforeEach
(
function
()
{
beforeEach
(
function
()
{
/*
* @tc.setup: setup invoked before each testcases
*/
console
.
info
(
'
beforeEach caled
'
)
})
afterEach
(
function
()
{
afterEach
(
function
()
{
/*
* @tc.teardown: teardown invoked after each testcases
*/
console
.
info
(
'
afterEach caled
'
)
})
var
errMessages
=
[
'
The number of parameters is not valid
'
,
'
Wrong argument type, should be object
'
,
'
UnsubscribeSensor failed
'
];
var
errMessages
=
[
'
The number of parameters is not valid
'
,
'
Wrong argument type, should be object
'
,
'
UnsubscribeSensor failed
'
];
/*
* @tc.name:subscribeAccelerometer_SensorJsTest001
...
...
@@ -57,26 +60,26 @@ describe("SensorJsTest", function () {
console
.
info
(
'
----------------------subscribeAccelerometer_SensorJsTest001---------------------------
'
);
sensor
.
subscribeAccelerometer
({
interval
:
'
game
'
,
success
:
function
(
data
)
{
success
:
function
(
data
)
{
console
.
info
(
"
subscribeAccelerometer_SensorJsTest001 success
"
+
JSON
.
stringify
(
data
));
expect
(
typeof
(
data
.
x
)).
assertEqual
(
"
number
"
);
expect
(
typeof
(
data
.
y
)).
assertEqual
(
"
number
"
);
expect
(
typeof
(
data
.
z
)).
assertEqual
(
"
number
"
);
expect
(
typeof
(
data
.
x
)).
assertEqual
(
"
number
"
);
expect
(
typeof
(
data
.
y
)).
assertEqual
(
"
number
"
);
expect
(
typeof
(
data
.
z
)).
assertEqual
(
"
number
"
);
},
fail
:
function
(
data
,
code
)
{
fail
:
function
(
data
,
code
)
{
console
.
log
(
"
subscribeAccelerometer_SensorJsTest001 is failed, data:
"
+
data
+
"
, code:
"
+
code
);
expect
(
false
).
assertTrue
();
},
});
setTimeout
(()
=>
{
setTimeout
(()
=>
{
try
{
sensor
.
unsubscribeAccelerometer
();
}
catch
(
error
)
{
console
.
info
(
'
subscribeAccelerometer_SensorJsTest001_unsubscribeAccelerometer error
'
+
error
);
expect
(
false
).
assertTrue
();
}
setTimeout
(()
=>
{
setTimeout
(()
=>
{
expect
(
true
).
assertTrue
();
done
();
},
500
);
...
...
@@ -93,26 +96,26 @@ describe("SensorJsTest", function () {
console
.
info
(
'
----------------------subscribeAccelerometer_SensorJsTest002---------------------------
'
);
sensor
.
subscribeAccelerometer
({
interval
:
'
ui
'
,
success
:
function
(
data
)
{
success
:
function
(
data
)
{
console
.
info
(
"
subscribeAccelerometer_SensorJsTest002 success
"
+
JSON
.
stringify
(
data
));
expect
(
typeof
(
data
.
x
)).
assertEqual
(
"
number
"
);
expect
(
typeof
(
data
.
y
)).
assertEqual
(
"
number
"
);
expect
(
typeof
(
data
.
z
)).
assertEqual
(
"
number
"
);
expect
(
typeof
(
data
.
x
)).
assertEqual
(
"
number
"
);
expect
(
typeof
(
data
.
y
)).
assertEqual
(
"
number
"
);
expect
(
typeof
(
data
.
z
)).
assertEqual
(
"
number
"
);
},
fail
:
function
(
data
,
code
)
{
fail
:
function
(
data
,
code
)
{
console
.
log
(
"
subscribeAccelerometer_SensorJsTest002 is failed, data:
"
+
data
+
"
, code:
"
+
code
);
expect
(
false
).
assertTrue
();
},
});
setTimeout
(()
=>
{
setTimeout
(()
=>
{
try
{
sensor
.
unsubscribeAccelerometer
();
}
catch
(
error
)
{
console
.
info
(
'
subscribeAccelerometer_SensorJsTest002_unsubscribeAccelerometer error
'
+
error
);
expect
(
false
).
assertTrue
();
}
setTimeout
(()
=>
{
setTimeout
(()
=>
{
expect
(
true
).
assertTrue
();
done
();
},
500
);
...
...
@@ -129,26 +132,26 @@ describe("SensorJsTest", function () {
console
.
info
(
'
----------------------subscribeAccelerometer_SensorJsTest003---------------------------
'
);
sensor
.
subscribeAccelerometer
({
interval
:
'
normal
'
,
success
:
function
(
data
)
{
success
:
function
(
data
)
{
console
.
info
(
"
subscribeAccelerometer_SensorJsTest003 success
"
+
JSON
.
stringify
(
data
));
expect
(
typeof
(
data
.
x
)).
assertEqual
(
"
number
"
);
expect
(
typeof
(
data
.
y
)).
assertEqual
(
"
number
"
);
expect
(
typeof
(
data
.
z
)).
assertEqual
(
"
number
"
);
expect
(
typeof
(
data
.
x
)).
assertEqual
(
"
number
"
);
expect
(
typeof
(
data
.
y
)).
assertEqual
(
"
number
"
);
expect
(
typeof
(
data
.
z
)).
assertEqual
(
"
number
"
);
},
fail
:
function
(
data
,
code
)
{
fail
:
function
(
data
,
code
)
{
console
.
log
(
"
subscribeAccelerometer_SensorJsTest003 is failed, data:
"
+
data
+
"
, code:
"
+
code
);
expect
(
false
).
assertTrue
();
},
});
setTimeout
(()
=>
{
setTimeout
(()
=>
{
try
{
sensor
.
unsubscribeAccelerometer
();
}
catch
(
error
)
{
console
.
info
(
'
subscribeAccelerometer_SensorJsTest003_unsubscribeAccelerometer error
'
+
error
);
expect
(
false
).
assertTrue
();
}
setTimeout
(()
=>
{
setTimeout
(()
=>
{
expect
(
true
).
assertTrue
();
done
();
},
500
);
...
...
@@ -163,29 +166,28 @@ describe("SensorJsTest", function () {
*/
it
(
"
subscribeAccelerometer_SensorJsTest004
"
,
0
,
async
function
(
done
)
{
console
.
info
(
'
----------------------subscribeAccelerometer_SensorJsTest004---------------------------
'
);
try
{
try
{
sensor
.
subscribeAccelerometer
({
interval
:
'
normal
'
,
success
:
function
(
data
)
{
success
:
function
(
data
)
{
console
.
info
(
"
subscribeAccelerometer_SensorJsTest004 success
"
+
JSON
.
stringify
(
data
));
expect
(
typeof
(
data
.
x
)).
assertEqual
(
"
number
"
);
expect
(
typeof
(
data
.
y
)).
assertEqual
(
"
number
"
);
expect
(
typeof
(
data
.
z
)).
assertEqual
(
"
number
"
);
expect
(
typeof
(
data
.
x
)).
assertEqual
(
"
number
"
);
expect
(
typeof
(
data
.
y
)).
assertEqual
(
"
number
"
);
expect
(
typeof
(
data
.
z
)).
assertEqual
(
"
number
"
);
},
fail
:
function
(
data
,
code
)
{
fail
:
function
(
data
,
code
)
{
console
.
log
(
"
subscribeAccelerometer_SensorJsTest004 is failed, data:
"
+
data
+
"
, code:
"
+
code
);
expect
(
false
).
assertTrue
();
},
},
25
);
},
25
);
}
catch
(
error
)
{
var
errMessage
=
error
.
toString
().
slice
(
19
,
56
);
var
errMessage
=
error
.
toString
().
slice
(
19
,
56
);
console
.
info
(
'
subscribeAccelerometer_SensorJsTest004 error:
'
+
error
);
expect
(
errMessage
).
assertEqual
(
errMessages
[
0
]);
done
();
}
})
/*
* @tc.name:subscribeAccelerometer_SensorJsTest005
* @tc.desc:verify app info is not null
...
...
@@ -194,30 +196,29 @@ describe("SensorJsTest", function () {
*/
it
(
"
subscribeAccelerometer_SensorJsTest005
"
,
0
,
async
function
(
done
)
{
console
.
info
(
'
----------------------subscribeAccelerometer_SensorJsTest005---------------------------
'
);
try
{
try
{
sensor
.
subscribeAccelerometer
({
interval
:
'
normal
'
,
success
:
function
(
data
)
{
success
:
function
(
data
)
{
console
.
info
(
"
subscribeAccelerometer_SensorJsTest005 success
"
+
JSON
.
stringify
(
data
));
expect
(
typeof
(
data
.
x
)).
assertEqual
(
"
number
"
);
expect
(
typeof
(
data
.
y
)).
assertEqual
(
"
number
"
);
expect
(
typeof
(
data
.
z
)).
assertEqual
(
"
number
"
);
expect
(
typeof
(
data
.
x
)).
assertEqual
(
"
number
"
);
expect
(
typeof
(
data
.
y
)).
assertEqual
(
"
number
"
);
expect
(
typeof
(
data
.
z
)).
assertEqual
(
"
number
"
);
},
fail
:
function
(
data
,
code
)
{
fail
:
function
(
data
,
code
)
{
console
.
log
(
"
subscribeAccelerometer_SensorJsTest005 is failed, data:
"
+
data
+
"
, code:
"
+
code
);
expect
(
false
).
assertTrue
();
},
},
function
(){},
25
);
},
function
()
{
},
25
);
}
catch
(
error
)
{
var
errMessage
=
error
.
toString
().
slice
(
19
,
56
);
var
errMessage
=
error
.
toString
().
slice
(
19
,
56
);
console
.
info
(
'
subscribeAccelerometer_SensorJsTest005 error:
'
+
error
);
expect
(
errMessage
).
assertEqual
(
errMessages
[
0
]);
done
();
}
})
/*
* @tc.name:subscribeAccelerometer_SensorJsTest006
* @tc.desc:verify app info is not null
...
...
@@ -228,13 +229,13 @@ describe("SensorJsTest", function () {
console
.
info
(
'
----------------------subscribeAccelerometer_SensorJsTest006---------------------------
'
);
sensor
.
subscribeAccelerometer
({
interval
:
'
normal
'
,
success
:
function
(
data
)
{
success
:
function
(
data
)
{
console
.
info
(
"
subscribeAccelerometer_SensorJsTest006 success
"
+
JSON
.
stringify
(
data
));
expect
(
typeof
(
data
.
x
)).
assertEqual
(
"
number
"
);
expect
(
typeof
(
data
.
y
)).
assertEqual
(
"
number
"
);
expect
(
typeof
(
data
.
z
)).
assertEqual
(
"
number
"
);
expect
(
typeof
(
data
.
x
)).
assertEqual
(
"
number
"
);
expect
(
typeof
(
data
.
y
)).
assertEqual
(
"
number
"
);
expect
(
typeof
(
data
.
z
)).
assertEqual
(
"
number
"
);
},
fail
:
function
(
data
,
code
)
{
fail
:
function
(
data
,
code
)
{
console
.
log
(
"
subscribeAccelerometer_SensorJsTest006 is failed, data:
"
+
data
+
"
, code:
"
+
code
);
expect
(
false
).
assertTrue
();
},
...
...
@@ -242,26 +243,26 @@ describe("SensorJsTest", function () {
sensor
.
subscribeAccelerometer
({
interval
:
'
normal
'
,
success
:
function
(
data
)
{
success
:
function
(
data
)
{
console
.
info
(
"
subscribeAccelerometer_SensorJsTest006_1 success
"
+
JSON
.
stringify
(
data
));
expect
(
typeof
(
data
.
x
)).
assertEqual
(
"
number
"
);
expect
(
typeof
(
data
.
y
)).
assertEqual
(
"
number
"
);
expect
(
typeof
(
data
.
z
)).
assertEqual
(
"
number
"
);
expect
(
typeof
(
data
.
x
)).
assertEqual
(
"
number
"
);
expect
(
typeof
(
data
.
y
)).
assertEqual
(
"
number
"
);
expect
(
typeof
(
data
.
z
)).
assertEqual
(
"
number
"
);
},
fail
:
function
(
data
,
code
)
{
fail
:
function
(
data
,
code
)
{
console
.
log
(
"
subscribeAccelerometer_SensorJsTest006_1 is failed, data:
"
+
data
+
"
, code:
"
+
code
);
expect
(
false
).
assertTrue
();
},
});
setTimeout
(()
=>
{
setTimeout
(()
=>
{
try
{
sensor
.
unsubscribeAccelerometer
();
}
catch
(
error
)
{
console
.
info
(
'
subscribeAccelerometer_SensorJsTest006_unsubscribeAccelerometer error
'
+
error
);
expect
(
false
).
assertTrue
();
}
setTimeout
(()
=>
{
setTimeout
(()
=>
{
expect
(
true
).
assertTrue
();
done
();
},
500
);
...
...
@@ -276,10 +277,10 @@ describe("SensorJsTest", function () {
*/
it
(
"
subscribeAccelerometer_SensorJsTest007
"
,
0
,
async
function
(
done
)
{
console
.
info
(
'
----------------------subscribeAccelerometer_SensorJsTest007---------------------------
'
);
try
{
try
{
sensor
.
subscribeAccelerometer
();
}
catch
(
error
)
{
var
errMessage
=
error
.
toString
().
slice
(
19
,
56
);
var
errMessage
=
error
.
toString
().
slice
(
19
,
56
);
console
.
info
(
'
subscribeAccelerometer_SensorJsTest007 error:
'
+
error
);
expect
(
errMessage
).
assertEqual
(
errMessages
[
0
]);
done
();
...
...
@@ -294,17 +295,16 @@ describe("SensorJsTest", function () {
*/
it
(
"
subscribeAccelerometer_SensorJsTest008
"
,
0
,
async
function
(
done
)
{
console
.
info
(
'
----------------------subscribeAccelerometer_SensorJsTest008---------------------------
'
);
try
{
try
{
sensor
.
subscribeAccelerometer
(
'
xxx
'
);
}
catch
(
error
)
{
var
errMessage
=
error
.
toString
().
slice
(
19
,
56
);
var
errMessage
=
error
.
toString
().
slice
(
19
,
56
);
console
.
info
(
'
subscribeAccelerometer_SensorJsTest008 error:
'
+
error
);
expect
(
errMessage
).
assertEqual
(
errMessages
[
1
]);
done
();
}
})
/*
* @tc.name:subscribeAccelerometer_SensorJsTest009
* @tc.desc:verify app info is not null
...
...
@@ -313,10 +313,10 @@ describe("SensorJsTest", function () {
*/
it
(
"
subscribeAccelerometer_SensorJsTest009
"
,
0
,
async
function
(
done
)
{
console
.
info
(
'
----------------------subscribeAccelerometer_SensorJsTest009---------------------------
'
);
try
{
try
{
sensor
.
unsubscribeAccelerometer
(
'
xxx
'
);
}
catch
(
error
)
{
var
errMessage
=
error
.
toString
().
slice
(
21
,
58
);
var
errMessage
=
error
.
toString
().
slice
(
21
,
58
);
console
.
info
(
'
subscribeAccelerometer_SensorJsTest009 error:
'
+
error
);
expect
(
errMessage
).
assertEqual
(
errMessages
[
0
]);
done
();
...
...
@@ -333,13 +333,13 @@ describe("SensorJsTest", function () {
console
.
info
(
'
----------------------subscribeAccelerometer_SensorJsTest010---------------------------
'
);
sensor
.
subscribeAccelerometer
({
interval
:
'
xxx
'
,
success
:
function
(
data
)
{
success
:
function
(
data
)
{
console
.
info
(
"
subscribeAccelerometer_SensorJsTest010 success
"
+
JSON
.
stringify
(
data
));
expect
(
typeof
(
data
.
x
)).
assertEqual
(
"
number
"
);
expect
(
typeof
(
data
.
y
)).
assertEqual
(
"
number
"
);
expect
(
typeof
(
data
.
z
)).
assertEqual
(
"
number
"
);
expect
(
typeof
(
data
.
x
)).
assertEqual
(
"
number
"
);
expect
(
typeof
(
data
.
y
)).
assertEqual
(
"
number
"
);
expect
(
typeof
(
data
.
z
)).
assertEqual
(
"
number
"
);
},
fail
:
function
(
data
,
code
)
{
fail
:
function
(
data
,
code
)
{
console
.
log
(
"
subscribeAccelerometer_SensorJsTest010 is failed, data:
"
+
data
+
"
, code:
"
+
code
);
expect
(
code
).
assertEqual
(
202
);
done
();
...
...
@@ -355,10 +355,10 @@ describe("SensorJsTest", function () {
*/
it
(
"
subscribeAccelerometer_SensorJsTest011
"
,
0
,
async
function
(
done
)
{
console
.
info
(
'
----------------------subscribeAccelerometer_SensorJsTest011---------------------------
'
);
try
{
try
{
sensor
.
unsubscribeAccelerometer
();
}
catch
(
error
)
{
var
errMessage
=
error
.
toString
().
slice
(
21
,
45
);
var
errMessage
=
error
.
toString
().
slice
(
21
,
45
);
console
.
info
(
'
subscribeAccelerometer_SensorJsTest011 error:
'
+
error
);
expect
(
errMessage
).
assertEqual
(
errMessages
[
2
]);
done
();
...
...
@@ -375,11 +375,11 @@ describe("SensorJsTest", function () {
console
.
info
(
'
----------------------subscribeAccelerometer_SensorJsTest012---------------------------
'
);
sensor
.
subscribeAccelerometer
({
interval
:
'
normal
'
,
success
:
function
(
data
)
{
success
:
function
(
data
)
{
console
.
info
(
"
subscribeAccelerometer_SensorJsTest012 success
"
+
JSON
.
stringify
(
data
));
expect
(
typeof
(
data
.
x
)).
assertEqual
(
"
number
"
);
expect
(
typeof
(
data
.
y
)).
assertEqual
(
"
number
"
);
expect
(
typeof
(
data
.
z
)).
assertEqual
(
"
number
"
);
expect
(
typeof
(
data
.
x
)).
assertEqual
(
"
number
"
);
expect
(
typeof
(
data
.
y
)).
assertEqual
(
"
number
"
);
expect
(
typeof
(
data
.
z
)).
assertEqual
(
"
number
"
);
done
();
},
});
...
...
@@ -395,19 +395,20 @@ describe("SensorJsTest", function () {
console
.
info
(
'
----------------------subscribeAccelerometer_SensorJsTest013---------------------------
'
);
sensor
.
subscribeAccelerometer
({
interval
:
'
normal
'
,
success
:
function
(
data
)
{
success
:
function
(
data
)
{
console
.
info
(
"
subscribeAccelerometer_SensorJsTest013 success
"
+
JSON
.
stringify
(
data
));
expect
(
typeof
(
data
.
x
)).
assertEqual
(
"
number
"
);
expect
(
typeof
(
data
.
y
)).
assertEqual
(
"
number
"
);
expect
(
typeof
(
data
.
z
)).
assertEqual
(
"
number
"
);
expect
(
typeof
(
data
.
x
)).
assertEqual
(
"
number
"
);
expect
(
typeof
(
data
.
y
)).
assertEqual
(
"
number
"
);
expect
(
typeof
(
data
.
z
)).
assertEqual
(
"
number
"
);
done
();
},
fail
:
function
(
data
,
code
)
{
fail
:
function
(
data
,
code
)
{
console
.
log
(
"
subscribeAccelerometer_SensorJsTest013 is failed, data:
"
+
data
+
"
, code:
"
+
code
);
expect
(
false
).
assertTrue
();
},
});
})
/*
* @tc.name:subscribeAccelerometer_SensorJsTest014
* @tc.desc:verify app info is not null
...
...
@@ -418,13 +419,13 @@ describe("SensorJsTest", function () {
console
.
info
(
'
----------------------subscribeAccelerometer_SensorJsTest014---------------------------
'
);
sensor
.
subscribeAccelerometer
({
interval
:
'
normal
'
,
success
:
function
(
data
)
{
success
:
function
(
data
)
{
console
.
info
(
"
subscribeAccelerometer_SensorJsTest014 success
"
+
JSON
.
stringify
(
data
));
expect
(
typeof
(
data
.
x
)).
assertEqual
(
"
number
"
);
expect
(
typeof
(
data
.
y
)).
assertEqual
(
"
number
"
);
expect
(
typeof
(
data
.
z
)).
assertEqual
(
"
number
"
);
expect
(
typeof
(
data
.
x
)).
assertEqual
(
"
number
"
);
expect
(
typeof
(
data
.
y
)).
assertEqual
(
"
number
"
);
expect
(
typeof
(
data
.
z
)).
assertEqual
(
"
number
"
);
},
fail
:
function
(
data
,
code
)
{
fail
:
function
(
data
,
code
)
{
console
.
log
(
"
subscribeAccelerometer_SensorJsTest014 is failed, data:
"
+
data
+
"
, code:
"
+
code
);
expect
(
false
).
assertTrue
();
},
...
...
@@ -436,10 +437,9 @@ describe("SensorJsTest", function () {
console
.
info
(
'
subscribeAccelerometer_SensorJsTest014_unsubscribeAccelerometer error
'
+
error
);
expect
(
true
).
assertTrue
();
}
setTimeout
(()
=>
{
setTimeout
(()
=>
{
expect
(
true
).
assertTrue
();
done
();
},
500
);
})
})
\ No newline at end of file
})
\ No newline at end of file
sensors/sensor_standard/src/main/js/default/test/subscribeGyroscope.js
浏览文件 @
cd1fa4e6
...
...
@@ -13,39 +13,42 @@
* limitations under the License.
*/
import
sensor
from
'
@system.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
()
{
beforeAll
(
function
()
{
beforeAll
(
function
()
{
/*
* @tc.setup: setup invoked before all testcases
*/
console
.
info
(
'
beforeAll caled
'
)
})
afterAll
(
function
()
{
afterAll
(
function
()
{
/*
* @tc.teardown: teardown invoked after all testcases
*/
console
.
info
(
'
afterAll caled
'
)
})
beforeEach
(
function
()
{
beforeEach
(
function
()
{
/*
* @tc.setup: setup invoked before each testcases
*/
console
.
info
(
'
beforeEach caled
'
)
})
afterEach
(
function
()
{
afterEach
(
function
()
{
/*
* @tc.teardown: teardown invoked after each testcases
*/
console
.
info
(
'
afterEach caled
'
)
})
var
errMessages
=
[
'
The number of parameters is not valid
'
,
'
Wrong argument type, should be object
'
,
'
UnsubscribeSensor failed
'
];
var
errMessages
=
[
'
The number of parameters is not valid
'
,
'
Wrong argument type, should be object
'
,
'
UnsubscribeSensor failed
'
];
/*
* @tc.name:subscribeGyroscope_SensorJsTest001
...
...
@@ -57,26 +60,26 @@ describe("SensorJsTest", function () {
console
.
info
(
'
----------------------subscribeGyroscope_SensorJsTest001---------------------------
'
);
sensor
.
subscribeGyroscope
({
interval
:
'
game
'
,
success
:
function
(
data
)
{
success
:
function
(
data
)
{
console
.
info
(
"
subscribeGyroscope_SensorJsTest001 success
"
+
JSON
.
stringify
(
data
));
expect
(
typeof
(
data
.
x
)).
assertEqual
(
"
number
"
);
expect
(
typeof
(
data
.
y
)).
assertEqual
(
"
number
"
);
expect
(
typeof
(
data
.
z
)).
assertEqual
(
"
number
"
);
expect
(
typeof
(
data
.
x
)).
assertEqual
(
"
number
"
);
expect
(
typeof
(
data
.
y
)).
assertEqual
(
"
number
"
);
expect
(
typeof
(
data
.
z
)).
assertEqual
(
"
number
"
);
},
fail
:
function
(
data
,
code
)
{
fail
:
function
(
data
,
code
)
{
console
.
log
(
"
subscribeGyroscope_SensorJsTest001 is failed, data:
"
+
data
+
"
, code:
"
+
code
);
expect
(
false
).
assertTrue
();
},
});
setTimeout
(()
=>
{
setTimeout
(()
=>
{
try
{
sensor
.
unsubscribeGyroscope
();
}
catch
(
error
)
{
console
.
info
(
'
subscribeGyroscope_SensorJsTest001_unsubscribeGyroscope error
'
+
error
);
expect
(
false
).
assertTrue
();
}
setTimeout
(()
=>
{
setTimeout
(()
=>
{
expect
(
true
).
assertTrue
();
done
();
},
500
);
...
...
@@ -93,26 +96,26 @@ describe("SensorJsTest", function () {
console
.
info
(
'
----------------------subscribeGyroscope_SensorJsTest002---------------------------
'
);
sensor
.
subscribeGyroscope
({
interval
:
'
ui
'
,
success
:
function
(
data
)
{
success
:
function
(
data
)
{
console
.
info
(
"
subscribeGyroscope_SensorJsTest002 success
"
+
JSON
.
stringify
(
data
));
expect
(
typeof
(
data
.
x
)).
assertEqual
(
"
number
"
);
expect
(
typeof
(
data
.
y
)).
assertEqual
(
"
number
"
);
expect
(
typeof
(
data
.
z
)).
assertEqual
(
"
number
"
);
expect
(
typeof
(
data
.
x
)).
assertEqual
(
"
number
"
);
expect
(
typeof
(
data
.
y
)).
assertEqual
(
"
number
"
);
expect
(
typeof
(
data
.
z
)).
assertEqual
(
"
number
"
);
},
fail
:
function
(
data
,
code
)
{
fail
:
function
(
data
,
code
)
{
console
.
log
(
"
subscribeGyroscope_SensorJsTest002 is failed, data:
"
+
data
+
"
, code:
"
+
code
);
expect
(
false
).
assertTrue
();
},
});
setTimeout
(()
=>
{
setTimeout
(()
=>
{
try
{
sensor
.
unsubscribeGyroscope
();
}
catch
(
error
)
{
console
.
info
(
'
subscribeGyroscope_SensorJsTest002_unsubscribeGyroscope error
'
+
error
);
expect
(
false
).
assertTrue
();
}
setTimeout
(()
=>
{
setTimeout
(()
=>
{
expect
(
true
).
assertTrue
();
done
();
},
500
);
...
...
@@ -129,26 +132,26 @@ describe("SensorJsTest", function () {
console
.
info
(
'
----------------------subscribeGyroscope_SensorJsTest003---------------------------
'
);
sensor
.
subscribeGyroscope
({
interval
:
'
normal
'
,
success
:
function
(
data
)
{
success
:
function
(
data
)
{
console
.
info
(
"
subscribeGyroscope_SensorJsTest003 success
"
+
JSON
.
stringify
(
data
));
expect
(
typeof
(
data
.
x
)).
assertEqual
(
"
number
"
);
expect
(
typeof
(
data
.
y
)).
assertEqual
(
"
number
"
);
expect
(
typeof
(
data
.
z
)).
assertEqual
(
"
number
"
);
expect
(
typeof
(
data
.
x
)).
assertEqual
(
"
number
"
);
expect
(
typeof
(
data
.
y
)).
assertEqual
(
"
number
"
);
expect
(
typeof
(
data
.
z
)).
assertEqual
(
"
number
"
);
},
fail
:
function
(
data
,
code
)
{
fail
:
function
(
data
,
code
)
{
console
.
log
(
"
subscribeGyroscope_SensorJsTest003 is failed, data:
"
+
data
+
"
, code:
"
+
code
);
expect
(
false
).
assertTrue
();
},
});
setTimeout
(()
=>
{
setTimeout
(()
=>
{
try
{
sensor
.
unsubscribeGyroscope
();
}
catch
(
error
)
{
console
.
info
(
'
subscribeGyroscope_SensorJsTest003_unsubscribeGyroscope error
'
+
error
);
expect
(
false
).
assertTrue
();
}
setTimeout
(()
=>
{
setTimeout
(()
=>
{
expect
(
true
).
assertTrue
();
done
();
},
500
);
...
...
@@ -165,13 +168,13 @@ describe("SensorJsTest", function () {
console
.
info
(
'
----------------------subscribeGyroscope_SensorJsTest004---------------------------
'
);
sensor
.
subscribeGyroscope
({
interval
:
'
xxx
'
,
success
:
function
(
data
)
{
success
:
function
(
data
)
{
console
.
info
(
"
subscribeGyroscope_SensorJsTest004 success
"
+
JSON
.
stringify
(
data
));
expect
(
typeof
(
data
.
x
)).
assertEqual
(
"
number
"
);
expect
(
typeof
(
data
.
y
)).
assertEqual
(
"
number
"
);
expect
(
typeof
(
data
.
z
)).
assertEqual
(
"
number
"
);
expect
(
typeof
(
data
.
x
)).
assertEqual
(
"
number
"
);
expect
(
typeof
(
data
.
y
)).
assertEqual
(
"
number
"
);
expect
(
typeof
(
data
.
z
)).
assertEqual
(
"
number
"
);
},
fail
:
function
(
data
,
code
)
{
fail
:
function
(
data
,
code
)
{
console
.
log
(
"
subscribeGyroscope_SensorJsTest004 is failed, data:
"
+
data
+
"
, code:
"
+
code
);
expect
(
code
).
assertEqual
(
202
);
done
();
...
...
@@ -189,14 +192,14 @@ describe("SensorJsTest", function () {
console
.
info
(
'
----------------------subscribeGyroscope_SensorJsTest005---------------------------
'
);
sensor
.
subscribeGyroscope
({
interval
:
'
normal
'
,
success
:
function
(
data
)
{
success
:
function
(
data
)
{
console
.
info
(
"
subscribeGyroscope_SensorJsTest005 success
"
+
JSON
.
stringify
(
data
));
expect
(
typeof
(
data
.
x
)).
assertEqual
(
"
number
"
);
expect
(
typeof
(
data
.
y
)).
assertEqual
(
"
number
"
);
expect
(
typeof
(
data
.
z
)).
assertEqual
(
"
number
"
);
expect
(
typeof
(
data
.
x
)).
assertEqual
(
"
number
"
);
expect
(
typeof
(
data
.
y
)).
assertEqual
(
"
number
"
);
expect
(
typeof
(
data
.
z
)).
assertEqual
(
"
number
"
);
done
();
},
fail
:
function
(
data
,
code
)
{
fail
:
function
(
data
,
code
)
{
console
.
log
(
"
subscribeGyroscope_SensorJsTest005 is failed, data:
"
+
data
+
"
, code:
"
+
code
);
expect
(
false
).
assertTrue
();
},
...
...
@@ -211,22 +214,22 @@ describe("SensorJsTest", function () {
*/
it
(
"
subscribeGyroscope_SensorJsTest006
"
,
0
,
async
function
(
done
)
{
console
.
info
(
'
----------------------subscribeGyroscope_SensorJsTest006---------------------------
'
);
try
{
try
{
sensor
.
subscribeGyroscope
({
interval
:
'
normal
'
,
success
:
function
(
data
)
{
success
:
function
(
data
)
{
console
.
info
(
"
subscribeGyroscope_SensorJsTest006 success
"
+
JSON
.
stringify
(
data
));
expect
(
typeof
(
data
.
x
)).
assertEqual
(
"
number
"
);
expect
(
typeof
(
data
.
y
)).
assertEqual
(
"
number
"
);
expect
(
typeof
(
data
.
z
)).
assertEqual
(
"
number
"
);
expect
(
typeof
(
data
.
x
)).
assertEqual
(
"
number
"
);
expect
(
typeof
(
data
.
y
)).
assertEqual
(
"
number
"
);
expect
(
typeof
(
data
.
z
)).
assertEqual
(
"
number
"
);
},
fail
:
function
(
data
,
code
)
{
fail
:
function
(
data
,
code
)
{
console
.
log
(
"
subscribeGyroscope_SensorJsTest006 is failed, data:
"
+
data
+
"
, code:
"
+
code
);
expect
(
false
).
assertTrue
();
},
},
25
);
},
25
);
}
catch
(
error
)
{
var
errMessage
=
error
.
toString
().
slice
(
19
,
56
);
var
errMessage
=
error
.
toString
().
slice
(
19
,
56
);
console
.
info
(
'
subscribeGyroscope_SensorJsTest006 error:
'
+
error
);
expect
(
errMessage
).
assertEqual
(
errMessages
[
0
]);
done
();
...
...
@@ -241,22 +244,23 @@ describe("SensorJsTest", function () {
*/
it
(
"
subscribeGyroscope_SensorJsTest007
"
,
0
,
async
function
(
done
)
{
console
.
info
(
'
----------------------subscribeGyroscope_SensorJsTest007---------------------------
'
);
try
{
try
{
sensor
.
subscribeGyroscope
({
interval
:
'
normal
'
,
success
:
function
(
data
)
{
success
:
function
(
data
)
{
console
.
info
(
"
subscribeGyroscope_SensorJsTest007 success
"
+
JSON
.
stringify
(
data
));
expect
(
typeof
(
data
.
x
)).
assertEqual
(
"
number
"
);
expect
(
typeof
(
data
.
y
)).
assertEqual
(
"
number
"
);
expect
(
typeof
(
data
.
z
)).
assertEqual
(
"
number
"
);
expect
(
typeof
(
data
.
x
)).
assertEqual
(
"
number
"
);
expect
(
typeof
(
data
.
y
)).
assertEqual
(
"
number
"
);
expect
(
typeof
(
data
.
z
)).
assertEqual
(
"
number
"
);
},
fail
:
function
(
data
,
code
)
{
fail
:
function
(
data
,
code
)
{
console
.
log
(
"
subscribeGyroscope_SensorJsTest007 is failed, data:
"
+
data
+
"
, code:
"
+
code
);
expect
(
false
).
assertTrue
();
},
},
function
(){},
25
);
},
function
()
{
},
25
);
}
catch
(
error
)
{
var
errMessage
=
error
.
toString
().
slice
(
19
,
56
);
var
errMessage
=
error
.
toString
().
slice
(
19
,
56
);
console
.
info
(
'
subscribeGyroscope_SensorJsTest007 error:
'
+
error
);
expect
(
errMessage
).
assertEqual
(
errMessages
[
0
]);
done
();
...
...
@@ -273,13 +277,13 @@ describe("SensorJsTest", function () {
console
.
info
(
'
----------------------subscribeGyroscope_SensorJsTest008---------------------------
'
);
sensor
.
subscribeGyroscope
({
interval
:
'
normal
'
,
success
:
function
(
data
)
{
success
:
function
(
data
)
{
console
.
info
(
"
subscribeGyroscope_SensorJsTest008 success
"
+
JSON
.
stringify
(
data
));
expect
(
typeof
(
data
.
x
)).
assertEqual
(
"
number
"
);
expect
(
typeof
(
data
.
y
)).
assertEqual
(
"
number
"
);
expect
(
typeof
(
data
.
z
)).
assertEqual
(
"
number
"
);
expect
(
typeof
(
data
.
x
)).
assertEqual
(
"
number
"
);
expect
(
typeof
(
data
.
y
)).
assertEqual
(
"
number
"
);
expect
(
typeof
(
data
.
z
)).
assertEqual
(
"
number
"
);
},
fail
:
function
(
data
,
code
)
{
fail
:
function
(
data
,
code
)
{
console
.
log
(
"
subscribeGyroscope_SensorJsTest008 is failed, data:
"
+
data
+
"
, code:
"
+
code
);
expect
(
false
).
assertTrue
();
},
...
...
@@ -287,26 +291,26 @@ describe("SensorJsTest", function () {
sensor
.
subscribeGyroscope
({
interval
:
'
normal
'
,
success
:
function
(
data
)
{
success
:
function
(
data
)
{
console
.
info
(
"
subscribeGyroscope_SensorJsTest008_1 success
"
+
JSON
.
stringify
(
data
));
expect
(
typeof
(
data
.
x
)).
assertEqual
(
"
number
"
);
expect
(
typeof
(
data
.
y
)).
assertEqual
(
"
number
"
);
expect
(
typeof
(
data
.
z
)).
assertEqual
(
"
number
"
);
expect
(
typeof
(
data
.
x
)).
assertEqual
(
"
number
"
);
expect
(
typeof
(
data
.
y
)).
assertEqual
(
"
number
"
);
expect
(
typeof
(
data
.
z
)).
assertEqual
(
"
number
"
);
},
fail
:
function
(
data
,
code
)
{
fail
:
function
(
data
,
code
)
{
console
.
log
(
"
subscribeGyroscope_SensorJsTest008_1 is failed, data:
"
+
data
+
"
, code:
"
+
code
);
expect
(
false
).
assertTrue
();
},
});
setTimeout
(()
=>
{
setTimeout
(()
=>
{
try
{
sensor
.
unsubscribeGyroscope
();
}
catch
(
error
)
{
console
.
info
(
'
subscribeGyroscope_SensorJsTest008_unsubscribeGyroscope error
'
+
error
);
expect
(
false
).
assertTrue
();
}
setTimeout
(()
=>
{
setTimeout
(()
=>
{
expect
(
true
).
assertTrue
();
done
();
},
500
);
...
...
@@ -321,15 +325,16 @@ describe("SensorJsTest", function () {
*/
it
(
"
subscribeGyroscope_SensorJsTest009
"
,
0
,
async
function
(
done
)
{
console
.
info
(
'
----------------------subscribeGyroscope_SensorJsTest009---------------------------
'
);
try
{
try
{
sensor
.
subscribeGyroscope
();
}
catch
(
error
)
{
var
errMessage
=
error
.
toString
().
slice
(
19
,
56
);
var
errMessage
=
error
.
toString
().
slice
(
19
,
56
);
console
.
info
(
'
subscribeGyroscope_SensorJsTest009 error:
'
+
error
);
expect
(
errMessage
).
assertEqual
(
errMessages
[
0
]);
done
();
}
})
/*
* @tc.name:subscribeGyroscope_SensorJsTest010
* @tc.desc:verify app info is not null
...
...
@@ -338,10 +343,10 @@ describe("SensorJsTest", function () {
*/
it
(
"
subscribeGyroscope_SensorJsTest010
"
,
0
,
async
function
(
done
)
{
console
.
info
(
'
----------------------subscribeGyroscope_SensorJsTest010---------------------------
'
);
try
{
try
{
sensor
.
subscribeGyroscope
(
'
xxx
'
);
}
catch
(
error
)
{
var
errMessage
=
error
.
toString
().
slice
(
19
,
56
);
var
errMessage
=
error
.
toString
().
slice
(
19
,
56
);
console
.
info
(
'
subscribeGyroscope_SensorJsTest010 error:
'
+
error
);
expect
(
errMessage
).
assertEqual
(
errMessages
[
1
]);
done
();
...
...
@@ -356,10 +361,10 @@ describe("SensorJsTest", function () {
*/
it
(
"
subscribeGyroscope_SensorJsTest011
"
,
0
,
async
function
(
done
)
{
console
.
info
(
'
----------------------subscribeGyroscope_SensorJsTest011---------------------------
'
);
try
{
try
{
sensor
.
unsubscribeGyroscope
();
}
catch
(
error
)
{
var
errMessage
=
error
.
toString
().
slice
(
21
,
45
);
var
errMessage
=
error
.
toString
().
slice
(
21
,
45
);
console
.
info
(
'
subscribeGyroscope_SensorJsTest011 error:
'
+
error
);
expect
(
errMessage
).
assertEqual
(
errMessages
[
2
]);
done
();
...
...
@@ -374,10 +379,10 @@ describe("SensorJsTest", function () {
*/
it
(
"
subscribeGyroscope_SensorJsTest012
"
,
0
,
async
function
(
done
)
{
console
.
info
(
'
----------------------subscribeGyroscope_SensorJsTest012---------------------------
'
);
try
{
try
{
sensor
.
unsubscribeGyroscope
(
'
xxx
'
);
}
catch
(
error
)
{
var
errMessage
=
error
.
toString
().
slice
(
21
,
58
);
var
errMessage
=
error
.
toString
().
slice
(
21
,
58
);
console
.
info
(
'
subscribeGyroscope_SensorJsTest012 error:
'
+
error
);
expect
(
errMessage
).
assertEqual
(
errMessages
[
0
]);
done
();
...
...
@@ -385,7 +390,6 @@ describe("SensorJsTest", function () {
})
/*
* @tc.name:/*
* @tc.name:subscribeGyroscope_SensorJsTest013
* @tc.desc:verify app info is not null
* @tc.type: FUNC
...
...
@@ -395,17 +399,17 @@ describe("SensorJsTest", function () {
console
.
info
(
'
----------------------subscribeGyroscope_SensorJsTest013---------------------------
'
);
sensor
.
subscribeGyroscope
({
interval
:
'
normal
'
,
success
:
function
(
data
)
{
success
:
function
(
data
)
{
console
.
info
(
"
subscribeGyroscope_SensorJsTest013 success
"
+
JSON
.
stringify
(
data
));
expect
(
typeof
(
data
.
x
)).
assertEqual
(
"
number
"
);
expect
(
typeof
(
data
.
y
)).
assertEqual
(
"
number
"
);
expect
(
typeof
(
data
.
z
)).
assertEqual
(
"
number
"
);
expect
(
typeof
(
data
.
x
)).
assertEqual
(
"
number
"
);
expect
(
typeof
(
data
.
y
)).
assertEqual
(
"
number
"
);
expect
(
typeof
(
data
.
z
)).
assertEqual
(
"
number
"
);
done
();
},
})
})
/*
* @tc.name:/*
* @tc.name:subscribeGyroscope_SensorJsTest014
* @tc.desc:verify app info is not null
* @tc.type: FUNC
...
...
@@ -415,14 +419,14 @@ describe("SensorJsTest", function () {
console
.
info
(
'
----------------------subscribeGyroscope_SensorJsTest014---------------------------
'
);
sensor
.
subscribeGyroscope
({
interval
:
'
normal
'
,
success
:
function
(
data
)
{
success
:
function
(
data
)
{
console
.
info
(
"
subscribeGyroscope_SensorJsTest014 success
"
+
JSON
.
stringify
(
data
));
expect
(
typeof
(
data
.
x
)).
assertEqual
(
"
number
"
);
expect
(
typeof
(
data
.
y
)).
assertEqual
(
"
number
"
);
expect
(
typeof
(
data
.
z
)).
assertEqual
(
"
number
"
);
expect
(
typeof
(
data
.
x
)).
assertEqual
(
"
number
"
);
expect
(
typeof
(
data
.
y
)).
assertEqual
(
"
number
"
);
expect
(
typeof
(
data
.
z
)).
assertEqual
(
"
number
"
);
done
();
},
fail
:
function
(
data
,
code
)
{
fail
:
function
(
data
,
code
)
{
console
.
log
(
"
subscribeGyroscope_SensorJsTest014 is failed, data:
"
+
data
+
"
, code:
"
+
code
);
expect
(
false
).
assertTrue
();
},
...
...
@@ -434,9 +438,9 @@ describe("SensorJsTest", function () {
console
.
info
(
'
subscribeAccelerometer_SensorJsTest014_unsubscribeAccelerometer error
'
+
error
);
expect
(
false
).
assertTrue
();
}
setTimeout
(()
=>
{
setTimeout
(()
=>
{
expect
(
true
).
assertTrue
();
done
();
},
500
);
})
})
\ No newline at end of file
})
\ No newline at end of file
sensors/sensor_standard/src/main/js/default/test/subscribeLight.js
浏览文件 @
cd1fa4e6
...
...
@@ -13,39 +13,42 @@
* limitations under the License.
*/
import
sensor
from
'
@system.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
()
{
beforeAll
(
function
()
{
beforeAll
(
function
()
{
/*
* @tc.setup: setup invoked before all testcases
*/
console
.
info
(
'
beforeAll caled
'
)
})
afterAll
(
function
()
{
afterAll
(
function
()
{
/*
* @tc.teardown: teardown invoked after all testcases
*/
console
.
info
(
'
afterAll caled
'
)
})
beforeEach
(
function
()
{
beforeEach
(
function
()
{
/*
* @tc.setup: setup invoked before each testcases
*/
console
.
info
(
'
beforeEach caled
'
)
})
afterEach
(
function
()
{
afterEach
(
function
()
{
/*
* @tc.teardown: teardown invoked after each testcases
*/
console
.
info
(
'
afterEach caled
'
)
})
var
errMessages
=
[
'
The number of parameters is not valid
'
,
'
UnsubscribeSensor failed
'
,
'
Wrong argument type, should be object
'
];
var
errMessages
=
[
'
The number of parameters is not valid
'
,
'
UnsubscribeSensor failed
'
,
'
Wrong argument type, should be object
'
];
/*
* @tc.name:subscribeLight_SensorJsTest001
...
...
@@ -54,25 +57,26 @@ describe("SensorJsTest", function () {
* @tc.require: SR000H0ALK, AR000H0ALM
*/
it
(
"
subscribeLight_SensorJsTest001
"
,
0
,
function
(
done
)
{
console
.
info
(
'
----------------------subscribeLight_SensorJsTest001---------------------------
'
);
sensor
.
subscribeLight
({
success
:
function
(
data
)
{
success
:
function
(
data
)
{
console
.
info
(
"
subscribeLight_SensorJsTest001 success:
"
+
JSON
.
stringify
(
data
));
expect
(
typeof
(
data
.
intensity
)).
assertEqual
(
"
number
"
);
expect
(
typeof
(
data
.
intensity
)).
assertEqual
(
"
number
"
);
},
fail
:
function
(
data
,
code
)
{
fail
:
function
(
data
,
code
)
{
console
.
error
(
'
subscribeLight_SensorJsTest001 failed. Code:
'
+
code
+
'
; Data:
'
+
data
);
expect
(
false
).
assertTrue
();
},
});
setTimeout
(()
=>
{
setTimeout
(()
=>
{
try
{
sensor
.
unsubscribeLight
();
}
catch
(
error
)
{
console
.
info
(
'
subscribeLight_SensorJsTest001_unsubscribeLight error
'
+
error
);
expect
(
false
).
assertTrue
();
}
setTimeout
(()
=>
{
setTimeout
(()
=>
{
expect
(
true
).
assertTrue
();
done
();
},
500
);
...
...
@@ -86,19 +90,20 @@ describe("SensorJsTest", function () {
* @tc.require: SR000H0ALK, AR000H0ALM
*/
it
(
"
subscribeLight_SensorJsTest002
"
,
0
,
function
(
done
)
{
try
{
console
.
info
(
'
----------------------subscribeLight_SensorJsTest002---------------------------
'
);
try
{
sensor
.
subscribeLight
({
success
:
function
(
data
)
{
success
:
function
(
data
)
{
console
.
info
(
"
subscribeLight_SensorJsTest002 success:
"
+
JSON
.
stringify
(
data
));
expect
(
typeof
(
data
.
intensity
)).
assertEqual
(
"
number
"
);
expect
(
typeof
(
data
.
intensity
)).
assertEqual
(
"
number
"
);
},
fail
:
function
(
data
,
code
)
{
fail
:
function
(
data
,
code
)
{
console
.
error
(
'
subscribeLight_SensorJsTest002 failed. Code:
'
+
code
+
'
; Data:
'
+
data
);
expect
(
false
).
assertTrue
();
},
},
25
);
},
25
);
}
catch
(
error
)
{
var
errMessage
=
error
.
toString
().
slice
(
19
,
56
);
var
errMessage
=
error
.
toString
().
slice
(
19
,
56
);
console
.
info
(
'
subscribeLight_SensorJsTest002 error:
'
+
error
);
expect
(
errMessage
).
assertEqual
(
errMessages
[
0
]);
done
();
...
...
@@ -112,21 +117,22 @@ describe("SensorJsTest", function () {
* @tc.require: SR000H0ALK, AR000H0ALM
*/
it
(
"
subscribeLight_SensorJsTest003
"
,
0
,
function
(
done
)
{
console
.
info
(
'
----------------------subscribeLight_SensorJsTest003---------------------------
'
);
sensor
.
subscribeLight
({
success
:
function
(
data
)
{
success
:
function
(
data
)
{
console
.
info
(
"
subscribeLight_SensorJsTest003 success:
"
+
JSON
.
stringify
(
data
));
expect
(
typeof
(
data
.
intensity
)).
assertEqual
(
"
number
"
);
expect
(
typeof
(
data
.
intensity
)).
assertEqual
(
"
number
"
);
},
});
setTimeout
(()
=>
{
setTimeout
(()
=>
{
try
{
sensor
.
unsubscribeLight
();
}
catch
(
error
)
{
console
.
info
(
'
subscribeLight_SensorJsTest003_unsubscribeLight error
'
+
error
);
expect
(
false
).
assertTrue
();
}
setTimeout
(()
=>
{
setTimeout
(()
=>
{
expect
(
true
).
assertTrue
();
done
();
},
500
);
...
...
@@ -140,19 +146,21 @@ describe("SensorJsTest", function () {
* @tc.require: SR000H0ALK, AR000H0ALM
*/
it
(
"
subscribeLight_SensorJsTest004
"
,
0
,
function
(
done
)
{
try
{
console
.
info
(
'
----------------------subscribeLight_SensorJsTest004---------------------------
'
);
try
{
sensor
.
subscribeLight
({
success
:
function
(
data
)
{
success
:
function
(
data
)
{
console
.
info
(
"
subscribeLight_SensorJsTest004 success:
"
+
JSON
.
stringify
(
data
));
expect
(
typeof
(
data
.
intensity
)).
assertEqual
(
"
number
"
);
expect
(
typeof
(
data
.
intensity
)).
assertEqual
(
"
number
"
);
},
fail
:
function
(
data
,
code
)
{
fail
:
function
(
data
,
code
)
{
console
.
error
(
'
subscribeLight_SensorJsTest004 failed. Code:
'
+
code
+
'
; Data:
'
+
data
);
expect
(
false
).
assertTrue
();
},
},
function
(){},
25
);
},
function
()
{
},
25
);
}
catch
(
error
)
{
var
errMessage
=
error
.
toString
().
slice
(
19
,
56
);
var
errMessage
=
error
.
toString
().
slice
(
19
,
56
);
console
.
info
(
'
subscribeLight_SensorJsTest004 error:
'
+
error
);
expect
(
errMessage
).
assertEqual
(
errMessages
[
0
]);
done
();
...
...
@@ -167,10 +175,10 @@ describe("SensorJsTest", function () {
*/
it
(
"
subscribeLight_SensorJsTest005
"
,
0
,
async
function
(
done
)
{
console
.
info
(
'
----------------------subscribeLight_SensorJsTest005---------------------------
'
);
try
{
try
{
sensor
.
unsubscribeLight
(
'
xxx
'
);
}
catch
(
error
)
{
var
errMessage
=
error
.
toString
().
slice
(
21
,
58
);
var
errMessage
=
error
.
toString
().
slice
(
21
,
58
);
console
.
info
(
'
subscribeLight_SensorJsTest005 error:
'
+
error
);
expect
(
errMessage
).
assertEqual
(
errMessages
[
0
]);
done
();
...
...
@@ -185,10 +193,10 @@ describe("SensorJsTest", function () {
*/
it
(
"
subscribeLight_SensorJsTest006
"
,
0
,
async
function
(
done
)
{
console
.
info
(
'
----------------------subscribeLight_SensorJsTest006---------------------------
'
);
try
{
try
{
sensor
.
subscribeLight
();
}
catch
(
error
)
{
var
errMessage
=
error
.
toString
().
slice
(
19
,
56
);
var
errMessage
=
error
.
toString
().
slice
(
19
,
56
);
console
.
info
(
'
subscribeLight_SensorJsTest006 error:
'
+
error
);
expect
(
errMessage
).
assertEqual
(
errMessages
[
0
]);
done
();
...
...
@@ -203,10 +211,10 @@ describe("SensorJsTest", function () {
*/
it
(
"
subscribeLight_SensorJsTest007
"
,
0
,
async
function
(
done
)
{
console
.
info
(
'
----------------------subscribeLight_SensorJsTest007---------------------------
'
);
try
{
try
{
sensor
.
subscribeLight
(
'
xxx
'
);
}
catch
(
error
)
{
var
errMessage
=
error
.
toString
().
slice
(
19
,
56
);
var
errMessage
=
error
.
toString
().
slice
(
19
,
56
);
console
.
info
(
'
subscribeLight_SensorJsTest007 error:
'
+
error
);
expect
(
errMessage
).
assertEqual
(
errMessages
[
2
]);
done
();
...
...
@@ -220,35 +228,36 @@ describe("SensorJsTest", function () {
* @tc.require: SR000H0ALK, AR000H0ALM
*/
it
(
"
subscribeLight_SensorJsTest008
"
,
0
,
function
(
done
)
{
console
.
info
(
'
----------------------subscribeLight_SensorJsTest008---------------------------
'
);
sensor
.
subscribeLight
({
success
:
function
(
data
)
{
success
:
function
(
data
)
{
console
.
info
(
"
subscribeLight_SensorJsTest008 success:
"
+
JSON
.
stringify
(
data
));
expect
(
typeof
(
data
.
intensity
)).
assertEqual
(
"
number
"
);
expect
(
typeof
(
data
.
intensity
)).
assertEqual
(
"
number
"
);
},
fail
:
function
(
data
,
code
)
{
fail
:
function
(
data
,
code
)
{
console
.
error
(
'
subscribeLight_SensorJsTest008 failed. Code:
'
+
code
+
'
; Data:
'
+
data
);
expect
(
false
).
assertTrue
();
},
});
sensor
.
subscribeLight
({
success
:
function
(
data
)
{
success
:
function
(
data
)
{
console
.
info
(
"
subscribeLight_SensorJsTest008_1 success:
"
+
JSON
.
stringify
(
data
));
expect
(
typeof
(
data
.
intensity
)).
assertEqual
(
"
number
"
);
expect
(
typeof
(
data
.
intensity
)).
assertEqual
(
"
number
"
);
},
fail
:
function
(
data
,
code
)
{
fail
:
function
(
data
,
code
)
{
console
.
error
(
'
subscribeLight_SensorJsTest008_1 failed. Code:
'
+
code
+
'
; Data:
'
+
data
);
expect
(
false
).
assertTrue
();
},
});
setTimeout
(()
=>
{
setTimeout
(()
=>
{
try
{
sensor
.
unsubscribeLight
();
}
catch
(
error
)
{
console
.
info
(
'
subscribeLight_SensorJsTest008_unsubscribeLight error
'
+
error
);
expect
(
false
).
assertTrue
();
}
setTimeout
(()
=>
{
setTimeout
(()
=>
{
expect
(
true
).
assertTrue
();
done
();
},
500
);
...
...
@@ -263,7 +272,7 @@ describe("SensorJsTest", function () {
*/
it
(
"
subscribeLight_SensorJsTest009
"
,
0
,
async
function
(
done
)
{
console
.
info
(
'
----------------------subscribeLight_SensorJsTest009---------------------------
'
);
try
{
try
{
sensor
.
unsubscribeLight
();
}
catch
(
error
)
{
var
errMessage
=
error
.
toString
().
slice
(
21
,
45
);
...
...
@@ -280,12 +289,13 @@ describe("SensorJsTest", function () {
* @tc.require: SR000H0ALK, AR000H0ALM
*/
it
(
"
subscribeLight_SensorJsTest010
"
,
0
,
function
(
done
)
{
console
.
info
(
'
----------------------subscribeLight_SensorJsTest010---------------------------
'
);
sensor
.
subscribeLight
({
success
:
function
(
data
)
{
success
:
function
(
data
)
{
console
.
info
(
"
subscribeLight_SensorJsTest010 success:
"
+
JSON
.
stringify
(
data
));
expect
(
typeof
(
data
.
intensity
)).
assertEqual
(
"
number
"
);
expect
(
typeof
(
data
.
intensity
)).
assertEqual
(
"
number
"
);
},
fail
:
function
(
data
,
code
)
{
fail
:
function
(
data
,
code
)
{
console
.
error
(
'
subscribeLight_SensorJsTest010 failed. Code:
'
+
code
+
'
; Data:
'
+
data
);
expect
(
false
).
assertTrue
();
},
...
...
@@ -297,11 +307,11 @@ describe("SensorJsTest", function () {
console
.
info
(
'
subscribeLight_SensorJsTest008_unsubscribeLight error
'
+
error
);
expect
(
true
).
assertTrue
();
}
setTimeout
(()
=>
{
setTimeout
(()
=>
{
expect
(
true
).
assertTrue
();
done
();
},
500
);
})
})
})
\ No newline at end of file
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录