Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
OpenHarmony
Xts Acts
提交
23b3d674
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看板
未验证
提交
23b3d674
编写于
1月 14, 2022
作者:
O
openharmony_ci
提交者:
Gitee
1月 14, 2022
浏览文件
操作
浏览文件
下载
差异文件
!1577 add sensor js interface testcase
Merge pull request !1577 from liuzixuan10/master
上级
7c24fe0f
a0a84820
变更
17
显示空白变更内容
内联
并排
Showing
17 changed file
with
2228 addition
and
0 deletion
+2228
-0
sensors/sensor_standard/src/main/js/default/test/SensorOnOffTest.test_acc_uncal.js
...rc/main/js/default/test/SensorOnOffTest.test_acc_uncal.js
+140
-0
sensors/sensor_standard/src/main/js/default/test/SensorOnOffTest.test_bar.js
...dard/src/main/js/default/test/SensorOnOffTest.test_bar.js
+128
-0
sensors/sensor_standard/src/main/js/default/test/SensorOnOffTest.test_dete.js
...ard/src/main/js/default/test/SensorOnOffTest.test_dete.js
+128
-0
sensors/sensor_standard/src/main/js/default/test/SensorOnOffTest.test_field_unca.js
...c/main/js/default/test/SensorOnOffTest.test_field_unca.js
+140
-0
sensors/sensor_standard/src/main/js/default/test/SensorOnOffTest.test_grav.js
...ard/src/main/js/default/test/SensorOnOffTest.test_grav.js
+132
-0
sensors/sensor_standard/src/main/js/default/test/SensorOnOffTest.test_gyr_unca.js
...src/main/js/default/test/SensorOnOffTest.test_gyr_unca.js
+140
-0
sensors/sensor_standard/src/main/js/default/test/SensorOnOffTest.test_harr.js
...ard/src/main/js/default/test/SensorOnOffTest.test_harr.js
+128
-0
sensors/sensor_standard/src/main/js/default/test/SensorOnOffTest.test_humi.js
...ard/src/main/js/default/test/SensorOnOffTest.test_humi.js
+128
-0
sensors/sensor_standard/src/main/js/default/test/SensorOnOffTest.test_line_acc.js
...src/main/js/default/test/SensorOnOffTest.test_line_acc.js
+132
-0
sensors/sensor_standard/src/main/js/default/test/SensorOnOffTest.test_moti.js
...ard/src/main/js/default/test/SensorOnOffTest.test_moti.js
+128
-0
sensors/sensor_standard/src/main/js/default/test/SensorOnOffTest.test_orie.js
...ard/src/main/js/default/test/SensorOnOffTest.test_orie.js
+132
-0
sensors/sensor_standard/src/main/js/default/test/SensorOnOffTest.test_ped.js
...dard/src/main/js/default/test/SensorOnOffTest.test_ped.js
+128
-0
sensors/sensor_standard/src/main/js/default/test/SensorOnOffTest.test_ped_det.js
.../src/main/js/default/test/SensorOnOffTest.test_ped_det.js
+128
-0
sensors/sensor_standard/src/main/js/default/test/SensorOnOffTest.test_prox.js
...ard/src/main/js/default/test/SensorOnOffTest.test_prox.js
+128
-0
sensors/sensor_standard/src/main/js/default/test/SensorOnOffTest.test_rate.js
...ard/src/main/js/default/test/SensorOnOffTest.test_rate.js
+128
-0
sensors/sensor_standard/src/main/js/default/test/SensorOnOffTest.test_temp.js
...ard/src/main/js/default/test/SensorOnOffTest.test_temp.js
+128
-0
sensors/sensor_standard/src/main/js/default/test/SensorOnOffTest.test_vec.js
...dard/src/main/js/default/test/SensorOnOffTest.test_vec.js
+132
-0
未找到文件。
sensors/sensor_standard/src/main/js/default/test/SensorOnOffTest.test_acc_uncal.js
0 → 100755
浏览文件 @
23b3d674
/*
* Copyright (C) 2021 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import
sensor
from
'
@ohos.sensor
'
import
{
describe
,
beforeAll
,
beforeEach
,
afterEach
,
afterAll
,
it
,
expect
}
from
'
deccjsunit/index
'
describe
(
"
SensorJsTest
"
,
function
()
{
beforeAll
(
function
()
{
/*
* @tc.setup: setup invoked before all testcases
*/
console
.
info
(
'
beforeAll caled
'
)
})
afterAll
(
function
()
{
/*
* @tc.teardown: teardown invoked after all testcases
*/
console
.
info
(
'
afterAll caled
'
)
})
beforeEach
(
function
()
{
/*
* @tc.setup: setup invoked before each testcases
*/
console
.
info
(
'
beforeEach caled
'
)
})
afterEach
(
function
()
{
/*
* @tc.teardown: teardown invoked after each testcases
*/
console
.
info
(
'
afterEach caled
'
)
})
/*
* @tc.name:SensorJsTest001
* @tc.desc:verify app info is not null
* @tc.type: FUNC
* @tc.require: Issue Number
*/
it
(
"
SensorJsTest001
"
,
0
,
async
function
(
done
)
{
console
.
info
(
'
----------------------SensorJsTest001---------------------------
'
);
function
offPromise
()
{
return
new
Promise
((
resolve
,
reject
)
=>
{
sensor
.
off
(
sensor
.
SensorType
.
SENSOR_TYPE_ID_ACCELEROMETER_UNCALIBRATED
,
(
error
)
=>
{
if
(
error
)
{
console
.
info
(
'
SensorJsTest001 off error
'
);
expect
(
false
).
assertTrue
();
console
.
info
(
'
setTimeout ..start
'
)
setTimeout
((
err
)
=>
{
reject
(
err
);
},
500
);
}
else
{
console
.
info
(
'
SensorJsTest001 off success
'
);
expect
(
true
).
assertTrue
();
setTimeout
(()
=>
{
resolve
();
},
500
);
}
},
1000
)
})
}
let
promise
=
new
Promise
((
resolve
,
reject
)
=>
{
sensor
.
on
(
sensor
.
SensorType
.
SENSOR_TYPE_ID_ACCELEROMETER_UNCALIBRATED
,
function
(
error
,
data
)
{
if
(
error
)
{
console
.
info
(
'
SensorJsTest001 on error
'
);
expect
(
false
).
assertTrue
();
setTimeout
((
err
)
=>
{
reject
(
err
);
},
500
);
}
else
{
console
.
info
(
'
SensorJsTest001 on success, x:
'
+
data
.
x
+
"
y:
"
+
data
.
y
+
"
z:
"
+
data
.
z
+
"
biasX:
"
+
data
.
biasX
+
"
biasY:
"
+
data
.
biasY
+
"
biasZ:
"
+
data
.
biasZ
);
expect
(
typeof
(
data
.
x
)).
assertEqual
(
"
number
"
);
expect
(
typeof
(
data
.
y
)).
assertEqual
(
"
number
"
);
expect
(
typeof
(
data
.
z
)).
assertEqual
(
"
number
"
);
expect
(
typeof
(
data
.
biasX
)).
assertEqual
(
"
number
"
);
expect
(
typeof
(
data
.
biasY
)).
assertEqual
(
"
number
"
);
expect
(
typeof
(
data
.
biasZ
)).
assertEqual
(
"
number
"
);
setTimeout
(()
=>
{
resolve
();
},
500
);
}
});
})
await
promise
.
then
(()
=>
{
return
offPromise
();
},
()
=>
{
console
.
info
(
"
SensorJsTest001 reject
"
);
})
done
();
})
/*
* @tc.name:SensorJsTest005
* @tc.desc:verify app info is not null
* @tc.type: FUNC
* @tc.require: Issue Number
*/
it
(
"
SensorJsTest005
"
,
0
,
async
function
(
done
)
{
function
onceSensorCallback
(
error
,
data
)
{
if
(
error
)
{
console
.
info
(
'
SensorJsTest005 once error
'
);
expect
(
false
).
assertTrue
();
}
else
{
console
.
info
(
'
SensorJsTest001 on success, x:
'
+
data
.
x
+
"
y:
"
+
data
.
y
+
"
z:
"
+
data
.
z
+
"
biasX:
"
+
data
.
biasX
+
"
biasY:
"
+
data
.
biasY
+
"
biasZ:
"
+
data
.
biasZ
);
expect
(
typeof
(
data
.
x
)).
assertEqual
(
"
number
"
);
expect
(
typeof
(
data
.
y
)).
assertEqual
(
"
number
"
);
expect
(
typeof
(
data
.
z
)).
assertEqual
(
"
number
"
);
expect
(
typeof
(
data
.
biasX
)).
assertEqual
(
"
number
"
);
expect
(
typeof
(
data
.
biasY
)).
assertEqual
(
"
number
"
);
expect
(
typeof
(
data
.
biasZ
)).
assertEqual
(
"
number
"
);
}
setTimeout
(()
=>
{
done
();
},
500
);
}
sensor
.
once
(
sensor
.
SensorType
.
SENSOR_TYPE_ID_ACCELEROMETER_UNCALIBRATED
,
onceSensorCallback
);
})
})
sensors/sensor_standard/src/main/js/default/test/SensorOnOffTest.test_bar.js
0 → 100755
浏览文件 @
23b3d674
/*
* Copyright (C) 2021 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import
sensor
from
'
@ohos.sensor
'
import
{
describe
,
beforeAll
,
beforeEach
,
afterEach
,
afterAll
,
it
,
expect
}
from
'
deccjsunit/index
'
describe
(
"
SensorJsTest
"
,
function
()
{
beforeAll
(
function
()
{
/*
* @tc.setup: setup invoked before all testcases
*/
console
.
info
(
'
beforeAll caled
'
)
})
afterAll
(
function
()
{
/*
* @tc.teardown: teardown invoked after all testcases
*/
console
.
info
(
'
afterAll caled
'
)
})
beforeEach
(
function
()
{
/*
* @tc.setup: setup invoked before each testcases
*/
console
.
info
(
'
beforeEach caled
'
)
})
afterEach
(
function
()
{
/*
* @tc.teardown: teardown invoked after each testcases
*/
console
.
info
(
'
afterEach caled
'
)
})
/*
* @tc.name:SensorJsTest001
* @tc.desc:verify app info is not null
* @tc.type: FUNC
* @tc.require: Issue Number
*/
it
(
"
SensorJsTest001
"
,
0
,
async
function
(
done
)
{
console
.
info
(
'
----------------------SensorJsTest001---------------------------
'
);
function
offPromise
()
{
return
new
Promise
((
resolve
,
reject
)
=>
{
sensor
.
off
(
sensor
.
SensorType
.
SENSOR_TYPE_ID_BAROMETER
,
(
error
)
=>
{
if
(
error
)
{
console
.
info
(
'
SensorJsTest001 off error
'
);
expect
(
false
).
assertTrue
();
console
.
info
(
'
setTimeout ..start
'
)
setTimeout
((
err
)
=>
{
reject
(
err
);
},
500
);
}
else
{
console
.
info
(
'
SensorJsTest001 off success
'
);
expect
(
true
).
assertTrue
();
setTimeout
(()
=>
{
resolve
();
},
500
);
}
},
1000
)
})
}
let
promise
=
new
Promise
((
resolve
,
reject
)
=>
{
sensor
.
on
(
sensor
.
SensorType
.
SENSOR_TYPE_ID_BAROMETER
,
function
(
error
,
data
)
{
if
(
error
)
{
console
.
info
(
'
SensorJsTest001 on error
'
);
expect
(
false
).
assertTrue
();
setTimeout
((
err
)
=>
{
reject
(
err
);
},
500
);
}
else
{
console
.
info
(
'
SensorJsTest001 on success pressure:
'
+
data
.
pressure
);
expect
(
typeof
(
data
.
pressure
)).
assertEqual
(
"
number
"
);
setTimeout
(()
=>
{
resolve
();
},
500
);
}
});
})
await
promise
.
then
(()
=>
{
return
offPromise
();
},
()
=>
{
console
.
info
(
"
SensorJsTest001 reject
"
);
})
done
();
})
/*
* @tc.name:SensorJsTest005
* @tc.desc:verify app info is not null
* @tc.type: FUNC
* @tc.require: Issue Number
*/
it
(
"
SensorJsTest005
"
,
0
,
async
function
(
done
)
{
function
onceSensorCallback
(
error
,
data
)
{
if
(
error
)
{
console
.
info
(
'
SensorJsTest005 once error
'
);
expect
(
false
).
assertTrue
();
}
else
{
console
.
info
(
'
SensorJsTest005 once success pressure:
'
+
data
.
pressure
);
expect
(
typeof
(
data
.
pressure
)).
assertEqual
(
"
number
"
);
}
setTimeout
(()
=>
{
done
();
},
500
);
}
sensor
.
once
(
sensor
.
SensorType
.
SENSOR_TYPE_ID_BAROMETER
,
onceSensorCallback
);
})
})
sensors/sensor_standard/src/main/js/default/test/SensorOnOffTest.test_dete.js
0 → 100755
浏览文件 @
23b3d674
/*
* Copyright (C) 2021 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import
sensor
from
'
@ohos.sensor
'
import
{
describe
,
beforeAll
,
beforeEach
,
afterEach
,
afterAll
,
it
,
expect
}
from
'
deccjsunit/index
'
describe
(
"
SensorJsTest
"
,
function
()
{
beforeAll
(
function
()
{
/*
* @tc.setup: setup invoked before all testcases
*/
console
.
info
(
'
beforeAll caled
'
)
})
afterAll
(
function
()
{
/*
* @tc.teardown: teardown invoked after all testcases
*/
console
.
info
(
'
afterAll caled
'
)
})
beforeEach
(
function
()
{
/*
* @tc.setup: setup invoked before each testcases
*/
console
.
info
(
'
beforeEach caled
'
)
})
afterEach
(
function
()
{
/*
* @tc.teardown: teardown invoked after each testcases
*/
console
.
info
(
'
afterEach caled
'
)
})
/*
* @tc.name:SensorJsTest001
* @tc.desc:verify app info is not null
* @tc.type: FUNC
* @tc.require: Issue Number
*/
it
(
"
SensorJsTest001
"
,
0
,
async
function
(
done
)
{
console
.
info
(
'
----------------------SensorJsTest001---------------------------
'
);
function
offPromise
()
{
return
new
Promise
((
resolve
,
reject
)
=>
{
sensor
.
off
(
sensor
.
SensorType
.
SENSOR_TYPE_ID_WEAR_DETECTION
,
(
error
)
=>
{
if
(
error
)
{
console
.
info
(
'
SensorJsTest001 off error
'
);
expect
(
false
).
assertTrue
();
console
.
info
(
'
setTimeout ..start
'
)
setTimeout
((
err
)
=>
{
reject
(
err
);
},
500
);
}
else
{
console
.
info
(
'
SensorJsTest001 off success
'
);
expect
(
true
).
assertTrue
();
setTimeout
(()
=>
{
resolve
();
},
500
);
}
},
1000
)
})
}
let
promise
=
new
Promise
((
resolve
,
reject
)
=>
{
sensor
.
on
(
sensor
.
SensorType
.
SENSOR_TYPE_ID_WEAR_DETECTION
,
function
(
error
,
data
)
{
if
(
error
)
{
console
.
info
(
'
SensorJsTest001 on error
'
);
expect
(
false
).
assertTrue
();
setTimeout
((
err
)
=>
{
reject
(
err
);
},
500
);
}
else
{
console
.
info
(
'
SensorJsTest001 once success value:
'
+
data
.
value
);
expect
(
typeof
(
data
.
value
)).
assertEqual
(
"
number
"
);
setTimeout
(()
=>
{
resolve
();
},
500
);
}
});
})
await
promise
.
then
(()
=>
{
return
offPromise
();
},
()
=>
{
console
.
info
(
"
SensorJsTest001 reject
"
);
})
done
();
})
/*
* @tc.name:SensorJsTest005
* @tc.desc:verify app info is not null
* @tc.type: FUNC
* @tc.require: Issue Number
*/
it
(
"
SensorJsTest005
"
,
0
,
async
function
(
done
)
{
function
onceSensorCallback
(
error
,
data
)
{
if
(
error
)
{
console
.
info
(
'
SensorJsTest005 once error
'
);
expect
(
false
).
assertTrue
();
}
else
{
console
.
info
(
'
SensorJsTest005 once success value:
'
+
data
.
value
);
expect
(
typeof
(
data
.
value
)).
assertEqual
(
"
number
"
);
}
setTimeout
(()
=>
{
done
();
},
500
);
}
sensor
.
once
(
sensor
.
SensorType
.
SENSOR_TYPE_ID_WEAR_DETECTION
,
onceSensorCallback
);
})
})
sensors/sensor_standard/src/main/js/default/test/SensorOnOffTest.test_field_unca.js
0 → 100755
浏览文件 @
23b3d674
/*
* Copyright (C) 2021 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import
sensor
from
'
@ohos.sensor
'
import
{
describe
,
beforeAll
,
beforeEach
,
afterEach
,
afterAll
,
it
,
expect
}
from
'
deccjsunit/index
'
describe
(
"
SensorJsTest
"
,
function
()
{
beforeAll
(
function
()
{
/*
* @tc.setup: setup invoked before all testcases
*/
console
.
info
(
'
beforeAll caled
'
)
})
afterAll
(
function
()
{
/*
* @tc.teardown: teardown invoked after all testcases
*/
console
.
info
(
'
afterAll caled
'
)
})
beforeEach
(
function
()
{
/*
* @tc.setup: setup invoked before each testcases
*/
console
.
info
(
'
beforeEach caled
'
)
})
afterEach
(
function
()
{
/*
* @tc.teardown: teardown invoked after each testcases
*/
console
.
info
(
'
afterEach caled
'
)
})
/*
* @tc.name:SensorJsTest001
* @tc.desc:verify app info is not null
* @tc.type: FUNC
* @tc.require: Issue Number
*/
it
(
"
SensorJsTest001
"
,
0
,
async
function
(
done
)
{
console
.
info
(
'
----------------------SensorJsTest001---------------------------
'
);
function
offPromise
()
{
return
new
Promise
((
resolve
,
reject
)
=>
{
sensor
.
off
(
sensor
.
SensorType
.
SENSOR_TYPE_ID_MAGNETIC_FIELD_UNCALIBRATED
,
(
error
)
=>
{
if
(
error
)
{
console
.
info
(
'
SensorJsTest001 off error
'
);
expect
(
false
).
assertTrue
();
console
.
info
(
'
setTimeout ..start
'
)
setTimeout
((
err
)
=>
{
reject
(
err
);
},
500
);
}
else
{
console
.
info
(
'
SensorJsTest001 off success
'
);
expect
(
true
).
assertTrue
();
setTimeout
(()
=>
{
resolve
();
},
500
);
}
},
1000
)
})
}
let
promise
=
new
Promise
((
resolve
,
reject
)
=>
{
sensor
.
on
(
sensor
.
SensorType
.
SENSOR_TYPE_ID_MAGNETIC_FIELD_UNCALIBRATED
,
function
(
error
,
data
)
{
if
(
error
)
{
console
.
info
(
'
SensorJsTest001 on error
'
);
expect
(
false
).
assertTrue
();
setTimeout
((
err
)
=>
{
reject
(
err
);
},
500
);
}
else
{
console
.
info
(
'
SensorJsTest001 on success, x:
'
+
data
.
x
+
"
y:
"
+
data
.
y
+
"
z:
"
+
data
.
z
+
"
biasX:
"
+
data
.
biasX
+
"
biasY:
"
+
data
.
biasY
+
"
biasZ:
"
+
data
.
biasZ
);
expect
(
typeof
(
data
.
x
)).
assertEqual
(
"
number
"
);
expect
(
typeof
(
data
.
y
)).
assertEqual
(
"
number
"
);
expect
(
typeof
(
data
.
z
)).
assertEqual
(
"
number
"
);
expect
(
typeof
(
data
.
biasX
)).
assertEqual
(
"
number
"
);
expect
(
typeof
(
data
.
biasY
)).
assertEqual
(
"
number
"
);
expect
(
typeof
(
data
.
biasZ
)).
assertEqual
(
"
number
"
);
setTimeout
(()
=>
{
resolve
();
},
500
);
}
});
})
await
promise
.
then
(()
=>
{
return
offPromise
();
},
()
=>
{
console
.
info
(
"
SensorJsTest001 reject
"
);
})
done
();
})
/*
* @tc.name:SensorJsTest005
* @tc.desc:verify app info is not null
* @tc.type: FUNC
* @tc.require: Issue Number
*/
it
(
"
SensorJsTest005
"
,
0
,
async
function
(
done
)
{
function
onceSensorCallback
(
error
,
data
)
{
if
(
error
)
{
console
.
info
(
'
SensorJsTest005 once error
'
);
expect
(
false
).
assertTrue
();
}
else
{
console
.
info
(
'
SensorJsTest001 on success, x:
'
+
data
.
x
+
"
y:
"
+
data
.
y
+
"
z:
"
+
data
.
z
+
"
biasX:
"
+
data
.
biasX
+
"
biasY:
"
+
data
.
biasY
+
"
biasZ:
"
+
data
.
biasZ
);
expect
(
typeof
(
data
.
x
)).
assertEqual
(
"
number
"
);
expect
(
typeof
(
data
.
y
)).
assertEqual
(
"
number
"
);
expect
(
typeof
(
data
.
z
)).
assertEqual
(
"
number
"
);
expect
(
typeof
(
data
.
biasX
)).
assertEqual
(
"
number
"
);
expect
(
typeof
(
data
.
biasY
)).
assertEqual
(
"
number
"
);
expect
(
typeof
(
data
.
biasZ
)).
assertEqual
(
"
number
"
);
}
setTimeout
(()
=>
{
done
();
},
500
);
}
sensor
.
once
(
sensor
.
SensorType
.
SENSOR_TYPE_ID_MAGNETIC_FIELD_UNCALIBRATED
,
onceSensorCallback
);
})
})
sensors/sensor_standard/src/main/js/default/test/SensorOnOffTest.test_grav.js
0 → 100755
浏览文件 @
23b3d674
/*
* Copyright (C) 2021 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import
sensor
from
'
@ohos.sensor
'
import
{
describe
,
beforeAll
,
beforeEach
,
afterEach
,
afterAll
,
it
,
expect
}
from
'
deccjsunit/index
'
describe
(
"
SensorJsTest
"
,
function
()
{
beforeAll
(
function
()
{
/*
* @tc.setup: setup invoked before all testcases
*/
console
.
info
(
'
beforeAll caled
'
)
})
afterAll
(
function
()
{
/*
* @tc.teardown: teardown invoked after all testcases
*/
console
.
info
(
'
afterAll caled
'
)
})
beforeEach
(
function
()
{
/*
* @tc.setup: setup invoked before each testcases
*/
console
.
info
(
'
beforeEach caled
'
)
})
afterEach
(
function
()
{
/*
* @tc.teardown: teardown invoked after each testcases
*/
console
.
info
(
'
afterEach caled
'
)
})
/*
* @tc.name:SensorJsTest001
* @tc.desc:verify app info is not null
* @tc.type: FUNC
* @tc.require: Issue Number
*/
it
(
"
SensorJsTest001
"
,
0
,
async
function
(
done
)
{
console
.
info
(
'
----------------------SensorJsTest001---------------------------
'
);
function
offPromise
()
{
return
new
Promise
((
resolve
,
reject
)
=>
{
sensor
.
off
(
sensor
.
SensorType
.
SENSOR_TYPE_ID_GRAVITY
,
(
error
)
=>
{
if
(
error
)
{
console
.
info
(
'
SensorJsTest001 off error
'
);
expect
(
false
).
assertTrue
();
console
.
info
(
'
setTimeout ..start
'
)
setTimeout
((
err
)
=>
{
reject
(
err
);
},
500
);
}
else
{
console
.
info
(
'
SensorJsTest001 off success
'
);
expect
(
true
).
assertTrue
();
setTimeout
(()
=>
{
resolve
();
},
500
);
}
},
1000
)
})
}
let
promise
=
new
Promise
((
resolve
,
reject
)
=>
{
sensor
.
on
(
sensor
.
SensorType
.
SENSOR_TYPE_ID_GRAVITY
,
function
(
error
,
data
)
{
if
(
error
)
{
console
.
info
(
'
SensorJsTest001 on error
'
);
expect
(
false
).
assertTrue
();
setTimeout
((
err
)
=>
{
reject
(
err
);
},
500
);
}
else
{
console
.
info
(
'
SensorJsTest001 on success, x:
'
+
data
.
x
+
"
y:
"
+
data
.
y
+
"
z:
"
+
data
.
z
);
expect
(
typeof
(
data
.
x
)).
assertEqual
(
"
number
"
);
expect
(
typeof
(
data
.
y
)).
assertEqual
(
"
number
"
);
expect
(
typeof
(
data
.
z
)).
assertEqual
(
"
number
"
);
setTimeout
(()
=>
{
resolve
();
},
500
);
}
});
})
await
promise
.
then
(()
=>
{
return
offPromise
();
},
()
=>
{
console
.
info
(
"
SensorJsTest001 reject
"
);
})
done
();
})
/*
* @tc.name:SensorJsTest005
* @tc.desc:verify app info is not null
* @tc.type: FUNC
* @tc.require: Issue Number
*/
it
(
"
SensorJsTest005
"
,
0
,
async
function
(
done
)
{
function
onceSensorCallback
(
error
,
data
)
{
if
(
error
)
{
console
.
info
(
'
SensorJsTest005 once error
'
);
expect
(
false
).
assertTrue
();
}
else
{
console
.
info
(
'
SensorJsTest001 on success, x:
'
+
data
.
x
+
"
y:
"
+
data
.
y
+
"
z:
"
+
data
.
z
);
expect
(
typeof
(
data
.
x
)).
assertEqual
(
"
number
"
);
expect
(
typeof
(
data
.
y
)).
assertEqual
(
"
number
"
);
expect
(
typeof
(
data
.
z
)).
assertEqual
(
"
number
"
);
}
setTimeout
(()
=>
{
done
();
},
500
);
}
sensor
.
once
(
sensor
.
SensorType
.
SENSOR_TYPE_ID_GRAVITY
,
onceSensorCallback
);
})
})
sensors/sensor_standard/src/main/js/default/test/SensorOnOffTest.test_gyr_unca.js
0 → 100755
浏览文件 @
23b3d674
/*
* Copyright (C) 2021 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import
sensor
from
'
@ohos.sensor
'
import
{
describe
,
beforeAll
,
beforeEach
,
afterEach
,
afterAll
,
it
,
expect
}
from
'
deccjsunit/index
'
describe
(
"
SensorJsTest
"
,
function
()
{
beforeAll
(
function
()
{
/*
* @tc.setup: setup invoked before all testcases
*/
console
.
info
(
'
beforeAll caled
'
)
})
afterAll
(
function
()
{
/*
* @tc.teardown: teardown invoked after all testcases
*/
console
.
info
(
'
afterAll caled
'
)
})
beforeEach
(
function
()
{
/*
* @tc.setup: setup invoked before each testcases
*/
console
.
info
(
'
beforeEach caled
'
)
})
afterEach
(
function
()
{
/*
* @tc.teardown: teardown invoked after each testcases
*/
console
.
info
(
'
afterEach caled
'
)
})
/*
* @tc.name:SensorJsTest001
* @tc.desc:verify app info is not null
* @tc.type: FUNC
* @tc.require: Issue Number
*/
it
(
"
SensorJsTest001
"
,
0
,
async
function
(
done
)
{
console
.
info
(
'
----------------------SensorJsTest001---------------------------
'
);
function
offPromise
()
{
return
new
Promise
((
resolve
,
reject
)
=>
{
sensor
.
off
(
sensor
.
SensorType
.
SENSOR_TYPE_ID_GYROSCOPE_UNCALIBRATED
,
(
error
)
=>
{
if
(
error
)
{
console
.
info
(
'
SensorJsTest001 off error
'
);
expect
(
false
).
assertTrue
();
console
.
info
(
'
setTimeout ..start
'
)
setTimeout
((
err
)
=>
{
reject
(
err
);
},
500
);
}
else
{
console
.
info
(
'
SensorJsTest001 off success
'
);
expect
(
true
).
assertTrue
();
setTimeout
(()
=>
{
resolve
();
},
500
);
}
},
1000
)
})
}
let
promise
=
new
Promise
((
resolve
,
reject
)
=>
{
sensor
.
on
(
sensor
.
SensorType
.
SENSOR_TYPE_ID_GYROSCOPE_UNCALIBRATED
,
function
(
error
,
data
)
{
if
(
error
)
{
console
.
info
(
'
SensorJsTest001 on error
'
);
expect
(
false
).
assertTrue
();
setTimeout
((
err
)
=>
{
reject
(
err
);
},
500
);
}
else
{
console
.
info
(
'
SensorJsTest001 on success, x:
'
+
data
.
x
+
"
y:
"
+
data
.
y
+
"
z:
"
+
data
.
z
+
"
biasX:
"
+
data
.
biasX
+
"
biasY:
"
+
data
.
biasY
+
"
biasZ:
"
+
data
.
biasZ
);
expect
(
typeof
(
data
.
x
)).
assertEqual
(
"
number
"
);
expect
(
typeof
(
data
.
y
)).
assertEqual
(
"
number
"
);
expect
(
typeof
(
data
.
z
)).
assertEqual
(
"
number
"
);
expect
(
typeof
(
data
.
biasX
)).
assertEqual
(
"
number
"
);
expect
(
typeof
(
data
.
biasY
)).
assertEqual
(
"
number
"
);
expect
(
typeof
(
data
.
biasZ
)).
assertEqual
(
"
number
"
);
setTimeout
(()
=>
{
resolve
();
},
500
);
}
});
})
await
promise
.
then
(()
=>
{
return
offPromise
();
},
()
=>
{
console
.
info
(
"
SensorJsTest001 reject
"
);
})
done
();
})
/*
* @tc.name:SensorJsTest005
* @tc.desc:verify app info is not null
* @tc.type: FUNC
* @tc.require: Issue Number
*/
it
(
"
SensorJsTest005
"
,
0
,
async
function
(
done
)
{
function
onceSensorCallback
(
error
,
data
)
{
if
(
error
)
{
console
.
info
(
'
SensorJsTest005 once error
'
);
expect
(
false
).
assertTrue
();
}
else
{
console
.
info
(
'
SensorJsTest001 on success, x:
'
+
data
.
x
+
"
y:
"
+
data
.
y
+
"
z:
"
+
data
.
z
+
"
biasX:
"
+
data
.
biasX
+
"
biasY:
"
+
data
.
biasY
+
"
biasZ:
"
+
data
.
biasZ
);
expect
(
typeof
(
data
.
x
)).
assertEqual
(
"
number
"
);
expect
(
typeof
(
data
.
y
)).
assertEqual
(
"
number
"
);
expect
(
typeof
(
data
.
z
)).
assertEqual
(
"
number
"
);
expect
(
typeof
(
data
.
biasX
)).
assertEqual
(
"
number
"
);
expect
(
typeof
(
data
.
biasY
)).
assertEqual
(
"
number
"
);
expect
(
typeof
(
data
.
biasZ
)).
assertEqual
(
"
number
"
);
}
setTimeout
(()
=>
{
done
();
},
500
);
}
sensor
.
once
(
sensor
.
SensorType
.
SENSOR_TYPE_ID_GYROSCOPE_UNCALIBRATED
,
onceSensorCallback
);
})
})
sensors/sensor_standard/src/main/js/default/test/SensorOnOffTest.test_harr.js
0 → 100755
浏览文件 @
23b3d674
/*
* Copyright (C) 2021 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import
sensor
from
'
@ohos.sensor
'
import
{
describe
,
beforeAll
,
beforeEach
,
afterEach
,
afterAll
,
it
,
expect
}
from
'
deccjsunit/index
'
describe
(
"
SensorJsTest
"
,
function
()
{
beforeAll
(
function
()
{
/*
* @tc.setup: setup invoked before all testcases
*/
console
.
info
(
'
beforeAll caled
'
)
})
afterAll
(
function
()
{
/*
* @tc.teardown: teardown invoked after all testcases
*/
console
.
info
(
'
afterAll caled
'
)
})
beforeEach
(
function
()
{
/*
* @tc.setup: setup invoked before each testcases
*/
console
.
info
(
'
beforeEach caled
'
)
})
afterEach
(
function
()
{
/*
* @tc.teardown: teardown invoked after each testcases
*/
console
.
info
(
'
afterEach caled
'
)
})
/*
* @tc.name:SensorJsTest001
* @tc.desc:verify app info is not null
* @tc.type: FUNC
* @tc.require: Issue Number
*/
it
(
"
SensorJsTest001
"
,
0
,
async
function
(
done
)
{
console
.
info
(
'
----------------------SensorJsTest001---------------------------
'
);
function
offPromise
()
{
return
new
Promise
((
resolve
,
reject
)
=>
{
sensor
.
off
(
sensor
.
SensorType
.
SENSOR_TYPE_ID_HALL
,
(
error
)
=>
{
if
(
error
)
{
console
.
info
(
'
SensorJsTest001 off error
'
);
expect
(
false
).
assertTrue
();
console
.
info
(
'
setTimeout ..start
'
)
setTimeout
((
err
)
=>
{
reject
(
err
);
},
500
);
}
else
{
console
.
info
(
'
SensorJsTest001 off success
'
);
expect
(
true
).
assertTrue
();
setTimeout
(()
=>
{
resolve
();
},
500
);
}
},
1000
)
})
}
let
promise
=
new
Promise
((
resolve
,
reject
)
=>
{
sensor
.
on
(
sensor
.
SensorType
.
SENSOR_TYPE_ID_HALL
,
function
(
error
,
data
)
{
if
(
error
)
{
console
.
info
(
'
SensorJsTest001 on error
'
);
expect
(
false
).
assertTrue
();
setTimeout
((
err
)
=>
{
reject
(
err
);
},
500
);
}
else
{
console
.
info
(
'
SensorJsTest001 on success status:
'
+
data
.
status
);
expect
(
typeof
(
data
.
status
)).
assertEqual
(
"
number
"
);
setTimeout
(()
=>
{
resolve
();
},
500
);
}
});
})
await
promise
.
then
(()
=>
{
return
offPromise
();
},
()
=>
{
console
.
info
(
"
SensorJsTest001 reject
"
);
})
done
();
})
/*
* @tc.name:SensorJsTest005
* @tc.desc:verify app info is not null
* @tc.type: FUNC
* @tc.require: Issue Number
*/
it
(
"
SensorJsTest005
"
,
0
,
async
function
(
done
)
{
function
onceSensorCallback
(
error
,
data
)
{
if
(
error
)
{
console
.
info
(
'
SensorJsTest005 once error
'
);
expect
(
false
).
assertTrue
();
}
else
{
console
.
info
(
'
SensorJsTest005 once success status:
'
+
data
.
status
);
expect
(
typeof
(
data
.
status
)).
assertEqual
(
"
number
"
);
}
setTimeout
(()
=>
{
done
();
},
500
);
}
sensor
.
once
(
sensor
.
SensorType
.
SENSOR_TYPE_ID_HALL
,
onceSensorCallback
);
})
})
sensors/sensor_standard/src/main/js/default/test/SensorOnOffTest.test_humi.js
0 → 100755
浏览文件 @
23b3d674
/*
* Copyright (C) 2021 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import
sensor
from
'
@ohos.sensor
'
import
{
describe
,
beforeAll
,
beforeEach
,
afterEach
,
afterAll
,
it
,
expect
}
from
'
deccjsunit/index
'
describe
(
"
SensorJsTest
"
,
function
()
{
beforeAll
(
function
()
{
/*
* @tc.setup: setup invoked before all testcases
*/
console
.
info
(
'
beforeAll caled
'
)
})
afterAll
(
function
()
{
/*
* @tc.teardown: teardown invoked after all testcases
*/
console
.
info
(
'
afterAll caled
'
)
})
beforeEach
(
function
()
{
/*
* @tc.setup: setup invoked before each testcases
*/
console
.
info
(
'
beforeEach caled
'
)
})
afterEach
(
function
()
{
/*
* @tc.teardown: teardown invoked after each testcases
*/
console
.
info
(
'
afterEach caled
'
)
})
/*
* @tc.name:SensorJsTest001
* @tc.desc:verify app info is not null
* @tc.type: FUNC
* @tc.require: Issue Number
*/
it
(
"
SensorJsTest001
"
,
0
,
async
function
(
done
)
{
console
.
info
(
'
----------------------SensorJsTest001---------------------------
'
);
function
offPromise
()
{
return
new
Promise
((
resolve
,
reject
)
=>
{
sensor
.
off
(
sensor
.
SensorType
.
SENSOR_TYPE_ID_HUMIDITY
,
(
error
)
=>
{
if
(
error
)
{
console
.
info
(
'
SensorJsTest001 off error
'
);
expect
(
false
).
assertTrue
();
console
.
info
(
'
setTimeout ..start
'
)
setTimeout
((
err
)
=>
{
reject
(
err
);
},
500
);
}
else
{
console
.
info
(
'
SensorJsTest001 off success
'
);
expect
(
true
).
assertTrue
();
setTimeout
(()
=>
{
resolve
();
},
500
);
}
},
1000
)
})
}
let
promise
=
new
Promise
((
resolve
,
reject
)
=>
{
sensor
.
on
(
sensor
.
SensorType
.
SENSOR_TYPE_ID_HUMIDITY
,
function
(
error
,
data
)
{
if
(
error
)
{
console
.
info
(
'
SensorJsTest001 on error
'
);
expect
(
false
).
assertTrue
();
setTimeout
((
err
)
=>
{
reject
(
err
);
},
500
);
}
else
{
console
.
info
(
'
SensorJsTest001 on success humidity:
'
+
data
.
humidity
);
expect
(
typeof
(
data
.
humidity
)).
assertEqual
(
"
number
"
);
setTimeout
(()
=>
{
resolve
();
},
500
);
}
});
})
await
promise
.
then
(()
=>
{
return
offPromise
();
},
()
=>
{
console
.
info
(
"
SensorJsTest001 reject
"
);
})
done
();
})
/*
* @tc.name:SensorJsTest005
* @tc.desc:verify app info is not null
* @tc.type: FUNC
* @tc.require: Issue Number
*/
it
(
"
SensorJsTest005
"
,
0
,
async
function
(
done
)
{
function
onceSensorCallback
(
error
,
data
)
{
if
(
error
)
{
console
.
info
(
'
SensorJsTest005 once error
'
);
expect
(
false
).
assertTrue
();
}
else
{
console
.
info
(
'
SensorJsTest005 once success humidity:
'
+
data
.
humidity
);
expect
(
typeof
(
data
.
humidity
)).
assertEqual
(
"
number
"
);
}
setTimeout
(()
=>
{
done
();
},
500
);
}
sensor
.
once
(
sensor
.
SensorType
.
SENSOR_TYPE_ID_HUMIDITY
,
onceSensorCallback
);
})
})
sensors/sensor_standard/src/main/js/default/test/SensorOnOffTest.test_line_acc.js
0 → 100755
浏览文件 @
23b3d674
/*
* Copyright (C) 2021 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import
sensor
from
'
@ohos.sensor
'
import
{
describe
,
beforeAll
,
beforeEach
,
afterEach
,
afterAll
,
it
,
expect
}
from
'
deccjsunit/index
'
describe
(
"
SensorJsTest
"
,
function
()
{
beforeAll
(
function
()
{
/*
* @tc.setup: setup invoked before all testcases
*/
console
.
info
(
'
beforeAll caled
'
)
})
afterAll
(
function
()
{
/*
* @tc.teardown: teardown invoked after all testcases
*/
console
.
info
(
'
afterAll caled
'
)
})
beforeEach
(
function
()
{
/*
* @tc.setup: setup invoked before each testcases
*/
console
.
info
(
'
beforeEach caled
'
)
})
afterEach
(
function
()
{
/*
* @tc.teardown: teardown invoked after each testcases
*/
console
.
info
(
'
afterEach caled
'
)
})
/*
* @tc.name:SensorJsTest001
* @tc.desc:verify app info is not null
* @tc.type: FUNC
* @tc.require: Issue Number
*/
it
(
"
SensorJsTest001
"
,
0
,
async
function
(
done
)
{
console
.
info
(
'
----------------------SensorJsTest001---------------------------
'
);
function
offPromise
()
{
return
new
Promise
((
resolve
,
reject
)
=>
{
sensor
.
off
(
sensor
.
SensorType
.
SENSOR_TYPE_ID_LINEAR_ACCELERATION
,
(
error
)
=>
{
if
(
error
)
{
console
.
info
(
'
SensorJsTest001 off error
'
);
expect
(
false
).
assertTrue
();
console
.
info
(
'
setTimeout ..start
'
)
setTimeout
((
err
)
=>
{
reject
(
err
);
},
500
);
}
else
{
console
.
info
(
'
SensorJsTest001 off success
'
);
expect
(
true
).
assertTrue
();
setTimeout
(()
=>
{
resolve
();
},
500
);
}
},
1000
)
})
}
let
promise
=
new
Promise
((
resolve
,
reject
)
=>
{
sensor
.
on
(
sensor
.
SensorType
.
SENSOR_TYPE_ID_LINEAR_ACCELERATION
,
function
(
error
,
data
)
{
if
(
error
)
{
console
.
info
(
'
SensorJsTest001 on error
'
);
expect
(
false
).
assertTrue
();
setTimeout
((
err
)
=>
{
reject
(
err
);
},
500
);
}
else
{
console
.
info
(
'
SensorJsTest001 on success, x:
'
+
data
.
x
+
"
y:
"
+
data
.
y
+
"
z:
"
+
data
.
z
);
expect
(
typeof
(
data
.
x
)).
assertEqual
(
"
number
"
);
expect
(
typeof
(
data
.
y
)).
assertEqual
(
"
number
"
);
expect
(
typeof
(
data
.
z
)).
assertEqual
(
"
number
"
);
setTimeout
(()
=>
{
resolve
();
},
500
);
}
});
})
await
promise
.
then
(()
=>
{
return
offPromise
();
},
()
=>
{
console
.
info
(
"
SensorJsTest001 reject
"
);
})
done
();
})
/*
* @tc.name:SensorJsTest005
* @tc.desc:verify app info is not null
* @tc.type: FUNC
* @tc.require: Issue Number
*/
it
(
"
SensorJsTest005
"
,
0
,
async
function
(
done
)
{
function
onceSensorCallback
(
error
,
data
)
{
if
(
error
)
{
console
.
info
(
'
SensorJsTest005 once error
'
);
expect
(
false
).
assertTrue
();
}
else
{
console
.
info
(
'
SensorJsTest001 on success, x:
'
+
data
.
x
+
"
y:
"
+
data
.
y
+
"
z:
"
+
data
.
z
);
expect
(
typeof
(
data
.
x
)).
assertEqual
(
"
number
"
);
expect
(
typeof
(
data
.
y
)).
assertEqual
(
"
number
"
);
expect
(
typeof
(
data
.
z
)).
assertEqual
(
"
number
"
);
}
setTimeout
(()
=>
{
done
();
},
500
);
}
sensor
.
once
(
sensor
.
SensorType
.
SENSOR_TYPE_ID_LINEAR_ACCELERATION
,
onceSensorCallback
);
})
})
sensors/sensor_standard/src/main/js/default/test/SensorOnOffTest.test_moti.js
0 → 100755
浏览文件 @
23b3d674
/*
* Copyright (C) 2021 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import
sensor
from
'
@ohos.sensor
'
import
{
describe
,
beforeAll
,
beforeEach
,
afterEach
,
afterAll
,
it
,
expect
}
from
'
deccjsunit/index
'
describe
(
"
SensorJsTest
"
,
function
()
{
beforeAll
(
function
()
{
/*
* @tc.setup: setup invoked before all testcases
*/
console
.
info
(
'
beforeAll caled
'
)
})
afterAll
(
function
()
{
/*
* @tc.teardown: teardown invoked after all testcases
*/
console
.
info
(
'
afterAll caled
'
)
})
beforeEach
(
function
()
{
/*
* @tc.setup: setup invoked before each testcases
*/
console
.
info
(
'
beforeEach caled
'
)
})
afterEach
(
function
()
{
/*
* @tc.teardown: teardown invoked after each testcases
*/
console
.
info
(
'
afterEach caled
'
)
})
/*
* @tc.name:SensorJsTest001
* @tc.desc:verify app info is not null
* @tc.type: FUNC
* @tc.require: Issue Number
*/
it
(
"
SensorJsTest001
"
,
0
,
async
function
(
done
)
{
console
.
info
(
'
----------------------SensorJsTest001---------------------------
'
);
function
offPromise
()
{
return
new
Promise
((
resolve
,
reject
)
=>
{
sensor
.
off
(
sensor
.
SensorType
.
SENSOR_TYPE_ID_SIGNIFICANT_MOTION
,
(
error
)
=>
{
if
(
error
)
{
console
.
info
(
'
SensorJsTest001 off error
'
);
expect
(
false
).
assertTrue
();
console
.
info
(
'
setTimeout ..start
'
)
setTimeout
((
err
)
=>
{
reject
(
err
);
},
500
);
}
else
{
console
.
info
(
'
SensorJsTest001 off success
'
);
expect
(
true
).
assertTrue
();
setTimeout
(()
=>
{
resolve
();
},
500
);
}
},
1000
)
})
}
let
promise
=
new
Promise
((
resolve
,
reject
)
=>
{
sensor
.
on
(
sensor
.
SensorType
.
SENSOR_TYPE_ID_SIGNIFICANT_MOTION
,
function
(
error
,
data
)
{
if
(
error
)
{
console
.
info
(
'
SensorJsTest001 on error
'
);
expect
(
false
).
assertTrue
();
setTimeout
((
err
)
=>
{
reject
(
err
);
},
500
);
}
else
{
console
.
info
(
'
SensorJsTest001 once success scalar:
'
+
data
.
scalar
);
expect
(
typeof
(
data
.
scalar
)).
assertEqual
(
"
number
"
);
setTimeout
(()
=>
{
resolve
();
},
500
);
}
});
})
await
promise
.
then
(()
=>
{
return
offPromise
();
},
()
=>
{
console
.
info
(
"
SensorJsTest001 reject
"
);
})
done
();
})
/*
* @tc.name:SensorJsTest005
* @tc.desc:verify app info is not null
* @tc.type: FUNC
* @tc.require: Issue Number
*/
it
(
"
SensorJsTest005
"
,
0
,
async
function
(
done
)
{
function
onceSensorCallback
(
error
,
data
)
{
if
(
error
)
{
console
.
info
(
'
SensorJsTest005 once error
'
);
expect
(
false
).
assertTrue
();
}
else
{
console
.
info
(
'
SensorJsTest005 once success scalar:
'
+
data
.
scalar
);
expect
(
typeof
(
data
.
scalar
)).
assertEqual
(
"
number
"
);
}
setTimeout
(()
=>
{
done
();
},
500
);
}
sensor
.
once
(
sensor
.
SensorType
.
SENSOR_TYPE_ID_SIGNIFICANT_MOTION
,
onceSensorCallback
);
})
})
sensors/sensor_standard/src/main/js/default/test/SensorOnOffTest.test_orie.js
0 → 100755
浏览文件 @
23b3d674
/*
* Copyright (C) 2021 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import
sensor
from
'
@ohos.sensor
'
import
{
describe
,
beforeAll
,
beforeEach
,
afterEach
,
afterAll
,
it
,
expect
}
from
'
deccjsunit/index
'
describe
(
"
SensorJsTest
"
,
function
()
{
beforeAll
(
function
()
{
/*
* @tc.setup: setup invoked before all testcases
*/
console
.
info
(
'
beforeAll caled
'
)
})
afterAll
(
function
()
{
/*
* @tc.teardown: teardown invoked after all testcases
*/
console
.
info
(
'
afterAll caled
'
)
})
beforeEach
(
function
()
{
/*
* @tc.setup: setup invoked before each testcases
*/
console
.
info
(
'
beforeEach caled
'
)
})
afterEach
(
function
()
{
/*
* @tc.teardown: teardown invoked after each testcases
*/
console
.
info
(
'
afterEach caled
'
)
})
/*
* @tc.name:SensorJsTest001
* @tc.desc:verify app info is not null
* @tc.type: FUNC
* @tc.require: Issue Number
*/
it
(
"
SensorJsTest001
"
,
0
,
async
function
(
done
)
{
console
.
info
(
'
----------------------SensorJsTest001---------------------------
'
);
function
offPromise
()
{
return
new
Promise
((
resolve
,
reject
)
=>
{
sensor
.
off
(
sensor
.
SensorType
.
SENSOR_TYPE_ID_ORIENTATION
,
(
error
)
=>
{
if
(
error
)
{
console
.
info
(
'
SensorJsTest001 off error
'
);
expect
(
false
).
assertTrue
();
console
.
info
(
'
setTimeout ..start
'
)
setTimeout
((
err
)
=>
{
reject
(
err
);
},
500
);
}
else
{
console
.
info
(
'
SensorJsTest001 off success
'
);
expect
(
true
).
assertTrue
();
setTimeout
(()
=>
{
resolve
();
},
500
);
}
},
1000
)
})
}
let
promise
=
new
Promise
((
resolve
,
reject
)
=>
{
sensor
.
on
(
sensor
.
SensorType
.
SENSOR_TYPE_ID_ORIENTATION
,
function
(
error
,
data
)
{
if
(
error
)
{
console
.
info
(
'
SensorJsTest001 on error
'
);
expect
(
false
).
assertTrue
();
setTimeout
((
err
)
=>
{
reject
(
err
);
},
500
);
}
else
{
console
.
info
(
'
SensorJsTest001 on success, x:
'
+
data
.
x
+
"
y:
"
+
data
.
y
+
"
z:
"
+
data
.
z
);
expect
(
typeof
(
data
.
x
)).
assertEqual
(
"
number
"
);
expect
(
typeof
(
data
.
y
)).
assertEqual
(
"
number
"
);
expect
(
typeof
(
data
.
z
)).
assertEqual
(
"
number
"
);
setTimeout
(()
=>
{
resolve
();
},
500
);
}
});
})
await
promise
.
then
(()
=>
{
return
offPromise
();
},
()
=>
{
console
.
info
(
"
SensorJsTest001 reject
"
);
})
done
();
})
/*
* @tc.name:SensorJsTest005
* @tc.desc:verify app info is not null
* @tc.type: FUNC
* @tc.require: Issue Number
*/
it
(
"
SensorJsTest005
"
,
0
,
async
function
(
done
)
{
function
onceSensorCallback
(
error
,
data
)
{
if
(
error
)
{
console
.
info
(
'
SensorJsTest005 once error
'
);
expect
(
false
).
assertTrue
();
}
else
{
console
.
info
(
'
SensorJsTest001 once success, x:
'
+
data
.
x
+
"
y:
"
+
data
.
y
+
"
z:
"
+
data
.
z
);
expect
(
typeof
(
data
.
x
)).
assertEqual
(
"
number
"
);
expect
(
typeof
(
data
.
y
)).
assertEqual
(
"
number
"
);
expect
(
typeof
(
data
.
z
)).
assertEqual
(
"
number
"
);
}
setTimeout
(()
=>
{
done
();
},
500
);
}
sensor
.
once
(
sensor
.
SensorType
.
SENSOR_TYPE_ID_ORIENTATION
,
onceSensorCallback
);
})
})
sensors/sensor_standard/src/main/js/default/test/SensorOnOffTest.test_ped.js
0 → 100755
浏览文件 @
23b3d674
/*
* Copyright (C) 2021 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import
sensor
from
'
@ohos.sensor
'
import
{
describe
,
beforeAll
,
beforeEach
,
afterEach
,
afterAll
,
it
,
expect
}
from
'
deccjsunit/index
'
describe
(
"
SensorJsTest
"
,
function
()
{
beforeAll
(
function
()
{
/*
* @tc.setup: setup invoked before all testcases
*/
console
.
info
(
'
beforeAll caled
'
)
})
afterAll
(
function
()
{
/*
* @tc.teardown: teardown invoked after all testcases
*/
console
.
info
(
'
afterAll caled
'
)
})
beforeEach
(
function
()
{
/*
* @tc.setup: setup invoked before each testcases
*/
console
.
info
(
'
beforeEach caled
'
)
})
afterEach
(
function
()
{
/*
* @tc.teardown: teardown invoked after each testcases
*/
console
.
info
(
'
afterEach caled
'
)
})
/*
* @tc.name:SensorJsTest001
* @tc.desc:verify app info is not null
* @tc.type: FUNC
* @tc.require: Issue Number
*/
it
(
"
SensorJsTest001
"
,
0
,
async
function
(
done
)
{
console
.
info
(
'
----------------------SensorJsTest001---------------------------
'
);
function
offPromise
()
{
return
new
Promise
((
resolve
,
reject
)
=>
{
sensor
.
off
(
sensor
.
SensorType
.
SENSOR_TYPE_ID_PEDOMETER
,
(
error
)
=>
{
if
(
error
)
{
console
.
info
(
'
SensorJsTest001 off error
'
);
expect
(
false
).
assertTrue
();
console
.
info
(
'
setTimeout ..start
'
)
setTimeout
((
err
)
=>
{
reject
(
err
);
},
500
);
}
else
{
console
.
info
(
'
SensorJsTest001 off success
'
);
expect
(
true
).
assertTrue
();
setTimeout
(()
=>
{
resolve
();
},
500
);
}
},
1000
)
})
}
let
promise
=
new
Promise
((
resolve
,
reject
)
=>
{
sensor
.
on
(
sensor
.
SensorType
.
SENSOR_TYPE_ID_PEDOMETER
,
function
(
error
,
data
)
{
if
(
error
)
{
console
.
info
(
'
SensorJsTest001 on error
'
);
expect
(
false
).
assertTrue
();
setTimeout
((
err
)
=>
{
reject
(
err
);
},
500
);
}
else
{
console
.
info
(
'
SensorJsTest001 once success steps:
'
+
data
.
steps
);
expect
(
typeof
(
data
.
steps
)).
assertEqual
(
"
number
"
);
setTimeout
(()
=>
{
resolve
();
},
500
);
}
});
})
await
promise
.
then
(()
=>
{
return
offPromise
();
},
()
=>
{
console
.
info
(
"
SensorJsTest001 reject
"
);
})
done
();
})
/*
* @tc.name:SensorJsTest005
* @tc.desc:verify app info is not null
* @tc.type: FUNC
* @tc.require: Issue Number
*/
it
(
"
SensorJsTest005
"
,
0
,
async
function
(
done
)
{
function
onceSensorCallback
(
error
,
data
)
{
if
(
error
)
{
console
.
info
(
'
SensorJsTest005 once error
'
);
expect
(
false
).
assertTrue
();
}
else
{
console
.
info
(
'
SensorJsTest005 once success steps:
'
+
data
.
steps
);
expect
(
typeof
(
data
.
steps
)).
assertEqual
(
"
number
"
);
}
setTimeout
(()
=>
{
done
();
},
500
);
}
sensor
.
once
(
sensor
.
SensorType
.
SENSOR_TYPE_ID_PEDOMETER
,
onceSensorCallback
);
})
})
sensors/sensor_standard/src/main/js/default/test/SensorOnOffTest.test_ped_det.js
0 → 100755
浏览文件 @
23b3d674
/*
* Copyright (C) 2021 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import
sensor
from
'
@ohos.sensor
'
import
{
describe
,
beforeAll
,
beforeEach
,
afterEach
,
afterAll
,
it
,
expect
}
from
'
deccjsunit/index
'
describe
(
"
SensorJsTest
"
,
function
()
{
beforeAll
(
function
()
{
/*
* @tc.setup: setup invoked before all testcases
*/
console
.
info
(
'
beforeAll caled
'
)
})
afterAll
(
function
()
{
/*
* @tc.teardown: teardown invoked after all testcases
*/
console
.
info
(
'
afterAll caled
'
)
})
beforeEach
(
function
()
{
/*
* @tc.setup: setup invoked before each testcases
*/
console
.
info
(
'
beforeEach caled
'
)
})
afterEach
(
function
()
{
/*
* @tc.teardown: teardown invoked after each testcases
*/
console
.
info
(
'
afterEach caled
'
)
})
/*
* @tc.name:SensorJsTest001
* @tc.desc:verify app info is not null
* @tc.type: FUNC
* @tc.require: Issue Number
*/
it
(
"
SensorJsTest001
"
,
0
,
async
function
(
done
)
{
console
.
info
(
'
----------------------SensorJsTest001---------------------------
'
);
function
offPromise
()
{
return
new
Promise
((
resolve
,
reject
)
=>
{
sensor
.
off
(
sensor
.
SensorType
.
SENSOR_TYPE_ID_PEDOMETER_DETECTION
,
(
error
)
=>
{
if
(
error
)
{
console
.
info
(
'
SensorJsTest001 off error
'
);
expect
(
false
).
assertTrue
();
console
.
info
(
'
setTimeout ..start
'
)
setTimeout
((
err
)
=>
{
reject
(
err
);
},
500
);
}
else
{
console
.
info
(
'
SensorJsTest001 off success
'
);
expect
(
true
).
assertTrue
();
setTimeout
(()
=>
{
resolve
();
},
500
);
}
},
1000
)
})
}
let
promise
=
new
Promise
((
resolve
,
reject
)
=>
{
sensor
.
on
(
sensor
.
SensorType
.
SENSOR_TYPE_ID_PEDOMETER_DETECTION
,
function
(
error
,
data
)
{
if
(
error
)
{
console
.
info
(
'
SensorJsTest001 on error
'
);
expect
(
false
).
assertTrue
();
setTimeout
((
err
)
=>
{
reject
(
err
);
},
500
);
}
else
{
console
.
info
(
'
SensorJsTest001 once success scalar:
'
+
data
.
scalar
);
expect
(
typeof
(
data
.
scalar
)).
assertEqual
(
"
number
"
);
setTimeout
(()
=>
{
resolve
();
},
500
);
}
});
})
await
promise
.
then
(()
=>
{
return
offPromise
();
},
()
=>
{
console
.
info
(
"
SensorJsTest001 reject
"
);
})
done
();
})
/*
* @tc.name:SensorJsTest005
* @tc.desc:verify app info is not null
* @tc.type: FUNC
* @tc.require: Issue Number
*/
it
(
"
SensorJsTest005
"
,
0
,
async
function
(
done
)
{
function
onceSensorCallback
(
error
,
data
)
{
if
(
error
)
{
console
.
info
(
'
SensorJsTest005 once error
'
);
expect
(
false
).
assertTrue
();
}
else
{
console
.
info
(
'
SensorJsTest005 once success scalar:
'
+
data
.
scalar
);
expect
(
typeof
(
data
.
scalar
)).
assertEqual
(
"
number
"
);
}
setTimeout
(()
=>
{
done
();
},
500
);
}
sensor
.
once
(
sensor
.
SensorType
.
SENSOR_TYPE_ID_PEDOMETER_DETECTION
,
onceSensorCallback
);
})
})
sensors/sensor_standard/src/main/js/default/test/SensorOnOffTest.test_prox.js
0 → 100755
浏览文件 @
23b3d674
/*
* Copyright (C) 2021 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import
sensor
from
'
@ohos.sensor
'
import
{
describe
,
beforeAll
,
beforeEach
,
afterEach
,
afterAll
,
it
,
expect
}
from
'
deccjsunit/index
'
describe
(
"
SensorJsTest
"
,
function
()
{
beforeAll
(
function
()
{
/*
* @tc.setup: setup invoked before all testcases
*/
console
.
info
(
'
beforeAll caled
'
)
})
afterAll
(
function
()
{
/*
* @tc.teardown: teardown invoked after all testcases
*/
console
.
info
(
'
afterAll caled
'
)
})
beforeEach
(
function
()
{
/*
* @tc.setup: setup invoked before each testcases
*/
console
.
info
(
'
beforeEach caled
'
)
})
afterEach
(
function
()
{
/*
* @tc.teardown: teardown invoked after each testcases
*/
console
.
info
(
'
afterEach caled
'
)
})
/*
* @tc.name:SensorJsTest001
* @tc.desc:verify app info is not null
* @tc.type: FUNC
* @tc.require: Issue Number
*/
it
(
"
SensorJsTest001
"
,
0
,
async
function
(
done
)
{
console
.
info
(
'
----------------------SensorJsTest001---------------------------
'
);
function
offPromise
()
{
return
new
Promise
((
resolve
,
reject
)
=>
{
sensor
.
off
(
sensor
.
SensorType
.
SENSOR_TYPE_ID_PROXIMITY
,
(
error
)
=>
{
if
(
error
)
{
console
.
info
(
'
SensorJsTest001 off error
'
);
expect
(
false
).
assertTrue
();
console
.
info
(
'
setTimeout ..start
'
)
setTimeout
((
err
)
=>
{
reject
(
err
);
},
500
);
}
else
{
console
.
info
(
'
SensorJsTest001 off success
'
);
expect
(
true
).
assertTrue
();
setTimeout
(()
=>
{
resolve
();
},
500
);
}
},
1000
)
})
}
let
promise
=
new
Promise
((
resolve
,
reject
)
=>
{
sensor
.
on
(
sensor
.
SensorType
.
SENSOR_TYPE_ID_PROXIMITY
,
function
(
error
,
data
)
{
if
(
error
)
{
console
.
info
(
'
SensorJsTest001 on error
'
);
expect
(
false
).
assertTrue
();
setTimeout
((
err
)
=>
{
reject
(
err
);
},
500
);
}
else
{
console
.
info
(
'
SensorJsTest001 on success distance:
'
+
data
.
distance
);
expect
(
typeof
(
data
.
distance
)).
assertEqual
(
"
number
"
);
setTimeout
(()
=>
{
resolve
();
},
500
);
}
});
})
await
promise
.
then
(()
=>
{
return
offPromise
();
},
()
=>
{
console
.
info
(
"
SensorJsTest001 reject
"
);
})
done
();
})
/*
* @tc.name:SensorJsTest005
* @tc.desc:verify app info is not null
* @tc.type: FUNC
* @tc.require: Issue Number
*/
it
(
"
SensorJsTest005
"
,
0
,
async
function
(
done
)
{
function
onceSensorCallback
(
error
,
data
)
{
if
(
error
)
{
console
.
info
(
'
SensorJsTest005 once error
'
);
expect
(
false
).
assertTrue
();
}
else
{
console
.
info
(
'
SensorJsTest005 once success distance:
'
+
data
.
distance
);
expect
(
typeof
(
data
.
distance
)).
assertEqual
(
"
number
"
);
}
setTimeout
(()
=>
{
done
();
},
500
);
}
sensor
.
once
(
sensor
.
SensorType
.
SENSOR_TYPE_ID_PROXIMITY
,
onceSensorCallback
);
})
})
sensors/sensor_standard/src/main/js/default/test/SensorOnOffTest.test_rate.js
0 → 100755
浏览文件 @
23b3d674
/*
* Copyright (C) 2021 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import
sensor
from
'
@ohos.sensor
'
import
{
describe
,
beforeAll
,
beforeEach
,
afterEach
,
afterAll
,
it
,
expect
}
from
'
deccjsunit/index
'
describe
(
"
SensorJsTest
"
,
function
()
{
beforeAll
(
function
()
{
/*
* @tc.setup: setup invoked before all testcases
*/
console
.
info
(
'
beforeAll caled
'
)
})
afterAll
(
function
()
{
/*
* @tc.teardown: teardown invoked after all testcases
*/
console
.
info
(
'
afterAll caled
'
)
})
beforeEach
(
function
()
{
/*
* @tc.setup: setup invoked before each testcases
*/
console
.
info
(
'
beforeEach caled
'
)
})
afterEach
(
function
()
{
/*
* @tc.teardown: teardown invoked after each testcases
*/
console
.
info
(
'
afterEach caled
'
)
})
/*
* @tc.name:SensorJsTest001
* @tc.desc:verify app info is not null
* @tc.type: FUNC
* @tc.require: Issue Number
*/
it
(
"
SensorJsTest001
"
,
0
,
async
function
(
done
)
{
console
.
info
(
'
----------------------SensorJsTest001---------------------------
'
);
function
offPromise
()
{
return
new
Promise
((
resolve
,
reject
)
=>
{
sensor
.
off
(
sensor
.
SensorType
.
SENSOR_TYPE_ID_HEART_RATE
,
(
error
)
=>
{
if
(
error
)
{
console
.
info
(
'
SensorJsTest001 off error
'
);
expect
(
false
).
assertTrue
();
console
.
info
(
'
setTimeout ..start
'
)
setTimeout
((
err
)
=>
{
reject
(
err
);
},
500
);
}
else
{
console
.
info
(
'
SensorJsTest001 off success
'
);
expect
(
true
).
assertTrue
();
setTimeout
(()
=>
{
resolve
();
},
500
);
}
},
1000
)
})
}
let
promise
=
new
Promise
((
resolve
,
reject
)
=>
{
sensor
.
on
(
sensor
.
SensorType
.
SENSOR_TYPE_ID_HEART_RATE
,
function
(
error
,
data
)
{
if
(
error
)
{
console
.
info
(
'
SensorJsTest001 on error
'
);
expect
(
false
).
assertTrue
();
setTimeout
((
err
)
=>
{
reject
(
err
);
},
500
);
}
else
{
console
.
info
(
'
SensorJsTest001 once success heartRate:
'
+
data
.
heartRate
);
expect
(
typeof
(
data
.
heartRate
)).
assertEqual
(
"
number
"
);
setTimeout
(()
=>
{
resolve
();
},
500
);
}
});
})
await
promise
.
then
(()
=>
{
return
offPromise
();
},
()
=>
{
console
.
info
(
"
SensorJsTest001 reject
"
);
})
done
();
})
/*
* @tc.name:SensorJsTest005
* @tc.desc:verify app info is not null
* @tc.type: FUNC
* @tc.require: Issue Number
*/
it
(
"
SensorJsTest005
"
,
0
,
async
function
(
done
)
{
function
onceSensorCallback
(
error
,
data
)
{
if
(
error
)
{
console
.
info
(
'
SensorJsTest005 once error
'
);
expect
(
false
).
assertTrue
();
}
else
{
console
.
info
(
'
SensorJsTest005 once success heartRate:
'
+
data
.
heartRate
);
expect
(
typeof
(
data
.
heartRate
)).
assertEqual
(
"
number
"
);
}
setTimeout
(()
=>
{
done
();
},
500
);
}
sensor
.
once
(
sensor
.
SensorType
.
SENSOR_TYPE_ID_HEART_RATE
,
onceSensorCallback
);
})
})
sensors/sensor_standard/src/main/js/default/test/SensorOnOffTest.test_temp.js
0 → 100755
浏览文件 @
23b3d674
/*
* Copyright (C) 2021 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import
sensor
from
'
@ohos.sensor
'
import
{
describe
,
beforeAll
,
beforeEach
,
afterEach
,
afterAll
,
it
,
expect
}
from
'
deccjsunit/index
'
describe
(
"
SensorJsTest
"
,
function
()
{
beforeAll
(
function
()
{
/*
* @tc.setup: setup invoked before all testcases
*/
console
.
info
(
'
beforeAll caled
'
)
})
afterAll
(
function
()
{
/*
* @tc.teardown: teardown invoked after all testcases
*/
console
.
info
(
'
afterAll caled
'
)
})
beforeEach
(
function
()
{
/*
* @tc.setup: setup invoked before each testcases
*/
console
.
info
(
'
beforeEach caled
'
)
})
afterEach
(
function
()
{
/*
* @tc.teardown: teardown invoked after each testcases
*/
console
.
info
(
'
afterEach caled
'
)
})
/*
* @tc.name:SensorJsTest001
* @tc.desc:verify app info is not null
* @tc.type: FUNC
* @tc.require: Issue Number
*/
it
(
"
SensorJsTest001
"
,
0
,
async
function
(
done
)
{
console
.
info
(
'
----------------------SensorJsTest001---------------------------
'
);
function
offPromise
()
{
return
new
Promise
((
resolve
,
reject
)
=>
{
sensor
.
off
(
sensor
.
SensorType
.
SENSOR_TYPE_ID_AMBIENT_TEMPERATURE
,
(
error
)
=>
{
if
(
error
)
{
console
.
info
(
'
SensorJsTest001 off error
'
);
expect
(
false
).
assertTrue
();
console
.
info
(
'
setTimeout ..start
'
)
setTimeout
((
err
)
=>
{
reject
(
err
);
},
500
);
}
else
{
console
.
info
(
'
SensorJsTest001 off success
'
);
expect
(
true
).
assertTrue
();
setTimeout
(()
=>
{
resolve
();
},
500
);
}
},
1000
)
})
}
let
promise
=
new
Promise
((
resolve
,
reject
)
=>
{
sensor
.
on
(
sensor
.
SensorType
.
SENSOR_TYPE_ID_AMBIENT_TEMPERATURE
,
function
(
error
,
data
)
{
if
(
error
)
{
console
.
info
(
'
SensorJsTest001 on error
'
);
expect
(
false
).
assertTrue
();
setTimeout
((
err
)
=>
{
reject
(
err
);
},
500
);
}
else
{
console
.
info
(
'
SensorJsTest001 once success temperature:
'
+
data
.
temperature
);
expect
(
typeof
(
data
.
temperature
)).
assertEqual
(
"
number
"
);
setTimeout
(()
=>
{
resolve
();
},
500
);
}
});
})
await
promise
.
then
(()
=>
{
return
offPromise
();
},
()
=>
{
console
.
info
(
"
SensorJsTest001 reject
"
);
})
done
();
})
/*
* @tc.name:SensorJsTest005
* @tc.desc:verify app info is not null
* @tc.type: FUNC
* @tc.require: Issue Number
*/
it
(
"
SensorJsTest005
"
,
0
,
async
function
(
done
)
{
function
onceSensorCallback
(
error
,
data
)
{
if
(
error
)
{
console
.
info
(
'
SensorJsTest005 once error
'
);
expect
(
false
).
assertTrue
();
}
else
{
console
.
info
(
'
SensorJsTest005 once success temperature:
'
+
data
.
temperature
);
expect
(
typeof
(
data
.
temperature
)).
assertEqual
(
"
number
"
);
}
setTimeout
(()
=>
{
done
();
},
500
);
}
sensor
.
once
(
sensor
.
SensorType
.
SENSOR_TYPE_ID_AMBIENT_TEMPERATURE
,
onceSensorCallback
);
})
})
sensors/sensor_standard/src/main/js/default/test/SensorOnOffTest.test_vec.js
0 → 100755
浏览文件 @
23b3d674
/*
* Copyright (C) 2021 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import
sensor
from
'
@ohos.sensor
'
import
{
describe
,
beforeAll
,
beforeEach
,
afterEach
,
afterAll
,
it
,
expect
}
from
'
deccjsunit/index
'
describe
(
"
SensorJsTest
"
,
function
()
{
beforeAll
(
function
()
{
/*
* @tc.setup: setup invoked before all testcases
*/
console
.
info
(
'
beforeAll caled
'
)
})
afterAll
(
function
()
{
/*
* @tc.teardown: teardown invoked after all testcases
*/
console
.
info
(
'
afterAll caled
'
)
})
beforeEach
(
function
()
{
/*
* @tc.setup: setup invoked before each testcases
*/
console
.
info
(
'
beforeEach caled
'
)
})
afterEach
(
function
()
{
/*
* @tc.teardown: teardown invoked after each testcases
*/
console
.
info
(
'
afterEach caled
'
)
})
/*
* @tc.name:SensorJsTest001
* @tc.desc:verify app info is not null
* @tc.type: FUNC
* @tc.require: Issue Number
*/
it
(
"
SensorJsTest001
"
,
0
,
async
function
(
done
)
{
console
.
info
(
'
----------------------SensorJsTest001---------------------------
'
);
function
offPromise
()
{
return
new
Promise
((
resolve
,
reject
)
=>
{
sensor
.
off
(
sensor
.
SensorType
.
SENSOR_TYPE_ID_ROTATION_VECTOR
,
(
error
)
=>
{
if
(
error
)
{
console
.
info
(
'
SensorJsTest001 off error
'
);
expect
(
false
).
assertTrue
();
console
.
info
(
'
setTimeout ..start
'
)
setTimeout
((
err
)
=>
{
reject
(
err
);
},
500
);
}
else
{
console
.
info
(
'
SensorJsTest001 off success
'
);
expect
(
true
).
assertTrue
();
setTimeout
(()
=>
{
resolve
();
},
500
);
}
},
1000
)
})
}
let
promise
=
new
Promise
((
resolve
,
reject
)
=>
{
sensor
.
on
(
sensor
.
SensorType
.
SENSOR_TYPE_ID_ROTATION_VECTOR
,
function
(
error
,
data
)
{
if
(
error
)
{
console
.
info
(
'
SensorJsTest001 on error
'
);
expect
(
false
).
assertTrue
();
setTimeout
((
err
)
=>
{
reject
(
err
);
},
500
);
}
else
{
console
.
info
(
'
SensorJsTest001 on success, x:
'
+
data
.
x
+
"
y:
"
+
data
.
y
+
"
z:
"
+
data
.
z
);
expect
(
typeof
(
data
.
x
)).
assertEqual
(
"
number
"
);
expect
(
typeof
(
data
.
y
)).
assertEqual
(
"
number
"
);
expect
(
typeof
(
data
.
z
)).
assertEqual
(
"
number
"
);
setTimeout
(()
=>
{
resolve
();
},
500
);
}
});
})
await
promise
.
then
(()
=>
{
return
offPromise
();
},
()
=>
{
console
.
info
(
"
SensorJsTest001 reject
"
);
})
done
();
})
/*
* @tc.name:SensorJsTest005
* @tc.desc:verify app info is not null
* @tc.type: FUNC
* @tc.require: Issue Number
*/
it
(
"
SensorJsTest005
"
,
0
,
async
function
(
done
)
{
function
onceSensorCallback
(
error
,
data
)
{
if
(
error
)
{
console
.
info
(
'
SensorJsTest005 once error
'
);
expect
(
false
).
assertTrue
();
}
else
{
console
.
info
(
'
SensorJsTest001 on success, x:
'
+
data
.
x
+
"
y:
"
+
data
.
y
+
"
z:
"
+
data
.
z
);
expect
(
typeof
(
data
.
x
)).
assertEqual
(
"
number
"
);
expect
(
typeof
(
data
.
y
)).
assertEqual
(
"
number
"
);
expect
(
typeof
(
data
.
z
)).
assertEqual
(
"
number
"
);
}
setTimeout
(()
=>
{
done
();
},
500
);
}
sensor
.
once
(
sensor
.
SensorType
.
SENSOR_TYPE_ID_ROTATION_VECTOR
,
onceSensorCallback
);
})
})
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录