Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
OpenHarmony
Xts Acts
提交
8c829e6e
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,发现更多精彩内容 >>
未验证
提交
8c829e6e
编写于
5月 18, 2022
作者:
O
openharmony_ci
提交者:
Gitee
5月 18, 2022
浏览文件
操作
浏览文件
下载
差异文件
!3202 【Sensor】【Release】 SensorOnOffTest.test.js用例修改,新增加速剂,陀螺仪,马达,light用例。
Merge pull request !3202 from ldy/OpenHarmony-3.1-Release
上级
4d0b518c
e4239577
变更
5
隐藏空白更改
内联
并排
Showing
5 changed file
with
1564 addition
and
17 deletion
+1564
-17
sensors/miscdevice_standard/src/main/js/default/test/vibrate.js
...s/miscdevice_standard/src/main/js/default/test/vibrate.js
+313
-0
sensors/sensor_standard/src/main/js/default/test/SensorOnOffTest.test.js
...standard/src/main/js/default/test/SensorOnOffTest.test.js
+40
-17
sensors/sensor_standard/src/main/js/default/test/subscribeAccelerometer.js
...andard/src/main/js/default/test/subscribeAccelerometer.js
+446
-0
sensors/sensor_standard/src/main/js/default/test/subscribeGyroscope.js
...r_standard/src/main/js/default/test/subscribeGyroscope.js
+447
-0
sensors/sensor_standard/src/main/js/default/test/subscribeLight.js
...ensor_standard/src/main/js/default/test/subscribeLight.js
+318
-0
未找到文件。
sensors/miscdevice_standard/src/main/js/default/test/vibrate.js
0 → 100644
浏览文件 @
8c829e6e
/*
* 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
vibrator
from
'
@system.vibrator
'
;
import
{
describe
,
beforeAll
,
beforeEach
,
afterEach
,
afterAll
,
it
,
expect
}
from
'
deccjsunit/index
'
describe
(
"
VibratorJsTest
"
,
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
'
)
})
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
* @tc.type: FUNC
* @tc.require: SR000H0ALK, AR000H0ALM
*/
it
(
"
VibratorJsTest0001
"
,
0
,
async
function
(
done
)
{
console
.
info
(
'
----------------------VibratorJsTest0001---------------------------
'
);
vibrator
.
vibrate
({
mode
:
'
long
'
,
success
:
function
()
{
console
.
info
(
"
VibratorJsTest0001 success
"
);
expect
(
true
).
assertTrue
();
done
();
},
fail
:
function
(
data
,
code
)
{
console
.
log
(
"
VibratorJsTest0001 is failed, data:
"
+
data
+
"
, code:
"
+
code
);
expect
(
false
).
assertTrue
();
},
complete
:
function
()
{
console
.
log
(
'
VibratorJsTest0001 is completed
'
);
}
});
})
/*
* @tc.name:VibratorJsTest0002
* @tc.desc:verify app info is not null
* @tc.type: FUNC
* @tc.require: SR000H0ALK, AR000H0ALM
*/
it
(
"
VibratorJsTest0002
"
,
0
,
async
function
(
done
)
{
console
.
info
(
'
----------------------VibratorJsTest0002---------------------------
'
);
vibrator
.
vibrate
({
mode
:
'
short
'
,
success
:
function
()
{
console
.
info
(
"
VibratorJsTest0002 success
"
);
expect
(
true
).
assertTrue
();
done
();
},
fail
:
function
(
data
,
code
)
{
console
.
log
(
"
VibratorJsTest0002 is failed, data:
"
+
data
+
"
, code:
"
+
code
);
expect
(
false
).
assertTrue
();
},
complete
:
function
()
{
console
.
log
(
'
VibratorJsTest0002 is completed
'
);
}
});
})
/*
* @tc.name:VibratorJsTest0003
* @tc.desc:verify app info is not null
* @tc.type: FUNC
* @tc.require: SR000H0ALK, AR000H0ALM
*/
it
(
"
VibratorJsTest0003
"
,
0
,
async
function
(
done
)
{
console
.
info
(
'
----------------------VibratorJsTest0003---------------------------
'
);
vibrator
.
vibrate
({
mode
:
'
short
'
,
success
:
function
()
{
console
.
info
(
"
VibratorJsTest0003 success
"
);
expect
(
true
).
assertTrue
();
done
();
},
fail
:
function
(
data
,
code
)
{
console
.
error
(
'
VibratorJsTest0003 failed. Code:
'
+
code
+
'
; Data:
'
+
data
);
expect
(
false
).
assertTrue
();
},
});
})
/*
* @tc.name:VibratorJsTest0004
* @tc.desc:verify app info is not null
* @tc.type: FUNC
* @tc.require: SR000H0ALK, AR000H0ALM
*/
it
(
"
VibratorJsTest0004
"
,
0
,
async
function
(
done
)
{
console
.
info
(
'
----------------------VibratorJsTest0004---------------------------
'
);
vibrator
.
vibrate
({
mode
:
'
short
'
,
success
:
function
()
{
console
.
info
(
"
VibratorJsTest0004 success
"
);
expect
(
true
).
assertTrue
();
done
();
},
});
})
/*
* @tc.name:VibratorJsTest0005
* @tc.desc:verify app info is not null
* @tc.type: FUNC
* @tc.require: SR000H0ALK, AR000H0ALM
*/
it
(
"
VibratorJsTest0005
"
,
0
,
async
function
(
done
)
{
console
.
info
(
'
----------------------VibratorJsTest0005---------------------------
'
);
vibrator
.
vibrate
({
success
:
function
()
{
console
.
info
(
"
VibratorJsTest0005 success
"
);
expect
(
true
).
assertTrue
();
done
();
},
fail
:
function
(
data
,
code
)
{
console
.
error
(
'
VibratorJsTest0005 failed. Code:
'
+
code
+
'
; Data:
'
+
data
);
expect
(
false
).
assertTrue
();
},
});
})
/*
* @tc.name:VibratorJsTest0006
* @tc.desc:verify app info is not null
* @tc.type: FUNC
* @tc.require: SR000H0ALK, AR000H0ALM
*/
it
(
"
VibratorJsTest0006
"
,
0
,
async
function
(
done
)
{
console
.
info
(
'
----------------------VibratorJsTest0006---------------------------
'
);
vibrator
.
vibrate
({
mode
:
'
long
'
,
inInvalid
:
2
,
success
:
function
()
{
console
.
info
(
"
VibratorJsTest0006 success
"
);
expect
(
true
).
assertTrue
();
done
();
},
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
* @tc.type: FUNC
* @tc.require: SR000H0ALK, AR000H0ALM
*/
it
(
"
VibratorJsTest0007
"
,
0
,
async
function
(
done
)
{
console
.
info
(
'
----------------------VibratorJsTest0007---------------------------
'
);
try
{
vibrator
.
vibrate
({
mode
:
'
short
'
,
success
:
function
()
{
console
.
info
(
"
VibratorJsTest0007 success
"
);
expect
(
false
).
assertTrue
();
done
();
},
},
25
);
}
catch
(
error
)
{
var
errMessage
=
error
.
toString
().
slice
(
39
);
console
.
info
(
'
VibratorJsTest0007 error:
'
+
error
);
expect
(
errMessage
).
assertEqual
(
errMessages
[
0
]);
done
();
}
})
/*
* @tc.name:VibratorJsTest0008
* @tc.desc:verify app info is not null
* @tc.type: FUNC
* @tc.require: SR000H0ALK, AR000H0ALM
*/
it
(
"
VibratorJsTest0008
"
,
0
,
async
function
(
done
)
{
console
.
info
(
'
----------------------VibratorJsTest0008---------------------------
'
);
vibrator
.
vibrate
({
mode
:
'
short
'
,
success
:
function
()
{
console
.
info
(
"
VibratorJsTest0008 success
"
);
expect
(
true
).
assertTrue
();
},
fail
:
function
(
data
,
code
)
{
console
.
error
(
'
VibratorJsTest0008 failed. Code:
'
+
code
+
'
; Data:
'
+
data
);
expect
(
false
).
assertTrue
();
},
});
vibrator
.
vibrate
({
mode
:
'
short
'
,
success
:
function
()
{
console
.
info
(
"
VibratorJsTest0008_1 success
"
);
expect
(
true
).
assertTrue
();
},
fail
:
function
(
data
,
code
)
{
console
.
error
(
'
VibratorJsTest0008_1 failed. Code:
'
+
code
+
'
; Data:
'
+
data
);
expect
(
false
).
assertTrue
();
},
});
setTimeout
(()
=>
{
done
();
},
500
);
})
/*
* @tc.name:VibratorJsTest0009
* @tc.desc:verify app info is not null
* @tc.type: FUNC
* @tc.require: SR000H0ALK, AR000H0ALM
*/
it
(
"
VibratorJsTest0009
"
,
0
,
async
function
(
done
)
{
console
.
info
(
'
----------------------VibratorJsTest0009---------------------------
'
);
try
{
vibrator
.
vibrate
(
'
xxx
'
,
done
);
}
catch
(
error
)
{
console
.
info
(
'
VibratorJsTest0009 error:
'
+
error
);
var
errMessage
=
error
.
toString
().
slice
(
68
);
expect
(
errMessage
).
assertEqual
(
errMessages
[
1
]);
done
();
}
})
/*
* @tc.name:VibratorJsTest0010
* @tc.desc:verify app info is not null
* @tc.type: FUNC
* @tc.require: SR000H0ALK, AR000H0ALM
*/
it
(
"
VibratorJsTest0010
"
,
0
,
async
function
(
done
)
{
console
.
info
(
'
----------------------VibratorJsTest0010---------------------------
'
);
try
{
vibrator
.
vibrate
(
done
);
}
catch
(
error
)
{
var
errMessage
=
error
.
toString
().
slice
(
7
);
console
.
info
(
'
VibratorJsTest0010 error:
'
+
error
);
expect
(
errMessage
).
assertEqual
(
errMessages
[
2
]);
done
();
}
})
/*
* @tc.name:VibratorJsTest0011
* @tc.desc:verify app info is not null
* @tc.type: FUNC
* @tc.require: SR000H0ALK, AR000H0ALM
*/
it
(
"
VibratorJsTest0011
"
,
0
,
async
function
(
done
)
{
console
.
info
(
'
----------------------VibratorJsTest0011---------------------------
'
);
try
{
vibrator
.
vibrate
({
mode
:
'
short
'
,
success
:
function
()
{
console
.
info
(
"
VibratorJsTest0011 success
"
);
expect
(
false
).
assertTrue
();
done
();
},
},
function
()
{
},
25
);
}
catch
(
error
)
{
var
errMessage
=
error
.
toString
().
slice
(
39
);
console
.
info
(
'
VibratorJsTest0011 error:
'
+
error
);
expect
(
errMessage
).
assertEqual
(
errMessages
[
3
]);
done
();
}
})
})
\ No newline at end of file
sensors/sensor_standard/src/main/js/default/test/SensorOnOffTest.test.js
100755 → 100644
浏览文件 @
8c829e6e
...
...
@@ -31,32 +31,50 @@ function sleep(NumberMillis) {
describe
(
'
SystemParameterTest
'
,
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
'
)
})
var
testSensorId
=
0
;
var
testNullSensorId
=
-
1
;
let
testSensorId
=
0
;
let
testNullSensorId
=
-
1
;
/**
/**
* @tc.number SUB_SENSORS_Sensor_JSTest_0010
* @tc.name testRegisterSensortest001
* @tc.desc test get sensor data by sensor id.
*/
it
(
'
SUB_SENSORS_Sensor_JSTest_0010
'
,
0
,
async
function
(
done
)
{
console
.
info
(
'
SUB_SENSORS_Sensor_JSTest_0010 start
'
);
await
sensor
.
on
(
testSensorId
,
function
(
data
)
{
try
{
sensor
.
on
(
testSensorId
,
function
(
data
)
{
if
(
data
)
{
console
.
info
(
'
testRegisterSensortest001 on success
'
);
expect
(
data
.
x
).
assertInstanceOf
(
'
Number
'
);
...
...
@@ -68,28 +86,33 @@ describe('SystemParameterTest', function () {
done
();
}
});
}
catch
(
error
)
{
console
.
info
(
error
);
expect
(
true
).
assertTrue
();
done
();
}
console
.
info
(
'
SUB_SENSORS_Sensor_JSTest_0010 end
'
);
})
/**
/**
* @tc.number SUB_SENSORS_Sensor_JSTest_0020
* @tc.name testRegisterSensortest002
* @tc.desc test get sensor data by wrong sensor id.
*/
it
(
'
SUB_SENSORS_Sensor_JSTest_0020
'
,
0
,
async
function
(
done
)
{
console
.
info
(
'
SUB_SENSORS_Sensor_JSTest_0020 start
'
);
await
sensor
.
on
(
testNullSensorId
,
function
(
data
)
{
if
(
data
)
{
console
.
info
(
'
testRegisterSensortest002 on success
'
);
expect
(
false
).
assertTrue
();
done
();
}
});
setTimeout
(()
=>
{
function
onSensorCallback
(
data
)
{
console
.
info
(
'
SensorJsTest002 on error
'
);
expect
(
false
).
assertTrue
();
done
();
}
try
{
sensor
.
on
(
testNullSensorId
,
onSensorCallback
);
}
catch
(
error
)
{
console
.
info
(
error
);
expect
(
true
).
assertTrue
();
done
();
}
,
500
)
console
.
info
(
'
SUB_SENSORS_Sensor_JSTest_0020 end
'
);
}
console
.
info
(
'
SUB_SENSORS_Sensor_JSTest_0020 end
'
);
})
})
\ No newline at end of file
sensors/sensor_standard/src/main/js/default/test/subscribeAccelerometer.js
0 → 100644
浏览文件 @
8c829e6e
/*
* 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
'
@system.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
'
)
})
var
errMessages
=
[
'
The number of parameters is not valid
'
,
'
Wrong argument type,
should be object
'
,
'
UnsubscribeSensor failed
'
];
/*
* @tc.name:subscribeAccelerometer_SensorJsTest001
* @tc.desc:verify app info is not null
* @tc.type: FUNC
* @tc.require: SR000H0ALK, AR000H0ALM
*/
it
(
"
subscribeAccelerometer_SensorJsTest001
"
,
0
,
async
function
(
done
)
{
console
.
info
(
'
----------------------subscribeAccelerometer_SensorJsTest001---------------------------
'
);
sensor
.
subscribeAccelerometer
({
interval
:
'
game
'
,
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
"
);
},
fail
:
function
(
data
,
code
)
{
console
.
log
(
"
subscribeAccelerometer_SensorJsTest001 is failed, data:
"
+
data
+
"
, code:
"
+
code
);
expect
(
false
).
assertTrue
();
},
});
setTimeout
(()
=>
{
try
{
sensor
.
unsubscribeAccelerometer
();
}
catch
(
error
)
{
console
.
info
(
'
subscribeAccelerometer_SensorJsTest001_unsubscribeAccelerometer error
'
+
error
);
expect
(
false
).
assertTrue
();
}
setTimeout
(()
=>
{
expect
(
true
).
assertTrue
();
done
();
},
500
);
},
1000
);
})
/*
* @tc.name:subscribeAccelerometer_SensorJsTest002
* @tc.desc:verify app info is not null
* @tc.type: FUNC
* @tc.require: SR000H0ALK, AR000H0ALM
*/
it
(
"
subscribeAccelerometer_SensorJsTest002
"
,
0
,
async
function
(
done
)
{
console
.
info
(
'
----------------------subscribeAccelerometer_SensorJsTest002---------------------------
'
);
sensor
.
subscribeAccelerometer
({
interval
:
'
ui
'
,
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
"
);
},
fail
:
function
(
data
,
code
)
{
console
.
log
(
"
subscribeAccelerometer_SensorJsTest002 is failed, data:
"
+
data
+
"
, code:
"
+
code
);
expect
(
false
).
assertTrue
();
},
});
setTimeout
(()
=>
{
try
{
sensor
.
unsubscribeAccelerometer
();
}
catch
(
error
)
{
console
.
info
(
'
subscribeAccelerometer_SensorJsTest002_unsubscribeAccelerometer error
'
+
error
);
expect
(
false
).
assertTrue
();
}
setTimeout
(()
=>
{
expect
(
true
).
assertTrue
();
done
();
},
500
);
},
1000
);
})
/*
* @tc.name:subscribeAccelerometer_SensorJsTest003
* @tc.desc:verify app info is not null
* @tc.type: FUNC
* @tc.require: SR000H0ALK, AR000H0ALM
*/
it
(
"
subscribeAccelerometer_SensorJsTest003
"
,
0
,
async
function
(
done
)
{
console
.
info
(
'
----------------------subscribeAccelerometer_SensorJsTest003---------------------------
'
);
sensor
.
subscribeAccelerometer
({
interval
:
'
normal
'
,
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
"
);
},
fail
:
function
(
data
,
code
)
{
console
.
log
(
"
subscribeAccelerometer_SensorJsTest003 is failed, data:
"
+
data
+
"
, code:
"
+
code
);
expect
(
false
).
assertTrue
();
},
});
setTimeout
(()
=>
{
try
{
sensor
.
unsubscribeAccelerometer
();
}
catch
(
error
)
{
console
.
info
(
'
subscribeAccelerometer_SensorJsTest003_unsubscribeAccelerometer error
'
+
error
);
expect
(
false
).
assertTrue
();
}
setTimeout
(()
=>
{
expect
(
true
).
assertTrue
();
done
();
},
500
);
},
1000
);
})
/*
* @tc.name:subscribeAccelerometer_SensorJsTest004
* @tc.desc:verify app info is not null
* @tc.type: FUNC
* @tc.require: SR000H0ALK, AR000H0ALM
*/
it
(
"
subscribeAccelerometer_SensorJsTest004
"
,
0
,
async
function
(
done
)
{
console
.
info
(
'
----------------------subscribeAccelerometer_SensorJsTest004---------------------------
'
);
try
{
sensor
.
subscribeAccelerometer
({
interval
:
'
normal
'
,
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
"
);
},
fail
:
function
(
data
,
code
)
{
console
.
log
(
"
subscribeAccelerometer_SensorJsTest004 is failed, data:
"
+
data
+
"
, code:
"
+
code
);
expect
(
false
).
assertTrue
();
},
},
25
);
}
catch
(
error
)
{
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
* @tc.type: FUNC
* @tc.require: SR000H0ALK, AR000H0ALM
*/
it
(
"
subscribeAccelerometer_SensorJsTest005
"
,
0
,
async
function
(
done
)
{
console
.
info
(
'
----------------------subscribeAccelerometer_SensorJsTest005---------------------------
'
);
try
{
sensor
.
subscribeAccelerometer
({
interval
:
'
normal
'
,
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
"
);
},
fail
:
function
(
data
,
code
)
{
console
.
log
(
"
subscribeAccelerometer_SensorJsTest005 is failed, data:
"
+
data
+
"
, code:
"
+
code
);
expect
(
false
).
assertTrue
();
},
},
function
()
{
},
25
);
}
catch
(
error
)
{
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
* @tc.type: FUNC
* @tc.require: SR000H0ALK, AR000H0ALM
*/
it
(
"
subscribeAccelerometer_SensorJsTest006
"
,
0
,
async
function
(
done
)
{
console
.
info
(
'
----------------------subscribeAccelerometer_SensorJsTest006---------------------------
'
);
sensor
.
subscribeAccelerometer
({
interval
:
'
normal
'
,
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
"
);
},
fail
:
function
(
data
,
code
)
{
console
.
log
(
"
subscribeAccelerometer_SensorJsTest006 is failed, data:
"
+
data
+
"
, code:
"
+
code
);
expect
(
false
).
assertTrue
();
},
});
sensor
.
subscribeAccelerometer
({
interval
:
'
normal
'
,
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
"
);
},
fail
:
function
(
data
,
code
)
{
console
.
log
(
"
subscribeAccelerometer_SensorJsTest006_1 is failed, data:
"
+
data
+
"
, code:
"
+
code
);
expect
(
false
).
assertTrue
();
},
});
setTimeout
(()
=>
{
try
{
sensor
.
unsubscribeAccelerometer
();
}
catch
(
error
)
{
console
.
info
(
'
subscribeAccelerometer_SensorJsTest006_unsubscribeAccelerometer error
'
+
error
);
expect
(
false
).
assertTrue
();
}
setTimeout
(()
=>
{
expect
(
true
).
assertTrue
();
done
();
},
500
);
},
1000
);
})
/*
* @tc.name:subscribeAccelerometer_SensorJsTest007
* @tc.desc:verify app info is not null
* @tc.type: FUNC
* @tc.require: SR000H0ALK, AR000H0ALM
*/
it
(
"
subscribeAccelerometer_SensorJsTest007
"
,
0
,
async
function
(
done
)
{
console
.
info
(
'
----------------------subscribeAccelerometer_SensorJsTest007---------------------------
'
);
try
{
sensor
.
subscribeAccelerometer
();
}
catch
(
error
)
{
var
errMessage
=
error
.
toString
().
slice
(
19
,
56
);
console
.
info
(
'
subscribeAccelerometer_SensorJsTest007 error:
'
+
error
);
expect
(
errMessage
).
assertEqual
(
errMessages
[
0
]);
done
();
}
})
/*
* @tc.name:subscribeAccelerometer_SensorJsTest008
* @tc.desc:verify app info is not null
* @tc.type: FUNC
* @tc.require: SR000H0ALK, AR000H0ALM
*/
it
(
"
subscribeAccelerometer_SensorJsTest008
"
,
0
,
async
function
(
done
)
{
console
.
info
(
'
----------------------subscribeAccelerometer_SensorJsTest008---------------------------
'
);
try
{
sensor
.
subscribeAccelerometer
(
'
xxx
'
);
}
catch
(
error
)
{
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
* @tc.type: FUNC
* @tc.require: SR000H0ALK, AR000H0ALM
*/
it
(
"
subscribeAccelerometer_SensorJsTest009
"
,
0
,
async
function
(
done
)
{
console
.
info
(
'
----------------------subscribeAccelerometer_SensorJsTest009---------------------------
'
);
try
{
sensor
.
unsubscribeAccelerometer
(
'
xxx
'
);
}
catch
(
error
)
{
var
errMessage
=
error
.
toString
().
slice
(
21
,
58
);
console
.
info
(
'
subscribeAccelerometer_SensorJsTest009 error:
'
+
error
);
expect
(
errMessage
).
assertEqual
(
errMessages
[
0
]);
done
();
}
})
/*
* @tc.name:subscribeAccelerometer_SensorJsTest010
* @tc.desc:verify app info is not null
* @tc.type: FUNC
* @tc.require: SR000H0ALK, AR000H0ALM
*/
it
(
"
subscribeAccelerometer_SensorJsTest010
"
,
0
,
async
function
(
done
)
{
console
.
info
(
'
----------------------subscribeAccelerometer_SensorJsTest010---------------------------
'
);
sensor
.
subscribeAccelerometer
({
interval
:
'
xxx
'
,
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
"
);
},
fail
:
function
(
data
,
code
)
{
console
.
log
(
"
subscribeAccelerometer_SensorJsTest010 is failed, data:
"
+
data
+
"
, code:
"
+
code
);
expect
(
code
).
assertEqual
(
202
);
done
();
},
});
})
/*
* @tc.name:subscribeAccelerometer_SensorJsTest011
* @tc.desc:verify app info is not null
* @tc.type: FUNC
* @tc.require: SR000H0ALK, AR000H0ALM
*/
it
(
"
subscribeAccelerometer_SensorJsTest011
"
,
0
,
async
function
(
done
)
{
console
.
info
(
'
----------------------subscribeAccelerometer_SensorJsTest011---------------------------
'
);
try
{
sensor
.
unsubscribeAccelerometer
();
}
catch
(
error
)
{
var
errMessage
=
error
.
toString
().
slice
(
21
,
45
);
console
.
info
(
'
subscribeAccelerometer_SensorJsTest011 error:
'
+
error
);
expect
(
errMessage
).
assertEqual
(
errMessages
[
2
]);
done
();
}
})
/*
* @tc.name:subscribeAccelerometer_SensorJsTest012
* @tc.desc:verify app info is not null
* @tc.type: FUNC
* @tc.require: SR000H0ALK, AR000H0ALM
*/
it
(
"
subscribeAccelerometer_SensorJsTest012
"
,
0
,
async
function
(
done
)
{
console
.
info
(
'
----------------------subscribeAccelerometer_SensorJsTest012---------------------------
'
);
sensor
.
subscribeAccelerometer
({
interval
:
'
normal
'
,
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
"
);
done
();
},
});
})
/*
* @tc.name:subscribeAccelerometer_SensorJsTest013
* @tc.desc:verify app info is not null
* @tc.type: FUNC
* @tc.require: SR000H0ALK, AR000H0ALM
*/
it
(
"
subscribeAccelerometer_SensorJsTest013
"
,
0
,
async
function
(
done
)
{
console
.
info
(
'
----------------------subscribeAccelerometer_SensorJsTest013---------------------------
'
);
sensor
.
subscribeAccelerometer
({
interval
:
'
normal
'
,
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
"
);
done
();
},
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
* @tc.type: FUNC
* @tc.require: SR000H0ALK, AR000H0ALM
*/
it
(
"
subscribeAccelerometer_SensorJsTest014
"
,
0
,
async
function
(
done
)
{
console
.
info
(
'
----------------------subscribeAccelerometer_SensorJsTest014---------------------------
'
);
sensor
.
subscribeAccelerometer
({
interval
:
'
normal
'
,
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
"
);
},
fail
:
function
(
data
,
code
)
{
console
.
log
(
"
subscribeAccelerometer_SensorJsTest014 is failed, data:
"
+
data
+
"
, code:
"
+
code
);
expect
(
false
).
assertTrue
();
},
});
try
{
sensor
.
unsubscribeAccelerometer
();
}
catch
(
error
)
{
console
.
info
(
'
subscribeAccelerometer_SensorJsTest014_unsubscribeAccelerometer error
'
+
error
);
expect
(
true
).
assertTrue
();
}
setTimeout
(()
=>
{
expect
(
true
).
assertTrue
();
done
();
},
500
);
})
})
\ No newline at end of file
sensors/sensor_standard/src/main/js/default/test/subscribeGyroscope.js
0 → 100644
浏览文件 @
8c829e6e
/*
* 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
'
@system.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
'
)
})
var
errMessages
=
[
'
The number of parameters is not valid
'
,
'
Wrong argument type,
should be object
'
,
'
UnsubscribeSensor failed
'
];
/*
* @tc.name:subscribeGyroscope_SensorJsTest001
* @tc.desc:verify app info is not null
* @tc.type: FUNC
* @tc.require: SR000H0ALK, AR000H0ALM
*/
it
(
"
subscribeGyroscope_SensorJsTest001
"
,
0
,
async
function
(
done
)
{
console
.
info
(
'
----------------------subscribeGyroscope_SensorJsTest001---------------------------
'
);
sensor
.
subscribeGyroscope
({
interval
:
'
game
'
,
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
"
);
},
fail
:
function
(
data
,
code
)
{
console
.
log
(
"
subscribeGyroscope_SensorJsTest001 is failed, data:
"
+
data
+
"
, code:
"
+
code
);
expect
(
false
).
assertTrue
();
},
});
setTimeout
(()
=>
{
try
{
sensor
.
unsubscribeGyroscope
();
}
catch
(
error
)
{
console
.
info
(
'
subscribeGyroscope_SensorJsTest001_unsubscribeGyroscope error
'
+
error
);
expect
(
false
).
assertTrue
();
}
setTimeout
(()
=>
{
expect
(
true
).
assertTrue
();
done
();
},
500
);
},
1000
);
})
/*
* @tc.name:subscribeGyroscope_SensorJsTest002
* @tc.desc:verify app info is not null
* @tc.type: FUNC
* @tc.require: SR000H0ALK, AR000H0ALM
*/
it
(
"
subscribeGyroscope_SensorJsTest002
"
,
0
,
async
function
(
done
)
{
console
.
info
(
'
----------------------subscribeGyroscope_SensorJsTest002---------------------------
'
);
sensor
.
subscribeGyroscope
({
interval
:
'
ui
'
,
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
"
);
},
fail
:
function
(
data
,
code
)
{
console
.
log
(
"
subscribeGyroscope_SensorJsTest002 is failed, data:
"
+
data
+
"
, code:
"
+
code
);
expect
(
false
).
assertTrue
();
},
});
setTimeout
(()
=>
{
try
{
sensor
.
unsubscribeGyroscope
();
}
catch
(
error
)
{
console
.
info
(
'
subscribeGyroscope_SensorJsTest002_unsubscribeGyroscope error
'
+
error
);
expect
(
false
).
assertTrue
();
}
setTimeout
(()
=>
{
expect
(
true
).
assertTrue
();
done
();
},
500
);
},
1000
);
})
/*
* @tc.name:subscribeGyroscope_SensorJsTest003
* @tc.desc:verify app info is not null
* @tc.type: FUNC
* @tc.require: SR000H0ALK, AR000H0ALM
*/
it
(
"
subscribeGyroscope_SensorJsTest003
"
,
0
,
async
function
(
done
)
{
console
.
info
(
'
----------------------subscribeGyroscope_SensorJsTest003---------------------------
'
);
sensor
.
subscribeGyroscope
({
interval
:
'
normal
'
,
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
"
);
},
fail
:
function
(
data
,
code
)
{
console
.
log
(
"
subscribeGyroscope_SensorJsTest003 is failed, data:
"
+
data
+
"
, code:
"
+
code
);
expect
(
false
).
assertTrue
();
},
});
setTimeout
(()
=>
{
try
{
sensor
.
unsubscribeGyroscope
();
}
catch
(
error
)
{
console
.
info
(
'
subscribeGyroscope_SensorJsTest003_unsubscribeGyroscope error
'
+
error
);
expect
(
false
).
assertTrue
();
}
setTimeout
(()
=>
{
expect
(
true
).
assertTrue
();
done
();
},
500
);
},
1000
);
})
/*
* @tc.name:subscribeGyroscope_SensorJsTest004
* @tc.desc:verify app info is not null
* @tc.type: FUNC
* @tc.require: SR000H0ALK, AR000H0ALM
*/
it
(
"
subscribeGyroscope_SensorJsTest004
"
,
0
,
async
function
(
done
)
{
console
.
info
(
'
----------------------subscribeGyroscope_SensorJsTest004---------------------------
'
);
sensor
.
subscribeGyroscope
({
interval
:
'
xxx
'
,
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
"
);
},
fail
:
function
(
data
,
code
)
{
console
.
log
(
"
subscribeGyroscope_SensorJsTest004 is failed, data:
"
+
data
+
"
, code:
"
+
code
);
expect
(
code
).
assertEqual
(
202
);
done
();
},
});
})
/*
* @tc.name:subscribeGyroscope_SensorJsTest005
* @tc.desc:verify app info is not null
* @tc.type: FUNC
* @tc.require: SR000H0ALK, AR000H0ALM
*/
it
(
"
subscribeGyroscope_SensorJsTest005
"
,
0
,
async
function
(
done
)
{
console
.
info
(
'
----------------------subscribeGyroscope_SensorJsTest005---------------------------
'
);
sensor
.
subscribeGyroscope
({
interval
:
'
normal
'
,
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
"
);
done
();
},
fail
:
function
(
data
,
code
)
{
console
.
log
(
"
subscribeGyroscope_SensorJsTest005 is failed, data:
"
+
data
+
"
, code:
"
+
code
);
expect
(
false
).
assertTrue
();
},
});
})
/*
* @tc.name:subscribeGyroscope_SensorJsTest006
* @tc.desc:verify app info is not null
* @tc.type: FUNC
* @tc.require: SR000H0ALK, AR000H0ALM
*/
it
(
"
subscribeGyroscope_SensorJsTest006
"
,
0
,
async
function
(
done
)
{
console
.
info
(
'
----------------------subscribeGyroscope_SensorJsTest006---------------------------
'
);
try
{
sensor
.
subscribeGyroscope
({
interval
:
'
normal
'
,
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
"
);
},
fail
:
function
(
data
,
code
)
{
console
.
log
(
"
subscribeGyroscope_SensorJsTest006 is failed, data:
"
+
data
+
"
, code:
"
+
code
);
expect
(
false
).
assertTrue
();
},
},
25
);
}
catch
(
error
)
{
var
errMessage
=
error
.
toString
().
slice
(
19
,
56
);
console
.
info
(
'
subscribeGyroscope_SensorJsTest006 error:
'
+
error
);
expect
(
errMessage
).
assertEqual
(
errMessages
[
0
]);
done
();
}
})
/*
* @tc.name:subscribeGyroscope_SensorJsTest007
* @tc.desc:verify app info is not null
* @tc.type: FUNC
* @tc.require: SR000H0ALK, AR000H0ALM
*/
it
(
"
subscribeGyroscope_SensorJsTest007
"
,
0
,
async
function
(
done
)
{
console
.
info
(
'
----------------------subscribeGyroscope_SensorJsTest007---------------------------
'
);
try
{
sensor
.
subscribeGyroscope
({
interval
:
'
normal
'
,
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
"
);
},
fail
:
function
(
data
,
code
)
{
console
.
log
(
"
subscribeGyroscope_SensorJsTest007 is failed, data:
"
+
data
+
"
, code:
"
+
code
);
expect
(
false
).
assertTrue
();
},
},
function
()
{
},
25
);
}
catch
(
error
)
{
var
errMessage
=
error
.
toString
().
slice
(
19
,
56
);
console
.
info
(
'
subscribeGyroscope_SensorJsTest007 error:
'
+
error
);
expect
(
errMessage
).
assertEqual
(
errMessages
[
0
]);
done
();
}
})
/*
* @tc.name:subscribeGyroscope_SensorJsTest008
* @tc.desc:verify app info is not null
* @tc.type: FUNC
* @tc.require: SR000H0ALK, AR000H0ALM
*/
it
(
"
subscribeGyroscope_SensorJsTest008
"
,
0
,
async
function
(
done
)
{
console
.
info
(
'
----------------------subscribeGyroscope_SensorJsTest008---------------------------
'
);
sensor
.
subscribeGyroscope
({
interval
:
'
normal
'
,
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
"
);
},
fail
:
function
(
data
,
code
)
{
console
.
log
(
"
subscribeGyroscope_SensorJsTest008 is failed, data:
"
+
data
+
"
, code:
"
+
code
);
expect
(
false
).
assertTrue
();
},
});
sensor
.
subscribeGyroscope
({
interval
:
'
normal
'
,
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
"
);
},
fail
:
function
(
data
,
code
)
{
console
.
log
(
"
subscribeGyroscope_SensorJsTest008_1 is failed, data:
"
+
data
+
"
, code:
"
+
code
);
expect
(
false
).
assertTrue
();
},
});
setTimeout
(()
=>
{
try
{
sensor
.
unsubscribeGyroscope
();
}
catch
(
error
)
{
console
.
info
(
'
subscribeGyroscope_SensorJsTest008_unsubscribeGyroscope error
'
+
error
);
expect
(
false
).
assertTrue
();
}
setTimeout
(()
=>
{
expect
(
true
).
assertTrue
();
done
();
},
500
);
},
1000
);
})
/*
* @tc.name:subscribeGyroscope_SensorJsTest009
* @tc.desc:verify app info is not null
* @tc.type: FUNC
* @tc.require: SR000H0ALK, AR000H0ALM
*/
it
(
"
subscribeGyroscope_SensorJsTest009
"
,
0
,
async
function
(
done
)
{
console
.
info
(
'
----------------------subscribeGyroscope_SensorJsTest009---------------------------
'
);
try
{
sensor
.
subscribeGyroscope
();
}
catch
(
error
)
{
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
* @tc.type: FUNC
* @tc.require: SR000H0ALK, AR000H0ALM
*/
it
(
"
subscribeGyroscope_SensorJsTest010
"
,
0
,
async
function
(
done
)
{
console
.
info
(
'
----------------------subscribeGyroscope_SensorJsTest010---------------------------
'
);
try
{
sensor
.
subscribeGyroscope
(
'
xxx
'
);
}
catch
(
error
)
{
var
errMessage
=
error
.
toString
().
slice
(
19
,
56
);
console
.
info
(
'
subscribeGyroscope_SensorJsTest010 error:
'
+
error
);
expect
(
errMessage
).
assertEqual
(
errMessages
[
1
]);
done
();
}
})
/*
* @tc.name:subscribeGyroscope_SensorJsTest011
* @tc.desc:verify app info is not null
* @tc.type: FUNC
* @tc.require: SR000H0ALK, AR000H0ALM
*/
it
(
"
subscribeGyroscope_SensorJsTest011
"
,
0
,
async
function
(
done
)
{
console
.
info
(
'
----------------------subscribeGyroscope_SensorJsTest011---------------------------
'
);
try
{
sensor
.
unsubscribeGyroscope
();
}
catch
(
error
)
{
var
errMessage
=
error
.
toString
().
slice
(
21
,
45
);
console
.
info
(
'
subscribeGyroscope_SensorJsTest011 error:
'
+
error
);
expect
(
errMessage
).
assertEqual
(
errMessages
[
2
]);
done
();
}
})
/*
* @tc.name:subscribeGyroscope_SensorJsTest012
* @tc.desc:verify app info is not null
* @tc.type: FUNC
* @tc.require: SR000H0ALK, AR000H0ALM
*/
it
(
"
subscribeGyroscope_SensorJsTest012
"
,
0
,
async
function
(
done
)
{
console
.
info
(
'
----------------------subscribeGyroscope_SensorJsTest012---------------------------
'
);
try
{
sensor
.
unsubscribeGyroscope
(
'
xxx
'
);
}
catch
(
error
)
{
var
errMessage
=
error
.
toString
().
slice
(
21
,
58
);
console
.
info
(
'
subscribeGyroscope_SensorJsTest012 error:
'
+
error
);
expect
(
errMessage
).
assertEqual
(
errMessages
[
0
]);
done
();
}
})
/*
* @tc.name:subscribeGyroscope_SensorJsTest013
* @tc.desc:verify app info is not null
* @tc.type: FUNC
* @tc.require: SR000H0ALK, AR000H0ALM
*/
it
(
"
subscribeGyroscope_SensorJsTest013
"
,
0
,
async
function
(
done
)
{
console
.
info
(
'
----------------------subscribeGyroscope_SensorJsTest013---------------------------
'
);
sensor
.
subscribeGyroscope
({
interval
:
'
normal
'
,
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
"
);
done
();
},
})
})
/*
* @tc.name:subscribeGyroscope_SensorJsTest014
* @tc.desc:verify app info is not null
* @tc.type: FUNC
* @tc.require: SR000H0ALK, AR000H0ALM
*/
it
(
"
subscribeGyroscope_SensorJsTest014
"
,
0
,
async
function
(
done
)
{
console
.
info
(
'
----------------------subscribeGyroscope_SensorJsTest014---------------------------
'
);
sensor
.
subscribeGyroscope
({
interval
:
'
normal
'
,
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
"
);
done
();
},
fail
:
function
(
data
,
code
)
{
console
.
log
(
"
subscribeGyroscope_SensorJsTest014 is failed, data:
"
+
data
+
"
, code:
"
+
code
);
expect
(
false
).
assertTrue
();
},
});
try
{
sensor
.
unsubscribeGyroscope
();
}
catch
(
error
)
{
console
.
info
(
'
subscribeAccelerometer_SensorJsTest014_unsubscribeAccelerometer error
'
+
error
);
expect
(
false
).
assertTrue
();
}
setTimeout
(()
=>
{
expect
(
true
).
assertTrue
();
done
();
},
500
);
})
})
\ No newline at end of file
sensors/sensor_standard/src/main/js/default/test/subscribeLight.js
0 → 100644
浏览文件 @
8c829e6e
/*
* 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
'
@system.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
'
)
})
var
errMessages
=
[
'
The number of parameters is not valid
'
,
'
UnsubscribeSensor failed
'
,
'
Wrong argument type, should be object
'
];
/*
* @tc.name:subscribeLight_SensorJsTest001
* @tc.desc:verify app info is not null
* @tc.type: FUNC
* @tc.require: SR000H0ALK, AR000H0ALM
*/
it
(
"
subscribeLight_SensorJsTest001
"
,
0
,
function
(
done
)
{
console
.
info
(
'
----------------------subscribeLight_SensorJsTest001---------------------------
'
);
sensor
.
subscribeLight
({
success
:
function
(
data
)
{
console
.
info
(
"
subscribeLight_SensorJsTest001 success:
"
+
JSON
.
stringify
(
data
));
expect
(
typeof
(
data
.
intensity
)).
assertEqual
(
"
number
"
);
},
fail
:
function
(
data
,
code
)
{
console
.
error
(
'
subscribeLight_SensorJsTest001 failed. Code:
'
+
code
+
'
; Data:
'
+
data
);
expect
(
false
).
assertTrue
();
},
});
setTimeout
(()
=>
{
try
{
sensor
.
unsubscribeLight
();
}
catch
(
error
)
{
console
.
info
(
'
subscribeLight_SensorJsTest001_unsubscribeLight error
'
+
error
);
expect
(
false
).
assertTrue
();
}
setTimeout
(()
=>
{
expect
(
true
).
assertTrue
();
done
();
},
500
);
},
1000
);
})
/*
* @tc.name:subscribeLight_SensorJsTest002
* @tc.desc:verify app info is not null
* @tc.type: FUNC
* @tc.require: SR000H0ALK, AR000H0ALM
*/
it
(
"
subscribeLight_SensorJsTest002
"
,
0
,
function
(
done
)
{
console
.
info
(
'
----------------------subscribeLight_SensorJsTest002---------------------------
'
);
try
{
sensor
.
subscribeLight
({
success
:
function
(
data
)
{
console
.
info
(
"
subscribeLight_SensorJsTest002 success:
"
+
JSON
.
stringify
(
data
));
expect
(
typeof
(
data
.
intensity
)).
assertEqual
(
"
number
"
);
},
fail
:
function
(
data
,
code
)
{
console
.
error
(
'
subscribeLight_SensorJsTest002 failed. Code:
'
+
code
+
'
; Data:
'
+
data
);
expect
(
false
).
assertTrue
();
},
},
25
);
}
catch
(
error
)
{
var
errMessage
=
error
.
toString
().
slice
(
19
,
56
);
console
.
info
(
'
subscribeLight_SensorJsTest002 error:
'
+
error
);
expect
(
errMessage
).
assertEqual
(
errMessages
[
0
]);
done
();
}
})
/*
* @tc.name:subscribeLight_SensorJsTest003
* @tc.desc:verify app info is not null
* @tc.type: FUNC
* @tc.require: SR000H0ALK, AR000H0ALM
*/
it
(
"
subscribeLight_SensorJsTest003
"
,
0
,
function
(
done
)
{
console
.
info
(
'
----------------------subscribeLight_SensorJsTest003---------------------------
'
);
sensor
.
subscribeLight
({
success
:
function
(
data
)
{
console
.
info
(
"
subscribeLight_SensorJsTest003 success:
"
+
JSON
.
stringify
(
data
));
expect
(
typeof
(
data
.
intensity
)).
assertEqual
(
"
number
"
);
},
});
setTimeout
(()
=>
{
try
{
sensor
.
unsubscribeLight
();
}
catch
(
error
)
{
console
.
info
(
'
subscribeLight_SensorJsTest003_unsubscribeLight error
'
+
error
);
expect
(
false
).
assertTrue
();
}
setTimeout
(()
=>
{
expect
(
true
).
assertTrue
();
done
();
},
500
);
},
1000
);
})
/*
* @tc.name:subscribeLight_SensorJsTest004
* @tc.desc:verify app info is not null
* @tc.type: FUNC
* @tc.require: SR000H0ALK, AR000H0ALM
*/
it
(
"
subscribeLight_SensorJsTest004
"
,
0
,
function
(
done
)
{
console
.
info
(
'
----------------------subscribeLight_SensorJsTest004---------------------------
'
);
try
{
sensor
.
subscribeLight
({
success
:
function
(
data
)
{
console
.
info
(
"
subscribeLight_SensorJsTest004 success:
"
+
JSON
.
stringify
(
data
));
expect
(
typeof
(
data
.
intensity
)).
assertEqual
(
"
number
"
);
},
fail
:
function
(
data
,
code
)
{
console
.
error
(
'
subscribeLight_SensorJsTest004 failed. Code:
'
+
code
+
'
; Data:
'
+
data
);
expect
(
false
).
assertTrue
();
},
},
function
()
{
},
25
);
}
catch
(
error
)
{
var
errMessage
=
error
.
toString
().
slice
(
19
,
56
);
console
.
info
(
'
subscribeLight_SensorJsTest004 error:
'
+
error
);
expect
(
errMessage
).
assertEqual
(
errMessages
[
0
]);
done
();
}
})
/*
* @tc.name:subscribeLight_SensorJsTest005
* @tc.desc:verify app info is not null
* @tc.type: FUNC
* @tc.require: SR000H0ALK, AR000H0ALM
*/
it
(
"
subscribeLight_SensorJsTest005
"
,
0
,
async
function
(
done
)
{
console
.
info
(
'
----------------------subscribeLight_SensorJsTest005---------------------------
'
);
try
{
sensor
.
unsubscribeLight
(
'
xxx
'
);
}
catch
(
error
)
{
var
errMessage
=
error
.
toString
().
slice
(
21
,
58
);
console
.
info
(
'
subscribeLight_SensorJsTest005 error:
'
+
error
);
expect
(
errMessage
).
assertEqual
(
errMessages
[
0
]);
done
();
}
})
/*
* @tc.name:subscribeLight_SensorJsTest006
* @tc.desc:verify app info is not null
* @tc.type: FUNC
* @tc.require: SR000H0ALK, AR000H0ALM
*/
it
(
"
subscribeLight_SensorJsTest006
"
,
0
,
async
function
(
done
)
{
console
.
info
(
'
----------------------subscribeLight_SensorJsTest006---------------------------
'
);
try
{
sensor
.
subscribeLight
();
}
catch
(
error
)
{
var
errMessage
=
error
.
toString
().
slice
(
19
,
56
);
console
.
info
(
'
subscribeLight_SensorJsTest006 error:
'
+
error
);
expect
(
errMessage
).
assertEqual
(
errMessages
[
0
]);
done
();
}
})
/*
* @tc.name:subscribeLight_SensorJsTest007
* @tc.desc:verify app info is not null
* @tc.type: FUNC
* @tc.require: SR000H0ALK, AR000H0ALM
*/
it
(
"
subscribeLight_SensorJsTest007
"
,
0
,
async
function
(
done
)
{
console
.
info
(
'
----------------------subscribeLight_SensorJsTest007---------------------------
'
);
try
{
sensor
.
subscribeLight
(
'
xxx
'
);
}
catch
(
error
)
{
var
errMessage
=
error
.
toString
().
slice
(
19
,
56
);
console
.
info
(
'
subscribeLight_SensorJsTest007 error:
'
+
error
);
expect
(
errMessage
).
assertEqual
(
errMessages
[
2
]);
done
();
}
})
/*
* @tc.name:subscribeLight_SensorJsTest008
* @tc.desc:verify app info is not null
* @tc.type: FUNC
* @tc.require: SR000H0ALK, AR000H0ALM
*/
it
(
"
subscribeLight_SensorJsTest008
"
,
0
,
function
(
done
)
{
console
.
info
(
'
----------------------subscribeLight_SensorJsTest008---------------------------
'
);
sensor
.
subscribeLight
({
success
:
function
(
data
)
{
console
.
info
(
"
subscribeLight_SensorJsTest008 success:
"
+
JSON
.
stringify
(
data
));
expect
(
typeof
(
data
.
intensity
)).
assertEqual
(
"
number
"
);
},
fail
:
function
(
data
,
code
)
{
console
.
error
(
'
subscribeLight_SensorJsTest008 failed. Code:
'
+
code
+
'
; Data:
'
+
data
);
expect
(
false
).
assertTrue
();
},
});
sensor
.
subscribeLight
({
success
:
function
(
data
)
{
console
.
info
(
"
subscribeLight_SensorJsTest008_1 success:
"
+
JSON
.
stringify
(
data
));
expect
(
typeof
(
data
.
intensity
)).
assertEqual
(
"
number
"
);
},
fail
:
function
(
data
,
code
)
{
console
.
error
(
'
subscribeLight_SensorJsTest008_1 failed. Code:
'
+
code
+
'
; Data:
'
+
data
);
expect
(
false
).
assertTrue
();
},
});
setTimeout
(()
=>
{
try
{
sensor
.
unsubscribeLight
();
}
catch
(
error
)
{
console
.
info
(
'
subscribeLight_SensorJsTest008_unsubscribeLight error
'
+
error
);
expect
(
false
).
assertTrue
();
}
setTimeout
(()
=>
{
expect
(
true
).
assertTrue
();
done
();
},
500
);
},
1000
);
})
/*
* @tc.name:subscribeLight_SensorJsTest009
* @tc.desc:verify app info is not null
* @tc.type: FUNC
* @tc.require: SR000H0ALK, AR000H0ALM
*/
it
(
"
subscribeLight_SensorJsTest009
"
,
0
,
async
function
(
done
)
{
console
.
info
(
'
----------------------subscribeLight_SensorJsTest009---------------------------
'
);
try
{
sensor
.
unsubscribeLight
();
}
catch
(
error
)
{
var
errMessage
=
error
.
toString
().
slice
(
21
,
45
);
console
.
info
(
'
subscribeLight_SensorJsTest009 error:
'
+
error
);
expect
(
errMessage
).
assertEqual
(
errMessages
[
1
]);
done
();
}
})
/*
* @tc.name:subscribeLight_SensorJsTest010
* @tc.desc:verify app info is not null
* @tc.type: FUNC
* @tc.require: SR000H0ALK, AR000H0ALM
*/
it
(
"
subscribeLight_SensorJsTest010
"
,
0
,
function
(
done
)
{
console
.
info
(
'
----------------------subscribeLight_SensorJsTest010---------------------------
'
);
sensor
.
subscribeLight
({
success
:
function
(
data
)
{
console
.
info
(
"
subscribeLight_SensorJsTest010 success:
"
+
JSON
.
stringify
(
data
));
expect
(
typeof
(
data
.
intensity
)).
assertEqual
(
"
number
"
);
},
fail
:
function
(
data
,
code
)
{
console
.
error
(
'
subscribeLight_SensorJsTest010 failed. Code:
'
+
code
+
'
; Data:
'
+
data
);
expect
(
false
).
assertTrue
();
},
});
try
{
sensor
.
unsubscribeLight
();
}
catch
(
error
)
{
console
.
info
(
'
subscribeLight_SensorJsTest008_unsubscribeLight error
'
+
error
);
expect
(
true
).
assertTrue
();
}
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.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录