Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
OpenHarmony
Xts Acts
提交
c209d682
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看板
提交
c209d682
编写于
5月 24, 2022
作者:
L
lidanyang16
1
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
<lidanyang16@huawei.com>
Signed-off-by:
N
lidanyang16
<
lidanyang16@huawei.com
>
上级
5ae53070
变更
11
隐藏空白更改
内联
并排
Showing
11 changed file
with
3490 addition
and
0 deletion
+3490
-0
sensors/sensor_standard/src/main/js/default/test/Accelerometer.js
...sensor_standard/src/main/js/default/test/Accelerometer.js
+331
-0
sensors/sensor_standard/src/main/js/default/test/GyroScope.js
...ors/sensor_standard/src/main/js/default/test/GyroScope.js
+327
-0
sensors/sensor_standard/src/main/js/default/test/Hall.js
sensors/sensor_standard/src/main/js/default/test/Hall.js
+315
-0
sensors/sensor_standard/src/main/js/default/test/getOnBodyState.js
...ensor_standard/src/main/js/default/test/getOnBodyState.js
+321
-0
sensors/sensor_standard/src/main/js/default/test/subscribeBarometer.js
...r_standard/src/main/js/default/test/subscribeBarometer.js
+287
-0
sensors/sensor_standard/src/main/js/default/test/subscribeCompass.js
...sor_standard/src/main/js/default/test/subscribeCompass.js
+318
-0
sensors/sensor_standard/src/main/js/default/test/subscribeDeviceOrientation.js
...rd/src/main/js/default/test/subscribeDeviceOrientation.js
+447
-0
sensors/sensor_standard/src/main/js/default/test/subscribeHeartRate.js
...r_standard/src/main/js/default/test/subscribeHeartRate.js
+286
-0
sensors/sensor_standard/src/main/js/default/test/subscribeOnBodyState.js
...standard/src/main/js/default/test/subscribeOnBodyState.js
+287
-0
sensors/sensor_standard/src/main/js/default/test/subscribeProximity.js
...r_standard/src/main/js/default/test/subscribeProximity.js
+286
-0
sensors/sensor_standard/src/main/js/default/test/subscribeStepCounter.js
...standard/src/main/js/default/test/subscribeStepCounter.js
+285
-0
未找到文件。
sensors/sensor_standard/src/main/js/default/test/Accelerometer.js
0 → 100644
浏览文件 @
c209d682
/*
* Copyright (C) 2021 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import
sensor
from
'
@ohos.sensor
'
import
{
describe
,
beforeAll
,
beforeEach
,
afterEach
,
afterAll
,
it
,
expect
}
from
'
deccjsunit/index
'
describe
(
"
SensorJsTest
"
,
function
()
{
function
callback
(
data
)
{
console
.
info
(
"
callback
"
+
JSON
.
stringify
(
data
));
expect
(
typeof
(
data
.
x
)).
assertEqual
(
"
number
"
);
expect
(
typeof
(
data
.
y
)).
assertEqual
(
"
number
"
);
expect
(
typeof
(
data
.
z
)).
assertEqual
(
"
number
"
);
}
function
callback2
(
data
)
{
console
.
info
(
"
callback2
"
+
JSON
.
stringify
(
data
));
expect
(
typeof
(
data
.
x
)).
assertEqual
(
"
number
"
);
expect
(
typeof
(
data
.
y
)).
assertEqual
(
"
number
"
);
expect
(
typeof
(
data
.
z
)).
assertEqual
(
"
number
"
);
}
beforeAll
(
function
()
{
/*
* @tc.setup: setup invoked before all testcases
*/
console
.
info
(
'
beforeAll caled
'
)
})
afterAll
(
function
()
{
/*
* @tc.teardown: teardown invoked after all testcases
*/
console
.
info
(
'
afterAll caled
'
)
})
beforeEach
(
function
()
{
/*
* @tc.setup: setup invoked before each testcases
*/
console
.
info
(
'
beforeEach caled
'
)
})
afterEach
(
function
()
{
/*
* @tc.teardown: teardown invoked after each testcases
*/
console
.
info
(
'
afterEach caled
'
)
})
let
errMessages
=
[
'
The number of parameters is not valid
'
,
'
Should subscribe first
'
,
'
string is not defined
'
];
let
errMessage
;
/*
* @tc.name:Accelerometer_SensorJsTest001
* @tc.desc:verify app info is not null
* @tc.type: FUNC
* @tc.require: Issue Number
*/
it
(
"
Accelerometer_SensorJsTest001
"
,
0
,
async
function
(
done
)
{
console
.
info
(
'
----------------------Accelerometer_SensorJsTest001---------------------------
'
);
sensor
.
on
(
sensor
.
SensorType
.
SENSOR_TYPE_ID_ACCELEROMETER
,
callback
);
setTimeout
(()
=>
{
sensor
.
off
(
sensor
.
SensorType
.
SENSOR_TYPE_ID_ACCELEROMETER
);
done
();
},
500
);
})
/*
* @tc.name:Accelerometer_SensorJsTest002
* @tc.desc:verify app info is not null
* @tc.type: FUNC
* @tc.require: Issue Number
*/
it
(
"
Accelerometer_SensorJsTest002
"
,
0
,
async
function
(
done
)
{
console
.
info
(
'
----------------------Accelerometer_SensorJsTest002---------------------------
'
);
sensor
.
on
(
sensor
.
SensorType
.
SENSOR_TYPE_ID_ACCELEROMETER
,
callback
,
{
'
interval
'
:
100000000
});
setTimeout
(()
=>
{
console
.
info
(
'
----------------------Accelerometer_SensorJsTest002 off in---------------------------
'
);
sensor
.
off
(
sensor
.
SensorType
.
SENSOR_TYPE_ID_ACCELEROMETER
);
console
.
info
(
'
----------------------Accelerometer_SensorJsTest002 off end---------------------------
'
);
done
();
},
500
);
})
/*
* @tc.name:Accelerometer_SensorJsTest003
* @tc.desc:verify app info is not null
* @tc.type: FUNC
* @tc.require: Issue Number
*/
it
(
"
Accelerometer_SensorJsTest003
"
,
0
,
async
function
(
done
)
{
console
.
info
(
'
----------------------Accelerometer_SensorJsTest003---------------------------
'
);
function
onSensorCallback
(
data
)
{
console
.
info
(
'
Accelerometer_SensorJsTest003 on error
'
);
expect
(
false
).
assertTrue
();
done
();
}
try
{
sensor
.
on
(
sensor
.
SensorType
.
SENSOR_TYPE_ID_ACCELEROMETER
,
onSensorCallback
,
{
'
interval
'
:
100000000
},
5
);
}
catch
(
error
)
{
console
.
info
(
"
Accelerometer_SensorJsTest003 error:
"
+
error
);
errMessage
=
error
.
toString
().
slice
(
12
,
49
);
expect
(
errMessage
).
assertEqual
(
errMessages
[
0
]);
done
();
}
})
/*
* @tc.name:Accelerometer_SensorJsTest004
* @tc.desc:verify app info is not null
* @tc.type: FUNC
* @tc.require: Issue Number
*/
it
(
"
Accelerometer_SensorJsTest004
"
,
0
,
async
function
(
done
)
{
console
.
info
(
'
----------------------Accelerometer_SensorJsTest004---------------------------
'
);
sensor
.
once
(
sensor
.
SensorType
.
SENSOR_TYPE_ID_ACCELEROMETER
,
callback
);
setTimeout
(()
=>
{
expect
(
true
).
assertTrue
();
done
();
},
500
);
})
/*
* @tc.name:Accelerometer_SensorJsTest005
* @tc.desc:verify app info is not null
* @tc.type: FUNC
* @tc.require: Issue Number
*/
it
(
"
Accelerometer_SensorJsTest005
"
,
0
,
async
function
(
done
)
{
console
.
info
(
'
----------------------Accelerometer_SensorJsTest005---------------------------
'
);
function
onceSensorCallback
(
data
)
{
console
.
info
(
'
Accelerometer_SensorJsTest005 on error
'
);
expect
(
false
).
assertTrue
();
done
();
}
try
{
sensor
.
once
(
sensor
.
SensorType
.
SENSOR_TYPE_ID_ACCELEROMETER
,
onceSensorCallback
,
5
);
}
catch
(
error
)
{
console
.
info
(
"
Accelerometer_SensorJsTest005 error:
"
+
error
);
errMessage
=
error
.
toString
().
slice
(
14
,
51
);
expect
(
errMessage
).
assertEqual
(
errMessages
[
0
]);
done
();
}
})
/*
* @tc.name:Accelerometer_SensorJsTest006
* @tc.desc:verify app info is not null
* @tc.type: FUNC
* @tc.require: Issue Number
*/
it
(
"
Accelerometer_SensorJsTest006
"
,
0
,
async
function
(
done
)
{
console
.
info
(
'
----------------------Accelerometer_SensorJsTest006---------------------------
'
);
try
{
sensor
.
off
(
string
,
""
);
}
catch
(
error
)
{
console
.
info
(
"
Accelerometer_SensorJsTest006 error:
"
+
error
);
errMessage
=
error
.
toString
().
slice
(
16
,
40
);
expect
(
errMessage
).
assertEqual
(
errMessages
[
2
]);
done
();
}
})
/*
* @tc.name:Accelerometer_SensorJsTest007
* @tc.desc:verify app info is not null
* @tc.type: FUNC
* @tc.require: Issue Number
*/
it
(
"
Accelerometer_SensorJsTest007
"
,
0
,
async
function
(
done
)
{
console
.
info
(
'
----------------------Accelerometer_SensorJsTest007---------------------------
'
);
function
onSensorCallback
(
data
)
{
console
.
info
(
'
Accelerometer_SensorJsTest007 on error
'
);
expect
(
false
).
assertTrue
();
done
();
}
sensor
.
on
(
sensor
.
SensorType
.
SENSOR_TYPE_ID_ACCELEROMETER
,
onSensorCallback
);
sensor
.
off
(
sensor
.
SensorType
.
SENSOR_TYPE_ID_ACCELEROMETER
,
onSensorCallback
);
setTimeout
(()
=>
{
expect
(
true
).
assertTrue
();
done
();
},
500
);
})
/*
* @tc.name:Accelerometer_SensorJsTest008
* @tc.desc:verify app info is not null
* @tc.type: FUNC
* @tc.require: Issue Number
*/
it
(
"
Accelerometer_SensorJsTest008
"
,
0
,
async
function
(
done
)
{
console
.
info
(
'
----------------------Accelerometer_SensorJsTest008---------------------------
'
);
function
onSensorCallback
(
data
)
{
console
.
info
(
'
Accelerometer_SensorJsTest008 on error
'
);
expect
(
false
).
assertTrue
();
done
();
}
try
{
sensor
.
off
(
1000000
,
onSensorCallback
);
}
catch
(
error
)
{
console
.
info
(
"
Accelerometer_SensorJsTest008 error:
"
+
error
);
errMessage
=
error
.
toString
().
slice
(
13
,
35
);
expect
(
errMessage
).
assertEqual
(
errMessages
[
1
]);
done
();
}
})
/*
* @tc.name:Accelerometer_SensorJsTest009
* @tc.desc:verify app info is not null
* @tc.type: FUNC
* @tc.require: Issue Number
*/
it
(
"
Accelerometer_SensorJsTest009
"
,
0
,
async
function
(
done
)
{
console
.
info
(
'
----------------------Accelerometer_SensorJsTest009---------------------------
'
);
sensor
.
on
(
sensor
.
SensorType
.
SENSOR_TYPE_ID_ACCELEROMETER
,
callback
);
sensor
.
on
(
sensor
.
SensorType
.
SENSOR_TYPE_ID_ACCELEROMETER
,
callback2
);
setTimeout
(()
=>
{
console
.
info
(
'
----------------------Accelerometer_SensorJsTest009 off in---------------------------
'
);
sensor
.
off
(
sensor
.
SensorType
.
SENSOR_TYPE_ID_ACCELEROMETER
);
console
.
info
(
'
----------------------Accelerometer_SensorJsTest009 off end---------------------------
'
);
done
();
},
1000
);
})
/*
* @tc.name:Accelerometer_SensorJsTest010
* @tc.desc:verify app info is not null
* @tc.type: FUNC
* @tc.require: Issue Number
*/
it
(
"
Accelerometer_SensorJsTest010
"
,
0
,
async
function
(
done
)
{
console
.
info
(
'
----------------------Accelerometer_SensorJsTest010---------------------------
'
);
sensor
.
on
(
sensor
.
SensorType
.
SENSOR_TYPE_ID_ACCELEROMETER
,
callback
);
sensor
.
on
(
sensor
.
SensorType
.
SENSOR_TYPE_ID_ACCELEROMETER
,
callback2
);
setTimeout
(()
=>
{
console
.
info
(
'
----------------------Accelerometer_SensorJsTest010 off in---------------------------
'
);
sensor
.
off
(
sensor
.
SensorType
.
SENSOR_TYPE_ID_ACCELEROMETER
,
callback
);
console
.
info
(
'
----------------------Accelerometer_SensorJsTest010 off end---------------------------
'
);
},
500
);
setTimeout
(()
=>
{
console
.
info
(
'
----------------------Accelerometer_SensorJsTest010 off in---------------------------
'
);
sensor
.
off
(
sensor
.
SensorType
.
SENSOR_TYPE_ID_ACCELEROMETER
,
callback2
);
console
.
info
(
'
----------------------Accelerometer_SensorJsTest010 off end---------------------------
'
);
done
();
},
1000
);
})
/*
* @tc.name:Accelerometer_SensorJsTest011
* @tc.desc:verify app info is not null
* @tc.type: FUNC
* @tc.require: Issue Number
*/
it
(
"
Accelerometer_SensorJsTest011
"
,
0
,
async
function
(
done
)
{
console
.
info
(
'
----------------------Accelerometer_SensorJsTest011---------------------------
'
);
sensor
.
on
(
sensor
.
SensorType
.
SENSOR_TYPE_ID_ACCELEROMETER
,
callback
,
{
'
interval
'
:
100000000
});
sensor
.
once
(
sensor
.
SensorType
.
SENSOR_TYPE_ID_ACCELEROMETER
,
callback2
);
setTimeout
(()
=>
{
console
.
info
(
'
----------------------Accelerometer_SensorJsTest011 off in---------------------------
'
);
sensor
.
off
(
sensor
.
SensorType
.
SENSOR_TYPE_ID_ACCELEROMETER
);
console
.
info
(
'
----------------------Accelerometer_SensorJsTest011 off end---------------------------
'
);
done
();
},
1000
);
})
/*
* @tc.name:Accelerometer_SensorJsTest012
* @tc.desc:verify app info is not null
* @tc.type: FUNC
* @tc.require: Issue Number
*/
it
(
"
Accelerometer_SensorJsTest012
"
,
0
,
async
function
(
done
)
{
console
.
info
(
'
----------------------Accelerometer_SensorJsTest012---------------------------
'
);
sensor
.
on
(
sensor
.
SensorType
.
SENSOR_TYPE_ID_ACCELEROMETER
,
callback
,
{
'
interval
'
:
100000000
});
sensor
.
on
(
sensor
.
SensorType
.
SENSOR_TYPE_ID_ACCELEROMETER
,
callback2
,
{
'
interval
'
:
100000000
});
setTimeout
(()
=>
{
console
.
info
(
'
----------------------Accelerometer_SensorJsTest012 off in---------------------------
'
);
sensor
.
off
(
sensor
.
SensorType
.
SENSOR_TYPE_ID_ACCELEROMETER
,
callback
);
console
.
info
(
'
----------------------Accelerometer_SensorJsTest012 off end---------------------------
'
);
},
500
);
setTimeout
(()
=>
{
console
.
info
(
'
----------------------Accelerometer_SensorJsTest012 off in---------------------------
'
);
sensor
.
off
(
sensor
.
SensorType
.
SENSOR_TYPE_ID_ACCELEROMETER
,
callback2
);
console
.
info
(
'
----------------------Accelerometer_SensorJsTest012 off end---------------------------
'
);
done
();
},
1000
);
})
/*
* @tc.name:Accelerometer_SensorJsTest013
* @tc.desc:verify app info is not null
* @tc.type: FUNC
* @tc.require: Issue Number
*/
it
(
"
Accelerometer_SensorJsTest013
"
,
0
,
async
function
(
done
)
{
console
.
info
(
'
----------------------Accelerometer_SensorJsTest013---------------------------
'
);
sensor
.
on
(
sensor
.
SensorType
.
SENSOR_TYPE_ID_ACCELEROMETER
,
callback
,
{
'
interval
'
:
100000000
});
sensor
.
on
(
sensor
.
SensorType
.
SENSOR_TYPE_ID_ACCELEROMETER
,
callback2
,
{
'
interval
'
:
100000000
});
setTimeout
(()
=>
{
console
.
info
(
'
----------------------Accelerometer_SensorJsTest013 off in---------------------------
'
);
sensor
.
off
(
sensor
.
SensorType
.
SENSOR_TYPE_ID_ACCELEROMETER
);
console
.
info
(
'
----------------------Accelerometer_SensorJsTest013 off end---------------------------
'
);
done
();
},
1000
);
})
})
\ No newline at end of file
sensors/sensor_standard/src/main/js/default/test/GyroScope.js
0 → 100644
浏览文件 @
c209d682
/*
* Copyright (C) 2021 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import
sensor
from
'
@ohos.sensor
'
import
{
describe
,
beforeAll
,
beforeEach
,
afterEach
,
afterAll
,
it
,
expect
}
from
'
deccjsunit/index
'
describe
(
"
SensorJsTest
"
,
function
()
{
function
callback
(
data
)
{
console
.
info
(
"
callback
"
+
JSON
.
stringify
(
data
));
expect
(
typeof
(
data
.
x
)).
assertEqual
(
"
number
"
);
expect
(
typeof
(
data
.
y
)).
assertEqual
(
"
number
"
);
expect
(
typeof
(
data
.
z
)).
assertEqual
(
"
number
"
);
}
function
callback2
(
data
)
{
console
.
info
(
"
callback2
"
+
JSON
.
stringify
(
data
));
expect
(
typeof
(
data
.
x
)).
assertEqual
(
"
number
"
);
expect
(
typeof
(
data
.
y
)).
assertEqual
(
"
number
"
);
expect
(
typeof
(
data
.
z
)).
assertEqual
(
"
number
"
);
}
beforeAll
(
function
()
{
/*
* @tc.setup: setup invoked before all testcases
*/
console
.
info
(
'
beforeAll caled
'
)
})
afterAll
(
function
()
{
/*
* @tc.teardown: teardown invoked after all testcases
*/
console
.
info
(
'
afterAll caled
'
)
})
beforeEach
(
function
()
{
/*
* @tc.setup: setup invoked before each testcases
*/
console
.
info
(
'
beforeEach caled
'
)
})
afterEach
(
function
()
{
/*
* @tc.teardown: teardown invoked after each testcases
*/
console
.
info
(
'
afterEach caled
'
)
})
let
errMessages
=
[
'
The number of parameters is not valid
'
,
'
Should subscribe first
'
,
'
string is not defined
'
];
let
errMessage
;
/*
* @tc.name:GYROSCOPE_SensorJsTest001
* @tc.desc:verify app info is not null
* @tc.type: FUNC
* @tc.require: Issue Number
*/
it
(
"
GYROSCOPE_SensorJsTest001
"
,
0
,
async
function
(
done
)
{
console
.
info
(
'
----------------------GYROSCOPE_SensorJsTest001---------------------------
'
);
sensor
.
on
(
sensor
.
SensorType
.
SENSOR_TYPE_ID_GYROSCOPE
,
callback
);
setTimeout
(()
=>
{
sensor
.
off
(
sensor
.
SensorType
.
SENSOR_TYPE_ID_GYROSCOPE
);
done
();
},
500
);
})
/*
* @tc.name:GYROSCOPE_SensorJsTest002
* @tc.desc:verify app info is not null
* @tc.type: FUNC
* @tc.require: Issue Number
*/
it
(
"
GYROSCOPE_SensorJsTest002
"
,
0
,
async
function
(
done
)
{
console
.
info
(
'
----------------------GYROSCOPE_SensorJsTest002---------------------------
'
);
sensor
.
on
(
sensor
.
SensorType
.
SENSOR_TYPE_ID_GYROSCOPE
,
callback
,
{
'
interval
'
:
100000000
});
setTimeout
(()
=>
{
console
.
info
(
'
----------------------GYROSCOPE_SensorJsTest002 off in---------------------------
'
);
sensor
.
off
(
sensor
.
SensorType
.
SENSOR_TYPE_ID_GYROSCOPE
);
console
.
info
(
'
----------------------GYROSCOPE_SensorJsTest002 off end---------------------------
'
);
done
();
},
500
);
})
/*
* @tc.name:GYROSCOPE_SensorJsTest003
* @tc.desc:verify app info is not null
* @tc.type: FUNC
* @tc.require: Issue Number
*/
it
(
"
GYROSCOPE_SensorJsTest003
"
,
0
,
async
function
(
done
)
{
console
.
info
(
'
----------------------GYROSCOPE_SensorJsTest003---------------------------
'
);
function
onSensorCallback
(
data
)
{
console
.
info
(
'
GYROSCOPE_SensorJsTest003 on error
'
);
expect
(
false
).
assertTrue
();
done
();
}
try
{
sensor
.
on
(
sensor
.
SensorType
.
SENSOR_TYPE_ID_GYROSCOPE
,
onSensorCallback
,
{
'
interval
'
:
100000000
},
5
);
}
catch
(
error
)
{
console
.
info
(
"
GYROSCOPE_SensorJsTest003 error:
"
+
error
);
errMessage
=
error
.
toString
().
slice
(
12
,
49
);
expect
(
errMessage
).
assertEqual
(
errMessages
[
0
]);
done
();
}
})
/*
* @tc.name:GYROSCOPE_SensorJsTest004
* @tc.desc:verify app info is not null
* @tc.type: FUNC
* @tc.require: Issue Number
*/
it
(
"
GYROSCOPE_SensorJsTest004
"
,
0
,
async
function
(
done
)
{
console
.
info
(
'
----------------------GYROSCOPE_SensorJsTest004---------------------------
'
);
sensor
.
once
(
sensor
.
SensorType
.
SENSOR_TYPE_ID_GYROSCOPE
,
callback
);
setTimeout
(()
=>
{
expect
(
true
).
assertTrue
();
done
();
},
500
);
})
/*
* @tc.name:GYROSCOPE_SensorJsTest005
* @tc.desc:verify app info is not null
* @tc.type: FUNC
* @tc.require: Issue Number
*/
it
(
"
GYROSCOPE_SensorJsTest005
"
,
0
,
async
function
(
done
)
{
console
.
info
(
'
----------------------GYROSCOPE_SensorJsTest005---------------------------
'
);
function
onceSensorCallback
(
data
)
{
console
.
info
(
'
GYROSCOPE_SensorJsTest005 on error
'
);
expect
(
false
).
assertTrue
();
done
();
}
try
{
sensor
.
once
(
sensor
.
SensorType
.
SENSOR_TYPE_ID_GYROSCOPE
,
onceSensorCallback
,
5
);
}
catch
(
error
)
{
console
.
info
(
"
GYROSCOPE_SensorJsTest005 error:
"
+
error
);
errMessage
=
error
.
toString
().
slice
(
14
,
51
);
expect
(
errMessage
).
assertEqual
(
errMessages
[
0
]);
done
();
}
})
/*
* @tc.name:GYROSCOPE_SensorJsTest006
* @tc.desc:verify app info is not null
* @tc.type: FUNC
* @tc.require: Issue Number
*/
it
(
"
GYROSCOPE_SensorJsTest006
"
,
0
,
async
function
(
done
)
{
console
.
info
(
'
----------------------GYROSCOPE_SensorJsTest006---------------------------
'
);
try
{
sensor
.
off
(
string
,
""
);
}
catch
(
error
)
{
console
.
info
(
"
GYROSCOPE_SensorJsTest006 error:
"
+
error
);
errMessage
=
error
.
toString
().
slice
(
16
,
40
);
expect
(
errMessage
).
assertEqual
(
errMessages
[
2
]);
done
();
}
})
/*
* @tc.name:GYROSCOPE_SensorJsTest007
* @tc.desc:verify app info is not null
* @tc.type: FUNC
* @tc.require: Issue Number
*/
it
(
"
GYROSCOPE_SensorJsTest007
"
,
0
,
async
function
(
done
)
{
console
.
info
(
'
----------------------GYROSCOPE_SensorJsTest007---------------------------
'
);
function
onSensorCallback
(
data
)
{
console
.
info
(
'
GYROSCOPE_SensorJsTest007 on error
'
);
expect
(
false
).
assertTrue
();
done
();
}
sensor
.
on
(
sensor
.
SensorType
.
SENSOR_TYPE_ID_GYROSCOPE
,
onSensorCallback
);
sensor
.
off
(
sensor
.
SensorType
.
SENSOR_TYPE_ID_GYROSCOPE
,
onSensorCallback
);
setTimeout
(()
=>
{
expect
(
true
).
assertTrue
();
done
();
},
500
);
})
/*
* @tc.name:GYROSCOPE_SensorJsTest008
* @tc.desc:verify app info is not null
* @tc.type: FUNC
* @tc.require: Issue Number
*/
it
(
"
GYROSCOPE_SensorJsTest008
"
,
0
,
async
function
(
done
)
{
console
.
info
(
'
----------------------GYROSCOPE_SensorJsTest008---------------------------
'
);
function
onSensorCallback
(
data
)
{
console
.
info
(
'
GYROSCOPE_SensorJsTest008 on error
'
);
expect
(
false
).
assertTrue
();
done
();
}
try
{
sensor
.
off
(
1000000
,
onSensorCallback
);
}
catch
(
error
)
{
console
.
info
(
"
GYROSCOPE_SensorJsTest008 error:
"
+
error
);
errMessage
=
error
.
toString
().
slice
(
13
,
35
);
expect
(
errMessage
).
assertEqual
(
errMessages
[
1
]);
done
();
}
})
/*
* @tc.name:GYROSCOPE_SensorJsTest009
* @tc.desc:verify app info is not null
* @tc.type: FUNC
* @tc.require: Issue Number
*/
it
(
"
GYROSCOPE_SensorJsTest009
"
,
0
,
async
function
(
done
)
{
console
.
info
(
'
----------------------GYROSCOPE_SensorJsTest009---------------------------
'
);
sensor
.
on
(
sensor
.
SensorType
.
SENSOR_TYPE_ID_GYROSCOPE
,
callback
);
sensor
.
on
(
sensor
.
SensorType
.
SENSOR_TYPE_ID_GYROSCOPE
,
callback2
);
setTimeout
(()
=>
{
console
.
info
(
'
----------------------GYROSCOPE_SensorJsTest009 off in---------------------------
'
);
sensor
.
off
(
sensor
.
SensorType
.
SENSOR_TYPE_ID_GYROSCOPE
);
console
.
info
(
'
----------------------GYROSCOPE_SensorJsTest009 off end---------------------------
'
);
done
();
},
1000
);
})
/*
* @tc.name:GYROSCOPE_SensorJsTest010
* @tc.desc:verify app info is not null
* @tc.type: FUNC
* @tc.require: Issue Number
*/
it
(
"
GYROSCOPE_SensorJsTest010
"
,
0
,
async
function
(
done
)
{
console
.
info
(
'
----------------------GYROSCOPE_SensorJsTest010---------------------------
'
);
sensor
.
on
(
sensor
.
SensorType
.
SENSOR_TYPE_ID_GYROSCOPE
,
callback
);
sensor
.
on
(
sensor
.
SensorType
.
SENSOR_TYPE_ID_GYROSCOPE
,
callback2
);
setTimeout
(()
=>
{
console
.
info
(
'
----------------------GYROSCOPE_SensorJsTest010 off in---------------------------
'
);
sensor
.
off
(
sensor
.
SensorType
.
SENSOR_TYPE_ID_GYROSCOPE
,
callback
);
console
.
info
(
'
----------------------GYROSCOPE_SensorJsTest010 off end---------------------------
'
);
},
500
);
setTimeout
(()
=>
{
console
.
info
(
'
----------------------GYROSCOPE_SensorJsTest010 off in---------------------------
'
);
sensor
.
off
(
sensor
.
SensorType
.
SENSOR_TYPE_ID_GYROSCOPE
,
callback2
);
console
.
info
(
'
----------------------GYROSCOPE_SensorJsTest010 off end---------------------------
'
);
done
();
},
1000
);
})
/*
* @tc.name:GYROSCOPE_SensorJsTest011
* @tc.desc:verify app info is not null
* @tc.type: FUNC
* @tc.require: Issue Number
*/
it
(
"
GYROSCOPE_SensorJsTest011
"
,
0
,
async
function
(
done
)
{
console
.
info
(
'
----------------------GYROSCOPE_SensorJsTest011---------------------------
'
);
sensor
.
on
(
sensor
.
SensorType
.
SENSOR_TYPE_ID_GYROSCOPE
,
callback
,
{
'
interval
'
:
100000000
});
sensor
.
once
(
sensor
.
SensorType
.
SENSOR_TYPE_ID_GYROSCOPE
,
callback2
);
setTimeout
(()
=>
{
console
.
info
(
'
----------------------GYROSCOPE_SensorJsTest011 off in---------------------------
'
);
sensor
.
off
(
sensor
.
SensorType
.
SENSOR_TYPE_ID_GYROSCOPE
);
console
.
info
(
'
----------------------GYROSCOPE_SensorJsTest011 off end---------------------------
'
);
done
();
},
1000
);
})
/*
* @tc.name:GYROSCOPE_SensorJsTest012
* @tc.desc:verify app info is not null
* @tc.type: FUNC
* @tc.require: Issue Number
*/
it
(
"
GYROSCOPE_SensorJsTest012
"
,
0
,
async
function
(
done
)
{
console
.
info
(
'
----------------------GYROSCOPE_SensorJsTest012---------------------------
'
);
sensor
.
on
(
sensor
.
SensorType
.
SENSOR_TYPE_ID_GYROSCOPE
,
callback
,
{
'
interval
'
:
100000000
});
sensor
.
on
(
sensor
.
SensorType
.
SENSOR_TYPE_ID_GYROSCOPE
,
callback2
,
{
'
interval
'
:
100000000
});
setTimeout
(()
=>
{
console
.
info
(
'
----------------------GYROSCOPE_SensorJsTest012 off in---------------------------
'
);
sensor
.
off
(
sensor
.
SensorType
.
SENSOR_TYPE_ID_GYROSCOPE
,
callback
);
console
.
info
(
'
----------------------GYROSCOPE_SensorJsTest012 off end---------------------------
'
);
},
500
);
setTimeout
(()
=>
{
console
.
info
(
'
----------------------GYROSCOPE_SensorJsTest012 off in---------------------------
'
);
sensor
.
off
(
sensor
.
SensorType
.
SENSOR_TYPE_ID_GYROSCOPE
,
callback2
);
console
.
info
(
'
----------------------GYROSCOPE_SensorJsTest012 off end---------------------------
'
);
done
();
},
1000
);
})
/*
* @tc.name:GYROSCOPE_SensorJsTest013
* @tc.desc:verify app info is not null
* @tc.type: FUNC
* @tc.require: Issue Number
*/
it
(
"
GYROSCOPE_SensorJsTest013
"
,
0
,
async
function
(
done
)
{
console
.
info
(
'
----------------------GYROSCOPE_SensorJsTest013---------------------------
'
);
sensor
.
on
(
sensor
.
SensorType
.
SENSOR_TYPE_ID_GYROSCOPE
,
callback
,
{
'
interval
'
:
100000000
});
sensor
.
on
(
sensor
.
SensorType
.
SENSOR_TYPE_ID_GYROSCOPE
,
callback2
,
{
'
interval
'
:
100000000
});
setTimeout
(()
=>
{
console
.
info
(
'
----------------------GYROSCOPE_SensorJsTest013 off in---------------------------
'
);
sensor
.
off
(
sensor
.
SensorType
.
SENSOR_TYPE_ID_GYROSCOPE
);
console
.
info
(
'
----------------------GYROSCOPE_SensorJsTest013 off end---------------------------
'
);
done
();
},
1000
);
})
})
\ No newline at end of file
sensors/sensor_standard/src/main/js/default/test/Hall.js
0 → 100644
浏览文件 @
c209d682
/*
* Copyright (C) 2021 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import
sensor
from
'
@ohos.sensor
'
import
{
describe
,
beforeAll
,
beforeEach
,
afterEach
,
afterAll
,
it
,
expect
}
from
'
deccjsunit/index
'
describe
(
"
SensorJsTest
"
,
function
()
{
function
callback
(
data
)
{
console
.
info
(
"
callback
"
+
JSON
.
stringify
(
data
));
expect
(
typeof
(
data
.
status
)).
assertEqual
(
"
number
"
);
}
function
callback2
(
data
)
{
console
.
info
(
"
callback2
"
+
JSON
.
stringify
(
data
));
expect
(
typeof
(
data
.
status
)).
assertEqual
(
"
number
"
);
}
beforeAll
(
function
()
{
/*
* @tc.setup: setup invoked before all testcases
*/
console
.
info
(
'
beforeAll caled
'
)
})
afterAll
(
function
()
{
/*
* @tc.teardown: teardown invoked after all testcases
*/
console
.
info
(
'
afterAll caled
'
)
})
beforeEach
(
function
()
{
/*
* @tc.setup: setup invoked before each testcases
*/
console
.
info
(
'
beforeEach caled
'
)
})
afterEach
(
function
()
{
/*
* @tc.teardown: teardown invoked after each testcases
*/
console
.
info
(
'
afterEach caled
'
)
})
let
errMessages
=
[
'
The number of parameters is not valid
'
,
'
Should subscribe first
'
,
'
string is not defined
'
];
let
errMessage
;
/*
* @tc.name:Hall_SensorJsTest001
* @tc.desc:verify app info is not null
* @tc.type: FUNC
* @tc.require: Issue Number
*/
it
(
"
Hall_SensorJsTest001
"
,
0
,
async
function
(
done
)
{
console
.
info
(
'
----------------------Hall_SensorJsTest001---------------------------
'
);
sensor
.
on
(
sensor
.
SensorType
.
SENSOR_TYPE_ID_HALL
,
callback
);
setTimeout
(()
=>
{
sensor
.
off
(
sensor
.
SensorType
.
SENSOR_TYPE_ID_HALL
);
done
();
},
500
);
})
/*
* @tc.name:Hall_SensorJsTest002
* @tc.desc:verify app info is not null
* @tc.type: FUNC
* @tc.require: Issue Number
*/
it
(
"
Hall_SensorJsTest002
"
,
0
,
async
function
(
done
)
{
console
.
info
(
'
----------------------Hall_SensorJsTest002---------------------------
'
);
sensor
.
on
(
sensor
.
SensorType
.
SENSOR_TYPE_ID_HALL
,
callback
,
{
'
interval
'
:
100000000
});
setTimeout
(()
=>
{
console
.
info
(
'
----------------------Hall_SensorJsTest002 off in---------------------------
'
);
sensor
.
off
(
sensor
.
SensorType
.
SENSOR_TYPE_ID_HALL
);
console
.
info
(
'
----------------------Hall_SensorJsTest002 off end---------------------------
'
);
done
();
},
500
);
})
/*
* @tc.name:Hall_SensorJsTest003
* @tc.desc:verify app info is not null
* @tc.type: FUNC
* @tc.require: Issue Number
*/
it
(
"
Hall_SensorJsTest003
"
,
0
,
async
function
(
done
)
{
console
.
info
(
'
----------------------Hall_SensorJsTest003---------------------------
'
);
function
onSensorCallback
(
data
)
{
console
.
info
(
'
Hall_SensorJsTest003 on error
'
);
expect
(
false
).
assertTrue
();
done
();
}
try
{
sensor
.
on
(
sensor
.
SensorType
.
SENSOR_TYPE_ID_HALL
,
onSensorCallback
,
{
'
interval
'
:
100000000
},
5
);
}
catch
(
error
)
{
console
.
info
(
"
Hall_SensorJsTest003 error:
"
+
error
);
errMessage
=
error
.
toString
().
slice
(
12
,
49
);
expect
(
errMessage
).
assertEqual
(
errMessages
[
0
]);
done
();
}
})
/*
* @tc.name:Hall_SensorJsTest004
* @tc.desc:verify app info is not null
* @tc.type: FUNC
* @tc.require: Issue Number
*/
it
(
"
Hall_SensorJsTest004
"
,
0
,
async
function
(
done
)
{
sensor
.
once
(
sensor
.
SensorType
.
SENSOR_TYPE_ID_HALL
,
callback
);
setTimeout
(()
=>
{
expect
(
true
).
assertTrue
();
done
();
},
500
);
})
/*
* @tc.name:Hall_SensorJsTest005
* @tc.desc:verify app info is not null
* @tc.type: FUNC
* @tc.require: Issue Number
*/
it
(
"
Hall_SensorJsTest005
"
,
0
,
async
function
(
done
)
{
function
onceSensorCallback
(
data
)
{
console
.
info
(
'
Hall_SensorJsTest005 on error
'
);
expect
(
false
).
assertTrue
();
done
();
}
try
{
sensor
.
once
(
sensor
.
SensorType
.
SENSOR_TYPE_ID_HALL
,
onceSensorCallback
,
5
);
}
catch
(
error
)
{
console
.
info
(
"
Hall_SensorJsTest005 error:
"
+
error
);
errMessage
=
error
.
toString
().
slice
(
14
,
51
);
expect
(
errMessage
).
assertEqual
(
errMessages
[
0
]);
done
();
}
})
/*
* @tc.name:Hall_SensorJsTest006
* @tc.desc:verify app info is not null
* @tc.type: FUNC
* @tc.require: Issue Number
*/
it
(
"
Hall_SensorJsTest006
"
,
0
,
async
function
(
done
)
{
try
{
sensor
.
off
(
string
,
""
);
}
catch
(
error
)
{
console
.
info
(
"
Hall_SensorJsTest006 error:
"
+
error
);
errMessage
=
error
.
toString
().
slice
(
16
,
40
);
expect
(
errMessage
).
assertEqual
(
errMessages
[
2
]);
done
();
}
})
/*
* @tc.name:Hall_SensorJsTest007
* @tc.desc:verify app info is not null
* @tc.type: FUNC
* @tc.require: Issue Number
*/
it
(
"
Hall_SensorJsTest007
"
,
0
,
async
function
(
done
)
{
function
onSensorCallback
(
data
)
{
console
.
info
(
'
Hall_SensorJsTest007 on error
'
);
expect
(
false
).
assertTrue
();
done
();
}
sensor
.
on
(
sensor
.
SensorType
.
SENSOR_TYPE_ID_HALL
,
onSensorCallback
);
sensor
.
off
(
sensor
.
SensorType
.
SENSOR_TYPE_ID_HALL
,
onSensorCallback
);
setTimeout
(()
=>
{
expect
(
true
).
assertTrue
();
done
();
},
500
);
})
/*
* @tc.name:Hall_SensorJsTest008
* @tc.desc:verify app info is not null
* @tc.type: FUNC
* @tc.require: Issue Number
*/
it
(
"
Hall_SensorJsTest008
"
,
0
,
async
function
(
done
)
{
function
onSensorCallback
(
data
)
{
console
.
info
(
'
Hall_SensorJsTest008 on error
'
);
expect
(
false
).
assertTrue
();
done
();
}
try
{
sensor
.
off
(
1000000
,
onSensorCallback
);
}
catch
(
error
)
{
console
.
info
(
"
Hall_SensorJsTest008 error:
"
+
error
);
errMessage
=
error
.
toString
().
slice
(
13
,
35
);
expect
(
errMessage
).
assertEqual
(
errMessages
[
1
]);
done
();
}
})
/*
* @tc.name:Hall_SensorJsTest009
* @tc.desc:verify app info is not null
* @tc.type: FUNC
* @tc.require: Issue Number
*/
it
(
"
Hall_SensorJsTest009
"
,
0
,
async
function
(
done
)
{
sensor
.
on
(
sensor
.
SensorType
.
SENSOR_TYPE_ID_HALL
,
callback
);
sensor
.
on
(
sensor
.
SensorType
.
SENSOR_TYPE_ID_HALL
,
callback2
);
setTimeout
(()
=>
{
console
.
info
(
'
----------------------Hall_SensorJsTest009 off in---------------------------
'
);
sensor
.
off
(
sensor
.
SensorType
.
SENSOR_TYPE_ID_HALL
);
console
.
info
(
'
----------------------Hall_SensorJsTest009 off end---------------------------
'
);
done
();
},
1000
);
})
/*
* @tc.name:Hall_SensorJsTest010
* @tc.desc:verify app info is not null
* @tc.type: FUNC
* @tc.require: Issue Number
*/
it
(
"
Hall_SensorJsTest010
"
,
0
,
async
function
(
done
)
{
sensor
.
on
(
sensor
.
SensorType
.
SENSOR_TYPE_ID_HALL
,
callback
);
sensor
.
on
(
sensor
.
SensorType
.
SENSOR_TYPE_ID_HALL
,
callback2
);
setTimeout
(()
=>
{
console
.
info
(
'
----------------------Hall_SensorJsTest010 off in---------------------------
'
);
sensor
.
off
(
sensor
.
SensorType
.
SENSOR_TYPE_ID_HALL
,
callback
);
console
.
info
(
'
----------------------Hall_SensorJsTest010 off end---------------------------
'
);
},
500
);
setTimeout
(()
=>
{
console
.
info
(
'
----------------------Hall_SensorJsTest010 off in---------------------------
'
);
sensor
.
off
(
sensor
.
SensorType
.
SENSOR_TYPE_ID_HALL
,
callback2
);
console
.
info
(
'
----------------------Hall_SensorJsTest010 off end---------------------------
'
);
done
();
},
1000
);
})
/*
* @tc.name:Hall_SensorJsTest011
* @tc.desc:verify app info is not null
* @tc.type: FUNC
* @tc.require: Issue Number
*/
it
(
"
Hall_SensorJsTest011
"
,
0
,
async
function
(
done
)
{
console
.
info
(
'
----------------------Hall_SensorJsTest011---------------------------
'
);
sensor
.
on
(
sensor
.
SensorType
.
SENSOR_TYPE_ID_HALL
,
callback
,
{
'
interval
'
:
100000000
});
sensor
.
once
(
sensor
.
SensorType
.
SENSOR_TYPE_ID_HALL
,
callback2
);
setTimeout
(()
=>
{
console
.
info
(
'
----------------------Hall_SensorJsTest011 off in---------------------------
'
);
sensor
.
off
(
sensor
.
SensorType
.
SENSOR_TYPE_ID_HALL
);
console
.
info
(
'
----------------------Hall_SensorJsTest011 off end---------------------------
'
);
done
();
},
1000
);
})
/*
* @tc.name:Hall_SensorJsTest012
* @tc.desc:verify app info is not null
* @tc.type: FUNC
* @tc.require: Issue Number
*/
it
(
"
Hall_SensorJsTest012
"
,
0
,
async
function
(
done
)
{
console
.
info
(
'
----------------------Hall_SensorJsTest012---------------------------
'
);
sensor
.
on
(
sensor
.
SensorType
.
SENSOR_TYPE_ID_HALL
,
callback
,
{
'
interval
'
:
100000000
});
sensor
.
on
(
sensor
.
SensorType
.
SENSOR_TYPE_ID_HALL
,
callback2
,
{
'
interval
'
:
100000000
});
setTimeout
(()
=>
{
console
.
info
(
'
----------------------Hall_SensorJsTest012 off in---------------------------
'
);
sensor
.
off
(
sensor
.
SensorType
.
SENSOR_TYPE_ID_HALL
,
callback
);
console
.
info
(
'
----------------------Hall_SensorJsTest012 off end---------------------------
'
);
},
500
);
setTimeout
(()
=>
{
console
.
info
(
'
----------------------Hall_SensorJsTest012 off in---------------------------
'
);
sensor
.
off
(
sensor
.
SensorType
.
SENSOR_TYPE_ID_HALL
,
callback2
);
console
.
info
(
'
----------------------Hall_SensorJsTest012 off end---------------------------
'
);
done
();
},
1000
);
})
/*
* @tc.name:Hall_SensorJsTest013
* @tc.desc:verify app info is not null
* @tc.type: FUNC
* @tc.require: Issue Number
*/
it
(
"
Hall_SensorJsTest013
"
,
0
,
async
function
(
done
)
{
console
.
info
(
'
----------------------Hall_SensorJsTest013---------------------------
'
);
sensor
.
on
(
sensor
.
SensorType
.
SENSOR_TYPE_ID_HALL
,
callback
,
{
'
interval
'
:
100000000
});
sensor
.
on
(
sensor
.
SensorType
.
SENSOR_TYPE_ID_HALL
,
callback2
,
{
'
interval
'
:
100000000
});
setTimeout
(()
=>
{
console
.
info
(
'
----------------------Hall_SensorJsTest013 off in---------------------------
'
);
sensor
.
off
(
sensor
.
SensorType
.
SENSOR_TYPE_ID_HALL
);
console
.
info
(
'
----------------------Hall_SensorJsTest013 off end---------------------------
'
);
done
();
},
1000
);
})
})
\ No newline at end of file
sensors/sensor_standard/src/main/js/default/test/getOnBodyState.js
0 → 100644
浏览文件 @
c209d682
/*
* 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
'
)
})
let
errMessages
=
[
'
The number of parameters is not valid
'
,
'
Wrong argument type, function expected
'
,
'
Wrong argument type, should be object
'
]
let
errMessage
;
/*
* @tc.name:getOnBodyState_SensorJsTest001
* @tc.desc:verify app info is not null
* @tc.type: FUNC
* @tc.require: SR000H0ALK, AR000H0ALM
*/
it
(
"
getOnBodyState_SensorJsTest001
"
,
0
,
async
function
(
done
)
{
console
.
info
(
'
----------------------getOnBodyState_SensorJsTest001---------------------------
'
);
try
{
sensor
.
getOnBodyState
();
}
catch
(
error
)
{
console
.
info
(
'
getOnBodyState_SensorJsTest001 error
'
+
error
);
errMessage
=
error
.
toString
().
slice
(
22
,
59
);
expect
(
errMessage
).
assertEqual
(
errMessages
[
0
]);
done
();
}
})
/*
* @tc.name:getOnBodyState_SensorJsTest002
* @tc.desc:verify app info is not null
* @tc.type: FUNC
* @tc.require: SR000H0ALK, AR000H0ALM
*/
it
(
"
getOnBodyState_SensorJsTest002
"
,
0
,
async
function
(
done
)
{
console
.
info
(
'
----------------------getOnBodyState_SensorJsTest002---------------------------
'
);
try
{
sensor
.
getOnBodyState
({
success
:
function
(
data
)
{
console
.
info
(
"
getOnBodyState_SensorJsTest002 success:
"
+
JSON
.
stringify
(
data
));
expect
(
typeof
(
data
.
value
)).
assertEqual
(
"
boolean
"
);
done
();
}
});
}
catch
(
error
)
{
console
.
info
(
'
getOnBodyState_SensorJsTest002 error
'
+
error
);
expect
(
false
).
assertTrue
();
done
();
}
})
/*
* @tc.name:getOnBodyState_SensorJsTest003
* @tc.desc:verify app info is not null
* @tc.type: FUNC
* @tc.require: SR000H0ALK, AR000H0ALM
*/
it
(
"
getOnBodyState_SensorJsTest003
"
,
0
,
async
function
(
done
)
{
console
.
info
(
'
----------------------getOnBodyState_SensorJsTest003---------------------------
'
);
sensor
.
getOnBodyState
({
success
:
function
(
data
)
{
console
.
info
(
"
getOnBodyState_SensorJsTest003 success:
"
+
JSON
.
stringify
(
data
));
expect
(
typeof
(
data
.
value
)).
assertEqual
(
"
boolean
"
);
done
();
},
fail
:
function
(
data
,
code
)
{
console
.
log
(
"
getOnBodyState_SensorJsTest003 is failed, data:
"
+
data
+
"
, code:
"
+
code
);
expect
(
false
).
assertTrue
();
},
complete
:
function
()
{
console
.
log
(
'
getOnBodyState_SensorJsTest003 is completed
'
);
}
});
})
/*
* @tc.name:getOnBodyState_SensorJsTest004
* @tc.desc:verify app info is not null
* @tc.type: FUNC
* @tc.require: SR000H0ALK, AR000H0ALM
*/
it
(
"
getOnBodyState_SensorJsTest004
"
,
0
,
async
function
(
done
)
{
console
.
info
(
'
----------------------getOnBodyState_SensorJsTest004---------------------------
'
);
sensor
.
getOnBodyState
({
success
:
function
(
data
)
{
console
.
info
(
"
getOnBodyState_SensorJsTest004 success:
"
+
JSON
.
stringify
(
data
));
expect
(
typeof
(
data
.
value
)).
assertEqual
(
"
boolean
"
);
done
();
},
});
})
/*
* @tc.name:getOnBodyState_SensorJsTest005
* @tc.desc:verify app info is not null
* @tc.type: FUNC
* @tc.require: SR000H0ALK, AR000H0ALM
*/
it
(
"
getOnBodyState_SensorJsTest005
"
,
0
,
async
function
(
done
)
{
console
.
info
(
'
----------------------getOnBodyState_SensorJsTest005---------------------------
'
);
sensor
.
getOnBodyState
({
success
:
function
(
data
)
{
console
.
info
(
"
getOnBodyState_SensorJsTest005 success:
"
+
JSON
.
stringify
(
data
));
expect
(
typeof
(
data
.
value
)).
assertEqual
(
"
boolean
"
);
done
();
},
fail
:
function
(
data
,
code
)
{
console
.
error
(
'
getOnBodyState_SensorJsTest005 failed. Code:
'
+
code
+
'
; Data:
'
+
data
);
expect
(
false
).
assertTrue
();
},
});
})
/*
* @tc.name:getOnBodyState_SensorJsTest006
* @tc.desc:verify app info is not null
* @tc.type: FUNC
* @tc.require: SR000H0ALK, AR000H0ALM
*/
it
(
"
getOnBodyState_SensorJsTest006
"
,
0
,
async
function
(
done
)
{
console
.
info
(
'
----------------------getOnBodyState_SensorJsTest006---------------------------
'
);
sensor
.
getOnBodyState
({
inInvalid
:
2
,
success
:
function
(
data
)
{
console
.
info
(
"
getOnBodyState_SensorJsTest006 success:
"
+
JSON
.
stringify
(
data
));
expect
(
typeof
(
data
.
value
)).
assertEqual
(
"
boolean
"
);
done
();
},
fail
:
function
(
data
,
code
)
{
console
.
error
(
'
getOnBodyState_SensorJsTest006 failed. Code:
'
+
code
+
'
; Data:
'
+
data
);
expect
(
false
).
assertTrue
();
},
});
})
/*
* @tc.name:getOnBodyState_SensorJsTest007
* @tc.desc:verify app info is not null
* @tc.type: FUNC
* @tc.require: SR000H0ALK, AR000H0ALM
*/
it
(
"
getOnBodyState_SensorJsTest007
"
,
0
,
async
function
(
done
)
{
console
.
info
(
'
----------------------getOnBodyState_SensorJsTest007---------------------------
'
);
try
{
sensor
.
getOnBodyState
({
success
:
function
(
data
)
{
console
.
info
(
"
getOnBodyState_SensorJsTest007 success:
"
+
JSON
.
stringify
(
data
));
expect
(
typeof
(
data
.
value
)).
assertEqual
(
"
boolean
"
);
},
},
25
);
}
catch
(
error
)
{
errMessage
=
error
.
toString
().
slice
(
22
,
59
);
console
.
info
(
'
getOnBodyState_SensorJsTest007 error:
'
+
error
);
expect
(
errMessage
).
assertEqual
(
errMessages
[
0
]);
done
();
}
})
/*
* @tc.name:getOnBodyState_SensorJsTest008
* @tc.desc:verify app info is not null
* @tc.type: FUNC
* @tc.require: SR000H0ALK, AR000H0ALM
*/
it
(
"
getOnBodyState_SensorJsTest008
"
,
0
,
async
function
(
done
)
{
console
.
info
(
'
----------------------getOnBodyState_SensorJsTest008---------------------------
'
);
sensor
.
getOnBodyState
({
success
:
function
(
data
)
{
console
.
info
(
"
getOnBodyState_SensorJsTest008 success:
"
+
JSON
.
stringify
(
data
));
expect
(
typeof
(
data
.
value
)).
assertEqual
(
"
boolean
"
);
},
fail
:
function
(
data
,
code
)
{
console
.
error
(
'
getOnBodyState_SensorJsTest008 failed. Code:
'
+
code
+
'
; Data:
'
+
data
);
expect
(
false
).
assertTrue
();
},
});
sensor
.
getOnBodyState
({
success
:
function
(
data
)
{
console
.
info
(
"
getOnBodyState_SensorJsTest008 success:
"
+
JSON
.
stringify
(
data
));
expect
(
typeof
(
data
.
value
)).
assertEqual
(
"
boolean
"
);
},
fail
:
function
(
data
,
code
)
{
console
.
error
(
'
getOnBodyState_SensorJsTest008_1 failed. Code:
'
+
code
+
'
; Data:
'
+
data
);
expect
(
false
).
assertTrue
();
},
});
setTimeout
(()
=>
{
done
();
},
500
);
})
/*
* @tc.name:getOnBodyState_SensorJsTest009
* @tc.desc:verify app info is not null
* @tc.type: FUNC
* @tc.require: SR000H0ALK, AR000H0ALM
*/
it
(
"
getOnBodyState_SensorJsTest009
"
,
0
,
async
function
(
done
)
{
console
.
info
(
'
----------------------getOnBodyState_SensorJsTest009---------------------------
'
);
try
{
sensor
.
getOnBodyState
(
'
xxx
'
);
}
catch
(
error
)
{
console
.
info
(
'
getOnBodyState_SensorJsTest009 error:
'
+
error
);
errMessage
=
error
.
toString
().
slice
(
22
,
59
);
console
.
info
(
'
getOnBodyState_SensorJsTest009 errMessage:
'
+
errMessage
);
expect
(
errMessage
).
assertEqual
(
errMessages
[
2
]);
done
();
}
})
/*
* @tc.name:getOnBodyState_SensorJsTest010
* @tc.desc:verify app info is not null
* @tc.type: FUNC
* @tc.require: SR000H0ALK, AR000H0ALM
*/
it
(
"
getOnBodyState_SensorJsTest010
"
,
0
,
async
function
(
done
)
{
console
.
info
(
'
----------------------getOnBodyState_SensorJsTest010---------------------------
'
);
try
{
sensor
.
getOnBodyState
();
}
catch
(
error
)
{
errMessage
=
error
.
toString
().
slice
(
22
,
59
);
console
.
info
(
'
getOnBodyState_SensorJsTest010 error:
'
+
error
);
expect
(
errMessage
).
assertEqual
(
errMessages
[
0
]);
done
();
}
})
/*
* @tc.name:getOnBodyState_SensorJsTest011
* @tc.desc:verify app info is not null
* @tc.type: FUNC
* @tc.require: SR000H0ALK, AR000H0ALM
*/
it
(
"
getOnBodyState_SensorJsTest011
"
,
0
,
async
function
(
done
)
{
console
.
info
(
'
----------------------getOnBodyState_SensorJsTest011---------------------------
'
);
try
{
sensor
.
getOnBodyState
({
success
:
function
(
data
)
{
console
.
info
(
"
getOnBodyState_SensorJsTest011 success:
"
+
JSON
.
stringify
(
data
));
expect
(
typeof
(
data
.
value
)).
assertEqual
(
"
boolean
"
);
done
();
},
},
function
()
{
},
25
);
}
catch
(
error
)
{
errMessage
=
error
.
toString
().
slice
(
22
,
59
);
console
.
info
(
'
getOnBodyState_SensorJsTest011 error:
'
+
error
);
expect
(
errMessage
).
assertEqual
(
errMessages
[
0
]);
done
();
}
})
/*
* @tc.name:getOnBodyState_SensorJsTest012
* @tc.desc:verify app info is not null
* @tc.type: FUNC
* @tc.require: SR000H0ALK, AR000H0ALM
*/
it
(
"
getOnBodyState_SensorJsTest012
"
,
0
,
async
function
(
done
)
{
console
.
info
(
'
----------------------getOnBodyState_SensorJsTest012---------------------------
'
);
sensor
.
getOnBodyState
({
success
:
function
(
data
)
{
console
.
info
(
"
getOnBodyState_SensorJsTest012 success:
"
+
JSON
.
stringify
(
data
));
expect
(
typeof
(
data
.
value
)).
assertEqual
(
"
boolean
"
);
done
();
},
fail
:
function
(
data
,
code
)
{
console
.
error
(
'
getOnBodyState_SensorJsTest012 failed. Code:
'
+
code
+
'
; Data:
'
+
data
);
expect
(
false
).
assertTrue
();
done
();
},
});
})
})
\ No newline at end of file
sensors/sensor_standard/src/main/js/default/test/subscribeBarometer.js
0 → 100644
浏览文件 @
c209d682
/*
* 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
'
)
})
let
errMessages
=
[
'
The number of parameters is not valid
'
,
'
UnsubscribeSensor failed
'
,
'
Wrong argument type, should be object
'
];
let
errMessage
;
/*
* @tc.name:subscribeBarometer_SensorJsTest001
* @tc.desc:verify app info is not null
* @tc.type: FUNC
* @tc.require: SR000H0ALK, AR000H0ALM
*/
it
(
"
subscribeBarometer_SensorJsTest001
"
,
0
,
async
function
(
done
)
{
console
.
info
(
'
----------------------subscribeBarometer_SensorJsTest001---------------------------
'
);
sensor
.
subscribeBarometer
({
success
:
function
(
data
)
{
console
.
info
(
"
subscribeBarometer_SensorJsTest001 success
"
+
JSON
.
stringify
(
data
));
expect
(
typeof
(
data
.
pressure
)).
assertEqual
(
"
number
"
);
},
fail
:
function
(
data
,
code
)
{
console
.
error
(
'
subscribeBarometer_SensorJsTest001 failed. Code:
'
+
code
+
'
; Data:
'
+
data
);
expect
(
code
).
assertEqual
(
1001
);
},
});
setTimeout
(()
=>
{
try
{
sensor
.
unsubscribeBarometer
();
}
catch
(
error
)
{
console
.
info
(
'
subscribeBarometer_SensorJsTest001_unsubscribeBarometer error
'
+
error
);
}
setTimeout
(()
=>
{
expect
(
true
).
assertTrue
();
done
();
},
500
);
},
1000
);
})
/*
* @tc.name:subscribeBarometer_SensorJsTest002
* @tc.desc:verify app info is not null
* @tc.type: FUNC
* @tc.require: SR000H0ALK, AR000H0ALM
*/
it
(
"
subscribeBarometer_SensorJsTest002
"
,
0
,
function
(
done
)
{
console
.
info
(
'
----------------------subscribeBarometer_SensorJsTest002---------------------------
'
);
try
{
sensor
.
subscribeBarometer
({
success
:
function
(
data
)
{
console
.
info
(
"
subscribeBarometer_SensorJsTest002 success:
"
+
JSON
.
stringify
(
data
));
expect
(
typeof
(
data
.
pressure
)).
assertEqual
(
"
number
"
);
},
fail
:
function
(
data
,
code
)
{
console
.
error
(
'
subscribeBarometer_SensorJsTest002 failed. Code:
'
+
code
+
'
; Data:
'
+
data
);
expect
(
code
).
assertEqual
(
1001
);
},
},
25
);
}
catch
(
error
)
{
errMessage
=
error
.
toString
().
slice
(
19
,
56
);
console
.
info
(
'
subscribeBarometer_SensorJsTest002 error:
'
+
error
);
expect
(
errMessage
).
assertEqual
(
errMessages
[
0
]);
done
();
}
})
/*
* @tc.name:subscribeBarometer_SensorJsTest003
* @tc.desc:verify app info is not null
* @tc.type: FUNC
* @tc.require: SR000H0ALK, AR000H0ALM
*/
it
(
"
subscribeBarometer_SensorJsTest003
"
,
0
,
function
(
done
)
{
console
.
info
(
'
----------------------subscribeBarometer_SensorJsTest003---------------------------
'
);
try
{
sensor
.
subscribeBarometer
({
success
:
function
(
data
)
{
console
.
info
(
"
subscribeBarometer_SensorJsTest003 success:
"
+
JSON
.
stringify
(
data
));
expect
(
typeof
(
data
.
pressure
)).
assertEqual
(
"
number
"
);
},
fail
:
function
(
data
,
code
)
{
console
.
error
(
'
subscribeBarometer_SensorJsTest003 failed. Code:
'
+
code
+
'
; Data:
'
+
data
);
expect
(
code
).
assertEqual
(
1001
);
},
},
function
()
{
},
25
);
}
catch
(
error
)
{
errMessage
=
error
.
toString
().
slice
(
19
,
56
);
console
.
info
(
'
subscribeBarometer_SensorJsTest003 error:
'
+
error
);
expect
(
errMessage
).
assertEqual
(
errMessages
[
0
]);
done
();
}
})
/*
* @tc.name:subscribeBarometer_SensorJsTest004
* @tc.desc:verify app info is not null
* @tc.type: FUNC
* @tc.require: SR000H0ALK, AR000H0ALM
*/
it
(
"
subscribeBarometer_SensorJsTest004
"
,
0
,
async
function
(
done
)
{
console
.
info
(
'
----------------------subscribeBarometer_SensorJsTest004---------------------------
'
);
try
{
sensor
.
unsubscribeBarometer
(
'
xxx
'
);
}
catch
(
error
)
{
errMessage
=
error
.
toString
().
slice
(
21
,
58
);
console
.
info
(
'
subscribeBarometer_SensorJsTest004 error:
'
+
error
);
expect
(
errMessage
).
assertEqual
(
errMessages
[
0
]);
done
();
}
})
/*
* @tc.name:subscribeBarometer_SensorJsTest005
* @tc.desc:verify app info is not null
* @tc.type: FUNC
* @tc.require: SR000H0ALK, AR000H0ALM
*/
it
(
"
subscribeBarometer_SensorJsTest005
"
,
0
,
async
function
(
done
)
{
console
.
info
(
'
----------------------subscribeBarometer_SensorJsTest005---------------------------
'
);
try
{
sensor
.
subscribeBarometer
();
}
catch
(
error
)
{
errMessage
=
error
.
toString
().
slice
(
19
,
56
);
console
.
info
(
'
subscribeBarometer_SensorJsTest005 error:
'
+
error
);
expect
(
errMessage
).
assertEqual
(
errMessages
[
0
]);
done
();
}
})
/*
* @tc.name:subscribeBarometer_SensorJsTest006
* @tc.desc:verify app info is not null
* @tc.type: FUNC
* @tc.require: SR000H0ALK, AR000H0ALM
*/
it
(
"
subscribeBarometer_SensorJsTest006
"
,
0
,
async
function
(
done
)
{
console
.
info
(
'
----------------------subscribeBarometer_SensorJsTest006---------------------------
'
);
try
{
sensor
.
subscribeBarometer
(
'
xxx
'
);
}
catch
(
error
)
{
errMessage
=
error
.
toString
().
slice
(
19
,
56
);
console
.
info
(
'
subscribeBarometer_SensorJsTest006 error:
'
+
error
);
expect
(
errMessage
).
assertEqual
(
errMessages
[
2
]);
done
();
}
})
/*
* @tc.name:subscribeBarometer_SensorJsTest007
* @tc.desc:verify app info is not null
* @tc.type: FUNC
* @tc.require: SR000H0ALK, AR000H0ALM
*/
it
(
"
subscribeBarometer_SensorJsTest007
"
,
0
,
function
(
done
)
{
console
.
info
(
'
----------------------subscribeBarometer_SensorJsTest007---------------------------
'
);
sensor
.
subscribeBarometer
({
success
:
function
(
data
)
{
console
.
info
(
"
subscribeBarometer_SensorJsTest007 success:
"
+
JSON
.
stringify
(
data
));
expect
(
typeof
(
data
.
pressure
)).
assertEqual
(
"
number
"
);
},
fail
:
function
(
data
,
code
)
{
console
.
error
(
'
subscribeBarometer_SensorJsTest007 failed. Code:
'
+
code
+
'
; Data:
'
+
data
);
expect
(
code
).
assertEqual
(
1001
);
},
});
sensor
.
subscribeBarometer
({
success
:
function
(
data
)
{
console
.
info
(
"
subscribeBarometer_SensorJsTest007_1 success:
"
+
JSON
.
stringify
(
data
));
expect
(
typeof
(
data
.
pressure
)).
assertEqual
(
"
number
"
);
},
fail
:
function
(
data
,
code
)
{
console
.
error
(
'
subscribeBarometer_SensorJsTest007_1 failed. Code:
'
+
code
+
'
; Data:
'
+
data
);
expect
(
code
).
assertEqual
(
1001
);
},
});
setTimeout
(()
=>
{
try
{
sensor
.
unsubscribeBarometer
();
}
catch
(
error
)
{
console
.
info
(
'
subscribeBarometer_SensorJsTest007_unsubscribeBarometer error
'
+
error
);
}
setTimeout
(()
=>
{
expect
(
true
).
assertTrue
();
done
();
},
500
);
},
1000
);
})
/*
* @tc.name:subscribeBarometer_SensorJsTest008
* @tc.desc:verify app info is not null
* @tc.type: FUNC
* @tc.require: SR000H0ALK, AR000H0ALM
*/
it
(
"
subscribeBarometer_SensorJsTest008
"
,
0
,
async
function
(
done
)
{
console
.
info
(
'
----------------------subscribeBarometer_SensorJsTest008---------------------------
'
);
try
{
sensor
.
unsubscribeBarometer
();
}
catch
(
error
)
{
var
errMessage
=
error
.
toString
().
slice
(
21
,
45
);
console
.
info
(
'
subscribeBarometer_SensorJsTest008 error:
'
+
error
);
expect
(
errMessage
).
assertEqual
(
errMessages
[
1
]);
done
();
}
})
/*
* @tc.name:subscribeBarometer_SensorJsTest009
* @tc.desc:verify app info is not null
* @tc.type: FUNC
* @tc.require: SR000H0ALK, AR000H0ALM
*/
it
(
"
subscribeBarometer_SensorJsTest009
"
,
0
,
function
(
done
)
{
console
.
info
(
'
----------------------subscribeBarometer_SensorJsTest009---------------------------
'
);
sensor
.
subscribeBarometer
({
success
:
function
(
data
)
{
console
.
info
(
"
subscribeBarometer_SensorJsTest009 success:
"
+
JSON
.
stringify
(
data
));
expect
(
typeof
(
data
.
pressure
)).
assertEqual
(
"
number
"
);
},
fail
:
function
(
data
,
code
)
{
console
.
error
(
'
subscribeBarometer_SensorJsTest009 failed. Code:
'
+
code
+
'
; Data:
'
+
data
);
expect
(
code
).
assertEqual
(
1001
);
},
});
try
{
sensor
.
unsubscribeBarometer
();
}
catch
(
error
)
{
console
.
info
(
'
subscribeBarometer_SensorJsTest009_unsubscribeBarometer error
'
+
error
);
}
setTimeout
(()
=>
{
expect
(
true
).
assertTrue
();
done
();
},
500
);
})
})
\ No newline at end of file
sensors/sensor_standard/src/main/js/default/test/subscribeCompass.js
0 → 100644
浏览文件 @
c209d682
/*
* 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
'
)
})
let
errMessages
=
[
'
The number of parameters is not valid
'
,
'
UnsubscribeSensor failed
'
,
'
Wrong argument type, should be object
'
];
let
errMessage
;
/*
* @tc.name:subscribeCompass_SensorJsTest001
* @tc.desc:verify app info is not null
* @tc.type: FUNC
* @tc.require: SR000H0ALK, AR000H0ALM
*/
it
(
"
subscribeCompass_SensorJsTest001
"
,
0
,
function
(
done
)
{
console
.
info
(
'
----------------------subscribeCompass_SensorJsTest001---------------------------
'
);
sensor
.
subscribeCompass
({
success
:
function
(
data
)
{
console
.
info
(
"
subscribeCompass_SensorJsTest001 success:
"
+
JSON
.
stringify
(
data
));
expect
(
typeof
(
data
.
direction
)).
assertEqual
(
"
number
"
);
},
fail
:
function
(
data
,
code
)
{
console
.
error
(
'
subscribeCompass_SensorJsTest001 failed. Code:
'
+
code
+
'
; Data:
'
+
data
);
expect
(
false
).
assertTrue
();
},
});
setTimeout
(()
=>
{
try
{
sensor
.
unsubscribeCompass
();
}
catch
(
error
)
{
console
.
info
(
'
subscribeCompass_SensorJsTest001_unsubscribeCompass error
'
+
error
);
expect
(
false
).
assertTrue
();
}
setTimeout
(()
=>
{
expect
(
true
).
assertTrue
();
done
();
},
500
);
},
1000
);
})
/*
* @tc.name:subscribeCompass_SensorJsTest002
* @tc.desc:verify app info is not null
* @tc.type: FUNC
* @tc.require: SR000H0ALK, AR000H0ALM
*/
it
(
"
subscribeCompass_SensorJsTest002
"
,
0
,
function
(
done
)
{
console
.
info
(
'
----------------------subscribeCompass_SensorJsTest002---------------------------
'
);
try
{
sensor
.
subscribeCompass
({
success
:
function
(
data
)
{
console
.
info
(
"
subscribeCompass_SensorJsTest002 success:
"
+
JSON
.
stringify
(
data
));
expect
(
typeof
(
data
.
direction
)).
assertEqual
(
"
number
"
);
},
fail
:
function
(
data
,
code
)
{
console
.
error
(
'
subscribeCompass_SensorJsTest002 failed. Code:
'
+
code
+
'
; Data:
'
+
data
);
expect
(
false
).
assertTrue
();
},
},
25
);
}
catch
(
error
)
{
errMessage
=
error
.
toString
().
slice
(
19
,
56
);
console
.
info
(
'
subscribeCompass_SensorJsTest002 error:
'
+
error
);
expect
(
errMessage
).
assertEqual
(
errMessages
[
0
]);
done
();
}
})
/*
* @tc.name:subscribeCompass_SensorJsTest003
* @tc.desc:verify app info is not null
* @tc.type: FUNC
* @tc.require: SR000H0ALK, AR000H0ALM
*/
it
(
"
subscribeCompass_SensorJsTest003
"
,
0
,
function
(
done
)
{
console
.
info
(
'
----------------------subscribeCompass_SensorJsTest003---------------------------
'
);
sensor
.
subscribeCompass
({
success
:
function
(
data
)
{
console
.
info
(
"
subscribeCompass_SensorJsTest003 success:
"
+
JSON
.
stringify
(
data
));
expect
(
typeof
(
data
.
direction
)).
assertEqual
(
"
number
"
);
},
});
setTimeout
(()
=>
{
try
{
sensor
.
unsubscribeCompass
();
}
catch
(
error
)
{
console
.
info
(
'
subscribeCompass_SensorJsTest003_unsubscribeLight error
'
+
error
);
expect
(
false
).
assertTrue
();
}
setTimeout
(()
=>
{
expect
(
true
).
assertTrue
();
done
();
},
500
);
},
1000
);
})
/*
* @tc.name:subscribeCompass_SensorJsTest004
* @tc.desc:verify app info is not null
* @tc.type: FUNC
* @tc.require: SR000H0ALK, AR000H0ALM
*/
it
(
"
subscribeCompass_SensorJsTest004
"
,
0
,
function
(
done
)
{
console
.
info
(
'
----------------------subscribeCompass_SensorJsTest004---------------------------
'
);
try
{
sensor
.
subscribeCompass
({
success
:
function
(
data
)
{
console
.
info
(
"
subscribeCompass_SensorJsTest004 success:
"
+
JSON
.
stringify
(
data
));
expect
(
typeof
(
data
.
direction
)).
assertEqual
(
"
number
"
);
},
fail
:
function
(
data
,
code
)
{
console
.
error
(
'
subscribeCompass_SensorJsTest004 failed. Code:
'
+
code
+
'
; Data:
'
+
data
);
expect
(
false
).
assertTrue
();
},
},
function
()
{
},
25
);
}
catch
(
error
)
{
errMessage
=
error
.
toString
().
slice
(
19
,
56
);
console
.
info
(
'
subscribeCompass_SensorJsTest004 error:
'
+
error
);
expect
(
errMessage
).
assertEqual
(
errMessages
[
0
]);
done
();
}
})
/*
* @tc.name:subscribeCompass_SensorJsTest005
* @tc.desc:verify app info is not null
* @tc.type: FUNC
* @tc.require: SR000H0ALK, AR000H0ALM
*/
it
(
"
subscribeCompass_SensorJsTest005
"
,
0
,
async
function
(
done
)
{
console
.
info
(
'
----------------------subscribeCompass_SensorJsTest005---------------------------
'
);
try
{
sensor
.
unsubscribeCompass
(
'
xxx
'
);
}
catch
(
error
)
{
errMessage
=
error
.
toString
().
slice
(
21
,
58
);
console
.
info
(
'
subscribeCompass_SensorJsTest005 error:
'
+
error
);
expect
(
errMessage
).
assertEqual
(
errMessages
[
0
]);
done
();
}
})
/*
* @tc.name:subscribeCompass_SensorJsTest006
* @tc.desc:verify app info is not null
* @tc.type: FUNC
* @tc.require: SR000H0ALK, AR000H0ALM
*/
it
(
"
subscribeCompass_SensorJsTest006
"
,
0
,
async
function
(
done
)
{
console
.
info
(
'
----------------------subscribeCompass_SensorJsTest006---------------------------
'
);
try
{
sensor
.
subscribeCompass
();
}
catch
(
error
)
{
errMessage
=
error
.
toString
().
slice
(
19
,
56
);
console
.
info
(
'
subscribeCompass_SensorJsTest006 error:
'
+
error
);
expect
(
errMessage
).
assertEqual
(
errMessages
[
0
]);
done
();
}
})
/*
* @tc.name:subscribeCompass_SensorJsTest007
* @tc.desc:verify app info is not null
* @tc.type: FUNC
* @tc.require: SR000H0ALK, AR000H0ALM
*/
it
(
"
subscribeCompass_SensorJsTest007
"
,
0
,
async
function
(
done
)
{
console
.
info
(
'
----------------------subscribeCompass_SensorJsTest007---------------------------
'
);
try
{
sensor
.
subscribeCompass
(
'
xxx
'
);
}
catch
(
error
)
{
errMessage
=
error
.
toString
().
slice
(
19
,
56
);
console
.
info
(
'
subscribeCompass_SensorJsTest007 error:
'
+
error
);
expect
(
errMessage
).
assertEqual
(
errMessages
[
2
]);
done
();
}
})
/*
* @tc.name:subscribeCompass_SensorJsTest008
* @tc.desc:verify app info is not null
* @tc.type: FUNC
* @tc.require: SR000H0ALK, AR000H0ALM
*/
it
(
"
subscribeCompass_SensorJsTest008
"
,
0
,
function
(
done
)
{
console
.
info
(
'
----------------------subscribeCompass_SensorJsTest008---------------------------
'
);
sensor
.
subscribeCompass
({
success
:
function
(
data
)
{
console
.
info
(
"
subscribeCompass_SensorJsTest008 success:
"
+
JSON
.
stringify
(
data
));
expect
(
typeof
(
data
.
direction
)).
assertEqual
(
"
number
"
);
},
fail
:
function
(
data
,
code
)
{
console
.
error
(
'
subscribeCompass_SensorJsTest008 failed. Code:
'
+
code
+
'
; Data:
'
+
data
);
expect
(
false
).
assertTrue
();
},
});
sensor
.
subscribeCompass
({
success
:
function
(
data
)
{
console
.
info
(
"
subscribeCompass_SensorJsTest008_1 success:
"
+
JSON
.
stringify
(
data
));
expect
(
typeof
(
data
.
direction
)).
assertEqual
(
"
number
"
);
},
fail
:
function
(
data
,
code
)
{
console
.
error
(
'
subscribeCompass_SensorJsTest008_1 failed. Code:
'
+
code
+
'
; Data:
'
+
data
);
expect
(
false
).
assertTrue
();
},
});
setTimeout
(()
=>
{
try
{
sensor
.
unsubscribeCompass
();
}
catch
(
error
)
{
console
.
info
(
'
subscribeCompass_SensorJsTest008_unsubscribeCompass error
'
+
error
);
expect
(
false
).
assertTrue
();
}
setTimeout
(()
=>
{
expect
(
true
).
assertTrue
();
done
();
},
500
);
},
1000
);
})
/*
* @tc.name:subscribeCompass_SensorJsTest009
* @tc.desc:verify app info is not null
* @tc.type: FUNC
* @tc.require: SR000H0ALK, AR000H0ALM
*/
it
(
"
subscribeCompass_SensorJsTest009
"
,
0
,
async
function
(
done
)
{
console
.
info
(
'
----------------------subscribeCompass_SensorJsTest009---------------------------
'
);
try
{
sensor
.
unsubscribeCompass
();
}
catch
(
error
)
{
errMessage
=
error
.
toString
().
slice
(
21
,
45
);
console
.
info
(
'
subscribeCompass_SensorJsTest009 error:
'
+
error
);
expect
(
errMessage
).
assertEqual
(
errMessages
[
1
]);
done
();
}
})
/*
* @tc.name:subscribeCompass_SensorJsTest010
* @tc.desc:verify app info is not null
* @tc.type: FUNC
* @tc.require: SR000H0ALK, AR000H0ALM
*/
it
(
"
subscribeCompass_SensorJsTest010
"
,
0
,
function
(
done
)
{
console
.
info
(
'
----------------------subscribeCompass_SensorJsTest010---------------------------
'
);
sensor
.
subscribeCompass
({
success
:
function
(
data
)
{
console
.
info
(
"
subscribeCompass_SensorJsTest010 success:
"
+
JSON
.
stringify
(
data
));
expect
(
typeof
(
data
.
direction
)).
assertEqual
(
"
number
"
);
},
fail
:
function
(
data
,
code
)
{
console
.
error
(
'
subscribeCompass_SensorJsTest010 failed. Code:
'
+
code
+
'
; Data:
'
+
data
);
expect
(
false
).
assertTrue
();
},
});
try
{
sensor
.
unsubscribeCompass
();
}
catch
(
error
)
{
console
.
info
(
'
subscribeLight_SensorJsTest010_unsubscribeLight 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/subscribeDeviceOrientation.js
0 → 100644
浏览文件 @
c209d682
/*
* 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
'
)
})
let
errMessages
=
[
'
The number of parameters is not valid
'
,
'
Wrong argument type, should be object
'
,
'
UnsubscribeSensor failed
'
];
let
errMessage
;
/*
* @tc.name:subscribeDeviceOrientation_SensorJsTest001
* @tc.desc:verify app info is not null
* @tc.type: FUNC
* @tc.require: SR000H0ALK, AR000H0ALM
*/
it
(
"
subscribeDeviceOrientation_SensorJsTest001
"
,
0
,
async
function
(
done
)
{
console
.
info
(
'
----------------------subscribeDeviceOrientation_SensorJsTest001---------------------------
'
);
sensor
.
subscribeDeviceOrientation
({
interval
:
'
game
'
,
success
:
function
(
data
)
{
console
.
info
(
"
subscribeDeviceOrientation_SensorJsTest001 success
"
+
JSON
.
stringify
(
data
));
expect
(
typeof
(
data
.
alpha
)).
assertEqual
(
"
number
"
);
expect
(
typeof
(
data
.
beta
)).
assertEqual
(
"
number
"
);
expect
(
typeof
(
data
.
gamma
)).
assertEqual
(
"
number
"
);
},
fail
:
function
(
data
,
code
)
{
console
.
log
(
"
subscribeDeviceOrientation_SensorJsTest001 failed, data:
"
+
data
+
"
, code:
"
+
code
);
expect
(
false
).
assertTrue
();
},
});
setTimeout
(()
=>
{
try
{
sensor
.
unsubscribeDeviceOrientation
();
}
catch
(
error
)
{
console
.
info
(
'
subscribeDeviceOrientation_SensorJsTest001_unsubscribeDeviceOrientation error
'
+
error
);
expect
(
false
).
assertTrue
();
}
setTimeout
(()
=>
{
expect
(
true
).
assertTrue
();
done
();
},
500
);
},
1000
);
})
/*
* @tc.name:subscribeDeviceOrientation_SensorJsTest002
* @tc.desc:verify app info is not null
* @tc.type: FUNC
* @tc.require: SR000H0ALK, AR000H0ALM
*/
it
(
"
subscribeDeviceOrientation_SensorJsTest002
"
,
0
,
async
function
(
done
)
{
console
.
info
(
'
----------------------subscribeDeviceOrientation_SensorJsTest002---------------------------
'
);
sensor
.
subscribeDeviceOrientation
({
interval
:
'
ui
'
,
success
:
function
(
data
)
{
console
.
info
(
"
subscribeDeviceOrientation_SensorJsTest002 success
"
+
JSON
.
stringify
(
data
));
expect
(
typeof
(
data
.
alpha
)).
assertEqual
(
"
number
"
);
expect
(
typeof
(
data
.
beta
)).
assertEqual
(
"
number
"
);
expect
(
typeof
(
data
.
gamma
)).
assertEqual
(
"
number
"
);
},
fail
:
function
(
data
,
code
)
{
console
.
log
(
"
subscribeDeviceOrientation_SensorJsTest002 failed, data:
"
+
data
+
"
, code:
"
+
code
);
expect
(
false
).
assertTrue
();
},
});
setTimeout
(()
=>
{
try
{
sensor
.
unsubscribeDeviceOrientation
();
}
catch
(
error
)
{
console
.
info
(
'
subscribeDeviceOrientation_SensorJsTest002_unsubscribeDeviceOrientation error
'
+
error
);
expect
(
false
).
assertTrue
();
}
setTimeout
(()
=>
{
expect
(
true
).
assertTrue
();
done
();
},
500
);
},
1000
);
})
/*
* @tc.name:subscribeDeviceOrientation_SensorJsTest003
* @tc.desc:verify app info is not null
* @tc.type: FUNC
* @tc.require: SR000H0ALK, AR000H0ALM
*/
it
(
"
subscribeDeviceOrientation_SensorJsTest003
"
,
0
,
async
function
(
done
)
{
console
.
info
(
'
----------------------subscribeDeviceOrientation_SensorJsTest003---------------------------
'
);
sensor
.
subscribeDeviceOrientation
({
interval
:
'
normal
'
,
success
:
function
(
data
)
{
console
.
info
(
"
subscribeDeviceOrientation_SensorJsTest003 success
"
+
JSON
.
stringify
(
data
));
expect
(
typeof
(
data
.
alpha
)).
assertEqual
(
"
number
"
);
expect
(
typeof
(
data
.
beta
)).
assertEqual
(
"
number
"
);
expect
(
typeof
(
data
.
gamma
)).
assertEqual
(
"
number
"
);
},
fail
:
function
(
data
,
code
)
{
console
.
log
(
"
subscribeDeviceOrientation_SensorJsTest003 failed, data:
"
+
data
+
"
, code:
"
+
code
);
expect
(
false
).
assertTrue
();
},
});
setTimeout
(()
=>
{
try
{
sensor
.
unsubscribeDeviceOrientation
();
}
catch
(
error
)
{
console
.
info
(
'
subscribeDeviceOrientation_SensorJsTest003_ unsubscribeDeviceOrientation error
'
+
error
);
expect
(
false
).
assertTrue
();
}
setTimeout
(()
=>
{
expect
(
true
).
assertTrue
();
done
();
},
500
);
},
1000
);
})
/*
* @tc.name:subscribeDeviceOrientation_SensorJsTest004
* @tc.desc:verify app info is not null
* @tc.type: FUNC
* @tc.require: SR000H0ALK, AR000H0ALM
*/
it
(
"
subscribeDeviceOrientation_SensorJsTest004
"
,
0
,
async
function
(
done
)
{
console
.
info
(
'
----------------------subscribeDeviceOrientation_SensorJsTest004---------------------------
'
);
try
{
sensor
.
subscribeDeviceOrientation
({
interval
:
'
normal
'
,
success
:
function
(
data
)
{
console
.
info
(
"
subscribeDeviceOrientation_SensorJsTest004 success
"
+
JSON
.
stringify
(
data
));
expect
(
typeof
(
data
.
alpha
)).
assertEqual
(
"
number
"
);
expect
(
typeof
(
data
.
beta
)).
assertEqual
(
"
number
"
);
expect
(
typeof
(
data
.
gamma
)).
assertEqual
(
"
number
"
);
},
fail
:
function
(
data
,
code
)
{
console
.
log
(
"
subscribeDeviceOrientation_SensorJsTest004 failed, data:
"
+
data
+
"
, code:
"
+
code
);
expect
(
false
).
assertTrue
();
},
},
25
);
}
catch
(
error
)
{
errMessage
=
error
.
toString
().
slice
(
19
,
56
);
console
.
info
(
'
subscribeDeviceOrientation_SensorJsTest004 error:
'
+
error
);
expect
(
errMessage
).
assertEqual
(
errMessages
[
0
]);
done
();
}
})
/*
* @tc.name:subscribeDeviceOrientation_SensorJsTest005
* @tc.desc:verify app info is not null
* @tc.type: FUNC
* @tc.require: SR000H0ALK, AR000H0ALM
*/
it
(
"
subscribeDeviceOrientation_SensorJsTest005
"
,
0
,
async
function
(
done
)
{
console
.
info
(
'
----------------------subscribeDeviceOrientation_SensorJsTest005---------------------------
'
);
try
{
sensor
.
subscribeDeviceOrientation
({
interval
:
'
normal
'
,
success
:
function
(
data
)
{
console
.
info
(
"
subscribeDeviceOrientation_SensorJsTest005 success
"
+
JSON
.
stringify
(
data
));
expect
(
typeof
(
data
.
alpha
)).
assertEqual
(
"
number
"
);
expect
(
typeof
(
data
.
beta
)).
assertEqual
(
"
number
"
);
expect
(
typeof
(
data
.
gamma
)).
assertEqual
(
"
number
"
);
},
fail
:
function
(
data
,
code
)
{
console
.
log
(
"
subscribeDeviceOrientation_SensorJsTest005 failed, data:
"
+
data
+
"
, code:
"
+
code
);
expect
(
false
).
assertTrue
();
},
},
function
()
{
},
25
);
}
catch
(
error
)
{
errMessage
=
error
.
toString
().
slice
(
19
,
56
);
console
.
info
(
'
subscribeDeviceOrientation_SensorJsTest005 error:
'
+
error
);
expect
(
errMessage
).
assertEqual
(
errMessages
[
0
]);
done
();
}
})
/*
* @tc.name:subscribeDeviceOrientation_SensorJsTest006
* @tc.desc:verify app info is not null
* @tc.type: FUNC
* @tc.require: SR000H0ALK, AR000H0ALM
*/
it
(
"
subscribeDeviceOrientation_SensorJsTest006
"
,
0
,
async
function
(
done
)
{
console
.
info
(
'
----------------------subscribeDeviceOrientation_SensorJsTest006---------------------------
'
);
sensor
.
subscribeDeviceOrientation
({
interval
:
'
normal
'
,
success
:
function
(
data
)
{
console
.
info
(
"
subscribeDeviceOrientation_SensorJsTest006 success
"
+
JSON
.
stringify
(
data
));
expect
(
typeof
(
data
.
alpha
)).
assertEqual
(
"
number
"
);
expect
(
typeof
(
data
.
beta
)).
assertEqual
(
"
number
"
);
expect
(
typeof
(
data
.
gamma
)).
assertEqual
(
"
number
"
);
},
fail
:
function
(
data
,
code
)
{
console
.
log
(
"
subscribeDeviceOrientation_SensorJsTest006 failed, data:
"
+
data
+
"
, code:
"
+
code
);
expect
(
false
).
assertTrue
();
},
});
sensor
.
subscribeDeviceOrientation
({
interval
:
'
normal
'
,
success
:
function
(
data
)
{
console
.
info
(
"
subscribeDeviceOrientation_SensorJsTest006_1 success
"
+
JSON
.
stringify
(
data
));
expect
(
typeof
(
data
.
alpha
)).
assertEqual
(
"
number
"
);
expect
(
typeof
(
data
.
beta
)).
assertEqual
(
"
number
"
);
expect
(
typeof
(
data
.
gamma
)).
assertEqual
(
"
number
"
);
},
fail
:
function
(
data
,
code
)
{
console
.
log
(
"
subscribeDeviceOrientation_SensorJsTest006_1 failed, data:
"
+
data
+
"
, code:
"
+
code
);
expect
(
false
).
assertTrue
();
},
});
setTimeout
(()
=>
{
try
{
sensor
.
unsubscribeDeviceOrientation
();
}
catch
(
error
)
{
console
.
info
(
'
subscribeDeviceOrientation_SensorJsTest006_unsubscribeDeviceOrientation error
'
+
error
);
expect
(
false
).
assertTrue
();
}
setTimeout
(()
=>
{
expect
(
true
).
assertTrue
();
done
();
},
500
);
},
1000
);
})
/*
* @tc.name:subscribeDeviceOrientation_SensorJsTest007
* @tc.desc:verify app info is not null
* @tc.type: FUNC
* @tc.require: SR000H0ALK, AR000H0ALM
*/
it
(
"
subscribeDeviceOrientation_SensorJsTest007
"
,
0
,
async
function
(
done
)
{
console
.
info
(
'
----------------------subscribeDeviceOrientation_SensorJsTest007---------------------------
'
);
try
{
sensor
.
subscribeDeviceOrientation
();
}
catch
(
error
)
{
errMessage
=
error
.
toString
().
slice
(
19
,
56
);
console
.
info
(
'
subscribeDeviceOrientation_SensorJsTest007 error:
'
+
error
);
expect
(
errMessage
).
assertEqual
(
errMessages
[
0
]);
done
();
}
})
/*
* @tc.name:subscribeDeviceOrientation_SensorJsTest008
* @tc.desc:verify app info is not null
* @tc.type: FUNC
* @tc.require: SR000H0ALK, AR000H0ALM
*/
it
(
"
subscribeDeviceOrientation_SensorJsTest008
"
,
0
,
async
function
(
done
)
{
console
.
info
(
'
----------------------subscribeDeviceOrientation_SensorJsTest008---------------------------
'
);
try
{
sensor
.
subscribeDeviceOrientation
(
'
xxx
'
);
}
catch
(
error
)
{
errMessage
=
error
.
toString
().
slice
(
19
,
56
);
console
.
info
(
'
subscribeDeviceOrientation_SensorJsTest008 error:
'
+
error
);
expect
(
errMessage
).
assertEqual
(
errMessages
[
1
]);
done
();
}
})
/*
* @tc.name:subscribeDeviceOrientation_SensorJsTest009
* @tc.desc:verify app info is not null
* @tc.type: FUNC
* @tc.require: SR000H0ALK, AR000H0ALM
*/
it
(
"
subscribeDeviceOrientation_SensorJsTest009
"
,
0
,
async
function
(
done
)
{
console
.
info
(
'
----------------------subscribeDeviceOrientation_SensorJsTest009---------------------------
'
);
try
{
sensor
.
unsubscribeDeviceOrientation
(
'
xxx
'
);
}
catch
(
error
)
{
errMessage
=
error
.
toString
().
slice
(
21
,
58
);
console
.
info
(
'
subscribeDeviceOrientation_SensorJsTest009 error:
'
+
error
);
expect
(
errMessage
).
assertEqual
(
errMessages
[
0
]);
done
();
}
})
/*
* @tc.name:subscribeDeviceOrientation_SensorJsTest010
* @tc.desc:verify app info is not null
* @tc.type: FUNC
* @tc.require: SR000H0ALK, AR000H0ALM
*/
it
(
"
subscribeDeviceOrientation_SensorJsTest010
"
,
0
,
async
function
(
done
)
{
console
.
info
(
'
----------------------subscribeDeviceOrientation_SensorJsTest010---------------------------
'
);
sensor
.
subscribeDeviceOrientation
({
interval
:
'
xxx
'
,
success
:
function
(
data
)
{
console
.
info
(
"
subscribeDeviceOrientation_SensorJsTest010 success
"
+
JSON
.
stringify
(
data
));
expect
(
typeof
(
data
.
alpha
)).
assertEqual
(
"
number
"
);
expect
(
typeof
(
data
.
beta
)).
assertEqual
(
"
number
"
);
expect
(
typeof
(
data
.
gamma
)).
assertEqual
(
"
number
"
);
},
fail
:
function
(
data
,
code
)
{
console
.
log
(
"
subscribeDeviceOrientation_SensorJsTest010 failed, data:
"
+
data
+
"
, code:
"
+
code
);
expect
(
code
).
assertEqual
(
202
);
done
();
},
});
})
/*
* @tc.name:subscribeDeviceOrientation_SensorJsTest011
* @tc.desc:verify app info is not null
* @tc.type: FUNC
* @tc.require: SR000H0ALK, AR000H0ALM
*/
it
(
"
subscribeDeviceOrientation_SensorJsTest011
"
,
0
,
async
function
(
done
)
{
console
.
info
(
'
----------------------subscribeDeviceOrientation_SensorJsTest011---------------------------
'
);
try
{
sensor
.
unsubscribeDeviceOrientation
();
}
catch
(
error
)
{
errMessage
=
error
.
toString
().
slice
(
21
,
45
);
console
.
info
(
'
subscribeDeviceOrientation_SensorJsTest011 error:
'
+
error
);
expect
(
errMessage
).
assertEqual
(
errMessages
[
2
]);
done
();
}
})
/*
* @tc.name:subscribeDeviceOrientation_SensorJsTest012
* @tc.desc:verify app info is not null
* @tc.type: FUNC
* @tc.require: SR000H0ALK, AR000H0ALM
*/
it
(
"
subscribeDeviceOrientation_SensorJsTest012
"
,
0
,
async
function
(
done
)
{
console
.
info
(
'
----------------------subscribeDeviceOrientation_SensorJsTest012---------------------------
'
);
sensor
.
subscribeDeviceOrientation
({
interval
:
'
normal
'
,
success
:
function
(
data
)
{
console
.
info
(
"
subscribeDeviceOrientation_SensorJsTest012 success
"
+
JSON
.
stringify
(
data
));
expect
(
typeof
(
data
.
alpha
)).
assertEqual
(
"
number
"
);
expect
(
typeof
(
data
.
beta
)).
assertEqual
(
"
number
"
);
expect
(
typeof
(
data
.
gamma
)).
assertEqual
(
"
number
"
);
done
();
},
});
})
/*
* @tc.name:subscribeDeviceOrientation_SensorJsTest013
* @tc.desc:verify app info is not null
* @tc.type: FUNC
* @tc.require: SR000H0ALK, AR000H0ALM
*/
it
(
"
subscribeDeviceOrientation_SensorJsTest013
"
,
0
,
async
function
(
done
)
{
console
.
info
(
'
----------------------subscribeDeviceOrientation_SensorJsTest013---------------------------
'
);
sensor
.
subscribeDeviceOrientation
({
interval
:
'
normal
'
,
success
:
function
(
data
)
{
console
.
info
(
"
subscribeDeviceOrientation_SensorJsTest013 success
"
+
JSON
.
stringify
(
data
));
expect
(
typeof
(
data
.
alpha
)).
assertEqual
(
"
number
"
);
expect
(
typeof
(
data
.
beta
)).
assertEqual
(
"
number
"
);
expect
(
typeof
(
data
.
gamma
)).
assertEqual
(
"
number
"
);
done
();
},
fail
:
function
(
data
,
code
)
{
console
.
log
(
"
subscribeDeviceOrientation_SensorJsTest013 failed, data:
"
+
data
+
"
, code:
"
+
code
);
expect
(
false
).
assertTrue
();
},
});
})
/*
* @tc.name:subscribeDeviceOrientation_SensorJsTest014
* @tc.desc:verify app info is not null
* @tc.type: FUNC
* @tc.require: SR000H0ALK, AR000H0ALM
*/
it
(
"
subscribeDeviceOrientation_SensorJsTest014
"
,
0
,
async
function
(
done
)
{
console
.
info
(
'
----------------------subscribeDeviceOrientation_SensorJsTest014---------------------------
'
);
sensor
.
subscribeDeviceOrientation
({
interval
:
'
normal
'
,
success
:
function
(
data
)
{
console
.
info
(
"
subscribeDeviceOrientation_SensorJsTest014 success
"
+
JSON
.
stringify
(
data
));
expect
(
typeof
(
data
.
alpha
)).
assertEqual
(
"
number
"
);
expect
(
typeof
(
data
.
beta
)).
assertEqual
(
"
number
"
);
expect
(
typeof
(
data
.
gamma
)).
assertEqual
(
"
number
"
);
},
fail
:
function
(
data
,
code
)
{
console
.
log
(
"
subscribeDeviceOrientation_SensorJsTest014 failed, data:
"
+
data
+
"
, code:
"
+
code
);
expect
(
false
).
assertTrue
();
},
});
try
{
sensor
.
unsubscribeDeviceOrientation
();
}
catch
(
error
)
{
console
.
info
(
'
subscribeDeviceOrientation_SensorJsTest014_unsubscribeDeviceOrientation 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/subscribeHeartRate.js
0 → 100644
浏览文件 @
c209d682
/*
* 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
'
)
})
let
errMessages
=
[
'
The number of parameters is not valid
'
,
'
UnsubscribeSensor failed
'
,
'
Wrong argument type, should be object
'
];
let
errMessage
;
/*
* @tc.name:subscribeHeartRate_SensorJsTest001
* @tc.desc:verify app info is not null
* @tc.type: FUNC
* @tc.require: SR000H0ALK, AR000H0ALM
*/
it
(
"
subscribeHeartRate_SensorJsTest001
"
,
0
,
async
function
(
done
)
{
console
.
info
(
'
----------------------subscribeHeartRate_SensorJsTest001---------------------------
'
);
sensor
.
subscribeHeartRate
({
success
:
function
(
data
)
{
console
.
info
(
"
subscribeHeartRate_SensorJsTest001 success
"
+
JSON
.
stringify
(
data
));
expect
(
typeof
(
data
.
heartRate
)).
assertEqual
(
"
number
"
);
},
fail
:
function
(
data
,
code
)
{
console
.
error
(
'
subscribeHeartRate_SensorJsTest001 failed. Code:
'
+
code
+
'
; Data:
'
+
data
);
expect
(
code
).
assertEqual
(
1001
);
},
});
setTimeout
(()
=>
{
try
{
sensor
.
unsubscribeHeartRate
();
}
catch
(
error
)
{
console
.
info
(
'
subscribeHeartRate_SensorJsTest001_unsubscribeHeartRate error
'
+
error
);
}
setTimeout
(()
=>
{
expect
(
true
).
assertTrue
();
done
();
},
500
);
},
1000
);
})
/*
* @tc.name:subscribeHeartRate_SensorJsTest002
* @tc.desc:verify app info is not null
* @tc.type: FUNC
* @tc.require: SR000H0ALK, AR000H0ALM
*/
it
(
"
subscribeHeartRate_SensorJsTest002
"
,
0
,
function
(
done
)
{
console
.
info
(
'
----------------------subscribeHeartRate_SensorJsTest002---------------------------
'
);
try
{
sensor
.
subscribeHeartRate
({
success
:
function
(
data
)
{
console
.
info
(
"
subscribeHeartRate_SensorJsTest002 success:
"
+
JSON
.
stringify
(
data
));
expect
(
typeof
(
data
.
heartRate
)).
assertEqual
(
"
number
"
);
},
fail
:
function
(
data
,
code
)
{
console
.
error
(
'
subscribeHeartRate_SensorJsTest002 failed. Code:
'
+
code
+
'
; Data:
'
+
data
);
expect
(
code
).
assertEqual
(
1001
);
},
},
25
);
}
catch
(
error
)
{
errMessage
=
error
.
toString
().
slice
(
19
,
56
);
console
.
info
(
'
subscribeHeartRate_SensorJsTest002 error:
'
+
error
);
expect
(
errMessage
).
assertEqual
(
errMessages
[
0
]);
done
();
}
})
/*
* @tc.name:subscribeHeartRate_SensorJsTest003
* @tc.desc:verify app info is not null
* @tc.type: FUNC
* @tc.require: SR000H0ALK, AR000H0ALM
*/
it
(
"
subscribeHeartRate_SensorJsTest003
"
,
0
,
function
(
done
)
{
console
.
info
(
'
----------------------subscribeHeartRate_SensorJsTest003---------------------------
'
);
try
{
sensor
.
subscribeHeartRate
({
success
:
function
(
data
)
{
console
.
info
(
"
subscribeHeartRate_SensorJsTest003 success:
"
+
JSON
.
stringify
(
data
));
expect
(
typeof
(
data
.
heartRate
)).
assertEqual
(
"
number
"
);
},
fail
:
function
(
data
,
code
)
{
console
.
error
(
'
subscribeHeartRate_SensorJsTest003 failed. Code:
'
+
code
+
'
; Data:
'
+
data
);
expect
(
code
).
assertEqual
(
1001
);
},
},
function
()
{
},
25
);
}
catch
(
error
)
{
errMessage
=
error
.
toString
().
slice
(
19
,
56
);
console
.
info
(
'
subscribeHeartRate_SensorJsTest003 error:
'
+
error
);
expect
(
errMessage
).
assertEqual
(
errMessages
[
0
]);
done
();
}
})
/*
* @tc.name:subscribeHeartRate_SensorJsTest004
* @tc.desc:verify app info is not null
* @tc.type: FUNC
* @tc.require: SR000H0ALK, AR000H0ALM
*/
it
(
"
subscribeHeartRate_SensorJsTest004
"
,
0
,
async
function
(
done
)
{
console
.
info
(
'
----------------------subscribeHeartRate_SensorJsTest004---------------------------
'
);
try
{
sensor
.
unsubscribeHeartRate
(
'
xxx
'
);
}
catch
(
error
)
{
errMessage
=
error
.
toString
().
slice
(
21
,
58
);
console
.
info
(
'
subscribeHeartRate_SensorJsTest004 error:
'
+
error
);
expect
(
errMessage
).
assertEqual
(
errMessages
[
0
]);
done
();
}
})
/*
* @tc.name:subscribeHeartRate_SensorJsTest005
* @tc.desc:verify app info is not null
* @tc.type: FUNC
* @tc.require: SR000H0ALK, AR000H0ALM
*/
it
(
"
subscribeHeartRate_SensorJsTest005
"
,
0
,
async
function
(
done
)
{
console
.
info
(
'
----------------------subscribeHeartRate_SensorJsTest005---------------------------
'
);
try
{
sensor
.
subscribeHeartRate
();
}
catch
(
error
)
{
errMessage
=
error
.
toString
().
slice
(
19
,
56
);
console
.
info
(
'
subscribeHeartRate_SensorJsTest005 error:
'
+
error
);
expect
(
errMessage
).
assertEqual
(
errMessages
[
0
]);
done
();
}
})
/*
* @tc.name:subscribeHeartRate_SensorJsTest006
* @tc.desc:verify app info is not null
* @tc.type: FUNC
* @tc.require: SR000H0ALK, AR000H0ALM
*/
it
(
"
subscribeHeartRate_SensorJsTest006
"
,
0
,
async
function
(
done
)
{
console
.
info
(
'
----------------------subscribeHeartRate_SensorJsTest006---------------------------
'
);
try
{
sensor
.
subscribeHeartRate
(
'
xxx
'
);
}
catch
(
error
)
{
errMessage
=
error
.
toString
().
slice
(
19
,
56
);
console
.
info
(
'
subscribeHeartRate_SensorJsTest006 error:
'
+
error
);
expect
(
errMessage
).
assertEqual
(
errMessages
[
2
]);
done
();
}
})
/*
* @tc.name:subscribeHeartRate_SensorJsTest007
* @tc.desc:verify app info is not null
* @tc.type: FUNC
* @tc.require: SR000H0ALK, AR000H0ALM
*/
it
(
"
subscribeHeartRate_SensorJsTest007
"
,
0
,
function
(
done
)
{
console
.
info
(
'
----------------------subscribeHeartRate_SensorJsTest007---------------------------
'
);
sensor
.
subscribeHeartRate
({
success
:
function
(
data
)
{
console
.
info
(
"
subscribeHeartRate_SensorJsTest007 success:
"
+
JSON
.
stringify
(
data
));
expect
(
typeof
(
data
.
heartRate
)).
assertEqual
(
"
number
"
);
},
fail
:
function
(
data
,
code
)
{
console
.
error
(
'
subscribeHeartRate_SensorJsTest007 failed. Code:
'
+
code
+
'
; Data:
'
+
data
);
expect
(
code
).
assertEqual
(
1001
);
},
});
sensor
.
subscribeHeartRate
({
success
:
function
(
data
)
{
console
.
info
(
"
subscribeHeartRate_SensorJsTest007_1 success:
"
+
JSON
.
stringify
(
data
));
expect
(
typeof
(
data
.
heartRate
)).
assertEqual
(
"
number
"
);
},
fail
:
function
(
data
,
code
)
{
console
.
error
(
'
subscribeHeartRate_SensorJsTest007_1 failed. Code:
'
+
code
+
'
; Data:
'
+
data
);
expect
(
code
).
assertEqual
(
1001
);
},
});
setTimeout
(()
=>
{
try
{
sensor
.
unsubscribeHeartRate
();
}
catch
(
error
)
{
console
.
info
(
'
subscribeHeartRate_SensorJsTest007_unsubscribeHeartRate error
'
+
error
);
}
setTimeout
(()
=>
{
expect
(
true
).
assertTrue
();
done
();
},
500
);
},
1000
);
})
/*
* @tc.name:subscribeHeartRate_SensorJsTest008
* @tc.desc:verify app info is not null
* @tc.type: FUNC
* @tc.require: SR000H0ALK, AR000H0ALM
*/
it
(
"
subscribeHeartRate_SensorJsTest008
"
,
0
,
async
function
(
done
)
{
console
.
info
(
'
----------------------subscribeHeartRate_SensorJsTest008---------------------------
'
);
try
{
sensor
.
unsubscribeHeartRate
();
}
catch
(
error
)
{
errMessage
=
error
.
toString
().
slice
(
21
,
45
);
console
.
info
(
'
subscribeHeartRate_SensorJsTest008 error:
'
+
error
);
expect
(
errMessage
).
assertEqual
(
errMessages
[
1
]);
done
();
}
})
/*
* @tc.name:subscribeHeartRate_SensorJsTest009
* @tc.desc:verify app info is not null
* @tc.type: FUNC
* @tc.require: SR000H0ALK, AR000H0ALM
*/
it
(
"
subscribeHeartRate_SensorJsTest009
"
,
0
,
function
(
done
)
{
console
.
info
(
'
----------------------subscribeHeartRate_SensorJsTest009---------------------------
'
);
sensor
.
subscribeHeartRate
({
success
:
function
(
data
)
{
console
.
info
(
"
subscribeHeartRate_SensorJsTest009 success:
"
+
JSON
.
stringify
(
data
));
expect
(
typeof
(
data
.
heartRate
)).
assertEqual
(
"
number
"
);
},
fail
:
function
(
data
,
code
)
{
console
.
error
(
'
subscribeHeartRate_SensorJsTest009 failed. Code:
'
+
code
+
'
; Data:
'
+
data
);
expect
(
code
).
assertEqual
(
1001
);
},
});
try
{
sensor
.
unsubscribeHeartRate
();
}
catch
(
error
)
{
console
.
info
(
'
subscribeHeartRate_SensorJsTest009_unsubscribeHeartRate error
'
+
error
);
}
setTimeout
(()
=>
{
expect
(
true
).
assertTrue
();
done
();
},
500
);
})
})
\ No newline at end of file
sensors/sensor_standard/src/main/js/default/test/subscribeOnBodyState.js
0 → 100644
浏览文件 @
c209d682
/*
* 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
'
)
})
let
errMessages
=
[
'
The number of parameters is not valid
'
,
'
UnsubscribeSensor failed
'
,
'
Wrong argument type, should be object
'
];
let
errMessage
;
/*
* @tc.name:subscribeOnBodyState_SensorJsTest001
* @tc.desc:verify app info is not null
* @tc.type: FUNC
* @tc.require: SR000H0ALK, AR000H0ALM
*/
it
(
"
subscribeOnBodyState_SensorJsTest001
"
,
0
,
async
function
(
done
)
{
console
.
info
(
'
----------------------subscribeOnBodyState_SensorJsTest001---------------------------
'
);
sensor
.
subscribeOnBodyState
({
success
:
function
(
data
)
{
console
.
info
(
"
subscribeOnBodyState_SensorJsTest001 success
"
+
JSON
.
stringify
(
data
));
expect
(
typeof
(
data
.
value
)).
assertEqual
(
"
boolean
"
);
},
fail
:
function
(
data
,
code
)
{
console
.
error
(
'
subscribeOnBodyState_SensorJsTest001 failed. Code:
'
+
code
+
'
; Data:
'
+
data
);
expect
(
code
).
assertEqual
(
1001
);
},
});
setTimeout
(()
=>
{
try
{
sensor
.
unsubscribeOnBodyState
();
}
catch
(
error
)
{
console
.
info
(
'
subscribeOnBodyState_SensorJsTest001_unsubscribeOnBodyState error
'
+
error
);
}
setTimeout
(()
=>
{
expect
(
true
).
assertTrue
();
done
();
},
500
);
},
1000
);
})
/*
* @tc.name:subscribeOnBodyState_SensorJsTest002
* @tc.desc:verify app info is not null
* @tc.type: FUNC
* @tc.require: SR000H0ALK, AR000H0ALM
*/
it
(
"
subscribeOnBodyState_SensorJsTest002
"
,
0
,
function
(
done
)
{
console
.
info
(
'
----------------------subscribeOnBodyState_SensorJsTest002---------------------------
'
);
try
{
sensor
.
subscribeOnBodyState
({
success
:
function
(
data
)
{
console
.
info
(
"
subscribeOnBodyState_SensorJsTest002 success:
"
+
JSON
.
stringify
(
data
));
expect
(
typeof
(
data
.
value
)).
assertEqual
(
"
boolean
"
);
},
fail
:
function
(
data
,
code
)
{
console
.
error
(
'
subscribeOnBodyState_SensorJsTest002 failed. Code:
'
+
code
+
'
; Data:
'
+
data
);
expect
(
code
).
assertEqual
(
1001
);
},
},
25
);
}
catch
(
error
)
{
errMessage
=
error
.
toString
().
slice
(
19
,
56
);
console
.
info
(
'
subscribeOnBodyState_SensorJsTest002 error:
'
+
error
);
expect
(
errMessage
).
assertEqual
(
errMessages
[
0
]);
done
();
}
})
/*
* @tc.name:subscribeOnBodyState_SensorJsTest003
* @tc.desc:verify app info is not null
* @tc.type: FUNC
* @tc.require: SR000H0ALK, AR000H0ALM
*/
it
(
"
subscribeOnBodyState_SensorJsTest003
"
,
0
,
function
(
done
)
{
console
.
info
(
'
----------------------subscribeOnBodyState_SensorJsTest003---------------------------
'
);
try
{
sensor
.
subscribeOnBodyState
({
success
:
function
(
data
)
{
console
.
info
(
"
subscribeOnBodyState_SensorJsTest003 success:
"
+
JSON
.
stringify
(
data
));
expect
(
typeof
(
data
.
value
)).
assertEqual
(
"
boolean
"
);
},
fail
:
function
(
data
,
code
)
{
console
.
error
(
'
subscribeOnBodyState_SensorJsTest003 failed. Code:
'
+
code
+
'
; Data:
'
+
data
);
expect
(
code
).
assertEqual
(
1001
);
},
},
function
()
{
},
25
);
}
catch
(
error
)
{
var
errMessage
=
error
.
toString
().
slice
(
19
,
56
);
console
.
info
(
'
subscribeOnBodyState_SensorJsTest003 error:
'
+
error
);
expect
(
errMessage
).
assertEqual
(
errMessages
[
0
]);
done
();
}
})
/*
* @tc.name:subscribeOnBodyState_SensorJsTest004
* @tc.desc:verify app info is not null
* @tc.type: FUNC
* @tc.require: SR000H0ALK, AR000H0ALM
*/
it
(
"
subscribeOnBodyState_SensorJsTest004
"
,
0
,
async
function
(
done
)
{
console
.
info
(
'
----------------------subscribeOnBodyState_SensorJsTest004---------------------------
'
);
try
{
sensor
.
unsubscribeOnBodyState
(
'
xxx
'
);
}
catch
(
error
)
{
errMessage
=
error
.
toString
().
slice
(
21
,
58
);
console
.
info
(
'
subscribeOnBodyState_SensorJsTest004 error:
'
+
error
);
expect
(
errMessage
).
assertEqual
(
errMessages
[
0
]);
done
();
}
})
/*
* @tc.name:subscribeOnBodyState_SensorJsTest005
* @tc.desc:verify app info is not null
* @tc.type: FUNC
* @tc.require: SR000H0ALK, AR000H0ALM
*/
it
(
"
subscribeOnBodyState_SensorJsTest005
"
,
0
,
async
function
(
done
)
{
console
.
info
(
'
----------------------subscribeOnBodyState_SensorJsTest005---------------------------
'
);
try
{
sensor
.
subscribeOnBodyState
();
}
catch
(
error
)
{
errMessage
=
error
.
toString
().
slice
(
19
,
56
);
console
.
info
(
'
subscribeOnBodyState_SensorJsTest005 error:
'
+
error
);
expect
(
errMessage
).
assertEqual
(
errMessages
[
0
]);
done
();
}
})
/*
* @tc.name:subscribeOnBodyState_SensorJsTest006
* @tc.desc:verify app info is not null
* @tc.type: FUNC
* @tc.require: SR000H0ALK, AR000H0ALM
*/
it
(
"
subscribeOnBodyState_SensorJsTest006
"
,
0
,
async
function
(
done
)
{
console
.
info
(
'
----------------------subscribeOnBodyState_SensorJsTest006---------------------------
'
);
try
{
sensor
.
subscribeOnBodyState
(
'
xxx
'
);
}
catch
(
error
)
{
errMessage
=
error
.
toString
().
slice
(
19
,
56
);
console
.
info
(
'
subscribeOnBodyState_SensorJsTest006 error:
'
+
error
);
expect
(
errMessage
).
assertEqual
(
errMessages
[
2
]);
done
();
}
})
/*
* @tc.name:subscribeOnBodyState_SensorJsTest007
* @tc.desc:verify app info is not null
* @tc.type: FUNC
* @tc.require: SR000H0ALK, AR000H0ALM
*/
it
(
"
subscribeOnBodyState_SensorJsTest007
"
,
0
,
function
(
done
)
{
console
.
info
(
'
----------------------subscribeOnBodyState_SensorJsTest007---------------------------
'
);
sensor
.
subscribeOnBodyState
({
success
:
function
(
data
)
{
console
.
info
(
"
subscribeOnBodyState_SensorJsTest007 success:
"
+
JSON
.
stringify
(
data
));
expect
(
typeof
(
data
.
value
)).
assertEqual
(
"
boolean
"
);
},
fail
:
function
(
data
,
code
)
{
console
.
error
(
'
subscribeOnBodyState_SensorJsTest007 failed. Code:
'
+
code
+
'
; Data:
'
+
data
);
expect
(
code
).
assertEqual
(
1001
);
},
});
sensor
.
subscribeOnBodyState
({
success
:
function
(
data
)
{
console
.
info
(
"
subscribeOnBodyState_SensorJsTest007_1 success:
"
+
JSON
.
stringify
(
data
));
expect
(
typeof
(
data
.
value
)).
assertEqual
(
"
boolean
"
);
},
fail
:
function
(
data
,
code
)
{
console
.
error
(
'
subscribeOnBodyState_SensorJsTest007_1 failed. Code:
'
+
code
+
'
; Data:
'
+
data
);
expect
(
code
).
assertEqual
(
1001
);
},
});
setTimeout
(()
=>
{
try
{
sensor
.
unsubscribeOnBodyState
();
}
catch
(
error
)
{
console
.
info
(
'
subscribeOnBodyState_SensorJsTest007_unsubscribeOnBodyState error
'
+
error
);
}
setTimeout
(()
=>
{
expect
(
true
).
assertTrue
();
done
();
},
500
);
},
1000
);
})
/*
* @tc.name:subscribeOnBodyState_SensorJsTest008
* @tc.desc:verify app info is not null
* @tc.type: FUNC
* @tc.require: SR000H0ALK, AR000H0ALM
*/
it
(
"
subscribeOnBodyState_SensorJsTest008
"
,
0
,
async
function
(
done
)
{
console
.
info
(
'
----------------------subscribeOnBodyState_SensorJsTest008---------------------------
'
);
try
{
sensor
.
unsubscribeOnBodyState
();
}
catch
(
error
)
{
errMessage
=
error
.
toString
().
slice
(
21
,
45
);
console
.
info
(
'
subscribeOnBodyState_SensorJsTest008 error:
'
+
error
);
expect
(
errMessage
).
assertEqual
(
errMessages
[
1
]);
done
();
}
})
/*
* @tc.name:subscribeOnBodyState_SensorJsTest009
* @tc.desc:verify app info is not null
* @tc.type: FUNC
* @tc.require: SR000H0ALK, AR000H0ALM
*/
it
(
"
subscribeOnBodyState_SensorJsTest009
"
,
0
,
function
(
done
)
{
console
.
info
(
'
----------------------subscribeOnBodyState_SensorJsTest009---------------------------
'
);
sensor
.
subscribeOnBodyState
({
success
:
function
(
data
)
{
console
.
info
(
"
subscribeOnBodyState_SensorJsTest009 success:
"
+
JSON
.
stringify
(
data
));
expect
(
typeof
(
data
.
heartRate
)).
assertEqual
(
"
number
"
);
},
fail
:
function
(
data
,
code
)
{
console
.
error
(
'
subscribeOnBodyState_SensorJsTest009 failed. Code:
'
+
code
+
'
; Data:
'
+
data
);
expect
(
code
).
assertEqual
(
1001
);
},
});
try
{
sensor
.
unsubscribeOnBodyState
();
}
catch
(
error
)
{
console
.
info
(
'
subscribeOnBodyState_SensorJsTest009_unsubscribeOnBodyState error
'
+
error
);
}
setTimeout
(()
=>
{
expect
(
true
).
assertTrue
();
done
();
},
500
);
})
})
\ No newline at end of file
sensors/sensor_standard/src/main/js/default/test/subscribeProximity.js
0 → 100644
浏览文件 @
c209d682
/*
* 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
'
)
})
let
errMessages
=
[
'
The number of parameters is not valid
'
,
'
UnsubscribeSensor failed
'
,
'
Wrong argument type, should be object
'
];
let
errMessage
;
/*
* @tc.name:subscribeProximity_SensorJsTest001
* @tc.desc:verify app info is not null
* @tc.type: FUNC
* @tc.require: SR000H0ALK, AR000H0ALM
*/
it
(
"
subscribeProximity_SensorJsTest001
"
,
0
,
async
function
(
done
)
{
console
.
info
(
'
----------------------subscribeProximity_SensorJsTest001---------------------------
'
);
sensor
.
subscribeProximity
({
success
:
function
(
data
)
{
console
.
info
(
"
subscribeProximity_SensorJsTest001 success
"
+
JSON
.
stringify
(
data
));
expect
(
typeof
(
data
.
distance
)).
assertEqual
(
"
number
"
);
},
fail
:
function
(
data
,
code
)
{
console
.
error
(
'
subscribeProximity_SensorJsTest001 failed. Code:
'
+
code
+
'
; Data:
'
+
data
);
expect
(
code
).
assertEqual
(
1001
);
},
});
setTimeout
(()
=>
{
try
{
sensor
.
unsubscribeProximity
();
}
catch
(
error
)
{
console
.
info
(
error
);
}
setTimeout
(()
=>
{
expect
(
true
).
assertTrue
();
done
();
},
500
);
},
1000
);
})
/*
* @tc.name:subscribeProximity_SensorJsTest002
* @tc.desc:verify app info is not null
* @tc.type: FUNC
* @tc.require: SR000H0ALK, AR000H0ALM
*/
it
(
"
subscribeProximity_SensorJsTest002
"
,
0
,
function
(
done
)
{
console
.
info
(
'
----------------------subscribeProximity_SensorJsTest002---------------------------
'
);
try
{
sensor
.
subscribeProximity
({
success
:
function
(
data
)
{
console
.
info
(
"
subscribeProximity_SensorJsTest002 success:
"
+
JSON
.
stringify
(
data
));
expect
(
typeof
(
data
.
distance
)).
assertEqual
(
"
number
"
);
},
fail
:
function
(
data
,
code
)
{
console
.
error
(
'
subscribeProximity_SensorJsTest002 failed. Code:
'
+
code
+
'
; Data:
'
+
data
);
expect
(
code
).
assertEqual
(
1001
);
},
},
25
);
}
catch
(
error
)
{
errMessage
=
error
.
toString
().
slice
(
19
,
56
);
console
.
info
(
'
subscribeProximity_SensorJsTest002 error:
'
+
error
);
expect
(
errMessage
).
assertEqual
(
errMessages
[
0
]);
done
();
}
})
/*
* @tc.name:subscribeProximity_SensorJsTest003
* @tc.desc:verify app info is not null
* @tc.type: FUNC
* @tc.require: SR000H0ALK, AR000H0ALM
*/
it
(
"
subscribeProximity_SensorJsTest003
"
,
0
,
function
(
done
)
{
console
.
info
(
'
----------------------subscribeProximity_SensorJsTest003---------------------------
'
);
try
{
sensor
.
subscribeProximity
({
success
:
function
(
data
)
{
console
.
info
(
"
subscribeProximity_SensorJsTest003 success:
"
+
JSON
.
stringify
(
data
));
expect
(
typeof
(
data
.
distance
)).
assertEqual
(
"
number
"
);
},
fail
:
function
(
data
,
code
)
{
console
.
error
(
'
subscribeProximity_SensorJsTest003 failed. Code:
'
+
code
+
'
; Data:
'
+
data
);
expect
(
code
).
assertEqual
(
1001
);
},
},
function
()
{
},
25
);
}
catch
(
error
)
{
errMessage
=
error
.
toString
().
slice
(
19
,
56
);
console
.
info
(
'
subscribeProximity_SensorJsTest003 error:
'
+
error
);
expect
(
errMessage
).
assertEqual
(
errMessages
[
0
]);
done
();
}
})
/*
* @tc.name:subscribeProximity_SensorJsTest004
* @tc.desc:verify app info is not null
* @tc.type: FUNC
* @tc.require: SR000H0ALK, AR000H0ALM
*/
it
(
"
subscribeProximity_SensorJsTest004
"
,
0
,
async
function
(
done
)
{
console
.
info
(
'
----------------------subscribeProximity_SensorJsTest004---------------------------
'
);
try
{
sensor
.
unsubscribeProximity
(
'
xxx
'
);
}
catch
(
error
)
{
errMessage
=
error
.
toString
().
slice
(
21
,
58
);
console
.
info
(
'
subscribeProximity_SensorJsTest004 error:
'
+
error
);
expect
(
errMessage
).
assertEqual
(
errMessages
[
0
]);
done
();
}
})
/*
* @tc.name:subscribeProximity_SensorJsTest005
* @tc.desc:verify app info is not null
* @tc.type: FUNC
* @tc.require: SR000H0ALK, AR000H0ALM
*/
it
(
"
subscribeProximity_SensorJsTest005
"
,
0
,
async
function
(
done
)
{
console
.
info
(
'
----------------------subscribeProximity_SensorJsTest005---------------------------
'
);
try
{
sensor
.
subscribeProximity
();
}
catch
(
error
)
{
errMessage
=
error
.
toString
().
slice
(
19
,
56
);
console
.
info
(
'
subscribeProximity_SensorJsTest005 error:
'
+
error
);
expect
(
errMessage
).
assertEqual
(
errMessages
[
0
]);
done
();
}
})
/*
* @tc.name:subscribeProximity_SensorJsTest006
* @tc.desc:verify app info is not null
* @tc.type: FUNC
* @tc.require: SR000H0ALK, AR000H0ALM
*/
it
(
"
subscribeProximity_SensorJsTest006
"
,
0
,
async
function
(
done
)
{
console
.
info
(
'
----------------------subscribeProximity_SensorJsTest006---------------------------
'
);
try
{
sensor
.
subscribeProximity
(
'
xxx
'
);
}
catch
(
error
)
{
errMessage
=
error
.
toString
().
slice
(
19
,
56
);
console
.
info
(
'
subscribeProximity_SensorJsTest006 error:
'
+
error
);
expect
(
errMessage
).
assertEqual
(
errMessages
[
2
]);
done
();
}
})
/*
* @tc.name:subscribeProximity_SensorJsTest007
* @tc.desc:verify app info is not null
* @tc.type: FUNC
* @tc.require: SR000H0ALK, AR000H0ALM
*/
it
(
"
subscribeProximity_SensorJsTest007
"
,
0
,
function
(
done
)
{
console
.
info
(
'
----------------------subscribeProximity_SensorJsTest007---------------------------
'
);
sensor
.
subscribeProximity
({
success
:
function
(
data
)
{
console
.
info
(
"
subscribeProximity_SensorJsTest007 success:
"
+
JSON
.
stringify
(
data
));
expect
(
typeof
(
data
.
distance
)).
assertEqual
(
"
number
"
);
},
fail
:
function
(
data
,
code
)
{
console
.
error
(
'
subscribeProximity_SensorJsTest007 failed. Code:
'
+
code
+
'
; Data:
'
+
data
);
expect
(
code
).
assertEqual
(
1001
);
},
});
sensor
.
subscribeProximity
({
success
:
function
(
data
)
{
console
.
info
(
"
subscribeProximity_SensorJsTest007_1 success:
"
+
JSON
.
stringify
(
data
));
expect
(
typeof
(
data
.
distance
)).
assertEqual
(
"
number
"
);
},
fail
:
function
(
data
,
code
)
{
console
.
error
(
'
subscribeProximity_SensorJsTest007_1 failed. Code:
'
+
code
+
'
; Data:
'
+
data
);
expect
(
code
).
assertEqual
(
1001
);
},
});
setTimeout
(()
=>
{
try
{
sensor
.
unsubscribeProximity
();
}
catch
(
error
)
{
console
.
info
(
'
subscribeProximity_SensorJsTest007_unsubscribeProximity error
'
+
error
);
}
setTimeout
(()
=>
{
expect
(
true
).
assertTrue
();
done
();
},
500
);
},
1000
);
})
/*
* @tc.name:subscribeProximity_SensorJsTest008
* @tc.desc:verify app info is not null
* @tc.type: FUNC
* @tc.require: SR000H0ALK, AR000H0ALM
*/
it
(
"
subscribeProximity_SensorJsTest008
"
,
0
,
async
function
(
done
)
{
console
.
info
(
'
----------------------subscribeProximity_SensorJsTest008---------------------------
'
);
try
{
sensor
.
unsubscribeProximity
();
}
catch
(
error
)
{
errMessage
=
error
.
toString
().
slice
(
21
,
45
);
console
.
info
(
'
subscribeProximity_SensorJsTest008 error:
'
+
error
);
expect
(
errMessage
).
assertEqual
(
errMessages
[
1
]);
done
();
}
})
/*
* @tc.name:subscribeProximity_SensorJsTest009
* @tc.desc:verify app info is not null
* @tc.type: FUNC
* @tc.require: SR000H0ALK, AR000H0ALM
*/
it
(
"
subscribeProximity_SensorJsTest009
"
,
0
,
function
(
done
)
{
console
.
info
(
'
----------------------subscribeProximity_SensorJsTest009---------------------------
'
);
sensor
.
subscribeProximity
({
success
:
function
(
data
)
{
console
.
info
(
"
subscribeProximity_SensorJsTest009 success:
"
+
JSON
.
stringify
(
data
));
expect
(
typeof
(
data
.
distance
)).
assertEqual
(
"
number
"
);
},
fail
:
function
(
data
,
code
)
{
console
.
error
(
'
subscribeProximity_SensorJsTest009 failed. Code:
'
+
code
+
'
; Data:
'
+
data
);
expect
(
code
).
assertEqual
(
1001
);
},
});
try
{
sensor
.
unsubscribeProximity
();
}
catch
(
error
)
{
console
.
info
(
'
subscribeProximity_SensorJsTest009_unsubscribeProximity error
'
+
error
);
}
setTimeout
(()
=>
{
expect
(
true
).
assertTrue
();
done
();
},
500
);
})
})
\ No newline at end of file
sensors/sensor_standard/src/main/js/default/test/subscribeStepCounter.js
0 → 100644
浏览文件 @
c209d682
/*
* 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
'
)
})
let
errMessages
=
[
'
The number of parameters is not valid
'
,
'
UnsubscribeSensor failed
'
,
'
Wrong argument type, should be object
'
];
let
errMessage
;
/*
* @tc.name:subscribeStepCounter_SensorJsTest001
* @tc.desc:verify app info is not null
* @tc.type: FUNC
* @tc.require: SR000H0ALK, AR000H0ALM
*/
it
(
"
subscribeStepCounter_SensorJsTest001
"
,
0
,
async
function
(
done
)
{
console
.
info
(
'
----------------------subscribeStepCounter_SensorJsTest001---------------------------
'
);
sensor
.
subscribeStepCounter
({
success
:
function
(
data
)
{
console
.
info
(
"
subscribeStepCounter_SensorJsTest001 success
"
+
JSON
.
stringify
(
data
));
expect
(
typeof
(
data
.
steps
)).
assertEqual
(
"
number
"
);
},
fail
:
function
(
data
,
code
)
{
console
.
error
(
'
subscribeStepCounter_SensorJsTest001 failed. Code:
'
+
code
+
'
; Data:
'
+
data
);
expect
(
code
).
assertEqual
(
1001
);
},
});
setTimeout
(()
=>
{
try
{
sensor
.
unsubscribeStepCounter
();
}
catch
(
error
)
{
console
.
info
(
'
subscribeStepCounter_SensorJsTest001_unsubscribeStepCounter error
'
+
error
);
}
setTimeout
(()
=>
{
expect
(
true
).
assertTrue
();
done
();
},
500
);
},
1000
);
})
/*
* @tc.name:subscribeStepCounter_SensorJsTest002
* @tc.desc:verify app info is not null
* @tc.type: FUNC
* @tc.require: SR000H0ALK, AR000H0ALM
*/
it
(
"
subscribeStepCounter_SensorJsTest002
"
,
0
,
function
(
done
)
{
console
.
info
(
'
----------------------subscribeStepCounter_SensorJsTest002---------------------------
'
);
try
{
sensor
.
subscribeStepCounter
({
success
:
function
(
data
)
{
console
.
info
(
"
subscribeStepCounter_SensorJsTest002 success:
"
+
JSON
.
stringify
(
data
));
expect
(
typeof
(
data
.
steps
)).
assertEqual
(
"
number
"
);
},
fail
:
function
(
data
,
code
)
{
console
.
error
(
'
subscribeStepCounter_SensorJsTest002 failed. Code:
'
+
code
+
'
; Data:
'
+
data
);
expect
(
code
).
assertEqual
(
1001
);
},
},
25
);
}
catch
(
error
)
{
errMessage
=
error
.
toString
().
slice
(
19
,
56
);
console
.
info
(
'
subscribeStepCounter_SensorJsTest002 error:
'
+
error
);
expect
(
errMessage
).
assertEqual
(
errMessages
[
0
]);
done
();
}
})
/*
* @tc.name:subscribeStepCounter_SensorJsTest003
* @tc.desc:verify app info is not null
* @tc.type: FUNC
* @tc.require: SR000H0ALK, AR000H0ALM
*/
it
(
"
subscribeStepCounter_SensorJsTest003
"
,
0
,
function
(
done
)
{
console
.
info
(
'
----------------------subscribeStepCounter_SensorJsTest003---------------------------
'
);
try
{
sensor
.
subscribeStepCounter
({
success
:
function
(
data
)
{
console
.
info
(
"
subscribeStepCounter_SensorJsTest003 success:
"
+
JSON
.
stringify
(
data
));
expect
(
typeof
(
data
.
steps
)).
assertEqual
(
"
number
"
);
},
fail
:
function
(
data
,
code
)
{
console
.
error
(
'
subscribeStepCounter_SensorJsTest003 failed. Code:
'
+
code
+
'
; Data:
'
+
data
);
expect
(
code
).
assertEqual
(
1001
);
},
},
function
()
{},
25
);
}
catch
(
error
)
{
errMessage
=
error
.
toString
().
slice
(
19
,
56
);
console
.
info
(
'
subscribeStepCounter_SensorJsTest003 error:
'
+
error
);
expect
(
errMessage
).
assertEqual
(
errMessages
[
0
]);
done
();
}
})
/*
* @tc.name:subscribeStepCounter_SensorJsTest004
* @tc.desc:verify app info is not null
* @tc.type: FUNC
* @tc.require: SR000H0ALK, AR000H0ALM
*/
it
(
"
subscribeStepCounter_SensorJsTest004
"
,
0
,
async
function
(
done
)
{
console
.
info
(
'
----------------------subscribeStepCounter_SensorJsTest004---------------------------
'
);
try
{
sensor
.
unsubscribeStepCounter
(
'
xxx
'
);
}
catch
(
error
)
{
errMessage
=
error
.
toString
().
slice
(
21
,
58
);
console
.
info
(
'
subscribeStepCounter_SensorJsTest004 error:
'
+
error
);
expect
(
errMessage
).
assertEqual
(
errMessages
[
0
]);
done
();
}
})
/*
* @tc.name:subscribeStepCounter_SensorJsTest005
* @tc.desc:verify app info is not null
* @tc.type: FUNC
* @tc.require: SR000H0ALK, AR000H0ALM
*/
it
(
"
subscribeStepCounter_SensorJsTest005
"
,
0
,
async
function
(
done
)
{
console
.
info
(
'
----------------------subscribeStepCounter_SensorJsTest005---------------------------
'
);
try
{
sensor
.
subscribeStepCounter
();
}
catch
(
error
)
{
errMessage
=
error
.
toString
().
slice
(
19
,
56
);
console
.
info
(
'
subscribeStepCounter_SensorJsTest005 error:
'
+
error
);
expect
(
errMessage
).
assertEqual
(
errMessages
[
0
]);
done
();
}
})
/*
* @tc.name:subscribeStepCounter_SensorJsTest006
* @tc.desc:verify app info is not null
* @tc.type: FUNC
* @tc.require: SR000H0ALK, AR000H0ALM
*/
it
(
"
subscribeStepCounter_SensorJsTest006
"
,
0
,
async
function
(
done
)
{
console
.
info
(
'
----------------------subscribeStepCounter_SensorJsTest006---------------------------
'
);
try
{
sensor
.
subscribeStepCounter
(
'
xxx
'
);
}
catch
(
error
)
{
errMessage
=
error
.
toString
().
slice
(
19
,
56
);
console
.
info
(
'
subscribeStepCounter_SensorJsTest006 error:
'
+
error
);
expect
(
errMessage
).
assertEqual
(
errMessages
[
2
]);
done
();
}
})
/*
* @tc.name:subscribeStepCounter_SensorJsTest007
* @tc.desc:verify app info is not null
* @tc.type: FUNC
* @tc.require: SR000H0ALK, AR000H0ALM
*/
it
(
"
subscribeStepCounter_SensorJsTest007
"
,
0
,
function
(
done
)
{
console
.
info
(
'
----------------------subscribeStepCounter_SensorJsTest007---------------------------
'
);
sensor
.
subscribeStepCounter
({
success
:
function
(
data
)
{
console
.
info
(
"
subscribeStepCounter_SensorJsTest007 success:
"
+
JSON
.
stringify
(
data
));
expect
(
typeof
(
data
.
steps
)).
assertEqual
(
"
number
"
);
},
fail
:
function
(
data
,
code
)
{
console
.
error
(
'
subscribeStepCounter_SensorJsTest007 failed. Code:
'
+
code
+
'
; Data:
'
+
data
);
expect
(
code
).
assertEqual
(
1001
);
},
});
sensor
.
subscribeStepCounter
({
success
:
function
(
data
)
{
console
.
info
(
"
subscribeStepCounter_SensorJsTest007_1 success:
"
+
JSON
.
stringify
(
data
));
expect
(
typeof
(
data
.
steps
)).
assertEqual
(
"
number
"
);
},
fail
:
function
(
data
,
code
)
{
console
.
error
(
'
subscribeStepCounter_SensorJsTest007_1 failed. Code:
'
+
code
+
'
; Data:
'
+
data
);
expect
(
code
).
assertEqual
(
1001
);
},
});
setTimeout
(()
=>
{
try
{
sensor
.
unsubscribeStepCounter
();
}
catch
(
error
)
{
console
.
info
(
'
subscribeStepCounter_SensorJsTest007_unsubscribeStepCounter error
'
+
error
);
}
setTimeout
(()
=>
{
expect
(
true
).
assertTrue
();
done
();
},
500
);
},
1000
);
})
/*
* @tc.name:subscribeStepCounter_SensorJsTest008
* @tc.desc:verify app info is not null
* @tc.type: FUNC
* @tc.require: SR000H0ALK, AR000H0ALM
*/
it
(
"
subscribeStepCounter_SensorJsTest008
"
,
0
,
async
function
(
done
)
{
console
.
info
(
'
----------------------subscribeStepCounter_SensorJsTest008---------------------------
'
);
try
{
sensor
.
unsubscribeStepCounter
();
}
catch
(
error
)
{
errMessage
=
error
.
toString
().
slice
(
21
,
45
);
console
.
info
(
'
subscribeStepCounter_SensorJsTest008 error:
'
+
error
);
expect
(
errMessage
).
assertEqual
(
errMessages
[
1
]);
done
();
}
})
/*
* @tc.name:subscribeStepCounter_SensorJsTest009
* @tc.desc:verify app info is not null
* @tc.type: FUNC
* @tc.require: SR000H0ALK, AR000H0ALM
*/
it
(
"
subscribeStepCounter_SensorJsTest009
"
,
0
,
function
(
done
)
{
console
.
info
(
'
----------------------subscribeStepCounter_SensorJsTest009---------------------------
'
);
sensor
.
subscribeStepCounter
({
success
:
function
(
data
)
{
console
.
info
(
"
subscribeStepCounter_SensorJsTest009 success:
"
+
JSON
.
stringify
(
data
));
expect
(
typeof
(
data
.
steps
)).
assertEqual
(
"
number
"
);
},
fail
:
function
(
data
,
code
)
{
console
.
error
(
'
subscribeStepCounter_SensorJsTest009 failed. Code:
'
+
code
+
'
; Data:
'
+
data
);
expect
(
code
).
assertEqual
(
1001
);
},
});
try
{
sensor
.
unsubscribeStepCounter
();
}
catch
(
error
)
{
console
.
info
(
'
subscribeStepCounter_SensorJsTest009_unsubscribeStepCounter error
'
+
error
);
}
setTimeout
(()
=>
{
expect
(
true
).
assertTrue
();
done
();
},
500
);
})
})
\ No newline at end of file
鸿蒙社区
@harmonycommunity
mentioned in commit
358723b5
·
5月 26, 2022
mentioned in commit
358723b5
mentioned in commit 358723b53eea279122b27699d27d148e91ba0913
开关提交列表
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录