未验证 提交 c76403dd 编写于 作者: O openharmony_ci 提交者: Gitee

!7843 【媒体子系统】增加try catch捕获UiDriver异常

Merge pull request !7843 from 秦莉文/monthly_20221018
......@@ -449,17 +449,22 @@ export default function audioCapturer() {
})
}
async function driveFn() {
console.info(`come in driveFn`);
let driver = await UiDriver.create();
console.info(`driver is ${JSON.stringify(driver)}`);
await sleep(100);
console.info(`UiDriver start`);
let button = await driver.findComponent(BY.text('允许'));
console.info(`button is ${JSON.stringify(button)}`);
await sleep(100);
await button.click();
try {
let driver = await UiDriver.create()
console.info(`case come in driveFn 222`)
console.info(`driver is ${JSON.stringify(driver)}`)
await sleep(100);
let button = await driver.findComponent(BY.text('允许'));
console.info(`button is ${JSON.stringify(button)}`);
await sleep(100);
await button.click();
} catch (err) {
console.info('err is ' + err);
return;
}
}
beforeAll(async function () {
await getPermission();
await driveFn();
......
......@@ -40,15 +40,20 @@ describe('audioVoip', function () {
})
}
async function driveFn() {
console.info(`come in driveFn`);
let driver = await UiDriver.create();
console.info(`driver is ${JSON.stringify(driver)}`);
await sleep(100);
console.info(`UiDriver start`);
let button = await driver.findComponent(BY.text('允许'));
console.info(`button is ${JSON.stringify(button)}`);
await sleep(100);
await button.click();
try {
let driver = await UiDriver.create()
console.info(`case come in driveFn 222`)
console.info(`driver is ${JSON.stringify(driver)}`)
await sleep(100);
console.info(`UiDriver start`);
let button = await driver.findComponent(BY.text('允许'));
console.info(`button is ${JSON.stringify(button)}`);
await sleep(100);
await button.click();
} catch (err) {
console.info('err is ' + err);
return;
}
}
beforeAll(async function () {
......
......@@ -14,7 +14,7 @@
*/
import resourceManager from '@ohos.resourceManager';
import {expect} from 'deccjsunit/index'
import { expect } from 'deccjsunit/index'
import router from '@system.router'
import mediaLibrary from '@ohos.multimedia.mediaLibrary'
import fileio from '@ohos.fileio'
......@@ -31,18 +31,23 @@ export async function getPermission(permissionNames) {
export async function driveFn(num) {
console.info(`case come in driveFn 111`)
let driver = await UiDriver.create()
console.info(`case come in driveFn 222`)
console.info(`driver is ${JSON.stringify(driver)}`)
await msleepAsync(2000)
console.info(`UiDriver start`)
for (let i = 0; i < num; i++) {
let button = await driver.findComponent(BY.text('允许'))
console.info(`button is ${JSON.stringify(button)}`)
try {
let driver = await UiDriver.create()
console.info(`case come in driveFn 222`)
console.info(`driver is ${JSON.stringify(driver)}`)
await msleepAsync(2000)
console.info(`UiDriver start`)
for (let i = 0; i < num; i++) {
let button = await driver.findComponent(BY.text('允许'))
console.info(`button is ${JSON.stringify(button)}`)
await msleepAsync(2000)
await button.click()
}
await msleepAsync(2000)
await button.click()
} catch (err) {
console.info('err is ' + err);
return;
}
await msleepAsync(2000)
}
// File operation
......@@ -50,7 +55,7 @@ export async function getFileDescriptor(fileName) {
let fileDescriptor = undefined;
await resourceManager.getResourceManager().then(async (mgr) => {
await mgr.getRawFileDescriptor(fileName).then(value => {
fileDescriptor = {fd: value.fd, offset: value.offset, length: value.length};
fileDescriptor = { fd: value.fd, offset: value.offset, length: value.length };
console.log('case getRawFileDescriptor success fileName: ' + fileName);
}).catch(error => {
console.log('case getRawFileDescriptor err: ' + error);
......@@ -61,7 +66,7 @@ export async function getFileDescriptor(fileName) {
export async function closeFileDescriptor(fileName) {
await resourceManager.getResourceManager().then(async (mgr) => {
await mgr.closeRawFileDescriptor(fileName).then(()=> {
await mgr.closeRawFileDescriptor(fileName).then(() => {
console.log('case closeRawFileDescriptor ' + fileName);
}).catch(error => {
console.log('case closeRawFileDescriptor err: ' + error);
......@@ -98,7 +103,7 @@ export async function closeFdNumber(fdNumber) {
// wait synchronously
export function msleep(time) {
for(let t = Date.now();Date.now() - t <= time;);
for (let t = Date.now(); Date.now() - t <= time;);
}
// wait asynchronously
......@@ -127,21 +132,21 @@ export function catchCallback(error) {
export function checkDescription(actualDescription, descriptionKey, descriptionValue) {
for (let i = 0; i < descriptionKey.length; i++) {
let property = actualDescription[descriptionKey[i]];
console.info('case key is '+ descriptionKey[i]);
console.info('case actual value is '+ property);
console.info('case hope value is '+ descriptionValue[i]);
console.info('case key is ' + descriptionKey[i]);
console.info('case actual value is ' + property);
console.info('case hope value is ' + descriptionValue[i]);
expect(property).assertEqual(descriptionValue[i]);
}
}
export function printDescription(obj) {
let description = "";
for(let i in obj) {
export function printDescription(obj) {
let description = "";
for (let i in obj) {
let property = obj[i];
console.info('case key is '+ i);
console.info('case value is '+ property);
description += i + " = " + property + "\n";
}
console.info('case key is ' + i);
console.info('case value is ' + property);
description += i + " = " + property + "\n";
}
}
export async function toNewPage(pagePath1, pagePath2, page) {
......@@ -167,8 +172,8 @@ export async function clearRouter() {
export async function getFd(pathName) {
let fdObject = {
fileAsset : null,
fdNumber : null
fileAsset: null,
fdNumber: null
}
let displayName = pathName;
const mediaTest = mediaLibrary.getMediaLibrary();
......@@ -179,8 +184,8 @@ export async function getFd(pathName) {
if (dataUri != undefined) {
let args = dataUri.id.toString();
let fetchOp = {
selections : fileKeyObj.ID + "=?",
selectionArgs : [args],
selections: fileKeyObj.ID + "=?",
selectionArgs: [args],
}
let fetchFileResult = await mediaTest.getFileAssets(fetchOp);
fdObject.fileAsset = await fetchFileResult.getAllObject();
......@@ -192,8 +197,8 @@ export async function getFd(pathName) {
export async function getAudioFd(pathName) {
let fdObject = {
fileAsset : null,
fdNumber : null
fileAsset: null,
fdNumber: null
}
let displayName = pathName;
const mediaTest = mediaLibrary.getMediaLibrary();
......@@ -204,8 +209,8 @@ export async function getAudioFd(pathName) {
if (dataUri != undefined) {
let args = dataUri.id.toString();
let fetchOp = {
selections : fileKeyObj.ID + "=?",
selectionArgs : [args],
selections: fileKeyObj.ID + "=?",
selectionArgs: [args],
}
let fetchFileResult = await mediaTest.getFileAssets(fetchOp);
fdObject.fileAsset = await fetchFileResult.getAllObject();
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册