Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
OpenHarmony
Xts Acts
提交
be2c9903
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看板
提交
be2c9903
编写于
2月 15, 2023
作者:
L
lwx1121892
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
<audio_prefer output device>
Signed-off-by:
N
lwx1121892
<
liuxueqi3@huawei.com
>
上级
c4f268de
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
331 addition
and
0 deletion
+331
-0
multimedia/audio/audio_js_standard/audioManager/src/main/js/test/AudioRoutingManager.test.js
...audioManager/src/main/js/test/AudioRoutingManager.test.js
+329
-0
multimedia/audio/audio_js_standard/audioManager/src/main/js/test/List.test.js
...io_js_standard/audioManager/src/main/js/test/List.test.js
+2
-0
未找到文件。
multimedia/audio/audio_js_standard/audioManager/src/main/js/test/AudioRoutingManager.test.js
0 → 100644
浏览文件 @
be2c9903
/*
* 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
audio
from
'
@ohos.multimedia.audio
'
;
import
{
afterAll
,
afterEach
,
beforeAll
,
beforeEach
,
describe
,
expect
,
it
}
from
'
@ohos/hypium
'
;
export
default
function
audioRoutingManager
()
{
const
TAG
=
"
[AudioRoutingManagerJsTest]
"
;
const
stringParameter
=
'
stringParameter
'
;
const
numberParameter
=
12345678
;
describe
(
"
AudioRoutingManagerJsTest
"
,
function
()
{
beforeAll
(
async
function
()
{
console
.
info
(
TAG
+
"
beforeAll called
"
);
})
afterAll
(
function
()
{
console
.
info
(
TAG
+
'
afterAll called
'
)
})
beforeEach
(
function
()
{
console
.
info
(
TAG
+
'
beforeEach called
'
)
})
afterEach
(
function
()
{
console
.
info
(
TAG
+
'
afterEach called
'
)
})
function
sleep
(
time
)
{
return
new
Promise
((
resolve
)
=>
setTimeout
(
resolve
,
time
));
}
/**
*@tc.number : SUB_MULTIMEDIA_AUDIO_GETREFEROUTPUTDEVICEFORRENDERERINFOTEST_0100
*@tc.name : Get prefer output device - promise
*@tc.desc : Get prefer output device - promise
*@tc.size : MEDIUM
*@tc.type : Function
*@tc.level : Level 0
*/
it
(
"
SUB_MULTIMEDIA_AUDIO_GETPREFEROUTUTDEVICEFORRENDERERINFOTEST_0100
"
,
0
,
async
function
(
done
)
{
let
rendererInfo
=
{
content
:
audio
.
ContentType
.
CONTENT_TYPE_MUSIC
,
usage
:
audio
.
StreamUsage
.
STREAM_USAGE_MEDIA
,
rendererFlags
:
0
}
let
routingManager
=
audio
.
getAudioManager
().
getRoutingManager
();
try
{
let
data
=
await
routingManager
.
getPreferOutputDeviceForRendererInfo
(
rendererInfo
);
console
.
info
(
`
${
TAG
}
SUB_MULTIMEDIA_AUDIO_GETREFEROUTPUTDEVICEFORRENDERERINFOTEST_0100 SUCCESS`
+
JSON
.
stringify
(
data
));
expect
(
true
).
assertTrue
();
done
();
}
catch
(
e
)
{
console
.
error
(
`
${
TAG
}
SUB_MULTIMEDIA_AUDIO_GETREFEROUTPUTDEVICEFORRENDERERINFOTEST_0100 ERROR:
${
e
.
message
}
`
);
expect
().
assertFail
();
done
();
}
})
/**
*@tc.number : SUB_MULTIMEDIA_AUDIO_GETREFEROUTPUTDEVICEFORRENDERERINFOTEST_0200
*@tc.name : Get prefer output device no parameter- promise
*@tc.desc : Get prefer output device no parameter- promise
*@tc.size : MEDIUM
*@tc.type : Function
*@tc.level : Level 0
*/
it
(
"
SUB_MULTIMEDIA_AUDIO_GETREFEROUTPUTDEVICEFORRENDERERINFOTEST_0200
"
,
0
,
async
function
(
done
)
{
let
routingManager
=
audio
.
getAudioManager
().
getRoutingManager
();
try
{
let
data
=
await
routingManager
.
getPreferOutputDeviceForRendererInfo
();
console
.
error
(
`
${
TAG
}
SUB_MULTIMEDIA_AUDIO_GETREFEROUTPUTDEVICEFORRENDERERINFOTEST_0200 parameter check ERROR:
${
JSON
.
stringify
(
data
)}
`
);
expect
().
assertFail
();
}
catch
(
e
)
{
if
(
e
.
code
!=
audio
.
AudioErrors
.
ERROR_INVALID_PARAM
)
{
console
.
error
(
`
${
TAG
}
SUB_MULTIMEDIA_AUDIO_GETREFEROUTPUTDEVICEFORRENDERERINFOTEST_0200 ERROR:
${
e
.
message
}
`
);
expect
().
assertFail
();
done
();
}
console
.
info
(
`
${
TAG
}
SUB_MULTIMEDIA_AUDIO_GETREFEROUTPUTDEVICEFORRENDERERINFOTEST_0200 check no parameter PASS`
);
expect
(
true
).
assertTrue
();
}
done
();
})
/**
*@tc.number : SUB_MULTIMEDIA_AUDIO_GETREFEROUTPUTDEVICEFORRENDERERINFOTEST_0300
*@tc.name : Get prefer output device check number parameter- promise
*@tc.desc : Get prefer output device check number parameter- promise
*@tc.size : MEDIUM
*@tc.type : Function
*@tc.level : Level 0
*/
it
(
"
SUB_MULTIMEDIA_AUDIO_GETREFEROUTPUTDEVICEFORRENDERERINFOTEST_0300
"
,
0
,
async
function
(
done
)
{
let
routingManager
=
audio
.
getAudioManager
().
getRoutingManager
();
try
{
let
data
=
await
routingManager
.
getPreferOutputDeviceForRendererInfo
(
numberParameter
);
console
.
error
(
`
${
TAG
}
SUB_MULTIMEDIA_AUDIO_GETPREFEROUTPUTDEVICEFORRENDERERINFOTEST_0300 parameter check ERROR: `
+
JSON
.
stringify
(
data
));
expect
().
assertFail
();
}
catch
(
e
)
{
if
(
e
.
code
!=
audio
.
AudioErrors
.
ERROR_INVALID_PARAM
)
{
console
.
error
(
`
${
TAG
}
SUB_MULTIMEDIA_AUDIO_GETREFEROUTPUTDEVICEFORRENDERERINFOTEST_0300 ERROR:
${
e
.
message
}
`
);
expect
().
assertFail
();
done
();
}
console
.
info
(
`
${
TAG
}
SUB_MULTIMEDIA_AUDIO_GETREFEROUTPUTDEVICEFORRENDERERINFOTEST_0300 check number parameter PASS`
);
expect
(
true
).
assertTrue
();
}
done
();
})
/**
*@tc.number : SUB_MULTIMEDIA_AUDIO_GETREFEROUTPUTDEVICEFORRENDERERINFOTEST_0400
*@tc.name : Get prefer output device check string parameter- promise
*@tc.desc : Get prefer output device check string parameter- promise
*@tc.size : MEDIUM
*@tc.type : Function
*@tc.level : Level 0
*/
it
(
"
SUB_MULTIMEDIA_AUDIO_GETREFEROUTPUTDEVICEFORRENDERERINFOTEST_0400
"
,
0
,
async
function
(
done
)
{
let
routingManager
=
audio
.
getAudioManager
().
getRoutingManager
();
try
{
let
data
=
await
routingManager
.
getPreferOutputDeviceForRendererInfo
(
stringParameter
);
console
.
error
(
`
${
TAG
}
SUB_MULTIMEDIA_AUDIO_GETREFEROUTPUTDEVICEFORRENDERERINFOTEST_0400 parameter check ERROR: `
+
JSON
.
stringify
(
data
));
expect
().
assertFail
();
}
catch
(
e
)
{
if
(
e
.
code
!=
audio
.
AudioErrors
.
ERROR_INVALID_PARAM
)
{
console
.
error
(
`
${
TAG
}
SUB_MULTIMEDIA_AUDIO_GETREFEROUTPUTDEVICEFORRENDERERINFOTEST_0400 ERROR:
${
e
.
message
}
`
);
expect
().
assertFail
();
done
();
}
console
.
info
(
`
${
TAG
}
SUB_MULTIMEDIA_AUDIO_GETREFEROUTPUTDEVICEFORRENDERERINFOTEST_0400 check string parameter PASS`
);
expect
(
true
).
assertTrue
();
}
done
();
})
/**
*@tc.number : SUB_MULTIMEDIA_AUDIO_GETREFEROUTPUTDEVICEFORRENDERERINFOTEST_0500
*@tc.name : Get prefer output device - callback
*@tc.desc : Get prefer output device - callback
*@tc.size : MEDIUM
*@tc.type : Function
*@tc.level : Level 0
*/
it
(
"
SUB_MULTIMEDIA_AUDIO_GETREFEROUTPUTDEVICEFORRENDERERINFOTEST_0500
"
,
0
,
async
function
(
done
)
{
let
rendererInfo
=
{
content
:
audio
.
ContentType
.
CONTENT_TYPE_MUSIC
,
usage
:
audio
.
StreamUsage
.
STREAM_USAGE_MEDIA
,
rendererFlags
:
0
}
let
routingManager
=
audio
.
getAudioManager
().
getRoutingManager
();
routingManager
.
getPreferOutputDeviceForRendererInfo
(
rendererInfo
,
(
e
,
data
)
=>
{
if
(
e
)
{
console
.
error
(
`
${
TAG
}
SUB_MULTIMEDIA_AUDIO_GETREFEROUTPUTDEVICEFORRENDERERINFOTEST_0500 ERROR:
${
e
.
message
}
`
);
expect
(
false
).
assertTrue
();
done
();
}
console
.
info
(
`
${
TAG
}
SUB_MULTIMEDIA_AUDIO_GETREFEROUTPUTDEVICEFORRENDERERINFOTEST_0500 SUCCESS`
);
expect
(
true
).
assertTrue
();
done
();
});
})
/**
*@tc.number : SUB_MULTIMEDIA_AUDIO_GETPREFEROUTPUTDEVICEFORRENDERERINFOTEST_0600
*@tc.name : Get prefer output device check number parameter- callback
*@tc.desc : Get prefer output device check number parameter- callback
*@tc.size : MEDIUM
*@tc.type : Function
*@tc.level : Level 0
*/
it
(
"
SUB_MULTIMEDIA_AUDIO_GETREFEROUTPUTDEVICEFORRENDERERINFOTEST_0600
"
,
0
,
async
function
(
done
)
{
let
routingManager
=
audio
.
getAudioManager
().
getRoutingManager
();
routingManager
.
getPreferOutputDeviceForRendererInfo
(
numberParameter
,
(
e
,
data
)
=>
{
if
(
e
.
code
!=
audio
.
AudioErrors
.
ERROR_INVALID_PARAM
)
{
console
.
error
(
`
${
TAG
}
SUB_MULTIMEDIA_AUDIO_GETREFEROUTPUTDEVICEFORRENDERERINFOTEST_0600 ERROR:
${
e
.
message
}
`
);
expect
().
assertFail
();
done
();
}
console
.
info
(
`
${
TAG
}
SUB_MULTIMEDIA_AUDIO_GETREFEROUTPUTDEVICEFORRENDERERINFOTEST_0600 check number parameter PASS`
);
expect
(
true
).
assertTrue
();
done
();
});
})
/**
*@tc.number : SUB_MULTIMEDIA_AUDIO_GETREFEROUTPUTDEVICEFORRENDERERINFOTEST_0700
*@tc.name : Get prefer output device check number parameter- callback
*@tc.desc : Get prefer output device check number parameter- callback
*@tc.size : MEDIUM
*@tc.type : Function
*@tc.level : Level 0
*/
it
(
"
SUB_MULTIMEDIA_AUDIO_GETREFEROUTPUTDEVICEFORRENDERERINFOTEST_0700
"
,
0
,
async
function
(
done
)
{
let
routingManager
=
audio
.
getAudioManager
().
getRoutingManager
();
routingManager
.
getPreferOutputDeviceForRendererInfo
(
stringParameter
,
(
e
,
data
)
=>
{
if
(
e
.
code
!=
audio
.
AudioErrors
.
ERROR_INVALID_PARAM
)
{
console
.
error
(
`
${
TAG
}
SUB_MULTIMEDIA_AUDIO_GETREFEROUTPUTDEVICEFORRENDERERINFOTEST_0700 ERROR:
${
e
.
message
}
`
);
expect
().
assertFail
();
done
();
}
console
.
info
(
`
${
TAG
}
SUB_MULTIMEDIA_AUDIO_GETREFEROUTPUTDEVICEFORRENDERERINFOTEST_0700 check string parameter PASS`
);
expect
(
true
).
assertTrue
();
done
();
});
})
/**
*@tc.number : SUB_MULTIMEDIA_AUDIO_ON_REFEROUTPUTDEVICEFORRENDERERINFOTEST_0100
*@tc.name : Get prefer output device check number parameter- callback
*@tc.desc : Get prefer output device check number parameter- callback
*@tc.size : MEDIUM
*@tc.type : Function
*@tc.level : Level 0
*/
it
(
"
SUB_MULTIMEDIA_AUDIO_ON_REFEROUTPUTDEVICEFORRENDERERINFOTEST_0100
"
,
0
,
async
function
(
done
)
{
let
rendererInfo
=
{
content
:
audio
.
ContentType
.
CONTENT_TYPE_MUSIC
,
usage
:
audio
.
StreamUsage
.
STREAM_USAGE_MEDIA
,
rendererFlags
:
0
}
let
routingManager
=
audio
.
getAudioManager
().
getRoutingManager
();
try
{
routingManager
.
on
(
'
preferOutputDeviceChangeForRendererInfo
'
,
rendererInfo
,
(
data
)
=>
{});
expect
(
true
).
assertTrue
();
done
();
}
catch
(
e
)
{
console
.
error
(
`
${
TAG
}
SUB_MULTIMEDIA_AUDIO_ON_REFEROUTPUTDEVICEFORRENDERERINFOTEST_0100 ERROR:
${
e
.
message
}
`
);
expect
().
assertFail
();
done
();
}
})
/**
*@tc.number : SUB_MULTIMEDIA_AUDIO_ON_REFEROUTPUTDEVICEFORRENDERERINFOTEST_0200
*@tc.name : On prefer output device check string parameter- callback
*@tc.desc : On prefer output device check string parameter- callback
*@tc.size : MEDIUM
*@tc.type : Function
*@tc.level : Level 0
*/
it
(
"
SUB_MULTIMEDIA_AUDIO_ON_REFEROUTPUTDEVICEFORRENDERERINFOTEST_0200
"
,
0
,
async
function
(
done
)
{
let
routingManager
=
audio
.
getAudioManager
().
getRoutingManager
();
try
{
routingManager
.
on
(
'
preferOutputDeviceChangeForRendererInfo
'
,
stringParameter
,
(
data
)
=>
{});
console
.
error
(
`
${
TAG
}
SUB_MULTIMEDIA_AUDIO_ON_REFEROUTPUTDEVICEFORRENDERERINFOTEST_0200 with string patameter ERROR:
${
e
.
message
}
`
);
expect
().
assertFail
();
done
();
}
catch
(
e
)
{
if
(
e
.
code
!=
audio
.
AudioErrors
.
ERROR_INVALID_PARAM
)
{
console
.
error
(
`
${
TAG
}
SUB_MULTIMEDIA_AUDIO_ON_REFEROUTPUTDEVICEFORRENDERERINFOTEST_0200 check string parameter ERROR:
${
e
.
message
}
`
);
expect
().
assertFail
();
done
();
}
console
.
info
(
`
${
TAG
}
SUB_MULTIMEDIA_AUDIO_ON_REFEROUTPUTDEVICEFORRENDERERINFOTEST_0200 PASS:
${
e
.
message
}
`
);
expect
(
true
).
assertTrue
();
done
();
}
})
/**
*@tc.number : SUB_MULTIMEDIA_AUDIO_ON_REFEROUTPUTDEVICEFORRENDERERINFOTEST_0300
*@tc.name : On prefer output device check number parameter- callback
*@tc.desc : On prefer output device check number parameter- callback
*@tc.size : MEDIUM
*@tc.type : Function
*@tc.level : Level 0
*/
it
(
"
SUB_MULTIMEDIA_AUDIO_ON_REFEROUTPUTDEVICEFORRENDERERINFOTEST_0300
"
,
0
,
async
function
(
done
)
{
let
routingManager
=
audio
.
getAudioManager
().
getRoutingManager
();
try
{
routingManager
.
on
(
'
preferOutputDeviceChangeForRendererInfo
'
,
numberParameter
,
(
data
)
=>
{});
console
.
error
(
`
${
TAG
}
SUB_MULTIMEDIA_AUDIO_ON_REFEROUTPUTDEVICEFORRENDERERINFOTEST_0300 with number patameter ERROR:
${
e
.
message
}
`
);
expect
().
assertFail
();
done
();
}
catch
(
e
)
{
if
(
e
.
code
!=
audio
.
AudioErrors
.
ERROR_INVALID_PARAM
)
{
console
.
error
(
`
${
TAG
}
SUB_MULTIMEDIA_AUDIO_ON_REFEROUTPUTDEVICEFORRENDERERINFOTEST_0300 check number parameter ERROR:
${
e
.
message
}
`
);
expect
().
assertFail
();
done
();
}
console
.
info
(
`
${
TAG
}
SUB_MULTIMEDIA_AUDIO_ON_REFEROUTPUTDEVICEFORRENDERERINFOTEST_0300 PASS:
${
e
.
message
}
`
);
expect
(
true
).
assertTrue
();
done
();
}
})
/**
*@tc.number : s
*@tc.name : Off prefer output device - callback
*@tc.desc : Off prefer output device - callback
*@tc.size : MEDIUM
*@tc.type : Function
*@tc.level : Level 0
*/
it
(
"
SUB_MULTIMEDIA_AUDIO_OFF_REFEROUTPUTDEVICEFORRENDERERINFOTEST_0100
"
,
0
,
async
function
(
done
)
{
let
routingManager
=
audio
.
getAudioManager
().
getRoutingManager
();
try
{
routingManager
.
off
(
'
preferOutputDeviceChangeForRendererInfo
'
,
(
data
)
=>
{});
console
.
info
(
`
${
TAG
}
SUB_MULTIMEDIA_AUDIO_OFF_REFEROUTPUTDEVICEFORRENDERERINFOTEST_0100 SUCCESS`
);
expect
(
true
).
assertTrue
();
done
();
}
catch
(
e
)
{
console
.
error
(
`
${
TAG
}
SUB_MULTIMEDIA_AUDIO_OFF_REFEROUTPUTDEVICEFORRENDERERINFOTEST_0100 ERROR:
${
e
.
message
}
`
);
expect
().
assertFail
();
done
();
}
})
})
}
\ No newline at end of file
multimedia/audio/audio_js_standard/audioManager/src/main/js/test/List.test.js
浏览文件 @
be2c9903
...
...
@@ -15,10 +15,12 @@
import
audioFramework
from
'
./AudioFramework.test.js
'
import
audioManagerApi9
from
'
./AudioManagerApi9.test.js
'
import
audioRoutingManager
from
'
./AudioRoutingManager.test.js
'
export
default
function
testsuite
()
{
audioFramework
()
audioManagerApi9
()
audioRoutingManager
()
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录