Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
OpenHarmony
Xts Acts
提交
bacde40a
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看板
提交
bacde40a
编写于
2月 19, 2022
作者:
L
logic42
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
add sensor testcasse
Signed-off-by:
N
logic42
<
wanglong108@huawei.com
>
上级
cdd21ff2
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
37 addition
and
34 deletion
+37
-34
sensors/sensor_standard/src/main/js/default/test/SensorOnOffTest.test.js
...standard/src/main/js/default/test/SensorOnOffTest.test.js
+31
-30
sensors/sensor_standard/src/main/js/default/test/SensorOnOffTest.test_Rotation_Vector.js
...n/js/default/test/SensorOnOffTest.test_Rotation_Vector.js
+6
-4
未找到文件。
sensors/sensor_standard/src/main/js/default/test/SensorOnOffTest.test.js
浏览文件 @
bacde40a
...
...
@@ -18,10 +18,10 @@
import
{
describe
,
beforeAll
,
beforeEach
,
afterEach
,
afterAll
,
it
,
expect
}
from
'
deccjsunit/index
'
import
sensor
from
'
@ohos.sensor
'
function
sleep
(
NumberMillis
)
{
function
sleep
(
NumberMillis
)
{
var
now
=
new
Date
()
var
exitTime
=
now
.
getTime
()
+
NumberMillis
while
(
true
)
{
while
(
true
)
{
now
=
new
Date
()
if
(
now
.
getTime
>
exitTime
)
{
return
...
...
@@ -30,20 +30,20 @@ function sleep (NumberMillis) {
}
describe
(
'
SystemParameterTest
'
,
function
()
{
beforeAll
(
function
()
{
console
.
info
(
'
beforeAll caled
'
)
beforeAll
(
function
()
{
console
.
info
(
'
beforeAll caled
'
)
})
afterAll
(
function
()
{
console
.
info
(
'
afterAll caled
'
)
afterAll
(
function
()
{
console
.
info
(
'
afterAll caled
'
)
})
beforeEach
(
function
()
{
console
.
info
(
'
beforeEach caled
'
)
beforeEach
(
function
()
{
console
.
info
(
'
beforeEach caled
'
)
})
afterEach
(
function
()
{
console
.
info
(
'
afterEach caled
'
)
afterEach
(
function
()
{
console
.
info
(
'
afterEach caled
'
)
})
/**
...
...
@@ -51,9 +51,9 @@ describe('SystemParameterTest', function () {
* @tc.name testRegisterSensortest001
* @tc.desc test get sensor data by sensor id.
*/
it
(
'
SUB_SENSORS_Sensor_JSTest_0010
'
,
0
,
async
function
(
done
)
{
it
(
'
SUB_SENSORS_Sensor_JSTest_0010
'
,
0
,
async
function
(
done
)
{
console
.
info
(
'
SUB_SENSORS_Sensor_JSTest_0010 start
'
);
await
sensor
.
on
(
0
,
function
(
error
,
data
)
{
await
sensor
.
on
(
0
,
function
(
error
,
data
)
{
if
(
error
)
{
console
.
info
(
'
testRegisterSensortest001 on error
'
);
expect
(
false
).
assertTrue
();
...
...
@@ -61,6 +61,7 @@ describe('SystemParameterTest', function () {
}
else
{
console
.
info
(
'
testRegisterSensortest001 on success
'
);
expect
(
data
.
x
).
assertInstanceOf
(
'
Number
'
);
expect
(
data
.
timestamp
).
assertInstanceOf
(
'
Number
'
);
done
();
}
});
...
...
@@ -72,20 +73,20 @@ describe('SystemParameterTest', function () {
* @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
(
-
1
,
function
(
error
,
data
)
{
if
(
error
)
{
console
.
info
(
'
testRegisterSensortest002 on error
'
);
expect
(
true
).
assertTrue
();
done
();
}
else
{
console
.
info
(
'
testRegisterSensortest002 on success
'
);
expect
(
false
).
assertTrue
();
done
();
}
});
console
.
info
(
'
SUB_SENSORS_Sensor_JSTest_0020 end
'
);
})
it
(
'
SUB_SENSORS_Sensor_JSTest_0020
'
,
0
,
async
function
(
done
)
{
console
.
info
(
'
SUB_SENSORS_Sensor_JSTest_0020 start
'
);
await
sensor
.
on
(
-
1
,
function
(
error
,
data
)
{
if
(
error
)
{
console
.
info
(
'
testRegisterSensortest002 on error
'
);
expect
(
true
).
assertTrue
();
done
();
}
else
{
console
.
info
(
'
testRegisterSensortest002 on success
'
);
expect
(
false
).
assertTrue
();
done
();
}
});
console
.
info
(
'
SUB_SENSORS_Sensor_JSTest_0020 end
'
);
})
})
\ No newline at end of file
sensors/sensor_standard/src/main/js/default/test/SensorOnOffTest.test_Rotation_Vector.js
浏览文件 @
bacde40a
...
...
@@ -86,11 +86,12 @@ describe("SensorJsTest", function () {
reject
(
err
);
},
500
);
}
else
{
console
.
info
(
'
SensorRotationVectorJSTest001 on success, x:
'
+
data
.
x
+
"
y:
"
+
data
.
y
+
"
z:
"
+
data
.
z
);
console
.
info
(
'
SensorRotationVectorJSTest001 on success, x:
'
+
data
.
x
+
"
y:
"
+
data
.
y
+
"
z:
"
+
data
.
z
+
"
w:
"
+
data
.
w
);
expect
(
typeof
(
data
.
x
)).
assertEqual
(
"
number
"
);
expect
(
typeof
(
data
.
y
)).
assertEqual
(
"
number
"
);
expect
(
typeof
(
data
.
z
)).
assertEqual
(
"
number
"
);
expect
(
typeof
(
data
.
w
)).
assertEqual
(
"
number
"
);
setTimeout
(()
=>
{
resolve
();
},
500
);
...
...
@@ -117,11 +118,12 @@ describe("SensorJsTest", function () {
console
.
info
(
'
SensorRotationVectorJSTest005 once error
'
);
expect
(
false
).
assertTrue
();
}
else
{
console
.
info
(
'
SensorRotationVectorJSTest005 on success, x:
'
+
data
.
x
+
"
y:
"
+
data
.
y
+
"
z:
"
+
data
.
z
);
console
.
info
(
'
SensorRotationVectorJSTest005 on success, x:
'
+
data
.
x
+
"
y:
"
+
data
.
y
+
"
z:
"
+
data
.
z
+
"
w:
"
+
data
.
w
);
expect
(
typeof
(
data
.
x
)).
assertEqual
(
"
number
"
);
expect
(
typeof
(
data
.
y
)).
assertEqual
(
"
number
"
);
expect
(
typeof
(
data
.
z
)).
assertEqual
(
"
number
"
);
expect
(
typeof
(
data
.
w
)).
assertEqual
(
"
number
"
);
}
setTimeout
(()
=>
{
done
();
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录