mirror of
https://gitee.com/openharmony/applications_app_samples
synced 2024-11-27 10:40:41 +00:00
!3193 【Sample】Camera初始测试用例覆盖功能
Merge pull request !3193 from BourneZ/cherry-pick-1690456184
This commit is contained in:
commit
da128fafbf
@ -13,37 +13,95 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
import hilog from '@ohos.hilog';
|
||||
import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from '@ohos/hypium'
|
||||
import { describe, it, expect } from '@ohos/hypium'
|
||||
import AbilityDelegatorRegistry from '@ohos.app.ability.abilityDelegatorRegistry';
|
||||
import { Driver, ON } from '@ohos.UiTest';
|
||||
import { getString } from '../util/ResourceUtil';
|
||||
|
||||
const DRIVER = Driver.create();
|
||||
const TAG = '[Sample_Camera]';
|
||||
const DOMAIN = 0x0000;
|
||||
const BUNDLE = 'Camera_';
|
||||
const WAITING_TIME = 1000;
|
||||
|
||||
export default function abilityTest() {
|
||||
describe('ActsAbilityTest', function () {
|
||||
// Defines a test suite. Two parameters are supported: test suite name and test suite function.
|
||||
beforeAll(function () {
|
||||
// Presets an action, which is performed only once before all test cases of the test suite start.
|
||||
// This API supports only one parameter: preset action function.
|
||||
/**
|
||||
* 拉起应用
|
||||
*/
|
||||
it('StartAbility_001', 0, async function (done) {
|
||||
hilog.info(DOMAIN, TAG, BUNDLE + 'StartAbility_001 begin');
|
||||
let abilityDelegatorRegistry = AbilityDelegatorRegistry.getAbilityDelegator();
|
||||
try {
|
||||
await abilityDelegatorRegistry.startAbility({
|
||||
bundleName: 'com.samples.camera',
|
||||
abilityName: 'EntryAbility'
|
||||
});
|
||||
done();
|
||||
} catch (err) {
|
||||
expect(0).assertEqual(err.code);
|
||||
hilog.info(DOMAIN, TAG, 'StartAbility err:' + JSON.stringify(err));
|
||||
done();
|
||||
}
|
||||
hilog.info(DOMAIN, TAG, BUNDLE + 'StartAbility_001 end');
|
||||
})
|
||||
beforeEach(function () {
|
||||
// Presets an action, which is performed before each unit test case starts.
|
||||
// The number of execution times is the same as the number of test cases defined by **it**.
|
||||
// This API supports only one parameter: preset action function.
|
||||
|
||||
/**
|
||||
* 获取权限
|
||||
*/
|
||||
it('RequestPermission_001', 0, async (done) => {
|
||||
hilog.info(DOMAIN, TAG, BUNDLE + 'RequestPermission_001 begin');
|
||||
await DRIVER.delayMs(WAITING_TIME);
|
||||
// 获取访问权限
|
||||
let tipAllow = getString($r('app.string.allow'));
|
||||
await DRIVER.assertComponentExist(ON.text(tipAllow));
|
||||
let btnAccept = await DRIVER.findComponent(ON.text(tipAllow));
|
||||
// 相机权限
|
||||
await btnAccept.click();
|
||||
await DRIVER.delayMs(WAITING_TIME);
|
||||
// 图片视频权限
|
||||
await btnAccept.click();
|
||||
await DRIVER.delayMs(WAITING_TIME);
|
||||
// 麦克风权限
|
||||
await btnAccept.click();
|
||||
await DRIVER.delayMs(WAITING_TIME);
|
||||
// 文件权限
|
||||
await btnAccept.click();
|
||||
await DRIVER.delayMs(WAITING_TIME);
|
||||
done();
|
||||
hilog.info(DOMAIN, TAG, BUNDLE + 'RequestPermissionFunction_001 end');
|
||||
})
|
||||
afterEach(function () {
|
||||
// Presets a clear action, which is performed after each unit test case ends.
|
||||
// The number of execution times is the same as the number of test cases defined by **it**.
|
||||
// This API supports only one parameter: clear action function.
|
||||
})
|
||||
afterAll(function () {
|
||||
// Presets a clear action, which is performed after all test cases of the test suite end.
|
||||
// This API supports only one parameter: clear action function.
|
||||
})
|
||||
it('assertContain',0, function () {
|
||||
// Defines a test case. This API supports three parameters: test case name, filter parameter, and test case function.
|
||||
hilog.info(0x0000, 'testTag', '%{public}s', 'it begin');
|
||||
let a = 'abc'
|
||||
let b = 'b'
|
||||
// Defines a variety of assertion methods, which are used to declare expected boolean conditions.
|
||||
expect(a).assertContain(b)
|
||||
expect(a).assertEqual(a)
|
||||
|
||||
/**
|
||||
* 属性设置
|
||||
*/
|
||||
it('CameraSetting_001', 0, async (done) => {
|
||||
hilog.info(DOMAIN, TAG, BUNDLE + 'CameraSetting_001 begin');
|
||||
// 进入设置界面
|
||||
let image = await DRIVER.findComponents(ON.type('Image'))
|
||||
await image[5].click()
|
||||
await DRIVER.delayMs(WAITING_TIME)
|
||||
// 进入旋转角度设置
|
||||
await DRIVER.assertComponentExist(ON.id('rotation'));
|
||||
let displayData = await DRIVER.findComponent(ON.id('rotation'));
|
||||
await displayData.click();
|
||||
await DRIVER.delayMs(WAITING_TIME);
|
||||
// 设置90旋转
|
||||
let set_90_rotate = getString($r('app.string.support_90_rotate'));
|
||||
await DRIVER.assertComponentExist(ON.text(set_90_rotate));
|
||||
let rotateSetting = await DRIVER.findComponent(ON.text(set_90_rotate));
|
||||
await rotateSetting.click();
|
||||
await DRIVER.delayMs(WAITING_TIME);
|
||||
// 确认选择
|
||||
let confirm = getString($r('app.string.confirm'));
|
||||
await DRIVER.assertComponentExist(ON.text(confirm));
|
||||
let confirmSetting = await DRIVER.findComponent(ON.text(confirm));
|
||||
await confirmSetting.click();
|
||||
await DRIVER.delayMs(WAITING_TIME);
|
||||
// 确定完成设置
|
||||
await DRIVER.assertComponentExist(ON.text(set_90_rotate));
|
||||
done();
|
||||
hilog.info(DOMAIN, TAG, BUNDLE + 'CameraSetting_001 end');
|
||||
})
|
||||
})
|
||||
}
|
@ -12,10 +12,22 @@
|
||||
"name": "TestAbility_label",
|
||||
"value": "test label"
|
||||
},
|
||||
{
|
||||
"name": "rotation_angle",
|
||||
"value": "拍摄旋转角度"
|
||||
},
|
||||
{
|
||||
"name": "resolution_ratio",
|
||||
"value": "录制分辨率"
|
||||
},
|
||||
{
|
||||
"name": "support_90_rotate",
|
||||
"value": "支持 90°C 旋转"
|
||||
},
|
||||
{
|
||||
"name": "confirm",
|
||||
"value": "确定"
|
||||
},
|
||||
{
|
||||
"name": "allow",
|
||||
"value": "允许"
|
||||
|
@ -0,0 +1,28 @@
|
||||
{
|
||||
"string": [
|
||||
{
|
||||
"name": "rotation_angle",
|
||||
"value": "Angle of rotation"
|
||||
},
|
||||
{
|
||||
"name": "resolution_ratio",
|
||||
"value": "size"
|
||||
},
|
||||
{
|
||||
"name": "support_90_rotate",
|
||||
"value": "support 90°C rotate"
|
||||
},
|
||||
{
|
||||
"name": "confirm",
|
||||
"value": "confirm"
|
||||
},
|
||||
{
|
||||
"name": "allow",
|
||||
"value": "ALLOW"
|
||||
},
|
||||
{
|
||||
"name": "whether",
|
||||
"value": "BAN"
|
||||
}
|
||||
]
|
||||
}
|
@ -0,0 +1,28 @@
|
||||
{
|
||||
"string": [
|
||||
{
|
||||
"name": "rotation_angle",
|
||||
"value": "拍摄旋转角度"
|
||||
},
|
||||
{
|
||||
"name": "resolution_ratio",
|
||||
"value": "录制分辨率"
|
||||
},
|
||||
{
|
||||
"name": "support_90_rotate",
|
||||
"value": "支持 90°C 旋转"
|
||||
},
|
||||
{
|
||||
"name": "confirm",
|
||||
"value": "确定"
|
||||
},
|
||||
{
|
||||
"name": "allow",
|
||||
"value": "允许"
|
||||
},
|
||||
{
|
||||
"name": "whether",
|
||||
"value": "是否"
|
||||
}
|
||||
]
|
||||
}
|
Loading…
Reference in New Issue
Block a user