!3212 【Sample】ScreenRecorder补充关闭按钮测试用例

Merge pull request !3212 from BourneZ/cherry-pick-1690861971
This commit is contained in:
openharmony_ci 2023-08-02 03:52:33 +00:00 committed by Gitee
commit 8d57bd7393
No known key found for this signature in database
GPG Key ID: 173E9B9CA92EEF8F
5 changed files with 73 additions and 4 deletions

View File

@ -18,6 +18,7 @@ import { Driver, ON } from '@ohos.UiTest';
import hilog from '@ohos.hilog';
import AbilityDelegatorRegistry from '@ohos.app.ability.abilityDelegatorRegistry';
import mediaLibrary from '@ohos.multimedia.mediaLibrary';
import { getString } from '../utils/ResourceUtil';
const TAG: string = 'abilityTest';
const DRIVER = Driver.create();
@ -54,14 +55,18 @@ export default function abilityTest() {
it('GetPermission_001', 0, async () => {
hilog.info(DOMAIN, TAG, BUNDLE + 'GetPermission_001 begin');
await DRIVER.delayMs(3000);
await DRIVER.assertComponentExist(ON.text('允许'));
let allowBtn1 = await DRIVER.findComponent(ON.text('允许'));
let tipAllow = getString($r('app.string.allow'));
await DRIVER.assertComponentExist(ON.text(tipAllow));
// 访问图片和视频
let allowBtn1 = await DRIVER.findComponent(ON.text(tipAllow));
await allowBtn1.click();
await DRIVER.delayMs(1000);
let allowBtn2 = await DRIVER.findComponent(ON.text('允许'));
// 访问文件授权
let allowBtn2 = await DRIVER.findComponent(ON.text(tipAllow));
await allowBtn2.click();
await DRIVER.delayMs(1000);
let allowBtn3 = await DRIVER.findComponent(ON.text('允许'));
// 麦克风授权
let allowBtn3 = await DRIVER.findComponent(ON.text(tipAllow));
await allowBtn3.click();
await DRIVER.delayMs(1000);
// 获取当前应用的ability
@ -101,6 +106,9 @@ export default function abilityTest() {
let stopRecordBtn = await DRIVER.findComponent(ON.id('stopRecord'));
await stopRecordBtn.click();
hilog.info(DOMAIN, TAG, BUNDLE + 'StopRecord_001 click');
await DRIVER.delayMs(1000);
// 确定关闭后,停止按钮消失
expect(await stopRecordBtn.isEnabled()).assertNull();
await DRIVER.delayMs(10000);
// 再次获取媒体库中的视频数量
// 读取媒体库的视频资源

View File

@ -0,0 +1,29 @@
/*
* Copyright (c) 2023 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 AbilityDelegatorRegistry from '@ohos.app.ability.abilityDelegatorRegistry';
const delegator = AbilityDelegatorRegistry.getAbilityDelegator();
export function getString(resource: Resource): string {
let manage = delegator.getAppContext().resourceManager
return manage.getStringSync(resource)
}
export async function getStringArray(resource: Resource): Promise<Array<string>> {
let manage = delegator.getAppContext().resourceManager
let menuList: Array<string> = await manage.getStringArrayValue(resource);
return menuList;
}

View File

@ -11,6 +11,14 @@
{
"name": "TestAbility_label",
"value": "test label"
},
{
"name": "allow",
"value": "允许"
},
{
"name": "whether",
"value": "是否"
}
]
}

View File

@ -0,0 +1,12 @@
{
"string": [
{
"name": "allow",
"value": "ALLOW"
},
{
"name": "whether",
"value": "BAN"
}
]
}

View File

@ -0,0 +1,12 @@
{
"string": [
{
"name": "allow",
"value": "允许"
},
{
"name": "whether",
"value": "是否"
}
]
}