Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
OpenHarmony
Xts Acts
提交
6feebf67
X
Xts Acts
项目概览
OpenHarmony
/
Xts Acts
1 年多 前同步成功
通知
9
Star
22
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
X
Xts Acts
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
未验证
提交
6feebf67
编写于
3月 29, 2023
作者:
O
openharmony_ci
提交者:
Gitee
3月 29, 2023
浏览文件
操作
浏览文件
下载
差异文件
!8282 ActsAVPlayerTest优化 偶现fail问题修复
Merge pull request !8282 from Nicklaus/master
上级
f8cde247
1405d5cd
变更
7
隐藏空白更改
内联
并排
Showing
7 changed file
with
1336 addition
and
37 deletion
+1336
-37
multimedia/media/media_js_standard/AVPlayerTestBase.js
multimedia/media/media_js_standard/AVPlayerTestBase.js
+17
-18
multimedia/media/media_js_standard/AVRecorderTestBase.js
multimedia/media/media_js_standard/AVRecorderTestBase.js
+2
-4
multimedia/media/media_js_standard/avPlayer/Test.json
multimedia/media/media_js_standard/avPlayer/Test.json
+2
-2
multimedia/media/media_js_standard/avPlayer/entry/src/main/ets/test/AVPlayerDataSrcNoSeekAPITest.test.js
...ry/src/main/ets/test/AVPlayerDataSrcNoSeekAPITest.test.js
+823
-0
multimedia/media/media_js_standard/avPlayer/entry/src/main/ets/test/AVPlayerDataSrcNoSeekCompatibilityTest.test.js
...n/ets/test/AVPlayerDataSrcNoSeekCompatibilityTest.test.js
+205
-0
multimedia/media/media_js_standard/avPlayer/entry/src/main/ets/test/AVPlayerDataSrcNoSeekReliabilityTest.test.js
...ain/ets/test/AVPlayerDataSrcNoSeekReliabilityTest.test.js
+274
-0
multimedia/media/media_js_standard/avPlayer/entry/src/main/ets/test/AVPlayerStabilityTest.test.js
...yer/entry/src/main/ets/test/AVPlayerStabilityTest.test.js
+13
-13
未找到文件。
multimedia/media/media_js_standard/AVPlayerTestBase.js
浏览文件 @
6feebf67
...
@@ -409,7 +409,7 @@ function setAVPlayerPlayAndPauseWithCallBack(src, avPlayer, playTime, done) {
...
@@ -409,7 +409,7 @@ function setAVPlayerPlayAndPauseWithCallBack(src, avPlayer, playTime, done) {
avPlayer
.
surfaceId
=
surfaceID
;
avPlayer
.
surfaceId
=
surfaceID
;
console
.
info
(
'
playPauseLoopWithCallBack play state is INITIALIZED
'
)
console
.
info
(
'
playPauseLoopWithCallBack play state is INITIALIZED
'
)
// step 1: initialized -> prepared -> play
// step 1: initialized -> prepared -> play
preparePromise
(
avPlayer
);
await
preparePromise
(
avPlayer
);
await
sleep
(
2000
);
await
sleep
(
2000
);
avPlayer
.
play
()
avPlayer
.
play
()
break
;
break
;
...
@@ -509,18 +509,17 @@ export async function createToRelease(src, avPlayer, done) {
...
@@ -509,18 +509,17 @@ export async function createToRelease(src, avPlayer, done) {
avPlayer
=
await
idle
(
src
,
avPlayer
)
avPlayer
=
await
idle
(
src
,
avPlayer
)
await
setSource
(
avPlayer
,
src
);
await
setSource
(
avPlayer
,
src
);
console
.
info
(
'
CreateToRelease setSource
'
);
console
.
info
(
'
CreateToRelease setSource
'
);
if
(
avPlayer
.
state
==
AV_PLAYER_STATE
.
INITIALIZED
)
{
await
sleep
(
20
)
avPlayer
.
surfaceId
=
surfaceID
;
avPlayer
.
surfaceId
=
surfaceID
;
await
avPlayer
.
release
().
then
(()
=>
{
await
avPlayer
.
release
().
then
(()
=>
{
console
.
info
(
'
CreateToRelease avPlayer from stop to release
'
)
expect
(
avPlayer
.
state
).
assertEqual
(
AV_PLAYER_STATE
.
RELEASED
);
console
.
info
(
`case CreateToRelease loop is
${
i
}
`
);
console
.
info
(
'
CreateToRelease avPlayer from stop to release
'
)
expect
(
avPlayer
.
state
).
assertEqual
(
AV_PLAYER_STATE
.
RELEASED
);
console
.
info
(
`case CreateToRelease loop is
${
i
}
`
);
avPlayer
=
null
;
avPlayer
=
null
;
if
(
i
==
999
){
if
(
i
==
999
){
done
();
done
();
}
}
},
mediaTestBase
.
failureCallback
).
catch
(
mediaTestBase
.
catchCallback
);
},
mediaTestBase
.
failureCallback
).
catch
(
mediaTestBase
.
catchCallback
);
}
}
}
}
}
...
@@ -542,7 +541,7 @@ async function playToCompletedLoop(src, avPlayer, done) {
...
@@ -542,7 +541,7 @@ async function playToCompletedLoop(src, avPlayer, done) {
avPlayer
.
surfaceId
=
surfaceID
;
avPlayer
.
surfaceId
=
surfaceID
;
console
.
info
(
'
playToCompletedLoop play state is INITIALIZED
'
)
console
.
info
(
'
playToCompletedLoop play state is INITIALIZED
'
)
// step 1: initialized -> prepared -> play
// step 1: initialized -> prepared -> play
preparePromise
(
avPlayer
);
await
preparePromise
(
avPlayer
);
await
sleep
(
2000
);
await
sleep
(
2000
);
avPlayer
.
play
()
avPlayer
.
play
()
break
;
break
;
...
@@ -601,7 +600,7 @@ export async function seekLoop(src, avPlayer, done) {
...
@@ -601,7 +600,7 @@ export async function seekLoop(src, avPlayer, done) {
if
(
avPlayer
.
state
==
AV_PLAYER_STATE
.
INITIALIZED
)
{
if
(
avPlayer
.
state
==
AV_PLAYER_STATE
.
INITIALIZED
)
{
avPlayer
.
surfaceId
=
surfaceID
;
avPlayer
.
surfaceId
=
surfaceID
;
console
.
info
(
'
seekLoop case prepare success
'
);
console
.
info
(
'
seekLoop case prepare success
'
);
preparePromise
(
avPlayer
);
await
preparePromise
(
avPlayer
);
await
sleep
(
2000
);
await
sleep
(
2000
);
}
}
await
avPlayer
.
play
().
then
(()
=>
{
await
avPlayer
.
play
().
then
(()
=>
{
...
@@ -642,7 +641,7 @@ export async function seekLoopWithoutCallback(src, avPlayer, done) {
...
@@ -642,7 +641,7 @@ export async function seekLoopWithoutCallback(src, avPlayer, done) {
await
setSource
(
avPlayer
,
src
);
await
setSource
(
avPlayer
,
src
);
if
(
avPlayer
.
state
==
'
initialized
'
)
{
if
(
avPlayer
.
state
==
'
initialized
'
)
{
avPlayer
.
surfaceId
=
surfaceID
;
avPlayer
.
surfaceId
=
surfaceID
;
preparePromise
(
avPlayer
);
await
preparePromise
(
avPlayer
);
await
sleep
(
2000
);
await
sleep
(
2000
);
}
}
await
avPlayer
.
play
().
then
(()
=>
{
await
avPlayer
.
play
().
then
(()
=>
{
...
@@ -2078,7 +2077,7 @@ export async function avPlayerWithoutCallBack(src, avPlayer, done) {
...
@@ -2078,7 +2077,7 @@ export async function avPlayerWithoutCallBack(src, avPlayer, done) {
console
.
info
(
'
avPlayerWithoutCallBack setSource
'
);
console
.
info
(
'
avPlayerWithoutCallBack setSource
'
);
if
(
avPlayer
.
state
==
AV_PLAYER_STATE
.
INITIALIZED
)
{
if
(
avPlayer
.
state
==
AV_PLAYER_STATE
.
INITIALIZED
)
{
avPlayer
.
surfaceId
=
surfaceID
;
avPlayer
.
surfaceId
=
surfaceID
;
preparePromise
(
avPlayer
);
await
preparePromise
(
avPlayer
);
await
sleep
(
2000
);
await
sleep
(
2000
);
}
}
if
(
avPlayer
.
state
==
AV_PLAYER_STATE
.
PREPARED
){
if
(
avPlayer
.
state
==
AV_PLAYER_STATE
.
PREPARED
){
...
@@ -2110,7 +2109,7 @@ function setAVPlayerPlay(src, avPlayer, done) {
...
@@ -2110,7 +2109,7 @@ function setAVPlayerPlay(src, avPlayer, done) {
avPlayer
.
surfaceId
=
surfaceID
;
avPlayer
.
surfaceId
=
surfaceID
;
console
.
info
(
'
setAVPlayerPlay play state is INITIALIZED
'
)
console
.
info
(
'
setAVPlayerPlay play state is INITIALIZED
'
)
// step 1: initialized -> prepared -> play
// step 1: initialized -> prepared -> play
preparePromise
(
avPlayer
)
await
preparePromise
(
avPlayer
)
await
sleep
(
3000
);
await
sleep
(
3000
);
avPlayer
.
play
()
avPlayer
.
play
()
break
;
break
;
...
...
multimedia/media/media_js_standard/AVRecorderTestBase.js
浏览文件 @
6feebf67
...
@@ -18,15 +18,13 @@ import * as mediaTestBase from './MediaTestBase.js';
...
@@ -18,15 +18,13 @@ import * as mediaTestBase from './MediaTestBase.js';
async
function
idleCallBack
(
avRecorder
)
{
async
function
idleCallBack
(
avRecorder
)
{
console
.
info
(
'
case createAVRecorder called
'
);
console
.
info
(
'
case createAVRecorder called
'
);
await
media
.
createAVRecorder
(
).
then
((
recorder
)
=>
{
await
media
.
createAVRecorder
(
(
error
,
recorder
)
=>
{
if
(
recorder
!=
null
)
{
if
(
recorder
!=
null
)
{
avRecorder
=
recorder
;
avRecorder
=
recorder
;
console
.
info
(
'
createAVRecorder success
'
);
console
.
info
(
'
createAVRecorder success
'
);
}
else
{
}
else
{
console
.
info
(
'
createAVRecorder fail
'
);
console
.
info
(
`createAVRecorder fail, error:
${
error
}
`
);
}
}
}).
catch
((
error
)
=>
{
console
.
info
(
`createAVRecorder catchCallback, error:
${
error
}
`
);
});
});
return
avRecorder
;
return
avRecorder
;
}
}
...
...
multimedia/media/media_js_standard/avPlayer/Test.json
浏览文件 @
6feebf67
...
@@ -5,8 +5,8 @@
...
@@ -5,8 +5,8 @@
"test-timeout"
:
"180000"
,
"test-timeout"
:
"180000"
,
"bundle-name"
:
"ohos.acts.multimedia.avplayer"
,
"bundle-name"
:
"ohos.acts.multimedia.avplayer"
,
"module-name"
:
"phone"
,
"module-name"
:
"phone"
,
"shell-timeout"
:
"
5
000000"
,
"shell-timeout"
:
"
9
000000"
,
"testcase-timeout"
:
8
0
0000
"testcase-timeout"
:
8
5
0000
},
},
"kits"
:
[
"kits"
:
[
{
{
...
...
multimedia/media/media_js_standard/avPlayer/entry/src/main/ets/test/AVPlayerDataSrcNoSeekAPITest.test.js
0 → 100644
浏览文件 @
6feebf67
/*
* Copyright (C) 2023 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the 'License');
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an 'AS IS' BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import
*
as
mediaTestBase
from
'
../../../../../../MediaTestBase.js
'
;
import
media
from
'
@ohos.multimedia.media
'
import
fileio
from
'
@ohos.fileio
'
import
{
testAVPlayerFun
,
AV_PLAYER_STATE
,
setSource
}
from
'
../../../../../../AVPlayerTestBase.js
'
;
import
{
describe
,
beforeAll
,
beforeEach
,
afterEach
,
afterAll
,
it
,
expect
}
from
'
deccjsunit/index
'
;
export
default
function
AVPlayerDataSrcNoSeekAPITest
()
{
describe
(
'
AVPlayerDataSrcNoSeekAPITest
'
,
function
()
{
const
PLAY_TIME
=
1000
;
const
TAG
=
'
AVPlayerLocalAPITest:
'
;
const
CREATE_EVENT
=
'
create
'
;
const
SETURL_EVENT
=
'
setUrl
'
;
const
SETFDSRC_EVENT
=
'
setfdSrc
'
;
const
SETSOURCE_EVENT
=
'
setSource
'
;
const
SETDATASRC_NOSEEK_EVENT
=
'
setDataSourceNoseek
'
;
const
SETSURFACE_EVENT
=
'
setDisplaySurface
'
;
const
GETDESCRIPTION_PROMISE
=
'
getTrackDescriptionPromise
'
;
const
GETDESCRIPTION_CALLBACK
=
'
getTrackDescriptionCallback
'
;
const
PREPARE_EVENT
=
'
prepare
'
;
const
PLAY_EVENT
=
'
play
'
;
const
PAUSE_EVENT
=
'
pause
'
;
const
STOP_EVENT
=
'
stop
'
;
const
RESET_EVENT
=
'
reset
'
;
const
RELEASE_EVENT
=
'
release
'
;
const
SEEK_EVENT
=
'
seek
'
;
const
SEEK_FUNCTION_EVENT
=
'
seek_function
'
;
const
SPEED_FUNCTION_EVENT
=
'
speed_function
'
;
const
PLAY_FUNCTION_EVENT
=
'
play_function
'
;
const
SETVOLUME_EVENT
=
'
volume
'
;
const
SETSPEED_EVENT
=
'
speed
'
;
const
FINISH_EVENT
=
'
finish
'
;
const
ERROR_EVENT
=
'
error
'
;
const
LOOP_EVENT
=
'
loop
'
;
const
END_EVENT
=
'
end
'
;
const
DELTA_TIME
=
1000
;
let
pathDir
=
globalThis
.
abilityContext
.
filesDir
;
let
stepCount
=
0
;
let
testTag
=
'
test
'
;
let
events
=
require
(
'
events
'
);
let
eventEmitter
=
new
events
.
EventEmitter
();
let
path_mp3
=
pathDir
+
"
/01_15s.mp3
"
;
let
path_h264_mp3_ts
=
pathDir
+
"
/h264_mp3_640x480_25r.ts
"
;
let
path_mpeg4_mkv
=
pathDir
+
"
/mpeg4_none_audio.mkv
"
;
let
readAtList
=
new
Array
();
let
fdList
=
new
Array
();
let
srcList
=
new
Array
();
let
pathList
=
new
Array
();
let
avPlayer
=
null
;
let
surfaceID
=
globalThis
.
value
;
let
testCount
=
0
;
let
myStepsList
=
new
Array
();
let
myStepsNameList
=
new
Array
();
let
testFdSource
;
let
testDataSource
;
let
srcCount
=
0
;
let
duration
=
0
;
let
durationTag
=
-
100
;
let
halfDurationTag
=
-
50
;
let
speedValue
=
-
1
;
let
videoInfor
=
new
Array
({
type
:
'
video_audio
'
,
width
:
720
,
height
:
640
,
duration
:
10034
,
state
:
''
,
PREV_FRAME
:
4166
,
NEXT_FRAME
:
8333
,
},
{
type
:
'
audio
'
,
width
:
0
,
height
:
0
,
duration
:
219600
,
state
:
''
,
PREV_FRAME
:
0
,
NEXT_FRAME
:
0
,
},
{
type
:
'
video
'
,
width
:
720
,
height
:
640
,
duration
:
10034
,
state
:
''
,
PREV_FRAME
:
5000
,
NEXT_FRAME
:
10001
,
});
let
descriptionKey01
=
new
Array
([
'
bitrate
'
,
'
codec_mime
'
,
'
frame_rate
'
,
'
height
'
,
'
track_index
'
,
'
track_type
'
,
'
width
'
],
[
'
bitrate
'
,
'
channel_count
'
,
'
codec_mime
'
,
'
sample_rate
'
,
'
track_index
'
,
'
track_type
'
]);
let
descriptionValue01
=
new
Array
([
1366541
,
'
video/avc
'
,
6000
,
480
,
0
,
1
,
720
],
[
129207
,
2
,
'
audio/mp4a-latm
'
,
44100
,
1
,
0
]);
let
descriptionKey02
=
new
Array
([
'
channel_count
'
,
'
codec_mime
'
,
'
sample_rate
'
,
'
track_index
'
,
'
track_type
'
]);
let
descriptionValue02
=
new
Array
([
1
,
'
audio/mpeg
'
,
48000
,
0
,
0
]);
let
descriptionKey03
=
new
Array
([
'
bitrate
'
,
'
codec_mime
'
,
'
frame_rate
'
,
'
height
'
,
'
track_index
'
,
'
track_type
'
,
'
width
'
]);
let
descriptionValue03
=
new
Array
([
1506121
,
'
video/avc
'
,
6000
,
480
,
0
,
1
,
720
]);
let
descriptionKey
=
new
Array
(
descriptionKey01
,
descriptionKey02
,
descriptionKey03
);
let
descriptionValue
=
new
Array
(
descriptionValue01
,
descriptionValue02
,
descriptionValue03
);
beforeAll
(
async
function
()
{
console
.
info
(
'
beforeAll case
'
);
pathList
=
new
Array
(
path_mp3
,
path_h264_mp3_ts
,
path_mpeg4_mkv
);
for
(
let
i
=
0
;
i
<
pathList
.
length
;
i
++
)
{
fdList
.
push
(
fileio
.
openSync
(
pathList
[
i
],
0o0
));
readAtList
.
push
(
setReadAt
(
fdList
[
i
],
pathList
[
i
]));
srcList
.
push
(
{
fileSize
:
-
1
,
callback
:
readAtList
[
i
]}
);
console
.
info
(
'
fdList:
'
+
fdList
[
i
]);
}
})
beforeEach
(
async
function
()
{
testDataSource
=
srcList
[
0
];
srcCount
=
0
;
testCount
=
0
;
stepCount
=
0
;
console
.
info
(
'
beforeEach case
'
);
})
afterEach
(
async
function
()
{
if
(
avPlayer
!=
null
)
{
avPlayer
.
release
().
then
(()
=>
{
},
mediaTestBase
.
failureCallback
).
catch
(
mediaTestBase
.
catchCallback
);
}
avPlayer
=
null
;
console
.
info
(
'
afterEach case
'
);
})
function
setReadAt
(
fd
,
filePath
)
{
let
readAt
=
(
buf
,
length
,
pos
)
=>
{
console
.
info
(
'
readAt:
'
+
length
);
let
num
=
0
;
if
(
buf
==
undefined
||
length
==
undefined
)
{
expect
().
assertFail
();
return
-
1
;
}
if
(
pos
==
undefined
)
{
num
=
fileio
.
readSync
(
fd
,
buf
,
{
offset
:
0
,
length
:
length
});
if
(
num
==
0
)
{
fileio
.
closeSync
(
fd
);
fd
=
fileio
.
openSync
(
filePath
,
0o0
);
}
}
else
{
num
=
stream
.
readSync
(
buf
,
{
offset
:
0
,
length
:
length
,
position
:
pos
});
}
console
.
info
(
'
readAt num:
'
+
num
);
if
(
num
>
0
)
{
return
num
;
}
return
-
1
;
}
return
readAt
;
}
function
setReadAtErr
(
fd
,
filePath
)
{
let
readAt
=
(
buf
,
length
,
pos
)
=>
{
console
.
info
(
'
readAt:
'
+
length
);
let
num
=
0
;
if
(
buf
==
undefined
||
length
==
undefined
)
{
expect
().
assertFail
();
return
-
1
;
}
num
=
fileio
.
readSync
(
fd
,
buf
,
{
offset
:
1000
,
length
:
2000
});
if
(
num
==
0
)
{
fileio
.
closeSync
(
fd
);
fd
=
fileio
.
openSync
(
filePath
,
0o0
);
}
console
.
info
(
'
readAt num:
'
+
num
);
if
(
num
>
0
)
{
return
num
;
}
return
-
1
;
}
return
readAt
;
}
function
openFileFailed
()
{
console
.
info
(
'
case file fail
'
);
}
afterAll
(
async
function
()
{
console
.
info
(
'
afterAll case
'
);
for
(
let
i
=
0
;
i
<
srcList
.
length
;
i
++
)
{
fileio
.
closeSync
(
fdList
[
i
]);
}
})
async
function
setOtherCallback
(
avPlayer
,
steps
,
done
)
{
avPlayer
.
on
(
'
error
'
,
(
error
)
=>
{
console
.
error
(
TAG
+
'
error happened,message is :
'
+
error
.
message
)
if
(
steps
[
stepCount
]
==
ERROR_EVENT
)
{
stepCount
++
;
toNextStep
(
avPlayer
,
steps
,
done
);
}
else
{
expect
().
assertFail
();
steps
[
stepCount
]
=
END_EVENT
;
avPlayer
.
release
((
err
)
=>
{
if
(
err
==
undefined
)
{
console
.
info
(
TAG
+
'
release success
'
);
}
else
{
console
.
info
(
TAG
+
'
error happened, release failed,message is :
'
+
err
.
message
);
}
})
}
})
// 时间戳变化上报函数
avPlayer
.
on
(
'
timeUpdate
'
,
(
time
)
=>
{
console
.
info
(
TAG
+
'
timeUpdate called: time is :
'
+
time
)
})
// 音量变化上报函数
avPlayer
.
on
(
'
volumeChange
'
,
(
vol
)
=>
{
console
.
info
(
TAG
+
'
volumeChange success,and new volume is :
'
+
vol
)
toNextStep
(
avPlayer
,
steps
,
done
);
})
// 视频播放结束触发回调
avPlayer
.
on
(
'
endOfStream
'
,
()
=>
{
console
.
info
(
TAG
+
'
endOfStream success
'
)
})
// seek操作回调函数
avPlayer
.
on
(
'
seekDone
'
,
(
seekDoneTime
)
=>
{
console
.
info
(
TAG
+
'
seekDone success,and seek time is:
'
+
seekDoneTime
)
expect
(
seekDoneTime
).
assertEqual
(
steps
[
stepCount
-
2
]
==
durationTag
?
duration
:
steps
[
stepCount
-
2
]);
toNextStep
(
avPlayer
,
steps
,
done
);
})
// 设置倍速播放回调函数
avPlayer
.
on
(
'
speedDone
'
,
(
speed
)
=>
{
console
.
info
(
TAG
+
'
speedDone success,and speed value is:
'
+
speed
)
expect
(
speed
).
assertEqual
(
steps
[
stepCount
]);
stepCount
++
;
toNextStep
(
avPlayer
,
steps
,
done
);
})
// bitrate设置成功回调函数
avPlayer
.
on
(
'
bitrateDone
'
,
(
bitrate
)
=>
{
console
.
info
(
TAG
+
'
bitrateDone success,and bitrate value is:
'
+
bitrate
)
})
// 缓冲上报回调函数
avPlayer
.
on
(
'
bufferingUpdate
'
,
(
infoType
,
value
)
=>
{
console
.
info
(
TAG
+
'
bufferingUpdate success,and infoType value is:
'
+
infoType
+
'
, value is :
'
+
value
)
})
// duration 变化函数上报
avPlayer
.
on
(
'
durationUpdate
'
,
(
duration
)
=>
{
console
.
info
(
TAG
+
'
durationUpdate called,duration:
'
+
duration
)
})
// 首帧上报回调函数
avPlayer
.
on
(
'
startRenderFrame
'
,
()
=>
{
console
.
info
(
TAG
+
'
startRenderFrame success
'
)
})
// 视频宽高上报回调函数
avPlayer
.
on
(
'
videoSizeChange
'
,
(
width
,
height
)
=>
{
console
.
info
(
TAG
+
'
videoSizeChange success,and width is:
'
+
width
+
'
, height is :
'
+
height
)
})
// 焦点上报回调函数
avPlayer
.
on
(
'
audioInterrupt
'
,
(
info
)
=>
{
console
.
info
(
TAG
+
'
audioInterrupt success,and InterruptEvent info is:
'
+
info
)
})
// HLS上报所有支持的比特率
avPlayer
.
on
(
'
availableBitrates
'
,
(
bitrates
)
=>
{
console
.
info
(
TAG
+
'
availableBitrates success,and availableBitrates length is:
'
+
bitrates
.
length
)
})
}
// 状态机变化回调函数
async
function
setStateChangeCallback
(
avPlayer
,
steps
,
done
)
{
avPlayer
.
on
(
'
stateChange
'
,
async
(
state
,
reason
)
=>
{
switch
(
state
)
{
case
AV_PLAYER_STATE
.
IDLE
:
console
.
info
(
TAG
+
'
state idle called
'
)
break
;
case
AV_PLAYER_STATE
.
INITIALIZED
:
toNextStep
(
avPlayer
,
steps
,
done
);
console
.
info
(
TAG
+
'
state initialized called
'
)
break
;
case
AV_PLAYER_STATE
.
PREPARED
:
console
.
info
(
TAG
+
'
state prepared called
'
)
break
;
case
AV_PLAYER_STATE
.
PLAYING
:
console
.
info
(
TAG
+
'
state playing called
'
)
break
;
case
AV_PLAYER_STATE
.
PAUSED
:
console
.
info
(
TAG
+
'
state paused called
'
)
break
;
case
AV_PLAYER_STATE
.
COMPLETED
:
console
.
info
(
TAG
+
'
state completed called
'
)
toNextStep
(
avPlayer
,
steps
,
done
);
break
;
case
AV_PLAYER_STATE
.
STOPPED
:
console
.
info
(
TAG
+
'
state stopped called
'
)
break
;
case
AV_PLAYER_STATE
.
RELEASED
:
console
.
info
(
TAG
+
'
state released called
'
)
break
;
case
AV_PLAYER_STATE
.
ERROR
:
console
.
info
(
TAG
+
'
state error called
'
)
break
;
default
:
console
.
info
(
TAG
+
'
unkown state :
'
+
state
)
break
;
}
})
}
// 释放数组内存
function
deleteArrayList
()
{
for
(
let
i
=
0
;
i
<
myStepsList
.
length
;
i
++
)
{
console
.
info
(
TAG
+
'
case delete myStepsList!!
'
);
myStepsList
[
i
].
length
=
0
;
}
myStepsList
.
length
=
0
;
myStepsNameList
.
length
=
0
;
console
.
info
(
TAG
+
'
case delete myStepsNameList!!
'
);
}
// 执行下一步操作函数
async
function
toNextStep
(
avPlayer
,
steps
,
done
)
{
console
.
info
(
TAG
+
'
next step is :
'
+
steps
[
stepCount
]);
if
(
steps
[
stepCount
]
==
END_EVENT
)
{
avPlayer
=
null
;
if
((
testCount
==
myStepsList
.
length
))
{
if
(
srcCount
==
(
srcList
.
length
-
1
))
{
console
.
info
(
TAG
+
'
case success!!
'
);
deleteArrayList
();
done
();
}
else
{
stepCount
=
0
;
srcCount
++
;
testDataSource
=
srcList
[
srcCount
];
testCount
=
0
;
eventEmitter
.
emit
(
testTag
);
}
}
else
{
stepCount
=
0
;
console
.
info
(
TAG
+
'
start next step,and length is:
'
+
testCount
)
eventEmitter
.
emit
(
testTag
);
}
}
else
{
eventEmitter
.
emit
(
steps
[
stepCount
],
avPlayer
,
steps
,
done
);
}
}
// 触发create事件,创建avplayer实例对象
eventEmitter
.
on
(
CREATE_EVENT
,
(
avPlayer
,
steps
,
done
)
=>
{
stepCount
++
;
media
.
createAVPlayer
((
err
,
video
)
=>
{
if
(
video
!=
null
)
{
avPlayer
=
video
;
// 设置状态机回调函数
setStateChangeCallback
(
avPlayer
,
steps
,
done
);
setOtherCallback
(
avPlayer
,
steps
,
done
);
expect
(
avPlayer
.
state
).
assertEqual
(
'
idle
'
);
console
.
info
(
TAG
+
'
createVideoPlayer success!!
'
);
toNextStep
(
avPlayer
,
steps
,
done
);
}
else
if
((
err
!=
null
)
&&
(
steps
[
stepCount
]
==
ERROR_EVENT
))
{
stepCount
++
;
toNextStep
(
avPlayer
,
steps
,
done
);
}
else
{
mediaTestBase
.
printError
(
err
,
done
);
}
});
});
// 设置播放源,即avplayer.url的值
eventEmitter
.
on
(
SETSOURCE_EVENT
,
(
avPlayer
,
steps
,
done
)
=>
{
stepCount
++
;
avPlayer
.
url
=
steps
[
stepCount
];
stepCount
++
;
});
// 设置播放源,即avplayer.fdSrc的值
eventEmitter
.
on
(
SETFDSRC_EVENT
,
(
avPlayer
,
steps
,
done
)
=>
{
stepCount
++
;
avPlayer
.
fdSrc
=
testFdSource
;
});
// 设置播放源,即avplayer.fdSrc的值
eventEmitter
.
on
(
SETDATASRC_NOSEEK_EVENT
,
(
avPlayer
,
steps
,
done
)
=>
{
stepCount
++
;
avPlayer
.
dataSrc
=
testDataSource
;
});
// 设置surfaceID
eventEmitter
.
on
(
SETSURFACE_EVENT
,
(
avPlayer
,
steps
,
done
)
=>
{
stepCount
++
;
avPlayer
.
surfaceId
=
steps
[
stepCount
];
stepCount
++
;
toNextStep
(
avPlayer
,
steps
,
done
);
});
// prepare 操作
eventEmitter
.
on
(
PREPARE_EVENT
,
(
avPlayer
,
steps
,
done
)
=>
{
stepCount
++
;
avPlayer
.
prepare
((
err
)
=>
{
if
(
err
==
null
)
{
console
.
info
(
TAG
+
'
prepare success!!
'
);
duration
=
avPlayer
.
duration
;
toNextStep
(
avPlayer
,
steps
,
done
);
}
else
if
((
err
!=
null
)
&&
(
steps
[
stepCount
]
==
ERROR_EVENT
))
{
stepCount
++
;
console
.
info
(
TAG
+
'
prepare error happened,and message is :
'
+
err
.
message
);
toNextStep
(
avPlayer
,
steps
,
done
);
}
else
{
mediaTestBase
.
printError
(
err
,
done
);
}
});
});
// play 操作
eventEmitter
.
on
(
PLAY_EVENT
,
(
avPlayer
,
steps
,
done
)
=>
{
stepCount
++
;
avPlayer
.
play
(
async
(
err
)
=>
{
if
(
err
==
null
)
{
console
.
info
(
TAG
+
'
play success!!
'
);
await
mediaTestBase
.
msleepAsync
(
PLAY_TIME
);
toNextStep
(
avPlayer
,
steps
,
done
);
}
else
if
((
err
!=
null
)
&&
(
steps
[
stepCount
]
==
ERROR_EVENT
))
{
stepCount
++
;
console
.
info
(
TAG
+
'
play error happened,and message is :
'
+
err
.
message
);
toNextStep
(
avPlayer
,
steps
,
done
);
}
else
{
mediaTestBase
.
printError
(
err
,
done
);
}
});
});
// pause 操作
eventEmitter
.
on
(
PAUSE_EVENT
,
(
avPlayer
,
steps
,
done
)
=>
{
stepCount
++
;
avPlayer
.
pause
(
async
(
err
)
=>
{
if
(
err
==
null
)
{
console
.
info
(
TAG
+
'
pause success!!
'
);
toNextStep
(
avPlayer
,
steps
,
done
);
}
else
if
((
err
!=
null
)
&&
(
steps
[
stepCount
]
==
ERROR_EVENT
))
{
stepCount
++
;
console
.
info
(
TAG
+
'
pause error happened,and message is :
'
+
err
.
message
);
toNextStep
(
avPlayer
,
steps
,
done
);
}
else
{
mediaTestBase
.
printError
(
err
,
done
);
}
});
});
// stop 操作
eventEmitter
.
on
(
STOP_EVENT
,
(
avPlayer
,
steps
,
done
)
=>
{
stepCount
++
;
avPlayer
.
stop
(
async
(
err
)
=>
{
if
(
err
==
null
)
{
console
.
info
(
TAG
+
'
stop success!!
'
);
fileio
.
closeSync
(
fdList
[
srcCount
]);
fdList
[
srcCount
]
=
fileio
.
openSync
(
pathList
[
srcCount
],
0o0
);
toNextStep
(
avPlayer
,
steps
,
done
);
}
else
if
((
err
!=
null
)
&&
(
steps
[
stepCount
]
==
ERROR_EVENT
))
{
stepCount
++
;
console
.
info
(
TAG
+
'
stop error happened,and message is :
'
+
err
.
message
);
toNextStep
(
avPlayer
,
steps
,
done
);
}
else
{
mediaTestBase
.
printError
(
err
,
done
);
}
});
});
// reset 操作
eventEmitter
.
on
(
RESET_EVENT
,
(
avPlayer
,
steps
,
done
)
=>
{
stepCount
++
;
avPlayer
.
reset
(
async
(
err
)
=>
{
if
(
err
==
null
)
{
console
.
info
(
TAG
+
'
reset success!!
'
);
fileio
.
closeSync
(
fdList
[
srcCount
]);
fdList
[
srcCount
]
=
fileio
.
openSync
(
pathList
[
srcCount
],
0o0
);
toNextStep
(
avPlayer
,
steps
,
done
);
}
else
if
((
err
!=
null
)
&&
(
steps
[
stepCount
]
==
ERROR_EVENT
))
{
stepCount
++
;
console
.
info
(
TAG
+
'
reset error happened,and message is :
'
+
err
.
message
);
toNextStep
(
avPlayer
,
steps
,
done
);
}
else
{
mediaTestBase
.
printError
(
err
,
done
);
}
});
});
// seek 操作
eventEmitter
.
on
(
SEEK_EVENT
,
(
avPlayer
,
steps
,
done
)
=>
{
let
seekTime
=
steps
[
stepCount
+
1
];
if
(
seekTime
==
durationTag
)
{
seekTime
=
videoInfor
[
srcCount
].
duration
;
}
let
seekMode
=
steps
[
stepCount
+
2
];
stepCount
=
stepCount
+
3
avPlayer
.
seek
(
seekTime
,
seekMode
);
});
// 设置音量操作
eventEmitter
.
on
(
SETVOLUME_EVENT
,
(
avPlayer
,
steps
,
done
)
=>
{
let
volumeValue
=
steps
[
stepCount
+
1
];
stepCount
=
stepCount
+
2
;
avPlayer
.
setVolume
(
volumeValue
)
});
// 设置倍数操作
eventEmitter
.
on
(
SETSPEED_EVENT
,
(
avPlayer
,
steps
,
done
)
=>
{
let
speedValue
=
steps
[
stepCount
+
1
];
stepCount
++
;
avPlayer
.
setSpeed
(
speedValue
);
});
// 设置loop值
eventEmitter
.
on
(
LOOP_EVENT
,
(
avPlayer
,
steps
,
done
)
=>
{
let
loopValue
=
steps
[
stepCount
+
1
];
stepCount
=
stepCount
+
2
avPlayer
.
loop
=
loopValue
;
if
((
steps
[
stepCount
]
!=
ERROR_EVENT
))
{
toNextStep
(
avPlayer
,
steps
,
done
);
}
});
// 等待complete上报
eventEmitter
.
on
(
FINISH_EVENT
,
(
avPlayer
,
steps
,
done
)
=>
{
stepCount
++
console
.
info
(
TAG
+
'
wait for completed called
'
);
});
// 释放avplayer实例对象
eventEmitter
.
on
(
RELEASE_EVENT
,
(
avPlayer
,
steps
,
done
)
=>
{
stepCount
++
;
avPlayer
.
release
((
err
)
=>
{
if
(
err
==
null
)
{
console
.
info
(
TAG
+
'
release success!!
'
);
fileio
.
closeSync
(
fdList
[
srcCount
]);
fdList
[
srcCount
]
=
fileio
.
openSync
(
pathList
[
srcCount
],
0o0
);
toNextStep
(
avPlayer
,
steps
,
done
);
}
else
if
((
err
!=
null
)
&&
(
steps
[
stepCount
]
==
ERROR_EVENT
))
{
stepCount
++
;
toNextStep
(
avPlayer
,
steps
,
done
);
console
.
info
(
TAG
+
'
release failed, and message is:
'
+
err
.
message
);
}
else
{
mediaTestBase
.
printError
(
err
,
done
);
}
});
});
// function seek 调用接口: SUB_MULTIMEDIA_MEDIA_AVPLAYER_FUNCTION_SEEK
async
function
checkSeekTime
(
avPlayer
,
seekTime
,
seekMode
)
{
console
.
info
(
TAG
+
'
test currentTime is:
'
+
avPlayer
.
currentTime
);
switch
(
seekTime
)
{
case
0
:
if
(
seekMode
==
media
.
SeekMode
.
SEEK_PREV_SYNC
)
{
expect
(
avPlayer
.
currentTime
-
0
).
assertLess
(
DELTA_TIME
);
}
else
{
expect
(
avPlayer
.
currentTime
-
videoInfor
[
srcCount
].
PREV_FRAME
).
assertLess
(
DELTA_TIME
);
}
break
;
case
videoInfor
[
srcCount
].
duration
/
2
:
if
(
seekMode
==
media
.
SeekMode
.
SEEK_PREV_SYNC
)
{
expect
(
avPlayer
.
currentTime
-
videoInfor
[
srcCount
].
PREV_FRAME
).
assertLess
(
DELTA_TIME
);
}
else
{
expect
(
avPlayer
.
currentTime
-
videoInfor
[
srcCount
].
NEXT_FRAME
).
assertLess
(
DELTA_TIME
);
}
break
;
case
videoInfor
[
srcCount
].
duration
:
if
(
seekMode
==
media
.
SeekMode
.
SEEK_PREV_SYNC
)
{
expect
(
avPlayer
.
currentTime
-
videoInfor
[
srcCount
].
NEXT_FRAME
).
assertLess
(
DELTA_TIME
);
}
else
{
expect
(
avPlayer
.
currentTime
-
seekTime
).
assertLess
(
DELTA_TIME
);
}
break
;
}
}
eventEmitter
.
on
(
SEEK_FUNCTION_EVENT
,
(
avPlayer
,
steps
,
done
)
=>
{
let
seekTime
;
if
(
steps
[
stepCount
+
1
]
==
halfDurationTag
)
{
seekTime
=
videoInfor
[
srcCount
].
duration
/
2
;
}
else
if
(
steps
[
stepCount
+
1
]
==
durationTag
)
{
seekTime
=
videoInfor
[
srcCount
].
duration
;
}
else
{
seekTime
=
steps
[
stepCount
+
1
];
}
let
seekMode
=
steps
[
stepCount
+
2
];
// seek操作回调函数
avPlayer
.
on
(
'
seekDone
'
,
(
seekDoneTime
)
=>
{
console
.
info
(
TAG
+
'
seekDone success, seekTime is
'
+
seekTime
+
'
seekDoneTime time is:
'
+
seekDoneTime
);
expect
(
seekDoneTime
).
assertEqual
(
seekTime
);
if
(
videoInfor
[
srcCount
].
type
==
'
audio
'
)
{
expect
(
avPlayer
.
currentTime
-
seekDoneTime
).
assertLess
(
DELTA_TIME
);
}
else
{
checkSeekTime
(
avPlayer
,
seekTime
,
seekMode
);
}
toNextStep
(
avPlayer
,
steps
,
done
);
})
stepCount
=
stepCount
+
3
avPlayer
.
seek
(
seekTime
,
seekMode
);
});
// function speed 调用接口: SUB_MULTIMEDIA_MEDIA_AVPLAYER_FUNCTION_SPEED
function
checkSpeedTime
(
avPlayer
,
speedValue
,
startTime
)
{
let
newTime
=
avPlayer
.
currentTime
;
console
.
info
(
TAG
+
'
start checkSpeedTime 22,new time is :
'
+
newTime
);
if
(
avPlayer
.
state
==
'
playing
'
)
{
switch
(
speedValue
)
{
case
media
.
PlaybackSpeed
.
SPEED_FORWARD_0_75_X
:
console
.
error
(
'
checkSpeedTime time is :
'
+
(
newTime
-
startTime
));
expect
(
Math
.
abs
(
newTime
-
startTime
-
(
0.75
*
PLAY_TIME
))).
assertLess
(
DELTA_TIME
*
0.75
);
break
;
case
media
.
PlaybackSpeed
.
SPEED_FORWARD_1_00_X
:
console
.
error
(
'
checkSpeedTime time is :
'
+
(
newTime
-
startTime
));
expect
(
Math
.
abs
(
newTime
-
startTime
-
(
PLAY_TIME
))).
assertLess
(
DELTA_TIME
);
break
;
case
media
.
PlaybackSpeed
.
SPEED_FORWARD_1_25_X
:
console
.
error
(
'
checkSpeedTime time is :
'
+
(
newTime
-
startTime
));
expect
(
Math
.
abs
(
newTime
-
startTime
-
(
1.25
*
PLAY_TIME
))).
assertLess
(
DELTA_TIME
*
1.25
);
break
;
case
media
.
PlaybackSpeed
.
SPEED_FORWARD_1_75_X
:
console
.
error
(
'
checkSpeedTime time is :
'
+
(
newTime
-
startTime
));
expect
(
Math
.
abs
(
newTime
-
startTime
-
(
1.75
*
PLAY_TIME
))).
assertLess
(
DELTA_TIME
*
1.75
);
break
;
case
media
.
PlaybackSpeed
.
SPEED_FORWARD_2_00_X
:
console
.
error
(
'
checkSpeedTime time is :
'
+
(
newTime
-
startTime
));
expect
(
Math
.
abs
(
newTime
-
startTime
-
(
2
*
PLAY_TIME
))).
assertLess
(
DELTA_TIME
*
2
);
break
;
}
}
else
{
console
.
info
(
'
case speed not in play
'
);
}
}
eventEmitter
.
on
(
SPEED_FUNCTION_EVENT
,
(
avPlayer
,
steps
,
done
)
=>
{
let
testSpeedValue
=
steps
[
stepCount
+
1
];
stepCount
=
stepCount
+
2
;
avPlayer
.
on
(
'
speedDone
'
,
(
speed
)
=>
{
console
.
info
(
TAG
+
'
speedDone success, set speed value is
'
+
testSpeedValue
+
'
speed value is:
'
+
speed
)
expect
(
speed
).
assertEqual
(
testSpeedValue
);
speedValue
=
speed
;
toNextStep
(
avPlayer
,
steps
,
done
);
})
avPlayer
.
setSpeed
(
testSpeedValue
);
});
eventEmitter
.
on
(
PLAY_FUNCTION_EVENT
,
(
avPlayer
,
steps
,
done
)
=>
{
stepCount
++
;
avPlayer
.
play
(
async
(
err
)
=>
{
if
(
err
==
null
)
{
let
startTime
=
avPlayer
.
currentTime
;
console
.
info
(
TAG
+
'
start checkSpeedTime 11,start time is :
'
+
startTime
);
await
mediaTestBase
.
msleepAsync
(
PLAY_TIME
);
//checkSpeedTime(avPlayer, speedValue, startTime);
toNextStep
(
avPlayer
,
steps
,
done
);
}
else
if
((
err
!=
null
)
&&
(
steps
[
stepCount
]
==
ERROR_EVENT
))
{
stepCount
++
;
console
.
info
(
TAG
+
'
play error happened,and message is :
'
+
err
.
message
);
toNextStep
(
avPlayer
,
steps
,
done
);
}
else
{
mediaTestBase
.
printError
(
err
,
done
);
}
});
});
// gettreckdescription promise
eventEmitter
.
on
(
GETDESCRIPTION_PROMISE
,
async
(
avPlayer
,
steps
,
done
)
=>
{
let
arrayDescription
;
stepCount
++
;
await
avPlayer
.
getTrackDescription
().
then
((
arrayList
)
=>
{
console
.
info
(
'
case getTrackDescription called!!
'
);
if
(
typeof
(
arrayList
)
!=
'
undefined
'
)
{
arrayDescription
=
arrayList
;
expect
(
descriptionKey
[
srcCount
].
length
).
assertEqual
(
arrayDescription
.
length
);
for
(
let
i
=
0
;
i
<
arrayDescription
.
length
;
i
++
)
{
mediaTestBase
.
checkDescription
(
arrayDescription
[
i
],
descriptionKey
[
srcCount
][
i
],
descriptionValue
[
srcCount
][
i
]);
}
toNextStep
(
avPlayer
,
steps
,
done
);
}
else
{
console
.
info
(
'
case getTrackDescription is null
'
);
expect
().
assertFail
();
done
();
}
},
(
error
)
=>
{
console
.
info
(
TAG
+
'
getTrackDescription error happened,and message is :
'
+
error
.
message
);
if
(
steps
[
stepCount
]
==
ERROR_EVENT
)
{
stepCount
++
;
toNextStep
(
avPlayer
,
steps
,
done
);
}
}).
catch
(
mediaTestBase
.
catchCallback
);
});
// gettreckdescription callback
eventEmitter
.
on
(
GETDESCRIPTION_CALLBACK
,
async
(
avPlayer
,
steps
,
done
)
=>
{
stepCount
++
;
avPlayer
.
getTrackDescription
((
error
,
arrayList
)
=>
{
if
(
error
==
null
)
{
expect
(
descriptionKey
[
srcCount
].
length
).
assertEqual
(
arrayList
.
length
);
for
(
let
i
=
0
;
i
<
arrayList
.
length
;
i
++
)
{
mediaTestBase
.
checkDescription
(
arrayList
[
i
],
descriptionKey
[
srcCount
][
i
],
descriptionValue
[
srcCount
][
i
]);
}
toNextStep
(
avPlayer
,
steps
,
done
);
}
else
{
if
(
steps
[
stepCount
]
==
ERROR_EVENT
)
{
stepCount
++
;
console
.
info
(
TAG
+
'
getTrackDescription error happened,and message is :
'
+
error
.
message
);
toNextStep
(
avPlayer
,
steps
,
done
);
}
}
})
});
/* *
* @tc.number : SUB_MULTIMEDIA_MEDIA_AVPLAYER_DATASRC_NOSEEK_STATE_PREPARED
* @tc.name : 001.test prepared stateChange
* @tc.desc : Local Video playback control test
* @tc.size : MediumTest
* @tc.type : Function test
* @tc.level : Level0
*/
it
(
'
SUB_MULTIMEDIA_MEDIA_AVPLAYER_DATASRC_NOSEEK_STATE_PREPARED
'
,
0
,
async
function
(
done
)
{
testTag
=
'
test_prepared
'
;
myStepsNameList
.
push
(
"
prepared -> release (released)
"
);
myStepsList
.
push
(
new
Array
(
CREATE_EVENT
,
SETDATASRC_NOSEEK_EVENT
,
SETSURFACE_EVENT
,
surfaceID
,
PREPARE_EVENT
,
RELEASE_EVENT
,
END_EVENT
));
myStepsNameList
.
push
(
"
prepared -> reset -> setDataSource (initialized)
"
);
myStepsList
.
push
(
new
Array
(
CREATE_EVENT
,
SETDATASRC_NOSEEK_EVENT
,
SETSURFACE_EVENT
,
surfaceID
,
PREPARE_EVENT
,
RESET_EVENT
,
SETDATASRC_NOSEEK_EVENT
,
RELEASE_EVENT
,
END_EVENT
));
myStepsNameList
.
push
(
"
prepared -> reset -> released (released)
"
);
myStepsList
.
push
(
new
Array
(
CREATE_EVENT
,
SETDATASRC_NOSEEK_EVENT
,
SETSURFACE_EVENT
,
surfaceID
,
PREPARE_EVENT
,
RESET_EVENT
,
RELEASE_EVENT
,
END_EVENT
));
myStepsNameList
.
push
(
"
prepared -> reset -> prepare (error)
"
);
myStepsList
.
push
(
new
Array
(
CREATE_EVENT
,
SETDATASRC_NOSEEK_EVENT
,
SETSURFACE_EVENT
,
surfaceID
,
PREPARE_EVENT
,
RESET_EVENT
,
PREPARE_EVENT
,
ERROR_EVENT
,
RELEASE_EVENT
,
END_EVENT
));
myStepsNameList
.
push
(
"
prepared -> reset -> play (error)
"
);
myStepsList
.
push
(
new
Array
(
CREATE_EVENT
,
SETDATASRC_NOSEEK_EVENT
,
SETSURFACE_EVENT
,
surfaceID
,
PREPARE_EVENT
,
RESET_EVENT
,
PLAY_EVENT
,
ERROR_EVENT
,
RELEASE_EVENT
,
END_EVENT
));
myStepsNameList
.
push
(
"
prepared -> reset -> pause (error)
"
);
myStepsList
.
push
(
new
Array
(
CREATE_EVENT
,
SETDATASRC_NOSEEK_EVENT
,
SETSURFACE_EVENT
,
surfaceID
,
PREPARE_EVENT
,
RESET_EVENT
,
PAUSE_EVENT
,
ERROR_EVENT
,
RELEASE_EVENT
,
END_EVENT
));
myStepsNameList
.
push
(
"
prepared -> reset -> stop (error)
"
);
myStepsList
.
push
(
new
Array
(
CREATE_EVENT
,
SETDATASRC_NOSEEK_EVENT
,
SETSURFACE_EVENT
,
surfaceID
,
PREPARE_EVENT
,
RESET_EVENT
,
STOP_EVENT
,
ERROR_EVENT
,
RELEASE_EVENT
,
END_EVENT
));
myStepsNameList
.
push
(
"
prepared -> reset -> seek (error)
"
);
myStepsList
.
push
(
new
Array
(
CREATE_EVENT
,
SETDATASRC_NOSEEK_EVENT
,
SETSURFACE_EVENT
,
surfaceID
,
PREPARE_EVENT
,
RESET_EVENT
,
SEEK_EVENT
,
5000
,
media
.
SeekMode
.
SEEK_NEXT_SYNC
,
ERROR_EVENT
,
RELEASE_EVENT
,
END_EVENT
));
myStepsNameList
.
push
(
"
prepared -> reset -> setsurfaceID (error)
"
);
myStepsList
.
push
(
new
Array
(
CREATE_EVENT
,
SETDATASRC_NOSEEK_EVENT
,
SETSURFACE_EVENT
,
surfaceID
,
PREPARE_EVENT
,
RESET_EVENT
,
SETSURFACE_EVENT
,
surfaceID
,
ERROR_EVENT
,
RELEASE_EVENT
,
END_EVENT
));
myStepsNameList
.
push
(
"
prepared -> reset -> reset (idle)
"
);
myStepsList
.
push
(
new
Array
(
CREATE_EVENT
,
SETDATASRC_NOSEEK_EVENT
,
SETSURFACE_EVENT
,
surfaceID
,
PREPARE_EVENT
,
RESET_EVENT
,
RESET_EVENT
,
RELEASE_EVENT
,
END_EVENT
));
myStepsNameList
.
push
(
"
prepared -> seek(error) -> release (released)
"
);
myStepsList
.
push
(
new
Array
(
CREATE_EVENT
,
SETDATASRC_NOSEEK_EVENT
,
SETSURFACE_EVENT
,
surfaceID
,
PREPARE_EVENT
,
SEEK_EVENT
,
5000
,
media
.
SeekMode
.
SEEK_NEXT_SYNC
,
ERROR_EVENT
,
RELEASE_EVENT
,
END_EVENT
));
myStepsNameList
.
push
(
"
prepared -> seek(error) -> reset (idle)
"
);
myStepsList
.
push
(
new
Array
(
CREATE_EVENT
,
SETDATASRC_NOSEEK_EVENT
,
SETSURFACE_EVENT
,
surfaceID
,
PREPARE_EVENT
,
SEEK_EVENT
,
5000
,
media
.
SeekMode
.
SEEK_NEXT_SYNC
,
ERROR_EVENT
,
RESET_EVENT
,
RELEASE_EVENT
,
END_EVENT
));
myStepsNameList
.
push
(
"
prepared -> seek(error) -> seek (prepared)
"
);
myStepsList
.
push
(
new
Array
(
CREATE_EVENT
,
SETDATASRC_NOSEEK_EVENT
,
SETSURFACE_EVENT
,
surfaceID
,
PREPARE_EVENT
,
SEEK_EVENT
,
5000
,
media
.
SeekMode
.
SEEK_NEXT_SYNC
,
ERROR_EVENT
,
SEEK_EVENT
,
8000
,
media
.
SeekMode
.
SEEK_NEXT_SYNC
,
ERROR_EVENT
,
RELEASE_EVENT
,
END_EVENT
));
myStepsNameList
.
push
(
"
prepared -> seek(error) -> play (playing)
"
);
myStepsList
.
push
(
new
Array
(
CREATE_EVENT
,
SETDATASRC_NOSEEK_EVENT
,
SETSURFACE_EVENT
,
surfaceID
,
PREPARE_EVENT
,
SEEK_EVENT
,
5000
,
media
.
SeekMode
.
SEEK_NEXT_SYNC
,
ERROR_EVENT
,
PLAY_EVENT
,
RELEASE_EVENT
,
END_EVENT
));
myStepsNameList
.
push
(
"
prepared -> seek(error) -> stop (stopped)
"
);
myStepsList
.
push
(
new
Array
(
CREATE_EVENT
,
SETDATASRC_NOSEEK_EVENT
,
SETSURFACE_EVENT
,
surfaceID
,
PREPARE_EVENT
,
SEEK_EVENT
,
5000
,
media
.
SeekMode
.
SEEK_NEXT_SYNC
,
ERROR_EVENT
,
STOP_EVENT
,
RELEASE_EVENT
,
END_EVENT
));
myStepsNameList
.
push
(
"
prepared -> seek -> prepared (error)
"
);
myStepsList
.
push
(
new
Array
(
CREATE_EVENT
,
SETDATASRC_NOSEEK_EVENT
,
SETSURFACE_EVENT
,
surfaceID
,
PREPARE_EVENT
,
SEEK_EVENT
,
5000
,
media
.
SeekMode
.
SEEK_NEXT_SYNC
,
ERROR_EVENT
,
PREPARE_EVENT
,
RELEASE_EVENT
,
END_EVENT
));
myStepsNameList
.
push
(
"
prepared -> play -> release (released)
"
);
myStepsList
.
push
(
new
Array
(
CREATE_EVENT
,
SETDATASRC_NOSEEK_EVENT
,
SETSURFACE_EVENT
,
surfaceID
,
PREPARE_EVENT
,
PLAY_EVENT
,
RELEASE_EVENT
,
END_EVENT
));
myStepsNameList
.
push
(
"
prepared -> play -> reset (idle)
"
);
myStepsList
.
push
(
new
Array
(
CREATE_EVENT
,
SETDATASRC_NOSEEK_EVENT
,
SETSURFACE_EVENT
,
surfaceID
,
PREPARE_EVENT
,
PLAY_EVENT
,
RESET_EVENT
,
RELEASE_EVENT
,
END_EVENT
));
myStepsNameList
.
push
(
"
prepared -> play -> seek (prepared)
"
);
myStepsList
.
push
(
new
Array
(
CREATE_EVENT
,
SETDATASRC_NOSEEK_EVENT
,
SETSURFACE_EVENT
,
surfaceID
,
PREPARE_EVENT
,
PLAY_EVENT
,
SEEK_EVENT
,
5000
,
media
.
SeekMode
.
SEEK_NEXT_SYNC
,
ERROR_EVENT
,
RELEASE_EVENT
,
END_EVENT
));
myStepsNameList
.
push
(
"
prepared -> play -> stop (stopped)
"
);
myStepsList
.
push
(
new
Array
(
CREATE_EVENT
,
SETDATASRC_NOSEEK_EVENT
,
SETSURFACE_EVENT
,
surfaceID
,
PREPARE_EVENT
,
PLAY_EVENT
,
STOP_EVENT
,
RELEASE_EVENT
,
END_EVENT
));
myStepsNameList
.
push
(
"
prepared -> play -> pause (paused)
"
);
myStepsList
.
push
(
new
Array
(
CREATE_EVENT
,
SETDATASRC_NOSEEK_EVENT
,
SETSURFACE_EVENT
,
surfaceID
,
PREPARE_EVENT
,
PLAY_EVENT
,
PAUSE_EVENT
,
RELEASE_EVENT
,
END_EVENT
));
myStepsNameList
.
push
(
"
prepared -> play(loop = 0) -> eos (completed)
"
);
myStepsList
.
push
(
new
Array
(
CREATE_EVENT
,
SETDATASRC_NOSEEK_EVENT
,
SETSURFACE_EVENT
,
surfaceID
,
PREPARE_EVENT
,
LOOP_EVENT
,
false
,
ERROR_EVENT
,
PLAY_EVENT
,
FINISH_EVENT
,
RELEASE_EVENT
,
END_EVENT
));
myStepsNameList
.
push
(
"
prepared -> play -> setSource (error)
"
);
myStepsList
.
push
(
new
Array
(
CREATE_EVENT
,
SETDATASRC_NOSEEK_EVENT
,
SETSURFACE_EVENT
,
surfaceID
,
PREPARE_EVENT
,
PLAY_EVENT
,
SETDATASRC_NOSEEK_EVENT
,
ERROR_EVENT
,
RELEASE_EVENT
,
END_EVENT
));
myStepsNameList
.
push
(
"
prepared -> play -> prepare (error)
"
);
myStepsList
.
push
(
new
Array
(
CREATE_EVENT
,
SETDATASRC_NOSEEK_EVENT
,
SETSURFACE_EVENT
,
surfaceID
,
PREPARE_EVENT
,
PLAY_EVENT
,
PREPARE_EVENT
,
ERROR_EVENT
,
RELEASE_EVENT
,
END_EVENT
));
myStepsNameList
.
push
(
"
prepared -> play -> surfaceid (error)
"
);
myStepsList
.
push
(
new
Array
(
CREATE_EVENT
,
SETDATASRC_NOSEEK_EVENT
,
SETSURFACE_EVENT
,
surfaceID
,
PREPARE_EVENT
,
PLAY_EVENT
,
SETSURFACE_EVENT
,
surfaceID
,
ERROR_EVENT
,
RELEASE_EVENT
,
END_EVENT
));
myStepsNameList
.
push
(
"
prepared -> play -> play (playing)
"
);
myStepsList
.
push
(
new
Array
(
CREATE_EVENT
,
SETDATASRC_NOSEEK_EVENT
,
SETSURFACE_EVENT
,
surfaceID
,
PREPARE_EVENT
,
PLAY_EVENT
,
PLAY_EVENT
,
RELEASE_EVENT
,
END_EVENT
));
myStepsNameList
.
push
(
"
prepared -> stop -> release (released)
"
);
myStepsList
.
push
(
new
Array
(
CREATE_EVENT
,
SETDATASRC_NOSEEK_EVENT
,
SETSURFACE_EVENT
,
surfaceID
,
PREPARE_EVENT
,
STOP_EVENT
,
RELEASE_EVENT
,
END_EVENT
));
myStepsNameList
.
push
(
"
prepared -> stop -> reset (idle)
"
);
myStepsList
.
push
(
new
Array
(
CREATE_EVENT
,
SETDATASRC_NOSEEK_EVENT
,
SETSURFACE_EVENT
,
surfaceID
,
PREPARE_EVENT
,
STOP_EVENT
,
RESET_EVENT
,
RELEASE_EVENT
,
END_EVENT
));
myStepsNameList
.
push
(
"
prepared -> stop -> prepare (prepared)
"
);
myStepsList
.
push
(
new
Array
(
CREATE_EVENT
,
SETDATASRC_NOSEEK_EVENT
,
SETSURFACE_EVENT
,
surfaceID
,
PREPARE_EVENT
,
STOP_EVENT
,
PREPARE_EVENT
,
RELEASE_EVENT
,
END_EVENT
));
myStepsNameList
.
push
(
"
prepared -> stop -> setSource (error)
"
);
myStepsList
.
push
(
new
Array
(
CREATE_EVENT
,
SETDATASRC_NOSEEK_EVENT
,
SETSURFACE_EVENT
,
surfaceID
,
PREPARE_EVENT
,
STOP_EVENT
,
SETDATASRC_NOSEEK_EVENT
,
ERROR_EVENT
,
RELEASE_EVENT
,
END_EVENT
));
myStepsNameList
.
push
(
"
prepared -> stop -> play (error)
"
);
myStepsList
.
push
(
new
Array
(
CREATE_EVENT
,
SETDATASRC_NOSEEK_EVENT
,
SETSURFACE_EVENT
,
surfaceID
,
PREPARE_EVENT
,
STOP_EVENT
,
PLAY_EVENT
,
ERROR_EVENT
,
RELEASE_EVENT
,
END_EVENT
));
myStepsNameList
.
push
(
"
prepared -> stop -> pause (error)
"
);
myStepsList
.
push
(
new
Array
(
CREATE_EVENT
,
SETDATASRC_NOSEEK_EVENT
,
SETSURFACE_EVENT
,
surfaceID
,
PREPARE_EVENT
,
STOP_EVENT
,
PAUSE_EVENT
,
ERROR_EVENT
,
RELEASE_EVENT
,
END_EVENT
));
myStepsNameList
.
push
(
"
prepared -> stop -> seek (error)
"
);
myStepsList
.
push
(
new
Array
(
CREATE_EVENT
,
SETDATASRC_NOSEEK_EVENT
,
SETSURFACE_EVENT
,
surfaceID
,
PREPARE_EVENT
,
STOP_EVENT
,
SEEK_EVENT
,
5000
,
media
.
SeekMode
.
SEEK_NEXT_SYNC
,
ERROR_EVENT
,
RELEASE_EVENT
,
END_EVENT
));
myStepsNameList
.
push
(
"
prepared -> stop -> surfaceid (error)
"
);
myStepsList
.
push
(
new
Array
(
CREATE_EVENT
,
SETDATASRC_NOSEEK_EVENT
,
SETSURFACE_EVENT
,
surfaceID
,
PREPARE_EVENT
,
STOP_EVENT
,
SETSURFACE_EVENT
,
surfaceID
,
ERROR_EVENT
,
RELEASE_EVENT
,
END_EVENT
));
myStepsNameList
.
push
(
"
prepared -> stop -> stop (stopped)
"
);
myStepsList
.
push
(
new
Array
(
CREATE_EVENT
,
SETDATASRC_NOSEEK_EVENT
,
SETSURFACE_EVENT
,
surfaceID
,
PREPARE_EVENT
,
STOP_EVENT
,
STOP_EVENT
,
RELEASE_EVENT
,
END_EVENT
));
myStepsNameList
.
push
(
"
prepared -> url -> release (released)
"
);
myStepsList
.
push
(
new
Array
(
CREATE_EVENT
,
SETDATASRC_NOSEEK_EVENT
,
SETSURFACE_EVENT
,
surfaceID
,
PREPARE_EVENT
,
SETDATASRC_NOSEEK_EVENT
,
ERROR_EVENT
,
RELEASE_EVENT
,
END_EVENT
));
myStepsNameList
.
push
(
"
prepared -> url -> reset (idle)
"
);
myStepsList
.
push
(
new
Array
(
CREATE_EVENT
,
SETDATASRC_NOSEEK_EVENT
,
SETSURFACE_EVENT
,
surfaceID
,
PREPARE_EVENT
,
SETDATASRC_NOSEEK_EVENT
,
ERROR_EVENT
,
RESET_EVENT
,
RELEASE_EVENT
,
END_EVENT
));
myStepsNameList
.
push
(
"
prepared -> pause -> release (released)
"
);
myStepsList
.
push
(
new
Array
(
CREATE_EVENT
,
SETDATASRC_NOSEEK_EVENT
,
SETSURFACE_EVENT
,
surfaceID
,
PREPARE_EVENT
,
PAUSE_EVENT
,
ERROR_EVENT
,
RELEASE_EVENT
,
END_EVENT
));
myStepsNameList
.
push
(
"
prepared -> pause -> reset (idle)
"
);
myStepsList
.
push
(
new
Array
(
CREATE_EVENT
,
SETDATASRC_NOSEEK_EVENT
,
SETSURFACE_EVENT
,
surfaceID
,
PREPARE_EVENT
,
PAUSE_EVENT
,
ERROR_EVENT
,
RESET_EVENT
,
RELEASE_EVENT
,
END_EVENT
));
myStepsNameList
.
push
(
"
prepared -> surfaceid -> release (released)
"
);
myStepsList
.
push
(
new
Array
(
CREATE_EVENT
,
SETDATASRC_NOSEEK_EVENT
,
SETSURFACE_EVENT
,
surfaceID
,
PREPARE_EVENT
,
SETSURFACE_EVENT
,
surfaceID
,
ERROR_EVENT
,
RELEASE_EVENT
,
END_EVENT
));
myStepsNameList
.
push
(
"
prepared -> surfaceid -> reset (idle)
"
);
myStepsList
.
push
(
new
Array
(
CREATE_EVENT
,
SETDATASRC_NOSEEK_EVENT
,
SETSURFACE_EVENT
,
surfaceID
,
PREPARE_EVENT
,
SETSURFACE_EVENT
,
surfaceID
,
ERROR_EVENT
,
RESET_EVENT
,
RELEASE_EVENT
,
END_EVENT
));
myStepsNameList
.
push
(
"
prepared -> prepared -> release (released)
"
);
myStepsList
.
push
(
new
Array
(
CREATE_EVENT
,
SETDATASRC_NOSEEK_EVENT
,
SETSURFACE_EVENT
,
surfaceID
,
PREPARE_EVENT
,
PREPARE_EVENT
,
RELEASE_EVENT
,
END_EVENT
));
myStepsNameList
.
push
(
"
prepared -> prepared -> reset (idle)
"
);
myStepsList
.
push
(
new
Array
(
CREATE_EVENT
,
SETDATASRC_NOSEEK_EVENT
,
SETSURFACE_EVENT
,
surfaceID
,
PREPARE_EVENT
,
PREPARE_EVENT
,
RESET_EVENT
,
RELEASE_EVENT
,
END_EVENT
));
eventEmitter
.
on
(
'
test_prepared
'
,
()
=>
{
console
.
info
(
TAG
+
'
**************************test video or audio name is :
'
+
pathList
[
srcCount
]
+
'
*****************
'
);
console
.
info
(
TAG
+
'
**************************this is state playing test:
'
+
(
testCount
+
1
)
+
'
testcase start****************
'
);
console
.
info
(
TAG
+
'
**************************this is state playing test:
'
+
myStepsNameList
[
testCount
]
+
'
****************
'
);
let
avPlayer
=
null
;
eventEmitter
.
emit
(
myStepsList
[
testCount
][
stepCount
],
avPlayer
,
myStepsList
[
testCount
],
done
);
testCount
++
;
});
eventEmitter
.
emit
(
testTag
);
})
})
}
multimedia/media/media_js_standard/avPlayer/entry/src/main/ets/test/AVPlayerDataSrcNoSeekCompatibilityTest.test.js
0 → 100644
浏览文件 @
6feebf67
/*
* Copyright (C) 2023 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import
media
from
'
@ohos.multimedia.media
'
import
fileio
from
'
@ohos.fileio
'
import
{
testAVPlayerDataSrcNoSeek
,
testAVPlayerFun
}
from
'
../../../../../../AVPlayerTestBase.js
'
;
import
*
as
mediaTestBase
from
'
../../../../../../MediaTestBase.js
'
;
import
{
describe
,
beforeAll
,
beforeEach
,
afterEach
,
afterAll
,
it
,
expect
}
from
'
deccjsunit/index
'
;
export
default
function
AVPlayerDataSrcNoSeekCompatibilityTest
()
{
describe
(
'
AVPlayerDataSrcNoSeekCompatibilityTest
'
,
function
()
{
const
PLAY_TIME
=
3000
;
let
avPlayer
=
null
;
let
avPlayTest
=
{
width
:
0
,
height
:
0
,
duration
:
-
1
,
}
let
pathDir
=
globalThis
.
abilityContext
.
filesDir
;
let
filePath
=
pathDir
+
"
/01.mp3
"
;
let
stream
=
null
;
let
fd
=
null
;
let
srcNoSeek
=
{
fileSize
:
-
1
,
callback
:
readAtNoSeek
}
beforeAll
(
async
function
()
{
console
.
info
(
'
beforeAll case
'
);
})
beforeEach
(
async
function
()
{
console
.
info
(
'
beforeEach case
'
);
})
afterEach
(
async
function
()
{
console
.
info
(
'
afterEach case
'
);
})
afterAll
(
async
function
()
{
console
.
info
(
'
afterAll case
'
);
if
(
avPlayer
!=
null
)
{
avPlayer
.
release
().
then
(()
=>
{
},
mediaTestBase
.
failureCallback
).
catch
(
mediaTestBase
.
catchCallback
);
}
})
function
readAtNoSeek
(
buf
,
length
)
{
console
.
info
(
'
readAt length:
'
+
length
);
let
num
=
0
;
if
(
buf
==
undefined
||
length
==
undefined
)
{
expect
().
assertFail
();
return
-
1
;
}
num
=
fileio
.
readSync
(
fd
,
buf
,
{
offset
:
0
,
length
:
length
});
console
.
info
(
'
case readAt num:
'
+
num
);
if
(
num
==
0
)
{
fileio
.
closeSync
(
fd
);
fd
=
fileio
.
openSync
(
filePath
,
0o0
);
}
if
(
num
>
0
)
{
return
num
;
}
return
-
1
;
}
/* *
* @tc.number : SUB_MULTIMEDIA_MEDIA_AVPLAYER_DATASRC_NOSEEK_MP3_0100
* @tc.name : 0100.mp3
* @tc.desc : data source compatibility test
* @tc.size : MediumTest
* @tc.type : compatibility test
* @tc.level : Level0
*/
it
(
'
SUB_MULTIMEDIA_MEDIA_AVPLAYER_DATASRC_NOSEEK_MP3_0100
'
,
0
,
async
function
(
done
)
{
filePath
=
pathDir
+
"
/01_15s.mp3
"
;
console
.
info
(
`case filePath is
${
filePath
}
`
);
fd
=
fileio
.
openSync
(
filePath
,
0o0
);
avPlayTest
=
{
width
:
0
,
height
:
0
,
duration
:
0
};
await
testAVPlayerDataSrcNoSeek
(
srcNoSeek
,
avPlayer
,
avPlayTest
,
PLAY_TIME
,
done
);
})
/* *
* @tc.number : SUB_MULTIMEDIA_MEDIA_AVPLAYER_DATASRC_NOSEEK_AAC_0100
* @tc.name : 0100.aac_48ksr_16kbr_1ch
* @tc.desc : data source compatibility test
* @tc.size : MediumTest
* @tc.type : compatibility test
* @tc.level : Level0
*/
it
(
'
SUB_MULTIMEDIA_MEDIA_AVPLAYER_DATASRC_NOSEEK_AAC_0100
'
,
0
,
async
function
(
done
)
{
filePath
=
pathDir
+
"
/aac_48ksr_16kbr_1ch.aac
"
;
console
.
info
(
`case filePath is
${
filePath
}
`
);
fd
=
fileio
.
openSync
(
filePath
,
0o0
);
avPlayTest
=
{
width
:
0
,
height
:
0
,
duration
:
0
};
await
testAVPlayerDataSrcNoSeek
(
srcNoSeek
,
avPlayer
,
avPlayTest
,
PLAY_TIME
,
done
);
})
/* *
* @tc.number : SUB_MULTIMEDIA_MEDIA_AVPLAYER_DATASRC_NOSEEK_OGG_0100
* @tc.name : 0100.vorbis_48ksr_32kbr_1ch
* @tc.desc : data source compatibility test
* @tc.size : MediumTest
* @tc.type : compatibility test
* @tc.level : Level1
*/
it
(
'
SUB_MULTIMEDIA_MEDIA_AVPLAYER_DATASRC_NOSEEK_OGG_0100
'
,
0
,
async
function
(
done
)
{
filePath
=
pathDir
+
"
/vorbis_48ksr_32kbr_1ch.ogg
"
;
console
.
info
(
`case filePath is
${
filePath
}
`
);
fd
=
fileio
.
openSync
(
filePath
,
0o0
);
avPlayTest
=
{
width
:
0
,
height
:
0
,
duration
:
0
};
await
testAVPlayerDataSrcNoSeek
(
srcNoSeek
,
avPlayer
,
avPlayTest
,
PLAY_TIME
,
done
);
})
/* *
* @tc.number : SUB_MULTIMEDIA_MEDIA_AVPLAYER_DATASRC_NOSEEK_WAV_0100
* @tc.name : 0100.pcm_96ksr_64kbr_2ch
* @tc.desc : data source compatibility test
* @tc.size : MediumTest
* @tc.type : compatibility test
* @tc.level : Level1
*/
it
(
'
SUB_MULTIMEDIA_MEDIA_AVPLAYER_DATASRC_NOSEEK_WAV_0100
'
,
0
,
async
function
(
done
)
{
filePath
=
pathDir
+
"
/pcm_96ksr_64kbr_2ch.wav
"
;
console
.
info
(
`case filePath is
${
filePath
}
`
);
fd
=
fileio
.
openSync
(
filePath
,
0o0
);
avPlayTest
=
{
width
:
0
,
height
:
0
,
duration
:
0
};
await
testAVPlayerDataSrcNoSeek
(
srcNoSeek
,
avPlayer
,
avPlayTest
,
PLAY_TIME
,
done
);
})
/* *
* @tc.number : SUB_MULTIMEDIA_MEDIA_AVPLAYER_DATASRC_NOSEEK_FLAC_0100
* @tc.name : 0100.flac_48ksr_32kbr_2ch
* @tc.desc : data source compatibility test
* @tc.size : MediumTest
* @tc.type : compatibility test
* @tc.level : Level1
*/
it
(
'
SUB_MULTIMEDIA_MEDIA_AVPLAYER_DATASRC_NOSEEK_FLAC_0100
'
,
0
,
async
function
(
done
)
{
filePath
=
pathDir
+
"
/flac_48ksr_32kbr_2ch.flac
"
;
console
.
info
(
`case filePath is
${
filePath
}
`
);
fd
=
fileio
.
openSync
(
filePath
,
0o0
);
avPlayTest
=
{
width
:
0
,
height
:
0
,
duration
:
0
};
await
testAVPlayerDataSrcNoSeek
(
srcNoSeek
,
avPlayer
,
avPlayTest
,
PLAY_TIME
,
done
);
})
/* *
* @tc.number : SUB_MULTIMEDIA_MEDIA_AVPLAYER_DATASRC_NOSEEK_MKV_0100
* @tc.name : 0100.mpeg4_aac_1080p_60r.mkv
* @tc.desc : data source compatibility test
* @tc.size : MediumTest
* @tc.type : compatibility test
* @tc.level : Level1
*/
it
(
'
SUB_MULTIMEDIA_MEDIA_AVPLAYER_DATASRC_NOSEEK_MKV_0100
'
,
0
,
async
function
(
done
)
{
filePath
=
pathDir
+
"
/mpeg4_aac_1080p_60r.mkv
"
;
console
.
info
(
`case filePath is
${
filePath
}
`
);
fd
=
fileio
.
openSync
(
filePath
,
0o0
);
avPlayTest
=
{
width
:
1920
,
height
:
1080
,
duration
:
0
};
await
testAVPlayerDataSrcNoSeek
(
srcNoSeek
,
avPlayer
,
avPlayTest
,
PLAY_TIME
,
done
);
})
/* *
* @tc.number : SUB_MULTIMEDIA_MEDIA_AVPLAYER_DATASRC_NOSEEK_WEBM_0100
* @tc.name : 0100.vp8_vorbis_270p_10r.webm
* @tc.desc : data source compatibility test
* @tc.size : MediumTest
* @tc.type : compatibility test
* @tc.level : Level1
*/
it
(
'
SUB_MULTIMEDIA_MEDIA_AVPLAYER_DATASRC_NOSEEK_WEBM_0100
'
,
0
,
async
function
(
done
)
{
filePath
=
pathDir
+
"
/vp8_vorbis_270p_10r.webm
"
;
console
.
info
(
`case filePath is
${
filePath
}
`
);
fd
=
fileio
.
openSync
(
filePath
,
0o0
);
avPlayTest
=
{
width
:
360
,
height
:
270
,
duration
:
0
};
await
testAVPlayerDataSrcNoSeek
(
srcNoSeek
,
avPlayer
,
avPlayTest
,
PLAY_TIME
,
done
);
})
/* *
* @tc.number : SUB_MULTIMEDIA_MEDIA_AVPLAYER_DATASRC_NOSEEK_TS_0100
* @tc.name : 0100.h264_aac_640x480_30r.ts
* @tc.desc : data source compatibility test
* @tc.size : MediumTest
* @tc.type : compatibility test
* @tc.level : Level1
*/
it
(
'
SUB_MULTIMEDIA_MEDIA_AVPLAYER_DATASRC_NOSEEK_TS_0100
'
,
0
,
async
function
(
done
)
{
filePath
=
pathDir
+
"
/h264_aac_640x480_30r.ts
"
;
console
.
info
(
`case filePath is
${
filePath
}
`
);
fd
=
fileio
.
openSync
(
filePath
,
0o0
);
avPlayTest
=
{
width
:
640
,
height
:
480
,
duration
:
0
};
await
testAVPlayerDataSrcNoSeek
(
srcNoSeek
,
avPlayer
,
avPlayTest
,
PLAY_TIME
,
done
);
})
});
}
\ No newline at end of file
multimedia/media/media_js_standard/avPlayer/entry/src/main/ets/test/AVPlayerDataSrcNoSeekReliabilityTest.test.js
0 → 100644
浏览文件 @
6feebf67
/*
* Copyright (C) 2023 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import
media
from
'
@ohos.multimedia.media
'
import
fileio
from
'
@ohos.fileio
'
import
{
testAVPlayerDataSrcNoSeek
,
testAVPlayerFun
,
AV_PLAYER_STATE
}
from
'
../../../../../../AVPlayerTestBase.js
'
;
import
*
as
mediaTestBase
from
'
../../../../../../MediaTestBase.js
'
;
import
{
describe
,
beforeAll
,
beforeEach
,
afterEach
,
afterAll
,
it
,
expect
}
from
'
deccjsunit/index
'
;
export
default
function
AVPlayerDataSrcNoSeekReliabilityTest
()
{
describe
(
'
AVPlayerDataSrcNoSeekReliabilityTest
'
,
function
()
{
let
avPlayer
=
null
;
let
pathDir
=
globalThis
.
abilityContext
.
filesDir
;
let
filePath
=
pathDir
+
"
/01_15s.mp3
"
;
let
src
=
null
;
let
stream
=
null
;
let
fd
=
null
;
let
readAtCnt
=
0
;
let
expectErr
=
0
;
beforeAll
(
async
function
()
{
console
.
info
(
'
beforeAll case
'
);
})
beforeEach
(
async
function
()
{
console
.
info
(
'
beforeEach case
'
);
stream
=
null
;
fd
=
null
;
readAtCnt
=
0
;
expectErr
=
0
;
})
afterEach
(
async
function
()
{
console
.
info
(
'
afterEach case
'
);
})
afterAll
(
async
function
()
{
console
.
info
(
'
afterAll case
'
);
if
(
avPlayer
!=
null
)
{
avPlayer
.
release
().
then
(()
=>
{
},
mediaTestBase
.
failureCallback
).
catch
(
mediaTestBase
.
catchCallback
);
}
})
async
function
testDataSrcNoSeek
(
done
)
{
await
media
.
createAVPlayer
().
then
((
video
)
=>
{
if
(
typeof
(
video
)
!=
'
undefined
'
)
{
console
.
info
(
'
case createAVPlayer success
'
);
avPlayer
=
video
;
setCallback
(
done
);
avPlayer
.
dataSrc
=
src
;
}
else
{
console
.
error
(
'
case createAVPlayer failed
'
);
expect
().
assertFail
();
done
();
}
},
mediaTestBase
.
failureCallback
).
catch
(
mediaTestBase
.
catchCallback
);
}
function
setCallback
(
done
)
{
avPlayer
.
on
(
'
stateChange
'
,
async
(
state
,
reason
)
=>
{
console
.
info
(
`case state is
${
state
}
`
);
switch
(
state
)
{
case
AV_PLAYER_STATE
.
INITIALIZED
:
console
.
info
(
`case AVPlayerTestBase.AV_PLAYER_STATE.INITIALIZED`
);
expect
(
avPlayer
.
state
).
assertEqual
(
AV_PLAYER_STATE
.
INITIALIZED
);
avPlayer
.
surfaceId
=
globalThis
.
value
;
console
.
info
(
`case toPreparePromise`
);
await
avPlayer
.
prepare
().
then
(()
=>
{
console
.
info
(
'
case prepare success
'
);
avPlayer
.
play
();
},
mediaTestBase
.
expectFailureCallback
).
catch
(
mediaTestBase
.
catchCallback
);
break
;
case
AV_PLAYER_STATE
.
COMPLETED
:
avPlayer
.
release
().
then
(()
=>
{
avPlayer
=
null
;
done
();
},
mediaTestBase
.
failureCallback
).
catch
(
mediaTestBase
.
catchCallback
);
case
AV_PLAYER_STATE
.
ERROR
:
avPlayer
.
release
().
then
(()
=>
{
avPlayer
=
null
;
done
();
},
mediaTestBase
.
failureCallback
).
catch
(
mediaTestBase
.
catchCallback
);
break
;
default
:
break
;
}
})
avPlayer
.
on
(
'
seekDone
'
,
async
(
seekDoneTime
)
=>
{
console
.
info
(
`case seekDone called, seekDoneCnt is
${
seekDoneCnt
}
, seekDoneTime is
${
seekDoneTime
}
`
);
})
avPlayer
.
on
(
'
error
'
,
async
(
err
)
=>
{
console
.
error
(
`case error called, errCode is
${
err
.
code
}
, errMessage is
${
err
.
message
}
`
);
expect
(
err
.
code
).
assertEqual
(
expectErr
);
});
}
function
readErr
(
buf
,
length
)
{
let
num
=
fileio
.
readSync
(
fd
,
buf
,
{
offset
:
0
,
length
:
1000
});
return
num
;
}
function
readAt
(
buf
,
length
,
pos
)
{
console
.
info
(
'
readAtCnt:
'
+
readAtCnt
+
'
readAt:
'
+
length
+
'
pos:
'
+
pos
);
readAtCnt
++
;
let
num
=
0
;
if
(
buf
==
undefined
||
length
==
undefined
)
{
console
.
info
(
'
buf == undefined || length == undefined
'
);
expect
().
assertFail
();
return
-
1
;
}
num
=
readErr
(
buf
,
length
);
if
(
num
!=
-
1
)
{
console
.
info
(
'
case readAt num:
'
+
num
);
return
num
;
}
else
if
(
pos
==
undefined
)
{
num
=
fileio
.
readSync
(
fd
,
buf
,
{
offset
:
0
,
length
:
length
});
if
(
num
==
0
)
{
fileio
.
closeSync
(
fd
);
fd
=
fileio
.
openSync
(
filePath
,
0o0
);
readAtCnt
=
0
;
return
-
1
;
}
}
else
{
num
=
stream
.
readSync
(
buf
,
{
offset
:
0
,
length
:
length
,
position
:
pos
});
}
console
.
info
(
'
case readAt num:
'
+
num
);
if
(
num
>=
0
)
{
return
num
;
}
return
-
1
;
}
/* *
* @tc.number : SUB_MULTIMEDIA_MEDIA_AVPLAYER_DATASRC_NOSEEK_RELI_MP3_0100
* @tc.name : 0100.readAt buffer data is not enough
* @tc.desc : data source compatibility test
* @tc.size : MediumTest
* @tc.type : compatibility test
* @tc.level : Level3
*/
it
(
'
SUB_MULTIMEDIA_MEDIA_AVPLAYER_DATASRC_NOSEEK_RELI_MP3_0100
'
,
0
,
async
function
(
done
)
{
filePath
=
pathDir
+
"
/01_15s.mp3
"
;
console
.
info
(
'
SUB_MULTIMEDIA_MEDIA_AVPLAYER_DATASRC_NOSEEK_RELI_MP3_0100 filePath is
'
+
JSON
.
stringify
(
filePath
));
let
size
=
fileio
.
statSync
(
filePath
).
size
;
console
.
info
(
'
case file size:
'
+
size
);
fd
=
fileio
.
openSync
(
filePath
,
0o0
);
readErr
=
(
buf
,
length
)
=>
{
if
(
readAtCnt
>=
2
&&
readAtCnt
<=
10
)
{
let
num
=
fileio
.
readSync
(
fd
,
buf
,
{
offset
:
0
,
length
:
(
readAtCnt
)
*
1000
});
return
num
;
}
else
{
return
-
1
;
}
}
src
=
{
fileSize
:
-
1
,
callback
:
readAt
}
testDataSrcNoSeek
(
done
);
})
/* *
* @tc.number : SUB_MULTIMEDIA_MEDIA_AVPLAYER_DATASRC_NOSEEK_RELI_MP3_0200
* @tc.name : 0200.readAt buffer offset is wrong
* @tc.desc : data source compatibility test
* @tc.size : MediumTest
* @tc.type : compatibility test
* @tc.level : Level3
*/
it
(
'
SUB_MULTIMEDIA_MEDIA_AVPLAYER_DATASRC_NOSEEK_RELI_MP3_0200
'
,
0
,
async
function
(
done
)
{
filePath
=
pathDir
+
"
/01_15s.mp3
"
;
fd
=
fileio
.
openSync
(
filePath
,
0o0
);
readErr
=
(
buf
,
length
)
=>
{
if
(
readAtCnt
>=
2
&&
readAtCnt
<=
10
)
{
console
.
info
(
'
case buf length:
'
+
length
+
'
readAtCnt:
'
+
readAtCnt
);
let
num
=
fileio
.
readSync
(
fd
,
buf
,
{
offset
:
1000
,
length
:
readAtCnt
*
1000
});
return
num
;
}
else
{
return
-
1
;
}
}
src
=
{
fileSize
:
-
1
,
callback
:
readAt
}
testDataSrcNoSeek
(
done
);
})
/* *
* @tc.number : SUB_MULTIMEDIA_MEDIA_AVPLAYER_DATASRC_NOSEEK_RELI_MP3_0300
* @tc.name : 0200.readAt media file position is wrong
* @tc.desc : data source compatibility test
* @tc.size : MediumTest
* @tc.type : compatibility test
* @tc.level : Level3
*/
it
(
'
SUB_MULTIMEDIA_MEDIA_AVPLAYER_DATASRC_NOSEEK_RELI_MP3_0300
'
,
0
,
async
function
(
done
)
{
filePath
=
pathDir
+
"
/01_15s.mp3
"
;
fd
=
fileio
.
openSync
(
filePath
,
0o0
);
readErr
=
(
buf
,
length
)
=>
{
if
(
readAtCnt
>=
2
&&
readAtCnt
<=
10
)
{
let
num
=
fileio
.
readSync
(
fd
,
buf
,
{
offset
:
0
,
length
:
1000
,
position
:
readAtCnt
});
return
num
;
}
else
{
return
-
1
;
}
}
src
=
{
fileSize
:
-
1
,
callback
:
readAt
}
testDataSrcNoSeek
(
done
);
})
/* *
* @tc.number : SUB_MULTIMEDIA_MEDIA_AVPLAYER_DATASRC_NOSEEK_RELI_MP3_0400
* @tc.name : 0200.readAt num is wrong
* @tc.desc : data source compatibility test
* @tc.size : MediumTest
* @tc.type : compatibility test
* @tc.level : Level3
*/
it
(
'
SUB_MULTIMEDIA_MEDIA_AVPLAYER_DATASRC_NOSEEK_RELI_MP3_0400
'
,
0
,
async
function
(
done
)
{
filePath
=
pathDir
+
"
/01_15s.mp3
"
;
fd
=
fileio
.
openSync
(
filePath
,
0o0
);
readErr
=
(
buf
,
length
)
=>
{
if
(
readAtCnt
>=
2
&&
readAtCnt
<=
10
)
{
let
num
=
fileio
.
readSync
(
fd
,
buf
,
{
offset
:
0
,
length
:
(
readAtCnt
)
*
1000
});
return
num
+
readAtCnt
;
}
else
{
return
-
1
;
}
}
src
=
{
fileSize
:
-
1
,
callback
:
readAt
}
testDataSrcNoSeek
(
done
);
})
/* *
* @tc.number : SUB_MULTIMEDIA_MEDIA_AVPLAYER_DATASRC_NOSEEK_RELI_MP3_0500
* @tc.name : 0200.readAt num is wrong
* @tc.desc : data source compatibility test
* @tc.size : MediumTest
* @tc.type : compatibility test
* @tc.level : Level3
*/
it
(
'
SUB_MULTIMEDIA_MEDIA_AVPLAYER_DATASRC_NOSEEK_RELI_MP3_0500
'
,
0
,
async
function
(
done
)
{
filePath
=
pathDir
+
"
/01_15s.mp3
"
;
fd
=
fileio
.
openSync
(
filePath
,
0o0
);
readErr
=
(
buf
,
length
)
=>
{
if
(
readAtCnt
>=
2
&&
readAtCnt
<=
10
)
{
let
num
=
fileio
.
readSync
(
fd
,
buf
,
{
offset
:
0
,
length
:
(
readAtCnt
)
*
1000
});
return
num
-
readAtCnt
;
}
else
{
return
-
1
;
}
}
src
=
{
fileSize
:
-
1
,
callback
:
readAt
}
testDataSrcNoSeek
(
done
);
})
});
}
\ No newline at end of file
multimedia/media/media_js_standard/avPlayer/entry/src/main/ets/test/AVPlayerStabilityTest.test.js
浏览文件 @
6feebf67
...
@@ -803,19 +803,19 @@ export default function AVPlayerStabilityTest() {
...
@@ -803,19 +803,19 @@ export default function AVPlayerStabilityTest() {
console
.
info
(
TAG
+
'
SUB_MULTIMEDIA_MEDIA_AVPLAYER_STABILITY_01_0200 end
'
)
console
.
info
(
TAG
+
'
SUB_MULTIMEDIA_MEDIA_AVPLAYER_STABILITY_01_0200 end
'
)
})
})
/* *
//
/* *
* @tc.number : SUB_MULTIMEDIA_MEDIA_AVPLAYER_STABILITY_01_0300
//
* @tc.number : SUB_MULTIMEDIA_MEDIA_AVPLAYER_STABILITY_01_0300
* @tc.name : 001.test complete->play->seek duration (1000 times)
//
* @tc.name : 001.test complete->play->seek duration (1000 times)
* @tc.desc : Local Video complete->play->seek duration (1000 times)
//
* @tc.desc : Local Video complete->play->seek duration (1000 times)
* @tc.size : MediumTest
//
* @tc.size : MediumTest
* @tc.type : Function test
//
* @tc.type : Function test
* @tc.level : Level3
//
* @tc.level : Level3
*/
//
*/
it
(
'
SUB_MULTIMEDIA_MEDIA_AVPLAYER_STABILITY_01_0300
'
,
0
,
async
function
(
done
)
{
//
it('SUB_MULTIMEDIA_MEDIA_AVPLAYER_STABILITY_01_0300', 0, async function (done) {
console
.
info
(
TAG
+
'
SUB_MULTIMEDIA_MEDIA_AVPLAYER_STABILITY_01_0300 start
'
)
//
console.info(TAG + 'SUB_MULTIMEDIA_MEDIA_AVPLAYER_STABILITY_01_0300 start')
AVPlayerTestBase
.
playToCompleted
(
videos
[
0
],
avPlayer
,
done
);
//
AVPlayerTestBase.playToCompleted(videos[0], avPlayer, done);
console
.
info
(
TAG
+
'
SUB_MULTIMEDIA_MEDIA_AVPLAYER_STABILITY_01_0300 end
'
)
//
console.info(TAG + 'SUB_MULTIMEDIA_MEDIA_AVPLAYER_STABILITY_01_0300 end')
})
//
})
/* *
/* *
* @tc.number : SUB_MULTIMEDIA_MEDIA_AVPLAYER_STABILITY_01_0400
* @tc.number : SUB_MULTIMEDIA_MEDIA_AVPLAYER_STABILITY_01_0400
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录