Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
OpenHarmony
Xts Acts
提交
c5bbc5af
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看板
未验证
提交
c5bbc5af
编写于
11月 07, 2022
作者:
O
openharmony_ci
提交者:
Gitee
11月 07, 2022
浏览文件
操作
浏览文件
下载
差异文件
!6400 新增XTS覆盖分布式接口
Merge pull request !6400 from LeiiYB/cherry-pick-1667784913
上级
6f370fda
18fe0342
变更
5
隐藏空白更改
内联
并排
Showing
5 changed file
with
622 addition
and
67 deletion
+622
-67
multimedia/avsession/avsession_js_standard/avsessionManager/src/main/js/test/AVSession.test.js
...ndard/avsessionManager/src/main/js/test/AVSession.test.js
+180
-67
multimedia/avsession/avsession_js_standard/avsessionManager/src/main/js/test/AVSessionController.test.js
...ssionManager/src/main/js/test/AVSessionController.test.js
+54
-0
multimedia/avsession/avsession_js_standard/avsessionManager/src/main/js/test/AVSessionErrorCode.test.js
...essionManager/src/main/js/test/AVSessionErrorCode.test.js
+249
-0
multimedia/avsession/avsession_js_standard/avsessionManager/src/main/js/test/AVSessionManager.test.js
...vsessionManager/src/main/js/test/AVSessionManager.test.js
+137
-0
multimedia/avsession/avsession_js_standard/avsessionManager/src/main/js/test/List.test.js
...s_standard/avsessionManager/src/main/js/test/List.test.js
+2
-0
未找到文件。
multimedia/avsession/avsession_js_standard/avsessionManager/src/main/js/test/AVSession.test.js
100644 → 100755
浏览文件 @
c5bbc5af
...
...
@@ -14,7 +14,7 @@
*/
import
avSession
from
'
@ohos.multimedia.avsession
'
;
import
{
afterAll
,
afterEach
,
beforeAll
,
beforeEach
,
describe
,
expect
,
it
}
from
'
@ohos/hypium
'
;
import
{
afterAll
,
afterEach
,
beforeAll
,
beforeEach
,
describe
,
expect
,
it
}
from
'
@ohos/hypium
'
;
import
image
from
'
@ohos.multimedia.image
'
;
import
WantAgent
from
'
@ohos.wantAgent
'
;
import
featureAbility
from
'
@ohos.ability.featureAbility
'
;
...
...
@@ -25,11 +25,12 @@ export default function AVSession() {
let
type
=
'
audio
'
;
let
session
;
let
controller
;
let
keyItem
=
{
code
:
0x49
,
pressedTime
:
123456789
,
deviceId
:
0
};
let
event
=
{
action
:
2
,
key
:
keyItem
,
keys
:[
keyItem
]};
let
OutputDeviceInfo
=
{
isRemote
:
false
,
audioDeviceId
:
[
0
],
deviceName
:
[
'
LocalDevice
'
]
};
let
keyItem
=
{
code
:
0x49
,
pressedTime
:
123456789
,
deviceId
:
0
};
let
event
=
{
action
:
2
,
key
:
keyItem
,
keys
:
[
keyItem
]
};
let
context
=
featureAbility
.
getContext
();
function
sleep
(
ms
)
{
function
sleep
(
ms
)
{
return
new
Promise
(
resolve
=>
setTimeout
(
resolve
,
ms
));
}
...
...
@@ -37,7 +38,7 @@ export default function AVSession() {
let
color
=
new
ArrayBuffer
(
96
);
let
bufferArr
=
new
Uint8Array
(
color
);
bufferArr
.
fill
(
'
3
'
,
0
,
95
);
let
opts
=
{
editable
:
true
,
pixelFormat
:
3
,
size
:
{
height
:
4
,
width
:
6
},
AlphaType
:
3
};
let
opts
=
{
editable
:
true
,
pixelFormat
:
3
,
size
:
{
height
:
4
,
width
:
6
},
AlphaType
:
3
};
return
image
.
createPixelMap
(
color
,
opts
);
}
...
...
@@ -118,7 +119,7 @@ export default function AVSession() {
* @tc.level : Level0
*/
it
(
'
SUB_MULTIMEDIA_AVSESSION_SET_METADATA_PROMISE_0100
'
,
0
,
async
function
(
done
)
{
let
metadata0
=
{
let
metadata0
=
{
assetId
:
'
121278
'
,
};
await
session
.
setAVMetadata
(
metadata0
).
then
(()
=>
{
...
...
@@ -153,7 +154,7 @@ export default function AVSession() {
* @tc.level : Level2
*/
it
(
'
SUB_MULTIMEDIA_AVSESSION_SET_METADATA_PROMISE_0200
'
,
0
,
async
function
(
done
)
{
let
metadata1
=
{
let
metadata1
=
{
assetId
:
'
121278
'
,
artist
:
'
Eminem
'
,
};
...
...
@@ -187,7 +188,7 @@ export default function AVSession() {
* @tc.level : Level2
*/
it
(
'
SUB_MULTIMEDIA_AVSESSION_SET_METADATA_PROMISE_0300
'
,
0
,
async
function
(
done
)
{
let
metadata2
=
{
let
metadata2
=
{
assetId
:
'
121278
'
,
author
:
'
ST
'
,
};
...
...
@@ -221,7 +222,7 @@ export default function AVSession() {
* @tc.level : Level2
*/
it
(
'
SUB_MULTIMEDIA_AVSESSION_SET_METADATA_PROMISE_0400
'
,
0
,
async
function
(
done
)
{
let
metadata3
=
{
let
metadata3
=
{
assetId
:
'
121278
'
,
album
:
'
Slim shady
'
,
};
...
...
@@ -255,7 +256,7 @@ export default function AVSession() {
* @tc.level : Level2
*/
it
(
'
SUB_MULTIMEDIA_AVSESSION_SET_METADATA_PROMISE_0500
'
,
0
,
async
function
(
done
)
{
let
metadata4
=
{
let
metadata4
=
{
assetId
:
'
121278
'
,
writer
:
'
ST
'
,
};
...
...
@@ -289,7 +290,7 @@ export default function AVSession() {
* @tc.level : Level2
*/
it
(
'
SUB_MULTIMEDIA_AVSESSION_SET_METADATA_PROMISE_0600
'
,
0
,
async
function
(
done
)
{
let
metadata5
=
{
let
metadata5
=
{
assetId
:
'
121278
'
,
composer
:
'
ST
'
,
};
...
...
@@ -323,7 +324,7 @@ export default function AVSession() {
* @tc.level : Level2
*/
it
(
'
SUB_MULTIMEDIA_AVSESSION_SET_METADATA_PROMISE_0700
'
,
0
,
async
function
(
done
)
{
let
metadata6
=
{
let
metadata6
=
{
assetId
:
'
121278
'
,
duration
:
2222
,
};
...
...
@@ -358,7 +359,7 @@ export default function AVSession() {
* @tc.level : Level2
*/
it
(
'
SUB_MULTIMEDIA_AVSESSION_SET_METADATA_PROMISE_0800
'
,
0
,
async
function
(
done
)
{
let
metadata7
=
{
let
metadata7
=
{
assetId
:
'
121278
'
,
mediaImage
:
'
https://img2.baidu.com/it/u=3583435814,2833583486&fm=253&fmt=auto&app=138&f=JPEG?w=526&h=500
'
,
};
...
...
@@ -397,7 +398,7 @@ export default function AVSession() {
let
readBuffer0
=
new
ArrayBuffer
(
96
);
await
pixelMap
.
readPixelsToBuffer
(
readBuffer0
);
let
bufferArr0
=
new
Uint8Array
(
readBuffer0
);
let
metadata8
=
{
let
metadata8
=
{
assetId
:
'
121278
'
,
mediaImage
:
pixelMap
,
};
...
...
@@ -443,9 +444,9 @@ export default function AVSession() {
* @tc.level : Level2
*/
it
(
'
SUB_MULTIMEDIA_AVSESSION_SET_METADATA_PROMISE_1000
'
,
0
,
async
function
(
done
)
{
let
metadata9
=
{
let
metadata9
=
{
assetId
:
'
121278
'
,
publishDate
:
new
Date
(
1994
,
1
,
1
,
1
),
publishDate
:
new
Date
(
1994
,
1
,
1
,
1
),
};
await
session
.
setAVMetadata
(
metadata9
).
then
(()
=>
{
console
.
info
(
'
TestLog: Set publishDate successfully
'
);
...
...
@@ -477,7 +478,7 @@ export default function AVSession() {
* @tc.level : Level2
*/
it
(
'
SUB_MULTIMEDIA_AVSESSION_SET_METADATA_PROMISE_1100
'
,
0
,
async
function
(
done
)
{
let
metadata10
=
{
let
metadata10
=
{
assetId
:
'
121278
'
,
subtitle
:
'
8 Mile
'
,
};
...
...
@@ -513,7 +514,7 @@ export default function AVSession() {
* @tc.level : Level2
*/
it
(
'
SUB_MULTIMEDIA_AVSESSION_SET_METADATA_PROMISE_1200
'
,
0
,
async
function
(
done
)
{
let
metadata11
=
{
let
metadata11
=
{
assetId
:
'
121278
'
,
description
:
'
Rap
'
,
};
...
...
@@ -547,7 +548,7 @@ export default function AVSession() {
* @tc.level : Level2
*/
it
(
'
SUB_MULTIMEDIA_AVSESSION_SET_METADATA_PROMISE_1300
'
,
0
,
async
function
(
done
)
{
let
metadata12
=
{
let
metadata12
=
{
assetId
:
'
121278
'
,
lyric
:
'
https://lyric.tingmall.com/lyric/58/970/589710004-LRC-LRC.lrc?t=1649918948000
'
,
};
...
...
@@ -583,7 +584,7 @@ export default function AVSession() {
* @tc.level : Level2
*/
it
(
'
SUB_MULTIMEDIA_AVSESSION_SET_METADATA_PROMISE_1400
'
,
0
,
async
function
(
done
)
{
let
metadata13
=
{
let
metadata13
=
{
assetId
:
'
121278
'
,
previousAssetId
:
'
121277
'
,
nextAssetId
:
'
121279
'
,
...
...
@@ -621,7 +622,7 @@ export default function AVSession() {
* @tc.level : Level2
*/
it
(
'
SUB_MULTIMEDIA_AVSESSION_SET_METADATA_PROMISE_1500
'
,
0
,
async
function
(
done
)
{
let
metadata14
=
{
let
metadata14
=
{
assetId
:
'
121278
'
,
};
await
session
.
destroy
();
...
...
@@ -645,7 +646,7 @@ export default function AVSession() {
* @tc.level : Level2
*/
it
(
'
SUB_MULTIMEDIA_AVSESSION_SET_METADATA_PROMISE_1600
'
,
0
,
async
function
(
done
)
{
let
metadata15
=
{
let
metadata15
=
{
assetId
:
'
121278
'
,
duration
:
-
2
,
};
...
...
@@ -669,7 +670,7 @@ export default function AVSession() {
*/
it
(
'
SUB_MULTIMEDIA_AVSESSION_SETAVPLAYBACKSTATE_PROMISE_0100
'
,
0
,
async
function
(
done
)
{
let
PlaybackState1
=
{
state
:
avSession
.
PlaybackState
.
PLAYBACK_STATE_PLAY
,
state
:
avSession
.
PlaybackState
.
PLAYBACK_STATE_PLAY
,
};
await
session
.
setAVPlaybackState
(
PlaybackState1
).
then
(()
=>
{
console
.
info
(
'
TestLog: Set State successfully
'
);
...
...
@@ -742,7 +743,7 @@ export default function AVSession() {
*/
it
(
'
SUB_MULTIMEDIA_AVSESSION_SETAVPLAYBACKSTATE_PROMISE_0300
'
,
0
,
async
function
(
done
)
{
let
PlaybackState3
=
{
position
:
{
elapsedTime
:
10
,
updateTime
:(
new
Date
()).
getTime
()
},
position
:
{
elapsedTime
:
10
,
updateTime
:
(
new
Date
()).
getTime
()
},
};
await
session
.
setAVPlaybackState
(
PlaybackState3
).
then
(()
=>
{
...
...
@@ -816,7 +817,7 @@ export default function AVSession() {
*/
it
(
'
SUB_MULTIMEDIA_AVSESSION_SETAVPLAYBACKSTATE_PROMISE_0500
'
,
0
,
async
function
(
done
)
{
let
PlaybackState5
=
{
loopMode
:
avSession
.
LoopMode
.
LOOP_MODE_SEQUENCE
,
loopMode
:
avSession
.
LoopMode
.
LOOP_MODE_SEQUENCE
,
};
await
session
.
setAVPlaybackState
(
PlaybackState5
).
then
(()
=>
{
...
...
@@ -1003,7 +1004,7 @@ export default function AVSession() {
let
PlaybackState10
=
{
state
:
avSession
.
PlaybackState
.
PLAYBACK_STATE_PLAY
,
speed
:
1.0
,
position
:
{
elapsedTime
:
10
,
updateTime
:
(
new
Date
()).
getTime
()
},
position
:
{
elapsedTime
:
10
,
updateTime
:
(
new
Date
()).
getTime
()
},
bufferedTime
:
1000
,
loopMode
:
avSession
.
LoopMode
.
LOOP_MODE_SINGLE
,
isFavorite
:
true
,
...
...
@@ -1032,7 +1033,7 @@ export default function AVSession() {
let
PlaybackState11
=
{
state
:
avSession
.
PlaybackState
.
PLAYBACK_STATE_PLAY
,
speed
:
-
2
,
position
:
{
elapsedTime
:
-
2
,
updateTime
:
(
new
Date
()).
getTime
()
},
position
:
{
elapsedTime
:
-
2
,
updateTime
:
(
new
Date
()).
getTime
()
},
bufferedTime
:
-
4
,
loopMode
:
avSession
.
LoopMode
.
LOOP_MODE_SINGLE
,
isFavorite
:
true
,
...
...
@@ -1055,11 +1056,11 @@ export default function AVSession() {
* @tc.type : Function
* @tc.level : Level1
*/
it
(
'
SUB_MULTIMEDIA_AVSESSION_SETLAUNCHABILITY_PROMISE_0100
'
,
0
,
async
function
(
done
)
{
it
(
'
SUB_MULTIMEDIA_AVSESSION_SETLAUNCHABILITY_PROMISE_0100
'
,
0
,
async
function
(
done
)
{
let
wantAgentInfo
=
{
wants
:
[
wants
:
[
{
bundleName
:
'
com.example.myapplication
'
,
bundleName
:
'
com.example.myapplication
'
,
abilityName
:
'
com.example.myapplication.MainAbility
'
}
],
...
...
@@ -1217,7 +1218,7 @@ export default function AVSession() {
expect
(
true
).
assertTrue
();
});
await
controller
.
sendControlCommand
({
command
:
'
play
'
}).
then
(()
=>
{
await
controller
.
sendControlCommand
({
command
:
'
play
'
}).
then
(()
=>
{
console
.
info
(
'
TestLog: Controller send command successfully
'
);
}).
catch
((
err
)
=>
{
console
.
info
(
`TestLog: Controller send command error: code:
${
err
.
code
}
, message:
${
err
.
message
}
`
);
...
...
@@ -1241,7 +1242,7 @@ export default function AVSession() {
expect
(
true
).
assertTrue
();
});
await
controller
.
sendControlCommand
({
command
:
'
pause
'
}).
then
(()
=>
{
await
controller
.
sendControlCommand
({
command
:
'
pause
'
}).
then
(()
=>
{
console
.
info
(
'
TestLog: Controller send command successfully
'
);
}).
catch
((
err
)
=>
{
console
.
info
(
`TestLog: Controller send command error: code:
${
err
.
code
}
, message:
${
err
.
message
}
`
);
...
...
@@ -1265,7 +1266,7 @@ export default function AVSession() {
expect
(
true
).
assertTrue
();
});
await
controller
.
sendControlCommand
({
command
:
'
stop
'
}).
then
(()
=>
{
await
controller
.
sendControlCommand
({
command
:
'
stop
'
}).
then
(()
=>
{
console
.
info
(
'
TestLog: Controller send command successfully
'
);
}).
catch
((
err
)
=>
{
console
.
info
(
`TestLog: Controller send command error: code:
${
err
.
code
}
, message:
${
err
.
message
}
`
);
...
...
@@ -1289,7 +1290,7 @@ export default function AVSession() {
expect
(
true
).
assertTrue
();
});
await
controller
.
sendControlCommand
({
command
:
'
playNext
'
}).
then
(()
=>
{
await
controller
.
sendControlCommand
({
command
:
'
playNext
'
}).
then
(()
=>
{
console
.
info
(
'
TestLog: Controller send command successfully
'
);
}).
catch
((
err
)
=>
{
console
.
info
(
`TestLog: Controller send command error: code:
${
err
.
code
}
, message:
${
err
.
message
}
`
);
...
...
@@ -1313,7 +1314,7 @@ export default function AVSession() {
expect
(
true
).
assertTrue
();
});
await
controller
.
sendControlCommand
({
command
:
'
playPrevious
'
}).
then
(()
=>
{
await
controller
.
sendControlCommand
({
command
:
'
playPrevious
'
}).
then
(()
=>
{
console
.
info
(
'
TestLog: Controller send command successfully
'
);
}).
catch
((
err
)
=>
{
console
.
info
(
`TestLog: Controller send command error: code:
${
err
.
code
}
, message:
${
err
.
message
}
`
);
...
...
@@ -1337,7 +1338,7 @@ export default function AVSession() {
expect
(
true
).
assertTrue
();
});
await
controller
.
sendControlCommand
({
command
:
'
fastForward
'
}).
then
(()
=>
{
await
controller
.
sendControlCommand
({
command
:
'
fastForward
'
}).
then
(()
=>
{
console
.
info
(
'
TestLog: Controller send command successfully
'
);
}).
catch
((
err
)
=>
{
console
.
info
(
`TestLog: Controller send command error: code:
${
err
.
code
}
, message:
${
err
.
message
}
`
);
...
...
@@ -1361,7 +1362,7 @@ export default function AVSession() {
expect
(
true
).
assertTrue
();
});
await
controller
.
sendControlCommand
({
command
:
'
rewind
'
}).
then
(()
=>
{
await
controller
.
sendControlCommand
({
command
:
'
rewind
'
}).
then
(()
=>
{
console
.
info
(
'
TestLog: Controller send command successfully
'
);
}).
catch
((
err
)
=>
{
console
.
info
(
`TestLog: Controller send command error: code:
${
err
.
code
}
, message:
${
err
.
message
}
`
);
...
...
@@ -1390,7 +1391,7 @@ export default function AVSession() {
}
});
await
controller
.
sendControlCommand
({
command
:
'
seek
'
,
parameter
:
10
}).
then
(()
=>
{
await
controller
.
sendControlCommand
({
command
:
'
seek
'
,
parameter
:
10
}).
then
(()
=>
{
console
.
info
(
'
TestLog: Controller send command successfully
'
);
}).
catch
((
err
)
=>
{
console
.
info
(
`TestLog: Controller send command error: code:
${
err
.
code
}
, message:
${
err
.
message
}
`
);
...
...
@@ -1419,7 +1420,7 @@ export default function AVSession() {
}
});
await
controller
.
sendControlCommand
({
command
:
'
setSpeed
'
,
parameter
:
2.6
}).
then
(()
=>
{
await
controller
.
sendControlCommand
({
command
:
'
setSpeed
'
,
parameter
:
2.6
}).
then
(()
=>
{
console
.
info
(
'
TestLog: Controller send command successfully
'
);
}).
catch
((
err
)
=>
{
console
.
info
(
`TestLog: Controller send command error: code:
${
err
.
code
}
, message:
${
err
.
message
}
`
);
...
...
@@ -1448,8 +1449,10 @@ export default function AVSession() {
}
});
await
controller
.
sendControlCommand
({
command
:
'
setLoopMode
'
,
parameter
:
avSession
.
LoopMode
.
LOOP_MODE_SINGLE
}).
then
(()
=>
{
await
controller
.
sendControlCommand
({
command
:
'
setLoopMode
'
,
parameter
:
avSession
.
LoopMode
.
LOOP_MODE_SINGLE
}).
then
(()
=>
{
console
.
info
(
'
TestLog: Controller send command successfully
'
);
}).
catch
((
err
)
=>
{
console
.
info
(
`TestLog: Controller send command error: code:
${
err
.
code
}
, message:
${
err
.
message
}
`
);
...
...
@@ -1479,7 +1482,7 @@ export default function AVSession() {
}
});
await
controller
.
sendControlCommand
({
command
:
'
toggleFavorite
'
,
parameter
:
'
false
'
}).
then
(()
=>
{
await
controller
.
sendControlCommand
({
command
:
'
toggleFavorite
'
,
parameter
:
'
false
'
}).
then
(()
=>
{
console
.
info
(
'
TestLog: Controller send command successfully
'
);
}).
catch
((
err
)
=>
{
console
.
info
(
`TestLog: Controller send command error: code:
${
err
.
code
}
, message:
${
err
.
message
}
`
);
...
...
@@ -1563,7 +1566,7 @@ export default function AVSession() {
session
.
off
(
'
play
'
);
await
controller
.
sendControlCommand
({
command
:
'
play
'
}).
then
(()
=>
{
await
controller
.
sendControlCommand
({
command
:
'
play
'
}).
then
(()
=>
{
console
.
info
(
'
TestLog: Controller send command successfully
'
);
}).
catch
((
err
)
=>
{
console
.
info
(
`TestLog: Controller send command error: code:
${
err
.
code
}
, message:
${
err
.
message
}
`
);
...
...
@@ -1581,7 +1584,7 @@ export default function AVSession() {
* @tc.type : Function
* @tc.level : Level2
*/
it
(
'
SUB_MULTIMEDIA_AVSESSION_OFFPLAY_0200
'
,
0
,
async
function
(
done
)
{
it
(
'
SUB_MULTIMEDIA_AVSESSION_OFFPLAY_0200
'
,
0
,
async
function
(
done
)
{
function
callback1
()
{
console
.
info
(
'
TestLog: Play command registration1 success
'
);
expect
(
false
).
assertTrue
();
...
...
@@ -1598,7 +1601,7 @@ export default function AVSession() {
session
.
off
(
'
play
'
,
callback1
);
await
controller
.
sendControlCommand
({
command
:
'
play
'
}).
then
(()
=>
{
await
controller
.
sendControlCommand
({
command
:
'
play
'
}).
then
(()
=>
{
console
.
info
(
'
TestLog: Controller send command successfully
'
);
}).
catch
((
err
)
=>
{
console
.
info
(
`TestLog: Controller send command error: code:
${
err
.
code
}
, message:
${
err
.
message
}
`
);
...
...
@@ -1633,7 +1636,7 @@ export default function AVSession() {
session
.
off
(
'
pause
'
);
await
controller
.
sendControlCommand
({
command
:
'
pause
'
}).
then
(()
=>
{
await
controller
.
sendControlCommand
({
command
:
'
pause
'
}).
then
(()
=>
{
console
.
info
(
'
TestLog: Controller send command successfully
'
);
}).
catch
((
err
)
=>
{
console
.
info
(
`TestLog: Controller send command error: code:
${
err
.
code
}
, message:
${
err
.
message
}
`
);
...
...
@@ -1668,7 +1671,7 @@ export default function AVSession() {
session
.
off
(
'
pause
'
,
callback1
);
await
controller
.
sendControlCommand
({
command
:
'
pause
'
}).
then
(()
=>
{
await
controller
.
sendControlCommand
({
command
:
'
pause
'
}).
then
(()
=>
{
console
.
info
(
'
TestLog: Controller send command successfully
'
);
}).
catch
((
err
)
=>
{
console
.
info
(
`TestLog: Controller send command error: code:
${
err
.
code
}
, message:
${
err
.
message
}
`
);
...
...
@@ -1704,7 +1707,7 @@ export default function AVSession() {
session
.
off
(
'
stop
'
);
await
controller
.
sendControlCommand
({
command
:
'
stop
'
}).
then
(()
=>
{
await
controller
.
sendControlCommand
({
command
:
'
stop
'
}).
then
(()
=>
{
console
.
info
(
'
TestLog: Controller send command successfully
'
);
}).
catch
((
err
)
=>
{
console
.
info
(
`TestLog: Controller send command error: code:
${
err
.
code
}
, message:
${
err
.
message
}
`
);
...
...
@@ -1739,7 +1742,7 @@ export default function AVSession() {
session
.
off
(
'
stop
'
,
callback1
)
await
controller
.
sendControlCommand
({
command
:
'
stop
'
}).
then
(()
=>
{
await
controller
.
sendControlCommand
({
command
:
'
stop
'
}).
then
(()
=>
{
console
.
info
(
'
TestLog: Controller send command successfully
'
);
}).
catch
((
err
)
=>
{
console
.
info
(
`TestLog: Controller send command error: code:
${
err
.
code
}
, message:
${
err
.
message
}
`
);
...
...
@@ -1774,7 +1777,7 @@ export default function AVSession() {
session
.
off
(
'
playNext
'
);
await
controller
.
sendControlCommand
({
command
:
'
playNext
'
}).
then
(()
=>
{
await
controller
.
sendControlCommand
({
command
:
'
playNext
'
}).
then
(()
=>
{
console
.
info
(
'
TestLog: Controller send command successfully
'
);
}).
catch
((
err
)
=>
{
console
.
info
(
`TestLog: Controller send command error: code:
${
err
.
code
}
, message:
${
err
.
message
}
`
);
...
...
@@ -1809,7 +1812,7 @@ export default function AVSession() {
session
.
off
(
'
playNext
'
,
callback1
);
await
controller
.
sendControlCommand
({
command
:
'
playNext
'
}).
then
(()
=>
{
await
controller
.
sendControlCommand
({
command
:
'
playNext
'
}).
then
(()
=>
{
console
.
info
(
'
TestLog: Controller send command successfully
'
);
}).
catch
((
err
)
=>
{
console
.
info
(
`TestLog: Controller send command error: code:
${
err
.
code
}
, message:
${
err
.
message
}
`
);
...
...
@@ -1844,7 +1847,7 @@ export default function AVSession() {
session
.
off
(
'
playPrevious
'
);
await
controller
.
sendControlCommand
({
command
:
'
playPrevious
'
}).
then
(()
=>
{
await
controller
.
sendControlCommand
({
command
:
'
playPrevious
'
}).
then
(()
=>
{
console
.
info
(
'
TestLog: Controller send command successfully
'
);
}).
catch
((
err
)
=>
{
console
.
info
(
`TestLog: Controller send command error: code:
${
err
.
code
}
, message:
${
err
.
message
}
`
);
...
...
@@ -1879,7 +1882,7 @@ export default function AVSession() {
session
.
off
(
'
playPrevious
'
,
callback1
);
await
controller
.
sendControlCommand
({
command
:
'
playPrevious
'
}).
then
(()
=>
{
await
controller
.
sendControlCommand
({
command
:
'
playPrevious
'
}).
then
(()
=>
{
console
.
info
(
'
TestLog: Controller send command successfully
'
);
}).
catch
((
err
)
=>
{
console
.
info
(
`TestLog: Controller send command error: code:
${
err
.
code
}
, message:
${
err
.
message
}
`
);
...
...
@@ -1914,7 +1917,7 @@ export default function AVSession() {
session
.
off
(
'
fastForward
'
);
await
controller
.
sendControlCommand
({
command
:
'
fastForward
'
}).
then
(()
=>
{
await
controller
.
sendControlCommand
({
command
:
'
fastForward
'
}).
then
(()
=>
{
console
.
info
(
'
TestLog: Controller send command successfully
'
);
}).
catch
((
err
)
=>
{
console
.
info
(
`TestLog: Controller send command error: code:
${
err
.
code
}
, message:
${
err
.
message
}
`
);
...
...
@@ -1949,7 +1952,7 @@ export default function AVSession() {
session
.
off
(
'
fastForward
'
,
callback1
);
await
controller
.
sendControlCommand
({
command
:
'
fastForward
'
}).
then
(()
=>
{
await
controller
.
sendControlCommand
({
command
:
'
fastForward
'
}).
then
(()
=>
{
console
.
info
(
'
TestLog: Controller send command successfully
'
);
}).
catch
((
err
)
=>
{
console
.
info
(
`TestLog: Controller send command error: code:
${
err
.
code
}
, message:
${
err
.
message
}
`
);
...
...
@@ -1984,7 +1987,7 @@ export default function AVSession() {
session
.
off
(
'
rewind
'
);
await
controller
.
sendControlCommand
({
command
:
'
rewind
'
}).
then
(()
=>
{
await
controller
.
sendControlCommand
({
command
:
'
rewind
'
}).
then
(()
=>
{
console
.
info
(
'
TestLog: Controller send command successfully
'
);
}).
catch
((
err
)
=>
{
console
.
info
(
`TestLog: Controller send command error: code:
${
err
.
code
}
, message:
${
err
.
message
}
`
);
...
...
@@ -2019,7 +2022,7 @@ export default function AVSession() {
session
.
off
(
'
rewind
'
,
callback1
);
await
controller
.
sendControlCommand
({
command
:
'
rewind
'
}).
then
(()
=>
{
await
controller
.
sendControlCommand
({
command
:
'
rewind
'
}).
then
(()
=>
{
console
.
info
(
'
TestLog: Controller send command successfully
'
);
}).
catch
((
err
)
=>
{
console
.
info
(
`TestLog: Controller send command error: code:
${
err
.
code
}
, message:
${
err
.
message
}
`
);
...
...
@@ -2058,7 +2061,7 @@ export default function AVSession() {
session
.
off
(
'
seek
'
);
await
controller
.
sendControlCommand
({
command
:
'
seek
'
,
parameter
:
10
}).
then
(()
=>
{
await
controller
.
sendControlCommand
({
command
:
'
seek
'
,
parameter
:
10
}).
then
(()
=>
{
console
.
info
(
'
TestLog: Controller send command successfully
'
);
}).
catch
((
err
)
=>
{
console
.
info
(
`TestLog: Controller send command error: code:
${
err
.
code
}
, message:
${
err
.
message
}
`
);
...
...
@@ -2097,7 +2100,7 @@ export default function AVSession() {
session
.
off
(
'
seek
'
,
callback1
);
await
controller
.
sendControlCommand
({
command
:
'
seek
'
,
parameter
:
10
}).
then
(()
=>
{
await
controller
.
sendControlCommand
({
command
:
'
seek
'
,
parameter
:
10
}).
then
(()
=>
{
console
.
info
(
'
TestLog: Controller send command successfully
'
);
}).
catch
((
err
)
=>
{
console
.
info
(
`TestLog: Controller send command error: code:
${
err
.
code
}
, message:
${
err
.
message
}
`
);
...
...
@@ -2136,7 +2139,7 @@ export default function AVSession() {
session
.
off
(
'
setSpeed
'
);
await
controller
.
sendControlCommand
({
command
:
'
setSpeed
'
,
parameter
:
2.0
}).
then
(()
=>
{
await
controller
.
sendControlCommand
({
command
:
'
setSpeed
'
,
parameter
:
2.0
}).
then
(()
=>
{
console
.
info
(
'
TestLog: Controller send command successfully
'
);
}).
catch
((
err
)
=>
{
console
.
info
(
`TestLog: Controller send command error: code:
${
err
.
code
}
, message:
${
err
.
message
}
`
);
...
...
@@ -2175,7 +2178,7 @@ export default function AVSession() {
session
.
off
(
'
setSpeed
'
,
callback1
);
await
controller
.
sendControlCommand
({
command
:
'
setSpeed
'
,
parameter
:
2.0
}).
then
(()
=>
{
await
controller
.
sendControlCommand
({
command
:
'
setSpeed
'
,
parameter
:
2.0
}).
then
(()
=>
{
console
.
info
(
'
TestLog: Controller send command successfully
'
);
}).
catch
((
err
)
=>
{
console
.
info
(
`TestLog: Controller send command error: code:
${
err
.
code
}
, message:
${
err
.
message
}
`
);
...
...
@@ -2214,8 +2217,10 @@ export default function AVSession() {
session
.
off
(
'
setLoopMode
'
);
await
controller
.
sendControlCommand
({
command
:
'
setLoopMode
'
,
parameter
:
avSession
.
LoopMode
.
LOOP_MODE_SINGLE
}).
then
(()
=>
{
await
controller
.
sendControlCommand
({
command
:
'
setLoopMode
'
,
parameter
:
avSession
.
LoopMode
.
LOOP_MODE_SINGLE
}).
then
(()
=>
{
console
.
info
(
'
TestLog: Controller send command successfully
'
);
}).
catch
((
err
)
=>
{
console
.
info
(
`TestLog: Controller send command error: code:
${
err
.
code
}
, message:
${
err
.
message
}
`
);
...
...
@@ -2254,8 +2259,10 @@ export default function AVSession() {
session
.
off
(
'
setLoopMode
'
,
callback1
);
await
controller
.
sendControlCommand
({
command
:
'
setLoopMode
'
,
parameter
:
avSession
.
LoopMode
.
LOOP_MODE_SINGLE
}).
then
(()
=>
{
await
controller
.
sendControlCommand
({
command
:
'
setLoopMode
'
,
parameter
:
avSession
.
LoopMode
.
LOOP_MODE_SINGLE
}).
then
(()
=>
{
console
.
info
(
'
TestLog: Controller send command successfully
'
);
}).
catch
((
err
)
=>
{
console
.
info
(
`TestLog: Controller send command error: code:
${
err
.
code
}
, message:
${
err
.
message
}
`
);
...
...
@@ -2294,7 +2301,7 @@ export default function AVSession() {
session
.
off
(
'
toggleFavorite
'
);
await
controller
.
sendControlCommand
({
command
:
'
toggleFavorite
'
,
parameter
:
'
false
'
}).
then
(()
=>
{
await
controller
.
sendControlCommand
({
command
:
'
toggleFavorite
'
,
parameter
:
'
false
'
}).
then
(()
=>
{
console
.
info
(
'
TestLog: Controller send command successfully
'
);
}).
catch
((
err
)
=>
{
console
.
info
(
`TestLog: Controller send command error: code:
${
err
.
code
}
, message:
${
err
.
message
}
`
);
...
...
@@ -2333,7 +2340,7 @@ export default function AVSession() {
session
.
off
(
'
toggleFavorite
'
,
callback1
);
await
controller
.
sendControlCommand
({
command
:
'
toggleFavorite
'
,
parameter
:
'
false
'
}).
then
(()
=>
{
await
controller
.
sendControlCommand
({
command
:
'
toggleFavorite
'
,
parameter
:
'
false
'
}).
then
(()
=>
{
console
.
info
(
'
TestLog: Controller send command successfully
'
);
}).
catch
((
err
)
=>
{
console
.
info
(
`TestLog: Controller send command error: code:
${
err
.
code
}
, message:
${
err
.
message
}
`
);
...
...
@@ -2429,5 +2436,111 @@ export default function AVSession() {
await
sleep
(
500
);
done
();
})
/* *
* @tc.number : SUB_MULTIMEDIA_AVSESSION_GETOUTPUTDEVICE_PROMISE_0100
* @tc.name : GETOUTPUTDEVICE_PROMISE_0100
* @tc.desc : Testing get output device
* @tc.size : MediumTest
* @tc.type : Function
* @tc.level : Level2
*/
it
(
'
SUB_MULTIMEDIA_AVSESSION_GETOUTPUTDEVICE_PROMISE_0100
'
,
0
,
async
function
(
done
)
{
session
.
on
(
'
outputDeviceChange
'
,
(
callback
)
=>
{
if
(
!
callback
.
isRemote
)
{
console
.
info
(
callback
.
audioDeviceId
.
size
);
console
.
info
(
callback
.
deviceName
.
size
);
console
.
info
(
'
outputDeviceChange callback registration successful
'
);
expect
(
true
).
assertTrue
();
}
else
{
console
.
info
(
'
outputDeviceChange callback registration fail
'
);
expect
(
false
).
assertTrue
();
}
});
session
.
off
(
'
outputDeviceChange
'
);
await
session
.
getOutputDevice
().
then
((
data
)
=>
{
if
(
!
data
.
isRemote
)
{
expect
(
true
).
assertTrue
();
}
else
{
console
.
info
(
avSession
.
OutputDeviceInfo
.
isRemote
);
console
.
info
(
avSession
.
OutputDeviceInfo
.
audioDeviceId
.
size
);
console
.
info
(
avSession
.
OutputDeviceInfo
.
deviceName
.
size
);
console
.
info
(
'
getOutputDevice successfully
'
);
console
.
info
(
'
Get device information failed
'
);
expect
(
false
).
assertTrue
();
}
}).
catch
((
err
)
=>
{
console
.
info
(
`Get device BusinessError:
${
err
.
code
}
, message:
${
err
.
message
}
`
);
expect
(
false
).
assertTrue
();
})
done
();
})
/* *
* @tc.number : SUB_MULTIMEDIA_AVSESSION_GETOUTPUTDEVICE_CALLBACK_0100
* @tc.name : GETOUTPUTDEVICE_CALLBACK_0100
* @tc.desc : Testing get output device
* @tc.size : MediumTest
* @tc.type : Function
* @tc.level : Level2
*/
it
(
'
SUB_MULTIMEDIA_AVSESSION_GETOUTPUTDEVICE_CALLBACK_0100
'
,
0
,
async
function
(
done
)
{
session
.
getOutputDevice
((
err
,
value
)
=>
{
if
(
err
)
{
console
.
info
(
`Get device information BusinessError:
${
err
.
code
}
, message:
${
err
.
message
}
`
);
expect
(
false
).
assertTrue
();
}
else
if
(
!
value
.
isRemote
)
{
console
.
info
(
'
Get device information successfully
'
);
expect
(
true
).
assertTrue
();
}
else
{
console
.
info
(
'
Get device information failed
'
);
expect
(
false
).
assertTrue
();
}
});
done
();
})
/* *
* @tc.number : SUB_MULTIMEDIA_AVSESSION_GETCONTROLLER_PROMISE_0100
* @tc.name : GETCONTROLLER_PROMISE_0100
* @tc.desc : Testing get controller
* @tc.size : MediumTest
* @tc.type : Function
* @tc.level : Level2
*/
it
(
'
SUB_MULTIMEDIA_AVSESSION_GETCONTROLLER_PROMISE_0100
'
,
0
,
async
function
(
done
)
{
await
session
.
getController
().
then
((
data
)
=>
{
console
.
info
(
'
Get controller successfully
'
);
expect
(
true
).
assertTrue
();
}).
catch
((
err
)
=>
{
console
.
info
(
'
Get controller failed
'
);
console
.
info
(
`Get controller BusinessError:
${
err
.
code
}
, message:
${
err
.
message
}
`
);
expect
(
false
).
assertTrue
();
});
done
();
})
/* *
* @tc.number : SUB_MULTIMEDIA_AVSESSION_GETCONTROLLER_CALLBACK_0100
* @tc.name : GETCONTROLLER_CALLBACK_0100
* @tc.desc : Testing get controller
* @tc.size : MediumTest
* @tc.type : Function
* @tc.level : Level2
*/
it
(
'
SUB_MULTIMEDIA_AVSESSION_GETCONTROLLER_CALLBACK_0100
'
,
0
,
async
function
(
done
)
{
session
.
getController
((
err
,
data
)
=>
{
if
(
err
)
{
console
.
info
(
'
Get controller failed
'
);
expect
(
false
).
assertTrue
();
}
else
{
console
.
info
(
'
Get controller successfully
'
);
expect
(
true
).
assertTrue
();
}
})
done
();
})
})
}
\ No newline at end of file
multimedia/avsession/avsession_js_standard/avsessionManager/src/main/js/test/AVSessionController.test.js
100644 → 100755
浏览文件 @
c5bbc5af
...
...
@@ -1680,5 +1680,59 @@ export default function Controller() {
await
sleep
(
500
);
done
();
})
/* *
* @tc.number : SUB_MULTIMEDIA_AVSESSION_GETOUTPUTDEVICE_CALLBACK_0100
* @tc.name : GETOUTPUTDEVICE_CALLBACK_0100
* @tc.desc : Testing get output device
* @tc.size : MediumTest
* @tc.type : Function
* @tc.level : Level2
*/
it
(
'
SUB_MULTIMEDIA_AVSESSION_GETOUTPUTDEVICE_CALLBACK_0100
'
,
0
,
async
function
(
done
)
{
controller
.
on
(
'
outputDeviceChange
'
,
(
callback
)
=>
{
if
(
!
callback
.
isRemote
)
{
console
.
info
(
'
outputDeviceChange callback registration successful
'
);
expect
(
true
).
assertTrue
();
}
else
{
console
.
info
(
'
outputDeviceChange callback registration fail
'
);
expect
(
false
).
assertTrue
();
}
});
controller
.
off
(
'
outputDeviceChange
'
);
controller
.
getOutputDevice
((
err
,
value
)
=>
{
if
(
err
)
{
console
.
info
(
`Get device information BusinessError:
${
err
.
code
}
, message:
${
err
.
message
}
`
);
expect
(
false
).
assertTrue
();
}
else
if
(
!
value
.
isRemote
)
{
console
.
info
(
'
Get device information successfully
'
);
expect
(
true
).
assertTrue
();
}
else
{
console
.
info
(
'
Get device information failed
'
);
expect
(
false
).
assertTrue
();
}
});
done
();
})
/* *
* @tc.number : SUB_MULTIMEDIA_AVSESSION_GETOUTPUTDEVICE_PROMISE_0100
* @tc.name : GETOUTPUTDEVICE_PROMISE_0100
* @tc.desc : Testing get output device
* @tc.size : MediumTest
* @tc.type : Function
* @tc.level : Level2
*/
it
(
'
SUB_MULTIMEDIA_AVSESSION_GETOUTPUTDEVICE_PROMISE_0100
'
,
0
,
async
function
(
done
)
{
await
controller
.
getOutputDevice
().
then
((
value
)
=>
{
console
.
info
(
'
Get device information successfully
'
);
expect
(
true
).
assertTrue
();
}).
catch
((
err
)
=>
{
console
.
info
(
`Get device BusinessError:
${
err
.
code
}
, message:
${
err
.
message
}
`
);
expect
(
false
).
assertTrue
();
})
done
();
})
})
}
\ No newline at end of file
multimedia/avsession/avsession_js_standard/avsessionManager/src/main/js/test/AVSessionErrorCode.test.js
0 → 100755
浏览文件 @
c5bbc5af
/*
* 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
avSession
from
'
@ohos.multimedia.avsession
'
;
import
{
describe
,
beforeAll
,
beforeEach
,
afterEach
,
afterAll
,
it
,
expect
}
from
'
@ohos/hypium
'
;
import
featureAbility
from
'
@ohos.ability.featureAbility
'
;
export
default
function
AVSessionErrorCode
()
{
describe
(
'
AVSessionErrorCode
'
,
function
()
{
let
tag
=
'
ApplicationA
'
;
let
type
=
'
audio
'
;
let
session
;
let
pid
=
100
;
let
uid
=
200
;
let
audioDevices
;
let
sessionToken
;
let
controller
;
let
id
=
'
9527
'
;
let
sessionId
;
let
keyItem
=
{
code
:
10
,
pressedTime
:
123456789
,
deviceId
:
0
};
let
event
=
{
action
:
2
,
key
:
keyItem
,
keys
:[
keyItem
]};
let
context
=
featureAbility
.
getContext
();
function
sleep
(
ms
)
{
return
new
Promise
(
resolve
=>
setTimeout
(
resolve
,
ms
));
}
beforeAll
(
function
()
{
console
.
info
(
'
TestLog: Start Testing avSession Interfaces
'
);
})
beforeEach
(
async
function
()
{
console
.
info
(
'
TestLog: Init Session And Controller
'
);
await
avSession
.
createAVSession
(
context
,
tag
,
type
).
then
((
data
)
=>
{
session
=
data
;
}).
catch
((
err
)
=>
{
expect
(
err
.
code
==
6600101
).
assertTrue
();
console
.
info
(
avSession
.
AVSessionErrorCode
.
ERR_CODE_SERVICE_EXCEPTION
);
console
.
info
(
`TestLog: Session create error: code:
${
err
.
code
}
, message:
${
err
.
message
}
`
);
expect
(
false
).
assertTrue
();
});
await
session
.
activate
().
then
(()
=>
{
console
.
info
(
'
TestLog: Session activate
'
);
}).
catch
((
err
)
=>
{
console
.
info
(
`TestLog: Session activate error: code:
${
err
.
code
}
, message:
${
err
.
message
}
`
);
expect
(
false
).
assertTrue
();
});
await
avSession
.
createController
(
session
.
sessionId
).
then
((
data
)
=>
{
controller
=
data
;
}).
catch
((
err
)
=>
{
console
.
info
(
`TestLog: Controller create error: code:
${
err
.
code
}
, message:
${
err
.
message
}
`
);
expect
(
false
).
assertTrue
();
});
})
afterEach
(
async
function
(
done
)
{
console
.
info
(
'
TestLog: Destroy Session And Controller
'
);
await
session
.
destroy
().
then
(()
=>
{
console
.
info
(
'
TestLog: Session destroy success
'
);
}).
catch
((
err
)
=>
{
console
.
info
(
`TestLog: Session destroy error: code:
${
err
.
code
}
, message:
${
err
.
message
}
`
);
expect
(
false
).
assertTrue
();
});
await
controller
.
destroy
().
then
(()
=>
{
console
.
info
(
'
TestLog: Controller destroy success
'
);
}).
catch
((
err
)
=>
{
console
.
info
(
`TestLog: Controller destroy error: code:
${
err
.
code
}
, message:
${
err
.
message
}
`
);
expect
(
false
).
assertTrue
();
});
done
();
})
afterAll
(
function
()
{
console
.
info
(
'
TestLog: End Testing avSession Interfaces
'
);
})
/* *
* @tc.number : SUB_MULTIMEDIA_AVSESSION_SET_METADATA_PROMISE_0100
* @tc.name : SETMETADATA_0100
* @tc.desc : Testing set metadata - promise
* @tc.size : MediumTest
* @tc.type : Function
* @tc.level : Level2
*/
it
(
'
SUB_MULTIMEDIA_AVSESSION_SET_METADATA_PROMISE_0100
'
,
0
,
async
function
(
done
)
{
let
metadata1
=
{
assetId
:
'
121278
'
,
};
await
sleep
(
500
);
await
session
.
setAVMetadata
(
metadata1
).
then
(()
=>
{
console
.
info
(
'
TestLog: Set metadata successfully
'
);
expect
(
true
).
assertTrue
();
}).
catch
((
err
)
=>
{
expect
(
err
.
code
==
6600102
).
assertTrue
();
console
.
info
(
avSession
.
AVSessionErrorCode
.
ERR_CODE_SESSION_NOT_EXIST
);
console
.
info
(
`TestLog: Set metadata error: code:
${
err
.
code
}
, message:
${
err
.
message
}
`
);
});
done
();
})
/* *
* @tc.number : SUB_MULTIMEDIA_AVSESSION_DESTROYCONTROLLER_PROMISE_0100
* @tc.name : DESTROYCONTROLLER_0100
* @tc.desc : Testing destroy the controller - promise
* @tc.size : MediumTest
* @tc.type : Function
* @tc.level : Level1
*/
it
(
'
SUB_MULTIMEDIA_AVSESSION_DESTROYCONTROLLER_PROMISE_0100
'
,
0
,
async
function
(
done
)
{
await
controller
.
destroy
().
then
(()
=>
{
console
.
info
(
'
TestLog: Controller destroy successfully
'
);
expect
(
true
).
assertTrue
();
}).
catch
((
err
)
=>
{
expect
(
err
.
code
==
6600103
).
assertTrue
();
console
.
info
(
avSession
.
AVSessionErrorCode
.
ERR_CODE_CONTROLLER_NOT_EXIST
);
console
.
info
(
`TestLog: Controller destroy error: code:
${
err
.
code
}
, message:
${
err
.
message
}
`
);
expect
(
false
).
assertTrue
();
});
done
();
})
/* *
* @tc.number : SUB_MULTIMEDIA_AVSESSION_OFFPLAY_0100
* @tc.name : OFFPLAY_0100
* @tc.desc : Testing offPlay callback
* @tc.size : MediumTest
* @tc.type : Function
* @tc.level : Level2
*/
it
(
'
SUB_MULTIMEDIA_AVSESSION_OFFPLAY_0100
'
,
0
,
async
function
(
done
)
{
function
callback1
()
{
console
.
info
(
'
TestLog: Play command registration1 success
'
);
expect
(
true
).
assertTrue
();
}
session
.
on
(
'
play
'
,
callback1
);
await
controller
.
sendControlCommand
({
command
:
'
play
'
}).
then
(()
=>
{
console
.
info
(
'
TestLog: Controller send command successfully
'
);
expect
(
true
).
assertTrue
();
}).
catch
((
err
)
=>
{
expect
(
err
.
code
==
6600105
).
assertTrue
();
console
.
info
(
avSession
.
AVSessionErrorCode
.
ERR_CODE_COMMAND_INVALID
);
console
.
info
(
`TestLog: Controller send command error: code:
${
err
.
code
}
, message:
${
err
.
message
}
`
);
});
await
sleep
(
500
);
done
();
})
/* *
* @tc.number : SUB_MULTIMEDIA_AVSESSION_CAST_AUDIO_PROMISE_0100
* @tc.name : CAST_AUDIO_0100
* @tc.desc : Testing cast audio
* @tc.size : MediumTest
* @tc.type : Function
* @tc.level : Level2
*/
it
(
'
SUB_MULTIMEDIA_AVSESSION_CAST_AUDIO_PROMISE_0100
'
,
0
,
async
function
(
done
)
{
sessionId
=
session
.
sessionId
;
sessionToken
=
{
sessionId
,
pid
,
uid
};
try
{
await
avSession
.
castAudio
(
sessionToken
,
audioDevices
).
then
(()
=>
{
console
.
info
(
'
Cast audio to remote
'
);
}).
catch
((
err
)
=>
{
console
.
info
(
avSession
.
AVSessionErrorCode
.
ERR_CODE_REMOTE_CONNECTION_ERR
);
console
.
info
(
`Cast audio to remote BusinessError:
${
err
.
code
}
, message:
${
err
.
message
}
`
);
expect
(
false
).
assertTrue
();
});
}
catch
(
err
)
{
console
.
info
(
`Testing has failed BusinessError:
${
err
.
code
}
, message:
${
err
.
message
}
`
);
expect
(
true
).
assertTrue
();
}
done
();
})
/* *
* @tc.number : SUB_MULTIMEDIA_AVSESSION_ONHANDLEKEYEVENT_0100
* @tc.name : ONHANDLEKEYEVENT_0100
* @tc.desc : Testing Handle KeyEvent callback
* @tc.size : MediumTest
* @tc.type : Function
* @tc.level : Level2
*/
it
(
'
SUB_MULTIMEDIA_AVSESSION_ONHANDLEKEYEVENT_0100
'
,
0
,
async
function
(
done
)
{
session
.
on
(
'
handleKeyEvent
'
,
(
callback
)
=>
{
if
(
callback
.
action
===
2
)
{
console
.
info
(
'
TestLog: Handle keyEvent callback registration successful
'
);
expect
(
true
).
assertTrue
();
}
else
{
console
.
info
(
'
TestLog: Handle keyEvent callback registration error
'
);
expect
(
false
).
assertTrue
();
}
});
await
controller
.
sendAVKeyEvent
(
event
).
then
(()
=>
{
console
.
info
(
'
TestLog: Controller send AVKeyEvent successfully
'
);
}).
catch
((
err
)
=>
{
expect
(
err
.
code
==
6600106
).
assertTrue
();
console
.
info
(
avSession
.
AVSessionErrorCode
.
ERR_CODE_SESSION_INACTIVE
);
console
.
info
(
`TestLog: Controller send AVKeyEvent error: code:
${
err
.
code
}
, message:
${
err
.
message
}
`
);
expect
(
false
).
assertTrue
();
});
await
sleep
(
500
);
done
();
})
/* *
* @tc.number : SUB_MULTIMEDIA_AVSESSION_ONPLAY_0100
* @tc.name : ONPLAY_0100
* @tc.desc : Testing onPlay callback
* @tc.size : MediumTest
* @tc.type : Function
* @tc.level : Level2
*/
it
(
'
SUB_MULTIMEDIA_AVSESSION_ONPLAY_0100
'
,
0
,
async
function
(
done
)
{
session
.
on
(
'
play
'
,
()
=>
{
console
.
info
(
'
TestLog: Play command callback registration successful
'
);
expect
(
true
).
assertTrue
();
});
await
controller
.
sendControlCommand
({
command
:
'
play
'
}).
then
(()
=>
{
console
.
info
(
'
TestLog: Controller send command successfully
'
);
}).
catch
((
err
)
=>
{
expect
(
err
.
code
==
6600107
).
assertTrue
();
console
.
info
(
avSession
.
AVSessionErrorCode
.
ERR_CODE_MESSAGE_OVERLOAD
);
console
.
info
(
`TestLog: Controller send command error: code:
${
err
.
code
}
, message:
${
err
.
message
}
`
);
expect
(
false
).
assertTrue
();
});
await
sleep
(
500
);
done
();
})
})
}
\ No newline at end of file
multimedia/avsession/avsession_js_standard/avsessionManager/src/main/js/test/AVSessionManager.test.js
100644 → 100755
浏览文件 @
c5bbc5af
...
...
@@ -24,6 +24,11 @@ export default function AVSessionManager() {
let
session
;
let
controller
;
let
id
=
'
9527
'
;
let
sessionId
;
let
pid
=
100
;
let
uid
=
200
;
let
audioDevices
;
let
sessionToken
;
let
keyItem
=
{
code
:
10
,
pressedTime
:
123456789
,
deviceId
:
0
};
let
event
=
{
action
:
2
,
key
:
keyItem
,
keys
:[
keyItem
]};
let
context
=
featureAbility
.
getContext
();
...
...
@@ -1140,5 +1145,137 @@ export default function AVSessionManager() {
});
done
();
})
/* *
* @tc.number : SUB_MULTIMEDIA_AVSESSION_CAST_AUDIO_PROMISE_0100
* @tc.name : CAST_AUDIO_PROMISE_0100
* @tc.desc : Testing cast audio
* @tc.size : MediumTest
* @tc.type : Function
* @tc.level : Level2
*/
it
(
'
SUB_MULTIMEDIA_AVSESSION_CAST_AUDIO_PROMISE_0100
'
,
0
,
async
function
(
done
)
{
await
avSession
.
createAVSession
(
context
,
tag
,
type
).
then
((
data
)
=>
{
session
=
data
;
sessionId
=
session
.
sessionId
;
sessionToken
=
{
sessionId
,
pid
,
uid
};
}).
catch
((
err
)
=>
{
console
.
info
(
`Session create BusinessError:
${
err
.
code
}
, message:
${
err
.
message
}
`
);
});
await
avSession
.
castAudio
(
sessionToken
,
audioDevices
).
then
(()
=>
{
console
.
info
(
'
Cast audio to remote
'
);
}).
catch
((
err
)
=>
{
console
.
info
(
`Cast audio to remote BusinessError:
${
err
.
code
}
, message:
${
err
.
message
}
`
);
expect
(
true
).
assertTrue
();
});
await
session
.
destroy
().
then
(()
=>
{
console
.
info
(
'
TestLog: Session Destroy SUCCESS
'
);
}).
catch
((
err
)
=>
{
console
.
info
(
`TestLog: Session Destroy error: code:
${
err
.
code
}
, message:
${
err
.
message
}
`
);
});
done
();
})
/* *
* @tc.number : SUB_MULTIMEDIA_AVSESSION_CAST_AUDIO_PROMISE_0200
* @tc.name : CAST_AUDIO_PROMISE_0200
* @tc.desc : Testing cast audio with all session
* @tc.size : MediumTest
* @tc.type : Function
* @tc.level : Level2
*/
it
(
'
SUB_MULTIMEDIA_AVSESSION_CAST_AUDIO_PROMISE_0200
'
,
0
,
async
function
(
done
)
{
await
avSession
.
createAVSession
(
context
,
tag
,
type
).
then
((
data
)
=>
{
session
=
data
;
sessionId
=
session
.
sessionId
;
sessionToken
=
{
sessionId
,
pid
,
uid
};
}).
catch
((
err
)
=>
{
console
.
info
(
`Session create BusinessError:
${
err
.
code
}
, message:
${
err
.
message
}
`
);
});
await
avSession
.
castAudio
(
'
all
'
,
audioDevices
).
then
(()
=>
{
console
.
info
(
'
Cast audio to remote
'
);
}).
catch
((
err
)
=>
{
console
.
info
(
`Cast audio to remote BusinessError:
${
err
.
code
}
, message:
${
err
.
message
}
`
);
expect
(
true
).
assertTrue
();
});
await
session
.
destroy
().
then
(()
=>
{
console
.
info
(
'
TestLog: Session Destroy SUCCESS
'
);
}).
catch
((
err
)
=>
{
console
.
info
(
`TestLog: Session Destroy error: code:
${
err
.
code
}
, message:
${
err
.
message
}
`
);
});
done
();
})
/* *
* @tc.number : SUB_MULTIMEDIA_AVSESSION_CAST_AUDIO_CALLBACK_0100
* @tc.name : CAST_AUDIO_CALLBACK_0100
* @tc.desc : Testing cast audio
* @tc.size : MediumTest
* @tc.type : Function
* @tc.level : Level2
*/
it
(
'
SUB_MULTIMEDIA_AVSESSION_CAST_AUDIO_CALLBACK_0100
'
,
0
,
async
function
(
done
)
{
await
avSession
.
createAVSession
(
context
,
tag
,
type
).
then
((
data
)
=>
{
session
=
data
;
sessionId
=
session
.
sessionId
;
sessionToken
=
{
sessionId
,
pid
,
uid
};
}).
catch
((
err
)
=>
{
console
.
info
(
`Session create BusinessError:
${
err
.
code
}
, message:
${
err
.
message
}
`
);
});
avSession
.
castAudio
(
sessionToken
,
audioDevices
,
(
err
)
=>
{
if
(
err
)
{
console
.
info
(
`Cast audio to remote BusinessError:
${
err
.
code
}
, message:
${
err
.
message
}
`
);
expect
(
true
).
assertTrue
();
}
else
{
console
.
info
(
'
Cast audio to remote device
'
);
}
});
await
session
.
destroy
().
then
(()
=>
{
console
.
info
(
'
TestLog: Session Destroy SUCCESS
'
);
}).
catch
((
err
)
=>
{
console
.
info
(
`TestLog: Session Destroy error: code:
${
err
.
code
}
, message:
${
err
.
message
}
`
);
});
done
();
})
/* *
* @tc.number : SUB_MULTIMEDIA_AVSESSION_CAST_AUDIO_CALLBACK_0200
* @tc.name : CAST_AUDIO_CALLBACK_0200
* @tc.desc : Testing cast audio
* @tc.size : MediumTest
* @tc.type : Function
* @tc.level : Level2
*/
it
(
'
SUB_MULTIMEDIA_AVSESSION_CAST_AUDIO_CALLBACK_0200
'
,
0
,
async
function
(
done
)
{
await
avSession
.
createAVSession
(
context
,
tag
,
type
).
then
((
data
)
=>
{
session
=
data
;
sessionId
=
session
.
sessionId
;
sessionToken
=
{
sessionId
,
pid
,
uid
};
}).
catch
((
err
)
=>
{
console
.
info
(
`Session create BusinessError:
${
err
.
code
}
, message:
${
err
.
message
}
`
);
});
avSession
.
castAudio
(
'
all
'
,
audioDevices
,
(
err
)
=>
{
if
(
err
)
{
console
.
info
(
`Cast audio to remote BusinessError:
${
err
.
code
}
, message:
${
err
.
message
}
`
);
expect
(
true
).
assertTrue
();
}
else
{
console
.
info
(
'
Cast audio to remote device
'
);
}
});
await
session
.
destroy
().
then
(()
=>
{
console
.
info
(
'
TestLog: Session Destroy SUCCESS
'
);
}).
catch
((
err
)
=>
{
console
.
info
(
`TestLog: Session Destroy error: code:
${
err
.
code
}
, message:
${
err
.
message
}
`
);
});
done
();
})
})
}
\ No newline at end of file
multimedia/avsession/avsession_js_standard/avsessionManager/src/main/js/test/List.test.js
100644 → 100755
浏览文件 @
c5bbc5af
...
...
@@ -18,6 +18,7 @@ import AVSessionManager from './AVSessionManager.test.js';
import
AVSessionCallback
from
'
./AVSessionCallback.test.js
'
;
import
AVSessionControllerCallback
from
'
./AVSessionControllerCallback.test.js
'
;
import
AVSessionManagerCallback
from
'
./AVSessionManagerCallback.test.js
'
;
import
AVSessionErrorCode
from
'
./AVSessionErrorCode.test
'
;
export
default
function
testsuite
()
{
AVSession
()
...
...
@@ -26,4 +27,5 @@ export default function testsuite() {
AVSessionCallback
()
AVSessionControllerCallback
()
AVSessionManagerCallback
()
AVSessionErrorCode
()
}
\ No newline at end of file
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录