提交 09ad8404 编写于 作者: F fulizhong

modify testcase Signed-off-by: NOBUGGERS<ruanmeng@huawei.com>

Signed-off-by: Nfulizhong <fulizhong@huawei.com>
上级 fef51156
...@@ -16,14 +16,35 @@ ...@@ -16,14 +16,35 @@
import resourceManager from '@ohos.resourceManager'; import resourceManager from '@ohos.resourceManager';
import {expect} from 'deccjsunit/index' import {expect} from 'deccjsunit/index'
import router from '@system.router' import router from '@system.router'
import abilityAccessCtrl from '@ohos.abilityAccessCtrl'
import bundle from '@ohos.bundle'
import mediaLibrary from '@ohos.multimedia.mediaLibrary' import mediaLibrary from '@ohos.multimedia.mediaLibrary'
import fileio from '@ohos.fileio' import fileio from '@ohos.fileio'
import featureAbility from '@ohos.ability.featureAbility' import featureAbility from '@ohos.ability.featureAbility'
import { UiDriver, BY, PointerMatrix } from '@ohos.uitest'
const context = featureAbility.getContext(); const context = featureAbility.getContext();
export async function getPermission(permissionNames) {
featureAbility.getContext().requestPermissionsFromUser(permissionNames, 0, async (data) => {
console.info("case request success" + JSON.stringify(data));
})
}
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)}`)
await msleepAsync(2000)
await button.click()
}
await msleepAsync(2000)
}
// File operation // File operation
export async function getFileDescriptor(fileName) { export async function getFileDescriptor(fileName) {
let fileDescriptor = undefined; let fileDescriptor = undefined;
...@@ -205,22 +226,3 @@ export async function closeFd(fileAsset, fdNumber) { ...@@ -205,22 +226,3 @@ export async function closeFd(fileAsset, fdNumber) {
console.info('[mediaLibrary] case fileAsset is null'); console.info('[mediaLibrary] case fileAsset is null');
} }
} }
// apply permission for test hap
export async function applyPermission(applictionName, permissionNames) {
let appInfo = await bundle.getApplicationInfo(applictionName, 0, 100);
let atManager = abilityAccessCtrl.createAtManager();
if (atManager != null) {
let tokenID = appInfo.accessTokenId;
console.info('[permission] case accessTokenID is ' + tokenID);
for (let i = 0; i < permissionNames.length; i++) {
await atManager.grantUserGrantedPermission(tokenID, permissionNames[i], 1).then((result) => {
console.info('[permission] case grantUserGrantedPermission success :' + result);
}).catch((err) => {
console.info('[permission] case grantUserGrantedPermission failed :' + err);
});
}
} else {
console.info('[permission] case apply permission failed, createAtManager failed');
}
}
\ No newline at end of file
...@@ -25,7 +25,9 @@ ohos_js_hap_suite("audio_recorder_js_hap") { ...@@ -25,7 +25,9 @@ ohos_js_hap_suite("audio_recorder_js_hap") {
part_name = "multimedia_player_framework" part_name = "multimedia_player_framework"
} }
ohos_js_assets("audio_recorder_js_assets") { ohos_js_assets("audio_recorder_js_assets") {
source_dir = "./src/main/js/default" js2abc = true
hap_profile = "./src/main/config.json"
source_dir = "./src/main/js"
} }
ohos_resources("audio_recorder_resources") { ohos_resources("audio_recorder_resources") {
sources = [ "./src/main/resources" ] sources = [ "./src/main/resources" ]
......
{ {
"description": "Configuration for audioRecorder Tests", "description": "Configuration for audioRecorder Tests",
"driver": { "driver": {
"type": "JSUnitTest", "type": "OHJSUnitTest",
"test-timeout": "1000000", "test-timeout": "1000000",
"package": "ohos.acts.multimedia.audio.audiorecorder", "shell-timeout": "1000000",
"shell-timeout": "60000" "testcase-timeout": 60000,
"bundle-name": "ohos.acts.multimedia.audio.audiorecorder",
"package-name": "ohos.acts.multimedia.audio.audiorecorder"
}, },
"kits": [ "kits": [
{ {
"type": "ShellKit", "type": "ShellKit",
"run-command": [ "run-command": [
"rm -rf /storage/media/100/local/files/Audios/audio_*", "rm -rf /storage/media/100/local/files/Audios/audio_*",
"rm -rf /storage/media/100/local/files/Videos/audio_*",
"param set persist.ace.testmode.enabled 1",
"power-shell setmode 602" "power-shell setmode 602"
], ],
"teardown-command":[ "teardown-command":[
......
...@@ -20,7 +20,6 @@ ...@@ -20,7 +20,6 @@
"module": { "module": {
"abilities": [ "abilities": [
{ {
"iconId": 16777218,
"skills": [ "skills": [
{ {
"entities": [ "entities": [
...@@ -31,15 +30,29 @@ ...@@ -31,15 +30,29 @@
] ]
} }
], ],
"descriptionId": 16777217, "orientation": "unspecified",
"formsEnabled": false,
"name": ".MainAbility",
"srcLanguage": "js",
"srcPath": "MainAbility",
"icon": "$media:icon",
"description": "$string:MainAbility_desc",
"label": "$string:MainAbility_label",
"type": "page",
"visible": true, "visible": true,
"labelId": 16777216, "launchType": "standard"
},
{
"orientation": "unspecified",
"formsEnabled": false,
"name": ".TestAbility",
"srcLanguage": "js",
"srcPath": "TestAbility",
"icon": "$media:icon", "icon": "$media:icon",
"name": "ohos.acts.multimedia.audio.audiorecorder.MainAbility", "description": "$string:TestAbility_desc",
"description": "$string:mainability_description", "label": "$string:TestAbility_label",
"label": "$string:entry_MainAbility",
"type": "page", "type": "page",
"homeAbility": true, "visible": true,
"launchType": "standard" "launchType": "standard"
} }
], ],
...@@ -53,31 +66,27 @@ ...@@ -53,31 +66,27 @@
], ],
"reqPermissions": [ "reqPermissions": [
{ {
"name" : "ohos.permission.GRANT_SENSITIVE_PERMISSIONS", "name": "ohos.permission.GRANT_SENSITIVE_PERMISSIONS",
"reason" : "use ohos.permission.GRANT_SENSITIVE_PERMISSIONS" "reason": "use ohos.permission.GRANT_SENSITIVE_PERMISSIONS"
},
{
"name" : "ohos.permission.REVOKE_SENSITIVE_PERMISSIONS",
"reason" : "use ohos.permission.REVOKE_SENSITIVE_PERMISSIONS"
}, },
{ {
"name" : "ohos.permission.MICROPHONE", "name": "ohos.permission.MICROPHONE",
"reason" : "use ohos.permission.MICROPHONE" "reason": "use ohos.permission.MICROPHONE"
}, },
{ {
"name" : "ohos.permission.MEDIA_LOCATION", "name": "ohos.permission.MEDIA_LOCATION",
"reason" : "use ohos.permission.MEDIA_LOCATION" "reason": "use ohos.permission.MEDIA_LOCATION"
}, },
{ {
"name" : "ohos.permission.READ_MEDIA", "name": "ohos.permission.READ_MEDIA",
"reason" : "use ohos.permission.READ_MEDIA" "reason": "use ohos.permission.READ_MEDIA"
}, },
{ {
"name" : "ohos.permission.WRITE_MEDIA", "name": "ohos.permission.WRITE_MEDIA",
"reason" : "use ohos.permission.WRITE_MEDIA" "reason": "use ohos.permission.WRITE_MEDIA"
} }
], ],
"mainAbility": "ohos.acts.multimedia.audio.audiorecorder.MainAbility", "mainAbility": ".MainAbility",
"distro": { "distro": {
"moduleType": "entry", "moduleType": "entry",
"installationFree": false, "installationFree": false,
...@@ -85,7 +94,7 @@ ...@@ -85,7 +94,7 @@
"moduleName": "entry" "moduleName": "entry"
}, },
"package": "ohos.acts.multimedia.audio.audiorecorder", "package": "ohos.acts.multimedia.audio.audiorecorder",
"name": ".MyApplication", "name": ".entry",
"js": [ "js": [
{ {
"pages": [ "pages": [
...@@ -96,7 +105,22 @@ ...@@ -96,7 +105,22 @@
"designWidth": 720, "designWidth": 720,
"autoDesignWidth": true "autoDesignWidth": true
} }
},
{
"pages": [
"pages/index/index"
],
"name": ".TestAbility",
"window": {
"designWidth": 720,
"autoDesignWidth": false
} }
] }
],
"testRunner": {
"name": "OpenHarmonyTestRunner",
"srcPath": "TestRunner"
},
"srcPath": ""
} }
} }
\ No newline at end of file
/*
* Copyright (C) 2022 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.
*/
export default {
data: {
title: ""
},
onInit() {
this.title = this.$t('strings.world');
},
onShow() {
console.info('onShow finish')
},
onReady() {
},
}
\ No newline at end of file
/*
* Copyright (c) 2022 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.application.abilityDelegatorRegistry'
import { Hypium } from '@ohos/hypium'
import testsuite from '../test/List.test'
export default {
onCreate() {
console.info('TestApplication onCreate')
var abilityDelegator = AbilityDelegatorRegistry.getAbilityDelegator()
var abilityDelegatorArguments = AbilityDelegatorRegistry.getArguments()
console.info('start run testcase!!!')
Hypium.hypiumTest(abilityDelegator, abilityDelegatorArguments, testsuite)
},
onDestroy() {
console.info("TestApplication onDestroy");
}
};
{
"strings": {
"hello": "Hello",
"world": "World"
},
"Files": {
}
}
\ No newline at end of file
{
"strings": {
"hello": "您好",
"world": "世界"
},
"Files": {
}
}
\ No newline at end of file
.container {
display: flex;
flex-direction: column;
justify-content: center;
align-items: center;
left: 0px;
top: 0px;
width: 100%;
height: 100%;
}
.title {
font-size: 60px;
text-align: center;
width: 100%;
height: 40%;
margin: 10px;
}
@media screen and (device-type: phone) and (orientation: landscape) {
.title {
font-size: 60px;
}
}
@media screen and (device-type: tablet) and (orientation: landscape) {
.title {
font-size: 100px;
}
}
\ No newline at end of file
<div class="container">
<text class="title">
{{ $t('strings.hello') }} {{ title }}
</text>
</div>
/*
* Copyright (c) 2022 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.
*/
export default {
data: {
title: ""
},
onInit() {
this.title = this.$t('strings.world');
}
}
/*
* Copyright (c) 2022 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.application.abilityDelegatorRegistry'
function translateParamsToString(parameters) {
const keySet = new Set([
'-s class', '-s notClass', '-s suite', '-s itName',
'-s level', '-s testType', '-s size', '-s timeout',
'-s package', '-s dryRun'
])
let targetParams = '';
for (const key in parameters) {
if (keySet.has(key)) {
targetParams += ' ' + key + ' ' + parameters[key]
}
}
return targetParams.trim()
}
export default {
onPrepare() {
console.info('OpenHarmonyTestRunner OnPrepare')
},
onRun() {
console.log('OpenHarmonyTestRunner onRun run')
var abilityDelegatorArguments = AbilityDelegatorRegistry.getArguments()
var abilityDelegator = AbilityDelegatorRegistry.getAbilityDelegator()
var testAbilityName = abilityDelegatorArguments.parameters['-p'] + '.TestAbility'
var cmd = 'aa start -d 0 -a ' + testAbilityName + ' -b ' + abilityDelegatorArguments.bundleName
cmd += ' ' + translateParamsToString(abilityDelegatorArguments.parameters)
var debug = abilityDelegatorArguments.parameters["-D"]
console.info('debug value : '+debug)
if (debug == 'true')
{
cmd += ' -D'
}
console.info('cmd : '+cmd)
abilityDelegator.executeShellCommand(cmd, (err, data) => {
console.info('executeShellCommand : err : ' + JSON.stringify(err));
console.info('executeShellCommand : data : ' + data.stdResult);
console.info('executeShellCommand : data : ' + data.exitCode);
})
}
};
/*
* Copyright (C) 2022 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 * as mediaTestBase from '../../../../../../../MediaTestBase.js';
import {Core, ExpectExtend} from 'deccjsunit/index'
export default {
data: {
title: ""
},
onInit() {
this.title = this.$t('strings.world');
},
async onShow() {
console.info('onShow finish')
let applictionName = 'ohos.acts.multimedia.audio.audiorecorder';
let permissionName1 = 'ohos.permission.MICROPHONE';
let permissionName2 = 'ohos.permission.MEDIA_LOCATION';
let permissionName3 = 'ohos.permission.READ_MEDIA';
let permissionName4 = 'ohos.permission.WRITE_MEDIA';
let permissionNames = new Array(permissionName1, permissionName2, permissionName3,
permissionName4);
await mediaTestBase.applyPermission(applictionName, permissionNames);
const core = Core.getInstance()
const expectExtend = new ExpectExtend({
'id': 'extend'
})
core.addService('expect', expectExtend)
core.init()
const configService = core.getDefaultService('config')
this.timeout = 60000
configService.setConfig(this)
require('../../../test/List.test')
core.execute()
},
onReady() {
},
}
\ No newline at end of file
...@@ -16,7 +16,8 @@ ...@@ -16,7 +16,8 @@
import media from '@ohos.multimedia.media' import media from '@ohos.multimedia.media'
import {describe, beforeAll, beforeEach, afterEach, afterAll, it, expect} from 'deccjsunit/index' import {describe, beforeAll, beforeEach, afterEach, afterAll, it, expect} from 'deccjsunit/index'
describe('AudioRecorderEnumTest', function () { export default function AudioRecorderEnumTest() {
describe('AudioRecorderEnumTest', function () {
beforeAll(function() { beforeAll(function() {
console.info('beforeAll case'); console.info('beforeAll case');
}) })
...@@ -81,4 +82,6 @@ describe('AudioRecorderEnumTest', function () { ...@@ -81,4 +82,6 @@ describe('AudioRecorderEnumTest', function () {
expect(media.CodecMimeType.AUDIO_FLAC).assertEqual('audio/flac'); expect(media.CodecMimeType.AUDIO_FLAC).assertEqual('audio/flac');
done(); done();
}) })
}) })
\ No newline at end of file }
...@@ -12,7 +12,11 @@ ...@@ -12,7 +12,11 @@
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
import RecorderLocalTestAudioFUNC from './RecorderLocalTestAudioFUNC.test.js'
require('./RecorderLocalTestAudioFUNC.test.js') import RecorderLocalTestAudioAPI from './RecorderLocalTestAudioAPI.test.js'
require('./RecorderLocalTestAudioAPI.test.js') import AudioRecorderEnumTest from './AudioRecorderEnumTest.test.js'
require('./AudioRecorderEnumTest.test.js') export default function testsuite() {
\ No newline at end of file RecorderLocalTestAudioFUNC()
RecorderLocalTestAudioAPI()
AudioRecorderEnumTest()
}
...@@ -16,8 +16,8 @@ ...@@ -16,8 +16,8 @@
import media from '@ohos.multimedia.media' import media from '@ohos.multimedia.media'
import * as mediaTestBase from '../../../../../MediaTestBase.js'; import * as mediaTestBase from '../../../../../MediaTestBase.js';
import {describe, beforeAll, beforeEach, afterEach, afterAll, it, expect} from 'deccjsunit/index' import {describe, beforeAll, beforeEach, afterEach, afterAll, it, expect} from 'deccjsunit/index'
export default function RecorderLocalTestAudioAPI() {
describe('RecorderLocalTestAudioAPI', function () { describe('RecorderLocalTestAudioAPI', function () {
let audioRecorder = null; let audioRecorder = null;
const END_STATE = 0; const END_STATE = 0;
const PRE_STATE = 1; const PRE_STATE = 1;
...@@ -1060,4 +1060,5 @@ describe('RecorderLocalTestAudioAPI', function () { ...@@ -1060,4 +1060,5 @@ describe('RecorderLocalTestAudioAPI', function () {
setCallback(mySteps, done); setCallback(mySteps, done);
audioRecorder.prepare(audioConfig); audioRecorder.prepare(audioConfig);
}) })
}) })
\ No newline at end of file }
...@@ -18,7 +18,8 @@ import * as mediaTestBase from '../../../../../MediaTestBase.js'; ...@@ -18,7 +18,8 @@ import * as mediaTestBase from '../../../../../MediaTestBase.js';
import * as videoRecorderBase from '../../../../../VideoRecorderTestBase.js'; import * as videoRecorderBase from '../../../../../VideoRecorderTestBase.js';
import {describe, beforeAll, beforeEach, afterEach, afterAll, it, expect} from 'deccjsunit/index' import {describe, beforeAll, beforeEach, afterEach, afterAll, it, expect} from 'deccjsunit/index'
describe('RecorderLocalTestAudioFUNC', function () { export default function RecorderLocalTestAudioFUNC() {
describe('RecorderLocalTestAudioFUNC', function () {
let audioRecorder = null; let audioRecorder = null;
const END_STATE = 0; const END_STATE = 0;
const PRE_STATE = 1; const PRE_STATE = 1;
...@@ -59,7 +60,15 @@ describe('RecorderLocalTestAudioFUNC', function () { ...@@ -59,7 +60,15 @@ describe('RecorderLocalTestAudioFUNC', function () {
audioRecorder = media.createAudioRecorder(); audioRecorder = media.createAudioRecorder();
} }
beforeAll(function () { beforeAll(async function () {
let permissionName1 = 'ohos.permission.MICROPHONE';
let permissionName2 = 'ohos.permission.MEDIA_LOCATION';
let permissionName3 = 'ohos.permission.READ_MEDIA';
let permissionName4 = 'ohos.permission.WRITE_MEDIA';
let permissionNames = [permissionName1, permissionName2, permissionName3, permissionName4];
await mediaTestBase.getPermission(permissionNames);
await mediaTestBase.msleepAsync(2000);
await mediaTestBase.driveFn(2);
console.info('beforeAll case'); console.info('beforeAll case');
}) })
...@@ -839,4 +848,7 @@ describe('RecorderLocalTestAudioFUNC', function () { ...@@ -839,4 +848,7 @@ describe('RecorderLocalTestAudioFUNC', function () {
setCallback(mySteps, done); setCallback(mySteps, done);
audioRecorder.prepare(newAudioConfig); audioRecorder.prepare(newAudioConfig);
}) })
}) })
}
...@@ -7,6 +7,22 @@ ...@@ -7,6 +7,22 @@
{ {
"name": "mainability_description", "name": "mainability_description",
"value": "JS_Empty Ability" "value": "JS_Empty Ability"
},
{
"name": "MainAbility_desc",
"value": "description"
},
{
"name": "MainAbility_label",
"value": "label"
},
{
"name": "TestAbility_desc",
"value": "description"
},
{
"name": "TestAbility_label",
"value": "label"
} }
] ]
} }
\ No newline at end of file
...@@ -12,9 +12,13 @@ ...@@ -12,9 +12,13 @@
{ {
"type": "ShellKit", "type": "ShellKit",
"run-command": [ "run-command": [
"rm -rf /storage/media/100/local/files/Videos/COMPATIBILITY*" "rm -rf /storage/media/100/local/files/Audios/COMPATIBILITY*",
"param set persist.ace.testmode.enabled 1",
"power-shell setmode 602"
], ],
"teardown-command": [] "teardown-command": [
"power-shell setmode 600"
]
}, },
{ {
"test-file-name": [ "test-file-name": [
......
...@@ -69,10 +69,6 @@ ...@@ -69,10 +69,6 @@
"name": "ohos.permission.GRANT_SENSITIVE_PERMISSIONS", "name": "ohos.permission.GRANT_SENSITIVE_PERMISSIONS",
"reason": "use ohos.permission.GRANT_SENSITIVE_PERMISSIONS" "reason": "use ohos.permission.GRANT_SENSITIVE_PERMISSIONS"
}, },
{
"name": "ohos.permission.REVOKE_SENSITIVE_PERMISSIONS",
"reason": "use ohos.permission.REVOKE_SENSITIVE_PERMISSIONS"
},
{ {
"name": "ohos.permission.MICROPHONE", "name": "ohos.permission.MICROPHONE",
"reason": "use ohos.permission.MICROPHONE" "reason": "use ohos.permission.MICROPHONE"
......
...@@ -17,6 +17,7 @@ import media from '@ohos.multimedia.media' ...@@ -17,6 +17,7 @@ import media from '@ohos.multimedia.media'
import abilityAccessCtrl from '@ohos.abilityAccessCtrl' import abilityAccessCtrl from '@ohos.abilityAccessCtrl'
import bundle from '@ohos.bundle' import bundle from '@ohos.bundle'
import mediaLibrary from '@ohos.multimedia.mediaLibrary' import mediaLibrary from '@ohos.multimedia.mediaLibrary'
import * as mediaTestBase from '../../../../../MediaTestBase.js';
import {describe, beforeAll, beforeEach, afterEach, afterAll, it, expect} from '@ohos/hypium' import {describe, beforeAll, beforeEach, afterEach, afterAll, it, expect} from '@ohos/hypium'
export default function AudioRecorderFormatCompatibilityTest() { export default function AudioRecorderFormatCompatibilityTest() {
...@@ -59,7 +60,14 @@ describe('AudioRecorderFormatCompatibilityTest', function () { ...@@ -59,7 +60,14 @@ describe('AudioRecorderFormatCompatibilityTest', function () {
} }
beforeAll(async function () { beforeAll(async function () {
await applyPermission(); let permissionName1 = 'ohos.permission.MICROPHONE';
let permissionName2 = 'ohos.permission.MEDIA_LOCATION';
let permissionName3 = 'ohos.permission.READ_MEDIA';
let permissionName4 = 'ohos.permission.WRITE_MEDIA';
let permissionNames = [permissionName1, permissionName2, permissionName3, permissionName4];
await mediaTestBase.getPermission(permissionNames);
await mediaTestBase.msleepAsync(2000);
await mediaTestBase.driveFn(2);
console.info('beforeAll case'); console.info('beforeAll case');
}) })
...@@ -76,41 +84,6 @@ describe('AudioRecorderFormatCompatibilityTest', function () { ...@@ -76,41 +84,6 @@ describe('AudioRecorderFormatCompatibilityTest', function () {
console.info('afterAll case'); console.info('afterAll case');
}) })
async function applyPermission() {
let appInfo = await bundle.getApplicationInfo('ohos.acts.multimedia.audio.recorderformat', 0, 100);
let atManager = abilityAccessCtrl.createAtManager();
if (atManager != null) {
let tokenID = appInfo.accessTokenId;
console.info('[permission] case accessTokenID is ' + tokenID);
let permissionName1 = 'ohos.permission.MICROPHONE';
let permissionName2 = 'ohos.permission.MEDIA_LOCATION';
let permissionName3 = 'ohos.permission.READ_MEDIA';
let permissionName4 = 'ohos.permission.WRITE_MEDIA';
await atManager.grantUserGrantedPermission(tokenID, permissionName1, 1).then((result) => {
console.info('[permission] case grantUserGrantedPermission success :' + result);
}).catch((err) => {
console.error('[permission] case grantUserGrantedPermission failed :' + err);
});
await atManager.grantUserGrantedPermission(tokenID, permissionName2, 1).then((result) => {
console.info('[permission] case grantUserGrantedPermission success :' + result);
}).catch((err) => {
console.error('[permission] case grantUserGrantedPermission failed :' + err);
});
await atManager.grantUserGrantedPermission(tokenID, permissionName3, 1).then((result) => {
console.info('[permission] case grantUserGrantedPermission success :' + result);
}).catch((err) => {
console.error('[permission] case grantUserGrantedPermission failed :' + err);
});
await atManager.grantUserGrantedPermission(tokenID, permissionName4, 1).then((result) => {
console.info('[permission] case grantUserGrantedPermission success :' + result);
}).catch((err) => {
console.error('[permission] case grantUserGrantedPermission failed :' + err);
});
} else {
console.error('[permission] case apply permission failed, createAtManager failed');
}
}
async function getFd(pathName) { async function getFd(pathName) {
let displayName = pathName; let displayName = pathName;
const mediaTest = mediaLibrary.getMediaLibrary(); const mediaTest = mediaLibrary.getMediaLibrary();
......
...@@ -12,8 +12,10 @@ ...@@ -12,8 +12,10 @@
# limitations under the License. # limitations under the License.
import("//test/xts/tools/build/suite.gni") import("//test/xts/tools/build/suite.gni")
ohos_js_hap_suite("video_recorder_js_hap") { ohos_js_hap_suite("video_recorder_js_hap") {
hap_profile = "./src/main/config.json" hap_profile = "./src/main/config.json"
js2abc = true
deps = [ deps = [
":video_recorder_js_assets", ":video_recorder_js_assets",
":video_recorder_resources", ":video_recorder_resources",
...@@ -32,7 +34,9 @@ ohos_js_hap_suite("video_recorder_js_hap") { ...@@ -32,7 +34,9 @@ ohos_js_hap_suite("video_recorder_js_hap") {
# subsystem_name = "xts" # subsystem_name = "xts"
} }
ohos_js_assets("video_recorder_js_assets") { ohos_js_assets("video_recorder_js_assets") {
source_dir = "./src/main/js/default" js2abc = true
hap_profile = "./src/main/config.json"
source_dir = "./src/main/js"
} }
ohos_resources("video_recorder_resources") { ohos_resources("video_recorder_resources") {
sources = [ "./src/main/resources" ] sources = [ "./src/main/resources" ]
......
{ {
"description": "Configuration for videoRecorder Tests", "description": "Configuration for videoRecorder Tests",
"driver": { "driver": {
"type": "JSUnitTest", "type": "OHJSUnitTest",
"test-timeout": "2000000", "test-timeout": "1000000",
"package": "ohos.acts.multimedia.video.videorecorder", "shell-timeout": "1000000",
"shell-timeout": "60000" "testcase-timeout": 60000,
"bundle-name": "ohos.acts.multimedia.video.videorecorder",
"package-name": "ohos.acts.multimedia.video.videorecorder"
}, },
"kits": [ "kits": [
{
"test-file-name": [
"ActsVideoRecorderJsTest.hap"
],
"type": "AppInstallKit",
"cleanup-apps": true
},
{ {
"type": "ShellKit", "type": "ShellKit",
"run-command": [ "run-command": [
"rm -rf /storage/media/100/local/files/Videos/*", "rm -rf /storage/media/100/local/files/Videos/*",
"param set persist.ace.testmode.enabled 1",
"power-shell setmode 602" "power-shell setmode 602"
], ],
"teardown-command":[ "teardown-command":[
"power-shell setmode 600" "power-shell setmode 600"
]
},
{
"test-file-name": [
"ActsVideoRecorderJsTest.hap"
], ],
"type": "AppInstallKit",
"cleanup-apps": true "cleanup-apps": true
} }
] ]
......
...@@ -20,7 +20,6 @@ ...@@ -20,7 +20,6 @@
"module": { "module": {
"abilities": [ "abilities": [
{ {
"iconId": 16777218,
"skills": [ "skills": [
{ {
"entities": [ "entities": [
...@@ -31,16 +30,30 @@ ...@@ -31,16 +30,30 @@
] ]
} }
], ],
"descriptionId": 16777217, "orientation": "unspecified",
"formsEnabled": false,
"name": ".MainAbility",
"srcLanguage": "js",
"srcPath": "MainAbility",
"icon": "$media:icon",
"description": "$string:MainAbility_desc",
"label": "$string:MainAbility_label",
"type": "page",
"visible": true, "visible": true,
"labelId": 16777216, "launchType": "standard"
},
{
"orientation": "unspecified",
"formsEnabled": false,
"name": ".TestAbility",
"srcLanguage": "js",
"srcPath": "TestAbility",
"icon": "$media:icon", "icon": "$media:icon",
"name": "ohos.acts.multimedia.video.videorecorder.MainAbility", "description": "$string:TestAbility_desc",
"description": "$string:mainability_description", "label": "$string:TestAbility_label",
"label": "$string:entry_MainAbility",
"type": "page", "type": "page",
"homeAbility": true, "visible": true,
"launchType": "singleton" "launchType": "standard"
} }
], ],
"deviceType": [ "deviceType": [
...@@ -51,14 +64,17 @@ ...@@ -51,14 +64,17 @@
"tv", "tv",
"wearable" "wearable"
], ],
"reqPermissions": [ "mainAbility": ".MainAbility",
{ "distro": {
"name" : "ohos.permission.GRANT_SENSITIVE_PERMISSIONS", "moduleType": "entry",
"reason" : "use ohos.permission.GRANT_SENSITIVE_PERMISSIONS" "installationFree": false,
"deliveryWithInstall": true,
"moduleName": "entry"
}, },
"reqPermissions": [
{ {
"name" : "ohos.permission.REVOKE_SENSITIVE_PERMISSIONS", "name": "ohos.permission.GRANT_SENSITIVE_PERMISSIONS",
"reason" : "use ohos.permission.REVOKE_SENSITIVE_PERMISSIONS" "reason": "use ohos.permission.GRANT_SENSITIVE_PERMISSIONS"
}, },
{ {
"name" : "ohos.permission.CAMERA", "name" : "ohos.permission.CAMERA",
...@@ -81,15 +97,8 @@ ...@@ -81,15 +97,8 @@
"reason" : "use ohos.permission.WRITE_MEDIA" "reason" : "use ohos.permission.WRITE_MEDIA"
} }
], ],
"mainAbility": "ohos.acts.multimedia.video.videorecorder.MainAbility",
"distro": {
"moduleType": "entry",
"installationFree": false,
"deliveryWithInstall": true,
"moduleName": "entry"
},
"package": "ohos.acts.multimedia.video.videorecorder", "package": "ohos.acts.multimedia.video.videorecorder",
"name": ".MyApplication", "name": ".entry",
"js": [ "js": [
{ {
"pages": [ "pages": [
...@@ -102,7 +111,22 @@ ...@@ -102,7 +111,22 @@
"designWidth": 720, "designWidth": 720,
"autoDesignWidth": true "autoDesignWidth": true
} }
},
{
"pages": [
"pages/index/index"
],
"name": ".TestAbility",
"window": {
"designWidth": 720,
"autoDesignWidth": false
}
} }
] ],
"testRunner": {
"name": "OpenHarmonyTestRunner",
"srcPath": "TestRunner"
},
"srcPath": ""
} }
} }
\ No newline at end of file
/*
* Copyright (C) 2022 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.application.abilityDelegatorRegistry'
import { Hypium } from '@ohos/hypium'
import testsuite from '../test/List.test'
export default {
onCreate() {
console.info('TestApplication onCreate')
setTimeout(()=>{
var abilityDelegator = AbilityDelegatorRegistry.getAbilityDelegator()
var abilityDelegatorArguments = AbilityDelegatorRegistry.getArguments()
console.info('start run testcase!!!')
Hypium.hypiumTest(abilityDelegator, abilityDelegatorArguments, testsuite)
},100)
},
onDestroy() {
console.info("TestApplication onDestroy");
}
};
/*
* Copyright (C) 2022 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.
*/
export default {
data: {
title: ""
},
onInit() {
this.title = this.$t('strings.world');
},
onShow() {
console.info('onShow finish')
},
onReady() {
},
}
\ No newline at end of file
/* /*
* Copyright (C) 2022 Huawei Device Co., Ltd. * Copyright (c) 2022 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
* You may obtain a copy of the License at * You may obtain a copy of the License at
......
{
"strings": {
"hello": "Hello",
"world": "World"
},
"Files": {
}
}
\ No newline at end of file
{
"strings": {
"hello": "您好",
"world": "世界"
},
"Files": {
}
}
\ No newline at end of file
.container {
display: flex;
flex-direction: column;
justify-content: center;
align-items: center;
left: 0px;
top: 0px;
width: 100%;
height: 100%;
}
.title {
font-size: 60px;
text-align: center;
width: 100%;
height: 40%;
margin: 10px;
}
@media screen and (device-type: phone) and (orientation: landscape) {
.title {
font-size: 60px;
}
}
@media screen and (device-type: tablet) and (orientation: landscape) {
.title {
font-size: 100px;
}
}
\ No newline at end of file
<div class="container">
<text class="title">
{{ $t('strings.hello') }} {{ title }}
</text>
</div>
/*
* Copyright (c) 2022 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.
*/
export default {
data: {
title: ""
},
onInit() {
this.title = this.$t('strings.world');
}
}
/*
* Copyright (c) 2022 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.application.abilityDelegatorRegistry'
function translateParamsToString(parameters) {
const keySet = new Set([
'-s class', '-s notClass', '-s suite', '-s itName',
'-s level', '-s testType', '-s size', '-s timeout',
'-s package', '-s dryRun'
])
let targetParams = '';
for (const key in parameters) {
if (keySet.has(key)) {
targetParams += ' ' + key + ' ' + parameters[key]
}
}
return targetParams.trim()
}
export default {
onPrepare() {
console.info('OpenHarmonyTestRunner OnPrepare')
},
onRun() {
console.log('OpenHarmonyTestRunner onRun run')
var abilityDelegatorArguments = AbilityDelegatorRegistry.getArguments()
var abilityDelegator = AbilityDelegatorRegistry.getAbilityDelegator()
var testAbilityName = abilityDelegatorArguments.parameters['-p'] + '.MainAbility'
var cmd = 'aa start -d 0 -a ' + testAbilityName + ' -b ' + abilityDelegatorArguments.bundleName
cmd += ' ' + translateParamsToString(abilityDelegatorArguments.parameters)
var debug = abilityDelegatorArguments.parameters["-D"]
console.info('debug value : '+debug)
if (debug == 'true')
{
cmd += ' -D'
}
console.info('cmd : '+cmd)
abilityDelegator.executeShellCommand(cmd, (err, data) => {
console.info('executeShellCommand : err : ' + JSON.stringify(err));
console.info('executeShellCommand : data : ' + data.stdResult);
console.info('executeShellCommand : data : ' + data.exitCode);
})
}
};
/*
* Copyright (C) 2022 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 {Core, ExpectExtend} from 'deccjsunit/index'
import * as mediaTestBase from '../../../../../../../MediaTestBase.js';
export default {
data: {
title: ""
},
onInit() {
this.title = this.$t('strings.world');
},
async onShow() {
console.info('onShow finish')
let applictionName = 'ohos.acts.multimedia.video.videorecorder';
let permissionName1 = 'ohos.permission.CAMERA';
let permissionName2 = 'ohos.permission.MICROPHONE';
let permissionName3 = 'ohos.permission.MEDIA_LOCATION';
let permissionName4 = 'ohos.permission.READ_MEDIA';
let permissionName5 = 'ohos.permission.WRITE_MEDIA';
let permissionNames = new Array(permissionName1, permissionName2, permissionName3,
permissionName4, permissionName5);
await mediaTestBase.applyPermission(applictionName, permissionNames);
const core = Core.getInstance()
const expectExtend = new ExpectExtend({
'id': 'extend'
})
core.addService('expect', expectExtend)
core.init()
const configService = core.getDefaultService('config')
this.timeout = 60000
configService.setConfig(this)
require('../../../test/List.test')
core.execute()
},
onReady() {
},
}
\ No newline at end of file
...@@ -12,7 +12,14 @@ ...@@ -12,7 +12,14 @@
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
require('./VideoRecorderFuncCallbackTest.test.js')
require('./VideoRecorderFuncPromiseTest.test.js') import VideoRecorderFuncPromiseTest from './VideoRecorderFuncPromiseTest.test.js'
require('./VideoRecorderAPICallbackTest.test.js') import VideoRecorderFuncCallbackTest from './VideoRecorderFuncCallbackTest.test.js'
require('./VideoRecorderEnumTest.test.js') import VideoRecorderAPICallbackTest from './VideoRecorderAPICallbackTest.test.js'
import VideoRecorderEnumTest from './VideoRecorderEnumTest.test.js'
export default function testsuite() {
VideoRecorderFuncPromiseTest()
VideoRecorderFuncCallbackTest()
VideoRecorderAPICallbackTest()
VideoRecorderEnumTest()
}
...@@ -19,7 +19,8 @@ import * as mediaTestBase from '../../../../../MediaTestBase.js'; ...@@ -19,7 +19,8 @@ import * as mediaTestBase from '../../../../../MediaTestBase.js';
import * as videoRecorderBase from '../../../../../VideoRecorderTestBase.js'; import * as videoRecorderBase from '../../../../../VideoRecorderTestBase.js';
import {describe, beforeAll, beforeEach, afterEach, afterAll, it, expect} from 'deccjsunit/index' import {describe, beforeAll, beforeEach, afterEach, afterAll, it, expect} from 'deccjsunit/index'
describe('VideoRecorderAPICallbackTest', function () { export default function VideoRecorderAPICallbackTest() {
describe('VideoRecorderAPICallbackTest', function () {
const RECORDER_TIME = 3000; const RECORDER_TIME = 3000;
const PAUSE_TIME = 1000; const PAUSE_TIME = 1000;
const END_EVENT = 'end'; const END_EVENT = 'end';
...@@ -1171,4 +1172,7 @@ describe('VideoRecorderAPICallbackTest', function () { ...@@ -1171,4 +1172,7 @@ describe('VideoRecorderAPICallbackTest', function () {
GETSURFACE_EVENT, GETSURFACE_EVENT, RELEASE_EVENT, END_EVENT); GETSURFACE_EVENT, GETSURFACE_EVENT, RELEASE_EVENT, END_EVENT);
eventEmitter.emit(mySteps[0], videoRecorder, mySteps, done); eventEmitter.emit(mySteps[0], videoRecorder, mySteps, done);
}) })
}) })
}
...@@ -16,7 +16,8 @@ ...@@ -16,7 +16,8 @@
import media from '@ohos.multimedia.media' import media from '@ohos.multimedia.media'
import {describe, beforeAll, beforeEach, afterEach, afterAll, it, expect} from 'deccjsunit/index' import {describe, beforeAll, beforeEach, afterEach, afterAll, it, expect} from 'deccjsunit/index'
describe('VideoRecorderEnumTest', function () { export default function VideoRecorderEnumTest() {
describe('VideoRecorderEnumTest', function () {
beforeAll(function() { beforeAll(function() {
console.info('beforeAll case'); console.info('beforeAll case');
}) })
...@@ -77,4 +78,6 @@ describe('VideoRecorderEnumTest', function () { ...@@ -77,4 +78,6 @@ describe('VideoRecorderEnumTest', function () {
expect(media.CodecMimeType.VIDEO_VP8).assertEqual('video/x-vnd.on2.vp8'); expect(media.CodecMimeType.VIDEO_VP8).assertEqual('video/x-vnd.on2.vp8');
done(); done();
}) })
}) })
\ No newline at end of file }
...@@ -19,7 +19,8 @@ import * as mediaTestBase from '../../../../../MediaTestBase.js'; ...@@ -19,7 +19,8 @@ import * as mediaTestBase from '../../../../../MediaTestBase.js';
import * as videoRecorderBase from '../../../../../VideoRecorderTestBase.js'; import * as videoRecorderBase from '../../../../../VideoRecorderTestBase.js';
import {describe, beforeAll, beforeEach, afterEach, afterAll, it, expect} from 'deccjsunit/index' import {describe, beforeAll, beforeEach, afterEach, afterAll, it, expect} from 'deccjsunit/index'
describe('VideoRecorderFuncCallbackTest', function () { export default function VideoRecorderFuncCallbackTest() {
describe('VideoRecorderFuncCallbackTest', function () {
const RECORDER_TIME = 3000; const RECORDER_TIME = 3000;
const PAUSE_TIME = 1000; const PAUSE_TIME = 1000;
const END_EVENT = 'end'; const END_EVENT = 'end';
...@@ -841,4 +842,7 @@ describe('VideoRecorderFuncCallbackTest', function () { ...@@ -841,4 +842,7 @@ describe('VideoRecorderFuncCallbackTest', function () {
CHECK_EVENT, trackArray, RECORDER_TIME, END_EVENT); CHECK_EVENT, trackArray, RECORDER_TIME, END_EVENT);
eventEmitter.emit(mySteps[0], videoRecorder, mySteps, done); eventEmitter.emit(mySteps[0], videoRecorder, mySteps, done);
}) })
}) })
}
...@@ -19,6 +19,7 @@ import * as mediaTestBase from '../../../../../MediaTestBase.js'; ...@@ -19,6 +19,7 @@ import * as mediaTestBase from '../../../../../MediaTestBase.js';
import * as videoRecorderBase from '../../../../../VideoRecorderTestBase.js'; import * as videoRecorderBase from '../../../../../VideoRecorderTestBase.js';
import {describe, beforeAll, beforeEach, afterEach, afterAll, it, expect} from 'deccjsunit/index' import {describe, beforeAll, beforeEach, afterEach, afterAll, it, expect} from 'deccjsunit/index'
export default function VideoRecorderFuncPromiseTest() {
describe('VideoRecorderFuncPromiseTest', function () { describe('VideoRecorderFuncPromiseTest', function () {
const RECORDER_TIME = 3000; const RECORDER_TIME = 3000;
const PAUSE_TIME = 1000; const PAUSE_TIME = 1000;
...@@ -82,6 +83,15 @@ describe('VideoRecorderFuncPromiseTest', function () { ...@@ -82,6 +83,15 @@ describe('VideoRecorderFuncPromiseTest', function () {
} }
beforeAll(async function () { beforeAll(async function () {
let permissionName1 = 'ohos.permission.MICROPHONE';
let permissionName2 = 'ohos.permission.MEDIA_LOCATION';
let permissionName3 = 'ohos.permission.READ_MEDIA';
let permissionName4 = 'ohos.permission.WRITE_MEDIA';
let permissionName5 = 'ohos.permission.CAMERA';
let permissionNames = [permissionName1, permissionName2, permissionName3, permissionName4, permissionName5];
await mediaTestBase.getPermission(permissionNames);
await mediaTestBase.msleepAsync(2000);
await mediaTestBase.driveFn(3);
cameraManager = await camera.getCameraManager(null); cameraManager = await camera.getCameraManager(null);
if (cameraManager != null) { if (cameraManager != null) {
console.info('[camera] case getCameraManager success'); console.info('[camera] case getCameraManager success');
...@@ -149,26 +159,6 @@ describe('VideoRecorderFuncPromiseTest', function () { ...@@ -149,26 +159,6 @@ describe('VideoRecorderFuncPromiseTest', function () {
console.info('afterAll case'); console.info('afterAll case');
}) })
function checkErrorCode(errorCode)
{
let value = false;
switch (errorCode) {
case 0:
case 201:
case 401:
case 801:
case 5400101:
case 5400102:
case 5400103:
case 5400104:
case 5400105:
case 5400106:
value = true;
break;
}
return value;
}
async function startVideoOutput(videoOutPut) { async function startVideoOutput(videoOutPut) {
if (videoOutPut == null) { if (videoOutPut == null) {
console.info('[camera] case videoOutPut is null'); console.info('[camera] case videoOutPut is null');
...@@ -1737,115 +1727,6 @@ describe('VideoRecorderFuncPromiseTest', function () { ...@@ -1737,115 +1727,6 @@ describe('VideoRecorderFuncPromiseTest', function () {
await mediaTestBase.closeFd(fdObject.fileAsset, fdObject.fdNumber); await mediaTestBase.closeFd(fdObject.fileAsset, fdObject.fdNumber);
done(); done();
}) })
/* *
* @tc.number : SUB_MULTIMEDIA_MEDIA_VIDEO_RECORDER_FUNCTION_PROMISE_ERRORCODE
* @tc.name : 25.error code (promise)
* @tc.desc : Video recordr control test
* @tc.size : MediumTest
* @tc.type : Function
* @tc.level : Level0
*/
it('SUB_MULTIMEDIA_MEDIA_VIDEO_RECORDER_FUNCTION_PROMISE_ERRORCODE', 0, async function (done) {
let videoRecorder = undefined;
let surfaceID = '';
let videoOutput;
let previewOutput;
let errorCode = false;
fdObject = await mediaTestBase.getFd('recorder_promise_25.mp4');
fdPath = "fd://" + fdObject.fdNumber.toString();
videoConfig.url = '';
await media.createVideoRecorder().then((recorder) => {
console.info('case createVideoRecorder called');
if (typeof (recorder) != 'undefined') {
videoRecorder = recorder;
expect(videoRecorder.state).assertEqual('idle');
} else {
console.info('case recordr is undefined!!');
}
}, mediaTestBase.failureCallback).catch(mediaTestBase.catchCallback);
videoRecorder.on('error', (err) => {
console.info('case on error called, errMessage is ' + err.code);
errorCode = checkErrorCode(err.code);
expect(errorCode).assertEqual(true);
});
await videoRecorder.prepare(videoConfig).then(() => {
console.info('case recordr prepare called');
expect(videoRecorder.state).assertEqual('prepared');
}, (err) => {
console.info('case promise error called, errMessage is ' + err.code);
errorCode = checkErrorCode(err.code);
expect(errorCode).assertEqual(true);
}).catch(mediaTestBase.catchCallback);
await videoRecorder.reset().then(() => {
console.info('case recordr reset called');
expect(videoRecorder.state).assertEqual('idle');
}, (err) => {
console.info('case promise error called, errMessage is ' + err.code);
errorCode = checkErrorCode(err.code);
expect(errorCode).assertEqual(true);
}).catch(mediaTestBase.catchCallback);
videoConfig.url = fdPath;
await videoRecorder.prepare(videoConfig).then(() => {
console.info('case recordr prepare called');
expect(videoRecorder.state).assertEqual('prepared');
}, (err) => {
expect(videoRecorder.state).assertEqual('error');
console.info('case promise error called, errMessage is ' + err.code);
expect().assertFail();
}).catch(mediaTestBase.catchCallback);
await videoRecorder.getInputSurface().then((outPutSurface) => {
console.info('case getInputSurface called');
expect(videoRecorder.state).assertEqual('prepared');
surfaceID = outPutSurface;
}, mediaTestBase.failureCallback).catch(mediaTestBase.catchCallback);
videoOutput = await cameraManager.createVideoOutput(videoProfiles[0], surfaceID);
previewOutput = await cameraManager.createPreviewOutput(previewProfiles[0], playerSurfaceId)
captureSession = await videoRecorderBase.initCaptureSession(videoOutput, cameraManager,
cameras[0], previewOutput);
await startVideoOutput(videoOutput);
await videoRecorder.start().then(() => {
console.info('case recordr play called');
expect(videoRecorder.state).assertEqual('playing');
}, (err) => {
console.info('case promise error called, errMessage is ' + err.code);
expect().assertFail();
}).catch(mediaTestBase.catchCallback);
await videoRecorder.start().then(() => {
console.info('case recordr start called');
}, (err) => {
console.info('case promise error called, errMessage is ' + err.code);
errorCode = checkErrorCode(err.code);
expect(errorCode).assertEqual(true);
}).catch(mediaTestBase.catchCallback);
await videoRecorder.prepare(videoConfig).then(() => {
console.info('case recordr prepare called');
}, (err) => {
console.info('case promise error called, errMessage is ' + err.code);
errorCode = checkErrorCode(err.code);
expect(errorCode).assertEqual(true);
}).catch(mediaTestBase.catchCallback);
await videoRecorder.release().then(() => {
console.info('case release ');
expect(videoRecorder.state).assertEqual('idle');
}, mediaTestBase.failureCallback).catch(mediaTestBase.catchCallback);
await videoOutput.stop();
await videoRecorderBase.stopCaptureSession(captureSession);
await mediaTestBase.closeFd(fdObject.fileAsset, fdObject.fdNumber);
await videoRecorder.prepare(videoConfig).then(() => {
console.info('case recordr prepare called');
}, (err) => {
console.info('case promise error called, errMessage is ' + err.code);
errorCode = checkErrorCode(err.code);
expect(errorCode).assertEqual(true);
}).catch(mediaTestBase.catchCallback);
done();
})
}) })
}
...@@ -7,6 +7,22 @@ ...@@ -7,6 +7,22 @@
{ {
"name": "mainability_description", "name": "mainability_description",
"value": "JS_Empty Ability" "value": "JS_Empty Ability"
},
{
"name": "MainAbility_desc",
"value": "description"
},
{
"name": "MainAbility_label",
"value": "label"
},
{
"name": "TestAbility_desc",
"value": "description"
},
{
"name": "TestAbility_label",
"value": "label"
} }
] ]
} }
\ No newline at end of file
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册