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

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

Merge pull request !7843 from 秦莉文/monthly_20221018
......@@ -449,15 +449,20 @@ export default function audioCapturer() {
})
}
async function driveFn() {
console.info(`come in driveFn`);
let driver = await UiDriver.create();
console.info(`driver is ${JSON.stringify(driver)}`);
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 () {
......
......@@ -19,7 +19,7 @@ import { afterAll, afterEach, beforeAll, beforeEach, describe, expect, it } from
import { UiDriver, BY } from '@ohos.UiTest'
export default function audioCapturerChange() {
describe('audioCapturerChange', function () {
describe('audioCapturerChange', function () {
let audioStreamManager;
let audioStreamManagerCB;
let Tag = "AFCapLog";
......@@ -37,15 +37,20 @@ describe('audioCapturerChange', function () {
})
}
async function driveFn() {
console.info(`come in driveFn`);
let driver = await UiDriver.create();
console.info(`driver is ${JSON.stringify(driver)}`);
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 () {
......@@ -1638,5 +1643,5 @@ describe('audioCapturerChange', function () {
});
})
})
})
}
\ No newline at end of file
......@@ -20,7 +20,7 @@ import { UiDriver, BY } from '@ohos.UiTest'
export default function audioFramework() {
describe('audioFramework', function () {
describe('audioFramework', function () {
let TagFrmwk = "AudioFrameworkTest";
console.info(`${TagFrmwk}: Create AudioManger Object JS Framework`);
let audioManager = null;
......@@ -105,15 +105,20 @@ describe('audioFramework', function () {
})
}
async function driveFn() {
console.info(`come in driveFn`);
let driver = await UiDriver.create();
console.info(`driver is ${JSON.stringify(driver)}`);
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 () {
......@@ -3580,15 +3585,15 @@ describe('audioFramework', function () {
});
await audioManager.isDeviceActive(audio.ActiveDeviceType.SPEAKER).then(function (value) {
if (flag == true && value == false) {
console.info(`SUB_MULTIMEDIA_AUDIO_MANAGER_SETDEVICEACTIVE_0100 isDeviceActive : SPEAKER: Deactivate : PASS :${value } flag is ${flag}`);
console.info(`SUB_MULTIMEDIA_AUDIO_MANAGER_SETDEVICEACTIVE_0100 isDeviceActive : SPEAKER: Deactivate : PASS :${value} flag is ${flag}`);
expect(true).assertTrue();
}
else if (flag == false && value == true) {
console.info(`SUB_MULTIMEDIA_AUDIO_MANAGER_SETDEVICEACTIVE_0100 isDeviceActive : SPEAKER: Deactivate : PASS :${value } flag is ${flag}`);
console.info(`SUB_MULTIMEDIA_AUDIO_MANAGER_SETDEVICEACTIVE_0100 isDeviceActive : SPEAKER: Deactivate : PASS :${value} flag is ${flag}`);
expect(true).assertTrue();
}
else {
console.info(`SUB_MULTIMEDIA_AUDIO_MANAGER_SETDEVICEACTIVE_0100 isDeviceActive : SPEAKER: Deactivate : fail :${value } flag is ${flag}`);
console.info(`SUB_MULTIMEDIA_AUDIO_MANAGER_SETDEVICEACTIVE_0100 isDeviceActive : SPEAKER: Deactivate : fail :${value} flag is ${flag}`);
expect(false).assertTrue();
}
}).catch((err) => {
......@@ -3637,7 +3642,7 @@ describe('audioFramework', function () {
*@tc.type : Function
*@tc.level : Level 2
*/
it('SUB_MULTIMEDIA_AUDIO_MANAGER_SETDEVICEACTIVE_0300', 2,async function (done) {
it('SUB_MULTIMEDIA_AUDIO_MANAGER_SETDEVICEACTIVE_0300', 2, async function (done) {
let flag = true
let outputDeviceDescription = await audioManager.getDevices(audio.DeviceFlag.OUTPUT_DEVICES_FLAG);
console.info(`SUB_MULTIMEDIA_AUDIO_MANAGER_SETDEVICEACTIVE_0300 outputDeviceDescription is ${JSON.stringify(outputDeviceDescription)}`);
......@@ -3656,14 +3661,14 @@ describe('audioFramework', function () {
console.error(`${TagFrmwk}: Device Test: Callback : isDeviceActive : SPEAKER: Deactivate: Error: ${err.message}`);
expect(false).assertTrue();
} else if (value == false && flag == true) {
console.info(`${TagFrmwk}: Device Test: Callback : isDeviceActive : SPEAKER: Deactivate : PASS :${value } flag is ${flag}`);
console.info(`${TagFrmwk}: Device Test: Callback : isDeviceActive : SPEAKER: Deactivate : PASS :${value} flag is ${flag}`);
expect(true).assertTrue();
} else if (value == true && flag == false) {
console.info(`${TagFrmwk}: Device Test: Callback : isDeviceActive : SPEAKER: Deactivate : PASS :${value } flag is ${flag}`);
console.info(`${TagFrmwk}: Device Test: Callback : isDeviceActive : SPEAKER: Deactivate : PASS :${value} flag is ${flag}`);
expect(true).assertTrue();
}
else {
console.info(`SUB_MULTIMEDIA_AUDIO_MANAGER_SETDEVICEACTIVE_0300 ${TagFrmwk}: Device Test: Callback : isDeviceActive : SPEAKER: Deactivate : FAIL :${value } flag is ${flag}`);
console.info(`SUB_MULTIMEDIA_AUDIO_MANAGER_SETDEVICEACTIVE_0300 ${TagFrmwk}: Device Test: Callback : isDeviceActive : SPEAKER: Deactivate : FAIL :${value} flag is ${flag}`);
expect(false).assertTrue();
}
done();
......@@ -4675,7 +4680,7 @@ describe('audioFramework', function () {
*@tc.type : Function
*@tc.level : Level 2
*/
it('SUB_MULTIMEDIA_AUDIO_ROUTING_MANAGER_GETDEVICES_0100', 2,async function (done) {
it('SUB_MULTIMEDIA_AUDIO_ROUTING_MANAGER_GETDEVICES_0100', 2, async function (done) {
let AudioRoutingManager = audioManager.getRoutingManager();
AudioRoutingManager.getDevices(1, (err, value) => {
// Getting all Output devices Enumb 1 = OUTPUT_DEVICES_FLAG
......@@ -4709,7 +4714,7 @@ describe('audioFramework', function () {
*@tc.type : Function
*@tc.level : Level 2
*/
it('SUB_MULTIMEDIA_AUDIO_ROUTING_MANAGER_GETDEVICES_0200', 2,async function (done) {
it('SUB_MULTIMEDIA_AUDIO_ROUTING_MANAGER_GETDEVICES_0200', 2, async function (done) {
let AudioRoutingManager = audioManager.getRoutingManager();
AudioRoutingManager.getDevices(2, (err, value) => {
// Getting all Input Devices ENUM 2 = INPUT_DEVICES_FLAG
......@@ -4914,5 +4919,5 @@ describe('audioFramework', function () {
await sleep(50);
done();
})
})
})
}
......@@ -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)}`);
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,6 +31,7 @@ export async function getPermission(permissionNames) {
export async function driveFn(num) {
console.info(`case come in driveFn 111`)
try {
let driver = await UiDriver.create()
console.info(`case come in driveFn 222`)
console.info(`driver is ${JSON.stringify(driver)}`)
......@@ -43,6 +44,10 @@ export async function driveFn(num) {
await button.click()
}
await msleepAsync(2000)
} catch (err) {
console.info('err is ' + err);
return;
}
}
// 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,19 +132,19 @@ 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) {
for (let i in obj) {
let property = obj[i];
console.info('case key is '+ i);
console.info('case value is '+ property);
console.info('case key is ' + i);
console.info('case value is ' + property);
description += i + " = " + property + "\n";
}
}
......@@ -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.
先完成此消息的编辑!
想要评论请 注册