Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
OpenHarmony
Xts Acts
提交
48123541
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看板
未验证
提交
48123541
编写于
6月 21, 2022
作者:
O
openharmony_ci
提交者:
Gitee
6月 21, 2022
浏览文件
操作
浏览文件
下载
差异文件
!3636 修复编解码测试套用例失败问题
Merge pull request !3636 from ling990/ling990
上级
0cfa1c82
185b932b
变更
43
展开全部
隐藏空白更改
内联
并排
Showing
43 changed file
with
340 addition
and
1006 deletion
+340
-1006
multimedia/media/media_js_standard/MediaTestBase.js
multimedia/media/media_js_standard/MediaTestBase.js
+19
-0
multimedia/media/media_js_standard/audioCodecFormat/Test.json
...imedia/media/media_js_standard/audioCodecFormat/Test.json
+75
-75
multimedia/media/media_js_standard/audioCodecFormat/src/main/js/test/AudioDecoderFormatCompatibilityPromiseTest.test.js
...s/test/AudioDecoderFormatCompatibilityPromiseTest.test.js
+10
-46
multimedia/media/media_js_standard/audioCodecFormat/src/main/js/test/AudioEncoderFormatCompatibilityPromiseTest.test.js
...s/test/AudioEncoderFormatCompatibilityPromiseTest.test.js
+10
-45
multimedia/media/media_js_standard/audioCodecFormat/src/main/js/test/AudioFormatTestBase.test.js
...oCodecFormat/src/main/js/test/AudioFormatTestBase.test.js
+0
-38
multimedia/media/media_js_standard/audioDecoder/Test.json
multimedia/media/media_js_standard/audioDecoder/Test.json
+9
-9
multimedia/media/media_js_standard/audioDecoder/src/main/js/test/AudioDecoderEnumTest.test.js
...udioDecoder/src/main/js/test/AudioDecoderEnumTest.test.js
+0
-15
multimedia/media/media_js_standard/audioDecoder/src/main/js/test/AudioDecoderFormatCallbackTest.test.js
...r/src/main/js/test/AudioDecoderFormatCallbackTest.test.js
+12
-50
multimedia/media/media_js_standard/audioDecoder/src/main/js/test/AudioDecoderFormatPromiseTest.test.js
...er/src/main/js/test/AudioDecoderFormatPromiseTest.test.js
+12
-49
multimedia/media/media_js_standard/audioDecoder/src/main/js/test/AudioDecoderFuncCallbackTest.test.js
...der/src/main/js/test/AudioDecoderFuncCallbackTest.test.js
+13
-56
multimedia/media/media_js_standard/audioDecoder/src/main/js/test/AudioDecoderFuncPromiseTest.test.js
...oder/src/main/js/test/AudioDecoderFuncPromiseTest.test.js
+12
-56
multimedia/media/media_js_standard/audioDecoder/src/main/js/test/AudioDecoderMultiInstancesTest.test.js
...r/src/main/js/test/AudioDecoderMultiInstancesTest.test.js
+3
-4
multimedia/media/media_js_standard/audioDecoder/src/main/js/test/AudioDecoderReliabilityCallbackTest.test.js
.../main/js/test/AudioDecoderReliabilityCallbackTest.test.js
+5
-17
multimedia/media/media_js_standard/audioDecoder/src/main/js/test/AudioDecoderReliabilityPromiseTest.test.js
...c/main/js/test/AudioDecoderReliabilityPromiseTest.test.js
+5
-17
multimedia/media/media_js_standard/audioDecoder/src/main/js/test/AudioDecoderTestBase.test.js
...udioDecoder/src/main/js/test/AudioDecoderTestBase.test.js
+0
-38
multimedia/media/media_js_standard/audioDecoder/src/main/js/test/List.test.js
...ia_js_standard/audioDecoder/src/main/js/test/List.test.js
+1
-1
multimedia/media/media_js_standard/audioEncoder/Test.json
multimedia/media/media_js_standard/audioEncoder/Test.json
+5
-5
multimedia/media/media_js_standard/audioEncoder/src/main/js/test/AudioEncoderFuncCallbackTest.test.js
...der/src/main/js/test/AudioEncoderFuncCallbackTest.test.js
+11
-55
multimedia/media/media_js_standard/audioEncoder/src/main/js/test/AudioEncoderFuncPromiseTest.test.js
...oder/src/main/js/test/AudioEncoderFuncPromiseTest.test.js
+12
-56
multimedia/media/media_js_standard/audioEncoder/src/main/js/test/AudioEncoderReliabilityCallbackTest.test.js
.../main/js/test/AudioEncoderReliabilityCallbackTest.test.js
+5
-17
multimedia/media/media_js_standard/audioEncoder/src/main/js/test/AudioEncoderReliabilityPromiseTest.test.js
...c/main/js/test/AudioEncoderReliabilityPromiseTest.test.js
+6
-18
multimedia/media/media_js_standard/audioEncoder/src/main/js/test/AudioEncoderTestBase.test.js
...udioEncoder/src/main/js/test/AudioEncoderTestBase.test.js
+0
-38
multimedia/media/media_js_standard/audioEncoder/src/main/js/test/List.test.js
...ia_js_standard/audioEncoder/src/main/js/test/List.test.js
+0
-1
multimedia/media/media_js_standard/audioRecorder/src/main/js/test/AudioRecorderEnumTest.test.js
...ioRecorder/src/main/js/test/AudioRecorderEnumTest.test.js
+15
-0
multimedia/media/media_js_standard/videoCodecFormat/Test.json
...imedia/media/media_js_standard/videoCodecFormat/Test.json
+15
-15
multimedia/media/media_js_standard/videoCodecFormat/src/main/js/test/VideoDecoderFormatPromiseTest.test.js
...at/src/main/js/test/VideoDecoderFormatPromiseTest.test.js
+4
-12
multimedia/media/media_js_standard/videoCodecFormat/src/main/js/test/VideoEncoderFormatPromiseTest.test.js
...at/src/main/js/test/VideoEncoderFormatPromiseTest.test.js
+6
-32
multimedia/media/media_js_standard/videoCodecFormat/src/main/js/test/VideoFormatTestBase.test.js
...oCodecFormat/src/main/js/test/VideoFormatTestBase.test.js
+0
-38
multimedia/media/media_js_standard/videoDecoder/Test.json
multimedia/media/media_js_standard/videoDecoder/Test.json
+9
-9
multimedia/media/media_js_standard/videoDecoder/src/main/js/test/List.test.js
...ia_js_standard/videoDecoder/src/main/js/test/List.test.js
+1
-2
multimedia/media/media_js_standard/videoDecoder/src/main/js/test/VideoDecoderEnumTest.test.js
...ideoDecoder/src/main/js/test/VideoDecoderEnumTest.test.js
+3
-30
multimedia/media/media_js_standard/videoDecoder/src/main/js/test/VideoDecoderFuncCallbackTest.test.js
...der/src/main/js/test/VideoDecoderFuncCallbackTest.test.js
+5
-13
multimedia/media/media_js_standard/videoDecoder/src/main/js/test/VideoDecoderFuncPromiseTest.test.js
...oder/src/main/js/test/VideoDecoderFuncPromiseTest.test.js
+5
-16
multimedia/media/media_js_standard/videoDecoder/src/main/js/test/VideoDecoderReliCallbackTest.test.js
...der/src/main/js/test/VideoDecoderReliCallbackTest.test.js
+4
-15
multimedia/media/media_js_standard/videoDecoder/src/main/js/test/VideoDecoderReliPromiseTest.test.js
...oder/src/main/js/test/VideoDecoderReliPromiseTest.test.js
+8
-16
multimedia/media/media_js_standard/videoDecoder/src/main/js/test/VideoDecoderSoftwareFuncCallbackTest.test.js
...main/js/test/VideoDecoderSoftwareFuncCallbackTest.test.js
+4
-16
multimedia/media/media_js_standard/videoDecoder/src/main/js/test/VideoDecoderSoftwareFuncPromiseTest.test.js
.../main/js/test/VideoDecoderSoftwareFuncPromiseTest.test.js
+5
-17
multimedia/media/media_js_standard/videoDecoder/src/main/js/test/VideoDecoderSoftwareReliCallbackTest.test.js
...main/js/test/VideoDecoderSoftwareReliCallbackTest.test.js
+4
-14
multimedia/media/media_js_standard/videoDecoder/src/main/js/test/VideoDecoderSoftwareReliPromiseTest.test.js
.../main/js/test/VideoDecoderSoftwareReliPromiseTest.test.js
+8
-15
multimedia/media/media_js_standard/videoDecoder/src/main/js/test/VideoDecoderTestBase.test.js
...ideoDecoder/src/main/js/test/VideoDecoderTestBase.test.js
+0
-38
multimedia/media/media_js_standard/videoEncoder/src/main/js/test/VideoEncoderSoftwareFuncCallbackTest.test.js
...main/js/test/VideoEncoderSoftwareFuncCallbackTest.test.js
+1
-1
multimedia/media/media_js_standard/videoEncoder/src/main/js/test/VideoEncoderSoftwareFuncPromiseTest.test.js
.../main/js/test/VideoEncoderSoftwareFuncPromiseTest.test.js
+1
-1
multimedia/media/media_js_standard/videoRecorder/src/main/js/test/VideoRecorderEnumTest.test.js
...eoRecorder/src/main/js/test/VideoRecorderEnumTest.test.js
+17
-0
未找到文件。
multimedia/media/media_js_standard/MediaTestBase.js
浏览文件 @
48123541
...
...
@@ -19,6 +19,10 @@ import router from '@system.router'
import
abilityAccessCtrl
from
'
@ohos.abilityAccessCtrl
'
import
bundle
from
'
@ohos.bundle
'
import
mediaLibrary
from
'
@ohos.multimedia.mediaLibrary
'
import
fileio
from
'
@ohos.fileio
'
import
featureAbility
from
'
@ohos.ability.featureAbility
'
const
context
=
featureAbility
.
getContext
();
// File operation
export
async
function
getFileDescriptor
(
fileName
)
{
...
...
@@ -52,6 +56,21 @@ export function isFileOpen(fileDescriptor, done) {
}
}
export
async
function
getFdRead
(
pathName
,
done
)
{
let
fdReturn
;
await
context
.
getFilesDir
().
then
((
fileDir
)
=>
{
console
.
info
(
"
case file dir is
"
+
JSON
.
stringify
(
fileDir
));
pathName
=
fileDir
+
'
/
'
+
pathName
;
console
.
info
(
"
case pathName is
"
+
pathName
);
});
await
fileio
.
open
(
pathName
).
then
((
fdNumber
)
=>
{
isFileOpen
(
fdNumber
,
done
)
fdReturn
=
fdNumber
;
console
.
info
(
'
[fileio]case open fd success, fd is
'
+
fdReturn
);
})
return
fdReturn
;
}
// wait synchronously
export
function
msleep
(
time
)
{
for
(
let
t
=
Date
.
now
();
Date
.
now
()
-
t
<=
time
;);
...
...
multimedia/media/media_js_standard/audioCodecFormat/Test.json
浏览文件 @
48123541
此差异已折叠。
点击以展开。
multimedia/media/media_js_standard/audioCodecFormat/src/main/js/test/AudioDecoderFormatCompatibilityPromiseTest.test.js
浏览文件 @
48123541
...
...
@@ -15,11 +15,9 @@
import
media
from
'
@ohos.multimedia.media
'
import
fileio
from
'
@ohos.fileio
'
import
abilityAccessCtrl
from
'
@ohos.abilityAccessCtrl
'
import
bundle
from
'
@ohos.bundle
'
import
featureAbility
from
'
@ohos.ability.featureAbility
'
import
mediaLibrary
from
'
@ohos.multimedia.mediaLibrary
'
import
{
getFileDescriptor
,
closeFileDescriptor
}
from
'
./AudioFormatTestBase.test
.js
'
;
import
*
as
mediaTestBase
from
'
../../../../../MediaTestBase
.js
'
;
import
{
describe
,
beforeAll
,
beforeEach
,
afterEach
,
afterAll
,
it
,
expect
}
from
'
deccjsunit/index
'
describe
(
'
AudioDecoderFormatCompatibilityPromise
'
,
function
()
{
...
...
@@ -2107,7 +2105,12 @@ describe('AudioDecoderFormatCompatibilityPromise', function () {
beforeAll
(
async
function
()
{
console
.
info
(
'
beforeAll case 1
'
);
await
applyPermission
();
let
permissionName1
=
'
ohos.permission.MEDIA_LOCATION
'
;
let
permissionName2
=
'
ohos.permission.READ_MEDIA
'
;
let
permissionName3
=
'
ohos.permission.WRITE_MEDIA
'
;
permissionNameList
=
[
permissionName1
,
permissionName2
,
permissionName3
];
let
appName
=
'
ohos.acts.multimedia.audio.codecformat
'
;
await
mediaTestBase
.
applyPermission
(
appName
,
permissionNameList
);
console
.
info
(
'
beforeAll case after get permission
'
);
})
...
...
@@ -2142,7 +2145,6 @@ describe('AudioDecoderFormatCompatibilityPromise', function () {
audioDecodeProcessor
=
null
;
},
failCallback
).
catch
(
failCatch
);
}
await
closeFileDescriptor
(
readPath
);
await
closeFdWrite
();
})
...
...
@@ -2187,39 +2189,9 @@ describe('AudioDecoderFormatCompatibilityPromise', function () {
audioDecodeProcessor
=
null
;
},
failCallback
).
catch
(
failCatch
);
}
await
closeFileDescriptor
(
readPath
);
await
closeFdWrite
();
}
async
function
applyPermission
()
{
let
appInfo
=
await
bundle
.
getApplicationInfo
(
'
ohos.acts.multimedia.audio.codecformat
'
,
0
,
100
);
let
atManager
=
abilityAccessCtrl
.
createAtManager
();
if
(
atManager
!=
null
)
{
let
tokenID
=
appInfo
.
accessTokenId
;
console
.
info
(
'
[permission] case accessTokenID is
'
+
tokenID
);
let
permissionName1
=
'
ohos.permission.MEDIA_LOCATION
'
;
let
permissionName2
=
'
ohos.permission.READ_MEDIA
'
;
let
permissionName3
=
'
ohos.permission.WRITE_MEDIA
'
;
await
atManager
.
grantUserGrantedPermission
(
tokenID
,
permissionName1
,
1
).
then
((
result
)
=>
{
console
.
info
(
'
[permission] case grantUserGrantedPermission success :
'
+
result
);
}).
catch
((
err
)
=>
{
console
.
info
(
'
[permission] case grantUserGrantedPermission failed :
'
+
err
);
});
await
atManager
.
grantUserGrantedPermission
(
tokenID
,
permissionName2
,
1
).
then
((
result
)
=>
{
console
.
info
(
'
[permission] case grantUserGrantedPermission success :
'
+
result
);
}).
catch
((
err
)
=>
{
console
.
info
(
'
[permission] case grantUserGrantedPermission failed :
'
+
err
);
});
await
atManager
.
grantUserGrantedPermission
(
tokenID
,
permissionName3
,
1
).
then
((
result
)
=>
{
console
.
info
(
'
[permission] case grantUserGrantedPermission success :
'
+
result
);
}).
catch
((
err
)
=>
{
console
.
info
(
'
[permission] case grantUserGrantedPermission failed :
'
+
err
);
});
}
else
{
console
.
info
(
'
[permission] case apply permission failed, createAtManager failed
'
);
}
}
async
function
getFdWrite
(
pathName
)
{
console
.
info
(
'
[mediaLibrary] case start getFdWrite
'
);
console
.
info
(
'
[mediaLibrary] case getFdWrite pathName is
'
+
pathName
);
...
...
@@ -2243,19 +2215,11 @@ describe('AudioDecoderFormatCompatibilityPromise', function () {
}
}
async
function
getFdRead
(
pathName
,
done
)
{
await
getFileDescriptor
(
pathName
).
then
((
res
)
=>
{
if
(
res
==
undefined
)
{
expect
().
assertFail
();
console
.
info
(
'
case error fileDescriptor undefined, open file fail
'
);
done
();
}
else
{
fdRead
=
res
.
fd
;
console
.
info
(
"
case fdRead is:
"
+
fdRead
);
}
async
function
getFdRead
(
readPath
,
done
)
{
await
mediaTestBase
.
getFdRead
(
readPath
,
done
).
then
((
fdNumber
)
=>
{
fdRead
=
fdNumber
;
})
}
async
function
closeFdWrite
()
{
if
(
fileAssetWrite
!=
null
)
{
...
...
multimedia/media/media_js_standard/audioCodecFormat/src/main/js/test/AudioEncoderFormatCompatibilityPromiseTest.test.js
浏览文件 @
48123541
...
...
@@ -15,11 +15,9 @@
import
media
from
'
@ohos.multimedia.media
'
import
fileio
from
'
@ohos.fileio
'
import
abilityAccessCtrl
from
'
@ohos.abilityAccessCtrl
'
import
bundle
from
'
@ohos.bundle
'
import
featureAbility
from
'
@ohos.ability.featureAbility
'
import
mediaLibrary
from
'
@ohos.multimedia.mediaLibrary
'
import
{
getFileDescriptor
,
closeFileDescriptor
}
from
'
./AudioFormatTestBase.test
.js
'
;
import
*
as
mediaTestBase
from
'
../../../../../MediaTestBase
.js
'
;
import
{
describe
,
beforeAll
,
beforeEach
,
afterEach
,
afterAll
,
it
,
expect
}
from
'
deccjsunit/index
'
describe
(
'
AudioEncoderFormatCompatibilityPromise
'
,
function
()
{
...
...
@@ -55,7 +53,12 @@ describe('AudioEncoderFormatCompatibilityPromise', function () {
beforeAll
(
async
function
()
{
console
.
info
(
'
beforeAll case 1
'
);
await
applyPermission
();
let
permissionName1
=
'
ohos.permission.MEDIA_LOCATION
'
;
let
permissionName2
=
'
ohos.permission.READ_MEDIA
'
;
let
permissionName3
=
'
ohos.permission.WRITE_MEDIA
'
;
permissionNameList
=
[
permissionName1
,
permissionName2
,
permissionName3
];
let
appName
=
'
ohos.acts.multimedia.audio.codecformat
'
;
await
mediaTestBase
.
applyPermission
(
appName
,
permissionNameList
);
console
.
info
(
'
beforeAll case after get permission
'
);
})
...
...
@@ -72,7 +75,6 @@ describe('AudioEncoderFormatCompatibilityPromise', function () {
audioEncodeProcessor
=
null
;
},
failCallback
).
catch
(
failCatch
);
}
await
closeFileDescriptor
(
readPath
);
await
closeFdWrite
();
})
...
...
@@ -137,39 +139,9 @@ describe('AudioEncoderFormatCompatibilityPromise', function () {
audioEncodeProcessor
=
null
;
},
failCallback
).
catch
(
failCatch
);
}
await
closeFileDescriptor
(
readPath
);
await
closeFdWrite
();
}
async
function
applyPermission
()
{
let
appInfo
=
await
bundle
.
getApplicationInfo
(
'
ohos.acts.multimedia.audio.codecformat
'
,
0
,
100
);
let
atManager
=
abilityAccessCtrl
.
createAtManager
();
if
(
atManager
!=
null
)
{
let
tokenID
=
appInfo
.
accessTokenId
;
console
.
info
(
'
[permission] case accessTokenID is
'
+
tokenID
);
let
permissionName1
=
'
ohos.permission.MEDIA_LOCATION
'
;
let
permissionName2
=
'
ohos.permission.READ_MEDIA
'
;
let
permissionName3
=
'
ohos.permission.WRITE_MEDIA
'
;
await
atManager
.
grantUserGrantedPermission
(
tokenID
,
permissionName1
,
1
).
then
((
result
)
=>
{
console
.
info
(
'
[permission] case grantUserGrantedPermission success :
'
+
result
);
}).
catch
((
err
)
=>
{
console
.
info
(
'
[permission] case grantUserGrantedPermission failed :
'
+
err
);
});
await
atManager
.
grantUserGrantedPermission
(
tokenID
,
permissionName2
,
1
).
then
((
result
)
=>
{
console
.
info
(
'
[permission] case grantUserGrantedPermission success :
'
+
result
);
}).
catch
((
err
)
=>
{
console
.
info
(
'
[permission] case grantUserGrantedPermission failed :
'
+
err
);
});
await
atManager
.
grantUserGrantedPermission
(
tokenID
,
permissionName3
,
1
).
then
((
result
)
=>
{
console
.
info
(
'
[permission] case grantUserGrantedPermission success :
'
+
result
);
}).
catch
((
err
)
=>
{
console
.
info
(
'
[permission] case grantUserGrantedPermission failed :
'
+
err
);
});
}
else
{
console
.
info
(
'
[permission] case apply permission failed, createAtManager failed
'
);
}
}
async
function
getFdWrite
(
pathName
)
{
console
.
info
(
'
[mediaLibrary] case start getFdWrite
'
);
console
.
info
(
'
[mediaLibrary] case getFdWrite pathName is
'
+
pathName
);
...
...
@@ -193,16 +165,9 @@ describe('AudioEncoderFormatCompatibilityPromise', function () {
}
}
async
function
getFdRead
(
pathName
,
done
)
{
await
getFileDescriptor
(
pathName
).
then
((
res
)
=>
{
if
(
res
==
undefined
)
{
expect
().
assertFail
();
console
.
info
(
'
case error fileDescriptor undefined, open file fail
'
);
done
();
}
else
{
fdRead
=
res
.
fd
;
console
.
info
(
"
case fdRead is:
"
+
fdRead
);
}
async
function
getFdRead
(
readPath
,
done
)
{
await
mediaTestBase
.
getFdRead
(
readPath
,
done
).
then
((
fdNumber
)
=>
{
fdRead
=
fdNumber
;
})
}
...
...
multimedia/media/media_js_standard/audioCodecFormat/src/main/js/test/AudioFormatTestBase.test.js
已删除
100644 → 0
浏览文件 @
0cfa1c82
/*
* 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
resourceManager
from
'
@ohos.resourceManager
'
;
export
async
function
getFileDescriptor
(
fileName
)
{
let
fileDescriptor
=
undefined
;
await
resourceManager
.
getResourceManager
().
then
(
async
(
mgr
)
=>
{
await
mgr
.
getRawFileDescriptor
(
fileName
).
then
(
value
=>
{
fileDescriptor
=
{
fd
:
value
.
fd
,
offset
:
value
.
offset
,
length
:
value
.
length
};
}).
catch
(
error
=>
{
console
.
log
(
'
case getRawFileDescriptor err:
'
+
error
);
});
});
return
fileDescriptor
;
}
export
async
function
closeFileDescriptor
(
fileName
)
{
await
resourceManager
.
getResourceManager
().
then
(
async
(
mgr
)
=>
{
await
mgr
.
closeRawFileDescriptor
(
fileName
).
then
(
value
=>
{
console
.
log
(
'
case closeRawFileDescriptor success for file:
'
+
fileName
);
}).
catch
(
error
=>
{
console
.
log
(
'
case closeRawFileDescriptor err:
'
+
error
);
});
});
}
multimedia/media/media_js_standard/audioDecoder/Test.json
浏览文件 @
48123541
...
...
@@ -18,8 +18,8 @@
"type"
:
"ShellKit"
,
"run-command"
:
[
"rm -rf /storage/media/100/local/files/*"
,
"mkdir -p /data/app/el
1/bundle/public/ohos.acts.multimedia.audio.audiodecoder/ohos.acts.multimedia.audio.audiodecoder/assets/entry/resources/rawfile
/"
,
"chmod 777 -R /data/app/el
1/bundle/public/ohos.acts.multimedia.audio.audiodecoder/ohos.acts.multimedia.audio.audiodecoder/assets/entry/resources/rawfile
/"
"mkdir -p /data/app/el
2/100/base/ohos.acts.multimedia.audio.audiodecoder/haps/entry/files
/"
,
"chmod 777 -R /data/app/el
2/100/base/ohos.acts.multimedia.audio.audiodecoder/haps/entry/files
/"
],
"teardown-command"
:[
]
...
...
@@ -29,18 +29,18 @@
"pre-push"
:
[
],
"push"
:
[
"./resource/audio/audioDecode/AAC_48000_32_1.aac ->/data/app/el
1/bundle/public/ohos.acts.multimedia.audio.audiodecoder/ohos.acts.multimedia.audio.audiodecoder/assets/entry/resources/rawfile
/"
,
"./resource/audio/audioDecode/AAC_16000_1.aac ->/data/app/el
1/bundle/public/ohos.acts.multimedia.audio.audiodecoder/ohos.acts.multimedia.audio.audiodecoder/assets/entry/resources/rawfile
/"
,
"./resource/audio/audioDecode/FLAC_48000_32_1.flac ->/data/app/el
1/bundle/public/ohos.acts.multimedia.audio.audiodecoder/ohos.acts.multimedia.audio.audiodecoder/assets/entry/resources/rawfile
/"
,
"./resource/audio/audioDecode/mp3.es ->/data/app/el
1/bundle/public/ohos.acts.multimedia.audio.audiodecoder/ohos.acts.multimedia.audio.audiodecoder/assets/entry/resources/rawfile
/"
,
"./resource/audio/audioDecode/vorbis.es ->/data/app/el
1/bundle/public/ohos.acts.multimedia.audio.audiodecoder/ohos.acts.multimedia.audio.audiodecoder/assets/entry/resources/rawfile
/"
"./resource/audio/audioDecode/AAC_48000_32_1.aac ->/data/app/el
2/100/base/ohos.acts.multimedia.audio.audiodecoder/haps/entry/files
/"
,
"./resource/audio/audioDecode/AAC_16000_1.aac ->/data/app/el
2/100/base/ohos.acts.multimedia.audio.audiodecoder/haps/entry/files
/"
,
"./resource/audio/audioDecode/FLAC_48000_32_1.flac ->/data/app/el
2/100/base/ohos.acts.multimedia.audio.audiodecoder/haps/entry/files
/"
,
"./resource/audio/audioDecode/mp3.es ->/data/app/el
2/100/base/ohos.acts.multimedia.audio.audiodecoder/haps/entry/files
/"
,
"./resource/audio/audioDecode/vorbis.es ->/data/app/el
2/100/base/ohos.acts.multimedia.audio.audiodecoder/haps/entry/files
/"
]
},
{
"type"
:
"ShellKit"
,
"run-command"
:
[
"chmod 777 -R /data/app/el
1/bundle/public/ohos.acts.multimedia.audio.audiodecoder/ohos.acts.multimedia.audio.audiodecoder/assets/entry/resources/rawfile
/"
,
"chmod 777 /data/app/el
1/bundle/public/ohos.acts.multimedia.audio.audiodecoder/ohos.acts.multimedia.audio.audiodecoder/assets/entry/resources/rawfile
/*"
,
"chmod 777 -R /data/app/el
2/100/base/ohos.acts.multimedia.audio.audiodecoder/haps/entry/files
/"
,
"chmod 777 /data/app/el
2/100/base/ohos.acts.multimedia.audio.audiodecoder/haps/entry/files
/*"
,
"chmod 777 -R /storage/media/100/local/files/"
,
"chmod 777 /storage/media/100/local/files/*"
,
"killall com.ohos.medialibrary.MediaScannerAbilityA"
,
...
...
multimedia/media/media_js_standard/audioDecoder/src/main/js/test/AudioDecoderEnumTest.test.js
浏览文件 @
48123541
...
...
@@ -144,20 +144,5 @@ describe('AudioDecoderEnum', function () {
expect
(
media
.
AVCodecType
.
AVCODEC_TYPE_AUDIO_ENCODER
).
assertEqual
(
2
);
expect
(
media
.
AVCodecType
.
AVCODEC_TYPE_AUDIO_DECODER
).
assertEqual
(
3
);
done
();
})
/* *
* @tc.number : SUB_MEDIA_AUDIO_DECODER_ENUM_CodecMimeType_0100
* @tc.name : 004.CodecMimeType
* @tc.desc : Test Enumerate CodecMimeType
* @tc.size : MediumTest
* @tc.type : Function test
* @tc.level : Level0
*/
it
(
'
SUB_MEDIA_AUDIO_DECODER_ENUM_CodecMimeType_0100
'
,
0
,
async
function
(
done
)
{
expect
(
media
.
CodecMimeType
.
AUDIO_AAC
).
assertEqual
(
'
audio/mp4a-latm
'
);
expect
(
media
.
CodecMimeType
.
AUDIO_VORBIS
).
assertEqual
(
'
audio/vorbis
'
);
expect
(
media
.
CodecMimeType
.
AUDIO_FLAC
).
assertEqual
(
'
audio/flac
'
);
done
();
})
})
\ No newline at end of file
multimedia/media/media_js_standard/audioDecoder/src/main/js/test/AudioDecoderFormatCallbackTest.test.js
浏览文件 @
48123541
...
...
@@ -15,15 +15,12 @@
import
media
from
'
@ohos.multimedia.media
'
import
fileio
from
'
@ohos.fileio
'
import
abilityAccessCtrl
from
'
@ohos.abilityAccessCtrl
'
import
bundle
from
'
@ohos.bundle
'
import
featureAbility
from
'
@ohos.ability.featureAbility
'
import
mediaLibrary
from
'
@ohos.multimedia.mediaLibrary
'
import
{
getFileDescriptor
,
closeFileDescriptor
}
from
'
./AudioDecoderTestBase.test
.js
'
;
import
*
as
mediaTestBase
from
'
../../../../../MediaTestBase
.js
'
;
import
{
describe
,
beforeAll
,
beforeEach
,
afterEach
,
afterAll
,
it
,
expect
}
from
'
deccjsunit/index
'
describe
(
'
AudioDecoderFormatCallback
'
,
function
()
{
const
RESOURCEPATH
=
'
/data/accounts/account_0/appdata/ohos.acts.multimedia.audio.audiodecoder/
'
const
AUDIOPATH1
=
'
AAC_48000_32_1.aac
'
;
const
AUDIOPATH2
=
'
FLAC_48000_32_1.flac
'
const
AUDIOPATH3
=
'
mp3.es
'
;
...
...
@@ -54,7 +51,12 @@ describe('AudioDecoderFormatCallback', function () {
beforeAll
(
async
function
()
{
console
.
info
(
'
beforeAll case 1
'
);
await
applyPermission
();
let
permissionName1
=
'
ohos.permission.MEDIA_LOCATION
'
;
let
permissionName2
=
'
ohos.permission.READ_MEDIA
'
;
let
permissionName3
=
'
ohos.permission.WRITE_MEDIA
'
;
permissionNameList
=
[
permissionName1
,
permissionName2
,
permissionName3
];
let
appName
=
'
ohos.acts.multimedia.audio.audiodecoder
'
;
await
mediaTestBase
.
applyPermission
(
appName
,
permissionNameList
);
console
.
info
(
'
beforeAll case after get permission
'
);
})
...
...
@@ -84,56 +86,18 @@ describe('AudioDecoderFormatCallback', function () {
audioDecodeProcessor
=
null
;
},
failCallback
).
catch
(
failCatch
);
}
await
closeFileDescriptor
(
readpath
);
await
closeFdWrite
();
})
afterAll
(
function
()
{
afterAll
(
async
function
()
{
console
.
info
(
'
afterAll case
'
);
})
async
function
getFdRead
(
pathName
,
done
)
{
await
getFileDescriptor
(
pathName
).
then
((
res
)
=>
{
if
(
res
==
undefined
)
{
expect
().
assertFail
();
console
.
info
(
'
case error fileDescriptor undefined, open file fail
'
);
done
();
}
else
{
fdRead
=
res
.
fd
;
console
.
info
(
"
case fdRead is:
"
+
fdRead
);
}
async
function
getFdRead
(
readPath
,
done
)
{
await
mediaTestBase
.
getFdRead
(
readPath
,
done
).
then
((
fdNumber
)
=>
{
fdRead
=
fdNumber
;
})
}
async
function
applyPermission
()
{
let
appInfo
=
await
bundle
.
getApplicationInfo
(
'
ohos.acts.multimedia.audio.audiodecoder
'
,
0
,
100
);
let
atManager
=
abilityAccessCtrl
.
createAtManager
();
if
(
atManager
!=
null
)
{
let
tokenID
=
appInfo
.
accessTokenId
;
console
.
info
(
'
[permission] case accessTokenID is
'
+
tokenID
);
let
permissionName1
=
'
ohos.permission.MEDIA_LOCATION
'
;
let
permissionName2
=
'
ohos.permission.READ_MEDIA
'
;
let
permissionName3
=
'
ohos.permission.WRITE_MEDIA
'
;
await
atManager
.
grantUserGrantedPermission
(
tokenID
,
permissionName1
,
1
).
then
((
result
)
=>
{
console
.
info
(
'
[permission] case grantUserGrantedPermission success :
'
+
result
);
}).
catch
((
err
)
=>
{
console
.
info
(
'
[permission] case grantUserGrantedPermission failed :
'
+
err
);
});
await
atManager
.
grantUserGrantedPermission
(
tokenID
,
permissionName2
,
1
).
then
((
result
)
=>
{
console
.
info
(
'
[permission] case grantUserGrantedPermission success :
'
+
result
);
}).
catch
((
err
)
=>
{
console
.
info
(
'
[permission] case grantUserGrantedPermission failed :
'
+
err
);
});
await
atManager
.
grantUserGrantedPermission
(
tokenID
,
permissionName3
,
1
).
then
((
result
)
=>
{
console
.
info
(
'
[permission] case grantUserGrantedPermission success :
'
+
result
);
}).
catch
((
err
)
=>
{
console
.
info
(
'
[permission] case grantUserGrantedPermission failed :
'
+
err
);
});
}
else
{
console
.
info
(
'
[permission] case apply permission failed, createAtManager failed
'
);
}
}
async
function
getFdWrite
(
pathName
)
{
console
.
info
(
'
[mediaLibrary] case start getFdWrite
'
);
console
.
info
(
'
[mediaLibrary] case getFdWrite pathName is
'
+
pathName
);
...
...
@@ -152,7 +116,7 @@ describe('AudioDecoderFormatCallback', function () {
console
.
info
(
'
[mediaLibrary] case getFdWrite getFileAssets() success
'
);
fileAsset
=
await
fetchWriteFileResult
.
getAllObject
();
console
.
info
(
'
[mediaLibrary] case getFdWrite getAllObject() success
'
);
fdWrite
=
await
fileAsset
[
0
].
open
(
'
R
w
'
);
fdWrite
=
await
fileAsset
[
0
].
open
(
'
r
w
'
);
console
.
info
(
'
[mediaLibrary] case getFdWrite fdWrite is
'
+
fdWrite
);
}
}
...
...
@@ -169,7 +133,6 @@ describe('AudioDecoderFormatCallback', function () {
}
}
function
writeFile
(
path
,
buf
,
len
)
{
try
{
let
res
=
fileio
.
writeSync
(
fdWrite
,
buf
,
{
length
:
len
});
...
...
@@ -250,7 +213,6 @@ describe('AudioDecoderFormatCallback', function () {
expect
(
err
).
assertUndefined
();
console
.
log
(
"
case release success
"
);
audioDecodeProcessor
=
null
;
await
closeFileDescriptor
(
readpath
);
await
closeFdWrite
();
done
();
})
...
...
multimedia/media/media_js_standard/audioDecoder/src/main/js/test/AudioDecoderFormatPromiseTest.test.js
浏览文件 @
48123541
...
...
@@ -15,11 +15,9 @@
import
media
from
'
@ohos.multimedia.media
'
import
fileio
from
'
@ohos.fileio
'
import
abilityAccessCtrl
from
'
@ohos.abilityAccessCtrl
'
import
bundle
from
'
@ohos.bundle
'
import
featureAbility
from
'
@ohos.ability.featureAbility
'
import
mediaLibrary
from
'
@ohos.multimedia.mediaLibrary
'
import
{
getFileDescriptor
,
closeFileDescriptor
}
from
'
./AudioDecoderTestBase.test
.js
'
;
import
*
as
mediaTestBase
from
'
../../../../../MediaTestBase
.js
'
;
import
{
describe
,
beforeAll
,
beforeEach
,
afterEach
,
afterAll
,
it
,
expect
}
from
'
deccjsunit/index
'
describe
(
'
AudioDecoderFormatPromise
'
,
function
()
{
...
...
@@ -53,7 +51,12 @@ describe('AudioDecoderFormatPromise', function () {
beforeAll
(
async
function
()
{
console
.
info
(
'
beforeAll case 1
'
);
await
applyPermission
();
let
permissionName1
=
'
ohos.permission.MEDIA_LOCATION
'
;
let
permissionName2
=
'
ohos.permission.READ_MEDIA
'
;
let
permissionName3
=
'
ohos.permission.WRITE_MEDIA
'
;
permissionNameList
=
[
permissionName1
,
permissionName2
,
permissionName3
];
let
appName
=
'
ohos.acts.multimedia.audio.audiodecoder
'
;
await
mediaTestBase
.
applyPermission
(
appName
,
permissionNameList
);
console
.
info
(
'
beforeAll case after get permission
'
);
})
...
...
@@ -83,11 +86,9 @@ describe('AudioDecoderFormatPromise', function () {
audioDecodeProcessor
=
null
;
},
failCallback
).
catch
(
failCatch
);
}
await
closeFileDescriptor
(
readpath
);
await
closeFdWrite
();
})
afterAll
(
function
()
{
afterAll
(
async
function
()
{
console
.
info
(
'
afterAll case
'
);
})
...
...
@@ -101,48 +102,12 @@ describe('AudioDecoderFormatPromise', function () {
expect
(
err
).
assertUndefined
();
}
async
function
getFdRead
(
pathName
,
done
)
{
await
getFileDescriptor
(
pathName
).
then
((
res
)
=>
{
if
(
res
==
undefined
)
{
expect
().
assertFail
();
console
.
info
(
'
case error fileDescriptor undefined, open file fail
'
);
done
();
}
else
{
fdRead
=
res
.
fd
;
console
.
info
(
"
case fdRead is:
"
+
fdRead
);
}
async
function
getFdRead
(
readPath
,
done
)
{
await
mediaTestBase
.
getFdRead
(
readPath
,
done
).
then
((
fdNumber
)
=>
{
fdRead
=
fdNumber
;
})
}
async
function
applyPermission
()
{
let
appInfo
=
await
bundle
.
getApplicationInfo
(
'
ohos.acts.multimedia.audio.audiodecoder
'
,
0
,
100
);
let
atManager
=
abilityAccessCtrl
.
createAtManager
();
if
(
atManager
!=
null
)
{
let
tokenID
=
appInfo
.
accessTokenId
;
console
.
info
(
'
[permission] case accessTokenID is
'
+
tokenID
);
let
permissionName1
=
'
ohos.permission.MEDIA_LOCATION
'
;
let
permissionName2
=
'
ohos.permission.READ_MEDIA
'
;
let
permissionName3
=
'
ohos.permission.WRITE_MEDIA
'
;
await
atManager
.
grantUserGrantedPermission
(
tokenID
,
permissionName1
,
1
).
then
((
result
)
=>
{
console
.
info
(
'
[permission] case grantUserGrantedPermission success :
'
+
result
);
}).
catch
((
err
)
=>
{
console
.
info
(
'
[permission] case grantUserGrantedPermission failed :
'
+
err
);
});
await
atManager
.
grantUserGrantedPermission
(
tokenID
,
permissionName2
,
1
).
then
((
result
)
=>
{
console
.
info
(
'
[permission] case grantUserGrantedPermission success :
'
+
result
);
}).
catch
((
err
)
=>
{
console
.
info
(
'
[permission] case grantUserGrantedPermission failed :
'
+
err
);
});
await
atManager
.
grantUserGrantedPermission
(
tokenID
,
permissionName3
,
1
).
then
((
result
)
=>
{
console
.
info
(
'
[permission] case grantUserGrantedPermission success :
'
+
result
);
}).
catch
((
err
)
=>
{
console
.
info
(
'
[permission] case grantUserGrantedPermission failed :
'
+
err
);
});
}
else
{
console
.
info
(
'
[permission] case apply permission failed, createAtManager failed
'
);
}
}
async
function
getFdWrite
(
pathName
)
{
console
.
info
(
'
[mediaLibrary] case start getFdWrite
'
);
console
.
info
(
'
[mediaLibrary] case getFdWrite pathName is
'
+
pathName
);
...
...
@@ -161,7 +126,7 @@ describe('AudioDecoderFormatPromise', function () {
console
.
info
(
'
[mediaLibrary] case getFdWrite getFileAssets() success
'
);
fileAsset
=
await
fetchWriteFileResult
.
getAllObject
();
console
.
info
(
'
[mediaLibrary] case getFdWrite getAllObject() success
'
);
fdWrite
=
await
fileAsset
[
0
].
open
(
'
R
w
'
);
fdWrite
=
await
fileAsset
[
0
].
open
(
'
r
w
'
);
console
.
info
(
'
[mediaLibrary] case getFdWrite fdWrite is
'
+
fdWrite
);
}
}
...
...
@@ -178,7 +143,6 @@ describe('AudioDecoderFormatPromise', function () {
}
}
function
writeFile
(
path
,
buf
,
len
)
{
try
{
let
res
=
fileio
.
writeSync
(
fdWrite
,
buf
,
{
length
:
len
});
...
...
@@ -259,7 +223,6 @@ describe('AudioDecoderFormatPromise', function () {
console
.
info
(
'
release success
'
);
audioDecodeProcessor
=
null
;
},
failCallback
).
catch
(
failCatch
);
await
closeFileDescriptor
(
readpath
);
await
closeFdWrite
();
done
();
}
...
...
multimedia/media/media_js_standard/audioDecoder/src/main/js/test/AudioDecoderFuncCallbackTest.test.js
浏览文件 @
48123541
...
...
@@ -15,19 +15,16 @@
import
media
from
'
@ohos.multimedia.media
'
import
fileio
from
'
@ohos.fileio
'
import
abilityAccessCtrl
from
'
@ohos.abilityAccessCtrl
'
import
bundle
from
'
@ohos.bundle
'
import
featureAbility
from
'
@ohos.ability.featureAbility
'
import
mediaLibrary
from
'
@ohos.multimedia.mediaLibrary
'
import
{
getFileDescriptor
,
closeFileDescriptor
}
from
'
./AudioDecoderTestBase.test
.js
'
;
import
*
as
mediaTestBase
from
'
../../../../../MediaTestBase
.js
'
;
import
{
describe
,
beforeAll
,
beforeEach
,
afterEach
,
afterAll
,
it
,
expect
}
from
'
deccjsunit/index
'
describe
(
'
AudioDecoderFuncCallback
'
,
function
()
{
const
RESOURCEPATH
=
'
/data/accounts/account_0/appdata/ohos.acts.multimedia.audio.audiodecoder/
'
const
AUDIOPATH
=
'
AAC_48000_32_1.aac
'
;
const
AUDIOPATH2
=
'
AAC_16000_1.aac
'
;
const
AUDIOPATH3
=
'
FLAC_48000_32_1.flac
'
;
const
BASIC_PATH
=
RESOURCEPATH
+
'
results/decode_func_callback_
'
;
const
BASIC_PATH
=
'
results/decode_func_callback_
'
;
let
audioDecodeProcessor
;
let
readStreamSync
;
let
eosframenum
=
0
;
...
...
@@ -145,7 +142,12 @@ describe('AudioDecoderFuncCallback', function () {
beforeAll
(
async
function
()
{
console
.
info
(
'
beforeAll case 1
'
);
await
applyPermission
();
let
permissionName1
=
'
ohos.permission.MEDIA_LOCATION
'
;
let
permissionName2
=
'
ohos.permission.READ_MEDIA
'
;
let
permissionName3
=
'
ohos.permission.WRITE_MEDIA
'
;
permissionNameList
=
[
permissionName1
,
permissionName2
,
permissionName3
];
let
appName
=
'
ohos.acts.multimedia.audio.audiodecoder
'
;
await
mediaTestBase
.
applyPermission
(
appName
,
permissionNameList
);
console
.
info
(
'
beforeAll case after get permission
'
);
})
...
...
@@ -267,11 +269,9 @@ describe('AudioDecoderFuncCallback', function () {
audioDecodeProcessor
=
null
;
},
failCallback
).
catch
(
failCatch
);
}
await
closeFileDescriptor
(
readpath
);
await
closeFdWrite
();
})
afterAll
(
function
()
{
afterAll
(
async
function
()
{
console
.
info
(
'
afterAll case
'
);
})
...
...
@@ -293,49 +293,12 @@ describe('AudioDecoderFuncCallback', function () {
outputQueue
=
[];
}
async
function
getFdRead
(
pathName
,
done
)
{
await
getFileDescriptor
(
pathName
).
then
((
res
)
=>
{
if
(
res
==
undefined
)
{
expect
().
assertFail
();
console
.
info
(
'
case error fileDescriptor undefined, open file fail
'
);
done
();
}
else
{
fdRead
=
res
.
fd
;
console
.
info
(
"
case pathName is :
"
+
pathName
);
console
.
info
(
"
case fdRead is:
"
+
fdRead
);
}
async
function
getFdRead
(
readPath
,
done
)
{
await
mediaTestBase
.
getFdRead
(
readPath
,
done
).
then
((
fdNumber
)
=>
{
fdRead
=
fdNumber
;
})
}
async
function
applyPermission
()
{
let
appInfo
=
await
bundle
.
getApplicationInfo
(
'
ohos.acts.multimedia.audio.audiodecoder
'
,
0
,
100
);
let
atManager
=
abilityAccessCtrl
.
createAtManager
();
if
(
atManager
!=
null
)
{
let
tokenID
=
appInfo
.
accessTokenId
;
console
.
info
(
'
[permission] case accessTokenID is
'
+
tokenID
);
let
permissionName1
=
'
ohos.permission.MEDIA_LOCATION
'
;
let
permissionName2
=
'
ohos.permission.READ_MEDIA
'
;
let
permissionName3
=
'
ohos.permission.WRITE_MEDIA
'
;
await
atManager
.
grantUserGrantedPermission
(
tokenID
,
permissionName1
,
1
).
then
((
result
)
=>
{
console
.
info
(
'
[permission] case grantUserGrantedPermission success :
'
+
result
);
}).
catch
((
err
)
=>
{
console
.
info
(
'
[permission] case grantUserGrantedPermission failed :
'
+
err
);
});
await
atManager
.
grantUserGrantedPermission
(
tokenID
,
permissionName2
,
1
).
then
((
result
)
=>
{
console
.
info
(
'
[permission] case grantUserGrantedPermission success :
'
+
result
);
}).
catch
((
err
)
=>
{
console
.
info
(
'
[permission] case grantUserGrantedPermission failed :
'
+
err
);
});
await
atManager
.
grantUserGrantedPermission
(
tokenID
,
permissionName3
,
1
).
then
((
result
)
=>
{
console
.
info
(
'
[permission] case grantUserGrantedPermission success :
'
+
result
);
}).
catch
((
err
)
=>
{
console
.
info
(
'
[permission] case grantUserGrantedPermission failed :
'
+
err
);
});
}
else
{
console
.
info
(
'
[permission] case apply permission failed, createAtManager failed
'
);
}
}
async
function
getFdWrite
(
pathName
)
{
console
.
info
(
'
[mediaLibrary] case start getFdWrite
'
);
console
.
info
(
'
[mediaLibrary] case getFdWrite pathName is
'
+
pathName
);
...
...
@@ -354,7 +317,7 @@ describe('AudioDecoderFuncCallback', function () {
console
.
info
(
'
[mediaLibrary] case getFdWrite getFileAssets() success
'
);
fileAsset
=
await
fetchWriteFileResult
.
getAllObject
();
console
.
info
(
'
[mediaLibrary] case getFdWrite getAllObject() success
'
);
fdWrite
=
await
fileAsset
[
0
].
open
(
'
R
w
'
);
fdWrite
=
await
fileAsset
[
0
].
open
(
'
r
w
'
);
console
.
info
(
'
[mediaLibrary] case getFdWrite fdWrite is
'
+
fdWrite
);
}
}
...
...
@@ -423,7 +386,6 @@ describe('AudioDecoderFuncCallback', function () {
async
function
flushWork
(
done
)
{
inputQueue
=
[];
outputQueue
=
[];
await
closeFileDescriptor
(
readpath
);
await
getFdRead
(
readpath
,
done
);
audioDecodeProcessor
.
flush
((
err
)
=>
{
expect
(
err
).
assertUndefined
();
...
...
@@ -446,7 +408,6 @@ describe('AudioDecoderFuncCallback', function () {
expect
(
err
).
assertUndefined
();
console
.
log
(
"
case release success
"
);
audioDecodeProcessor
=
null
;
await
closeFileDescriptor
(
readpath
);
await
closeFdWrite
();
done
();
})
...
...
@@ -907,7 +868,6 @@ describe('AudioDecoderFuncCallback', function () {
expect
(
err
).
assertUndefined
();
console
.
info
(
`case release 1`
);
audioDecodeProcessor
=
null
;
await
closeFileDescriptor
(
readpath
);
await
closeFdWrite
();
done
();
})
...
...
@@ -987,7 +947,6 @@ describe('AudioDecoderFuncCallback', function () {
eventEmitter
.
on
(
'
restart
'
,
()
=>
{
sleep
(
2000
).
then
(
async
()
=>
{
resetParam
();
await
closeFileDescriptor
(
readpath
);
await
getFdRead
(
readpath
,
done
);
readFile
(
readpath
);
audioDecodeProcessor
.
start
((
err
)
=>
{
...
...
@@ -1071,7 +1030,6 @@ describe('AudioDecoderFuncCallback', function () {
eventEmitter
.
on
(
'
reconfigure
'
,
(
mediaDescription2
)
=>
{
sleep
(
10000
).
then
(
async
()
=>
{
resetParam
();
await
closeFileDescriptor
(
readpath
);
await
closeFdWrite
();
audioDecodeProcessor
.
configure
(
mediaDescription2
,
async
(
err
)
=>
{
expect
(
err
).
assertUndefined
();
...
...
@@ -1178,7 +1136,6 @@ describe('AudioDecoderFuncCallback', function () {
});
eventEmitter
.
on
(
'
recreate
'
,
()
=>
{
sleep
(
10000
).
then
(
async
()
=>
{
await
closeFileDescriptor
(
readpath
);
await
closeFdWrite
();
media
.
createAudioDecoderByMime
(
'
audio/flac
'
,
(
err
,
processor
)
=>
{
expect
(
err
).
assertUndefined
();
...
...
multimedia/media/media_js_standard/audioDecoder/src/main/js/test/AudioDecoderFuncPromiseTest.test.js
浏览文件 @
48123541
...
...
@@ -15,19 +15,15 @@
import
media
from
'
@ohos.multimedia.media
'
import
fileio
from
'
@ohos.fileio
'
import
abilityAccessCtrl
from
'
@ohos.abilityAccessCtrl
'
import
bundle
from
'
@ohos.bundle
'
import
featureAbility
from
'
@ohos.ability.featureAbility
'
import
mediaLibrary
from
'
@ohos.multimedia.mediaLibrary
'
import
{
getFileDescriptor
,
closeFileDescriptor
}
from
'
./AudioDecoderTestBase.test
.js
'
;
import
*
as
mediaTestBase
from
'
../../../../../MediaTestBase
.js
'
;
import
{
describe
,
beforeAll
,
beforeEach
,
afterEach
,
afterAll
,
it
,
expect
}
from
'
deccjsunit/index
'
describe
(
'
AudioDecoderFuncPromise
'
,
function
()
{
const
RESOURCEPATH
=
'
/data/accounts/account_0/appdata/ohos.acts.multimedia.audio.audiodecoder/
'
const
AUDIOPATH
=
'
AAC_48000_32_1.aac
'
;
const
AUDIOPATH2
=
'
AAC_16000_1.aac
'
;
const
AUDIOPATH3
=
'
FLAC_48000_32_1.flac
'
;
const
BASIC_PATH
=
'
results/decode_func_promise_
'
;
let
audioDecodeProcessor
;
let
readStreamSync
;
let
eosframenum
=
0
;
...
...
@@ -145,7 +141,12 @@ describe('AudioDecoderFuncPromise', function () {
beforeAll
(
async
function
()
{
console
.
info
(
'
beforeAll case 1
'
);
await
applyPermission
();
let
permissionName1
=
'
ohos.permission.MEDIA_LOCATION
'
;
let
permissionName2
=
'
ohos.permission.READ_MEDIA
'
;
let
permissionName3
=
'
ohos.permission.WRITE_MEDIA
'
;
permissionNameList
=
[
permissionName1
,
permissionName2
,
permissionName3
];
let
appName
=
'
ohos.acts.multimedia.audio.audiodecoder
'
;
await
mediaTestBase
.
applyPermission
(
appName
,
permissionNameList
);
console
.
info
(
'
beforeAll case after get permission
'
);
})
...
...
@@ -267,11 +268,9 @@ describe('AudioDecoderFuncPromise', function () {
audioDecodeProcessor
=
null
;
},
failCallback
).
catch
(
failCatch
);
}
await
closeFileDescriptor
(
readpath
);
await
closeFdWrite
();
})
afterAll
(
function
()
{
afterAll
(
async
function
()
{
console
.
info
(
'
afterAll case
'
);
})
...
...
@@ -303,49 +302,12 @@ describe('AudioDecoderFuncPromise', function () {
outputQueue
=
[];
}
async
function
getFdRead
(
pathName
,
done
)
{
await
getFileDescriptor
(
pathName
).
then
((
res
)
=>
{
if
(
res
==
undefined
)
{
expect
().
assertFail
();
console
.
info
(
'
case error fileDescriptor undefined, open file fail
'
);
done
();
}
else
{
fdRead
=
res
.
fd
;
console
.
info
(
"
case pathName is:
"
+
pathName
);
console
.
info
(
"
case fdRead is:
"
+
fdRead
);
}
async
function
getFdRead
(
readPath
,
done
)
{
await
mediaTestBase
.
getFdRead
(
readPath
,
done
).
then
((
fdNumber
)
=>
{
fdRead
=
fdNumber
;
})
}
async
function
applyPermission
()
{
let
appInfo
=
await
bundle
.
getApplicationInfo
(
'
ohos.acts.multimedia.audio.audiodecoder
'
,
0
,
100
);
let
atManager
=
abilityAccessCtrl
.
createAtManager
();
if
(
atManager
!=
null
)
{
let
tokenID
=
appInfo
.
accessTokenId
;
console
.
info
(
'
[permission] case accessTokenID is
'
+
tokenID
);
let
permissionName1
=
'
ohos.permission.MEDIA_LOCATION
'
;
let
permissionName2
=
'
ohos.permission.READ_MEDIA
'
;
let
permissionName3
=
'
ohos.permission.WRITE_MEDIA
'
;
await
atManager
.
grantUserGrantedPermission
(
tokenID
,
permissionName1
,
1
).
then
((
result
)
=>
{
console
.
info
(
'
[permission] case grantUserGrantedPermission success :
'
+
result
);
}).
catch
((
err
)
=>
{
console
.
info
(
'
[permission] case grantUserGrantedPermission failed :
'
+
err
);
});
await
atManager
.
grantUserGrantedPermission
(
tokenID
,
permissionName2
,
1
).
then
((
result
)
=>
{
console
.
info
(
'
[permission] case grantUserGrantedPermission success :
'
+
result
);
}).
catch
((
err
)
=>
{
console
.
info
(
'
[permission] case grantUserGrantedPermission failed :
'
+
err
);
});
await
atManager
.
grantUserGrantedPermission
(
tokenID
,
permissionName3
,
1
).
then
((
result
)
=>
{
console
.
info
(
'
[permission] case grantUserGrantedPermission success :
'
+
result
);
}).
catch
((
err
)
=>
{
console
.
info
(
'
[permission] case grantUserGrantedPermission failed :
'
+
err
);
});
}
else
{
console
.
info
(
'
[permission] case apply permission failed, createAtManager failed
'
);
}
}
async
function
getFdWrite
(
pathName
)
{
console
.
info
(
'
[mediaLibrary] case start getFdWrite
'
);
console
.
info
(
'
[mediaLibrary] case getFdWrite pathName is
'
+
pathName
);
...
...
@@ -364,7 +326,7 @@ describe('AudioDecoderFuncPromise', function () {
console
.
info
(
'
[mediaLibrary] case getFdWrite getFileAssets() success
'
);
fileAsset
=
await
fetchWriteFileResult
.
getAllObject
();
console
.
info
(
'
[mediaLibrary] case getFdWrite getAllObject() success
'
);
fdWrite
=
await
fileAsset
[
0
].
open
(
'
R
w
'
);
fdWrite
=
await
fileAsset
[
0
].
open
(
'
r
w
'
);
console
.
info
(
'
[mediaLibrary] case getFdWrite fdWrite is
'
+
fdWrite
);
}
}
...
...
@@ -427,7 +389,6 @@ describe('AudioDecoderFuncPromise', function () {
async
function
flushWork
(
done
)
{
inputQueue
=
[];
outputQueue
=
[];
await
closeFileDescriptor
(
readpath
);
await
getFdRead
(
readpath
,
done
);
await
audioDecodeProcessor
.
flush
().
then
(()
=>
{
console
.
info
(
"
case flush at inputeos success
"
);
...
...
@@ -497,7 +458,6 @@ describe('AudioDecoderFuncPromise', function () {
await
flushWork
(
done
);
}
else
if
(
workdoneAtEOS
)
{
await
doneWork
();
await
closeFileDescriptor
(
readpath
);
await
closeFdWrite
();
done
();
}
else
{
...
...
@@ -785,7 +745,6 @@ describe('AudioDecoderFuncPromise', function () {
console
.
info
(
"
case release success
"
);
},
failCallback
).
catch
(
failCatch
);
audioDecodeProcessor
=
null
;
await
closeFileDescriptor
(
readpath
);
await
closeFdWrite
();
done
();
})
...
...
@@ -839,7 +798,6 @@ describe('AudioDecoderFuncPromise', function () {
console
.
info
(
"
case restart decoding after 2s
"
);
});
resetParam
();
await
closeFileDescriptor
(
readpath
);
await
getFdRead
(
readpath
,
done
);
readFile
(
readpath
);
await
audioDecodeProcessor
.
start
().
then
(()
=>
{
...
...
@@ -898,7 +856,6 @@ describe('AudioDecoderFuncPromise', function () {
console
.
info
(
"
case start configure 2
"
);
});
resetParam
();
await
closeFileDescriptor
(
readpath
);
await
closeFdWrite
();
await
audioDecodeProcessor
.
configure
(
mediaDescription2
).
then
(()
=>
{
console
.
info
(
"
case configure 2 success
"
);
...
...
@@ -984,7 +941,6 @@ describe('AudioDecoderFuncPromise', function () {
await
sleep
(
10000
).
then
(()
=>
{
console
.
info
(
"
start createaudiodecoder 2
"
);
});
await
closeFileDescriptor
(
readpath
);
await
closeFdWrite
();
await
media
.
createAudioDecoderByMime
(
'
audio/flac
'
).
then
((
processor
)
=>
{
console
.
info
(
"
case create createAudioDecoder flac success
"
);
...
...
multimedia/media/media_js_standard/audioDecoder/src/main/js/test/AudioDecoderMultiInstancesTest.test.js
浏览文件 @
48123541
...
...
@@ -14,11 +14,10 @@
*/
import
media
from
'
@ohos.multimedia.media
'
import
F
ileio
from
'
@ohos.fileio
'
import
f
ileio
from
'
@ohos.fileio
'
import
{
describe
,
beforeAll
,
beforeEach
,
afterEach
,
afterAll
,
it
,
expect
}
from
'
deccjsunit/index
'
describe
(
'
AudioDecoderMultiInstances
'
,
function
()
{
const
RESOURCEPATH
=
'
/data/app/el1/bundle/resources/
'
const
AUDIOPATH
=
'
AAC_48000_32_1.aac
'
;
let
readStreamSync
;
let
eosframenum
=
0
;
...
...
@@ -84,7 +83,7 @@ describe('AudioDecoderMultiInstances', function () {
function
writeFile
(
path
,
buf
,
len
)
{
try
{
let
writestream
=
F
ileio
.
createStreamSync
(
path
,
"
ab+
"
);
let
writestream
=
f
ileio
.
createStreamSync
(
path
,
"
ab+
"
);
let
num
=
writestream
.
writeSync
(
buf
,
{
length
:
len
});
writestream
.
flushSync
();
writestream
.
closeSync
();
...
...
@@ -97,7 +96,7 @@ describe('AudioDecoderMultiInstances', function () {
console
.
info
(
'
read file start execution
'
);
try
{
console
.
info
(
'
filepath:
'
+
path
);
readStreamSync
=
F
ileio
.
createStreamSync
(
path
,
'
rb
'
);
readStreamSync
=
f
ileio
.
createStreamSync
(
path
,
'
rb
'
);
}
catch
(
e
)
{
console
.
info
(
e
);
}
...
...
multimedia/media/media_js_standard/audioDecoder/src/main/js/test/AudioDecoderReliabilityCallbackTest.test.js
浏览文件 @
48123541
...
...
@@ -15,13 +15,12 @@
import
media
from
'
@ohos.multimedia.media
'
import
fileio
from
'
@ohos.fileio
'
import
{
getFileDescriptor
,
closeFileDescriptor
}
from
'
./AudioDecoderTestBase.test.js
'
import
*
as
mediaTestBase
from
'
../../../../../MediaTestBase.js
'
;
import
{
describe
,
beforeAll
,
beforeEach
,
afterEach
,
afterAll
,
it
,
expect
}
from
'
deccjsunit/index
'
describe
(
'
AudioDecoderReliabilityCallback
'
,
function
()
{
const
RESOURCEPATH
=
'
/data/accounts/account_0/appdata/ohos.acts.multimedia.audio.audiodecoder/
'
const
AUDIOPATH
=
'
AAC_48000_32_1.aac
'
;
const
BASIC_PATH
=
RESOURCEPATH
+
'
results/decode_reliability_callback
'
;
const
BASIC_PATH
=
'
results/decode_reliability_callback
'
;
const
END
=
0
;
const
CONFIGURE
=
1
;
const
PREPARE
=
2
;
...
...
@@ -268,12 +267,10 @@ describe('AudioDecoderReliabilityCallback', function () {
audioDecodeProcessor
=
null
;
},
failCallback
).
catch
(
failCatch
);
}
await
closeFileDescriptor
(
AUDIOPATH
);
})
afterAll
(
async
function
()
{
console
.
info
(
'
afterAll case
'
);
await
closeFileDescriptor
(
AUDIOPATH
);
})
function
resetParam
()
{
...
...
@@ -303,16 +300,9 @@ describe('AudioDecoderReliabilityCallback', function () {
})
}
async
function
getFdRead
(
pathName
,
done
)
{
await
getFileDescriptor
(
pathName
).
then
((
res
)
=>
{
if
(
res
==
undefined
)
{
expect
().
assertFail
();
console
.
info
(
'
case error fileDescriptor undefined, open file fail
'
);
done
();
}
else
{
fdRead
=
res
.
fd
;
console
.
info
(
"
case fdRead is:
"
+
fdRead
);
}
async
function
getFdRead
(
readPath
,
done
)
{
await
mediaTestBase
.
getFdRead
(
readPath
,
done
).
then
((
fdNumber
)
=>
{
fdRead
=
fdNumber
;
})
}
...
...
@@ -396,7 +386,6 @@ describe('AudioDecoderReliabilityCallback', function () {
console
.
info
(
`case to start`
);
if
(
sawOutputEOS
)
{
resetParam
();
await
closeFileDescriptor
(
AUDIOPATH
);
await
getFdRead
(
AUDIOPATH
,
done
);
readFile
(
AUDIOPATH
);
workdoneAtEOS
=
true
;
...
...
@@ -418,7 +407,6 @@ describe('AudioDecoderReliabilityCallback', function () {
console
.
info
(
`case flush 1`
);
if
(
flushAtEOS
)
{
resetParam
();
await
closeFileDescriptor
(
AUDIOPATH
);
await
getFdRead
(
AUDIOPATH
,
done
);
readFile
(
AUDIOPATH
);
workdoneAtEOS
=
true
;
...
...
multimedia/media/media_js_standard/audioDecoder/src/main/js/test/AudioDecoderReliabilityPromiseTest.test.js
浏览文件 @
48123541
...
...
@@ -15,13 +15,12 @@
import
media
from
'
@ohos.multimedia.media
'
import
fileio
from
'
@ohos.fileio
'
import
{
getFileDescriptor
,
closeFileDescriptor
}
from
'
./AudioDecoderTestBase.test.js
'
import
*
as
mediaTestBase
from
'
../../../../../MediaTestBase.js
'
;
import
{
describe
,
beforeAll
,
beforeEach
,
afterEach
,
afterAll
,
it
,
expect
}
from
'
deccjsunit/index
'
describe
(
'
AudioDecoderReliabilityPromise
'
,
function
()
{
const
RESOURCEPATH
=
'
/data/accounts/account_0/appdata/ohos.acts.multimedia.audio.audiodecoder/
'
const
AUDIOPATH
=
'
AAC_48000_32_1.aac
'
;
const
BASIC_PATH
=
RESOURCEPATH
+
'
results/decode_reliability_promise
'
;
const
BASIC_PATH
=
'
results/decode_reliability_promise
'
;
const
END
=
0
;
const
CONFIGURE
=
1
;
const
PREPARE
=
2
;
...
...
@@ -272,12 +271,10 @@ describe('AudioDecoderReliabilityPromise', function () {
audioDecodeProcessor
=
null
;
},
failCallback
).
catch
(
failCatch
);
}
await
closeFileDescriptor
(
AUDIOPATH
);
})
afterAll
(
async
function
()
{
console
.
info
(
'
afterAll case
'
);
await
closeFileDescriptor
(
AUDIOPATH
);
})
let
failCallback
=
function
(
err
)
{
...
...
@@ -324,16 +321,9 @@ describe('AudioDecoderReliabilityPromise', function () {
})
}
async
function
getFdRead
(
pathName
,
done
)
{
await
getFileDescriptor
(
pathName
).
then
((
res
)
=>
{
if
(
res
==
undefined
)
{
expect
().
assertFail
();
console
.
info
(
'
case error fileDescriptor undefined, open file fail
'
);
done
();
}
else
{
fdRead
=
res
.
fd
;
console
.
info
(
"
case fdRead is:
"
+
fdRead
);
}
async
function
getFdRead
(
readPath
,
done
)
{
await
mediaTestBase
.
getFdRead
(
readPath
,
done
).
then
((
fdNumber
)
=>
{
fdRead
=
fdNumber
;
})
}
...
...
@@ -408,7 +398,6 @@ describe('AudioDecoderReliabilityPromise', function () {
console
.
info
(
`case to start`
);
if
(
sawOutputEOS
)
{
resetParam
();
await
closeFileDescriptor
(
AUDIOPATH
);
await
getFdRead
(
AUDIOPATH
,
done
);
readFile
(
AUDIOPATH
);
workdoneAtEOS
=
true
;
...
...
@@ -427,7 +416,6 @@ describe('AudioDecoderReliabilityPromise', function () {
audioDecodeProcessor
.
flush
().
then
(
async
()
=>
{
console
.
info
(
`case flush 1`
);
if
(
flushAtEOS
)
{
await
closeFileDescriptor
(
AUDIOPATH
);
await
getFdRead
(
AUDIOPATH
,
done
);
resetParam
();
readFile
(
AUDIOPATH
);
...
...
multimedia/media/media_js_standard/audioDecoder/src/main/js/test/AudioDecoderTestBase.test.js
已删除
100644 → 0
浏览文件 @
0cfa1c82
/*
* 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
resourceManager
from
'
@ohos.resourceManager
'
;
export
async
function
getFileDescriptor
(
fileName
)
{
let
fileDescriptor
=
undefined
;
await
resourceManager
.
getResourceManager
().
then
(
async
(
mgr
)
=>
{
await
mgr
.
getRawFileDescriptor
(
fileName
).
then
(
value
=>
{
fileDescriptor
=
{
fd
:
value
.
fd
,
offset
:
value
.
offset
,
length
:
value
.
length
};
}).
catch
(
error
=>
{
console
.
log
(
'
case getRawFileDescriptor err:
'
+
error
);
});
});
return
fileDescriptor
;
}
export
async
function
closeFileDescriptor
(
fileName
)
{
await
resourceManager
.
getResourceManager
().
then
(
async
(
mgr
)
=>
{
await
mgr
.
closeRawFileDescriptor
(
fileName
).
then
(
value
=>
{
console
.
log
(
'
case closeRawFileDescriptor success for file:
'
+
fileName
);
}).
catch
(
error
=>
{
console
.
log
(
'
case closeRawFileDescriptor err:
'
+
error
);
});
});
}
multimedia/media/media_js_standard/audioDecoder/src/main/js/test/List.test.js
浏览文件 @
48123541
...
...
@@ -13,7 +13,7 @@
* limitations under the License.
*/
require
(
'
./AudioDecoderTestBase.test.js
'
)
require
(
'
./AudioDecoderFuncPromiseTest.test.js
'
)
require
(
'
./AudioDecoderFuncCallbackTest.test.js
'
)
require
(
'
./AudioDecoderFormatPromiseTest.test.js
'
)
...
...
multimedia/media/media_js_standard/audioEncoder/Test.json
浏览文件 @
48123541
...
...
@@ -18,8 +18,8 @@
"type"
:
"ShellKit"
,
"run-command"
:
[
"rm -rf /storage/media/100/local/files/*"
,
"mkdir -p /data/app/el
1/bundle/public/ohos.acts.multimedia.audio.audioencoder/ohos.acts.multimedia.audio.audioencoder/assets/entry/resources/rawfile
/"
,
"chmod 777 -R /data/app/el
1/bundle/public/ohos.acts.multimedia.audio.audioencoder/ohos.acts.multimedia.audio.audioencoder/assets/entry/resources/rawfile
/"
"mkdir -p /data/app/el
2/100/base/ohos.acts.multimedia.audio.audioencoder/haps/entry/files
/"
,
"chmod 777 -R /data/app/el
2/100/base/ohos.acts.multimedia.audio.audioencoder/haps/entry/files
/"
],
"teardown-command"
:[
]
...
...
@@ -29,14 +29,14 @@
"pre-push"
:
[
],
"push"
:
[
"./resource/audio/audioEncode/S16LE.pcm ->/data/app/el
1/bundle/public/ohos.acts.multimedia.audio.audioencoder/ohos.acts.multimedia.audio.audioencoder/assets/entry/resources/rawfile
/"
"./resource/audio/audioEncode/S16LE.pcm ->/data/app/el
2/100/base/ohos.acts.multimedia.audio.audioencoder/haps/entry/files
/"
]
},
{
"type"
:
"ShellKit"
,
"run-command"
:
[
"chmod 777 -R /data/app/el
1/bundle/public/ohos.acts.multimedia.audio.audioencoder/ohos.acts.multimedia.audio.audioencoder/assets/entry/resources/rawfile
/"
,
"chmod 777 /data/app/el
1/bundle/public/ohos.acts.multimedia.audio.audioencoder/ohos.acts.multimedia.audio.audioencoder/assets/entry/resources/rawfile
/*"
,
"chmod 777 -R /data/app/el
2/100/base/ohos.acts.multimedia.audio.audioencoder/haps/entry/files
/"
,
"chmod 777 /data/app/el
2/100/base/ohos.acts.multimedia.audio.audioencoder/haps/entry/files
/*"
,
"chmod 777 -R /storage/media/100/local/files/"
,
"chmod 777 /storage/media/100/local/files/*"
,
"killall com.ohos.medialibrary.MediaScannerAbilityA"
,
...
...
multimedia/media/media_js_standard/audioEncoder/src/main/js/test/AudioEncoderFuncCallbackTest.test.js
浏览文件 @
48123541
...
...
@@ -15,17 +15,13 @@
import
media
from
'
@ohos.multimedia.media
'
import
fileio
from
'
@ohos.fileio
'
import
abilityAccessCtrl
from
'
@ohos.abilityAccessCtrl
'
import
bundle
from
'
@ohos.bundle
'
import
featureAbility
from
'
@ohos.ability.featureAbility
'
import
mediaLibrary
from
'
@ohos.multimedia.mediaLibrary
'
import
{
getFileDescriptor
,
closeFileDescriptor
}
from
'
./AudioEncoderTestBase.test
.js
'
;
import
*
as
mediaTestBase
from
'
../../../../../MediaTestBase
.js
'
;
import
{
describe
,
beforeAll
,
beforeEach
,
afterEach
,
afterAll
,
it
,
expect
}
from
'
deccjsunit/index
'
describe
(
'
AudioEncoderFuncCallback
'
,
function
()
{
const
RESOURCEPATH
=
'
/data/accounts/account_0/appdata/ohos.acts.multimedia.audio.audioencoder/
'
const
AUDIOPATH
=
'
S16LE.pcm
'
;
const
BASIC_PATH
=
RESOURCEPATH
+
'
results/encode_func_callback_
'
;
let
audioEncodeProcessor
;
let
readStreamSync
;
let
eosframenum
=
0
;
...
...
@@ -54,7 +50,12 @@ describe('AudioEncoderFuncCallback', function () {
beforeAll
(
async
function
()
{
console
.
info
(
'
beforeAll case 1
'
);
await
applyPermission
();
let
permissionName1
=
'
ohos.permission.MEDIA_LOCATION
'
;
let
permissionName2
=
'
ohos.permission.READ_MEDIA
'
;
let
permissionName3
=
'
ohos.permission.WRITE_MEDIA
'
;
permissionNameList
=
[
permissionName1
,
permissionName2
,
permissionName3
];
let
appName
=
'
ohos.acts.multimedia.audio.audioencoder
'
;
await
mediaTestBase
.
applyPermission
(
appName
,
permissionNameList
);
console
.
info
(
'
beforeAll case after get permission
'
);
})
...
...
@@ -86,13 +87,10 @@ describe('AudioEncoderFuncCallback', function () {
audioEncodeProcessor
=
null
;
},
failCallback
).
catch
(
failCatch
);
}
await
closeFileDescriptor
(
AUDIOPATH
);
await
closeFdWrite
();
})
afterAll
(
async
function
()
{
console
.
info
(
'
afterAll case
'
);
await
closeFileDescriptor
(
AUDIOPATH
);
})
function
resetParam
()
{
...
...
@@ -112,49 +110,12 @@ describe('AudioEncoderFuncCallback', function () {
outputQueue
=
[];
}
async
function
getFdRead
(
pathName
,
done
)
{
await
getFileDescriptor
(
pathName
).
then
((
res
)
=>
{
if
(
res
==
undefined
)
{
expect
().
assertFail
();
console
.
info
(
'
case error fileDescriptor undefined, open file fail
'
);
done
();
}
else
{
fdRead
=
res
.
fd
;
console
.
info
(
"
case pathName is:
"
+
pathName
);
console
.
info
(
"
case fdRead is:
"
+
fdRead
);
}
async
function
getFdRead
(
readPath
,
done
)
{
await
mediaTestBase
.
getFdRead
(
readPath
,
done
).
then
((
fdNumber
)
=>
{
fdRead
=
fdNumber
;
})
}
async
function
applyPermission
()
{
let
appInfo
=
await
bundle
.
getApplicationInfo
(
'
ohos.acts.multimedia.audio.audioencoder
'
,
0
,
100
);
let
atManager
=
abilityAccessCtrl
.
createAtManager
();
if
(
atManager
!=
null
)
{
let
tokenID
=
appInfo
.
accessTokenId
;
console
.
info
(
'
[permission] case accessTokenID is
'
+
tokenID
);
let
permissionName1
=
'
ohos.permission.MEDIA_LOCATION
'
;
let
permissionName2
=
'
ohos.permission.READ_MEDIA
'
;
let
permissionName3
=
'
ohos.permission.WRITE_MEDIA
'
;
await
atManager
.
grantUserGrantedPermission
(
tokenID
,
permissionName1
,
1
).
then
((
result
)
=>
{
console
.
info
(
'
[permission] case grantUserGrantedPermission success :
'
+
result
);
}).
catch
((
err
)
=>
{
console
.
info
(
'
[permission] case grantUserGrantedPermission failed :
'
+
err
);
});
await
atManager
.
grantUserGrantedPermission
(
tokenID
,
permissionName2
,
1
).
then
((
result
)
=>
{
console
.
info
(
'
[permission] case grantUserGrantedPermission success :
'
+
result
);
}).
catch
((
err
)
=>
{
console
.
info
(
'
[permission] case grantUserGrantedPermission failed :
'
+
err
);
});
await
atManager
.
grantUserGrantedPermission
(
tokenID
,
permissionName3
,
1
).
then
((
result
)
=>
{
console
.
info
(
'
[permission] case grantUserGrantedPermission success :
'
+
result
);
}).
catch
((
err
)
=>
{
console
.
info
(
'
[permission] case grantUserGrantedPermission failed :
'
+
err
);
});
}
else
{
console
.
info
(
'
[permission] case apply permission failed, createAtManager failed
'
);
}
}
async
function
getFdWrite
(
pathName
)
{
console
.
info
(
'
[mediaLibrary] case start getFdWrite
'
);
console
.
info
(
'
[mediaLibrary] case getFdWrite pathName is
'
+
pathName
);
...
...
@@ -173,7 +134,7 @@ describe('AudioEncoderFuncCallback', function () {
console
.
info
(
'
[mediaLibrary] case getFdWrite getFileAssets() success
'
);
fileAsset
=
await
fetchWriteFileResult
.
getAllObject
();
console
.
info
(
'
[mediaLibrary] case getFdWrite getAllObject() success
'
);
fdWrite
=
await
fileAsset
[
0
].
open
(
'
R
w
'
);
fdWrite
=
await
fileAsset
[
0
].
open
(
'
r
w
'
);
console
.
info
(
'
[mediaLibrary] case getFdWrite fdWrite is
'
+
fdWrite
);
}
}
...
...
@@ -269,7 +230,6 @@ describe('AudioEncoderFuncCallback', function () {
async
function
flushWork
(
done
)
{
inputQueue
=
[];
outputQueue
=
[];
await
closeFileDescriptor
(
readpath
);
await
getFdRead
(
readpath
,
done
);
audioEncodeProcessor
.
flush
((
err
)
=>
{
expect
(
err
).
assertUndefined
();
...
...
@@ -291,7 +251,6 @@ describe('AudioEncoderFuncCallback', function () {
expect
(
err
).
assertUndefined
();
console
.
log
(
"
case release success
"
);
audioEncodeProcessor
=
null
;
await
closeFileDescriptor
(
AUDIOPATH
);
await
closeFdWrite
();
done
();
})
...
...
@@ -739,7 +698,6 @@ describe('AudioEncoderFuncCallback', function () {
expect
(
err
).
assertUndefined
();
console
.
info
(
`case release 1`
);
audioEncodeProcessor
=
null
;
await
closeFileDescriptor
(
AUDIOPATH
);
await
closeFdWrite
();
done
();
})
...
...
@@ -819,7 +777,6 @@ describe('AudioEncoderFuncCallback', function () {
eventEmitter
.
on
(
'
restart
'
,
()
=>
{
sleep
(
2000
).
then
(
async
()
=>
{
resetParam
();
await
closeFileDescriptor
(
readpath
);
await
getFdRead
(
readpath
,
done
);
readFile
(
readpath
);
audioEncodeProcessor
.
start
((
err
)
=>
{
...
...
@@ -903,7 +860,6 @@ describe('AudioEncoderFuncCallback', function () {
eventEmitter
.
on
(
'
reconfigure
'
,
(
mediaDescription2
)
=>
{
sleep
(
10000
).
then
(
async
()
=>
{
resetParam
();
await
closeFileDescriptor
(
readpath
);
await
closeFdWrite
();
audioEncodeProcessor
.
configure
(
mediaDescription2
,
async
(
err
)
=>
{
expect
(
err
).
assertUndefined
();
...
...
multimedia/media/media_js_standard/audioEncoder/src/main/js/test/AudioEncoderFuncPromiseTest.test.js
浏览文件 @
48123541
...
...
@@ -15,17 +15,13 @@
import
media
from
'
@ohos.multimedia.media
'
import
fileio
from
'
@ohos.fileio
'
import
abilityAccessCtrl
from
'
@ohos.abilityAccessCtrl
'
import
bundle
from
'
@ohos.bundle
'
import
featureAbility
from
'
@ohos.ability.featureAbility
'
import
mediaLibrary
from
'
@ohos.multimedia.mediaLibrary
'
import
{
getFileDescriptor
,
closeFileDescriptor
}
from
'
./AudioEncoderTestBase.test
.js
'
;
import
*
as
mediaTestBase
from
'
../../../../../MediaTestBase
.js
'
;
import
{
describe
,
beforeAll
,
beforeEach
,
afterEach
,
afterAll
,
it
,
expect
}
from
'
deccjsunit/index
'
describe
(
'
AudioEncoderFuncPromise_audio_1
'
,
function
()
{
const
RESOURCEPATH
=
'
/data/accounts/account_0/appdata/ohos.acts.multimedia.audio.audioencoder/
'
describe
(
'
AudioEncoderFuncPromise
'
,
function
()
{
const
AUDIOPATH
=
'
S16LE.pcm
'
;
const
BASIC_PATH
=
RESOURCEPATH
+
'
results/encode_func_promise_
'
;
let
audioEncodeProcessor
;
let
readStreamSync
;
let
eosframenum
=
0
;
...
...
@@ -54,7 +50,12 @@ describe('AudioEncoderFuncPromise_audio_1', function () {
beforeAll
(
async
function
()
{
console
.
info
(
'
beforeAll case 1
'
);
await
applyPermission
();
let
permissionName1
=
'
ohos.permission.MEDIA_LOCATION
'
;
let
permissionName2
=
'
ohos.permission.READ_MEDIA
'
;
let
permissionName3
=
'
ohos.permission.WRITE_MEDIA
'
;
permissionNameList
=
[
permissionName1
,
permissionName2
,
permissionName3
];
let
appName
=
'
ohos.acts.multimedia.audio.audioencoder
'
;
await
mediaTestBase
.
applyPermission
(
appName
,
permissionNameList
);
console
.
info
(
'
beforeAll case after get permission
'
);
})
...
...
@@ -86,13 +87,10 @@ describe('AudioEncoderFuncPromise_audio_1', function () {
audioEncodeProcessor
=
null
;
},
failCallback
).
catch
(
failCatch
);
}
await
closeFileDescriptor
(
AUDIOPATH
);
await
closeFdWrite
();
})
afterAll
(
async
function
()
{
console
.
info
(
'
afterAll case
'
);
await
closeFileDescriptor
(
AUDIOPATH
);
})
let
failCallback
=
function
(
err
)
{
...
...
@@ -122,49 +120,12 @@ describe('AudioEncoderFuncPromise_audio_1', function () {
outputQueue
=
[];
}
async
function
getFdRead
(
pathName
,
done
)
{
await
getFileDescriptor
(
pathName
).
then
((
res
)
=>
{
if
(
res
==
undefined
)
{
expect
().
assertFail
();
console
.
info
(
'
case error fileDescriptor undefined, open file fail
'
);
done
();
}
else
{
fdRead
=
res
.
fd
;
console
.
info
(
"
case pathName is:
"
+
pathName
);
console
.
info
(
"
case fdRead is:
"
+
fdRead
);
}
async
function
getFdRead
(
readPath
,
done
)
{
await
mediaTestBase
.
getFdRead
(
readPath
,
done
).
then
((
fdNumber
)
=>
{
fdRead
=
fdNumber
;
})
}
async
function
applyPermission
()
{
let
appInfo
=
await
bundle
.
getApplicationInfo
(
'
ohos.acts.multimedia.audio.audioencoder
'
,
0
,
100
);
let
atManager
=
abilityAccessCtrl
.
createAtManager
();
if
(
atManager
!=
null
)
{
let
tokenID
=
appInfo
.
accessTokenId
;
console
.
info
(
'
[permission] case accessTokenID is
'
+
tokenID
);
let
permissionName1
=
'
ohos.permission.MEDIA_LOCATION
'
;
let
permissionName2
=
'
ohos.permission.READ_MEDIA
'
;
let
permissionName3
=
'
ohos.permission.WRITE_MEDIA
'
;
await
atManager
.
grantUserGrantedPermission
(
tokenID
,
permissionName1
,
1
).
then
((
result
)
=>
{
console
.
info
(
'
[permission] case grantUserGrantedPermission success :
'
+
result
);
}).
catch
((
err
)
=>
{
console
.
info
(
'
[permission] case grantUserGrantedPermission failed :
'
+
err
);
});
await
atManager
.
grantUserGrantedPermission
(
tokenID
,
permissionName2
,
1
).
then
((
result
)
=>
{
console
.
info
(
'
[permission] case grantUserGrantedPermission success :
'
+
result
);
}).
catch
((
err
)
=>
{
console
.
info
(
'
[permission] case grantUserGrantedPermission failed :
'
+
err
);
});
await
atManager
.
grantUserGrantedPermission
(
tokenID
,
permissionName3
,
1
).
then
((
result
)
=>
{
console
.
info
(
'
[permission] case grantUserGrantedPermission success :
'
+
result
);
}).
catch
((
err
)
=>
{
console
.
info
(
'
[permission] case grantUserGrantedPermission failed :
'
+
err
);
});
}
else
{
console
.
info
(
'
[permission] case apply permission failed, createAtManager failed
'
);
}
}
async
function
getFdWrite
(
pathName
)
{
console
.
info
(
'
[mediaLibrary] case start getFdWrite
'
);
console
.
info
(
'
[mediaLibrary] case getFdWrite pathName is
'
+
pathName
);
...
...
@@ -183,7 +144,7 @@ describe('AudioEncoderFuncPromise_audio_1', function () {
console
.
info
(
'
[mediaLibrary] case getFdWrite getFileAssets() success
'
);
fileAsset
=
await
fetchWriteFileResult
.
getAllObject
();
console
.
info
(
'
[mediaLibrary] case getFdWrite getAllObject() success
'
);
fdWrite
=
await
fileAsset
[
0
].
open
(
'
R
w
'
);
fdWrite
=
await
fileAsset
[
0
].
open
(
'
r
w
'
);
console
.
info
(
'
[mediaLibrary] case getFdWrite fdWrite is
'
+
fdWrite
);
}
}
...
...
@@ -275,7 +236,6 @@ describe('AudioEncoderFuncPromise_audio_1', function () {
async
function
flushWork
(
done
)
{
inputQueue
=
[];
outputQueue
=
[];
await
closeFileDescriptor
(
readpath
);
await
getFdRead
(
readpath
,
done
);
await
audioEncodeProcessor
.
flush
().
then
(()
=>
{
console
.
info
(
"
case flush at inputeos success
"
);
...
...
@@ -346,7 +306,6 @@ describe('AudioEncoderFuncPromise_audio_1', function () {
await
flushWork
(
done
);
}
else
if
(
workdoneAtEOS
)
{
await
doneWork
();
await
closeFileDescriptor
(
AUDIOPATH
);
await
closeFdWrite
();
done
();
}
else
{
...
...
@@ -640,7 +599,6 @@ describe('AudioEncoderFuncPromise_audio_1', function () {
console
.
info
(
"
case release success
"
);
},
failCallback
).
catch
(
failCatch
);
audioEncodeProcessor
=
null
;
await
closeFileDescriptor
(
AUDIOPATH
);
await
closeFdWrite
();
done
();
})
...
...
@@ -694,7 +652,6 @@ describe('AudioEncoderFuncPromise_audio_1', function () {
console
.
info
(
"
restart encoding after 2s
"
);
});
resetParam
();
await
closeFileDescriptor
(
readpath
);
await
getFdRead
(
readpath
,
done
);
readFile
(
readpath
);
await
audioEncodeProcessor
.
start
().
then
(()
=>
{
...
...
@@ -753,7 +710,6 @@ describe('AudioEncoderFuncPromise_audio_1', function () {
console
.
info
(
"
start configure 2
"
);
});
resetParam
();
await
closeFileDescriptor
(
readpath
);
await
closeFdWrite
();
await
audioEncodeProcessor
.
configure
(
mediaDescription2
).
then
(()
=>
{
console
.
info
(
"
configure 2 success
"
);
...
...
multimedia/media/media_js_standard/audioEncoder/src/main/js/test/AudioEncoderReliabilityCallbackTest.test.js
浏览文件 @
48123541
...
...
@@ -15,13 +15,12 @@
import
media
from
'
@ohos.multimedia.media
'
import
fileio
from
'
@ohos.fileio
'
import
{
getFileDescriptor
,
closeFileDescriptor
}
from
'
./AudioEncoderTestBase.test
.js
'
;
import
*
as
mediaTestBase
from
'
../../../../../MediaTestBase
.js
'
;
import
{
describe
,
beforeAll
,
beforeEach
,
afterEach
,
afterAll
,
it
,
expect
}
from
'
deccjsunit/index
'
describe
(
'
AudioEncoderReliabilityCallback
'
,
function
()
{
const
RESOURCEPATH
=
'
/data/accounts/account_0/appdata/ohos.acts.multimedia.audio.audioencoder/
'
const
AUDIOPATH
=
'
S16LE.pcm
'
;
const
BASIC_PATH
=
RESOURCEPATH
+
'
results/encode_reliability_callback_
'
;
const
BASIC_PATH
=
'
results/encode_reliability_callback_
'
;
const
END
=
0
;
const
CONFIGURE
=
1
;
const
PREPARE
=
2
;
...
...
@@ -91,12 +90,10 @@ describe('AudioEncoderReliabilityCallback', function () {
},
failCallback
).
catch
(
failCatch
);
audioEncodeProcessor
=
null
;
}
await
closeFileDescriptor
(
AUDIOPATH
);
})
afterAll
(
async
function
()
{
console
.
info
(
'
afterAll case
'
);
await
closeFileDescriptor
(
AUDIOPATH
);
})
function
resetParam
()
{
...
...
@@ -126,16 +123,9 @@ describe('AudioEncoderReliabilityCallback', function () {
})
}
async
function
getFdRead
(
pathName
,
done
)
{
await
getFileDescriptor
(
pathName
).
then
((
res
)
=>
{
if
(
res
==
undefined
)
{
expect
().
assertFail
();
console
.
info
(
'
case error fileDescriptor undefined, open file fail
'
);
done
();
}
else
{
fdRead
=
res
.
fd
;
console
.
info
(
"
case fdRead is:
"
+
fdRead
);
}
async
function
getFdRead
(
readPath
,
done
)
{
await
mediaTestBase
.
getFdRead
(
readPath
,
done
).
then
((
fdNumber
)
=>
{
fdRead
=
fdNumber
;
})
}
...
...
@@ -217,7 +207,6 @@ describe('AudioEncoderReliabilityCallback', function () {
console
.
info
(
`case to start`
);
if
(
sawOutputEOS
)
{
resetParam
();
await
closeFileDescriptor
(
AUDIOPATH
);
await
getFdRead
(
AUDIOPATH
,
done
);
readFile
(
AUDIOPATH
);
workdoneAtEOS
=
true
;
...
...
@@ -238,7 +227,6 @@ describe('AudioEncoderReliabilityCallback', function () {
expect
(
err
).
assertUndefined
();
console
.
info
(
`case flush 1`
);
if
(
flushAtEOS
)
{
await
closeFileDescriptor
(
AUDIOPATH
);
await
getFdRead
(
AUDIOPATH
,
done
);
resetParam
();
readFile
(
AUDIOPATH
);
...
...
multimedia/media/media_js_standard/audioEncoder/src/main/js/test/AudioEncoderReliabilityPromiseTest.test.js
浏览文件 @
48123541
...
...
@@ -15,13 +15,12 @@
import
media
from
'
@ohos.multimedia.media
'
import
fileio
from
'
@ohos.fileio
'
import
{
getFileDescriptor
,
closeFileDescriptor
}
from
'
./AudioEncoderTestBase.test
.js
'
;
import
*
as
mediaTestBase
from
'
../../../../../MediaTestBase
.js
'
;
import
{
describe
,
beforeAll
,
beforeEach
,
afterEach
,
afterAll
,
it
,
expect
}
from
'
deccjsunit/index
'
describe
(
'
AudioEncoderReliabilityPromise
'
,
function
()
{
const
RESOURCEPATH
=
'
/data/accounts/account_0/appdata/ohos.acts.multimedia.audio.audioencoder/
'
const
AUDIOPATH
=
'
S16LE.pcm
'
;
const
BASIC_PATH
=
RESOURCEPATH
+
'
results/encode_reliability_promise_
'
;
const
BASIC_PATH
=
'
results/encode_reliability_promise_
'
;
const
END
=
0
;
const
CONFIGURE
=
1
;
const
PREPARE
=
2
;
...
...
@@ -93,12 +92,10 @@ describe('AudioEncoderReliabilityPromise', function () {
},
failCallback
).
catch
(
failCatch
);
audioEncodeProcessor
=
null
;
}
await
closeFileDescriptor
(
AUDIOPATH
);
})
afterAll
(
async
function
()
{
console
.
info
(
'
afterAll case
'
);
await
closeFileDescriptor
(
AUDIOPATH
);
})
let
failCallback
=
function
(
err
)
{
...
...
@@ -143,19 +140,12 @@ describe('AudioEncoderReliabilityPromise', function () {
},
failCallback
).
catch
(
failCatch
);
}
async
function
getFdRead
(
pathName
,
done
)
{
await
getFileDescriptor
(
pathName
).
then
((
res
)
=>
{
if
(
res
==
undefined
)
{
expect
().
assertFail
();
console
.
info
(
'
case error fileDescriptor undefined, open file fail
'
);
done
();
}
else
{
fdRead
=
res
.
fd
;
console
.
info
(
"
case fdRead is:
"
+
fdRead
);
}
async
function
getFdRead
(
readPath
,
done
)
{
await
mediaTestBase
.
getFdRead
(
readPath
,
done
).
then
((
fdNumber
)
=>
{
fdRead
=
fdNumber
;
})
}
function
readFile
(
path
)
{
console
.
info
(
'
read file start execution
'
);
try
{
...
...
@@ -227,7 +217,6 @@ describe('AudioEncoderReliabilityPromise', function () {
console
.
info
(
`case to start`
);
if
(
sawOutputEOS
)
{
resetParam
();
await
closeFileDescriptor
(
AUDIOPATH
);
await
getFdRead
(
AUDIOPATH
,
done
);
readFile
(
AUDIOPATH
);
workdoneAtEOS
=
true
;
...
...
@@ -246,7 +235,6 @@ describe('AudioEncoderReliabilityPromise', function () {
audioEncodeProcessor
.
flush
().
then
(
async
()
=>
{
console
.
info
(
`case flush 1`
);
if
(
flushAtEOS
)
{
await
closeFileDescriptor
(
AUDIOPATH
);
await
getFdRead
(
AUDIOPATH
,
done
);
resetParam
();
readFile
(
AUDIOPATH
);
...
...
multimedia/media/media_js_standard/audioEncoder/src/main/js/test/AudioEncoderTestBase.test.js
已删除
100644 → 0
浏览文件 @
0cfa1c82
/*
* 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
resourceManager
from
'
@ohos.resourceManager
'
;
export
async
function
getFileDescriptor
(
fileName
)
{
let
fileDescriptor
;
await
resourceManager
.
getResourceManager
().
then
(
async
(
mgr
)
=>
{
await
mgr
.
getRawFileDescriptor
(
fileName
).
then
(
value
=>
{
fileDescriptor
=
{
fd
:
value
.
fd
,
offset
:
value
.
offset
,
length
:
value
.
length
};
}).
catch
(
error
=>
{
console
.
log
(
'
case getRawFileDescriptor err:
'
+
error
);
});
});
return
fileDescriptor
;
}
export
async
function
closeFileDescriptor
(
fileName
)
{
await
resourceManager
.
getResourceManager
().
then
(
async
(
mgr
)
=>
{
await
mgr
.
closeRawFileDescriptor
(
fileName
).
then
(
value
=>
{
console
.
log
(
'
case closeRawFileDescriptor success for fileName:
'
+
fileName
);
}).
catch
(
error
=>
{
console
.
log
(
'
case closeRawFileDescriptor err:
'
+
error
);
});
});
}
multimedia/media/media_js_standard/audioEncoder/src/main/js/test/List.test.js
浏览文件 @
48123541
...
...
@@ -13,7 +13,6 @@
* limitations under the License.
*/
require
(
'
./AudioEncoderTestBase.test.js
'
)
require
(
'
./AudioEncoderFuncCallbackTest.test.js
'
)
require
(
'
./AudioEncoderFuncPromiseTest.test.js
'
)
require
(
'
./AudioEncoderReliabilityCallbackTest.test.js
'
)
...
...
multimedia/media/media_js_standard/audioRecorder/src/main/js/test/AudioRecorderEnumTest.test.js
浏览文件 @
48123541
...
...
@@ -66,4 +66,19 @@ describe('AudioRecorderEnumTest', function () {
expect
(
media
.
AudioEncoder
.
HE_AAC
).
assertEqual
(
4
);
done
();
})
/* *
* @tc.number : SUB_MEDIA_AUDIO_DECODER_ENUM_CodecMimeType_0100
* @tc.name : CodecMimeType
* @tc.desc : Test Enumerate CodecMimeType
* @tc.size : MediumTest
* @tc.type : Function test
* @tc.level : Level0
*/
it
(
'
SUB_MEDIA_AUDIO_DECODER_ENUM_CodecMimeType_0100
'
,
0
,
async
function
(
done
)
{
expect
(
media
.
CodecMimeType
.
AUDIO_AAC
).
assertEqual
(
'
audio/mp4a-latm
'
);
expect
(
media
.
CodecMimeType
.
AUDIO_VORBIS
).
assertEqual
(
'
audio/vorbis
'
);
expect
(
media
.
CodecMimeType
.
AUDIO_FLAC
).
assertEqual
(
'
audio/flac
'
);
done
();
})
})
\ No newline at end of file
multimedia/media/media_js_standard/videoCodecFormat/Test.json
浏览文件 @
48123541
...
...
@@ -18,8 +18,8 @@
"type"
:
"ShellKit"
,
"run-command"
:
[
"rm -rf /storage/media/100/local/files/*"
,
"mkdir -p /data/app/el
1/bundle/public/ohos.acts.multimedia.video.codecformat/ohos.acts.multimedia.video.codecformat/assets/entry/resources/rawfile
/"
,
"chmod 777 -R /data/app/el
1/bundle/public/ohos.acts.multimedia.video.codecformat/ohos.acts.multimedia.video.codecformat/assets/entry/resources/rawfile
/"
"mkdir -p /data/app/el
2/100/base/ohos.acts.multimedia.video.codecformat/haps/entry/files
/"
,
"chmod 777 -R /data/app/el
2/100/base/ohos.acts.multimedia.video.codecformat/haps/entry/files
/"
],
"teardown-command"
:[
]
...
...
@@ -29,24 +29,24 @@
"pre-push"
:
[
],
"push"
:
[
"./resource/media/es/H264_BP_720_480_10_3000000.h264 ->/data/app/el
1/bundle/public/ohos.acts.multimedia.video.codecformat/ohos.acts.multimedia.video.codecformat/assets/entry/resources/rawfile
/"
,
"./resource/media/es/H264_BP_720_480_30_768000.h264 ->/data/app/el
1/bundle/public/ohos.acts.multimedia.video.codecformat/ohos.acts.multimedia.video.codecformat/assets/entry/resources/rawfile
/"
,
"./resource/media/es/H264_BP_720_480_30_2000000.h264 ->/data/app/el
1/bundle/public/ohos.acts.multimedia.video.codecformat/ohos.acts.multimedia.video.codecformat/assets/entry/resources/rawfile
/"
,
"./resource/media/es/H264_HP_352_288_30_3000000.h264 ->/data/app/el
1/bundle/public/ohos.acts.multimedia.video.codecformat/ohos.acts.multimedia.video.codecformat/assets/entry/resources/rawfile
/"
,
"./resource/media/es/H264_HP_640_480_30_3000000.h264 ->/data/app/el
1/bundle/public/ohos.acts.multimedia.video.codecformat/ohos.acts.multimedia.video.codecformat/assets/entry/resources/rawfile
/"
,
"./resource/media/es/H264_HP_720_480_25_3000000.h264 ->/data/app/el
1/bundle/public/ohos.acts.multimedia.video.codecformat/ohos.acts.multimedia.video.codecformat/assets/entry/resources/rawfile
/"
,
"./resource/media/es/H264_HP_720_480_30_3000000.h264 ->/data/app/el
1/bundle/public/ohos.acts.multimedia.video.codecformat/ohos.acts.multimedia.video.codecformat/assets/entry/resources/rawfile
/"
,
"./resource/media/es/H264_MP_720_480_30_64000.h264 ->/data/app/el
1/bundle/public/ohos.acts.multimedia.video.codecformat/ohos.acts.multimedia.video.codecformat/assets/entry/resources/rawfile
/"
,
"./resource/media/es/H264_MP_720_480_30_128000.h264 ->/data/app/el
1/bundle/public/ohos.acts.multimedia.video.codecformat/ohos.acts.multimedia.video.codecformat/assets/entry/resources/rawfile
/"
,
"./resource/media/es/H264_MP_720_480_30_192000.h264 ->/data/app/el
1/bundle/public/ohos.acts.multimedia.video.codecformat/ohos.acts.multimedia.video.codecformat/assets/entry/resources/rawfile
/"
,
"./resource/media/es/H264_MP_720_480_30_384000.h264 ->/data/app/el
1/bundle/public/ohos.acts.multimedia.video.codecformat/ohos.acts.multimedia.video.codecformat/assets/entry/resources/rawfile
/"
"./resource/media/es/H264_BP_720_480_10_3000000.h264 ->/data/app/el
2/100/base/ohos.acts.multimedia.video.codecformat/haps/entry/files
/"
,
"./resource/media/es/H264_BP_720_480_30_768000.h264 ->/data/app/el
2/100/base/ohos.acts.multimedia.video.codecformat/haps/entry/files
/"
,
"./resource/media/es/H264_BP_720_480_30_2000000.h264 ->/data/app/el
2/100/base/ohos.acts.multimedia.video.codecformat/haps/entry/files
/"
,
"./resource/media/es/H264_HP_352_288_30_3000000.h264 ->/data/app/el
2/100/base/ohos.acts.multimedia.video.codecformat/haps/entry/files
/"
,
"./resource/media/es/H264_HP_640_480_30_3000000.h264 ->/data/app/el
2/100/base/ohos.acts.multimedia.video.codecformat/haps/entry/files
/"
,
"./resource/media/es/H264_HP_720_480_25_3000000.h264 ->/data/app/el
2/100/base/ohos.acts.multimedia.video.codecformat/haps/entry/files
/"
,
"./resource/media/es/H264_HP_720_480_30_3000000.h264 ->/data/app/el
2/100/base/ohos.acts.multimedia.video.codecformat/haps/entry/files
/"
,
"./resource/media/es/H264_MP_720_480_30_64000.h264 ->/data/app/el
2/100/base/ohos.acts.multimedia.video.codecformat/haps/entry/files
/"
,
"./resource/media/es/H264_MP_720_480_30_128000.h264 ->/data/app/el
2/100/base/ohos.acts.multimedia.video.codecformat/haps/entry/files
/"
,
"./resource/media/es/H264_MP_720_480_30_192000.h264 ->/data/app/el
2/100/base/ohos.acts.multimedia.video.codecformat/haps/entry/files
/"
,
"./resource/media/es/H264_MP_720_480_30_384000.h264 ->/data/app/el
2/100/base/ohos.acts.multimedia.video.codecformat/haps/entry/files
/"
]
},
{
"type"
:
"ShellKit"
,
"run-command"
:
[
"chmod 777 -R /data/app/el
1/bundle/public/ohos.acts.multimedia.video.codecformat/ohos.acts.multimedia.video.codecformat/assets/entry/resources/rawfile
/"
,
"chmod 777 /data/app/el
1/bundle/public/ohos.acts.multimedia.video.codecformat/ohos.acts.multimedia.video.codecformat/assets/entry/resources/rawfile
/*"
"chmod 777 -R /data/app/el
2/100/base/ohos.acts.multimedia.video.codecformat/haps/entry/files
/"
,
"chmod 777 /data/app/el
2/100/base/ohos.acts.multimedia.video.codecformat/haps/entry/files
/*"
],
"teardown-command"
:[
]
...
...
multimedia/media/media_js_standard/videoCodecFormat/src/main/js/test/VideoDecoderFormatPromiseTest.test.js
浏览文件 @
48123541
...
...
@@ -16,7 +16,7 @@
import
media
from
'
@ohos.multimedia.media
'
import
fileio
from
'
@ohos.fileio
'
import
router
from
'
@system.router
'
import
{
getFileDescriptor
,
closeFileDescriptor
}
from
'
./VideoFormatTestBase.test.js
'
import
*
as
mediaTestBase
from
'
../../../../../MediaTestBase.js
'
;
import
{
describe
,
beforeAll
,
beforeEach
,
afterEach
,
afterAll
,
it
,
expect
}
from
'
deccjsunit/index
'
...
...
@@ -261,7 +261,6 @@ describe('VideoDecoderFormatPromise', function () {
},
failCallback
).
catch
(
failCatch
);
videoDecodeProcessor
=
null
;
}
await
closeFileDescriptor
(
readPath
);
await
router
.
clear
();
})
...
...
@@ -294,16 +293,9 @@ describe('VideoDecoderFormatPromise', function () {
}
}
async
function
getFdRead
(
pathName
,
done
)
{
await
getFileDescriptor
(
pathName
).
then
((
res
)
=>
{
if
(
res
==
undefined
)
{
expect
().
assertFail
();
console
.
info
(
'
case error fileDescriptor undefined, open file fail
'
);
done
();
}
else
{
fdRead
=
res
.
fd
;
console
.
info
(
"
case fdRead is:
"
+
fdRead
);
}
async
function
getFdRead
(
readPath
,
done
)
{
await
mediaTestBase
.
getFdRead
(
readPath
,
done
).
then
((
fdNumber
)
=>
{
fdRead
=
fdNumber
;
})
}
...
...
multimedia/media/media_js_standard/videoCodecFormat/src/main/js/test/VideoEncoderFormatPromiseTest.test.js
浏览文件 @
48123541
...
...
@@ -16,8 +16,6 @@
import
media
from
'
@ohos.multimedia.media
'
import
mediademo
from
'
@ohos.multimedia.mediademo
'
import
fileio
from
'
@ohos.fileio
'
import
abilityAccessCtrl
from
'
@ohos.abilityAccessCtrl
'
import
bundle
from
'
@ohos.bundle
'
import
featureAbility
from
'
@ohos.ability.featureAbility
'
import
mediaLibrary
from
'
@ohos.multimedia.mediaLibrary
'
import
{
describe
,
beforeAll
,
beforeEach
,
afterEach
,
afterAll
,
it
,
expect
}
from
'
deccjsunit/index
'
...
...
@@ -42,7 +40,12 @@ describe('VideoEncoderFormatPromise', function () {
beforeAll
(
async
function
()
{
console
.
info
(
'
beforeAll case 1
'
);
await
applyPermission
();
let
permissionName1
=
'
ohos.permission.MEDIA_LOCATION
'
;
let
permissionName2
=
'
ohos.permission.READ_MEDIA
'
;
let
permissionName3
=
'
ohos.permission.WRITE_MEDIA
'
;
permissionNameList
=
[
permissionName1
,
permissionName2
,
permissionName3
];
let
appName
=
'
ohos.acts.multimedia.video.codecformat
'
;
await
mediaTestBase
.
applyPermission
(
appName
,
permissionNameList
);
console
.
info
(
'
beforeAll case after get permission
'
);
})
...
...
@@ -97,35 +100,6 @@ describe('VideoEncoderFormatPromise', function () {
needGetMediaDes
=
false
;
}
async
function
applyPermission
()
{
let
appInfo
=
await
bundle
.
getApplicationInfo
(
'
ohos.acts.multimedia.video.codecformat
'
,
0
,
100
);
let
atManager
=
abilityAccessCtrl
.
createAtManager
();
if
(
atManager
!=
null
)
{
let
tokenID
=
appInfo
.
accessTokenId
;
console
.
info
(
'
[permission] case accessTokenID is
'
+
tokenID
);
let
permissionName1
=
'
ohos.permission.MEDIA_LOCATION
'
;
let
permissionName2
=
'
ohos.permission.READ_MEDIA
'
;
let
permissionName3
=
'
ohos.permission.WRITE_MEDIA
'
;
await
atManager
.
grantUserGrantedPermission
(
tokenID
,
permissionName1
,
1
).
then
((
result
)
=>
{
console
.
info
(
'
[permission] case grantUserGrantedPermission success :
'
+
result
);
}).
catch
((
err
)
=>
{
console
.
info
(
'
[permission] case grantUserGrantedPermission failed :
'
+
err
);
});
await
atManager
.
grantUserGrantedPermission
(
tokenID
,
permissionName2
,
1
).
then
((
result
)
=>
{
console
.
info
(
'
[permission] case grantUserGrantedPermission success :
'
+
result
);
}).
catch
((
err
)
=>
{
console
.
info
(
'
[permission] case grantUserGrantedPermission failed :
'
+
err
);
});
await
atManager
.
grantUserGrantedPermission
(
tokenID
,
permissionName3
,
1
).
then
((
result
)
=>
{
console
.
info
(
'
[permission] case grantUserGrantedPermission success :
'
+
result
);
}).
catch
((
err
)
=>
{
console
.
info
(
'
[permission] case grantUserGrantedPermission failed :
'
+
err
);
});
}
else
{
console
.
info
(
'
[permission] case apply permission failed, createAtManager failed
'
);
}
}
async
function
getFdWrite
(
pathName
)
{
console
.
info
(
'
[mediaLibrary] case start getFdWrite
'
);
console
.
info
(
'
[mediaLibrary] case getFdWrite pathName is
'
+
pathName
);
...
...
multimedia/media/media_js_standard/videoCodecFormat/src/main/js/test/VideoFormatTestBase.test.js
已删除
100644 → 0
浏览文件 @
0cfa1c82
/*
* 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
resourceManager
from
'
@ohos.resourceManager
'
;
export
async
function
getFileDescriptor
(
fileName
)
{
let
fileDescriptor
;
await
resourceManager
.
getResourceManager
().
then
(
async
(
mgr
)
=>
{
await
mgr
.
getRawFileDescriptor
(
fileName
).
then
(
value
=>
{
fileDescriptor
=
{
fd
:
value
.
fd
,
offset
:
value
.
offset
,
length
:
value
.
length
};
}).
catch
(
error
=>
{
console
.
log
(
'
case getRawFileDescriptor err:
'
+
error
);
});
});
return
fileDescriptor
;
}
export
async
function
closeFileDescriptor
(
fileName
)
{
await
resourceManager
.
getResourceManager
().
then
(
async
(
mgr
)
=>
{
await
mgr
.
closeRawFileDescriptor
(
fileName
).
then
(
value
=>
{
console
.
log
(
'
case closeRawFileDescriptor success for fileName:
'
+
fileName
);
}).
catch
(
error
=>
{
console
.
log
(
'
case closeRawFileDescriptor err:
'
+
error
);
});
});
}
multimedia/media/media_js_standard/videoDecoder/Test.json
浏览文件 @
48123541
...
...
@@ -18,8 +18,8 @@
"type"
:
"ShellKit"
,
"run-command"
:
[
"rm -rf /storage/media/100/local/files/*"
,
"mkdir -p /data/app/el
1/bundle/public/ohos.acts.multimedia.video.videodecoder/ohos.acts.multimedia.video.videodecoder/assets/entry/resources/rawfile
/"
,
"chmod 777 -R /data/app/el
1/bundle/public/ohos.acts.multimedia.video.videodecoder/ohos.acts.multimedia.video.videodecoder/assets/entry/resources/rawfile
/"
"mkdir -p /data/app/el
2/100/base/ohos.acts.multimedia.video.videodecoder/haps/entry/files
/"
,
"chmod 777 -R /data/app/el
2/100/base/ohos.acts.multimedia.video.videodecoder/haps/entry/files
/"
],
"teardown-command"
:[
]
...
...
@@ -29,18 +29,18 @@
"pre-push"
:
[
],
"push"
:
[
"./resource/media/es/out_1920_1080_30fps_3s.h264 ->/data/app/el
1/bundle/public/ohos.acts.multimedia.video.videodecoder/ohos.acts.multimedia.video.videodecoder/assets/entry/resources/rawfile
/"
,
"./resource/media/es/h263_1408_1152.es ->/data/app/el
1/bundle/public/ohos.acts.multimedia.video.videodecoder/ohos.acts.multimedia.video.videodecoder/assets/entry/resources/rawfile
/"
,
"./resource/media/es/MPEG2_720_480.es ->/data/app/el
1/bundle/public/ohos.acts.multimedia.video.videodecoder/ohos.acts.multimedia.video.videodecoder/assets/entry/resources/rawfile
/"
,
"./resource/media/es/mpeg4_320_240.es ->/data/app/el
1/bundle/public/ohos.acts.multimedia.video.videodecoder/ohos.acts.multimedia.video.videodecoder/assets/entry/resources/rawfile
/"
,
"./resource/media/es/out_320_240_10s.h264 ->/data/app/el
1/bundle/public/ohos.acts.multimedia.video.videodecoder/ohos.acts.multimedia.video.videodecoder/assets/entry/resources/rawfile
/"
"./resource/media/es/out_1920_1080_30fps_3s.h264 ->/data/app/el
2/100/base/ohos.acts.multimedia.video.videodecoder/haps/entry/files
/"
,
"./resource/media/es/h263_1408_1152.es ->/data/app/el
2/100/base/ohos.acts.multimedia.video.videodecoder/haps/entry/files
/"
,
"./resource/media/es/MPEG2_720_480.es ->/data/app/el
2/100/base/ohos.acts.multimedia.video.videodecoder/haps/entry/files
/"
,
"./resource/media/es/mpeg4_320_240.es ->/data/app/el
2/100/base/ohos.acts.multimedia.video.videodecoder/haps/entry/files
/"
,
"./resource/media/es/out_320_240_10s.h264 ->/data/app/el
2/100/base/ohos.acts.multimedia.video.videodecoder/haps/entry/files
/"
]
},
{
"type"
:
"ShellKit"
,
"run-command"
:
[
"chmod 777 -R /data/app/el
1/bundle/public/ohos.acts.multimedia.video.videodecoder/ohos.acts.multimedia.video.videodecoder/assets/entry/resources/rawfile
/"
,
"chmod 777 /data/app/el
1/bundle/public/ohos.acts.multimedia.video.videodecoder/ohos.acts.multimedia.video.videodecoder/assets/entry/resources/rawfile
/*"
"chmod 777 -R /data/app/el
2/100/base/ohos.acts.multimedia.video.videodecoder/haps/entry/files
/"
,
"chmod 777 /data/app/el
2/100/base/ohos.acts.multimedia.video.videodecoder/haps/entry/files
/*"
],
"teardown-command"
:[
]
...
...
multimedia/media/media_js_standard/videoDecoder/src/main/js/test/List.test.js
浏览文件 @
48123541
...
...
@@ -21,5 +21,4 @@ require('./VideoDecoderSoftwareFuncCallbackTest.test.js')
require
(
'
./VideoDecoderSoftwareFuncPromiseTest.test.js
'
)
require
(
'
./VideoDecoderSoftwareReliCallbackTest.test.js
'
)
require
(
'
./VideoDecoderSoftwareReliPromiseTest.test.js
'
)
require
(
'
./VideoDecoderEnumTest.test.js
'
)
require
(
'
./VideoDecoderTestBase.test.js
'
)
require
(
'
./VideoDecoderEnumTest.test.js
'
)
\ No newline at end of file
multimedia/media/media_js_standard/videoDecoder/src/main/js/test/VideoDecoderEnumTest.test.js
浏览文件 @
48123541
...
...
@@ -16,7 +16,7 @@
import
media
from
'
@ohos.multimedia.media
'
import
fileio
from
'
@ohos.fileio
'
import
router
from
'
@system.router
'
import
{
getFileDescriptor
,
closeFileDescriptor
}
from
'
./VideoDecoderTestBase.test.js
'
import
*
as
mediaTestBase
from
'
../../../../../MediaTestBase.js
'
;
import
{
describe
,
beforeAll
,
beforeEach
,
afterEach
,
afterAll
,
it
,
expect
}
from
'
deccjsunit/index
'
...
...
@@ -34,7 +34,6 @@ describe('VideoDecoderEnum', function () {
let
surfaceID
=
''
;
const
events
=
require
(
'
events
'
);
const
eventEmitter
=
new
events
.
EventEmitter
();
const
BASIC_PATH
=
'
/data/accounts/account_0/appdata/ohos.acts.multimedia.video.videodecoder/
'
;
let
ES_FRAME_SIZE
=
[];
const
H264_FRAME_SIZE_60FPS_320
=
[
2106
,
11465
];
...
...
@@ -43,7 +42,6 @@ describe('VideoDecoderEnum', function () {
beforeAll
(
function
()
{
console
.
info
(
'
beforeAll case
'
);
// getSurfaceID();
})
beforeEach
(
async
function
()
{
...
...
@@ -289,7 +287,6 @@ describe('VideoDecoderEnum', function () {
},
failCallback
).
catch
(
failCatch
);
videoDecodeProcessor
=
null
;
console
.
info
(
'
in case : done
'
);
await
closeFileDescriptor
(
readpath
);
done
();
});
async
function
toPrepare
()
{
...
...
@@ -316,15 +313,8 @@ describe('VideoDecoderEnum', function () {
isCodecData
=
true
;
let
srcPath
=
'
out_320_240_10s.h264
'
;
readpath
=
srcPath
;
await
getFileDescriptor
(
readpath
).
then
((
res
)
=>
{
if
(
res
==
undefined
)
{
expect
().
assertFail
();
console
.
info
(
'
case error fileDescriptor undefined, open file fail
'
);
done
();
}
else
{
fdRead
=
res
.
fd
;
console
.
info
(
"
case fdRead is:
"
+
fdRead
);
}
await
mediaTestBase
.
getFdRead
(
readpath
,
done
).
then
((
fdNumber
)
=>
{
fdRead
=
fdNumber
;
})
let
mediaDescription
=
{
'
track_type
'
:
1
,
...
...
@@ -345,22 +335,5 @@ describe('VideoDecoderEnum', function () {
await
toPrepare
();
await
toStart
();
})
/* *
* @tc.number : SUB_MEDIA_VIDEO_DECODER_ENUM_CodecMimeType_0100
* @tc.name : 002.CodecMimeType
* @tc.desc : Test Enumerate CodecMimeType
* @tc.size : MediumTest
* @tc.type : Function test
* @tc.level : Level0
*/
it
(
'
SUB_MEDIA_VIDEO_DECODER_ENUM_CodecMimeType_0100
'
,
0
,
async
function
(
done
)
{
expect
(
media
.
CodecMimeType
.
VIDEO_H263
).
assertEqual
(
'
video/h263
'
);
expect
(
media
.
CodecMimeType
.
VIDEO_AVC
).
assertEqual
(
'
video/avc
'
);
expect
(
media
.
CodecMimeType
.
VIDEO_MPEG2
).
assertEqual
(
'
video/mpeg2
'
);
expect
(
media
.
CodecMimeType
.
VIDEO_MPEG4
).
assertEqual
(
'
video/mp4v-es
'
);
expect
(
media
.
CodecMimeType
.
VIDEO_VP8
).
assertEqual
(
'
video/x-vnd.on2.vp8
'
);
done
();
})
})
multimedia/media/media_js_standard/videoDecoder/src/main/js/test/VideoDecoderFuncCallbackTest.test.js
浏览文件 @
48123541
...
...
@@ -16,10 +16,10 @@
import
media
from
'
@ohos.multimedia.media
'
import
fileio
from
'
@ohos.fileio
'
import
router
from
'
@system.router
'
import
{
getFileDescriptor
,
closeFileDescriptor
}
from
'
./VideoDecoderTestBase.test.js
'
import
*
as
mediaTestBase
from
'
../../../../../MediaTestBase.js
'
;
import
{
describe
,
beforeAll
,
beforeEach
,
afterEach
,
afterAll
,
it
,
expect
}
from
'
deccjsunit/index
'
describe
(
'
VideoDecoderFuncCallbackTest
_video1
'
,
function
()
{
describe
(
'
VideoDecoderFuncCallbackTest
'
,
function
()
{
let
videoDecodeProcessor
=
null
;
let
readStreamSync
=
undefined
;
let
frameCountIn
=
0
;
...
...
@@ -157,16 +157,9 @@ describe('VideoDecoderFuncCallbackTest_video1', function () {
}
}
async
function
getFdRead
(
pathName
,
done
)
{
await
getFileDescriptor
(
pathName
).
then
((
res
)
=>
{
if
(
res
==
undefined
)
{
expect
().
assertFail
();
console
.
info
(
'
case error fileDescriptor undefined, open file fail
'
);
done
();
}
else
{
fdRead
=
res
.
fd
;
console
.
info
(
"
case fdRead is:
"
+
fdRead
);
}
async
function
getFdRead
(
readPath
,
done
)
{
await
mediaTestBase
.
getFdRead
(
readPath
,
done
).
then
((
fdNumber
)
=>
{
fdRead
=
fdNumber
;
})
}
...
...
@@ -345,7 +338,6 @@ describe('VideoDecoderFuncCallbackTest_video1', function () {
expect
(
err
).
assertUndefined
();
console
.
info
(
'
in case : release success
'
);
videoDecodeProcessor
=
null
;
await
closeFileDescriptor
(
readpath
);
done
();
});
});
...
...
multimedia/media/media_js_standard/videoDecoder/src/main/js/test/VideoDecoderFuncPromiseTest.test.js
浏览文件 @
48123541
...
...
@@ -16,11 +16,11 @@
import
media
from
'
@ohos.multimedia.media
'
import
fileio
from
'
@ohos.fileio
'
import
router
from
'
@system.router
'
import
{
getFileDescriptor
,
closeFileDescriptor
}
from
'
./VideoDecoderTestBase.test.js
'
import
*
as
mediaTestBase
from
'
../../../../../MediaTestBase.js
'
;
import
{
describe
,
beforeAll
,
beforeEach
,
afterEach
,
afterAll
,
it
,
expect
}
from
'
deccjsunit/index
'
describe
(
'
VideoDecoderFuncPromiseTest
_video1
'
,
function
()
{
describe
(
'
VideoDecoderFuncPromiseTest
'
,
function
()
{
let
videoDecodeProcessor
=
null
;
let
readStreamSync
=
undefined
;
let
frameCountIn
=
0
;
...
...
@@ -33,7 +33,6 @@ describe('VideoDecoderFuncPromiseTest_video1', function () {
let
surfaceID
=
''
;
const
events
=
require
(
'
events
'
);
const
eventEmitter
=
new
events
.
EventEmitter
();
const
BASIC_PATH
=
'
/data/accounts/account_0/appdata/ohos.acts.multimedia.video.videodecoder/
'
;
let
ES_FRAME_SIZE
=
[];
const
H264_FRAME_SIZE_60FPS_320
=
[
2106
,
11465
,
321
,
72
,
472
,
68
,
76
,
79
,
509
,
90
,
677
,
88
,
956
,
99
,
347
,
77
,
452
,
681
,
81
,
1263
,
94
,
106
,
97
,
...
...
@@ -98,7 +97,6 @@ describe('VideoDecoderFuncPromiseTest_video1', function () {
beforeAll
(
function
()
{
console
.
info
(
'
beforeAll case
'
);
// getSurfaceID();
})
beforeEach
(
async
function
()
{
...
...
@@ -156,16 +154,9 @@ describe('VideoDecoderFuncPromiseTest_video1', function () {
}
}
async
function
getFdRead
(
pathName
,
done
)
{
await
getFileDescriptor
(
pathName
).
then
((
res
)
=>
{
if
(
res
==
undefined
)
{
expect
().
assertFail
();
console
.
info
(
'
case error fileDescriptor undefined, open file fail
'
);
done
();
}
else
{
fdRead
=
res
.
fd
;
console
.
info
(
"
case fdRead is:
"
+
fdRead
);
}
async
function
getFdRead
(
readPath
,
done
)
{
await
mediaTestBase
.
getFdRead
(
readPath
,
done
).
then
((
fdNumber
)
=>
{
fdRead
=
fdNumber
;
})
}
...
...
@@ -317,7 +308,6 @@ describe('VideoDecoderFuncPromiseTest_video1', function () {
console
.
info
(
'
in case : release success
'
);
},
failCallback
).
catch
(
failCatch
);
videoDecodeProcessor
=
null
;
await
closeFileDescriptor
(
readpath
);
console
.
info
(
'
in case : done
'
);
done
();
});
...
...
@@ -466,7 +456,6 @@ describe('VideoDecoderFuncPromiseTest_video1', function () {
console
.
info
(
'
in case : release success
'
);
},
failCallback
).
catch
(
failCatch
);
videoDecodeProcessor
=
null
;
await
closeFileDescriptor
(
readpath
);
done
();
})
for
(
let
i
=
0
;
i
<
3
;
i
++
)
{
...
...
multimedia/media/media_js_standard/videoDecoder/src/main/js/test/VideoDecoderReliCallbackTest.test.js
浏览文件 @
48123541
...
...
@@ -16,7 +16,7 @@
import
media
from
'
@ohos.multimedia.media
'
import
fileio
from
'
@ohos.fileio
'
import
router
from
'
@system.router
'
import
{
getFileDescriptor
,
closeFileDescriptor
}
from
'
./VideoDecoderTestBase.test.js
'
import
*
as
mediaTestBase
from
'
../../../../../MediaTestBase.js
'
;
import
{
describe
,
beforeAll
,
beforeEach
,
afterEach
,
afterAll
,
it
,
expect
}
from
'
deccjsunit/index
'
const
DECODE_STEP
=
{
...
...
@@ -47,7 +47,6 @@ describe('VideoDecoderReliCallbackTest', function () {
let
inputEosFlag
=
false
;
let
workdoneAtEOS
=
false
;
let
surfaceID
=
''
;
const
BASIC_PATH
=
'
/data/accounts/account_0/appdata/ohos.acts.multimedia.video.videodecoder/
'
;
const
SRCPATH
=
'
out_320_240_10s.h264
'
;
let
mediaDescription
=
{
'
track_type
'
:
1
,
...
...
@@ -110,12 +109,10 @@ describe('VideoDecoderReliCallbackTest', function () {
}
await
router
.
clear
().
then
(()
=>
{
},
failCallback
).
catch
(
failCatch
);
await
closeFileDescriptor
(
SRCPATH
);
})
afterAll
(
async
function
()
{
console
.
info
(
'
afterAll case
'
);
await
closeFileDescriptor
(
SRCPATH
);
})
let
failCallback
=
function
(
err
)
{
console
.
info
(
`in case error failCallback called, errMessage is
${
err
.
message
}
`
);
...
...
@@ -289,7 +286,6 @@ describe('VideoDecoderReliCallbackTest', function () {
printError
(
err
,
false
);
console
.
info
(
'
in case : videoDecodeProcessor release callback
'
);
videoDecodeProcessor
=
null
;
await
closeFileDescriptor
(
SRCPATH
);
console
.
info
(
'
case to done
'
);
done
();
});
...
...
@@ -416,17 +412,10 @@ describe('VideoDecoderReliCallbackTest', function () {
}
async
function
toCreateVideoDecoderByMime
(
mime
,
mySteps
,
done
)
{
await
getFileDescriptor
(
SRCPATH
).
then
((
res
)
=>
{
if
(
res
==
undefined
)
{
expect
().
assertFail
();
console
.
info
(
'
case error fileDescriptor undefined, open file fail
'
);
done
();
}
else
{
fdRead
=
res
.
fd
;
console
.
info
(
"
case fdRead is:
"
+
fdRead
);
}
await
mediaTestBase
.
getFdRead
(
SRCPATH
,
done
).
then
((
fdNumber
)
=>
{
fdRead
=
fdNumber
;
})
media
.
createVideoDecoderByMime
(
mime
,
(
err
,
processor
)
=>
{
await
media
.
createVideoDecoderByMime
(
mime
,
(
err
,
processor
)
=>
{
console
.
info
(
`case createVideoDecoderByMime callback`
);
printError
(
err
,
false
);
videoDecodeProcessor
=
processor
;
...
...
multimedia/media/media_js_standard/videoDecoder/src/main/js/test/VideoDecoderReliPromiseTest.test.js
浏览文件 @
48123541
...
...
@@ -16,7 +16,7 @@
import
media
from
'
@ohos.multimedia.media
'
import
fileio
from
'
@ohos.fileio
'
import
router
from
'
@system.router
'
import
{
getFileDescriptor
,
closeFileDescriptor
}
from
'
./VideoDecoderTestBase.test.js
'
import
*
as
mediaTestBase
from
'
../../../../../MediaTestBase.js
'
;
import
{
describe
,
beforeAll
,
beforeEach
,
afterEach
,
afterAll
,
it
,
expect
}
from
'
deccjsunit/index
'
const
DECODE_STEP
=
{
...
...
@@ -47,7 +47,6 @@ describe('VideoDecoderReliPromiseTest', function () {
let
inputEosFlag
=
false
;
let
workdoneAtEOS
=
false
;
let
surfaceID
=
''
;
const
BASIC_PATH
=
'
/data/accounts/account_0/appdata/ohos.acts.multimedia.video.videodecoder/
'
;
const
SRCPATH
=
'
out_320_240_10s.h264
'
;
let
mediaDescription
=
{
'
track_type
'
:
1
,
...
...
@@ -110,12 +109,10 @@ describe('VideoDecoderReliPromiseTest', function () {
}
await
router
.
clear
().
then
(()
=>
{
},
failCallback
).
catch
(
failCatch
);
await
closeFileDescriptor
(
SRCPATH
);
})
afterAll
(
async
function
()
{
console
.
info
(
'
afterAll case
'
);
await
closeFileDescriptor
(
SRCPATH
);
})
let
caseCallback
=
function
(
err
)
{
console
.
info
(
`in case caseCallback called, caseMessage is
${
err
.
message
}
`
);
...
...
@@ -286,7 +283,6 @@ describe('VideoDecoderReliPromiseTest', function () {
videoDecodeProcessor
.
release
().
then
(
async
()
=>
{
console
.
info
(
'
in case : videoDecodeProcessor release success
'
);
videoDecodeProcessor
=
null
;
await
closeFileDescriptor
(
SRCPATH
);
console
.
info
(
'
case to done
'
);
done
();
},
failCallback
).
catch
(
failCatch
);
...
...
@@ -375,11 +371,14 @@ describe('VideoDecoderReliPromiseTest', function () {
break
;
case
DECODE_STEP
.
WAIT_FOR_EOS
:
mySteps
.
shift
();
setTimeout
(()
=>
{
setTimeout
(
async
()
=>
{
expect
(
inputEosFlag
).
assertTrue
();
if
(
inputEosFlag
==
false
)
{
console
.
info
(
`in case error inputEosFlag == false`
);
}
await
mediaTestBase
.
getFdRead
(
SRCPATH
,
done
).
then
((
fdNumber
)
=>
{
fdRead
=
fdNumber
;
})
toNextStep
(
mySteps
,
done
);
},
7000
);
// wait 7000 ms for eos
break
;
...
...
@@ -413,17 +412,10 @@ describe('VideoDecoderReliPromiseTest', function () {
}
async
function
toCreateVideoDecoderByMime
(
mime
,
mySteps
,
done
)
{
await
getFileDescriptor
(
SRCPATH
).
then
((
res
)
=>
{
if
(
res
==
undefined
)
{
expect
().
assertFail
();
console
.
info
(
'
case error fileDescriptor undefined, open file fail
'
);
done
();
}
else
{
fdRead
=
res
.
fd
;
console
.
info
(
"
case fdRead is:
"
+
fdRead
);
}
await
mediaTestBase
.
getFdRead
(
SRCPATH
,
done
).
then
((
fdNumber
)
=>
{
fdRead
=
fdNumber
;
})
media
.
createVideoDecoderByMime
(
mime
).
then
((
processor
)
=>
{
await
media
.
createVideoDecoderByMime
(
mime
).
then
((
processor
)
=>
{
console
.
info
(
`case createVideoDecoderByMime success`
);
videoDecodeProcessor
=
processor
;
setCallback
(
done
);
...
...
multimedia/media/media_js_standard/videoDecoder/src/main/js/test/VideoDecoderSoftwareFuncCallbackTest.test.js
浏览文件 @
48123541
...
...
@@ -16,7 +16,7 @@
import
media
from
'
@ohos.multimedia.media
'
import
fileio
from
'
@ohos.fileio
'
import
router
from
'
@system.router
'
import
{
getFileDescriptor
,
closeFileDescriptor
}
from
'
./VideoDecoderTestBase.test.js
'
import
*
as
mediaTestBase
from
'
../../../../../MediaTestBase.js
'
;
import
{
describe
,
beforeAll
,
beforeEach
,
afterEach
,
afterAll
,
it
,
expect
}
from
'
deccjsunit/index
'
describe
(
'
VideoDecoderFuncCallbackTest
'
,
function
()
{
...
...
@@ -32,7 +32,6 @@ describe('VideoDecoderFuncCallbackTest', function () {
let
surfaceID
=
''
;
const
events
=
require
(
'
events
'
);
const
eventEmitter
=
new
events
.
EventEmitter
();
const
BASIC_PATH
=
'
/data/accounts/account_0/appdata/ohos.acts.multimedia.video.videodecoder/
'
;
let
ES_FRAME_SIZE
=
[];
const
H264_FRAME_SIZE_240
=
[
2106
,
11465
,
321
,
72
,
472
,
68
,
76
,
79
,
509
,
90
,
677
,
88
,
956
,
99
,
347
,
77
,
452
,
681
,
81
,
1263
,
94
,
106
,
97
,
...
...
@@ -141,7 +140,6 @@ describe('VideoDecoderFuncCallbackTest', function () {
}
await
router
.
clear
().
then
(()
=>
{
},
failCallback
).
catch
(
failCatch
);
await
closeFileDescriptor
(
readpath
);
})
afterAll
(
function
()
{
...
...
@@ -171,16 +169,9 @@ describe('VideoDecoderFuncCallbackTest', function () {
}
}
async
function
getFdRead
(
pathName
,
done
)
{
await
getFileDescriptor
(
pathName
).
then
((
res
)
=>
{
if
(
res
==
undefined
)
{
expect
().
assertFail
();
console
.
info
(
'
case error fileDescriptor undefined, open file fail
'
);
done
();
}
else
{
fdRead
=
res
.
fd
;
console
.
info
(
"
case fdRead is:
"
+
fdRead
);
}
async
function
getFdRead
(
readPath
,
done
)
{
await
mediaTestBase
.
getFdRead
(
readPath
,
done
).
then
((
fdNumber
)
=>
{
fdRead
=
fdNumber
;
})
}
...
...
@@ -320,7 +311,6 @@ describe('VideoDecoderFuncCallbackTest', function () {
expect
(
err
).
assertUndefined
();
console
.
info
(
'
in case : release success
'
);
videoDecodeProcessor
=
null
;
await
closeFileDescriptor
(
readpath
);
done
();
});
});
...
...
@@ -467,7 +457,6 @@ describe('VideoDecoderFuncCallbackTest', function () {
isCodecData
=
true
;
inputEosFlag
=
false
;
readStreamSync
=
null
;
await
closeFileDescriptor
(
readpath
);
await
getFdRead
(
readpath
,
done
);
await
toDisplayPage
().
then
(()
=>
{
},
failCallback
).
catch
(
failCatch
);
...
...
@@ -518,7 +507,6 @@ describe('VideoDecoderFuncCallbackTest', function () {
videoDecodeProcessor
.
stop
(
async
(
err
)
=>
{
expect
(
err
).
assertUndefined
();
console
.
info
(
'
in case : stop_for_callback_01_0700 success
'
);
await
closeFileDescriptor
(
readpath
);
eventEmitter
.
emit
(
'
reset_for_callback_01_0700
'
,
done
);
});
});
...
...
multimedia/media/media_js_standard/videoDecoder/src/main/js/test/VideoDecoderSoftwareFuncPromiseTest.test.js
浏览文件 @
48123541
...
...
@@ -16,7 +16,7 @@
import
media
from
'
@ohos.multimedia.media
'
import
fileio
from
'
@ohos.fileio
'
import
router
from
'
@system.router
'
import
{
getFileDescriptor
,
closeFileDescriptor
}
from
'
./VideoDecoderTestBase.test.js
'
import
*
as
mediaTestBase
from
'
../../../../../MediaTestBase.js
'
;
import
{
describe
,
beforeAll
,
beforeEach
,
afterEach
,
afterAll
,
it
,
expect
}
from
'
deccjsunit/index
'
...
...
@@ -33,7 +33,6 @@ describe('VideoDecoderFuncPromiseTest', function () {
let
surfaceID
=
''
;
const
events
=
require
(
'
events
'
);
const
eventEmitter
=
new
events
.
EventEmitter
();
const
BASIC_PATH
=
'
/data/accounts/account_0/appdata/ohos.acts.multimedia.video.videodecoder/
'
;
let
ES_FRAME_SIZE
=
[];
const
H264_FRAME_SIZE_240
=
[
2106
,
11465
,
321
,
72
,
472
,
68
,
76
,
79
,
509
,
90
,
677
,
88
,
956
,
99
,
347
,
77
,
452
,
681
,
81
,
1263
,
94
,
106
,
97
,
...
...
@@ -142,7 +141,6 @@ describe('VideoDecoderFuncPromiseTest', function () {
}
await
router
.
clear
().
then
(()
=>
{
},
failCallback
).
catch
(
failCatch
);
await
closeFileDescriptor
(
readpath
);
})
afterAll
(
function
()
{
...
...
@@ -172,19 +170,12 @@ describe('VideoDecoderFuncPromiseTest', function () {
}
}
async
function
getFdRead
(
pathName
,
done
)
{
await
getFileDescriptor
(
pathName
).
then
((
res
)
=>
{
if
(
res
==
undefined
)
{
expect
().
assertFail
();
console
.
info
(
'
case error fileDescriptor undefined, open file fail
'
);
done
();
}
else
{
fdRead
=
res
.
fd
;
console
.
info
(
"
case fdRead is:
"
+
fdRead
);
}
async
function
getFdRead
(
readPath
,
done
)
{
await
mediaTestBase
.
getFdRead
(
readPath
,
done
).
then
((
fdNumber
)
=>
{
fdRead
=
fdNumber
;
})
}
function
readFile
(
path
)
{
console
.
info
(
'
case read file start execution
'
);
try
{
...
...
@@ -311,7 +302,6 @@ describe('VideoDecoderFuncPromiseTest', function () {
console
.
info
(
'
in case : release success
'
);
},
failCallback
).
catch
(
failCatch
);
videoDecodeProcessor
=
null
;
await
closeFileDescriptor
(
readpath
);
console
.
info
(
'
in case : done
'
);
done
();
});
...
...
@@ -465,7 +455,6 @@ describe('VideoDecoderFuncPromiseTest', function () {
isCodecData
=
true
;
inputEosFlag
=
false
;
readStreamSync
=
null
;
await
closeFileDescriptor
(
readpath
);
await
getFdRead
(
readpath
,
done
);
await
toDisplayPage
().
then
(()
=>
{
},
failCallback
).
catch
(
failCatch
);
...
...
@@ -528,7 +517,6 @@ describe('VideoDecoderFuncPromiseTest', function () {
await
videoDecodeProcessor
.
stop
().
then
(()
=>
{
console
.
info
(
'
in case : stop success
'
);
},
failCallback
).
catch
(
failCatch
);
await
closeFileDescriptor
(
readpath
);
await
videoDecodeProcessor
.
reset
().
then
(()
=>
{
console
.
info
(
'
in case : reset success
'
);
},
failCallback
).
catch
(
failCatch
);
...
...
multimedia/media/media_js_standard/videoDecoder/src/main/js/test/VideoDecoderSoftwareReliCallbackTest.test.js
浏览文件 @
48123541
...
...
@@ -16,7 +16,7 @@
import
media
from
'
@ohos.multimedia.media
'
import
fileio
from
'
@ohos.fileio
'
import
router
from
'
@system.router
'
import
{
getFileDescriptor
,
closeFileDescriptor
}
from
'
./VideoDecoderTestBase.test.js
'
import
*
as
mediaTestBase
from
'
../../../../../MediaTestBase.js
'
;
import
{
describe
,
beforeAll
,
beforeEach
,
afterEach
,
afterAll
,
it
,
expect
}
from
'
deccjsunit/index
'
const
DECODE_STEP
=
{
...
...
@@ -47,7 +47,6 @@ describe('VideoDecoderSoftwareReliCallbackTest', function () {
let
inputEosFlag
=
false
;
let
workdoneAtEOS
=
false
;
let
surfaceID
=
''
;
const
BASIC_PATH
=
'
/data/accounts/account_0/appdata/ohos.acts.multimedia.video.videodecoder/
'
;
const
SRCPATH
=
'
out_320_240_10s.h264
'
;
let
mediaDescription
=
{
'
track_type
'
:
1
,
...
...
@@ -110,12 +109,10 @@ describe('VideoDecoderSoftwareReliCallbackTest', function () {
}
await
router
.
clear
().
then
(()
=>
{
},
failCallback
).
catch
(
failCatch
);
await
closeFileDescriptor
(
SRCPATH
);
})
afterAll
(
async
function
()
{
console
.
info
(
'
afterAll case
'
);
await
closeFileDescriptor
(
SRCPATH
);
})
let
failCallback
=
function
(
err
)
{
console
.
info
(
`in case error failCallback called, errMessage is
${
err
.
message
}
`
);
...
...
@@ -425,17 +422,10 @@ describe('VideoDecoderSoftwareReliCallbackTest', function () {
})
}
async
function
toCreateVideoDecoderByName
(
name
,
mySteps
,
done
)
{
await
getFileDescriptor
(
SRCPATH
).
then
((
res
)
=>
{
if
(
res
==
undefined
)
{
expect
().
assertFail
();
console
.
info
(
'
case error fileDescriptor undefined, open file fail
'
);
done
();
}
else
{
fdRead
=
res
.
fd
;
console
.
info
(
"
case fdRead is:
"
+
fdRead
);
}
await
mediaTestBase
.
getFdRead
(
SRCPATH
,
done
).
then
((
fdNumber
)
=>
{
fdRead
=
fdNumber
;
})
media
.
createVideoDecoderByName
(
name
,
(
err
,
processor
)
=>
{
await
media
.
createVideoDecoderByName
(
name
,
(
err
,
processor
)
=>
{
printError
(
err
,
false
);
console
.
info
(
`case createVideoDecoderByName callback`
);
videoDecodeProcessor
=
processor
;
...
...
multimedia/media/media_js_standard/videoDecoder/src/main/js/test/VideoDecoderSoftwareReliPromiseTest.test.js
浏览文件 @
48123541
...
...
@@ -16,7 +16,7 @@
import
media
from
'
@ohos.multimedia.media
'
import
fileio
from
'
@ohos.fileio
'
import
router
from
'
@system.router
'
import
{
getFileDescriptor
,
closeFileDescriptor
}
from
'
./VideoDecoderTestBase.test.js
'
import
*
as
mediaTestBase
from
'
../../../../../MediaTestBase.js
'
;
import
{
describe
,
beforeAll
,
beforeEach
,
afterEach
,
afterAll
,
it
,
expect
}
from
'
deccjsunit/index
'
const
DECODE_STEP
=
{
...
...
@@ -47,7 +47,6 @@ describe('VideoDecoderSoftwareReliPromiseTest', function () {
let
inputEosFlag
=
false
;
let
workdoneAtEOS
=
false
;
let
surfaceID
=
''
;
const
BASIC_PATH
=
'
/data/accounts/account_0/appdata/ohos.acts.multimedia.video.videodecoder/
'
;
const
SRCPATH
=
'
out_320_240_10s.h264
'
;
let
mediaDescription
=
{
'
track_type
'
:
1
,
...
...
@@ -110,12 +109,10 @@ describe('VideoDecoderSoftwareReliPromiseTest', function () {
}
await
router
.
clear
().
then
(()
=>
{
},
failCallback
).
catch
(
failCatch
);
await
closeFileDescriptor
(
SRCPATH
);
})
afterAll
(
async
function
()
{
console
.
info
(
'
afterAll case
'
);
await
closeFileDescriptor
(
SRCPATH
);
})
let
caseCallback
=
function
(
err
)
{
console
.
info
(
`in case caseCallback called, caseMessage is
${
err
.
message
}
`
);
...
...
@@ -376,11 +373,14 @@ describe('VideoDecoderSoftwareReliPromiseTest', function () {
break
;
case
DECODE_STEP
.
WAIT_FOR_EOS
:
mySteps
.
shift
();
setTimeout
(()
=>
{
setTimeout
(
async
()
=>
{
expect
(
inputEosFlag
).
assertTrue
();
if
(
inputEosFlag
==
false
)
{
console
.
info
(
`in case error inputEosFlag == false`
);
}
await
mediaTestBase
.
getFdRead
(
SRCPATH
,
done
).
then
((
fdNumber
)
=>
{
fdRead
=
fdNumber
;
})
toNextStep
(
mySteps
,
done
);
},
7000
);
// wait 7000 ms for eos
break
;
...
...
@@ -422,17 +422,10 @@ describe('VideoDecoderSoftwareReliPromiseTest', function () {
},
failCallback
).
catch
(
failCatch
);
}
async
function
toCreateVideoDecoderByName
(
name
,
mySteps
,
done
)
{
await
getFileDescriptor
(
SRCPATH
).
then
((
res
)
=>
{
if
(
res
==
undefined
)
{
expect
().
assertFail
();
console
.
info
(
'
case error fileDescriptor undefined, open file fail
'
);
done
();
}
else
{
fdRead
=
res
.
fd
;
console
.
info
(
"
case fdRead is:
"
+
fdRead
);
}
await
mediaTestBase
.
getFdRead
(
SRCPATH
,
done
).
then
((
fdNumber
)
=>
{
fdRead
=
fdNumber
;
})
media
.
createVideoDecoderByName
(
name
).
then
((
processor
)
=>
{
await
media
.
createVideoDecoderByName
(
name
).
then
((
processor
)
=>
{
console
.
info
(
`case createVideoDecoderByName success`
);
videoDecodeProcessor
=
processor
;
setCallback
(
done
);
...
...
multimedia/media/media_js_standard/videoDecoder/src/main/js/test/VideoDecoderTestBase.test.js
已删除
100644 → 0
浏览文件 @
0cfa1c82
/*
* 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
resourceManager
from
'
@ohos.resourceManager
'
;
export
async
function
getFileDescriptor
(
fileName
)
{
let
fileDescriptor
;
await
resourceManager
.
getResourceManager
().
then
(
async
(
mgr
)
=>
{
await
mgr
.
getRawFileDescriptor
(
fileName
).
then
(
value
=>
{
fileDescriptor
=
{
fd
:
value
.
fd
,
offset
:
value
.
offset
,
length
:
value
.
length
};
}).
catch
(
error
=>
{
console
.
log
(
'
case getRawFileDescriptor err:
'
+
error
);
});
});
return
fileDescriptor
;
}
export
async
function
closeFileDescriptor
(
fileName
)
{
await
resourceManager
.
getResourceManager
().
then
(
async
(
mgr
)
=>
{
await
mgr
.
closeRawFileDescriptor
(
fileName
).
then
(
value
=>
{
console
.
log
(
'
case closeRawFileDescriptor success for fileName:
'
+
fileName
);
}).
catch
(
error
=>
{
console
.
log
(
'
case closeRawFileDescriptor err:
'
+
error
);
});
});
}
multimedia/media/media_js_standard/videoEncoder/src/main/js/test/VideoEncoderSoftwareFuncCallbackTest.test.js
浏览文件 @
48123541
...
...
@@ -139,7 +139,7 @@ describe('VideoEncoderSoftwareFuncCallbackTest', function () {
console
.
info
(
'
[mediaLibrary] case getFdWrite getFileAssets() success
'
);
fileAsset
=
await
fetchWriteFileResult
.
getAllObject
();
console
.
info
(
'
[mediaLibrary] case getFdWrite getAllObject() success
'
);
fdWrite
=
await
fileAsset
[
0
].
open
(
'
R
w
'
);
fdWrite
=
await
fileAsset
[
0
].
open
(
'
r
w
'
);
console
.
info
(
'
[mediaLibrary] case getFdWrite fdWrite is
'
+
fdWrite
);
}
}
...
...
multimedia/media/media_js_standard/videoEncoder/src/main/js/test/VideoEncoderSoftwareFuncPromiseTest.test.js
浏览文件 @
48123541
...
...
@@ -159,7 +159,7 @@ describe('videoSoftwareEncoderFuncPromise', function () {
console
.
info
(
'
[mediaLibrary] case getFdWrite getFileAssets() success
'
);
fileAsset
=
await
fetchWriteFileResult
.
getAllObject
();
console
.
info
(
'
[mediaLibrary] case getFdWrite getAllObject() success
'
);
fdWrite
=
await
fileAsset
[
0
].
open
(
'
R
w
'
);
fdWrite
=
await
fileAsset
[
0
].
open
(
'
r
w
'
);
console
.
info
(
'
[mediaLibrary] case getFdWrite fdWrite is
'
+
fdWrite
);
}
}
...
...
multimedia/media/media_js_standard/videoRecorder/src/main/js/test/VideoRecorderEnumTest.test.js
浏览文件 @
48123541
...
...
@@ -60,4 +60,21 @@ describe('VideoRecorderEnumTest', function () {
expect
(
media
.
VideoSourceType
.
VIDEO_SOURCE_TYPE_SURFACE_ES
).
assertEqual
(
1
);
done
();
})
/* *
* @tc.number : SUB_MEDIA_VIDEO_DECODER_ENUM_CodecMimeType_0100
* @tc.name : CodecMimeType
* @tc.desc : Test Enumerate CodecMimeType
* @tc.size : MediumTest
* @tc.type : Function test
* @tc.level : Level0
*/
it
(
'
SUB_MEDIA_VIDEO_DECODER_ENUM_CodecMimeType_0100
'
,
0
,
async
function
(
done
)
{
expect
(
media
.
CodecMimeType
.
VIDEO_H263
).
assertEqual
(
'
video/h263
'
);
expect
(
media
.
CodecMimeType
.
VIDEO_AVC
).
assertEqual
(
'
video/avc
'
);
expect
(
media
.
CodecMimeType
.
VIDEO_MPEG2
).
assertEqual
(
'
video/mpeg2
'
);
expect
(
media
.
CodecMimeType
.
VIDEO_MPEG4
).
assertEqual
(
'
video/mp4v-es
'
);
expect
(
media
.
CodecMimeType
.
VIDEO_VP8
).
assertEqual
(
'
video/x-vnd.on2.vp8
'
);
done
();
})
})
\ No newline at end of file
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录