mirror of
https://gitee.com/openharmony/applications_app_samples
synced 2024-11-23 08:30:06 +00:00
!2655 【Sample】增加Sensor自动化测试用例
Merge pull request !2655 from sephyrothcloud/master
This commit is contained in:
commit
0372ecb877
@ -14,14 +14,24 @@
|
||||
*/
|
||||
|
||||
import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from '@ohos/hypium'
|
||||
import { UiDriver, BY, UiComponent, MatchPattern } from '@ohos.uitest'
|
||||
import AbilityDelegatorRegistry from '@ohos.application.abilityDelegatorRegistry'
|
||||
import { Driver, ON, Component, MatchPattern, DisplayRotation } from '@ohos.UiTest'
|
||||
import abilityDelegatorRegistry from '@ohos.app.ability.abilityDelegatorRegistry'
|
||||
import hilog from '@ohos.hilog'
|
||||
|
||||
const TAG = '[Sample_Sensor]'
|
||||
const DOMAIN = 0xF811
|
||||
const BUNDLE = 'Sensor_'
|
||||
|
||||
// 检查页面是否正常显示
|
||||
async function checkPage(driver: Driver) {
|
||||
hilog.info(DOMAIN, TAG, 'checkPage begin')
|
||||
let resourceManager = abilityDelegatorRegistry.getAbilityDelegator().getAppContext().resourceManager
|
||||
await driver.assertComponentExist(ON.text(await resourceManager.getStringValue($r('app.string.directionNorth'))))
|
||||
await driver.assertComponentExist(ON.text(await resourceManager.getStringValue($r('app.string.angle'))))
|
||||
await driver.assertComponentExist(ON.type('Image'))
|
||||
hilog.info(DOMAIN, TAG, 'checkPage end')
|
||||
}
|
||||
|
||||
export default function appTest() {
|
||||
describe('appTest', function () {
|
||||
it(BUNDLE + 'StartAbility_001', 0, async function (done) {
|
||||
@ -30,9 +40,11 @@ export default function appTest() {
|
||||
bundleName: "ohos.samples.sensor",
|
||||
abilityName: "EntryAbility"
|
||||
}
|
||||
AbilityDelegatorRegistry.getAbilityDelegator().startAbility(parameter, (err, data) => {
|
||||
hilog.info(DOMAIN, TAG, BUNDLE + 'StartAbility_001,err.code:' + err.code)
|
||||
expect(0).assertEqual(err.code)
|
||||
abilityDelegatorRegistry.getAbilityDelegator().startAbility(parameter, (err, data) => {
|
||||
if (err !== null) {
|
||||
hilog.info(DOMAIN, TAG, BUNDLE + 'StartAbility_001,err.code:' + err.code)
|
||||
expect(0).assertEqual(err.code)
|
||||
}
|
||||
done()
|
||||
hilog.info(DOMAIN, TAG, BUNDLE + 'StartAbility_001 end')
|
||||
})
|
||||
@ -44,9 +56,52 @@ export default function appTest() {
|
||||
it(BUNDLE + 'BringSensorFunction_001', 0, async function () {
|
||||
// create UiDriver
|
||||
hilog.info(DOMAIN, TAG, BUNDLE + 'BringSensorFunction_001 begin')
|
||||
let driver = await UiDriver.create()
|
||||
let driver = await Driver.create()
|
||||
await driver.delayMs(1000)
|
||||
hilog.info(DOMAIN, TAG, BUNDLE + 'BringSensorFunction_001 end')
|
||||
})
|
||||
|
||||
/**
|
||||
* 检查页面控件是否正常显示
|
||||
*/
|
||||
it(BUNDLE + 'CheckSensorFunction_001', 0, async function () {
|
||||
// create UiDriver
|
||||
hilog.info(DOMAIN, TAG, BUNDLE + 'CheckSensorFunction_001 begin')
|
||||
let driver = await Driver.create()
|
||||
await driver.delayMs(500)
|
||||
await checkPage(driver)
|
||||
await driver.delayMs(500)
|
||||
hilog.info(DOMAIN, TAG, BUNDLE + 'CheckSensorFunction_001 end')
|
||||
})
|
||||
|
||||
/**
|
||||
* 切换到横屏(转动90°)
|
||||
*/
|
||||
it(BUNDLE + 'RotateScreenLandscapeFunction_001', 0, async function () {
|
||||
// create UiDriver
|
||||
hilog.info(DOMAIN, TAG, BUNDLE + 'RotateScreenLandscapeFunction_001 begin')
|
||||
let driver = await Driver.create()
|
||||
await driver.delayMs(1000)
|
||||
await driver.setDisplayRotation(DisplayRotation.ROTATION_90)
|
||||
await driver.delayMs(1000)
|
||||
await checkPage(driver)
|
||||
await driver.delayMs(1000)
|
||||
hilog.info(DOMAIN, TAG, BUNDLE + 'RotateScreenLandscapeFunction_001 end')
|
||||
})
|
||||
|
||||
/**
|
||||
* 切换回竖屏
|
||||
*/
|
||||
it(BUNDLE + 'RotateScreenPortraitFunction_001', 0, async function () {
|
||||
// create UiDriver
|
||||
hilog.info(DOMAIN, TAG, BUNDLE + 'RotateScreenPortraitFunction_001 begin')
|
||||
let driver = await Driver.create()
|
||||
await driver.delayMs(1000)
|
||||
await driver.setDisplayRotation(DisplayRotation.ROTATION_0)
|
||||
await driver.delayMs(1000)
|
||||
await checkPage(driver)
|
||||
await driver.delayMs(1000)
|
||||
hilog.info(DOMAIN, TAG, BUNDLE + 'RotateScreenPortraitFunction_001 end')
|
||||
})
|
||||
})
|
||||
}
|
@ -11,6 +11,14 @@
|
||||
{
|
||||
"name": "TestAbility_label",
|
||||
"value": "test label"
|
||||
},
|
||||
{
|
||||
"name": "directionNorth",
|
||||
"value": "north"
|
||||
},
|
||||
{
|
||||
"name": "angle",
|
||||
"value": "0°"
|
||||
}
|
||||
]
|
||||
}
|
@ -0,0 +1,24 @@
|
||||
{
|
||||
"string": [
|
||||
{
|
||||
"name": "module_test_desc",
|
||||
"value": "test ability description"
|
||||
},
|
||||
{
|
||||
"name": "TestAbility_desc",
|
||||
"value": "the test ability"
|
||||
},
|
||||
{
|
||||
"name": "TestAbility_label",
|
||||
"value": "test label"
|
||||
},
|
||||
{
|
||||
"name": "directionNorth",
|
||||
"value": "north"
|
||||
},
|
||||
{
|
||||
"name": "angle",
|
||||
"value": "0°"
|
||||
}
|
||||
]
|
||||
}
|
@ -0,0 +1,24 @@
|
||||
{
|
||||
"string": [
|
||||
{
|
||||
"name": "module_test_desc",
|
||||
"value": "test ability description"
|
||||
},
|
||||
{
|
||||
"name": "TestAbility_desc",
|
||||
"value": "the test ability"
|
||||
},
|
||||
{
|
||||
"name": "TestAbility_label",
|
||||
"value": "test label"
|
||||
},
|
||||
{
|
||||
"name": "directionNorth",
|
||||
"value": "北"
|
||||
},
|
||||
{
|
||||
"name": "angle",
|
||||
"value": "0°"
|
||||
}
|
||||
]
|
||||
}
|
12
code/BasicFeature/DeviceManagement/Sensor/ohosTest.md
Normal file
12
code/BasicFeature/DeviceManagement/Sensor/ohosTest.md
Normal file
@ -0,0 +1,12 @@
|
||||
# FileManager 测试用例归档
|
||||
|
||||
## 用例表
|
||||
|
||||
|测试功能|预置条件|输入|预期输出|测试结果|
|
||||
|--------------------------------|--------------------------------|--------------------------------|--------------------------------|--------------------------------|
|
||||
|拉起应用| 设备正常运行| |成功拉起应用|Pass|
|
||||
|检查UI是否正常显示| 位于主页| |UI正常显示|Pass|
|
||||
|切换横屏| 位于主页| 旋转90°| 主页转为横屏显示|Pass|
|
||||
|检查UI是否正常显示| 位于主页| | UI正常显示|Pass|
|
||||
|切回竖屏| 位于主页| 往回旋转90°| 主页转为竖屏显示|Pass|
|
||||
|检查UI是否正常显示| 位于主页| | UI正常显示|Pass|
|
Loading…
Reference in New Issue
Block a user