diff --git a/multimedia/media/media_js_standard/MediaTestBase.js b/multimedia/media/media_js_standard/MediaTestBase.js
index 65dbd005a27323a778e037c6e91dac7023846fb9..fbba0361271d1f40a89a3f978828c34a2038957f 100644
--- a/multimedia/media/media_js_standard/MediaTestBase.js
+++ b/multimedia/media/media_js_standard/MediaTestBase.js
@@ -15,6 +15,10 @@
import resourceManager from '@ohos.resourceManager';
import {expect} from 'deccjsunit/index'
+import router from '@system.router'
+import abilityAccessCtrl from '@ohos.abilityAccessCtrl'
+import bundle from '@ohos.bundle'
+import mediaLibrary from '@ohos.multimedia.mediaLibrary'
// File operation
export async function getFileDescriptor(fileName) {
@@ -84,4 +88,81 @@ export function printDescription(obj) {
console.info('case value is '+ property);
description += i + " = " + property + "\n";
}
+}
+
+export async function toNewPage(pagePath1, pagePath2, page) {
+ let path = '';
+ if (page == 0) {
+ path = pagePath1;
+ } else {
+ path = pagePath2;
+ }
+ let options = {
+ uri: path,
+ }
+ try {
+ await router.push(options);
+ } catch {
+ console.info('case route failed');
+ }
+}
+
+export async function clearRouter() {
+ await router.clear();
+}
+
+export async function getFd(pathName) {
+ let fdObject = {
+ fileAsset : null,
+ fdNumber : null
+ }
+ let displayName = pathName;
+ const mediaTest = mediaLibrary.getMediaLibrary();
+ let fileKeyObj = mediaLibrary.FileKey;
+ let mediaType = mediaLibrary.MediaType.VIDEO;
+ let publicPath = await mediaTest.getPublicDirectory(mediaLibrary.DirectoryType.DIR_VIDEO);
+ let dataUri = await mediaTest.createAsset(mediaType, displayName, publicPath);
+ if (dataUri != undefined) {
+ let args = dataUri.id.toString();
+ let fetchOp = {
+ selections : fileKeyObj.ID + "=?",
+ selectionArgs : [args],
+ }
+ let fetchFileResult = await mediaTest.getFileAssets(fetchOp);
+ fdObject.fileAsset = await fetchFileResult.getAllObject();
+ fdObject.fdNumber = await fdObject.fileAsset[0].open('Rw');
+ console.info('case getFd number is: ' + fdObject.fdNumber);
+ }
+ return fdObject;
+}
+
+export async function closeFd(fileAsset, fdNumber) {
+ if (fileAsset != null) {
+ await fileAsset[0].close(fdNumber).then(() => {
+ console.info('[mediaLibrary] case close fd success');
+ }).catch((err) => {
+ console.info('[mediaLibrary] case close fd failed');
+ });
+ } else {
+ 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
diff --git a/multimedia/media/media_js_standard/VideoPlayerTestBase.js b/multimedia/media/media_js_standard/VideoPlayerTestBase.js
index 3008dd3c089cb2cad02030d8c5a0dd35208ab519..19226f6401f9dd73e87040ddb75f3baf82fd06a0 100644
--- a/multimedia/media/media_js_standard/VideoPlayerTestBase.js
+++ b/multimedia/media/media_js_standard/VideoPlayerTestBase.js
@@ -13,31 +13,20 @@
* limitations under the License.
*/
-import router from '@system.router'
+
import media from '@ohos.multimedia.media'
import * as mediaTestBase from './MediaTestBase.js';
-export async function toNewPage(pagePath1, pagePath2, page) {
- let path = '';
- if (page == 0) {
- path = pagePath1;
- } else {
- path = pagePath2;
- }
- let options = {
- uri: path,
- }
- try {
- await router.push(options);
- } catch {
- console.info('case route failed');
+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]);
+ expect(property).assertEqual(descriptionValue[i]);
}
}
-export async function clearRouter() {
- await router.clear();
-}
-
export async function playVideoSource(url, width, height, duration, playTime, done) {
console.info(`case media source url: ${url}`)
let videoPlayer = null;
@@ -185,4 +174,5 @@ export async function playVideoSource(url, width, height, duration, playTime, do
await videoPlayer.release().then(() => {
console.info('case release called');
}, mediaTestBase.failureCallback).catch(mediaTestBase.catchCallback);
-}
\ No newline at end of file
+}
+
diff --git a/multimedia/media/media_js_standard/VideoRecorderTestBase.js b/multimedia/media/media_js_standard/VideoRecorderTestBase.js
new file mode 100644
index 0000000000000000000000000000000000000000..74d20cdb50445ae4936f29f1bdcc9cc0533578dc
--- /dev/null
+++ b/multimedia/media/media_js_standard/VideoRecorderTestBase.js
@@ -0,0 +1,143 @@
+/*
+ * 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 {expect} from 'deccjsunit/index'
+import camera from '@ohos.multimedia.camera'
+import media from '@ohos.multimedia.media'
+import * as mediaTestBase from './MediaTestBase.js';
+
+const VIDEO_TRACK = 'video_track';
+const AUDIO_TRACK = 'audio_track';
+const AUDIO_VIDEO_TYPE = 'audio_video';
+const DELTA_TIME = 1000;
+const PLAY_TIME = 1000;
+let tarckType = new Array(VIDEO_TRACK, AUDIO_TRACK);
+
+export async function initCaptureSession(videoOutPut, cameraManager, cameras, cameraID) {
+ let cameraInput = await cameraManager.createCameraInput(cameras[cameraID].cameraId);
+ if (cameraInput != null) {
+ console.info('[camera] case createCameraInput success');
+ } else {
+ console.info('[camera] case createCameraInput failed');
+ return;
+ }
+ let captureSession = await camera.createCaptureSession(null);
+ await captureSession.beginConfig();
+ await captureSession.addInput(cameraInput);
+ await captureSession.addOutput(videoOutPut);
+ await captureSession.commitConfig();
+ return captureSession;
+}
+
+export async function stopCaptureSession(captureSession) {
+ await captureSession.release();
+}
+
+export function getTrackArray(videoType, recorderConfigFile) {
+ if (videoType == AUDIO_VIDEO_TYPE) {
+ let audioTrack = new Array(recorderConfigFile.audioBitrate, recorderConfigFile.audioChannels,
+ 'audio/mpeg', recorderConfigFile.audioSampleRate);
+ let videoTrack = new Array('video/mpeg', recorderConfigFile.videoFrameHeight,
+ recorderConfigFile.videoFrameWidth);
+ let trackArray = new Array(videoTrack, audioTrack);
+ return trackArray;
+ } else {
+ let videoTrack = new Array('video/mpeg',
+ recorderConfigFile.videoFrameHeight, recorderConfigFile.videoFrameWidth);
+ let trackArray = new Array(videoTrack);
+ return trackArray;
+ }
+}
+
+export function checkDescription(obj, trackTpye, descriptionValue) {
+ let index = 0;
+ if (trackTpye == VIDEO_TRACK) {
+ console.info('case video codec_mime is '+ obj['codec_mime']);
+ expect(obj['codec_mime']).assertEqual(descriptionValue[index++]);
+ console.info('case video height is '+ obj['height']);
+ expect(obj['height']).assertEqual(descriptionValue[index++]);
+ console.info('case video width is '+ obj['width']);
+ expect(obj['width']).assertEqual(descriptionValue[index++]);
+ } else {
+ console.info('case audio bitrate is '+ obj['bitrate']);
+ expect(obj['bitrate']).assertClose(descriptionValue[index++], 2 * DELTA_TIME);
+ console.info('case audio channel_count is '+ obj['channel_count']);
+ expect(obj['channel_count']).assertEqual(descriptionValue[index++]);
+ console.info('case audio codec_mime is '+ obj['codec_mime']);
+ expect(obj['codec_mime']).assertEqual(descriptionValue[index++]);
+ console.info('case audio sample_rate is '+ obj['sample_rate']);
+ expect(obj['sample_rate']).assertEqual(descriptionValue[index++]);
+ }
+}
+
+export async function checkVideos(playFdPath, duration, trackArray, playerSurfaceId) {
+ let videoPlayer = null;
+ let arrayDescription = null;
+ await media.createVideoPlayer().then((video) => {
+ if (typeof (video) != 'undefined') {
+ videoPlayer = video;
+ expect(videoPlayer.state).assertEqual('idle');
+ } else {
+ console.info('case createVideoPlayer is failed');
+ expect().assertFail();
+ }
+ }, mediaTestBase.failureCallback).catch(mediaTestBase.catchCallback);
+ console.info('[checkVideos] case checkVideos fdPath is :' + playFdPath);
+
+ videoPlayer.url = playFdPath;
+ await videoPlayer.setDisplaySurface(playerSurfaceId).then(() => {
+ console.info('case setDisplaySurface success');
+ expect(videoPlayer.state).assertEqual('idle');
+ }, mediaTestBase.failureCallback).catch(mediaTestBase.catchCallback);
+
+ await videoPlayer.prepare().then(() => {
+ expect(videoPlayer.state).assertEqual('prepared');
+ expect(videoPlayer.duration).assertClose(duration, DELTA_TIME);
+ console.info('case prepare called!!');
+ }, mediaTestBase.failureCallback).catch(mediaTestBase.catchCallback);
+
+ await videoPlayer.getTrackDescription().then((arrayList) => {
+ console.info('case getTrackDescription called!!');
+ if (typeof (arrayList) != 'undefined') {
+ arrayDescription = arrayList;
+ } else {
+ console.info('case getTrackDescription is failed');
+ expect().assertFail();
+ }
+ }, mediaTestBase.failureCallback).catch(mediaTestBase.catchCallback);
+
+ let startTime = videoPlayer.currentTime;
+ await videoPlayer.play().then(() => {
+ console.info('case play called!!');
+ mediaTestBase.msleep(PLAY_TIME);
+ expect(videoPlayer.state).assertEqual('playing');
+ }, mediaTestBase.failureCallback).catch(mediaTestBase.catchCallback);
+ let endTime = videoPlayer.currentTime;
+ expect(endTime - startTime).assertClose(PLAY_TIME, DELTA_TIME);
+
+ await videoPlayer.stop().then(() => {
+ console.info('case stop called!!');
+ expect(videoPlayer.state).assertEqual('stopped');
+ }, mediaTestBase.failureCallback).catch(mediaTestBase.catchCallback);
+
+ await videoPlayer.release().then(() => {
+ console.info('case release called!!');
+ }, mediaTestBase.failureCallback).catch(mediaTestBase.catchCallback);
+
+ expect(arrayDescription.length).assertEqual(trackArray.length);
+ for (let i = 0; i < arrayDescription.length; i++) {
+ checkDescription(arrayDescription[i], tarckType[i], trackArray[i]);
+ }
+}
\ No newline at end of file
diff --git a/multimedia/media/media_js_standard/videoPlayer/src/main/js/test/VideoPlayerAPICallbackTest.test.js b/multimedia/media/media_js_standard/videoPlayer/src/main/js/test/VideoPlayerAPICallbackTest.test.js
index 442a55bff33746e73f942fb3e56b146811988ecf..f56d8f7df46c0044d76d35296a6e3392b8e99b82 100644
--- a/multimedia/media/media_js_standard/videoPlayer/src/main/js/test/VideoPlayerAPICallbackTest.test.js
+++ b/multimedia/media/media_js_standard/videoPlayer/src/main/js/test/VideoPlayerAPICallbackTest.test.js
@@ -14,7 +14,6 @@
*/
import media from '@ohos.multimedia.media'
-import {toNewPage, clearRouter} from '../../../../../VideoPlayerTestBase.js';
import * as mediaTestBase from '../../../../../MediaTestBase.js';
import {describe, beforeAll, beforeEach, afterEach, afterAll, it, expect} from 'deccjsunit/index'
@@ -64,7 +63,7 @@ describe('VideoPlayerAPICallbackTest', function () {
await mediaTestBase.getFileDescriptor(VIDEO_SOURCE).then((res) => {
fileDescriptor = res;
});
- await toNewPage(pagePath1, pagePath2, pageId);
+ await mediaTestBase.toNewPage(pagePath1, pagePath2, pageId);
pageId = (pageId + 1) % 2;
await mediaTestBase.msleepAsync(1000).then(
() => {}, mediaTestBase.failureCallback).catch(mediaTestBase.catchCallback);
@@ -74,7 +73,7 @@ describe('VideoPlayerAPICallbackTest', function () {
})
afterEach(async function() {
- await clearRouter();
+ await mediaTestBase.clearRouter();
await mediaTestBase.closeFileDescriptor(VIDEO_SOURCE);
console.info('afterEach case');
})
diff --git a/multimedia/media/media_js_standard/videoPlayer/src/main/js/test/VideoPlayerFuncCallbackTest.test.js b/multimedia/media/media_js_standard/videoPlayer/src/main/js/test/VideoPlayerFuncCallbackTest.test.js
index 6614e65dcabade51ef12b4ab84fff6dbb0bfd8a1..b368c332d5149dfcf6153eaafefe9bbf27fd4d68 100644
--- a/multimedia/media/media_js_standard/videoPlayer/src/main/js/test/VideoPlayerFuncCallbackTest.test.js
+++ b/multimedia/media/media_js_standard/videoPlayer/src/main/js/test/VideoPlayerFuncCallbackTest.test.js
@@ -14,8 +14,8 @@
*/
import media from '@ohos.multimedia.media'
-import {toNewPage, clearRouter} from '../../../../../VideoPlayerTestBase.js';
import * as mediaTestBase from '../../../../../MediaTestBase.js';
+import * as videoPlayerBase from '../../../../../VideoPlayerTestBase.js';
import {describe, beforeAll, beforeEach, afterEach, afterAll, it, expect} from 'deccjsunit/index'
describe('VideoPlayerFuncCallbackTest', function () {
@@ -66,7 +66,7 @@ describe('VideoPlayerFuncCallbackTest', function () {
})
beforeEach(async function() {
- await toNewPage(pagePath1, pagePath2, pageId);
+ await mediaTestBase.toNewPage(pagePath1, pagePath2, pageId);
pageId = (pageId + 1) % 2;
await mediaTestBase.msleepAsync(1000).then(
() => {}, mediaTestBase.failureCallback).catch(mediaTestBase.catchCallback);
@@ -76,7 +76,7 @@ describe('VideoPlayerFuncCallbackTest', function () {
})
afterEach(async function() {
- await clearRouter();
+ await mediaTestBase.clearRouter();
console.info('afterEach case');
})
@@ -221,10 +221,18 @@ describe('VideoPlayerFuncCallbackTest', function () {
eventEmitter.on(GETDESCRIPTION, (videoPlayer, steps, done) => {
steps.shift();
+ let videoTrackKey = new Array('bitrate', 'codec_mime', 'frame_rate', 'height',
+ 'track_index', 'track_type', 'width');
+ let audioTrackKey = new Array('bitrate', 'channel_count', 'codec_mime', 'sample_rate',
+ 'track_index', 'track_type');
+ let videoTrackValue = new Array(1366541, 'video/x-h264', 6000, 480, 0, 1, 720);
+ let audioTrackValue = new Array(129207, 2, 'audio/mpeg', 44100, 1, 0);
+ let descriptionKey = new Array(videoTrackKey, audioTrackKey);
+ let descriptionValue = new Array(videoTrackValue, audioTrackValue);
videoPlayer.getTrackDescription((err, arrlist) => {
if (typeof (err) == 'undefined') {
for (let i = 0; i < arrlist.length; i++) {
- mediaTestBase.printDescription(arrlist[i]);
+ videoPlayerBase.checkDescription(arrlist[i], descriptionKey[i], descriptionValue[i]);
}
toNextStep(videoPlayer, steps, done);
} else if ((typeof (err) != 'undefined') && (steps[0] == ERROR_EVENT)) {
diff --git a/multimedia/media/media_js_standard/videoPlayer/src/main/js/test/VideoPlayerFuncPromiseTest.test.js b/multimedia/media/media_js_standard/videoPlayer/src/main/js/test/VideoPlayerFuncPromiseTest.test.js
index 4edb0d64825d54cda241396b11b5229d61b3e0d8..2b5d89f545472bba7e095f384521e8a92cd5c43d 100644
--- a/multimedia/media/media_js_standard/videoPlayer/src/main/js/test/VideoPlayerFuncPromiseTest.test.js
+++ b/multimedia/media/media_js_standard/videoPlayer/src/main/js/test/VideoPlayerFuncPromiseTest.test.js
@@ -14,8 +14,8 @@
*/
import media from '@ohos.multimedia.media'
-import {toNewPage, clearRouter} from '../../../../../VideoPlayerTestBase.js';
import * as mediaTestBase from '../../../../../MediaTestBase.js';
+import * as videoPlayerBase from '../../../../../VideoPlayerTestBase.js';
import {describe, beforeAll, beforeEach, afterEach, afterAll, it, expect} from 'deccjsunit/index'
describe('VideoPlayerFuncPromiseTest', function () {
@@ -44,7 +44,7 @@ describe('VideoPlayerFuncPromiseTest', function () {
})
beforeEach(async function() {
- await toNewPage(pagePath1, pagePath2, pageId);
+ await mediaTestBase.toNewPage(pagePath1, pagePath2, pageId);
pageId = (pageId + 1) % 2;
await mediaTestBase.msleepAsync(1000).then(
() => {}, mediaTestBase.failureCallback).catch(mediaTestBase.catchCallback);
@@ -54,7 +54,7 @@ describe('VideoPlayerFuncPromiseTest', function () {
})
afterEach(async function() {
- await clearRouter();
+ await mediaTestBase.clearRouter();
console.info('afterEach case');
})
@@ -445,6 +445,14 @@ describe('VideoPlayerFuncPromiseTest', function () {
mediaTestBase.isFileOpen(fileDescriptor, done);
let videoPlayer = null;
let arrayDescription = null;
+ let videoTrackKey = new Array('bitrate', 'codec_mime', 'frame_rate', 'height',
+ 'track_index', 'track_type', 'width');
+ let audioTrackKey = new Array('bitrate', 'channel_count', 'codec_mime', 'sample_rate',
+ 'track_index', 'track_type');
+ let videoTrackValue = new Array(1366541, 'video/x-h264', 6000, 480, 0, 1, 720);
+ let audioTrackValue = new Array(129207, 2, 'audio/mpeg', 44100, 1, 0);
+ let descriptionKey = new Array(videoTrackKey, audioTrackKey);
+ let descriptionValue = new Array(videoTrackValue, audioTrackValue);
await media.createVideoPlayer().then((video) => {
if (typeof (video) != 'undefined') {
videoPlayer = video;
@@ -477,7 +485,7 @@ describe('VideoPlayerFuncPromiseTest', function () {
}, mediaTestBase.failureCallback).catch(mediaTestBase.catchCallback);
for (let i = 0; i < arrayDescription.length; i++) {
- mediaTestBase.printDescription(arrayDescription[i]);
+ videoPlayerBase.checkDescription(arrayDescription[i], descriptionKey[i], descriptionValue[i]);
}
await videoPlayer.release().then(() => {
diff --git a/multimedia/media/media_js_standard/videoRecorder/Test.json b/multimedia/media/media_js_standard/videoRecorder/Test.json
index c8c2aac4fd94fce8f3d04d39e8e1e0c815f4a478..f3674de5fa81984f32dfc296ad842e4e9d78bd5a 100644
--- a/multimedia/media/media_js_standard/videoRecorder/Test.json
+++ b/multimedia/media/media_js_standard/videoRecorder/Test.json
@@ -10,6 +10,7 @@
{
"type": "ShellKit",
"run-command": [
+ "rm -rf /storage/media/100/local/files/Videos/*"
],
"teardown-command":[
]
diff --git a/multimedia/media/media_js_standard/videoRecorder/src/main/config.json b/multimedia/media/media_js_standard/videoRecorder/src/main/config.json
index 918c96f32043da55bbc3ab439da7fe253f6695a8..750e81eec5a4e8745a86510d88c8c9f4c61bcf8f 100644
--- a/multimedia/media/media_js_standard/videoRecorder/src/main/config.json
+++ b/multimedia/media/media_js_standard/videoRecorder/src/main/config.json
@@ -91,7 +91,9 @@
"js": [
{
"pages": [
- "pages/index/index"
+ "pages/index/index",
+ "pages/surfaceTest/surfaceTest",
+ "pages/surfaceTest2/surfaceTest2"
],
"name": "default",
"window": {
diff --git a/multimedia/media/media_js_standard/videoRecorder/src/main/js/default/pages/index/index.js b/multimedia/media/media_js_standard/videoRecorder/src/main/js/default/pages/index/index.js
index 67f8b8567ccc4932331b7a18a6b947340d84fb40..fd798251e27dec9f277f67b5964e7e594deaced5 100644
--- a/multimedia/media/media_js_standard/videoRecorder/src/main/js/default/pages/index/index.js
+++ b/multimedia/media/media_js_standard/videoRecorder/src/main/js/default/pages/index/index.js
@@ -14,7 +14,7 @@
*/
import {Core, ExpectExtend} from 'deccjsunit/index'
-
+import * as mediaTestBase from '../../../../../../../MediaTestBase.js';
export default {
data: {
title: ""
@@ -22,8 +22,17 @@ export default {
onInit() {
this.title = this.$t('strings.world');
},
- onShow() {
+ 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'
diff --git a/multimedia/media/media_js_standard/videoRecorder/src/main/js/default/pages/surfaceTest/surfaceTest.css b/multimedia/media/media_js_standard/videoRecorder/src/main/js/default/pages/surfaceTest/surfaceTest.css
new file mode 100644
index 0000000000000000000000000000000000000000..c9195944a956c0d5628c701b7a3d9d2ed525cd2d
--- /dev/null
+++ b/multimedia/media/media_js_standard/videoRecorder/src/main/js/default/pages/surfaceTest/surfaceTest.css
@@ -0,0 +1,61 @@
+/*
+ * 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.
+ */
+
+.container {
+ flex-direction: column;
+ justify-content: center;
+ align-items: center;
+ width: 100%;
+ height: 100%;
+}
+
+.title {
+ font-size: 40px;
+ color: #000000;
+ opacity: 0.9;
+}
+
+@media screen and (device-type: tablet) and (orientation: landscape) {
+ .title {
+ font-size: 100px;
+ }
+}
+
+@media screen and (device-type: wearable) {
+ .title {
+ font-size: 28px;
+ color: #FFFFFF;
+ }
+}
+
+@media screen and (device-type: tv) {
+ .container {
+ background-image: url("/common/images/Wallpaper.png");
+ background-size: cover;
+ background-repeat: no-repeat;
+ background-position: center;
+ }
+
+ .title {
+ font-size: 100px;
+ color: #FFFFFF;
+ }
+}
+
+@media screen and (device-type: phone) and (orientation: landscape) {
+ .title {
+ font-size: 60px;
+ }
+}
diff --git a/multimedia/media/media_js_standard/videoRecorder/src/main/js/default/pages/surfaceTest/surfaceTest.hml b/multimedia/media/media_js_standard/videoRecorder/src/main/js/default/pages/surfaceTest/surfaceTest.hml
new file mode 100644
index 0000000000000000000000000000000000000000..7b92aec42f622d3faaa96a9f3dc6e6fb248f84be
--- /dev/null
+++ b/multimedia/media/media_js_standard/videoRecorder/src/main/js/default/pages/surfaceTest/surfaceTest.hml
@@ -0,0 +1,26 @@
+
+
+
+
+ VideoRecorder Test
+
+
+
+
+
diff --git a/multimedia/media/media_js_standard/videoRecorder/src/main/js/default/pages/surfaceTest/surfaceTest.js b/multimedia/media/media_js_standard/videoRecorder/src/main/js/default/pages/surfaceTest/surfaceTest.js
new file mode 100644
index 0000000000000000000000000000000000000000..d38e7b9c705c7a3cdb3492a177d9ec84b0f57d0a
--- /dev/null
+++ b/multimedia/media/media_js_standard/videoRecorder/src/main/js/default/pages/surfaceTest/surfaceTest.js
@@ -0,0 +1,33 @@
+/*
+ * 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 Fileio from '@ohos.fileio'
+
+export default {
+ data: {
+ title: ""
+ },
+ onInit() {
+ this.title = this.$t('strings.world');
+ },
+ onShow() {
+ },
+ onReady() {
+ },
+ LoadXcomponent2() {
+ globalThis.value = this.$element('XcomponentId2').getXComponentSurfaceId()
+ },
+}
\ No newline at end of file
diff --git a/multimedia/media/media_js_standard/videoRecorder/src/main/js/default/pages/surfaceTest2/surfaceTest2.css b/multimedia/media/media_js_standard/videoRecorder/src/main/js/default/pages/surfaceTest2/surfaceTest2.css
new file mode 100644
index 0000000000000000000000000000000000000000..c9195944a956c0d5628c701b7a3d9d2ed525cd2d
--- /dev/null
+++ b/multimedia/media/media_js_standard/videoRecorder/src/main/js/default/pages/surfaceTest2/surfaceTest2.css
@@ -0,0 +1,61 @@
+/*
+ * 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.
+ */
+
+.container {
+ flex-direction: column;
+ justify-content: center;
+ align-items: center;
+ width: 100%;
+ height: 100%;
+}
+
+.title {
+ font-size: 40px;
+ color: #000000;
+ opacity: 0.9;
+}
+
+@media screen and (device-type: tablet) and (orientation: landscape) {
+ .title {
+ font-size: 100px;
+ }
+}
+
+@media screen and (device-type: wearable) {
+ .title {
+ font-size: 28px;
+ color: #FFFFFF;
+ }
+}
+
+@media screen and (device-type: tv) {
+ .container {
+ background-image: url("/common/images/Wallpaper.png");
+ background-size: cover;
+ background-repeat: no-repeat;
+ background-position: center;
+ }
+
+ .title {
+ font-size: 100px;
+ color: #FFFFFF;
+ }
+}
+
+@media screen and (device-type: phone) and (orientation: landscape) {
+ .title {
+ font-size: 60px;
+ }
+}
diff --git a/multimedia/media/media_js_standard/videoRecorder/src/main/js/default/pages/surfaceTest2/surfaceTest2.hml b/multimedia/media/media_js_standard/videoRecorder/src/main/js/default/pages/surfaceTest2/surfaceTest2.hml
new file mode 100644
index 0000000000000000000000000000000000000000..e01e11aee7adb81f2d91d36fcbab79bbe1dee929
--- /dev/null
+++ b/multimedia/media/media_js_standard/videoRecorder/src/main/js/default/pages/surfaceTest2/surfaceTest2.hml
@@ -0,0 +1,26 @@
+
+
+
+
+ VideoRecorder Test
+
+
+
+
+
diff --git a/multimedia/media/media_js_standard/videoRecorder/src/main/js/default/pages/surfaceTest2/surfaceTest2.js b/multimedia/media/media_js_standard/videoRecorder/src/main/js/default/pages/surfaceTest2/surfaceTest2.js
new file mode 100644
index 0000000000000000000000000000000000000000..067610e67bb013e2fa3b90aa2561e6d3229c2fe5
--- /dev/null
+++ b/multimedia/media/media_js_standard/videoRecorder/src/main/js/default/pages/surfaceTest2/surfaceTest2.js
@@ -0,0 +1,33 @@
+/*
+ * 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 Fileio from '@ohos.fileio'
+
+export default {
+ data: {
+ title: ""
+ },
+ onInit() {
+ this.title = this.$t('strings.world');
+ },
+ onShow() {
+ },
+ onReady() {
+ },
+ LoadXcomponent3() {
+ globalThis.value = this.$element('XcomponentId3').getXComponentSurfaceId()
+ },
+}
\ No newline at end of file
diff --git a/multimedia/media/media_js_standard/videoRecorder/src/main/js/test/VideoRecorderAPICallbackTest.test.js b/multimedia/media/media_js_standard/videoRecorder/src/main/js/test/VideoRecorderAPICallbackTest.test.js
index 9360113e363b6dc7154fc45f9011fcbcf55085d4..1ce20b239cd504be576a56ed9fe0455c1c01c49c 100644
--- a/multimedia/media/media_js_standard/videoRecorder/src/main/js/test/VideoRecorderAPICallbackTest.test.js
+++ b/multimedia/media/media_js_standard/videoRecorder/src/main/js/test/VideoRecorderAPICallbackTest.test.js
@@ -15,7 +15,8 @@
import media from '@ohos.multimedia.media'
import camera from '@ohos.multimedia.camera'
-import mediaLibrary from '@ohos.multimedia.mediaLibrary'
+import * as mediaTestBase from '../../../../../MediaTestBase.js';
+import * as videoRecorderBase from '../../../../../VideoRecorderTestBase.js';
import {describe, beforeAll, beforeEach, afterEach, afterAll, it, expect} from 'deccjsunit/index'
describe('VideoRecorderAPICallbackTest', function () {
@@ -24,7 +25,6 @@ describe('VideoRecorderAPICallbackTest', function () {
const END_EVENT = 'end';
const CREATE_EVENT = 'create';
const PREPARE_EVENT = 'prepare';
- const PREPARE_OLNYVIDEO_EVENT = 'prepare_only';
const GETSURFACE_EVENT = 'getInputSurface';
const START_EVENT = 'start';
const PAUSE_EVENT = 'pause';
@@ -33,9 +33,6 @@ describe('VideoRecorderAPICallbackTest', function () {
const RESET_EVENT = 'reset';
const RELEASE_EVENT = 'release';
const START_STREEAM = 'start_stream';
- const SETEXIT = 'setExit';
- const SETSTART = 'setStart';
- const SETPAUSE = 'setPause';
const CLOSE_STREAM = 'close_stream';
const ERROR_EVENT = 'error';
let cameraManager;
@@ -44,63 +41,53 @@ describe('VideoRecorderAPICallbackTest', function () {
let videoOutput;
let surfaceID;
let fdPath;
- let fileAsset;
- let fdNumber;
+ let fdObject;
+ let cameraID = 0;
let events = require('events');
let eventEmitter = new events.EventEmitter();
let configFile = {
audioBitrate : 48000,
audioChannels : 2,
- audioCodec : 'audio/mp4a-latm',
+ audioCodec : media.CodecMimeType.AUDIO_AAC,
audioSampleRate : 48000,
durationTime : 1000,
- fileFormat : 'mp4',
+ fileFormat : media.ContainerFormatType.CFT_MPEG_4,
videoBitrate : 48000,
- videoCodec : 'video/mp4v-es',
+ videoCodec : media.CodecMimeType.VIDEO_MPEG4,
videoFrameWidth : 640,
videoFrameHeight : 480,
videoFrameRate : 10
}
// rotation 0, 90, 180, 270
let videoConfig = {
- audioSourceType : 1,
- videoSourceType : 0,
+ audioSourceType : media.AudioSourceType.AUDIO_SOURCE_TYPE_MIC,
+ videoSourceType : media.VideoSourceType.VIDEO_SOURCE_TYPE_SURFACE_YUV,
profile : configFile,
- url : 'file:///data/media/API.mp4',
+ url : 'fd://',
rotation : 0,
location : { latitude : 30, longitude : 130 },
maxSize : 100,
maxDuration : 500
}
- let onlyVideoProfile = {
- durationTime : 1000,
- fileFormat : 'mp4',
- videoBitrate : 48000,
- videoCodec : 'video/mp4v-es',
- videoFrameWidth : 640,
- videoFrameHeight : 480,
- videoFrameRate : 10
- }
-
- let onlyVideoConfig = {
- videoSourceType : 0,
- profile : onlyVideoProfile,
- url : 'file:///data/media/API.mp4',
- rotation : 0,
- location : { latitude : 30, longitude : 130 },
- maxSize : 100,
- maxDuration : 500
- }
-
- function sleep(time) {
- for(let t = Date.now();Date.now() - t <= time;);
- }
-
beforeAll(async function () {
- await initCamera();
- await getFd('API.mp4');
+ cameraManager = await camera.getCameraManager(null);
+ if (cameraManager != null) {
+ console.info('[camera] case getCameraManager success');
+ } else {
+ console.info('[camera] case getCameraManager failed');
+ return;
+ }
+ cameras = await cameraManager.getCameras();
+ if (cameras != null) {
+ console.info('[camera] case getCameras success');
+ } else {
+ console.info('[camera] case getCameras failed');
+ }
+ fdObject = await mediaTestBase.getFd('recorder_callback_api.mp4');
+ fdPath = "fd://" + fdObject.fdNumber.toString();
+ videoConfig.url = fdPath;
console.info('beforeAll case');
})
@@ -114,76 +101,10 @@ describe('VideoRecorderAPICallbackTest', function () {
})
afterAll(async function () {
- await closeFd();
+ await mediaTestBase.closeFd();
console.info('afterAll case');
})
- async function getFd(pathName) {
- let displayName = pathName;
- const mediaTest = mediaLibrary.getMediaLibrary();
- let fileKeyObj = mediaLibrary.FileKey;
- let mediaType = mediaLibrary.MediaType.VIDEO;
- let publicPath = await mediaTest.getPublicDirectory(mediaLibrary.DirectoryType.DIR_VIDEO);
- let dataUri = await mediaTest.createAsset(mediaType, displayName, publicPath);
- if (dataUri != undefined) {
- let args = dataUri.id.toString();
- let fetchOp = {
- selections : fileKeyObj.ID + "=?",
- selectionArgs : [args],
- }
- let fetchFileResult = await mediaTest.getFileAssets(fetchOp);
- fileAsset = await fetchFileResult.getAllObject();
- fdNumber = await fileAsset[0].open('Rw');
- fdPath = "fd://" + fdNumber.toString();
- }
- }
-
- async function closeFd() {
- if (fileAsset != null) {
- await fileAsset[0].close(fdNumber).then(() => {
- console.info('[mediaLibrary] case close fd success');
- }).catch((err) => {
- console.info('[mediaLibrary] case close fd failed');
- });
- } else {
- console.info('[mediaLibrary] case fileAsset is null');
- }
- }
-
- async function initCamera() {
- cameraManager = await camera.getCameraManager(null);
- if (cameraManager != null) {
- console.info('[camera] case getCameraManager success');
- } else {
- console.info('[camera] case getCameraManager failed');
- return;
- }
- cameras = await cameraManager.getCameras();
- if (cameras != null) {
- console.info('[camera] case getCameras success');
- } else {
- console.info('[camera] case getCameras failed');
- }
- }
-
- async function initCaptureSession(videoOutPut) {
- let cameraInput = await cameraManager.createCameraInput(cameras[0].cameraId);
- if (cameraInput != null) {
- console.info('[camera] case createCameraInput success');
- } else {
- console.info('[camera] case createCameraInput failed');
- return;
- }
- captureSession = await camera.createCaptureSession(null);
- await captureSession.beginConfig();
- await captureSession.addInput(cameraInput);
- await captureSession.addOutput(videoOutPut);
- await captureSession.commitConfig();
- }
-
- async function stopCaptureSession() {
- await captureSession.release();
- }
function printfError(error, done) {
expect().assertFail();
@@ -208,23 +129,13 @@ describe('VideoRecorderAPICallbackTest', function () {
} else {
console.info('[camera] case createVideoOutput success');
}
- await initCaptureSession(videoOutput);
+ captureSession = await videoRecorderBase.initCaptureSession(videoOutput, cameraManager, cameras, cameraID);
await videoOutput.start().then(() => {
console.info('[camera] case videoOutput start success');
});
toNextStep(videoRecorder, steps, done);
});
- eventEmitter.on(SETSTART, async (videoRecorder, steps, done) => {
- steps.shift();
- toNextStep(videoRecorder, steps, done);
- });
-
- eventEmitter.on(SETPAUSE, async (videoRecorder, steps, done) => {
- steps.shift();
- toNextStep(videoRecorder, steps, done);
- });
-
eventEmitter.on(CLOSE_STREAM, async (videoRecorder, steps, done) => {
steps.shift();
await videoOutput.stop().then(() => {
@@ -234,7 +145,7 @@ describe('VideoRecorderAPICallbackTest', function () {
console.info('[camera] case videoOutput release success');
});
videoOutput = undefined;
- await stopCaptureSession();
+ await videoRecorderBase.stopCaptureSession(captureSession);
toNextStep(videoRecorder, steps, done);
});
@@ -273,23 +184,6 @@ describe('VideoRecorderAPICallbackTest', function () {
});
});
- eventEmitter.on(PREPARE_OLNYVIDEO_EVENT, async (videoRecorder, steps, done) => {
- steps.shift();
- videoRecorder.prepare(onlyVideoConfig, (err) => {
- if (typeof (err) == 'undefined') {
- console.info('case prepare success');
- expect(videoRecorder.state).assertEqual('prepared');
- toNextStep(videoRecorder, steps, done);
- } else if ((typeof (err) != 'undefined') && (steps[0] == ERROR_EVENT)) {
- steps.shift();
- console.info('case prepare error hanpped');
- toNextStep(videoRecorder, steps, done);
- } else {
- printfError(err, done);
- }
- });
- });
-
eventEmitter.on(GETSURFACE_EVENT, async (videoRecorder, steps, done) => {
steps.shift();
videoRecorder.getInputSurface((err, outPutSurface) => {
@@ -313,7 +207,7 @@ describe('VideoRecorderAPICallbackTest', function () {
if (typeof (err) == 'undefined') {
console.info('case start success');
expect(videoRecorder.state).assertEqual('playing');
- sleep(RECORDER_TIME);
+ mediaTestBase.msleep(RECORDER_TIME);
toNextStep(videoRecorder, steps, done);
} else if ((typeof (err) != 'undefined') && (steps[0] == ERROR_EVENT)) {
steps.shift();
@@ -330,7 +224,7 @@ describe('VideoRecorderAPICallbackTest', function () {
videoRecorder.pause((err) => {
if (typeof (err) == 'undefined') {
console.info('case pause success');
- sleep(PAUSE_TIME);
+ mediaTestBase.msleep(PAUSE_TIME);
expect(videoRecorder.state).assertEqual('paused');
toNextStep(videoRecorder, steps, done);
} else if ((typeof (err) != 'undefined') && (steps[0] == ERROR_EVENT)) {
@@ -348,7 +242,7 @@ describe('VideoRecorderAPICallbackTest', function () {
videoRecorder.resume((err) => {
if (typeof (err) == 'undefined') {
console.info('case resume success');
- sleep(RECORDER_TIME);
+ mediaTestBase.msleep(RECORDER_TIME);
expect(videoRecorder.state).assertEqual('playing');
toNextStep(videoRecorder, steps, done);
} else if ((typeof (err) != 'undefined') && (steps[0] == ERROR_EVENT)) {
@@ -421,7 +315,6 @@ describe('VideoRecorderAPICallbackTest', function () {
* @tc.level : Level2
*/
it('SUB_MEDIA_VIDEO_RECORDER_PREPARE_CALLBACK_0100', 0, async function (done) {
- videoConfig.url = fdPath;
let videoRecorder = null;
let mySteps = new Array(CREATE_EVENT, PREPARE_EVENT, RELEASE_EVENT, END_EVENT);
eventEmitter.emit(mySteps[0], videoRecorder, mySteps, done);
@@ -453,7 +346,7 @@ describe('VideoRecorderAPICallbackTest', function () {
it('SUB_MEDIA_VIDEO_RECORDER_PREPARE_CALLBACK_0300', 0, async function (done) {
let videoRecorder = null;
let mySteps = new Array(CREATE_EVENT, PREPARE_EVENT, GETSURFACE_EVENT, START_STREEAM,
- START_EVENT, SETPAUSE, PAUSE_EVENT, CLOSE_STREAM, PREPARE_EVENT, ERROR_EVENT, RELEASE_EVENT, END_EVENT);
+ START_EVENT, PAUSE_EVENT, CLOSE_STREAM, PREPARE_EVENT, ERROR_EVENT, RELEASE_EVENT, END_EVENT);
eventEmitter.emit(mySteps[0], videoRecorder, mySteps, done);
})
@@ -468,7 +361,7 @@ describe('VideoRecorderAPICallbackTest', function () {
it('SUB_MEDIA_VIDEO_RECORDER_PREPARE_CALLBACK_0400', 0, async function (done) {
let videoRecorder = null;
let mySteps = new Array(CREATE_EVENT, PREPARE_EVENT, GETSURFACE_EVENT, START_STREEAM,
- START_EVENT, SETPAUSE, PAUSE_EVENT, SETPAUSE, SETSTART, RESUME_EVENT,
+ START_EVENT, PAUSE_EVENT, RESUME_EVENT,
PREPARE_EVENT, ERROR_EVENT, RELEASE_EVENT, CLOSE_STREAM, END_EVENT);
eventEmitter.emit(mySteps[0], videoRecorder, mySteps, done);
})
@@ -573,7 +466,7 @@ describe('VideoRecorderAPICallbackTest', function () {
it('SUB_MEDIA_VIDEO_RECORDER_START_CALLBACK_0300', 0, async function (done) {
let videoRecorder = null;
let mySteps = new Array(CREATE_EVENT, PREPARE_EVENT, GETSURFACE_EVENT, START_STREEAM,
- START_EVENT, SETPAUSE, PAUSE_EVENT, START_EVENT, ERROR_EVENT, RELEASE_EVENT, CLOSE_STREAM, END_EVENT);
+ START_EVENT, PAUSE_EVENT, START_EVENT, ERROR_EVENT, RELEASE_EVENT, CLOSE_STREAM, END_EVENT);
eventEmitter.emit(mySteps[0], videoRecorder, mySteps, done);
})
@@ -588,7 +481,7 @@ describe('VideoRecorderAPICallbackTest', function () {
it('SUB_MEDIA_VIDEO_RECORDER_START_CALLBACK_0400', 0, async function (done) {
let videoRecorder = null;
let mySteps = new Array(CREATE_EVENT, PREPARE_EVENT, GETSURFACE_EVENT, START_STREEAM,
- START_EVENT, SETPAUSE, PAUSE_EVENT, SETPAUSE, SETSTART, RESUME_EVENT,
+ START_EVENT, PAUSE_EVENT, RESUME_EVENT,
START_EVENT, RELEASE_EVENT, CLOSE_STREAM, END_EVENT);
eventEmitter.emit(mySteps[0], videoRecorder, mySteps, done);
})
@@ -692,7 +585,7 @@ describe('VideoRecorderAPICallbackTest', function () {
it('SUB_MEDIA_VIDEO_RECORDER_PAUSE_CALLBACK_0300', 0, async function (done) {
let videoRecorder = null;
let mySteps = new Array(CREATE_EVENT, PREPARE_EVENT, GETSURFACE_EVENT, START_STREEAM,
- START_EVENT, SETPAUSE, PAUSE_EVENT, CLOSE_STREAM, RELEASE_EVENT, END_EVENT);
+ START_EVENT, PAUSE_EVENT, CLOSE_STREAM, RELEASE_EVENT, END_EVENT);
eventEmitter.emit(mySteps[0], videoRecorder, mySteps, done);
})
@@ -707,7 +600,7 @@ describe('VideoRecorderAPICallbackTest', function () {
it('SUB_MEDIA_VIDEO_RECORDER_PAUSE_CALLBACK_0400', 0, async function (done) {
let videoRecorder = null;
let mySteps = new Array(CREATE_EVENT, PREPARE_EVENT, GETSURFACE_EVENT, START_STREEAM,
- START_EVENT, SETPAUSE, PAUSE_EVENT, SETPAUSE, SETSTART, RESUME_EVENT, SETPAUSE,
+ START_EVENT, PAUSE_EVENT, RESUME_EVENT,
PAUSE_EVENT, CLOSE_STREAM, RELEASE_EVENT, END_EVENT);
eventEmitter.emit(mySteps[0], videoRecorder, mySteps, done);
})
@@ -768,7 +661,7 @@ describe('VideoRecorderAPICallbackTest', function () {
it('SUB_MEDIA_VIDEO_RECORDER_PAUSE_CALLBACK_0800', 0, async function (done) {
let videoRecorder = null;
let mySteps = new Array(CREATE_EVENT, PREPARE_EVENT, GETSURFACE_EVENT, START_STREEAM,
- START_EVENT, SETPAUSE, PAUSE_EVENT, PAUSE_EVENT, PAUSE_EVENT, CLOSE_STREAM, RELEASE_EVENT, END_EVENT);
+ START_EVENT, PAUSE_EVENT, PAUSE_EVENT, PAUSE_EVENT, CLOSE_STREAM, RELEASE_EVENT, END_EVENT);
eventEmitter.emit(mySteps[0], videoRecorder, mySteps, done);
})
@@ -826,7 +719,7 @@ describe('VideoRecorderAPICallbackTest', function () {
it('SUB_MEDIA_VIDEO_RECORDER_RESUME_CALLBACK_0400', 0, async function (done) {
let videoRecorder = null;
let mySteps = new Array(CREATE_EVENT, PREPARE_EVENT, GETSURFACE_EVENT, START_STREEAM,
- START_EVENT, SETPAUSE, PAUSE_EVENT, SETPAUSE, SETSTART,
+ START_EVENT, PAUSE_EVENT,
RESUME_EVENT, RELEASE_EVENT, CLOSE_STREAM, END_EVENT);
eventEmitter.emit(mySteps[0], videoRecorder, mySteps, done);
})
@@ -887,7 +780,7 @@ describe('VideoRecorderAPICallbackTest', function () {
it('SUB_MEDIA_VIDEO_RECORDER_RESUME_CALLBACK_0800', 0, async function (done) {
let videoRecorder = null;
let mySteps = new Array(CREATE_EVENT, PREPARE_EVENT, GETSURFACE_EVENT, START_STREEAM,
- START_EVENT, SETPAUSE, PAUSE_EVENT, SETPAUSE, SETSTART,
+ START_EVENT, PAUSE_EVENT,
RESUME_EVENT, RESUME_EVENT, RESUME_EVENT, RELEASE_EVENT, CLOSE_STREAM, END_EVENT);
eventEmitter.emit(mySteps[0], videoRecorder, mySteps, done);
})
@@ -946,7 +839,7 @@ describe('VideoRecorderAPICallbackTest', function () {
it('SUB_MEDIA_VIDEO_RECORDER_STOP_CALLBACK_0400', 0, async function (done) {
let videoRecorder = null;
let mySteps = new Array(CREATE_EVENT, PREPARE_EVENT, GETSURFACE_EVENT, START_STREEAM,
- START_EVENT, SETPAUSE, PAUSE_EVENT, STOP_EVENT, CLOSE_STREAM, RELEASE_EVENT, END_EVENT);
+ START_EVENT, PAUSE_EVENT, STOP_EVENT, CLOSE_STREAM, RELEASE_EVENT, END_EVENT);
eventEmitter.emit(mySteps[0], videoRecorder, mySteps, done);
})
@@ -961,7 +854,7 @@ describe('VideoRecorderAPICallbackTest', function () {
it('SUB_MEDIA_VIDEO_RECORDER_STOP_CALLBACK_0500', 0, async function (done) {
let videoRecorder = null;
let mySteps = new Array(CREATE_EVENT, PREPARE_EVENT, GETSURFACE_EVENT, START_STREEAM,
- START_EVENT, SETPAUSE, PAUSE_EVENT, SETPAUSE, SETSTART, RESUME_EVENT,
+ START_EVENT, PAUSE_EVENT, RESUME_EVENT,
STOP_EVENT, CLOSE_STREAM, RELEASE_EVENT, END_EVENT);
eventEmitter.emit(mySteps[0], videoRecorder, mySteps, done);
})
@@ -1066,7 +959,7 @@ describe('VideoRecorderAPICallbackTest', function () {
it('SUB_MEDIA_VIDEO_RECORDER_RESET_CALLBACK_0400', 0, async function (done) {
let videoRecorder = null;
let mySteps = new Array(CREATE_EVENT, PREPARE_EVENT, GETSURFACE_EVENT, START_STREEAM,
- START_EVENT, SETPAUSE, PAUSE_EVENT, RESET_EVENT, CLOSE_STREAM, RELEASE_EVENT, END_EVENT);
+ START_EVENT, PAUSE_EVENT, RESET_EVENT, CLOSE_STREAM, RELEASE_EVENT, END_EVENT);
eventEmitter.emit(mySteps[0], videoRecorder, mySteps, done);
})
@@ -1081,7 +974,7 @@ describe('VideoRecorderAPICallbackTest', function () {
it('SUB_MEDIA_VIDEO_RECORDER_RESET_CALLBACK_0500', 0, async function (done) {
let videoRecorder = null;
let mySteps = new Array(CREATE_EVENT, PREPARE_EVENT, GETSURFACE_EVENT, START_STREEAM,
- START_EVENT, SETPAUSE, PAUSE_EVENT, SETPAUSE, SETSTART, RESUME_EVENT,
+ START_EVENT, PAUSE_EVENT, RESUME_EVENT,
RESET_EVENT, CLOSE_STREAM, RELEASE_EVENT, END_EVENT);
eventEmitter.emit(mySteps[0], videoRecorder, mySteps, done);
})
@@ -1184,7 +1077,7 @@ describe('VideoRecorderAPICallbackTest', function () {
it('SUB_MEDIA_VIDEO_RECORDER_GETSURFACE_CALLBACK_0400', 0, async function (done) {
let videoRecorder = null;
let mySteps = new Array(CREATE_EVENT, PREPARE_EVENT, GETSURFACE_EVENT, START_STREEAM, START_EVENT,
- SETPAUSE, PAUSE_EVENT, GETSURFACE_EVENT, RELEASE_EVENT, CLOSE_STREAM, END_EVENT);
+ PAUSE_EVENT, GETSURFACE_EVENT, RELEASE_EVENT, CLOSE_STREAM, END_EVENT);
eventEmitter.emit(mySteps[0], videoRecorder, mySteps, done);
})
@@ -1199,7 +1092,7 @@ describe('VideoRecorderAPICallbackTest', function () {
it('SUB_MEDIA_VIDEO_RECORDER_GETSURFACE_CALLBACK_0500', 0, async function (done) {
let videoRecorder = null;
let mySteps = new Array(CREATE_EVENT, PREPARE_EVENT, GETSURFACE_EVENT, START_STREEAM, START_EVENT,
- SETPAUSE, PAUSE_EVENT, SETPAUSE, SETSTART, RESUME_EVENT, GETSURFACE_EVENT,
+ PAUSE_EVENT, RESUME_EVENT, GETSURFACE_EVENT,
RELEASE_EVENT, CLOSE_STREAM, END_EVENT);
eventEmitter.emit(mySteps[0], videoRecorder, mySteps, done);
})
diff --git a/multimedia/media/media_js_standard/videoRecorder/src/main/js/test/VideoRecorderFuncCallbackTest.test.js b/multimedia/media/media_js_standard/videoRecorder/src/main/js/test/VideoRecorderFuncCallbackTest.test.js
index 67677852ba93fa41a0c47c1420b687629f44e74e..9a798810b757de8b94feca801e729ff18e67cc31 100644
--- a/multimedia/media/media_js_standard/videoRecorder/src/main/js/test/VideoRecorderFuncCallbackTest.test.js
+++ b/multimedia/media/media_js_standard/videoRecorder/src/main/js/test/VideoRecorderFuncCallbackTest.test.js
@@ -15,9 +15,8 @@
import media from '@ohos.multimedia.media'
import camera from '@ohos.multimedia.camera'
-import mediaLibrary from '@ohos.multimedia.mediaLibrary'
-import abilityAccessCtrl from '@ohos.abilityAccessCtrl'
-import bundle from '@ohos.bundle'
+import * as mediaTestBase from '../../../../../MediaTestBase.js';
+import * as videoRecorderBase from '../../../../../VideoRecorderTestBase.js';
import {describe, beforeAll, beforeEach, afterEach, afterAll, it, expect} from 'deccjsunit/index'
describe('VideoRecorderFuncCallbackTest', function () {
@@ -34,33 +33,40 @@ describe('VideoRecorderFuncCallbackTest', function () {
const STOP_EVENT = 'stop';
const RESET_EVENT = 'reset';
const RELEASE_EVENT = 'release';
+ const CHECK_EVENT = "check";
+ const ONLYVIDEO_TYPE = 'only_video';
+ const AUDIO_VIDEO_TYPE = 'audio_video';
+ const pagePath1 = 'pages/surfaceTest/surfaceTest';
+ const pagePath2 = 'pages/surfaceTest2/surfaceTest2';
let cameraManager;
let cameras;
let captureSession;
let videoOutput;
let surfaceID;
+ let playerSurfaceId = '';
let fdPath;
- let fileAsset;
- let fdNumber;
+ let fdObject;
+ let cameraID = 0;
+ let pageId = 0;
let configFile = {
audioBitrate : 48000,
audioChannels : 2,
- audioCodec : 'audio/mp4a-latm',
+ audioCodec : media.CodecMimeType.AUDIO_AAC,
audioSampleRate : 48000,
durationTime : 1000,
- fileFormat : 'mp4',
+ fileFormat : media.ContainerFormatType.CFT_MPEG_4,
videoBitrate : 48000,
- videoCodec : 'video/mp4v-es',
+ videoCodec : media.CodecMimeType.VIDEO_MPEG4,
videoFrameWidth : 640,
videoFrameHeight : 480,
videoFrameRate : 10
}
// rotation 0, 90, 180, 270
let videoConfig = {
- audioSourceType : 1,
- videoSourceType : 0,
+ audioSourceType : media.AudioSourceType.AUDIO_SOURCE_TYPE_MIC,
+ videoSourceType : media.VideoSourceType.VIDEO_SOURCE_TYPE_SURFACE_YUV,
profile : configFile,
- url : 'file:///data/media/01.mp4',
+ url : 'fd://',
rotation : 0,
location : { latitude : 30, longitude : 130 },
maxSize : 100,
@@ -69,122 +75,25 @@ describe('VideoRecorderFuncCallbackTest', function () {
let onlyVideoProfile = {
durationTime : 1000,
- fileFormat : 'mp4',
+ fileFormat : media.ContainerFormatType.CFT_MPEG_4,
videoBitrate : 48000,
- videoCodec : 'video/mp4v-es',
+ videoCodec : media.CodecMimeType.VIDEO_MPEG4,
videoFrameWidth : 640,
videoFrameHeight : 480,
videoFrameRate : 10
}
let onlyVideoConfig = {
- videoSourceType : 0,
+ videoSourceType : media.VideoSourceType.VIDEO_SOURCE_TYPE_SURFACE_YUV,
profile : onlyVideoProfile,
- url : 'file:///data/media/01.mp4',
+ url : 'fd://',
rotation : 0,
location : { latitude : 30, longitude : 130 },
maxSize : 100,
maxDuration : 500
}
- function sleep(time) {
- for(let t = Date.now();Date.now() - t <= time;);
- }
-
beforeAll(async function () {
- await initCamera();
- await applyPermission();
- console.info('beforeAll case');
- })
-
- beforeEach(function () {
- sleep(5000);
- console.info('beforeEach case');
- })
-
- afterEach(async function () {
- await closeFd();
- console.info('afterEach case');
- })
-
- afterAll(function () {
- console.info('afterAll case');
- })
-
- async function applyPermission() {
- let appInfo = await bundle.getApplicationInfo('ohos.acts.multimedia.video.videorecorder', 0, 100);
- let atManager = abilityAccessCtrl.createAtManager();
- if (atManager != null) {
- let tokenID = appInfo.accessTokenId;
- console.info('[permission] case accessTokenID is ' + tokenID);
- 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';
- await atManager.grantUserGrantedPermission(tokenID, permissionName1, 1).then((result) => {
- console.info('[permission] case grantUserGrantedPermission success :' + result);
- }).catch((err) => {
- console.info('[permission] case grantUserGrantedPermission failed :' + err);
- });
- await atManager.grantUserGrantedPermission(tokenID, permissionName2, 1).then((result) => {
- console.info('[permission] case grantUserGrantedPermission success :' + result);
- }).catch((err) => {
- console.info('[permission] case grantUserGrantedPermission failed :' + err);
- });
- await atManager.grantUserGrantedPermission(tokenID, permissionName3, 1).then((result) => {
- console.info('[permission] case grantUserGrantedPermission success :' + result);
- }).catch((err) => {
- console.info('[permission] case grantUserGrantedPermission failed :' + err);
- });
- await atManager.grantUserGrantedPermission(tokenID, permissionName4, 1).then((result) => {
- console.info('[permission] case grantUserGrantedPermission success :' + result);
- }).catch((err) => {
- console.info('[permission] case grantUserGrantedPermission failed :' + err);
- });
- await atManager.grantUserGrantedPermission(tokenID, permissionName5, 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');
- }
- }
-
- async function getFd(pathName) {
- let displayName = pathName;
- const mediaTest = mediaLibrary.getMediaLibrary();
- let fileKeyObj = mediaLibrary.FileKey;
- let mediaType = mediaLibrary.MediaType.VIDEO;
- let publicPath = await mediaTest.getPublicDirectory(mediaLibrary.DirectoryType.DIR_VIDEO);
- let dataUri = await mediaTest.createAsset(mediaType, displayName, publicPath);
- if (dataUri != undefined) {
- let args = dataUri.id.toString();
- let fetchOp = {
- selections : fileKeyObj.ID + "=?",
- selectionArgs : [args],
- }
- let fetchFileResult = await mediaTest.getFileAssets(fetchOp);
- fileAsset = await fetchFileResult.getAllObject();
- fdNumber = await fileAsset[0].open('Rw');
- fdPath = "fd://" + fdNumber.toString();
- }
- }
-
- async function closeFd() {
- if (fileAsset != null) {
- await fileAsset[0].close(fdNumber).then(() => {
- console.info('[mediaLibrary] case close fd success');
- }).catch((err) => {
- console.info('[mediaLibrary] case close fd failed');
- });
- } else {
- console.info('[mediaLibrary] case fileAsset is null');
- }
- }
-
- async function initCamera() {
cameraManager = await camera.getCameraManager(null);
if (cameraManager != null) {
console.info('[camera] case getCameraManager success');
@@ -198,26 +107,27 @@ describe('VideoRecorderFuncCallbackTest', function () {
} else {
console.info('[camera] case getCameras failed');
}
- }
+ console.info('beforeAll case');
+ })
- async function initCaptureSession(videoOutPut) {
- let cameraInput = await cameraManager.createCameraInput(cameras[0].cameraId);
- if (cameraInput != null) {
- console.info('[camera] case createCameraInput success');
- } else {
- console.info('[camera] case createCameraInput failed');
- return;
- }
- captureSession = await camera.createCaptureSession(null);
- await captureSession.beginConfig();
- await captureSession.addInput(cameraInput);
- await captureSession.addOutput(videoOutPut);
- await captureSession.commitConfig();
- }
+ beforeEach(async function () {
+ await mediaTestBase.toNewPage(pagePath1, pagePath2, pageId);
+ pageId = (pageId + 1) % 2;
+ await mediaTestBase.msleepAsync(1000).then(
+ () => {}, mediaTestBase.failureCallback).catch(mediaTestBase.catchCallback);
+ playerSurfaceId = globalThis.value;
+ cameraID = 0;
+ console.info('beforeEach case');
+ })
- async function stopCaptureSession() {
- await captureSession.release();
- }
+ afterEach(async function () {
+ await mediaTestBase.clearRouter();
+ console.info('afterEach case');
+ })
+
+ afterAll(function () {
+ console.info('afterAll case');
+ })
function printfError(error, done) {
expect().assertFail();
@@ -228,11 +138,13 @@ describe('VideoRecorderFuncCallbackTest', function () {
let events = require('events');
let eventEmitter = new events.EventEmitter();
- function toNextStep(videoRecorder, steps, done) {
+ async function toNextStep(videoRecorder, steps, done) {
if (steps[0] == END_EVENT) {
console.info('case success!!');
+ await mediaTestBase.closeFd(fdObject.fileAsset, fdObject.fdNumber);
done();
} else {
+ console.info('case toNextStep is ' + steps[0]);
eventEmitter.emit(steps[0], videoRecorder, steps, done);
}
}
@@ -312,7 +224,7 @@ describe('VideoRecorderFuncCallbackTest', function () {
} else {
console.info('case createVideoOutput success');
}
- await initCaptureSession(videoOutput);
+ captureSession = await videoRecorderBase.initCaptureSession(videoOutput, cameraManager, cameras, cameraID);
await videoOutput.start().then(() => {
console.info('case videoOutput start success');
});
@@ -320,7 +232,7 @@ describe('VideoRecorderFuncCallbackTest', function () {
if (typeof (err) == 'undefined') {
console.info('case start success');
expect(videoRecorder.state).assertEqual('playing');
- sleep(RECORDER_TIME);
+ mediaTestBase.msleep(RECORDER_TIME);
toNextStep(videoRecorder, steps, done);
} else {
printfError(err, done);
@@ -334,7 +246,7 @@ describe('VideoRecorderFuncCallbackTest', function () {
if (typeof (err) == 'undefined') {
console.info('case pause success');
expect(videoRecorder.state).assertEqual('paused');
- sleep(PAUSE_TIME);
+ mediaTestBase.msleep(PAUSE_TIME);
toNextStep(videoRecorder, steps, done);
} else {
printfError(err, done);
@@ -347,7 +259,7 @@ describe('VideoRecorderFuncCallbackTest', function () {
videoRecorder.resume((err) => {
if (typeof (err) == 'undefined') {
console.info('case resume success');
- sleep(RECORDER_TIME);
+ mediaTestBase.msleep(RECORDER_TIME);
expect(videoRecorder.state).assertEqual('playing');
toNextStep(videoRecorder, steps, done);
} else {
@@ -392,7 +304,7 @@ describe('VideoRecorderFuncCallbackTest', function () {
console.info('case videoOutput release success');
});
videoOutput = undefined;
- await stopCaptureSession();
+ await videoRecorderBase.stopCaptureSession(captureSession);
if (typeof (err) == 'undefined') {
expect(videoRecorder.state).assertEqual('idle');
console.info('case release success');
@@ -403,6 +315,16 @@ describe('VideoRecorderFuncCallbackTest', function () {
});
});
+ eventEmitter.on(CHECK_EVENT, async (videoRecorder, steps, done) => {
+ steps.shift();
+ let trackArray = steps[0];
+ let recorderTime = steps[1];
+ steps.shift();
+ steps.shift();
+ await videoRecorderBase.checkVideos(fdPath, recorderTime, trackArray, playerSurfaceId);
+ toNextStep(videoRecorder, steps, done);
+ });
+
/* *
* @tc.number : SUB_MEDIA_VIDEO_RECORDER_FUNCTION_CALLBACK_0100
* @tc.name : 01.start->release (callback)
@@ -412,10 +334,13 @@ describe('VideoRecorderFuncCallbackTest', function () {
* @tc.level : Level0
*/
it('SUB_MEDIA_VIDEO_RECORDER_FUNCTION_CALLBACK_0100', 0, async function (done) {
- await getFd('19.mp4');
+ fdObject = await mediaTestBase.getFd('recorder_callback_01.mp4');
+ fdPath = "fd://" + fdObject.fdNumber.toString();
videoConfig.url = fdPath;
+ let trackArray = videoRecorderBase.getTrackArray(AUDIO_VIDEO_TYPE, configFile);
let videoRecorder = null;
- let mySteps = new Array(CREATE_EVENT, PREPARE_EVENT, GETSURFACE_EVENT, START_EVENT, RELEASE_EVENT, END_EVENT);
+ let mySteps = new Array(CREATE_EVENT, PREPARE_EVENT, GETSURFACE_EVENT, START_EVENT, RELEASE_EVENT, CHECK_EVENT,
+ trackArray, RECORDER_TIME, END_EVENT);
eventEmitter.emit(mySteps[0], videoRecorder, mySteps, done);
})
@@ -428,11 +353,14 @@ describe('VideoRecorderFuncCallbackTest', function () {
* @tc.level : Level0
*/
it('SUB_MEDIA_VIDEO_RECORDER_FUNCTION_CALLBACK_0200', 0, async function (done) {
- await getFd('20.mp4');
+ fdObject = await mediaTestBase.getFd('recorder_callback_02.mp4');
+ fdPath = "fd://" + fdObject.fdNumber.toString();
videoConfig.url = fdPath;
+ let trackArray = videoRecorderBase.getTrackArray(AUDIO_VIDEO_TYPE, configFile);
let videoRecorder = null;
let mySteps = new Array(CREATE_EVENT, PREPARE_EVENT, GETSURFACE_EVENT, START_EVENT,
- PAUSE_EVENT, RELEASE_EVENT, END_EVENT);
+ PAUSE_EVENT, RELEASE_EVENT, CHECK_EVENT,
+ trackArray, RECORDER_TIME, END_EVENT);
eventEmitter.emit(mySteps[0], videoRecorder, mySteps, done);
})
@@ -445,11 +373,14 @@ describe('VideoRecorderFuncCallbackTest', function () {
* @tc.level : Level0
*/
it('SUB_MEDIA_VIDEO_RECORDER_FUNCTION_CALLBACK_0300', 0, async function (done) {
- await getFd('21.mp4');
+ fdObject = await mediaTestBase.getFd('recorder_callback_03.mp4');
+ fdPath = "fd://" + fdObject.fdNumber.toString();
videoConfig.url = fdPath;
+ let trackArray = videoRecorderBase.getTrackArray(AUDIO_VIDEO_TYPE, configFile);
let videoRecorder = null;
let mySteps = new Array(CREATE_EVENT, PREPARE_EVENT, GETSURFACE_EVENT, START_EVENT,
- PAUSE_EVENT, RESUME_EVENT, RELEASE_EVENT, END_EVENT);
+ PAUSE_EVENT, RESUME_EVENT, RELEASE_EVENT, CHECK_EVENT,
+ trackArray, RECORDER_TIME * 2, END_EVENT);
eventEmitter.emit(mySteps[0], videoRecorder, mySteps, done);
})
@@ -462,11 +393,13 @@ describe('VideoRecorderFuncCallbackTest', function () {
* @tc.level : Level0
*/
it('SUB_MEDIA_VIDEO_RECORDER_FUNCTION_CALLBACK_0400', 0, async function (done) {
- await getFd('22.mp4');
+ fdObject = await mediaTestBase.getFd('recorder_callback_04.mp4');
+ fdPath = "fd://" + fdObject.fdNumber.toString();
videoConfig.url = fdPath;
+ let trackArray = videoRecorderBase.getTrackArray(AUDIO_VIDEO_TYPE, configFile);
let videoRecorder = null;
let mySteps = new Array(CREATE_EVENT, PREPARE_EVENT, GETSURFACE_EVENT, START_EVENT,
- STOP_EVENT, RELEASE_EVENT, END_EVENT);
+ STOP_EVENT, RELEASE_EVENT, CHECK_EVENT, trackArray, RECORDER_TIME, END_EVENT);
eventEmitter.emit(mySteps[0], videoRecorder, mySteps, done);
})
@@ -479,11 +412,13 @@ describe('VideoRecorderFuncCallbackTest', function () {
* @tc.level : Level0
*/
it('SUB_MEDIA_VIDEO_RECORDER_FUNCTION_CALLBACK_0500', 0, async function (done) {
- await getFd('23.mp4');
+ fdObject = await mediaTestBase.getFd('recorder_callback_05.mp4');
+ fdPath = "fd://" + fdObject.fdNumber.toString();
videoConfig.url = fdPath;
+ let trackArray = videoRecorderBase.getTrackArray(AUDIO_VIDEO_TYPE, configFile);
let videoRecorder = null;
let mySteps = new Array(CREATE_EVENT, PREPARE_EVENT, GETSURFACE_EVENT, START_EVENT,
- RESET_EVENT, RELEASE_EVENT, END_EVENT);
+ RESET_EVENT, RELEASE_EVENT, CHECK_EVENT, trackArray, RECORDER_TIME, END_EVENT);
eventEmitter.emit(mySteps[0], videoRecorder, mySteps, done);
})
@@ -496,11 +431,13 @@ describe('VideoRecorderFuncCallbackTest', function () {
* @tc.level : Level0
*/
it('SUB_MEDIA_VIDEO_RECORDER_FUNCTION_CALLBACK_0600', 0, async function (done) {
- await getFd('24.mp4');
+ fdObject = await mediaTestBase.getFd('recorder_callback_06.mp4');
+ fdPath = "fd://" + fdObject.fdNumber.toString();
videoConfig.url = fdPath;
+ let trackArray = videoRecorderBase.getTrackArray(AUDIO_VIDEO_TYPE, configFile);
let videoRecorder = null;
let mySteps = new Array(CREATE_EVENT, PREPARE_EVENT, GETSURFACE_EVENT, START_EVENT, PAUSE_EVENT,
- STOP_EVENT, RELEASE_EVENT, END_EVENT);
+ STOP_EVENT, RELEASE_EVENT, CHECK_EVENT, trackArray, RECORDER_TIME, END_EVENT);
eventEmitter.emit(mySteps[0], videoRecorder, mySteps, done);
})
@@ -513,11 +450,13 @@ describe('VideoRecorderFuncCallbackTest', function () {
* @tc.level : Level0
*/
it('SUB_MEDIA_VIDEO_RECORDER_FUNCTION_CALLBACK_0700', 0, async function (done) {
- await getFd('25.mp4');
+ fdObject = await mediaTestBase.getFd('recorder_callback_07.mp4');
+ fdPath = "fd://" + fdObject.fdNumber.toString();
videoConfig.url = fdPath;
+ let trackArray = videoRecorderBase.getTrackArray(AUDIO_VIDEO_TYPE, configFile);
let videoRecorder = null;
let mySteps = new Array(CREATE_EVENT, PREPARE_EVENT, GETSURFACE_EVENT, START_EVENT, PAUSE_EVENT,
- RESET_EVENT, RELEASE_EVENT, END_EVENT);
+ RESET_EVENT, RELEASE_EVENT, CHECK_EVENT, trackArray, RECORDER_TIME, END_EVENT);
eventEmitter.emit(mySteps[0], videoRecorder, mySteps, done);
})
@@ -530,11 +469,13 @@ describe('VideoRecorderFuncCallbackTest', function () {
* @tc.level : Level0
*/
it('SUB_MEDIA_VIDEO_RECORDER_FUNCTION_CALLBACK_0800', 0, async function (done) {
- await getFd('26.mp4');
+ fdObject = await mediaTestBase.getFd('recorder_callback_08.mp4');
+ fdPath = "fd://" + fdObject.fdNumber.toString();
videoConfig.url = fdPath;
+ let trackArray = videoRecorderBase.getTrackArray(AUDIO_VIDEO_TYPE, configFile);
let videoRecorder = null;
let mySteps = new Array(CREATE_EVENT, PREPARE_EVENT, GETSURFACE_EVENT, START_EVENT, PAUSE_EVENT,
- RESUME_EVENT, STOP_EVENT, RELEASE_EVENT, END_EVENT);
+ RESUME_EVENT, STOP_EVENT, RELEASE_EVENT, CHECK_EVENT, trackArray, RECORDER_TIME * 2, END_EVENT);
eventEmitter.emit(mySteps[0], videoRecorder, mySteps, done);
})
@@ -547,11 +488,13 @@ describe('VideoRecorderFuncCallbackTest', function () {
* @tc.level : Level0
*/
it('SUB_MEDIA_VIDEO_RECORDER_FUNCTION_CALLBACK_0900', 0, async function (done) {
- await getFd('27.mp4');
+ fdObject = await mediaTestBase.getFd('recorder_callback_09.mp4');
+ fdPath = "fd://" + fdObject.fdNumber.toString();
videoConfig.url = fdPath;
+ let trackArray = videoRecorderBase.getTrackArray(AUDIO_VIDEO_TYPE, configFile);
let videoRecorder = null;
let mySteps = new Array(CREATE_EVENT, PREPARE_EVENT, GETSURFACE_EVENT, START_EVENT, PAUSE_EVENT,
- RESUME_EVENT, RESET_EVENT, RELEASE_EVENT, END_EVENT);
+ RESUME_EVENT, RESET_EVENT, RELEASE_EVENT, CHECK_EVENT, trackArray, RECORDER_TIME * 2, END_EVENT);
eventEmitter.emit(mySteps[0], videoRecorder, mySteps, done);
})
@@ -568,11 +511,13 @@ describe('VideoRecorderFuncCallbackTest', function () {
configFile.audioBitrate = 8000;
configFile.audioSampleRate = 8000;
configFile.videoBitrate = 8000;
- await getFd('28.mp4');
+ fdObject = await mediaTestBase.getFd('recorder_callback_10.mp4');
+ fdPath = "fd://" + fdObject.fdNumber.toString();
videoConfig.url = fdPath;
+ let trackArray = videoRecorderBase.getTrackArray(AUDIO_VIDEO_TYPE, configFile);
let videoRecorder = null;
let mySteps = new Array(CREATE_EVENT, PREPARE_EVENT, GETSURFACE_EVENT, START_EVENT,
- STOP_EVENT, RELEASE_EVENT, END_EVENT);
+ STOP_EVENT, RELEASE_EVENT, CHECK_EVENT, trackArray, RECORDER_TIME, END_EVENT);
eventEmitter.emit(mySteps[0], videoRecorder, mySteps, done);
})
@@ -589,11 +534,13 @@ describe('VideoRecorderFuncCallbackTest', function () {
configFile.audioBitrate = 16000;
configFile.audioSampleRate = 32000;
configFile.videoBitrate = 16000;
- await getFd('29.mp4');
+ fdObject = await mediaTestBase.getFd('recorder_callback_11.mp4');
+ fdPath = "fd://" + fdObject.fdNumber.toString();
videoConfig.url = fdPath;
+ let trackArray = videoRecorderBase.getTrackArray(AUDIO_VIDEO_TYPE, configFile);
let videoRecorder = null;
let mySteps = new Array(CREATE_EVENT, PREPARE_EVENT, GETSURFACE_EVENT, START_EVENT,
- STOP_EVENT, RELEASE_EVENT, END_EVENT);
+ STOP_EVENT, RELEASE_EVENT, CHECK_EVENT, trackArray, RECORDER_TIME, END_EVENT);
eventEmitter.emit(mySteps[0], videoRecorder, mySteps, done);
})
@@ -610,11 +557,13 @@ describe('VideoRecorderFuncCallbackTest', function () {
configFile.audioBitrate = 32000;
configFile.audioSampleRate = 44100;
configFile.videoBitrate = 32000;
- await getFd('30.mp4');
+ fdObject = await mediaTestBase.getFd('recorder_callback_12.mp4');
+ fdPath = "fd://" + fdObject.fdNumber.toString();
videoConfig.url = fdPath;
+ let trackArray = videoRecorderBase.getTrackArray(AUDIO_VIDEO_TYPE, configFile);
let videoRecorder = null;
let mySteps = new Array(CREATE_EVENT, PREPARE_EVENT, GETSURFACE_EVENT, START_EVENT,
- STOP_EVENT, RELEASE_EVENT, END_EVENT);
+ STOP_EVENT, RELEASE_EVENT, CHECK_EVENT, trackArray, RECORDER_TIME, END_EVENT);
eventEmitter.emit(mySteps[0], videoRecorder, mySteps, done);
})
@@ -631,11 +580,13 @@ describe('VideoRecorderFuncCallbackTest', function () {
configFile.audioBitrate = 112000;
configFile.audioSampleRate = 96000;
configFile.videoBitrate = 112000;
- await getFd('31.mp4');
+ fdObject = await mediaTestBase.getFd('recorder_callback_13.mp4');
+ fdPath = "fd://" + fdObject.fdNumber.toString();
videoConfig.url = fdPath;
+ let trackArray = videoRecorderBase.getTrackArray(AUDIO_VIDEO_TYPE, configFile);
let videoRecorder = null;
let mySteps = new Array(CREATE_EVENT, PREPARE_EVENT, GETSURFACE_EVENT, START_EVENT,
- STOP_EVENT, RELEASE_EVENT, END_EVENT);
+ STOP_EVENT, RELEASE_EVENT, CHECK_EVENT, trackArray, RECORDER_TIME, END_EVENT);
eventEmitter.emit(mySteps[0], videoRecorder, mySteps, done);
})
@@ -648,11 +599,13 @@ describe('VideoRecorderFuncCallbackTest', function () {
* @tc.level : Level0
*/
it('SUB_MEDIA_VIDEO_RECORDER_FUNCTION_CALLBACK_1400', 0, async function (done) {
- await getFd('32.mp4');
+ fdObject = await mediaTestBase.getFd('recorder_callback_14.mp4');
+ fdPath = "fd://" + fdObject.fdNumber.toString();
onlyVideoConfig.url = fdPath;
+ let trackArray = videoRecorderBase.getTrackArray(ONLYVIDEO_TYPE, onlyVideoProfile);
let videoRecorder = null;
let mySteps = new Array(CREATE_EVENT, PREPARE_OLNYVIDEO_EVENT, GETSURFACE_EVENT,
- START_EVENT, RELEASE_EVENT, END_EVENT);
+ START_EVENT, RELEASE_EVENT, CHECK_EVENT, trackArray, RECORDER_TIME, END_EVENT);
eventEmitter.emit(mySteps[0], videoRecorder, mySteps, done);
})
@@ -665,11 +618,13 @@ describe('VideoRecorderFuncCallbackTest', function () {
* @tc.level : Level0
*/
it('SUB_MEDIA_VIDEO_RECORDER_FUNCTION_CALLBACK_1500', 0, async function (done) {
- await getFd('33.mp4');
+ fdObject = await mediaTestBase.getFd('recorder_callback_15.mp4');
+ fdPath = "fd://" + fdObject.fdNumber.toString();
onlyVideoConfig.url = fdPath;
+ let trackArray = videoRecorderBase.getTrackArray(ONLYVIDEO_TYPE, onlyVideoProfile);
let videoRecorder = null;
let mySteps = new Array(CREATE_EVENT, PREPARE_OLNYVIDEO_EVENT, GETSURFACE_EVENT, START_EVENT,
- PAUSE_EVENT, RELEASE_EVENT, END_EVENT);
+ PAUSE_EVENT, RELEASE_EVENT, CHECK_EVENT, trackArray, RECORDER_TIME, END_EVENT);
eventEmitter.emit(mySteps[0], videoRecorder, mySteps, done);
})
@@ -682,11 +637,13 @@ describe('VideoRecorderFuncCallbackTest', function () {
* @tc.level : Level0
*/
it('SUB_MEDIA_VIDEO_RECORDER_FUNCTION_CALLBACK_1600', 0, async function (done) {
- await getFd('34.mp4');
+ fdObject = await mediaTestBase.getFd('recorder_callback_16.mp4');
+ fdPath = "fd://" + fdObject.fdNumber.toString();
onlyVideoConfig.url = fdPath;
+ let trackArray = videoRecorderBase.getTrackArray(ONLYVIDEO_TYPE, onlyVideoProfile);
let videoRecorder = null;
let mySteps = new Array(CREATE_EVENT, PREPARE_OLNYVIDEO_EVENT, GETSURFACE_EVENT, START_EVENT,
- PAUSE_EVENT, RESUME_EVENT, RELEASE_EVENT, END_EVENT);
+ PAUSE_EVENT, RESUME_EVENT, RELEASE_EVENT, CHECK_EVENT, trackArray, RECORDER_TIME * 2, END_EVENT);
eventEmitter.emit(mySteps[0], videoRecorder, mySteps, done);
})
@@ -699,11 +656,13 @@ describe('VideoRecorderFuncCallbackTest', function () {
* @tc.level : Level0
*/
it('SUB_MEDIA_VIDEO_RECORDER_FUNCTION_CALLBACK_1700', 0, async function (done) {
- await getFd('35.mp4');
+ fdObject = await mediaTestBase.getFd('recorder_callback_17.mp4');
+ fdPath = "fd://" + fdObject.fdNumber.toString();
onlyVideoConfig.url = fdPath;
+ let trackArray = videoRecorderBase.getTrackArray(ONLYVIDEO_TYPE, onlyVideoProfile);
let videoRecorder = null;
let mySteps = new Array(CREATE_EVENT, PREPARE_OLNYVIDEO_EVENT, GETSURFACE_EVENT, START_EVENT,
- STOP_EVENT, RELEASE_EVENT, END_EVENT);
+ STOP_EVENT, RELEASE_EVENT, CHECK_EVENT, trackArray, RECORDER_TIME, END_EVENT);
eventEmitter.emit(mySteps[0], videoRecorder, mySteps, done);
})
@@ -716,11 +675,13 @@ describe('VideoRecorderFuncCallbackTest', function () {
* @tc.level : Level0
*/
it('SUB_MEDIA_VIDEO_RECORDER_FUNCTION_CALLBACK_1800', 0, async function (done) {
- await getFd('36.mp4');
+ fdObject = await mediaTestBase.getFd('recorder_callback_18.mp4');
+ fdPath = "fd://" + fdObject.fdNumber.toString();
onlyVideoConfig.url = fdPath;
+ let trackArray = videoRecorderBase.getTrackArray(ONLYVIDEO_TYPE, onlyVideoProfile);
let videoRecorder = null;
let mySteps = new Array(CREATE_EVENT, PREPARE_OLNYVIDEO_EVENT, GETSURFACE_EVENT, START_EVENT,
- RESET_EVENT, RELEASE_EVENT, END_EVENT);
+ RESET_EVENT, RELEASE_EVENT, CHECK_EVENT, trackArray, RECORDER_TIME, END_EVENT);
eventEmitter.emit(mySteps[0], videoRecorder, mySteps, done);
})
@@ -733,12 +694,15 @@ describe('VideoRecorderFuncCallbackTest', function () {
* @tc.level : Level1
*/
it('SUB_MEDIA_VIDEO_RECORDER_FUNCTION_CALLBACK_1900', 0, async function (done) {
- await getFd('37.mp4');
+ fdObject = await mediaTestBase.getFd('recorder_callback_19.mp4');
+ fdPath = "fd://" + fdObject.fdNumber.toString();
videoConfig.url = fdPath;
+ configFile.audioSampleRate = 48000;
videoConfig.rotation = 90;
+ let trackArray = videoRecorderBase.getTrackArray(AUDIO_VIDEO_TYPE, configFile);
let videoRecorder = null;
let mySteps = new Array(CREATE_EVENT, PREPARE_EVENT, GETSURFACE_EVENT,
- START_EVENT, RELEASE_EVENT, END_EVENT);
+ START_EVENT, RELEASE_EVENT, CHECK_EVENT, trackArray, RECORDER_TIME, END_EVENT);
eventEmitter.emit(mySteps[0], videoRecorder, mySteps, done);
})
@@ -751,11 +715,14 @@ describe('VideoRecorderFuncCallbackTest', function () {
* @tc.level : Level1
*/
it('SUB_MEDIA_VIDEO_RECORDER_FUNCTION_CALLBACK_2000', 0, async function (done) {
- await getFd('38.mp4');
+ fdObject = await mediaTestBase.getFd('recorder_callback_20.mp4');
+ fdPath = "fd://" + fdObject.fdNumber.toString();
videoConfig.url = fdPath;
videoConfig.rotation = 180;
+ let trackArray = videoRecorderBase.getTrackArray(AUDIO_VIDEO_TYPE, configFile);
let videoRecorder = null;
- let mySteps = new Array(CREATE_EVENT, PREPARE_EVENT, GETSURFACE_EVENT, START_EVENT, RELEASE_EVENT, END_EVENT);
+ let mySteps = new Array(CREATE_EVENT, PREPARE_EVENT, GETSURFACE_EVENT, START_EVENT, RELEASE_EVENT,
+ CHECK_EVENT, trackArray, RECORDER_TIME, END_EVENT);
eventEmitter.emit(mySteps[0], videoRecorder, mySteps, done);
})
@@ -768,11 +735,14 @@ describe('VideoRecorderFuncCallbackTest', function () {
* @tc.level : Level1
*/
it('SUB_MEDIA_VIDEO_RECORDER_FUNCTION_CALLBACK_2100', 0, async function (done) {
- await getFd('39.mp4');
+ fdObject = await mediaTestBase.getFd('recorder_callback_21.mp4');
+ fdPath = "fd://" + fdObject.fdNumber.toString();
videoConfig.url = fdPath;
videoConfig.rotation = 270;
+ let trackArray = videoRecorderBase.getTrackArray(AUDIO_VIDEO_TYPE, configFile);
let videoRecorder = null;
- let mySteps = new Array(CREATE_EVENT, PREPARE_EVENT, GETSURFACE_EVENT, START_EVENT, RELEASE_EVENT, END_EVENT);
+ let mySteps = new Array(CREATE_EVENT, PREPARE_EVENT, GETSURFACE_EVENT, START_EVENT, RELEASE_EVENT,
+ CHECK_EVENT, trackArray, RECORDER_TIME, END_EVENT);
eventEmitter.emit(mySteps[0], videoRecorder, mySteps, done);
})
@@ -785,11 +755,14 @@ describe('VideoRecorderFuncCallbackTest', function () {
* @tc.level : Level1
*/
it('SUB_MEDIA_VIDEO_RECORDER_FUNCTION_CALLBACK_2200', 0, async function (done) {
- await getFd('46.mp4');
+ fdObject = await mediaTestBase.getFd('recorder_callback_22.mp4');
+ fdPath = "fd://" + fdObject.fdNumber.toString();
videoConfig.url = fdPath;
videoConfig.videoFrameRate = 20;
+ let trackArray = videoRecorderBase.getTrackArray(AUDIO_VIDEO_TYPE, configFile);
let videoRecorder = null;
- let mySteps = new Array(CREATE_EVENT, PREPARE_EVENT, GETSURFACE_EVENT, START_EVENT, RELEASE_EVENT, END_EVENT);
+ let mySteps = new Array(CREATE_EVENT, PREPARE_EVENT, GETSURFACE_EVENT, START_EVENT, RELEASE_EVENT,
+ CHECK_EVENT, trackArray, RECORDER_TIME, END_EVENT);
eventEmitter.emit(mySteps[0], videoRecorder, mySteps, done);
})
@@ -802,11 +775,14 @@ describe('VideoRecorderFuncCallbackTest', function () {
* @tc.level : Level1
*/
it('SUB_MEDIA_VIDEO_RECORDER_FUNCTION_CALLBACK_2300', 0, async function (done) {
- await getFd('47.mp4');
+ fdObject = await mediaTestBase.getFd('recorder_callback_23.mp4');
+ fdPath = "fd://" + fdObject.fdNumber.toString();
videoConfig.url = fdPath;
videoConfig.videoFrameRate = 30;
+ let trackArray = videoRecorderBase.getTrackArray(AUDIO_VIDEO_TYPE, configFile);
let videoRecorder = null;
- let mySteps = new Array(CREATE_EVENT, PREPARE_EVENT, GETSURFACE_EVENT, START_EVENT, RELEASE_EVENT, END_EVENT);
+ let mySteps = new Array(CREATE_EVENT, PREPARE_EVENT, GETSURFACE_EVENT, START_EVENT, RELEASE_EVENT,
+ CHECK_EVENT, trackArray, RECORDER_TIME, END_EVENT);
eventEmitter.emit(mySteps[0], videoRecorder, mySteps, done);
})
@@ -819,11 +795,14 @@ describe('VideoRecorderFuncCallbackTest', function () {
* @tc.level : Level1
*/
it('SUB_MEDIA_VIDEO_RECORDER_FUNCTION_CALLBACK_2400', 0, async function (done) {
- await getFd('48.mp4');
+ fdObject = await mediaTestBase.getFd('recorder_callback_24.mp4');
+ fdPath = "fd://" + fdObject.fdNumber.toString();
videoConfig.url = fdPath;
videoConfig.videoFrameRate = 60;
+ let trackArray = videoRecorderBase.getTrackArray(AUDIO_VIDEO_TYPE, configFile);
let videoRecorder = null;
- let mySteps = new Array(CREATE_EVENT, PREPARE_EVENT, GETSURFACE_EVENT, START_EVENT, RELEASE_EVENT, END_EVENT);
+ let mySteps = new Array(CREATE_EVENT, PREPARE_EVENT, GETSURFACE_EVENT, START_EVENT, RELEASE_EVENT,
+ CHECK_EVENT, trackArray, RECORDER_TIME, END_EVENT);
eventEmitter.emit(mySteps[0], videoRecorder, mySteps, done);
})
})
diff --git a/multimedia/media/media_js_standard/videoRecorder/src/main/js/test/VideoRecorderFuncPromiseTest.test.js b/multimedia/media/media_js_standard/videoRecorder/src/main/js/test/VideoRecorderFuncPromiseTest.test.js
index 235ff0c82a6215a779e934ea7da126c91ca2f777..2a1509d8e0cfb4a6ca70b2b376848f87d8da8775 100644
--- a/multimedia/media/media_js_standard/videoRecorder/src/main/js/test/VideoRecorderFuncPromiseTest.test.js
+++ b/multimedia/media/media_js_standard/videoRecorder/src/main/js/test/VideoRecorderFuncPromiseTest.test.js
@@ -15,27 +15,35 @@
import media from '@ohos.multimedia.media'
import camera from '@ohos.multimedia.camera'
-import mediaLibrary from '@ohos.multimedia.mediaLibrary'
+import * as mediaTestBase from '../../../../../MediaTestBase.js';
+import * as videoRecorderBase from '../../../../../VideoRecorderTestBase.js';
import {describe, beforeAll, beforeEach, afterEach, afterAll, it, expect} from 'deccjsunit/index'
describe('VideoRecorderFuncPromiseTest', function () {
const RECORDER_TIME = 3000;
const PAUSE_TIME = 1000;
+ const DELTA_TIME = 1000;
+ const ONLYVIDEO_TYPE = 'only_video';
+ const AUDIO_VIDEO_TYPE = 'audio_video';
let cameraManager;
let cameras;
let captureSession;
let fdPath;
- let fileAsset;
- let fdNumber;
+ let fdObject;
+ let cameraID = 0;
+ let playerSurfaceId = '';
+ let pageId = 0;
+ const pagePath1 = 'pages/surfaceTest/surfaceTest';
+ const pagePath2 = 'pages/surfaceTest2/surfaceTest2';
let configFile = {
audioBitrate : 48000,
audioChannels : 2,
- audioCodec : 'audio/mp4a-latm',
+ audioCodec : media.CodecMimeType.AUDIO_AAC,
audioSampleRate : 48000,
durationTime : 1000,
- fileFormat : 'mp4',
+ fileFormat : media.ContainerFormatType.CFT_MPEG_4,
videoBitrate : 48000,
- videoCodec : 'video/mp4v-es',
+ videoCodec : media.CodecMimeType.VIDEO_MPEG4,
videoFrameWidth : 640,
videoFrameHeight : 480,
videoFrameRate : 10
@@ -45,7 +53,7 @@ describe('VideoRecorderFuncPromiseTest', function () {
audioSourceType : 1,
videoSourceType : 0,
profile : configFile,
- url : 'file:///data/media/01.mp4',
+ url : 'fd://',
rotation : 0,
location : { latitude : 30, longitude : 130 },
maxSize : 100,
@@ -54,48 +62,25 @@ describe('VideoRecorderFuncPromiseTest', function () {
let onlyVideoProfile = {
durationTime : 1000,
- fileFormat : 'mp4',
+ fileFormat : media.ContainerFormatType.CFT_MPEG_4,
videoBitrate : 48000,
- videoCodec : 'video/mp4v-es',
+ videoCodec : media.CodecMimeType.VIDEO_MPEG4,
videoFrameWidth : 640,
videoFrameHeight : 480,
videoFrameRate : 10
}
let onlyVideoConfig = {
- videoSourceType : 0,
+ videoSourceType : media.VideoSourceType.VIDEO_SOURCE_TYPE_SURFACE_YUV,
profile : onlyVideoProfile,
- url : 'file:///data/media/01.mp4',
+ url : 'fd://',
rotation : 0,
location : { latitude : 30, longitude : 130 },
maxSize : 100,
maxDuration : 500
}
- function sleep(time) {
- for(let t = Date.now();Date.now() - t <= time;);
- }
-
beforeAll(async function () {
- await initCamera();
- console.info('beforeAll case');
- })
-
- beforeEach(function () {
- sleep(5000);
- console.info('beforeEach case');
- })
-
- afterEach(async function () {
- await closeFd();
- console.info('afterEach case');
- })
-
- afterAll(function () {
- console.info('afterAll case');
- })
-
- async function initCamera() {
cameraManager = await camera.getCameraManager(null);
if (cameraManager != null) {
console.info('[camera] case getCameraManager success');
@@ -109,93 +94,113 @@ describe('VideoRecorderFuncPromiseTest', function () {
} else {
console.info('[camera] case getCameras failed');
}
- }
+ console.info('beforeAll case');
+ })
- async function initCaptureSession(videoOutPut) {
- let cameraInput = await cameraManager.createCameraInput(cameras[0].cameraId);
- if (cameraInput != null) {
- console.info('[camera] case createCameraInput success');
- } else {
- console.info('[camera] case createCameraInput failed');
- return;
- }
- captureSession = await camera.createCaptureSession(null);
- await captureSession.beginConfig();
- await captureSession.addInput(cameraInput);
- await captureSession.addOutput(videoOutPut);
- await captureSession.commitConfig();
- }
+ beforeEach(async function () {
+ await mediaTestBase.toNewPage(pagePath1, pagePath2, pageId);
+ pageId = (pageId + 1) % 2;
+ await mediaTestBase.msleepAsync(1000).then(
+ () => {}, mediaTestBase.failureCallback).catch(mediaTestBase.catchCallback);
+ playerSurfaceId = globalThis.value;
+ cameraID = 0;
+ console.info('beforeEach case');
+ })
- async function stopCaptureSession() {
- await captureSession.release();
- }
+ afterEach(async function () {
+ await mediaTestBase.clearRouter();
+ console.info('afterEach case');
+ })
+
+ afterAll(function () {
+ console.info('afterAll case');
+ })
async function startVideoOutput(videoOutPut) {
if (videoOutPut == null) {
console.info('[camera] case videoOutPut is null');
return;
}
- await initCaptureSession(videoOutPut);
-
await videoOutPut.start().then(() => {
console.info('[camera] case videoOutput start success');
});
}
- async function stopVideoOutput(videoOutPut) {
- await videoOutPut.release().then(() => {
- console.info('[camera] case videoOutput release success');
- });
- videoOutPut = undefined;
- await stopCaptureSession();
- }
-
- async function getFd(pathName) {
- let displayName = pathName;
- const mediaTest = mediaLibrary.getMediaLibrary();
- let fileKeyObj = mediaLibrary.FileKey;
- let mediaType = mediaLibrary.MediaType.VIDEO;
- let publicPath = await mediaTest.getPublicDirectory(mediaLibrary.DirectoryType.DIR_VIDEO);
- let dataUri = await mediaTest.createAsset(mediaType, displayName, publicPath);
- if (dataUri != undefined) {
- let args = dataUri.id.toString();
- let fetchOp = {
- selections : fileKeyObj.ID + "=?",
- selectionArgs : [args],
- }
- let fetchFileResult = await mediaTest.getFileAssets(fetchOp);
- fileAsset = await fetchFileResult.getAllObject();
- fdNumber = await fileAsset[0].open('Rw');
- fdPath = "fd://" + fdNumber.toString();
- }
- }
-
- async function closeFd() {
- if (fileAsset != null) {
- await fileAsset[0].close(fdNumber).then(() => {
- console.info('[mediaLibrary] case close fd success');
- }).catch((err) => {
- console.info('[mediaLibrary] case close fd failed');
+ /* *
+ * @tc.number : SUB_MEDIA_VIDEO_RECORDER_FUNCTION_PROMISE_ALL_CAMERAS
+ * @tc.name : 01.all cameras recordering (promise)
+ * @tc.desc : Video recordr control test
+ * @tc.size : MediumTest
+ * @tc.type : Function
+ * @tc.level : Level0
+ */
+ it('SUB_MEDIA_VIDEO_RECORDER_FUNCTION_PROMISE_ALL_CAMERAS', 0, async function (done) {
+ for (let i = 0; i < 2; i++) {
+ cameraID = i;
+ console.info('[camera] case cameraID is :' + cameraID);
+ let videoRecorder = undefined;
+ let surfaceID = '';
+ let videoOutput;
+ let trackArray = videoRecorderBase.getTrackArray(AUDIO_VIDEO_TYPE, configFile);
+ fdObject = await mediaTestBase.getFd('recorder_promise_cameraID_' + cameraID + '.mp4');
+ fdPath = "fd://" + fdObject.fdNumber.toString();
+ videoConfig.url = fdPath;
+ 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!!');
+ expect().assertFail();
+ }
+ }, mediaTestBase.failureCallback).catch(mediaTestBase.catchCallback);
+
+ await videoRecorder.prepare(videoConfig).then(() => {
+ console.info('case prepare called');
+ expect(videoRecorder.state).assertEqual('prepared');
+ }, mediaTestBase.failureCallback).catch(mediaTestBase.catchCallback);
+
+ await videoRecorder.getInputSurface().then((outPutSurface) => {
+ console.info('case getInputSurface called');
+ surfaceID = outPutSurface;
+ }, mediaTestBase.failureCallback).catch(mediaTestBase.catchCallback);
+
+ videoOutput = await camera.createVideoOutput(surfaceID);
+ captureSession = await videoRecorderBase.initCaptureSession(videoOutput, cameraManager, cameras, cameraID);
+ await startVideoOutput(videoOutput);
+
+ await videoRecorder.start().then(() => {
+ expect(videoRecorder.state).assertEqual('playing');
+ console.info('case start called');
+ mediaTestBase.msleep(RECORDER_TIME);
+ }, mediaTestBase.failureCallback).catch(mediaTestBase.catchCallback);
+
+ await videoRecorder.stop().then(() => {
+ expect(videoRecorder.state).assertEqual('stopped');
+ console.info('case stop called');
+ }, mediaTestBase.failureCallback).catch(mediaTestBase.catchCallback);
+
+ await videoRecorder.release().then(() => {
+ expect(videoRecorder.state).assertEqual('idle');
+ console.info('case release ');
+ }, mediaTestBase.failureCallback).catch(mediaTestBase.catchCallback);
+ await videoOutput.stop();
+ await videoOutput.release().then(() => {
+ console.info('[camera] case videoOutput release success');
});
- } else {
- console.info('[mediaLibrary] case fileAsset is null');
+ videoOutPut = undefined;
+ await videoRecorderBase.stopCaptureSession(captureSession);
+ await videoRecorderBase.checkVideos(fdPath, RECORDER_TIME, trackArray, playerSurfaceId);
+ await mediaTestBase.closeFd(fdObject.fileAsset, fdObject.fdNumber);
}
- }
-
- function failureCallback(error) {
- expect().assertFail();
- console.info(`case error called,errMessage is ${error.message}`);
- }
-
- function catchCallback(error) {
- expect().assertFail();
- console.info(`case error called,errMessage is ${error.message}`);
- }
+ done();
+ })
/* *
* @tc.number : SUB_MEDIA_VIDEO_RECORDER_FUNCTION_PROMISE_0100
- * @tc.name : 01.start->release (promise)
- * @tc.desc : Audio recordr control test
+ * @tc.name : 02.start->release (promise)
+ * @tc.desc : Video recordr control test
* @tc.size : MediumTest
* @tc.type : Function
* @tc.level : Level0
@@ -204,7 +209,9 @@ describe('VideoRecorderFuncPromiseTest', function () {
let videoRecorder = undefined;
let surfaceID = '';
let videoOutput;
- await getFd('01.mp4');
+ let trackArray = videoRecorderBase.getTrackArray(AUDIO_VIDEO_TYPE, configFile);
+ fdObject = await mediaTestBase.getFd('recorder_promise_01.mp4');
+ fdPath = "fd://" + fdObject.fdNumber.toString();
videoConfig.url = fdPath;
await media.createVideoRecorder().then((recorder) => {
console.info('case createVideoRecorder called');
@@ -213,39 +220,47 @@ describe('VideoRecorderFuncPromiseTest', function () {
expect(videoRecorder.state).assertEqual('idle');
} else {
console.info('case recordr is undefined!!');
- expect().assertFail();
}
- }, failureCallback).catch(catchCallback);
+ }, mediaTestBase.failureCallback).catch(mediaTestBase.catchCallback);
await videoRecorder.prepare(videoConfig).then(() => {
+ console.info('case recordr prepare called');
expect(videoRecorder.state).assertEqual('prepared');
- }, failureCallback).catch(catchCallback);
+ }, mediaTestBase.failureCallback).catch(mediaTestBase.catchCallback);
await videoRecorder.getInputSurface().then((outPutSurface) => {
+ console.info('case getInputSurface called');
+ expect(videoRecorder.state).assertEqual('prepared');
surfaceID = outPutSurface;
- }, failureCallback).catch(catchCallback);
+ }, mediaTestBase.failureCallback).catch(mediaTestBase.catchCallback);
videoOutput = await camera.createVideoOutput(surfaceID);
+ captureSession = await videoRecorderBase.initCaptureSession(videoOutput, cameraManager, cameras, cameraID);
await startVideoOutput(videoOutput);
-
await videoRecorder.start().then(() => {
- expect(videoRecorder.state).assertEqual('playing');
console.info('case start called');
- sleep(RECORDER_TIME);
- }, failureCallback).catch(catchCallback);
+ expect(videoRecorder.state).assertEqual('playing');
+ mediaTestBase.msleep(RECORDER_TIME);
+ }, mediaTestBase.failureCallback).catch(mediaTestBase.catchCallback);
await videoRecorder.release().then(() => {
- expect(videoRecorder.state).assertEqual('idle');
console.info('case release ');
- }, failureCallback).catch(catchCallback);
+ expect(videoRecorder.state).assertEqual('idle');
+ }, mediaTestBase.failureCallback).catch(mediaTestBase.catchCallback);
await videoOutput.stop();
- await stopVideoOutput(videoOutput);
+ await videoOutput.release().then(() => {
+ console.info('[camera] case videoOutput release success');
+ });
+ videoOutPut = undefined;
+ await videoRecorderBase.stopCaptureSession(captureSession);
+ await videoRecorderBase.checkVideos(fdPath, RECORDER_TIME, trackArray, playerSurfaceId);
+ await mediaTestBase.closeFd(fdObject.fileAsset, fdObject.fdNumber);
done();
})
/* *
* @tc.number : SUB_MEDIA_VIDEO_RECORDER_FUNCTION_PROMISE_0200
* @tc.name : 02.start->pause->release (promise)
- * @tc.desc : Audio recordr control test
+ * @tc.desc : Video recordr control test
* @tc.size : MediumTest
* @tc.type : Function
* @tc.level : Level0
@@ -254,7 +269,9 @@ describe('VideoRecorderFuncPromiseTest', function () {
let videoRecorder = undefined;
let surfaceID = '';
let videoOutput;
- await getFd('02.mp4');
+ let trackArray = videoRecorderBase.getTrackArray(AUDIO_VIDEO_TYPE, configFile);
+ fdObject = await mediaTestBase.getFd('recorder_promise_02.mp4');
+ fdPath = "fd://" + fdObject.fdNumber.toString();
videoConfig.url = fdPath;
await media.createVideoRecorder().then((recorder) => {
console.info('case createVideoRecorder called');
@@ -264,45 +281,51 @@ describe('VideoRecorderFuncPromiseTest', function () {
} else {
console.info('case recordr is undefined!!');
}
- }, failureCallback).catch(catchCallback);
+ }, mediaTestBase.failureCallback).catch(mediaTestBase.catchCallback);
await videoRecorder.prepare(videoConfig).then(() => {
console.info('case recordr prepare called');
expect(videoRecorder.state).assertEqual('prepared');
- }, failureCallback).catch(catchCallback);
+ }, mediaTestBase.failureCallback).catch(mediaTestBase.catchCallback);
await videoRecorder.getInputSurface().then((outPutSurface) => {
console.info('case getInputSurface called');
- console.info(`case getInputSurface,state is ${videoRecorder.state}`);
expect(videoRecorder.state).assertEqual('prepared');
surfaceID = outPutSurface;
- }, failureCallback).catch(catchCallback);
+ }, mediaTestBase.failureCallback).catch(mediaTestBase.catchCallback);
videoOutput = await camera.createVideoOutput(surfaceID);
+ captureSession = await videoRecorderBase.initCaptureSession(videoOutput, cameraManager, cameras, cameraID);
await startVideoOutput(videoOutput);
await videoRecorder.start().then(() => {
console.info('case start called');
expect(videoRecorder.state).assertEqual('playing');
- sleep(RECORDER_TIME);
- }, failureCallback).catch(catchCallback);
+ mediaTestBase.msleep(RECORDER_TIME);
+ }, mediaTestBase.failureCallback).catch(mediaTestBase.catchCallback);
await videoRecorder.pause().then(() => {
console.info('case pause called');
- sleep(PAUSE_TIME);
+ mediaTestBase.msleep(PAUSE_TIME);
expect(videoRecorder.state).assertEqual('paused');
- }, failureCallback).catch(catchCallback);
+ }, mediaTestBase.failureCallback).catch(mediaTestBase.catchCallback);
await videoRecorder.release().then(() => {
console.info('case release ');
expect(videoRecorder.state).assertEqual('idle');
- }, failureCallback).catch(catchCallback);
+ }, mediaTestBase.failureCallback).catch(mediaTestBase.catchCallback);
await videoOutput.stop();
- await stopVideoOutput(videoOutput);
+ await videoOutput.release().then(() => {
+ console.info('[camera] case videoOutput release success');
+ });
+ videoOutPut = undefined;
+ await videoRecorderBase.stopCaptureSession(captureSession);
+ await videoRecorderBase.checkVideos(fdPath, RECORDER_TIME, trackArray, playerSurfaceId);
+ await mediaTestBase.closeFd(fdObject.fileAsset, fdObject.fdNumber);
done();
})
/* *
* @tc.number : SUB_MEDIA_VIDEO_RECORDER_FUNCTION_PROMISE_0300
* @tc.name : 03.start->pause->resume->release (promise)
- * @tc.desc : Audio recordr control test
+ * @tc.desc : Video recordr control test
* @tc.size : MediumTest
* @tc.type : Function
* @tc.level : Level0
@@ -311,7 +334,9 @@ describe('VideoRecorderFuncPromiseTest', function () {
let videoRecorder = undefined;
let surfaceID = '';
let videoOutput;
- await getFd('03.mp4');
+ let trackArray = videoRecorderBase.getTrackArray(AUDIO_VIDEO_TYPE, configFile);
+ fdObject = await mediaTestBase.getFd('recorder_promise_03.mp4');
+ fdPath = "fd://" + fdObject.fdNumber.toString();
videoConfig.url = fdPath;
await media.createVideoRecorder().then((recorder) => {
console.info('case createVideoRecorder called');
@@ -321,53 +346,60 @@ describe('VideoRecorderFuncPromiseTest', function () {
} else {
console.info('case recordr is undefined!!');
}
- }, failureCallback).catch(catchCallback);
+ }, mediaTestBase.failureCallback).catch(mediaTestBase.catchCallback);
await videoRecorder.prepare(videoConfig).then(() => {
console.info('case recordr prepare called');
expect(videoRecorder.state).assertEqual('prepared');
- }, failureCallback).catch(catchCallback);
+ }, mediaTestBase.failureCallback).catch(mediaTestBase.catchCallback);
await videoRecorder.getInputSurface().then((outPutSurface) => {
expect(videoRecorder.state).assertEqual('prepared');
console.info('case getInputSurface called');
surfaceID = outPutSurface;
- }, failureCallback).catch(catchCallback);
+ }, mediaTestBase.failureCallback).catch(mediaTestBase.catchCallback);
videoOutput = await camera.createVideoOutput(surfaceID);
+ captureSession = await videoRecorderBase.initCaptureSession(videoOutput, cameraManager, cameras, cameraID);
await startVideoOutput(videoOutput);
await videoRecorder.start().then(() => {
expect(videoRecorder.state).assertEqual('playing');
console.info('case start called');
- sleep(RECORDER_TIME);
- }, failureCallback).catch(catchCallback);
+ mediaTestBase.msleep(RECORDER_TIME);
+ }, mediaTestBase.failureCallback).catch(mediaTestBase.catchCallback);
await videoOutput.stop();
await videoRecorder.pause().then(() => {
expect(videoRecorder.state).assertEqual('paused');
- sleep(PAUSE_TIME);
+ mediaTestBase.msleep(PAUSE_TIME);
console.info('case pause called');
- }, failureCallback).catch(catchCallback);
+ }, mediaTestBase.failureCallback).catch(mediaTestBase.catchCallback);
await videoOutput.start();
await videoRecorder.resume().then(() => {
expect(videoRecorder.state).assertEqual('playing');
- sleep(RECORDER_TIME);
+ mediaTestBase.msleep(RECORDER_TIME);
console.info('case resume called');
- }, failureCallback).catch(catchCallback);
+ }, mediaTestBase.failureCallback).catch(mediaTestBase.catchCallback);
await videoRecorder.release().then(() => {
expect(videoRecorder.state).assertEqual('idle');
console.info('case release ');
- }, failureCallback).catch(catchCallback);
+ }, mediaTestBase.failureCallback).catch(mediaTestBase.catchCallback);
await videoOutput.stop();
- await stopVideoOutput(videoOutput);
+ await videoOutput.release().then(() => {
+ console.info('[camera] case videoOutput release success');
+ });
+ videoOutPut = undefined;
+ await videoRecorderBase.stopCaptureSession(captureSession);
+ await videoRecorderBase.checkVideos(fdPath, RECORDER_TIME * 2, trackArray, playerSurfaceId);
+ await mediaTestBase.closeFd(fdObject.fileAsset, fdObject.fdNumber);
done();
})
/* *
* @tc.number : SUB_MEDIA_VIDEO_RECORDER_FUNCTION_PROMISE_0400
* @tc.name : 04.start->stop->release (promise)
- * @tc.desc : Audio recordr control test
+ * @tc.desc : Video recordr control test
* @tc.size : MediumTest
* @tc.type : Function
* @tc.level : Level0
@@ -376,7 +408,9 @@ describe('VideoRecorderFuncPromiseTest', function () {
let videoRecorder = undefined;
let surfaceID = '';
let videoOutput;
- await getFd('04.mp4');
+ let trackArray = videoRecorderBase.getTrackArray(AUDIO_VIDEO_TYPE, configFile);
+ fdObject = await mediaTestBase.getFd('recorder_promise_04.mp4');
+ fdPath = "fd://" + fdObject.fdNumber.toString();
videoConfig.url = fdPath;
await media.createVideoRecorder().then((recorder) => {
console.info('case createVideoRecorder called');
@@ -386,44 +420,50 @@ describe('VideoRecorderFuncPromiseTest', function () {
} else {
console.info('case recordr is undefined!!');
}
- }, failureCallback).catch(catchCallback);
+ }, mediaTestBase.failureCallback).catch(mediaTestBase.catchCallback);
await videoRecorder.prepare(videoConfig).then(() => {
console.info('case recordr prepare called');
expect(videoRecorder.state).assertEqual('prepared');
- }, failureCallback).catch(catchCallback);
+ }, mediaTestBase.failureCallback).catch(mediaTestBase.catchCallback);
await videoRecorder.getInputSurface().then((outPutSurface) => {
console.info('case getInputSurface called');
expect(videoRecorder.state).assertEqual('prepared');
surfaceID = outPutSurface;
- }, failureCallback).catch(catchCallback);
+ }, mediaTestBase.failureCallback).catch(mediaTestBase.catchCallback);
videoOutput = await camera.createVideoOutput(surfaceID);
+ captureSession = await videoRecorderBase.initCaptureSession(videoOutput, cameraManager, cameras, cameraID);
await startVideoOutput(videoOutput);
await videoRecorder.start().then(() => {
console.info('case start called');
expect(videoRecorder.state).assertEqual('playing');
- sleep(RECORDER_TIME);
- }, failureCallback).catch(catchCallback);
+ mediaTestBase.msleep(RECORDER_TIME);
+ }, mediaTestBase.failureCallback).catch(mediaTestBase.catchCallback);
-
await videoRecorder.stop().then(() => {
expect(videoRecorder.state).assertEqual('stopped');
console.info('case stop called');
- }, failureCallback).catch(catchCallback);
+ }, mediaTestBase.failureCallback).catch(mediaTestBase.catchCallback);
await videoOutput.stop();
await videoRecorder.release().then(() => {
expect(videoRecorder.state).assertEqual('idle');
console.info('case release ');
- }, failureCallback).catch(catchCallback);
- await stopVideoOutput(videoOutput);
+ }, mediaTestBase.failureCallback).catch(mediaTestBase.catchCallback);
+ await videoOutput.release().then(() => {
+ console.info('[camera] case videoOutput release success');
+ });
+ videoOutPut = undefined;
+ await videoRecorderBase.stopCaptureSession(captureSession);
+ await videoRecorderBase.checkVideos(fdPath, RECORDER_TIME, trackArray, playerSurfaceId);
+ await mediaTestBase.closeFd(fdObject.fileAsset, fdObject.fdNumber);
done();
})
/* *
* @tc.number : SUB_MEDIA_VIDEO_RECORDER_FUNCTION_PROMISE_0500
* @tc.name : 05.start->reset->release (promise)
- * @tc.desc : Audio recordr control test
+ * @tc.desc : Video recordr control test
* @tc.size : MediumTest
* @tc.type : Function
* @tc.level : Level0
@@ -432,7 +472,9 @@ describe('VideoRecorderFuncPromiseTest', function () {
let videoRecorder = undefined;
let surfaceID = '';
let videoOutput;
- await getFd('05.mp4');
+ let trackArray = videoRecorderBase.getTrackArray(AUDIO_VIDEO_TYPE, configFile);
+ fdObject = await mediaTestBase.getFd('recorder_promise_05.mp4');
+ fdPath = "fd://" + fdObject.fdNumber.toString();
videoConfig.url = fdPath;
await media.createVideoRecorder().then((recorder) => {
console.info('case createVideoRecorder called');
@@ -442,43 +484,50 @@ describe('VideoRecorderFuncPromiseTest', function () {
} else {
console.info('case recordr is undefined!!');
}
- }, failureCallback).catch(catchCallback);
+ }, mediaTestBase.failureCallback).catch(mediaTestBase.catchCallback);
await videoRecorder.prepare(videoConfig).then(() => {
console.info('case recordr prepare called');
expect(videoRecorder.state).assertEqual('prepared');
- }, failureCallback).catch(catchCallback);
+ }, mediaTestBase.failureCallback).catch(mediaTestBase.catchCallback);
await videoRecorder.getInputSurface().then((outPutSurface) => {
expect(videoRecorder.state).assertEqual('prepared');
console.info('case getInputSurface called');
surfaceID = outPutSurface;
- }, failureCallback).catch(catchCallback);
+ }, mediaTestBase.failureCallback).catch(mediaTestBase.catchCallback);
videoOutput = await camera.createVideoOutput(surfaceID);
+ captureSession = await videoRecorderBase.initCaptureSession(videoOutput, cameraManager, cameras, cameraID);
await startVideoOutput(videoOutput);
await videoRecorder.start().then(() => {
console.info('case start called');
expect(videoRecorder.state).assertEqual('playing');
- sleep(RECORDER_TIME);
- }, failureCallback).catch(catchCallback);
+ mediaTestBase.msleep(RECORDER_TIME);
+ }, mediaTestBase.failureCallback).catch(mediaTestBase.catchCallback);
await videoRecorder.reset().then(() => {
console.info('case reset called');
expect(videoRecorder.state).assertEqual('idle');
- }, failureCallback).catch(catchCallback);
+ }, mediaTestBase.failureCallback).catch(mediaTestBase.catchCallback);
await videoOutput.stop();
await videoRecorder.release().then(() => {
expect(videoRecorder.state).assertEqual('idle');
console.info('case release ');
- }, failureCallback).catch(catchCallback);
- await stopVideoOutput(videoOutput);
+ }, mediaTestBase.failureCallback).catch(mediaTestBase.catchCallback);
+ await videoOutput.release().then(() => {
+ console.info('[camera] case videoOutput release success');
+ });
+ videoOutPut = undefined;
+ await videoRecorderBase.stopCaptureSession(captureSession);
+ await videoRecorderBase.checkVideos(fdPath, RECORDER_TIME, trackArray, playerSurfaceId);
+ await mediaTestBase.closeFd(fdObject.fileAsset, fdObject.fdNumber);
done();
})
/* *
* @tc.number : SUB_MEDIA_VIDEO_RECORDER_FUNCTION_PROMISE_0600
* @tc.name : 06.start->pause->stop->release (promise)
- * @tc.desc : Audio recordr control test
+ * @tc.desc : Video recordr control test
* @tc.size : MediumTest
* @tc.type : Function
* @tc.level : Level0
@@ -487,7 +536,9 @@ describe('VideoRecorderFuncPromiseTest', function () {
let videoRecorder = undefined;
let surfaceID = '';
let videoOutput;
- await getFd('06.mp4');
+ let trackArray = videoRecorderBase.getTrackArray(AUDIO_VIDEO_TYPE, configFile);
+ fdObject = await mediaTestBase.getFd('recorder_promise_06.mp4');
+ fdPath = "fd://" + fdObject.fdNumber.toString();
videoConfig.url = fdPath;
await media.createVideoRecorder().then((recorder) => {
console.info('case createVideoRecorder called');
@@ -497,50 +548,58 @@ describe('VideoRecorderFuncPromiseTest', function () {
} else {
console.info('case recordr is undefined!!');
}
- }, failureCallback).catch(catchCallback);
+ }, mediaTestBase.failureCallback).catch(mediaTestBase.catchCallback);
await videoRecorder.prepare(videoConfig).then(() => {
console.info('case recordr prepare called');
expect(videoRecorder.state).assertEqual('prepared');
- }, failureCallback).catch(catchCallback);
+ }, mediaTestBase.failureCallback).catch(mediaTestBase.catchCallback);
await videoRecorder.getInputSurface().then((outPutSurface) => {
expect(videoRecorder.state).assertEqual('prepared');
console.info('case getInputSurface called');
surfaceID = outPutSurface;
- }, failureCallback).catch(catchCallback);
+ }, mediaTestBase.failureCallback).catch(mediaTestBase.catchCallback);
videoOutput = await camera.createVideoOutput(surfaceID);
+ captureSession = await videoRecorderBase.initCaptureSession(videoOutput, cameraManager, cameras, cameraID);
await startVideoOutput(videoOutput);
await videoRecorder.start().then(() => {
console.info('case start called');
expect(videoRecorder.state).assertEqual('playing');
- sleep(RECORDER_TIME);
- }, failureCallback).catch(catchCallback);
+ mediaTestBase.msleep(RECORDER_TIME);
+ }, mediaTestBase.failureCallback).catch(mediaTestBase.catchCallback);
await videoOutput.stop();
await videoRecorder.pause().then(() => {
expect(videoRecorder.state).assertEqual('paused');
- sleep(PAUSE_TIME);
+ mediaTestBase.msleep(PAUSE_TIME);
console.info('case pause called');
- }, failureCallback).catch(catchCallback);
+ }, mediaTestBase.failureCallback).catch(mediaTestBase.catchCallback);
await videoRecorder.stop().then(() => {
expect(videoRecorder.state).assertEqual('stopped');
console.info('case stop called');
- }, failureCallback).catch(catchCallback);
+ }, mediaTestBase.failureCallback).catch(mediaTestBase.catchCallback);
await videoRecorder.release().then(() => {
expect(videoRecorder.state).assertEqual('idle');
console.info('case release ');
- }, failureCallback).catch(catchCallback);
- await stopVideoOutput(videoOutput);
+ }, mediaTestBase.failureCallback).catch(mediaTestBase.catchCallback);
+
+ await videoOutput.release().then(() => {
+ console.info('[camera] case videoOutput release success');
+ });
+ videoOutPut = undefined;
+ await videoRecorderBase.stopCaptureSession(captureSession);
+ await videoRecorderBase.checkVideos(fdPath, RECORDER_TIME, trackArray, playerSurfaceId);
+ await mediaTestBase.closeFd(fdObject.fileAsset, fdObject.fdNumber);
done();
})
/* *
* @tc.number : SUB_MEDIA_VIDEO_RECORDER_FUNCTION_PROMISE_0700
* @tc.name : 07.start->pause->reset->release (promise)
- * @tc.desc : Audio recordr control test
+ * @tc.desc : Video recordr control test
* @tc.size : MediumTest
* @tc.type : Function
* @tc.level : Level0
@@ -549,7 +608,9 @@ describe('VideoRecorderFuncPromiseTest', function () {
let videoRecorder = undefined;
let surfaceID = '';
let videoOutput;
- await getFd('07.mp4');
+ let trackArray = videoRecorderBase.getTrackArray(AUDIO_VIDEO_TYPE, configFile);
+ fdObject = await mediaTestBase.getFd('recorder_promise_07.mp4');
+ fdPath = "fd://" + fdObject.fdNumber.toString();
videoConfig.url = fdPath;
await media.createVideoRecorder().then((recorder) => {
console.info('case createVideoRecorder called');
@@ -559,50 +620,57 @@ describe('VideoRecorderFuncPromiseTest', function () {
} else {
console.info('case recordr is undefined!!');
}
- }, failureCallback).catch(catchCallback);
+ }, mediaTestBase.failureCallback).catch(mediaTestBase.catchCallback);
await videoRecorder.prepare(videoConfig).then(() => {
console.info('case recordr prepare called');
expect(videoRecorder.state).assertEqual('prepared');
- }, failureCallback).catch(catchCallback);
+ }, mediaTestBase.failureCallback).catch(mediaTestBase.catchCallback);
await videoRecorder.getInputSurface().then((outPutSurface) => {
expect(videoRecorder.state).assertEqual('prepared');
console.info('case getInputSurface called');
surfaceID = outPutSurface;
- }, failureCallback).catch(catchCallback);
+ }, mediaTestBase.failureCallback).catch(mediaTestBase.catchCallback);
videoOutput = await camera.createVideoOutput(surfaceID);
+ captureSession = await videoRecorderBase.initCaptureSession(videoOutput, cameraManager, cameras, cameraID);
await startVideoOutput(videoOutput);
await videoRecorder.start().then(() => {
console.info('case start called');
expect(videoRecorder.state).assertEqual('playing');
- sleep(RECORDER_TIME);
- }, failureCallback).catch(catchCallback);
+ mediaTestBase.msleep(RECORDER_TIME);
+ }, mediaTestBase.failureCallback).catch(mediaTestBase.catchCallback);
await videoOutput.stop();
await videoRecorder.pause().then(() => {
expect(videoRecorder.state).assertEqual('paused');
- sleep(PAUSE_TIME);
+ mediaTestBase.msleep(PAUSE_TIME);
console.info('case pause called');
- }, failureCallback).catch(catchCallback);
+ }, mediaTestBase.failureCallback).catch(mediaTestBase.catchCallback);
await videoRecorder.reset().then(() => {
console.info('case reset called');
expect(videoRecorder.state).assertEqual('idle');
- }, failureCallback).catch(catchCallback);
+ }, mediaTestBase.failureCallback).catch(mediaTestBase.catchCallback);
await videoRecorder.release().then(() => {
expect(videoRecorder.state).assertEqual('idle');
console.info('case release ');
- }, failureCallback).catch(catchCallback);
- await stopVideoOutput(videoOutput);
+ }, mediaTestBase.failureCallback).catch(mediaTestBase.catchCallback);
+ await videoOutput.release().then(() => {
+ console.info('[camera] case videoOutput release success');
+ });
+ videoOutPut = undefined;
+ await videoRecorderBase.stopCaptureSession(captureSession);
+ await videoRecorderBase.checkVideos(fdPath, RECORDER_TIME, trackArray, playerSurfaceId);
+ await mediaTestBase.closeFd(fdObject.fileAsset, fdObject.fdNumber);
done();
})
/* *
* @tc.number : SUB_MEDIA_VIDEO_RECORDER_FUNCTION_PROMISE_0800
* @tc.name : 08.start->pause->resume->stop->release (promise)
- * @tc.desc : Audio recordr control test
+ * @tc.desc : Video recordr control test
* @tc.size : MediumTest
* @tc.type : Function
* @tc.level : Level0
@@ -611,7 +679,9 @@ describe('VideoRecorderFuncPromiseTest', function () {
let videoRecorder = undefined;
let surfaceID = '';
let videoOutput;
- await getFd('08.mp4');
+ let trackArray = videoRecorderBase.getTrackArray(AUDIO_VIDEO_TYPE, configFile);
+ fdObject = await mediaTestBase.getFd('recorder_promise_08.mp4');
+ fdPath = "fd://" + fdObject.fdNumber.toString();
videoConfig.url = fdPath;
await media.createVideoRecorder().then((recorder) => {
console.info('case createVideoRecorder called');
@@ -621,58 +691,65 @@ describe('VideoRecorderFuncPromiseTest', function () {
} else {
console.info('case recordr is undefined!!');
}
- }, failureCallback).catch(catchCallback);
+ }, mediaTestBase.failureCallback).catch(mediaTestBase.catchCallback);
await videoRecorder.prepare(videoConfig).then(() => {
console.info('case recordr prepare called');
expect(videoRecorder.state).assertEqual('prepared');
- }, failureCallback).catch(catchCallback);
+ }, mediaTestBase.failureCallback).catch(mediaTestBase.catchCallback);
await videoRecorder.getInputSurface().then((outPutSurface) => {
expect(videoRecorder.state).assertEqual('prepared');
console.info('case getInputSurface called');
surfaceID = outPutSurface;
- }, failureCallback).catch(catchCallback);
+ }, mediaTestBase.failureCallback).catch(mediaTestBase.catchCallback);
videoOutput = await camera.createVideoOutput(surfaceID);
+ captureSession = await videoRecorderBase.initCaptureSession(videoOutput, cameraManager, cameras, cameraID);
await startVideoOutput(videoOutput);
await videoRecorder.start().then(() => {
console.info('case start called');
expect(videoRecorder.state).assertEqual('playing');
- sleep(RECORDER_TIME);
- }, failureCallback).catch(catchCallback);
+ mediaTestBase.msleep(RECORDER_TIME);
+ }, mediaTestBase.failureCallback).catch(mediaTestBase.catchCallback);
await videoOutput.stop();
await videoRecorder.pause().then(() => {
expect(videoRecorder.state).assertEqual('paused');
- sleep(PAUSE_TIME);
+ mediaTestBase.msleep(PAUSE_TIME);
console.info('case pause called');
- }, failureCallback).catch(catchCallback);
+ }, mediaTestBase.failureCallback).catch(mediaTestBase.catchCallback);
await videoOutput.start();
await videoRecorder.resume().then(() => {
expect(videoRecorder.state).assertEqual('playing');
- sleep(RECORDER_TIME);
+ mediaTestBase.msleep(RECORDER_TIME);
console.info('case resume called');
- }, failureCallback).catch(catchCallback);
+ }, mediaTestBase.failureCallback).catch(mediaTestBase.catchCallback);
await videoRecorder.stop().then(() => {
expect(videoRecorder.state).assertEqual('stopped');
console.info('case stop called');
- }, failureCallback).catch(catchCallback);
+ }, mediaTestBase.failureCallback).catch(mediaTestBase.catchCallback);
await videoRecorder.release().then(() => {
expect(videoRecorder.state).assertEqual('idle');
console.info('case release ');
- }, failureCallback).catch(catchCallback);
+ }, mediaTestBase.failureCallback).catch(mediaTestBase.catchCallback);
await videoOutput.stop();
- await stopVideoOutput(videoOutput);
+ await videoOutput.release().then(() => {
+ console.info('[camera] case videoOutput release success');
+ });
+ videoOutPut = undefined;
+ await videoRecorderBase.stopCaptureSession(captureSession);
+ await videoRecorderBase.checkVideos(fdPath, RECORDER_TIME * 2, trackArray, playerSurfaceId);
+ await mediaTestBase.closeFd(fdObject.fileAsset, fdObject.fdNumber);
done();
})
/* *
* @tc.number : SUB_MEDIA_VIDEO_RECORDER_FUNCTION_PROMISE_0900
* @tc.name : 09.start->pause->resume->reset->release (promise)
- * @tc.desc : Audio recordr control test
+ * @tc.desc : Video recordr control test
* @tc.size : MediumTest
* @tc.type : Function
* @tc.level : Level0
@@ -681,7 +758,9 @@ describe('VideoRecorderFuncPromiseTest', function () {
let videoRecorder = undefined;
let surfaceID = '';
let videoOutput;
- await getFd('09.mp4');
+ let trackArray = videoRecorderBase.getTrackArray(AUDIO_VIDEO_TYPE, configFile);
+ fdObject = await mediaTestBase.getFd('recorder_promise_09.mp4');
+ fdPath = "fd://" + fdObject.fdNumber.toString();
videoConfig.url = fdPath;
await media.createVideoRecorder().then((recorder) => {
console.info('case createVideoRecorder called');
@@ -691,50 +770,57 @@ describe('VideoRecorderFuncPromiseTest', function () {
} else {
console.info('case recordr is undefined!!');
}
- }, failureCallback).catch(catchCallback);
+ }, mediaTestBase.failureCallback).catch(mediaTestBase.catchCallback);
await videoRecorder.prepare(videoConfig).then(() => {
console.info('case recordr prepare called');
expect(videoRecorder.state).assertEqual('prepared');
- }, failureCallback).catch(catchCallback);
+ }, mediaTestBase.failureCallback).catch(mediaTestBase.catchCallback);
await videoRecorder.getInputSurface().then((outPutSurface) => {
expect(videoRecorder.state).assertEqual('prepared');
console.info('case getInputSurface called');
surfaceID = outPutSurface;
- }, failureCallback).catch(catchCallback);
+ }, mediaTestBase.failureCallback).catch(mediaTestBase.catchCallback);
videoOutput = await camera.createVideoOutput(surfaceID);
+ captureSession = await videoRecorderBase.initCaptureSession(videoOutput, cameraManager, cameras, cameraID);
await startVideoOutput(videoOutput);
await videoRecorder.start().then(() => {
console.info('case start called');
expect(videoRecorder.state).assertEqual('playing');
- sleep(RECORDER_TIME);
- }, failureCallback).catch(catchCallback);
+ mediaTestBase.msleep(RECORDER_TIME);
+ }, mediaTestBase.failureCallback).catch(mediaTestBase.catchCallback);
await videoOutput.stop();
await videoRecorder.pause().then(() => {
expect(videoRecorder.state).assertEqual('paused');
- sleep(PAUSE_TIME);
+ mediaTestBase.msleep(PAUSE_TIME);
console.info('case pause called');
- }, failureCallback).catch(catchCallback);
+ }, mediaTestBase.failureCallback).catch(mediaTestBase.catchCallback);
await videoOutput.start();
await videoRecorder.resume().then(() => {
expect(videoRecorder.state).assertEqual('playing');
- sleep(RECORDER_TIME);
+ mediaTestBase.msleep(RECORDER_TIME);
console.info('case resume called');
- }, failureCallback).catch(catchCallback);
+ }, mediaTestBase.failureCallback).catch(mediaTestBase.catchCallback);
await videoOutput.stop();
await videoRecorder.reset().then(() => {
console.info('case reset called');
expect(videoRecorder.state).assertEqual('idle');
- }, failureCallback).catch(catchCallback);
+ }, mediaTestBase.failureCallback).catch(mediaTestBase.catchCallback);
await videoRecorder.release().then(() => {
expect(videoRecorder.state).assertEqual('idle');
console.info('case release ');
- }, failureCallback).catch(catchCallback);
- await stopVideoOutput(videoOutput);
+ }, mediaTestBase.failureCallback).catch(mediaTestBase.catchCallback);
+ await videoOutput.release().then(() => {
+ console.info('[camera] case videoOutput release success');
+ });
+ videoOutPut = undefined;
+ await videoRecorderBase.stopCaptureSession(captureSession);
+ await videoRecorderBase.checkVideos(fdPath, RECORDER_TIME * 2, trackArray, playerSurfaceId);
+ await mediaTestBase.closeFd(fdObject.fileAsset, fdObject.fdNumber);
done();
})
@@ -742,7 +828,7 @@ describe('VideoRecorderFuncPromiseTest', function () {
* @tc.number : SUB_MEDIA_VIDEO_RECORDER_FUNCTION_PROMISE_1000
* @tc.name : 10.start->stop->release
* (audioBitrate 8000,audioSampleRate 8000,videoBitrateRange 8000)(promise)
- * @tc.desc : Audio recordr control test
+ * @tc.desc : Video recordr control test
* @tc.size : MediumTest
* @tc.type : Function
* @tc.level : Level1
@@ -751,11 +837,13 @@ describe('VideoRecorderFuncPromiseTest', function () {
let videoRecorder = undefined;
let surfaceID = '';
let videoOutput;
- await getFd('10.mp4');
+ fdObject = await mediaTestBase.getFd('recorder_promise_10.mp4');
+ fdPath = "fd://" + fdObject.fdNumber.toString();
videoConfig.url = fdPath;
configFile.audioBitrate = 8000;
configFile.audioSampleRate = 8000;
configFile.videoBitrate = 8000;
+ let trackArray = videoRecorderBase.getTrackArray(AUDIO_VIDEO_TYPE, configFile);
await media.createVideoRecorder().then((recorder) => {
console.info('case createVideoRecorder called');
if (typeof (recorder) != 'undefined') {
@@ -764,37 +852,44 @@ describe('VideoRecorderFuncPromiseTest', function () {
} else {
console.info('case recordr is undefined!!');
}
- }, failureCallback).catch(catchCallback);
+ }, mediaTestBase.failureCallback).catch(mediaTestBase.catchCallback);
await videoRecorder.prepare(videoConfig).then(() => {
console.info('case recordr prepare called');
expect(videoRecorder.state).assertEqual('prepared');
- }, failureCallback).catch(catchCallback);
+ }, mediaTestBase.failureCallback).catch(mediaTestBase.catchCallback);
await videoRecorder.getInputSurface().then((outPutSurface) => {
console.info('case getInputSurface called');
expect(videoRecorder.state).assertEqual('prepared');
surfaceID = outPutSurface;
- }, failureCallback).catch(catchCallback);
+ }, mediaTestBase.failureCallback).catch(mediaTestBase.catchCallback);
videoOutput = await camera.createVideoOutput(surfaceID);
+ captureSession = await videoRecorderBase.initCaptureSession(videoOutput, cameraManager, cameras, cameraID);
await startVideoOutput(videoOutput);
await videoRecorder.start().then(() => {
console.info('case start called');
expect(videoRecorder.state).assertEqual('playing');
- sleep(RECORDER_TIME);
- }, failureCallback).catch(catchCallback);
+ mediaTestBase.msleep(RECORDER_TIME);
+ }, mediaTestBase.failureCallback).catch(mediaTestBase.catchCallback);
await videoOutput.stop();
await videoRecorder.stop().then(() => {
expect(videoRecorder.state).assertEqual('stopped');
console.info('case stop called');
- }, failureCallback).catch(catchCallback);
+ }, mediaTestBase.failureCallback).catch(mediaTestBase.catchCallback);
await videoRecorder.release().then(() => {
expect(videoRecorder.state).assertEqual('idle');
console.info('case release ');
- }, failureCallback).catch(catchCallback);
- await stopVideoOutput(videoOutput);
+ }, mediaTestBase.failureCallback).catch(mediaTestBase.catchCallback);
+ await videoOutput.release().then(() => {
+ console.info('[camera] case videoOutput release success');
+ });
+ videoOutPut = undefined;
+ await videoRecorderBase.stopCaptureSession(captureSession);
+ await videoRecorderBase.checkVideos(fdPath, RECORDER_TIME, trackArray, playerSurfaceId);
+ await mediaTestBase.closeFd(fdObject.fileAsset, fdObject.fdNumber);
done();
})
@@ -802,7 +897,7 @@ describe('VideoRecorderFuncPromiseTest', function () {
* @tc.number : SUB_MEDIA_VIDEO_RECORDER_FUNCTION_PROMISE_1100
* @tc.name : 11.start->stop->release
* (audioBitrate 16000,audioSampleRate 32000,videoBitrateRange 16000)(promise)
- * @tc.desc : Audio recordr control test
+ * @tc.desc : Video recordr control test
* @tc.size : MediumTest
* @tc.type : Function
* @tc.level : Level1
@@ -811,11 +906,13 @@ describe('VideoRecorderFuncPromiseTest', function () {
let videoRecorder = undefined;
let surfaceID = '';
let videoOutput;
- await getFd('11.mp4');
+ fdObject = await mediaTestBase.getFd('recorder_promise_11.mp4');
+ fdPath = "fd://" + fdObject.fdNumber.toString();
videoConfig.url = fdPath;
configFile.audioBitrate = 16000;
configFile.audioSampleRate = 32000;
configFile.videoBitrate = 16000;
+ let trackArray = videoRecorderBase.getTrackArray(AUDIO_VIDEO_TYPE, configFile);
await media.createVideoRecorder().then((recorder) => {
console.info('case createVideoRecorder called');
if (typeof (recorder) != 'undefined') {
@@ -824,37 +921,44 @@ describe('VideoRecorderFuncPromiseTest', function () {
} else {
console.info('case recordr is undefined!!');
}
- }, failureCallback).catch(catchCallback);
+ }, mediaTestBase.failureCallback).catch(mediaTestBase.catchCallback);
await videoRecorder.prepare(videoConfig).then(() => {
console.info('case recordr prepare called');
expect(videoRecorder.state).assertEqual('prepared');
- }, failureCallback).catch(catchCallback);
+ }, mediaTestBase.failureCallback).catch(mediaTestBase.catchCallback);
await videoRecorder.getInputSurface().then((outPutSurface) => {
console.info('case getInputSurface called');
expect(videoRecorder.state).assertEqual('prepared');
surfaceID = outPutSurface;
- }, failureCallback).catch(catchCallback);
+ }, mediaTestBase.failureCallback).catch(mediaTestBase.catchCallback);
videoOutput = await camera.createVideoOutput(surfaceID);
+ captureSession = await videoRecorderBase.initCaptureSession(videoOutput, cameraManager, cameras, cameraID);
await startVideoOutput(videoOutput);
await videoRecorder.start().then(() => {
console.info('case start called');
expect(videoRecorder.state).assertEqual('playing');
- sleep(RECORDER_TIME);
- }, failureCallback).catch(catchCallback);
+ mediaTestBase.msleep(RECORDER_TIME);
+ }, mediaTestBase.failureCallback).catch(mediaTestBase.catchCallback);
await videoOutput.stop();
await videoRecorder.stop().then(() => {
expect(videoRecorder.state).assertEqual('stopped');
console.info('case stop called');
- }, failureCallback).catch(catchCallback);
+ }, mediaTestBase.failureCallback).catch(mediaTestBase.catchCallback);
await videoRecorder.release().then(() => {
expect(videoRecorder.state).assertEqual('idle');
console.info('case release ');
- }, failureCallback).catch(catchCallback);
- await stopVideoOutput(videoOutput);
+ }, mediaTestBase.failureCallback).catch(mediaTestBase.catchCallback);
+ await videoOutput.release().then(() => {
+ console.info('[camera] case videoOutput release success');
+ });
+ videoOutPut = undefined;
+ await videoRecorderBase.stopCaptureSession(captureSession);
+ await videoRecorderBase.checkVideos(fdPath, RECORDER_TIME, trackArray, playerSurfaceId);
+ await mediaTestBase.closeFd(fdObject.fileAsset, fdObject.fdNumber);
done();
})
@@ -862,7 +966,7 @@ describe('VideoRecorderFuncPromiseTest', function () {
* @tc.number : SUB_MEDIA_VIDEO_RECORDER_FUNCTION_PROMISE_1200
* @tc.name : 12.start->stop->release
* (audioBitrate 32000,audioSampleRate 44100,videoBitrateRange 32000)(promise)
- * @tc.desc : Audio recordr control test
+ * @tc.desc : Video recordr control test
* @tc.size : MediumTest
* @tc.type : Function
* @tc.level : Level1
@@ -871,11 +975,13 @@ describe('VideoRecorderFuncPromiseTest', function () {
let videoRecorder = undefined;
let surfaceID = '';
let videoOutput;
- await getFd('12.mp4');
+ fdObject = await mediaTestBase.getFd('recorder_promise_12.mp4');
+ fdPath = "fd://" + fdObject.fdNumber.toString();
videoConfig.url = fdPath;
configFile.audioBitrate = 32000;
configFile.audioSampleRate = 44100;
configFile.videoBitrate = 32000;
+ let trackArray = videoRecorderBase.getTrackArray(AUDIO_VIDEO_TYPE, configFile);
await media.createVideoRecorder().then((recorder) => {
console.info('case createVideoRecorder called');
if (typeof (recorder) != 'undefined') {
@@ -884,37 +990,44 @@ describe('VideoRecorderFuncPromiseTest', function () {
} else {
console.info('case recordr is undefined!!');
}
- }, failureCallback).catch(catchCallback);
+ }, mediaTestBase.failureCallback).catch(mediaTestBase.catchCallback);
await videoRecorder.prepare(videoConfig).then(() => {
console.info('case recordr prepare called');
expect(videoRecorder.state).assertEqual('prepared');
- }, failureCallback).catch(catchCallback);
+ }, mediaTestBase.failureCallback).catch(mediaTestBase.catchCallback);
await videoRecorder.getInputSurface().then((outPutSurface) => {
console.info('case getInputSurface called');
expect(videoRecorder.state).assertEqual('prepared');
surfaceID = outPutSurface;
- }, failureCallback).catch(catchCallback);
+ }, mediaTestBase.failureCallback).catch(mediaTestBase.catchCallback);
videoOutput = await camera.createVideoOutput(surfaceID);
+ captureSession = await videoRecorderBase.initCaptureSession(videoOutput, cameraManager, cameras, cameraID);
await startVideoOutput(videoOutput);
await videoRecorder.start().then(() => {
console.info('case start called');
expect(videoRecorder.state).assertEqual('playing');
- sleep(RECORDER_TIME);
- }, failureCallback).catch(catchCallback);
+ mediaTestBase.msleep(RECORDER_TIME);
+ }, mediaTestBase.failureCallback).catch(mediaTestBase.catchCallback);
await videoOutput.stop();
await videoRecorder.stop().then(() => {
expect(videoRecorder.state).assertEqual('stopped');
console.info('case stop called');
- }, failureCallback).catch(catchCallback);
+ }, mediaTestBase.failureCallback).catch(mediaTestBase.catchCallback);
await videoRecorder.release().then(() => {
expect(videoRecorder.state).assertEqual('idle');
console.info('case release ');
- }, failureCallback).catch(catchCallback);
- await stopVideoOutput(videoOutput);
+ }, mediaTestBase.failureCallback).catch(mediaTestBase.catchCallback);
+ await videoOutput.release().then(() => {
+ console.info('[camera] case videoOutput release success');
+ });
+ videoOutPut = undefined;
+ await videoRecorderBase.stopCaptureSession(captureSession);
+ await videoRecorderBase.checkVideos(fdPath, RECORDER_TIME, trackArray, playerSurfaceId);
+ await mediaTestBase.closeFd(fdObject.fileAsset, fdObject.fdNumber);
done();
})
@@ -922,7 +1035,7 @@ describe('VideoRecorderFuncPromiseTest', function () {
* @tc.number : SUB_MEDIA_VIDEO_RECORDER_FUNCTION_PROMISE_1300
* @tc.name : 13.start->stop->release
* (audioBitrate 112000,audioSampleRate 96000,videoBitrateRange 112000)(promise)
- * @tc.desc : Audio recordr control test
+ * @tc.desc : Video recordr control test
* @tc.size : MediumTest
* @tc.type : Function
* @tc.level : Level1
@@ -931,11 +1044,13 @@ describe('VideoRecorderFuncPromiseTest', function () {
let videoRecorder = undefined;
let surfaceID = '';
let videoOutput;
- await getFd('13.mp4');
+ fdObject = await mediaTestBase.getFd('recorder_promise_13.mp4');
+ fdPath = "fd://" + fdObject.fdNumber.toString();
videoConfig.url = fdPath;
configFile.audioBitrate = 112000;
configFile.audioSampleRate = 96000;
configFile.videoBitrate = 112000;
+ let trackArray = videoRecorderBase.getTrackArray(AUDIO_VIDEO_TYPE, configFile);
await media.createVideoRecorder().then((recorder) => {
console.info('case createVideoRecorder called');
if (typeof (recorder) != 'undefined') {
@@ -944,44 +1059,51 @@ describe('VideoRecorderFuncPromiseTest', function () {
} else {
console.info('case recordr is undefined!!');
}
- }, failureCallback).catch(catchCallback);
+ }, mediaTestBase.failureCallback).catch(mediaTestBase.catchCallback);
await videoRecorder.prepare(videoConfig).then(() => {
console.info('case recordr prepare called');
expect(videoRecorder.state).assertEqual('prepared');
- }, failureCallback).catch(catchCallback);
+ }, mediaTestBase.failureCallback).catch(mediaTestBase.catchCallback);
await videoRecorder.getInputSurface().then((outPutSurface) => {
console.info('case getInputSurface called');
expect(videoRecorder.state).assertEqual('prepared');
surfaceID = outPutSurface;
- }, failureCallback).catch(catchCallback);
+ }, mediaTestBase.failureCallback).catch(mediaTestBase.catchCallback);
videoOutput = await camera.createVideoOutput(surfaceID);
+ captureSession = await videoRecorderBase.initCaptureSession(videoOutput, cameraManager, cameras, cameraID);
await startVideoOutput(videoOutput);
await videoRecorder.start().then(() => {
console.info('case start called');
expect(videoRecorder.state).assertEqual('playing');
- sleep(RECORDER_TIME);
- }, failureCallback).catch(catchCallback);
+ mediaTestBase.msleep(RECORDER_TIME);
+ }, mediaTestBase.failureCallback).catch(mediaTestBase.catchCallback);
await videoOutput.stop();
await videoRecorder.stop().then(() => {
expect(videoRecorder.state).assertEqual('stopped');
console.info('case stop called');
- }, failureCallback).catch(catchCallback);
+ }, mediaTestBase.failureCallback).catch(mediaTestBase.catchCallback);
await videoRecorder.release().then(() => {
expect(videoRecorder.state).assertEqual('idle');
console.info('case release ');
- }, failureCallback).catch(catchCallback);
- await stopVideoOutput(videoOutput);
+ }, mediaTestBase.failureCallback).catch(mediaTestBase.catchCallback);
+ await videoOutput.release().then(() => {
+ console.info('[camera] case videoOutput release success');
+ });
+ videoOutPut = undefined;
+ await videoRecorderBase.stopCaptureSession(captureSession);
+ await videoRecorderBase.checkVideos(fdPath, RECORDER_TIME, trackArray, playerSurfaceId);
+ await mediaTestBase.closeFd(fdObject.fileAsset, fdObject.fdNumber);
done();
})
/* *
* @tc.number : SUB_MEDIA_VIDEO_RECORDER_FUNCTION_PROMISE_1400
* @tc.name : 14.start->release (only video) (promise)
- * @tc.desc : Audio recordr control test
+ * @tc.desc : Video recordr control test
* @tc.size : MediumTest
* @tc.type : Function
* @tc.level : Level1
@@ -990,8 +1112,10 @@ describe('VideoRecorderFuncPromiseTest', function () {
let videoRecorder = undefined;
let surfaceID = '';
let videoOutput;
- await getFd('14.mp4');
+ fdObject = await mediaTestBase.getFd('recorder_promise_14.mp4');
+ fdPath = "fd://" + fdObject.fdNumber.toString();
onlyVideoConfig.url = fdPath;
+ let trackArray = videoRecorderBase.getTrackArray(ONLYVIDEO_TYPE, onlyVideoProfile);
await media.createVideoRecorder().then((recorder) => {
console.info('case createVideoRecorder called');
if (typeof (recorder) != 'undefined') {
@@ -1001,36 +1125,43 @@ describe('VideoRecorderFuncPromiseTest', function () {
console.info('case recordr is undefined!!');
expect().assertFail();
}
- }, failureCallback).catch(catchCallback);
+ }, mediaTestBase.failureCallback).catch(mediaTestBase.catchCallback);
await videoRecorder.prepare(onlyVideoConfig).then(() => {
expect(videoRecorder.state).assertEqual('prepared');
console.info('case prepare called');
- }, failureCallback).catch(catchCallback);
+ }, mediaTestBase.failureCallback).catch(mediaTestBase.catchCallback);
await videoRecorder.getInputSurface().then((outPutSurface) => {
surfaceID = outPutSurface;
- }, failureCallback).catch(catchCallback);
+ }, mediaTestBase.failureCallback).catch(mediaTestBase.catchCallback);
videoOutput = await camera.createVideoOutput(surfaceID);
+ captureSession = await videoRecorderBase.initCaptureSession(videoOutput, cameraManager, cameras, cameraID);
await startVideoOutput(videoOutput);
await videoRecorder.start().then(() => {
expect(videoRecorder.state).assertEqual('playing');
console.info('case start called');
- sleep(RECORDER_TIME);
- }, failureCallback).catch(catchCallback);
+ mediaTestBase.msleep(RECORDER_TIME);
+ }, mediaTestBase.failureCallback).catch(mediaTestBase.catchCallback);
await videoOutput.stop();
await videoRecorder.release().then(() => {
expect(videoRecorder.state).assertEqual('idle');
console.info('case release ');
- }, failureCallback).catch(catchCallback);
- await stopVideoOutput(videoOutput);
+ }, mediaTestBase.failureCallback).catch(mediaTestBase.catchCallback);
+ await videoOutput.release().then(() => {
+ console.info('[camera] case videoOutput release success');
+ });
+ videoOutPut = undefined;
+ await videoRecorderBase.stopCaptureSession(captureSession);
+ await videoRecorderBase.checkVideos(fdPath, RECORDER_TIME, trackArray, playerSurfaceId);
+ await mediaTestBase.closeFd(fdObject.fileAsset, fdObject.fdNumber);
done();
})
/* *
* @tc.number : SUB_MEDIA_VIDEO_RECORDER_FUNCTION_PROMISE_1500
* @tc.name : 15.start->pause->release (only video) (promise)
- * @tc.desc : Audio recordr control test
+ * @tc.desc : Video recordr control test
* @tc.size : MediumTest
* @tc.type : Function
* @tc.level : Level1
@@ -1039,8 +1170,10 @@ describe('VideoRecorderFuncPromiseTest', function () {
let videoRecorder = undefined;
let surfaceID = '';
let videoOutput;
- await getFd('15.mp4');
+ fdObject = await mediaTestBase.getFd('recorder_promise_15.mp4');
+ fdPath = "fd://" + fdObject.fdNumber.toString();
onlyVideoConfig.url = fdPath;
+ let trackArray = videoRecorderBase.getTrackArray(ONLYVIDEO_TYPE, onlyVideoProfile);
await media.createVideoRecorder().then((recorder) => {
console.info('case createVideoRecorder called');
if (typeof (recorder) != 'undefined') {
@@ -1049,46 +1182,53 @@ describe('VideoRecorderFuncPromiseTest', function () {
} else {
console.info('case recordr is undefined!!');
}
- }, failureCallback).catch(catchCallback);
+ }, mediaTestBase.failureCallback).catch(mediaTestBase.catchCallback);
await videoRecorder.prepare(onlyVideoConfig).then(() => {
console.info('case recordr prepare called');
expect(videoRecorder.state).assertEqual('prepared');
- }, failureCallback).catch(catchCallback);
+ }, mediaTestBase.failureCallback).catch(mediaTestBase.catchCallback);
await videoRecorder.getInputSurface().then((outPutSurface) => {
console.info('case getInputSurface called');
console.info(`case getInputSurface,state is ${videoRecorder.state}`);
expect(videoRecorder.state).assertEqual('prepared');
surfaceID = outPutSurface;
- }, failureCallback).catch(catchCallback);
+ }, mediaTestBase.failureCallback).catch(mediaTestBase.catchCallback);
videoOutput = await camera.createVideoOutput(surfaceID);
+ captureSession = await videoRecorderBase.initCaptureSession(videoOutput, cameraManager, cameras, cameraID);
await startVideoOutput(videoOutput);
await videoRecorder.start().then(() => {
console.info('case start called');
expect(videoRecorder.state).assertEqual('playing');
- sleep(RECORDER_TIME);
- }, failureCallback).catch(catchCallback);
+ mediaTestBase.msleep(RECORDER_TIME);
+ }, mediaTestBase.failureCallback).catch(mediaTestBase.catchCallback);
await videoOutput.stop();
await videoRecorder.pause().then(() => {
console.info('case pause called');
- sleep(PAUSE_TIME);
+ mediaTestBase.msleep(PAUSE_TIME);
expect(videoRecorder.state).assertEqual('paused');
- }, failureCallback).catch(catchCallback);
+ }, mediaTestBase.failureCallback).catch(mediaTestBase.catchCallback);
await videoRecorder.release().then(() => {
console.info('case release ');
expect(videoRecorder.state).assertEqual('idle');
- }, failureCallback).catch(catchCallback);
- await stopVideoOutput(videoOutput);
+ }, mediaTestBase.failureCallback).catch(mediaTestBase.catchCallback);
+ await videoOutput.release().then(() => {
+ console.info('[camera] case videoOutput release success');
+ });
+ videoOutPut = undefined;
+ await videoRecorderBase.stopCaptureSession(captureSession);
+ await videoRecorderBase.checkVideos(fdPath, RECORDER_TIME, trackArray, playerSurfaceId);
+ await mediaTestBase.closeFd(fdObject.fileAsset, fdObject.fdNumber);
done();
})
/* *
* @tc.number : SUB_MEDIA_VIDEO_RECORDER_FUNCTION_PROMISE_1600
* @tc.name : 16.start->pause->resume->releas (only video) (promise)
- * @tc.desc : Audio recordr control test
+ * @tc.desc : Video recordr control test
* @tc.size : MediumTest
* @tc.type : Function
* @tc.level : Level1
@@ -1097,8 +1237,10 @@ describe('VideoRecorderFuncPromiseTest', function () {
let videoRecorder = undefined;
let surfaceID = '';
let videoOutput;
- await getFd('16.mp4');
+ fdObject = await mediaTestBase.getFd('recorder_promise_16.mp4');
+ fdPath = "fd://" + fdObject.fdNumber.toString();
onlyVideoConfig.url = fdPath;
+ let trackArray = videoRecorderBase.getTrackArray(ONLYVIDEO_TYPE, onlyVideoProfile);
await media.createVideoRecorder().then((recorder) => {
console.info('case createVideoRecorder called');
if (typeof (recorder) != 'undefined') {
@@ -1107,52 +1249,59 @@ describe('VideoRecorderFuncPromiseTest', function () {
} else {
console.info('case recordr is undefined!!');
}
- }, failureCallback).catch(catchCallback);
+ }, mediaTestBase.failureCallback).catch(mediaTestBase.catchCallback);
await videoRecorder.prepare(onlyVideoConfig).then(() => {
console.info('case recordr prepare called');
expect(videoRecorder.state).assertEqual('prepared');
- }, failureCallback).catch(catchCallback);
+ }, mediaTestBase.failureCallback).catch(mediaTestBase.catchCallback);
await videoRecorder.getInputSurface().then((outPutSurface) => {
expect(videoRecorder.state).assertEqual('prepared');
console.info('case getInputSurface called');
surfaceID = outPutSurface;
- }, failureCallback).catch(catchCallback);
+ }, mediaTestBase.failureCallback).catch(mediaTestBase.catchCallback);
videoOutput = await camera.createVideoOutput(surfaceID);
+ captureSession = await videoRecorderBase.initCaptureSession(videoOutput, cameraManager, cameras, cameraID);
await startVideoOutput(videoOutput);
await videoRecorder.start().then(() => {
expect(videoRecorder.state).assertEqual('playing');
console.info('case start called');
- sleep(RECORDER_TIME);
- }, failureCallback).catch(catchCallback);
+ mediaTestBase.msleep(RECORDER_TIME);
+ }, mediaTestBase.failureCallback).catch(mediaTestBase.catchCallback);
await videoOutput.stop();
await videoRecorder.pause().then(() => {
expect(videoRecorder.state).assertEqual('paused');
- sleep(PAUSE_TIME);
+ mediaTestBase.msleep(PAUSE_TIME);
console.info('case pause called');
- }, failureCallback).catch(catchCallback);
+ }, mediaTestBase.failureCallback).catch(mediaTestBase.catchCallback);
await videoOutput.start();
await videoRecorder.resume().then(() => {
expect(videoRecorder.state).assertEqual('playing');
- sleep(RECORDER_TIME);
+ mediaTestBase.msleep(RECORDER_TIME);
console.info('case resume called');
- }, failureCallback).catch(catchCallback);
+ }, mediaTestBase.failureCallback).catch(mediaTestBase.catchCallback);
await videoRecorder.release().then(() => {
expect(videoRecorder.state).assertEqual('idle');
console.info('case release ');
- }, failureCallback).catch(catchCallback);
- await stopVideoOutput(videoOutput);
+ }, mediaTestBase.failureCallback).catch(mediaTestBase.catchCallback);
+ await videoOutput.release().then(() => {
+ console.info('[camera] case videoOutput release success');
+ });
+ videoOutPut = undefined;
+ await videoRecorderBase.stopCaptureSession(captureSession);
+ await videoRecorderBase.checkVideos(fdPath, RECORDER_TIME * 2, trackArray, playerSurfaceId);
+ await mediaTestBase.closeFd(fdObject.fileAsset, fdObject.fdNumber);
done();
})
/* *
* @tc.number : SUB_MEDIA_VIDEO_RECORDER_FUNCTION_PROMISE_1700
* @tc.name : 17.start->stop->release (only video) (promise)
- * @tc.desc : Audio recordr control test
+ * @tc.desc : Video recordr control test
* @tc.size : MediumTest
* @tc.type : Function
* @tc.level : Level1
@@ -1161,8 +1310,10 @@ describe('VideoRecorderFuncPromiseTest', function () {
let videoRecorder = undefined;
let surfaceID = '';
let videoOutput;
- await getFd('17.mp4');
+ fdObject = await mediaTestBase.getFd('recorder_promise_17.mp4');
+ fdPath = "fd://" + fdObject.fdNumber.toString();
onlyVideoConfig.url = fdPath;
+ let trackArray = videoRecorderBase.getTrackArray(ONLYVIDEO_TYPE, onlyVideoProfile);
await media.createVideoRecorder().then((recorder) => {
console.info('case createVideoRecorder called');
if (typeof (recorder) != 'undefined') {
@@ -1171,43 +1322,50 @@ describe('VideoRecorderFuncPromiseTest', function () {
} else {
console.info('case recordr is undefined!!');
}
- }, failureCallback).catch(catchCallback);
+ }, mediaTestBase.failureCallback).catch(mediaTestBase.catchCallback);
await videoRecorder.prepare(onlyVideoConfig).then(() => {
console.info('case recordr prepare called');
expect(videoRecorder.state).assertEqual('prepared');
- }, failureCallback).catch(catchCallback);
+ }, mediaTestBase.failureCallback).catch(mediaTestBase.catchCallback);
await videoRecorder.getInputSurface().then((outPutSurface) => {
console.info('case getInputSurface called');
expect(videoRecorder.state).assertEqual('prepared');
surfaceID = outPutSurface;
- }, failureCallback).catch(catchCallback);
+ }, mediaTestBase.failureCallback).catch(mediaTestBase.catchCallback);
videoOutput = await camera.createVideoOutput(surfaceID);
+ captureSession = await videoRecorderBase.initCaptureSession(videoOutput, cameraManager, cameras, cameraID);
await startVideoOutput(videoOutput);
await videoRecorder.start().then(() => {
console.info('case start called');
expect(videoRecorder.state).assertEqual('playing');
- sleep(RECORDER_TIME);
- }, failureCallback).catch(catchCallback);
+ mediaTestBase.msleep(RECORDER_TIME);
+ }, mediaTestBase.failureCallback).catch(mediaTestBase.catchCallback);
await videoOutput.stop();
await videoRecorder.stop().then(() => {
expect(videoRecorder.state).assertEqual('stopped');
console.info('case stop called');
- }, failureCallback).catch(catchCallback);
+ }, mediaTestBase.failureCallback).catch(mediaTestBase.catchCallback);
await videoRecorder.release().then(() => {
expect(videoRecorder.state).assertEqual('idle');
console.info('case release ');
- }, failureCallback).catch(catchCallback);
- await stopVideoOutput(videoOutput);
+ }, mediaTestBase.failureCallback).catch(mediaTestBase.catchCallback);
+ await videoOutput.release().then(() => {
+ console.info('[camera] case videoOutput release success');
+ });
+ videoOutPut = undefined;
+ await videoRecorderBase.stopCaptureSession(captureSession);
+ await videoRecorderBase.checkVideos(fdPath, RECORDER_TIME, trackArray, playerSurfaceId);
+ await mediaTestBase.closeFd(fdObject.fileAsset, fdObject.fdNumber);
done();
})
/* *
* @tc.number : SUB_MEDIA_VIDEO_RECORDER_FUNCTION_PROMISE_1800
* @tc.name : 18.start->reset->release (only video) (promise)
- * @tc.desc : Audio recordr control test
+ * @tc.desc : Video recordr control test
* @tc.size : MediumTest
* @tc.type : Function
* @tc.level : Level1
@@ -1216,8 +1374,10 @@ describe('VideoRecorderFuncPromiseTest', function () {
let videoRecorder = undefined;
let surfaceID = '';
let videoOutput;
- await getFd('18.mp4');
+ fdObject = await mediaTestBase.getFd('recorder_promise_18.mp4');
+ fdPath = "fd://" + fdObject.fdNumber.toString();
onlyVideoConfig.url = fdPath;
+ let trackArray = videoRecorderBase.getTrackArray(ONLYVIDEO_TYPE, onlyVideoProfile);
await media.createVideoRecorder().then((recorder) => {
console.info('case createVideoRecorder called');
if (typeof (recorder) != 'undefined') {
@@ -1226,43 +1386,50 @@ describe('VideoRecorderFuncPromiseTest', function () {
} else {
console.info('case recordr is undefined!!');
}
- }, failureCallback).catch(catchCallback);
+ }, mediaTestBase.failureCallback).catch(mediaTestBase.catchCallback);
await videoRecorder.prepare(onlyVideoConfig).then(() => {
console.info('case recordr prepare called');
expect(videoRecorder.state).assertEqual('prepared');
- }, failureCallback).catch(catchCallback);
+ }, mediaTestBase.failureCallback).catch(mediaTestBase.catchCallback);
await videoRecorder.getInputSurface().then((outPutSurface) => {
expect(videoRecorder.state).assertEqual('prepared');
console.info('case getInputSurface called');
surfaceID = outPutSurface;
- }, failureCallback).catch(catchCallback);
+ }, mediaTestBase.failureCallback).catch(mediaTestBase.catchCallback);
videoOutput = await camera.createVideoOutput(surfaceID);
+ captureSession = await videoRecorderBase.initCaptureSession(videoOutput, cameraManager, cameras, cameraID);
await startVideoOutput(videoOutput);
await videoRecorder.start().then(() => {
console.info('case start called');
expect(videoRecorder.state).assertEqual('playing');
- sleep(RECORDER_TIME);
- }, failureCallback).catch(catchCallback);
+ mediaTestBase.msleep(RECORDER_TIME);
+ }, mediaTestBase.failureCallback).catch(mediaTestBase.catchCallback);
await videoOutput.stop();
await videoRecorder.reset().then(() => {
console.info('case reset called');
expect(videoRecorder.state).assertEqual('idle');
- }, failureCallback).catch(catchCallback);
+ }, mediaTestBase.failureCallback).catch(mediaTestBase.catchCallback);
await videoRecorder.release().then(() => {
expect(videoRecorder.state).assertEqual('idle');
console.info('case release ');
- }, failureCallback).catch(catchCallback);
- await stopVideoOutput(videoOutput);
+ }, mediaTestBase.failureCallback).catch(mediaTestBase.catchCallback);
+ await videoOutput.release().then(() => {
+ console.info('[camera] case videoOutput release success');
+ });
+ videoOutPut = undefined;
+ await videoRecorderBase.stopCaptureSession(captureSession);
+ await videoRecorderBase.checkVideos(fdPath, RECORDER_TIME, trackArray, playerSurfaceId);
+ await mediaTestBase.closeFd(fdObject.fileAsset, fdObject.fdNumber);
done();
})
/* *
* @tc.number : SUB_MEDIA_VIDEO_RECORDER_FUNCTION_PROMISE_1900
* @tc.name : 19.rotation 90 (promise)
- * @tc.desc : Audio recordr control test
+ * @tc.desc : Video recordr control test
* @tc.size : MediumTest
* @tc.type : Function
* @tc.level : Level0
@@ -1271,9 +1438,12 @@ describe('VideoRecorderFuncPromiseTest', function () {
let videoRecorder = undefined;
let surfaceID = '';
let videoOutput;
- await getFd('40.mp4');
+ fdObject = await mediaTestBase.getFd('recorder_promise_19.mp4');
+ fdPath = "fd://" + fdObject.fdNumber.toString();
videoConfig.url = fdPath;
+ configFile.audioSampleRate = 48000;
videoConfig.rotation = 90;
+ let trackArray = videoRecorderBase.getTrackArray(AUDIO_VIDEO_TYPE, configFile);
await media.createVideoRecorder().then((recorder) => {
console.info('case createVideoRecorder called');
if (typeof (recorder) != 'undefined') {
@@ -1283,35 +1453,42 @@ describe('VideoRecorderFuncPromiseTest', function () {
console.info('case recordr is undefined!!');
expect().assertFail();
}
- }, failureCallback).catch(catchCallback);
+ }, mediaTestBase.failureCallback).catch(mediaTestBase.catchCallback);
await videoRecorder.prepare(videoConfig).then(() => {
expect(videoRecorder.state).assertEqual('prepared');
- }, failureCallback).catch(catchCallback);
+ }, mediaTestBase.failureCallback).catch(mediaTestBase.catchCallback);
await videoRecorder.getInputSurface().then((outPutSurface) => {
surfaceID = outPutSurface;
- }, failureCallback).catch(catchCallback);
+ }, mediaTestBase.failureCallback).catch(mediaTestBase.catchCallback);
videoOutput = await camera.createVideoOutput(surfaceID);
+ captureSession = await videoRecorderBase.initCaptureSession(videoOutput, cameraManager, cameras, cameraID);
await startVideoOutput(videoOutput);
await videoRecorder.start().then(() => {
expect(videoRecorder.state).assertEqual('playing');
console.info('case start called');
- sleep(RECORDER_TIME);
- }, failureCallback).catch(catchCallback);
+ mediaTestBase.msleep(RECORDER_TIME);
+ }, mediaTestBase.failureCallback).catch(mediaTestBase.catchCallback);
await videoOutput.stop();
await videoRecorder.release().then(() => {
expect(videoRecorder.state).assertEqual('idle');
console.info('case release ');
- }, failureCallback).catch(catchCallback);
- await stopVideoOutput(videoOutput);
+ }, mediaTestBase.failureCallback).catch(mediaTestBase.catchCallback);
+ await videoOutput.release().then(() => {
+ console.info('[camera] case videoOutput release success');
+ });
+ videoOutPut = undefined;
+ await videoRecorderBase.stopCaptureSession(captureSession);
+ await videoRecorderBase.checkVideos(fdPath, RECORDER_TIME, trackArray, playerSurfaceId);
+ await mediaTestBase.closeFd(fdObject.fileAsset, fdObject.fdNumber);
done();
})
/* *
* @tc.number : SUB_MEDIA_VIDEO_RECORDER_FUNCTION_PROMISE_2000
* @tc.name : 20.rotation 180 (promise)
- * @tc.desc : Audio recordr control test
+ * @tc.desc : Video recordr control test
* @tc.size : MediumTest
* @tc.type : Function
* @tc.level : Level0
@@ -1320,9 +1497,11 @@ describe('VideoRecorderFuncPromiseTest', function () {
let videoRecorder = undefined;
let surfaceID = '';
let videoOutput;
- await getFd('41.mp4');
+ fdObject = await mediaTestBase.getFd('recorder_promise_20.mp4');
+ fdPath = "fd://" + fdObject.fdNumber.toString();
videoConfig.url = fdPath;
videoConfig.rotation = 180;
+ let trackArray = videoRecorderBase.getTrackArray(AUDIO_VIDEO_TYPE, configFile);
await media.createVideoRecorder().then((recorder) => {
console.info('case createVideoRecorder called');
if (typeof (recorder) != 'undefined') {
@@ -1332,35 +1511,42 @@ describe('VideoRecorderFuncPromiseTest', function () {
console.info('case recordr is undefined!!');
expect().assertFail();
}
- }, failureCallback).catch(catchCallback);
+ }, mediaTestBase.failureCallback).catch(mediaTestBase.catchCallback);
await videoRecorder.prepare(videoConfig).then(() => {
expect(videoRecorder.state).assertEqual('prepared');
- }, failureCallback).catch(catchCallback);
+ }, mediaTestBase.failureCallback).catch(mediaTestBase.catchCallback);
await videoRecorder.getInputSurface().then((outPutSurface) => {
surfaceID = outPutSurface;
- }, failureCallback).catch(catchCallback);
+ }, mediaTestBase.failureCallback).catch(mediaTestBase.catchCallback);
videoOutput = await camera.createVideoOutput(surfaceID);
+ captureSession = await videoRecorderBase.initCaptureSession(videoOutput, cameraManager, cameras, cameraID);
await startVideoOutput(videoOutput);
await videoRecorder.start().then(() => {
expect(videoRecorder.state).assertEqual('playing');
console.info('case start called');
- sleep(RECORDER_TIME);
- }, failureCallback).catch(catchCallback);
+ mediaTestBase.msleep(RECORDER_TIME);
+ }, mediaTestBase.failureCallback).catch(mediaTestBase.catchCallback);
await videoOutput.stop();
await videoRecorder.release().then(() => {
expect(videoRecorder.state).assertEqual('idle');
console.info('case release ');
- }, failureCallback).catch(catchCallback);
- await stopVideoOutput(videoOutput);
+ }, mediaTestBase.failureCallback).catch(mediaTestBase.catchCallback);
+ await videoOutput.release().then(() => {
+ console.info('[camera] case videoOutput release success');
+ });
+ videoOutPut = undefined;
+ await videoRecorderBase.stopCaptureSession(captureSession);
+ await videoRecorderBase.checkVideos(fdPath, RECORDER_TIME, trackArray, playerSurfaceId);
+ await mediaTestBase.closeFd(fdObject.fileAsset, fdObject.fdNumber);
done();
})
/* *
* @tc.number : SUB_MEDIA_VIDEO_RECORDER_FUNCTION_PROMISE_2100
* @tc.name : 21.rotation 270 (promise)
- * @tc.desc : Audio recordr control test
+ * @tc.desc : Video recordr control test
* @tc.size : MediumTest
* @tc.type : Function
* @tc.level : Level0
@@ -1369,9 +1555,11 @@ describe('VideoRecorderFuncPromiseTest', function () {
let videoRecorder = undefined;
let surfaceID = '';
let videoOutput;
- await getFd('42.mp4');
+ fdObject = await mediaTestBase.getFd('recorder_promise_21.mp4');
+ fdPath = "fd://" + fdObject.fdNumber.toString();
videoConfig.url = fdPath;
videoConfig.rotation = 270;
+ let trackArray = videoRecorderBase.getTrackArray(AUDIO_VIDEO_TYPE, configFile);
await media.createVideoRecorder().then((recorder) => {
console.info('case createVideoRecorder called');
if (typeof (recorder) != 'undefined') {
@@ -1381,35 +1569,42 @@ describe('VideoRecorderFuncPromiseTest', function () {
console.info('case recordr is undefined!!');
expect().assertFail();
}
- }, failureCallback).catch(catchCallback);
+ }, mediaTestBase.failureCallback).catch(mediaTestBase.catchCallback);
await videoRecorder.prepare(videoConfig).then(() => {
expect(videoRecorder.state).assertEqual('prepared');
- }, failureCallback).catch(catchCallback);
+ }, mediaTestBase.failureCallback).catch(mediaTestBase.catchCallback);
await videoRecorder.getInputSurface().then((outPutSurface) => {
surfaceID = outPutSurface;
- }, failureCallback).catch(catchCallback);
+ }, mediaTestBase.failureCallback).catch(mediaTestBase.catchCallback);
videoOutput = await camera.createVideoOutput(surfaceID);
+ captureSession = await videoRecorderBase.initCaptureSession(videoOutput, cameraManager, cameras, cameraID);
await startVideoOutput(videoOutput);
await videoRecorder.start().then(() => {
expect(videoRecorder.state).assertEqual('playing');
console.info('case start called');
- sleep(RECORDER_TIME);
- }, failureCallback).catch(catchCallback);
+ mediaTestBase.msleep(RECORDER_TIME);
+ }, mediaTestBase.failureCallback).catch(mediaTestBase.catchCallback);
await videoOutput.stop();
await videoRecorder.release().then(() => {
expect(videoRecorder.state).assertEqual('idle');
console.info('case release ');
- }, failureCallback).catch(catchCallback);
- await stopVideoOutput(videoOutput);
+ }, mediaTestBase.failureCallback).catch(mediaTestBase.catchCallback);
+ await videoOutput.release().then(() => {
+ console.info('[camera] case videoOutput release success');
+ });
+ videoOutPut = undefined;
+ await videoRecorderBase.stopCaptureSession(captureSession);
+ await videoRecorderBase.checkVideos(fdPath, RECORDER_TIME, trackArray, playerSurfaceId);
+ await mediaTestBase.closeFd(fdObject.fileAsset, fdObject.fdNumber);
done();
})
/* *
* @tc.number : SUB_MEDIA_VIDEO_RECORDER_FUNCTION_PROMISE_2200
* @tc.name : 22.videoFrameRate 20 (promise)
- * @tc.desc : Audio recordr control test
+ * @tc.desc : Video recordr control test
* @tc.size : MediumTest
* @tc.type : Function
* @tc.level : Level0
@@ -1418,9 +1613,11 @@ describe('VideoRecorderFuncPromiseTest', function () {
let videoRecorder = undefined;
let surfaceID = '';
let videoOutput;
- await getFd('43.mp4');
+ fdObject = await mediaTestBase.getFd('recorder_promise_22.mp4');
+ fdPath = "fd://" + fdObject.fdNumber.toString();
videoConfig.url = fdPath;
videoConfig.videoFrameRate = 20;
+ let trackArray = videoRecorderBase.getTrackArray(AUDIO_VIDEO_TYPE, configFile);
await media.createVideoRecorder().then((recorder) => {
console.info('case createVideoRecorder called');
if (typeof (recorder) != 'undefined') {
@@ -1430,35 +1627,42 @@ describe('VideoRecorderFuncPromiseTest', function () {
console.info('case recordr is undefined!!');
expect().assertFail();
}
- }, failureCallback).catch(catchCallback);
+ }, mediaTestBase.failureCallback).catch(mediaTestBase.catchCallback);
await videoRecorder.prepare(videoConfig).then(() => {
expect(videoRecorder.state).assertEqual('prepared');
- }, failureCallback).catch(catchCallback);
+ }, mediaTestBase.failureCallback).catch(mediaTestBase.catchCallback);
await videoRecorder.getInputSurface().then((outPutSurface) => {
surfaceID = outPutSurface;
- }, failureCallback).catch(catchCallback);
+ }, mediaTestBase.failureCallback).catch(mediaTestBase.catchCallback);
videoOutput = await camera.createVideoOutput(surfaceID);
+ captureSession = await videoRecorderBase.initCaptureSession(videoOutput, cameraManager, cameras, cameraID);
await startVideoOutput(videoOutput);
await videoRecorder.start().then(() => {
expect(videoRecorder.state).assertEqual('playing');
console.info('case start called');
- sleep(RECORDER_TIME);
- }, failureCallback).catch(catchCallback);
+ mediaTestBase.msleep(RECORDER_TIME);
+ }, mediaTestBase.failureCallback).catch(mediaTestBase.catchCallback);
await videoOutput.stop();
await videoRecorder.release().then(() => {
expect(videoRecorder.state).assertEqual('idle');
console.info('case release ');
- }, failureCallback).catch(catchCallback);
- await stopVideoOutput(videoOutput);
+ }, mediaTestBase.failureCallback).catch(mediaTestBase.catchCallback);
+ await videoOutput.release().then(() => {
+ console.info('[camera] case videoOutput release success');
+ });
+ videoOutPut = undefined;
+ await videoRecorderBase.stopCaptureSession(captureSession);
+ await videoRecorderBase.checkVideos(fdPath, RECORDER_TIME, trackArray, playerSurfaceId);
+ await mediaTestBase.closeFd(fdObject.fileAsset, fdObject.fdNumber);
done();
})
/* *
* @tc.number : SUB_MEDIA_VIDEO_RECORDER_FUNCTION_PROMISE_2300
* @tc.name : 23.videoFrameRate 30 (promise)
- * @tc.desc : Audio recordr control test
+ * @tc.desc : Video recordr control test
* @tc.size : MediumTest
* @tc.type : Function
* @tc.level : Level0
@@ -1467,9 +1671,11 @@ describe('VideoRecorderFuncPromiseTest', function () {
let videoRecorder = undefined;
let surfaceID = '';
let videoOutput;
- await getFd('44.mp4');
+ fdObject = await mediaTestBase.getFd('recorder_promise_23.mp4');
+ fdPath = "fd://" + fdObject.fdNumber.toString();
videoConfig.url = fdPath;
videoConfig.videoFrameRate = 30;
+ let trackArray = videoRecorderBase.getTrackArray(AUDIO_VIDEO_TYPE, configFile);
await media.createVideoRecorder().then((recorder) => {
console.info('case createVideoRecorder called');
if (typeof (recorder) != 'undefined') {
@@ -1479,35 +1685,42 @@ describe('VideoRecorderFuncPromiseTest', function () {
console.info('case recordr is undefined!!');
expect().assertFail();
}
- }, failureCallback).catch(catchCallback);
+ }, mediaTestBase.failureCallback).catch(mediaTestBase.catchCallback);
await videoRecorder.prepare(videoConfig).then(() => {
expect(videoRecorder.state).assertEqual('prepared');
- }, failureCallback).catch(catchCallback);
+ }, mediaTestBase.failureCallback).catch(mediaTestBase.catchCallback);
await videoRecorder.getInputSurface().then((outPutSurface) => {
surfaceID = outPutSurface;
- }, failureCallback).catch(catchCallback);
+ }, mediaTestBase.failureCallback).catch(mediaTestBase.catchCallback);
videoOutput = await camera.createVideoOutput(surfaceID);
+ captureSession = await videoRecorderBase.initCaptureSession(videoOutput, cameraManager, cameras, cameraID);
await startVideoOutput(videoOutput);
await videoRecorder.start().then(() => {
expect(videoRecorder.state).assertEqual('playing');
console.info('case start called');
- sleep(RECORDER_TIME);
- }, failureCallback).catch(catchCallback);
+ mediaTestBase.msleep(RECORDER_TIME);
+ }, mediaTestBase.failureCallback).catch(mediaTestBase.catchCallback);
await videoOutput.stop();
await videoRecorder.release().then(() => {
expect(videoRecorder.state).assertEqual('idle');
console.info('case release ');
- }, failureCallback).catch(catchCallback);
- await stopVideoOutput(videoOutput);
+ }, mediaTestBase.failureCallback).catch(mediaTestBase.catchCallback);
+ await videoOutput.release().then(() => {
+ console.info('[camera] case videoOutput release success');
+ });
+ videoOutPut = undefined;
+ await videoRecorderBase.stopCaptureSession(captureSession);
+ await videoRecorderBase.checkVideos(fdPath, RECORDER_TIME, trackArray, playerSurfaceId);
+ await mediaTestBase.closeFd(fdObject.fileAsset, fdObject.fdNumber);
done();
})
/* *
* @tc.number : SUB_MEDIA_VIDEO_RECORDER_FUNCTION_PROMISE_2400
* @tc.name : 24.videoFrameRate 60 (promise)
- * @tc.desc : Audio recordr control test
+ * @tc.desc : Video recordr control test
* @tc.size : MediumTest
* @tc.type : Function
* @tc.level : Level0
@@ -1516,9 +1729,11 @@ describe('VideoRecorderFuncPromiseTest', function () {
let videoRecorder = undefined;
let surfaceID = '';
let videoOutput;
- await getFd('45.mp4');
+ fdObject = await mediaTestBase.getFd('recorder_promise_24.mp4');
+ fdPath = "fd://" + fdObject.fdNumber.toString();
videoConfig.url = fdPath;
videoConfig.videoFrameRate = 60;
+ let trackArray = videoRecorderBase.getTrackArray(AUDIO_VIDEO_TYPE, configFile);
await media.createVideoRecorder().then((recorder) => {
console.info('case createVideoRecorder called');
if (typeof (recorder) != 'undefined') {
@@ -1528,28 +1743,35 @@ describe('VideoRecorderFuncPromiseTest', function () {
console.info('case recordr is undefined!!');
expect().assertFail();
}
- }, failureCallback).catch(catchCallback);
+ }, mediaTestBase.failureCallback).catch(mediaTestBase.catchCallback);
await videoRecorder.prepare(videoConfig).then(() => {
expect(videoRecorder.state).assertEqual('prepared');
- }, failureCallback).catch(catchCallback);
+ }, mediaTestBase.failureCallback).catch(mediaTestBase.catchCallback);
await videoRecorder.getInputSurface().then((outPutSurface) => {
surfaceID = outPutSurface;
- }, failureCallback).catch(catchCallback);
+ }, mediaTestBase.failureCallback).catch(mediaTestBase.catchCallback);
videoOutput = await camera.createVideoOutput(surfaceID);
+ captureSession = await videoRecorderBase.initCaptureSession(videoOutput, cameraManager, cameras, cameraID);
await startVideoOutput(videoOutput);
await videoRecorder.start().then(() => {
expect(videoRecorder.state).assertEqual('playing');
console.info('case start called');
- sleep(RECORDER_TIME);
- }, failureCallback).catch(catchCallback);
+ mediaTestBase.msleep(RECORDER_TIME);
+ }, mediaTestBase.failureCallback).catch(mediaTestBase.catchCallback);
await videoOutput.stop();
await videoRecorder.release().then(() => {
expect(videoRecorder.state).assertEqual('idle');
console.info('case release ');
- }, failureCallback).catch(catchCallback);
- await stopVideoOutput(videoOutput);
+ }, mediaTestBase.failureCallback).catch(mediaTestBase.catchCallback);
+ await videoOutput.release().then(() => {
+ console.info('[camera] case videoOutput release success');
+ });
+ videoOutPut = undefined;
+ await videoRecorderBase.stopCaptureSession(captureSession);
+ await videoRecorderBase.checkVideos(fdPath, RECORDER_TIME, trackArray, playerSurfaceId);
+ await mediaTestBase.closeFd(fdObject.fileAsset, fdObject.fdNumber);
done();
})
})