Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
OpenHarmony
Xts Acts
提交
aeb042d9
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看板
体验新版 GitCode,发现更多精彩内容 >>
未验证
提交
aeb042d9
编写于
7月 21, 2022
作者:
O
openharmony_ci
提交者:
Gitee
7月 21, 2022
浏览文件
操作
浏览文件
下载
差异文件
!4350 【媒体子系统】XTS整改
Merge pull request !4350 from liuxueqi/OpenHarmony-3.1-Release
上级
8c48a678
ea6dfb4e
变更
17
隐藏空白更改
内联
并排
Showing
17 changed file
with
105 addition
and
800 deletion
+105
-800
multimedia/audio/audio_js_standard/audioManager/Test.json
multimedia/audio/audio_js_standard/audioManager/Test.json
+6
-3
multimedia/audio/audio_js_standard/audioManager/src/main/js/test/AudioCall.test.js
..._standard/audioManager/src/main/js/test/AudioCall.test.js
+6
-69
multimedia/audio/audio_js_standard/audioManager/src/main/js/test/AudioCapturer.test.js
...ndard/audioManager/src/main/js/test/AudioCapturer.test.js
+3
-324
multimedia/audio/audio_js_standard/audioManager/src/main/js/test/AudioEventManagement.test.js
...udioManager/src/main/js/test/AudioEventManagement.test.js
+2
-12
multimedia/audio/audio_js_standard/audioManager/src/main/js/test/AudioFramework.test.js
...dard/audioManager/src/main/js/test/AudioFramework.test.js
+1
-2
multimedia/audio/audio_js_standard/audioManager/src/main/js/test/AudioRenderer.test.js
...ndard/audioManager/src/main/js/test/AudioRenderer.test.js
+4
-85
multimedia/audio/audio_js_standard/audioManager/src/main/js/test/AudioVOIP.test.js
..._standard/audioManager/src/main/js/test/AudioVOIP.test.js
+4
-67
multimedia/audio/audio_js_standard/audioManager/src/main/js/test/List.test.js
...io_js_standard/audioManager/src/main/js/test/List.test.js
+1
-2
multimedia/audio/audio_js_standard/audioManager/src/main/js/test/getPermission.test.js
...ndard/audioManager/src/main/js/test/getPermission.test.js
+12
-4
multimedia/media/media_js_standard/audioRecorder/src/main/js/test/RecorderLocalTestAudioFUNC.test.js
...order/src/main/js/test/RecorderLocalTestAudioFUNC.test.js
+12
-3
multimedia/media/media_js_standard/videoRecorder/src/main/js/test/VideoRecorderFuncCallbackTest.test.js
...er/src/main/js/test/VideoRecorderFuncCallbackTest.test.js
+11
-3
multimedia/medialibrary/mediaLibrary_js_standard/src/main/js/test/FileAssetGetThumbnailCallBack.test.js
...rd/src/main/js/test/FileAssetGetThumbnailCallBack.test.js
+1
-1
multimedia/medialibrary/mediaLibrary_js_standard/src/main/js/test/fetchFileResultPromise.test.js
..._standard/src/main/js/test/fetchFileResultPromise.test.js
+1
-0
multimedia/medialibrary/mediaLibrary_js_standard/src/main/js/test/fileAssetTestCallback.test.js
...s_standard/src/main/js/test/fileAssetTestCallback.test.js
+0
-107
multimedia/medialibrary/mediaLibrary_js_standard/src/main/js/test/fileAssetTestPromise.test.js
...js_standard/src/main/js/test/fileAssetTestPromise.test.js
+0
-99
multimedia/medialibrary/mediaLibrary_js_standard/src/main/js/test/getPermission.test.js
...ibrary_js_standard/src/main/js/test/getPermission.test.js
+11
-3
multimedia/medialibrary/mediaLibrary_js_standard/src/main/js/test/mediaLibraryTestPromise.test.js
...standard/src/main/js/test/mediaLibraryTestPromise.test.js
+30
-16
未找到文件。
multimedia/audio/audio_js_standard/audioManager/Test.json
浏览文件 @
aeb042d9
...
...
@@ -12,15 +12,18 @@
"ActsAudioManagerJsTest.hap"
],
"type"
:
"AppInstallKit"
,
"cleanup-apps"
:
true
},
{
"type"
:
"ShellKit"
,
"run-command"
:
[
"mkdir /data/app/el2/100/base/ohos.acts.multimedia.audio.audiomanager/haps/entry/files/media"
"mkdir
-p
/data/app/el2/100/base/ohos.acts.multimedia.audio.audiomanager/haps/entry/files/media"
],
"cleanup-apps"
:
true
},
{
"type"
:
"PushKit"
,
"pre-push"
:
[
],
"pre-push"
:
[],
"push"
:
[
"./resource/audio/audioManager/Believer.wav ->/data/app/el2/100/base/ohos.acts.multimedia.audio.audiomanager/haps/entry/files/"
,
"./resource/audio/audioManager/Believer60s.wav ->/data/app/el2/100/base/ohos.acts.multimedia.audio.audiomanager/haps/entry/files/"
,
...
...
multimedia/audio/audio_js_standard/audioManager/src/main/js/test/AudioCall.test.js
浏览文件 @
aeb042d9
...
...
@@ -22,11 +22,10 @@ import bundle from '@ohos.bundle';
import
abilityAccessCtrl
from
'
@ohos.abilityAccessCtrl
'
;
import
featureAbility
from
'
@ohos.ability.featureAbility
'
import
resourceManager
from
'
@ohos.resourceManager
'
;
import
account
from
'
@ohos.account.osAccount
'
import
{
describe
,
beforeAll
,
beforeEach
,
afterEach
,
afterAll
,
it
,
expect
}
from
'
deccjsunit/index
'
;
describe
(
'
audioCall
'
,
async
function
()
{
describe
(
'
audioCall
'
,
function
()
{
var
mediaDir
;
let
fdRead
;
let
readpath
;
...
...
@@ -39,26 +38,6 @@ describe('audioCall', async function () {
const
audioManagerRec
=
audio
.
getAudioManager
();
console
.
info
(
'
AudioFrameworkRecLog: Create AudioManger Object JS Framework
'
);
let
userId
=
await
account
.
getAccountManager
().
getOsAccountLocalldFromProcess
();
console
.
info
(
'
userId :
'
+
userId
);
/*async function getPathName(){
var path1 = '/data/accounts/account_0/appdata/';
var packageName;
var context = ability_featureAbility.getContext();
await context.getBundleName()
.then((data) => {
console.info('AudioFrameworkRenderLog: Cache directory obtained. Data: ' + data);
packageName = data;
}).catch((error) => {
console.error('AudioFrameworkRenderLog: Failed to obtain the cache directory. Cause:' + error.message);
});
await sleep(200);
//var mediaDirTemp = path1 + packageName + '/' + packageName + '/assets/entry/resources/rawfile';
var mediaDirTemp = path1+packageName
console.info('AudioFrameworkRenderLog: Resource DIR Path : '+mediaDirTemp);
return mediaDirTemp;
}*/
async
function
getAbilityInfo
(
fileName
)
{
let
context
=
await
featureAbility
.
getContext
();
console
.
info
(
"
case0 context is
"
+
context
);
...
...
@@ -69,9 +48,7 @@ describe('audioCall', async function () {
})
}
beforeAll
(
async
function
()
{
await
applyPermission
();
console
.
info
(
'
AudioFrameworkTest: beforeAll: Prerequisites at the test suite level
'
);
// mediaDir = '/data/storage/el2/base/haps/entry/cache';
})
beforeEach
(
async
function
()
{
...
...
@@ -102,18 +79,7 @@ describe('audioCall', async function () {
});
});
}
// async function getFdRead(pathName, done) {
// await getFileDescriptor(pathName).then((res) => {
// if (res == undefined) {
// expect().assertFail();
// console.info('AudioFrameworkRenderLog:case error fileDescriptor undefined, open file fail');
// done();
// } else {
// fdRead = res.fd;
// console.info("AudioFrameworkRenderLog:case 0 fdRead is: " + fdRead);
// }
// })
// }
async
function
getFdRead
(
pathName
)
{
let
context
=
await
featureAbility
.
getContext
();
console
.
info
(
"
case0 context is
"
+
context
);
...
...
@@ -136,36 +102,7 @@ describe('audioCall', async function () {
console
.
info
(
'
[fileIO]case catch open fd failed
'
);
});
}
async
function
applyPermission
()
{
let
appInfo
=
await
bundle
.
getApplicationInfo
(
'
ohos.acts.multimedia.audio.audiomanager
'
,
0
,
userId
);
let
atManager
=
abilityAccessCtrl
.
createAtManager
();
if
(
atManager
!=
null
)
{
let
tokenID
=
appInfo
.
accessTokenId
;
console
.
info
(
'
AudioFrameworkRenderLog:[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
(
'
AudioFrameworkRenderLog:[permission] case grantUserGrantedPermission success :
'
+
result
);
}).
catch
((
err
)
=>
{
console
.
info
(
'
AudioFrameworkRenderLog:[permission] case grantUserGrantedPermission failed :
'
+
err
);
});
await
atManager
.
grantUserGrantedPermission
(
tokenID
,
permissionName2
,
1
).
then
((
result
)
=>
{
console
.
info
(
'
AudioFrameworkRenderLog:[permission] case grantUserGrantedPermission success :
'
+
result
);
}).
catch
((
err
)
=>
{
console
.
info
(
'
AudioFrameworkRenderLog:[permission] case grantUserGrantedPermission failed :
'
+
err
);
});
await
atManager
.
grantUserGrantedPermission
(
tokenID
,
permissionName3
,
1
).
then
((
result
)
=>
{
console
.
info
(
'
AudioFrameworkRenderLog:[permission] case grantUserGrantedPermission success :
'
+
result
);
}).
catch
((
err
)
=>
{
console
.
info
(
'
AudioFrameworkRenderLog:[permission] case grantUserGrantedPermission failed :
'
+
err
);
});
}
else
{
console
.
info
(
'
AudioFrameworkRenderLog:[permission] case apply permission failed, createAtManager failed
'
);
}
}
async
function
playbackPromise
(
AudioRendererOptions
,
pathName
,
AudioScene
)
{
resultFlagRen
=
'
new
'
;
console
.
info
(
'
AudioFrameworkRenderLog: Promise : Audio Playback Function
'
);
...
...
@@ -426,7 +363,7 @@ describe('audioCall', async function () {
* @tc.type : Function
* @tc.level : Level 0
*/
it
(
'
SUB_AUDIO_
VOIP
_Play_001
'
,
0
,
async
function
(
done
)
{
it
(
'
SUB_AUDIO_
CALL
_Play_001
'
,
0
,
async
function
(
done
)
{
var
AudioStreamInfo
=
{
samplingRate
:
audio
.
AudioSamplingRate
.
SAMPLE_RATE_44100
,
...
...
@@ -463,7 +400,7 @@ describe('audioCall', async function () {
* @tc.type : Function
* @tc.level : Level 0
*/
it
(
'
SUB_AUDIO_
VOIP
_Rec_001
'
,
0
,
async
function
(
done
)
{
it
(
'
SUB_AUDIO_
CALL
_Rec_001
'
,
0
,
async
function
(
done
)
{
var
AudioStreamInfo
=
{
samplingRate
:
audio
.
AudioSamplingRate
.
SAMPLE_RATE_44100
,
...
...
@@ -499,7 +436,7 @@ describe('audioCall', async function () {
* @tc.type : Function
* @tc.level : Level 0
*/
it
(
'
SUB_AUDIO_
VOIP
_RecPlay_001
'
,
0
,
async
function
(
done
)
{
it
(
'
SUB_AUDIO_
CALL
_RecPlay_001
'
,
0
,
async
function
(
done
)
{
var
AudioStreamInfoCap
=
{
samplingRate
:
audio
.
AudioSamplingRate
.
SAMPLE_RATE_44100
,
...
...
multimedia/audio/audio_js_standard/audioManager/src/main/js/test/AudioCapturer.test.js
浏览文件 @
aeb042d9
...
...
@@ -15,41 +15,13 @@
import
audio
from
'
@ohos.multimedia.audio
'
;
import
fileio
from
'
@ohos.fileio
'
;
import
ability_featureAbility
from
'
@ohos.ability.featureAbility
'
;
import
featureAbility
from
'
@ohos.ability.featureAbility
'
import
{
describe
,
beforeAll
,
beforeEach
,
afterEach
,
afterAll
,
it
,
expect
}
from
'
deccjsunit/index
'
;
describe
(
'
audioCapturer
'
,
function
()
{
var
dateTime
=
new
Date
().
getTime
();
//const dirPath = '/data/accounts/account_0/appdata/RecTest'+dateTime;
//var fpath = dirPath+'/capture_js.pcm';
var
audioCapCallBack
;
var
audioCapPromise
;
var
dirPath
;
var
fpath
;
//console.info('AudioFrameworkRecLog: Recording files Path: '+dirPath);
/* async function getPathName(){
/* var path1 = '/data/accounts/account_0/appdata/';
var packageName;
var context = ability_featureAbility.getContext();
await context.getBundleName()
.then((data) => {
console.info('AudioFrameworkRenderLog: Cache directory obtained. Data: ' + data);
packageName = data;
}).catch((error) => {
console.error('AudioFrameworkRenderLog: Failed to obtain the cache directory. Cause:' + error.message);
});
await sleep(200);
//var mediaDirTemp = path1 + packageName + '/' + packageName + '/assets/entry/resources/rawfile';
var mediaDirTemp ='/data/storage/el2/base/haps/entry/cache/'// path1+packageName
console.info('AudioFrameworkRenderLog: Resource DIR Path : '+mediaDirTemp);
return mediaDirTemp;
}*/
const
audioManager
=
audio
.
getAudioManager
();
console
.
info
(
'
AudioFrameworkRenderLog: Create AudioManger Object JS Framework
'
);
...
...
@@ -76,14 +48,8 @@ describe('audioCapturer', function () {
}
beforeAll
(
async
function
()
{
console
.
info
(
'
AudioFrameworkTest: beforeAll: Prerequisites at the test suite level
'
);
// dirPath = '/data/storage/el2/base/haps/entry/files'
// await getAbilityInfo();
/*dateTime = new Date().getTime();
dirPath = mediaDir+'/files/RecTest'+dateTime;*/
// console.info('AudioFrameworkRecLog: Recording files Path: '+dirPath);
// fpath = dirPath+'/capture_js.pcm';
await
sleep
(
100
);
// fileio.mkdirSync(fPath);
console
.
info
(
'
AudioFrameworkTest: beforeAll: END
'
);
})
...
...
@@ -97,11 +63,6 @@ describe('audioCapturer', function () {
})
afterAll
(
async
function
()
{
/*fileio.rmdir(dirPath, function(err){
if (!err) {
console.info('AudioFrameworkTest: Recorded files are deleted successfully');
}
});*/
await
sleep
(
1000
);
console
.
info
(
'
AudioFrameworkTest: afterAll: Test suite-level cleanup condition
'
);
})
...
...
@@ -580,6 +541,7 @@ describe('audioCapturer', function () {
console
.
info
(
'
AudioFrameworkRecLog: AudioCapturer Created : Success : Stream Type: SUCCESS
'
+
audioCapCallBack
.
state
);
}
});
await
sleep
(
1000
);
await
audioCapCallBack
.
start
(
async
(
err
,
value
)
=>
{
console
.
info
(
'
AudioFrameworkRecLog: AudioCapturer : START SUCCESS
'
);
console
.
info
(
'
AudioFrameworkRecLog: ---------START---------
'
);
...
...
@@ -5612,137 +5574,6 @@ describe('audioCapturer', function () {
await
sleep
(
1000
);
})
/* *
* @tc.number : SUB_AUDIO_VOIP_CAP_CB_READ_BUFFER_MARK_STRINGVALUE_REACH_083
* @tc.name : AudioCapturer-Check-READ_BUFFER
* @tc.desc : AudioCapturer with read buffer
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 0*/
it
(
'
SUB_AUDIO_VOIP_CAP_CB_READ_BUFFER_MARK_STRINGVALUE_REACH_083
'
,
0
,
async
function
(
done
)
{
var
stateFlag
;
await
getAbilityInfo
(
"
capture_CB_js-44100-2C-S16LE-checkpromisereadbuffer.pcm
"
);
var
AudioStreamInfo
=
{
samplingRate
:
audio
.
AudioSamplingRate
.
SAMPLE_RATE_44100
,
channels
:
audio
.
AudioChannel
.
CHANNEL_2
,
sampleFormat
:
audio
.
AudioSampleFormat
.
SAMPLE_FORMAT_S16LE
,
encodingType
:
audio
.
AudioEncodingType
.
ENCODING_TYPE_RAW
}
var
AudioCapturerInfo
=
{
source
:
audio
.
SourceType
.
SOURCE_TYPE_MIC
,
capturerFlags
:
0
}
var
AudioCapturerOptions
=
{
streamInfo
:
AudioStreamInfo
,
capturerInfo
:
AudioCapturerInfo
}
audio
.
createAudioCapturer
(
AudioCapturerOptions
,
async
(
err
,
value
)
=>
{
if
(
err
)
{
console
.
info
(
'
AudioFrameworkRecLog: AudioCapturer Not Created : Fail : Stream Type: FAIL
'
);
}
else
{
audioCapCallBack
=
value
;
console
.
info
(
'
AudioFrameworkRecLog: AudioCapturer Created : Success : Stream Type: SUCCESS
'
+
audioCapCallBack
.
state
);
}
});
await
sleep
(
1000
);
audioCapCallBack
.
on
(
'
markReach
'
,
"
HARSHA
"
,
(
position
)
=>
{
if
(
position
==
"
HARSHA
"
)
{
console
.
info
(
'
AudioFrameworkRecLog: ---------ON TRIGGERED SUCCESSFULLY---------
'
);
console
.
info
(
'
AudioRenderLog: mark reached:
'
+
position
);
stateFlag
=
true
;
}
else
{
stateFlag
=
false
;
expect
(
stateFlag
).
assertTrue
();
done
();
}
});
await
sleep
(
1000
);
audioCapCallBack
.
start
(
async
(
err
,
value
)
=>
{
console
.
info
(
'
AudioFrameworkRecLog: AudioCapturer : START SUCCESS
'
);
console
.
info
(
'
AudioFrameworkRecLog: ---------START---------
'
);
if
(
err
)
{
console
.
info
(
'
AudioFrameworkRecLog: Capturer start :ERROR :
'
+
err
.
message
);
stateFlag
=
false
;
}
else
{
console
.
info
(
'
AudioFrameworkRecLog: AudioCapturer : STATE :
'
+
audioCapCallBack
.
state
);
console
.
info
(
'
AudioFrameworkRecLog: Capturer started :SUCCESS
'
);
if
((
audioCapCallBack
.
state
==
2
))
{
stateFlag
=
true
;
}
}
});
await
sleep
(
1000
);
console
.
info
(
'
AudioFrameworkRecLog: ---------GET BUFFER SIZE---------
'
);
var
bufferSize
=
await
audioCapCallBack
.
getBufferSize
();
console
.
info
(
'
AudioFrameworkRecLog: buffer size:
'
+
bufferSize
);
await
sleep
(
1000
);
console
.
info
(
'
AudioFrameworkRecLog: ---------OPEN FILE---------
'
);
var
fd
=
fileio
.
openSync
(
fpath
,
0o102
,
0o777
);
if
(
fd
!==
null
)
{
console
.
info
(
'
AudioFrameworkRecLog: file fd created
'
);
}
else
{
console
.
info
(
'
AudioFrameworkRecLog: Capturer start :ERROR :
'
);
stateFlag
=
false
;
}
console
.
info
(
'
AudioFrameworkRecLog: ---------OPEN FILE IN APPEND MODE---------
'
);
fd
=
fileio
.
openSync
(
fpath
,
0o2002
,
0o666
);
if
(
fd
!==
null
)
{
console
.
info
(
'
AudioFrameworkRecLog: file fd opened : Append Mode :PASS
'
);
}
else
{
console
.
info
(
'
AudioFrameworkRecLog: file fd Open: Append Mode : FAILED
'
);
stateFlag
=
false
;
}
await
sleep
(
1000
);
var
numBuffersToCapture
=
45
;
while
(
numBuffersToCapture
)
{
console
.
info
(
'
AudioFrameworkRecLog: ---------BEFORE CHECK CB READ BUFFER---------
'
);
audioCapCallBack
.
read
(
bufferSize
,
true
,
async
(
err
,
buffer
)
=>
{
if
(
err
)
{
console
.
info
(
'
AudioFrameworkRecLog: Capturer release :ERROR :
'
+
err
.
message
);
stateFlag
=
false
;
}
else
{
console
.
info
(
'
AudioFrameworkRecLog: ---------AFTER CHECK CB READ BUFFER---------
'
);
console
.
info
(
'
AudioFrameworkRecLog: AudioCapturer : readvalue :
'
+
buffer
);
await
sleep
(
50
);
console
.
info
(
'
AudioFrameworkRecLog: ---------WRITE BUFFER---------
'
);
var
number
=
fileio
.
writeSync
(
fd
,
buffer
);
console
.
info
(
'
BufferRecLog: data written:
'
+
number
);
await
sleep
(
100
);
stateFlag
=
true
;
}
});
numBuffersToCapture
--
;
}
await
sleep
(
3000
);
audioCapCallBack
.
off
(
'
markReach
'
);
await
sleep
(
1000
);
audioCapCallBack
.
release
(
async
(
err
,
value
)
=>
{
console
.
info
(
'
AudioFrameworkRecLog: ---------RELEASE RECORD---------
'
);
if
(
err
)
{
console
.
info
(
'
AudioFrameworkRecLog: Capturer release :ERROR :
'
+
err
.
message
);
stateFlag
=
false
;
}
else
{
console
.
info
(
'
AudioFrameworkRecLog: ---------BEFORE CHECK AUDIO RELASED STATE---------
'
);
console
.
info
(
'
AudioFrameworkRecLog: Capturer release : SUCCESS
'
);
console
.
info
(
'
AudioFrameworkRecLog: AudioCapturer : STATE :
'
+
audioCapCallBack
.
state
);
if
((
audioCapCallBack
.
state
==
4
))
{
console
.
info
(
'
AudioFrameworkRecLog: ---------AFTER CHECK AUDIO RELEASED STATE---------
'
);
stateFlag
=
true
;
console
.
info
(
'
AudioFrameworkRenderLog: resultFlag :
'
+
stateFlag
);
expect
(
stateFlag
).
assertTrue
();
done
();
}
}
});
await
sleep
(
1000
);
})
/* *
* @tc.number : SUB_AUDIO_VOIP_CAP_CB_READ_BUFFER_PERIOD_REACH_1000_084
* @tc.name : AudioCapturer-Check-READ_BUFFER
...
...
@@ -6347,156 +6178,4 @@ describe('audioCapturer', function () {
}
})
/* *
* @tc.number : SUB_AUDIO_VOIP_CAP_CB_READ_BUFFER_PERIOD_REACH_STRING_088
* @tc.name : AudioCapturer-Check-READ_BUFFER
* @tc.desc : AudioCapturer with read buffer
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 0*/
it
(
'
SUB_AUDIO_VOIP_CAP_CB_READ_BUFFER_PERIOD_REACH_STRING_088
'
,
0
,
async
function
(
done
)
{
var
stateFlag
;
await
getAbilityInfo
(
"
capture_CB_js-44100-2C-S16LE-checkpromisereadbuffer.pcm
"
);
var
AudioStreamInfo
=
{
samplingRate
:
audio
.
AudioSamplingRate
.
SAMPLE_RATE_44100
,
channels
:
audio
.
AudioChannel
.
CHANNEL_2
,
sampleFormat
:
audio
.
AudioSampleFormat
.
SAMPLE_FORMAT_S16LE
,
encodingType
:
audio
.
AudioEncodingType
.
ENCODING_TYPE_RAW
}
var
AudioCapturerInfo
=
{
source
:
audio
.
SourceType
.
SOURCE_TYPE_MIC
,
capturerFlags
:
0
}
var
AudioCapturerOptions
=
{
streamInfo
:
AudioStreamInfo
,
capturerInfo
:
AudioCapturerInfo
}
audio
.
createAudioCapturer
(
AudioCapturerOptions
,
async
(
err
,
value
)
=>
{
if
(
err
)
{
console
.
info
(
'
AudioFrameworkRecLog: AudioCapturer Not Created : Fail : Stream Type: FAIL
'
);
}
else
{
audioCapCallBack
=
value
;
console
.
info
(
'
AudioFrameworkRecLog: AudioCapturer Created : Success : Stream Type: SUCCESS
'
+
audioCapCallBack
.
state
);
}
});
await
sleep
(
1000
);
audioCapCallBack
.
on
(
'
periodReach
'
,
"
Harsha
"
,
(
position
)
=>
{
if
(
position
==
"
Harsha
"
)
{
console
.
info
(
'
AudioFrameworkRecLog: ---------ON TRIGGERED SUCCESSFULLY---------
'
);
console
.
info
(
'
AudioRenderLog: periodReach:
'
+
position
);
stateFlag
=
true
;
}
else
{
stateFlag
=
false
;
}
});
await
sleep
(
1000
);
audioCapCallBack
.
start
(
async
(
err
,
value
)
=>
{
console
.
info
(
'
AudioFrameworkRecLog: AudioCapturer : START SUCCESS
'
);
console
.
info
(
'
AudioFrameworkRecLog: ---------START---------
'
);
if
(
err
)
{
console
.
info
(
'
AudioFrameworkRecLog: Capturer start :ERROR :
'
+
err
.
message
);
stateFlag
=
false
;
}
else
{
console
.
info
(
'
AudioFrameworkRecLog: AudioCapturer : STATE :
'
+
audioCapCallBack
.
state
);
console
.
info
(
'
AudioFrameworkRecLog: Capturer started :SUCCESS
'
);
if
((
audioCapCallBack
.
state
==
2
))
{
stateFlag
=
true
;
}
}
});
await
sleep
(
1000
);
console
.
info
(
'
AudioFrameworkRecLog: ---------GET BUFFER SIZE---------
'
);
var
bufferSize
=
await
audioCapCallBack
.
getBufferSize
();
console
.
info
(
'
AudioFrameworkRecLog: buffer size:
'
+
bufferSize
);
await
sleep
(
1000
);
console
.
info
(
'
AudioFrameworkRecLog: ---------OPEN FILE---------
'
);
var
fd
=
fileio
.
openSync
(
fpath
,
0o102
,
0o777
);
if
(
fd
!==
null
)
{
console
.
info
(
'
AudioFrameworkRecLog: file fd created
'
);
}
else
{
console
.
info
(
'
AudioFrameworkRecLog: Capturer start :ERROR :
'
);
stateFlag
=
false
;
}
console
.
info
(
'
AudioFrameworkRecLog: ---------OPEN FILE IN APPEND MODE---------
'
);
fd
=
fileio
.
openSync
(
fpath
,
0o2002
,
0o666
);
if
(
fd
!==
null
)
{
console
.
info
(
'
AudioFrameworkRecLog: file fd opened : Append Mode :PASS
'
);
}
else
{
console
.
info
(
'
AudioFrameworkRecLog: file fd Open: Append Mode : FAILED
'
);
stateFlag
=
false
;
}
await
sleep
(
1000
);
var
numBuffersToCapture
=
45
;
while
(
numBuffersToCapture
)
{
console
.
info
(
'
AudioFrameworkRecLog: ---------BEFORE CHECK CB READ BUFFER---------
'
);
audioCapCallBack
.
read
(
bufferSize
,
true
,
async
(
err
,
buffer
)
=>
{
if
(
err
)
{
console
.
info
(
'
AudioFrameworkRecLog: Capturer release :ERROR :
'
+
err
.
message
);
stateFlag
=
false
;
}
else
{
console
.
info
(
'
AudioFrameworkRecLog: ---------AFTER CHECK CB READ BUFFER---------
'
);
console
.
info
(
'
AudioFrameworkRecLog: AudioCapturer : readvalue :
'
+
buffer
);
await
sleep
(
50
);
console
.
info
(
'
AudioFrameworkRecLog: ---------WRITE BUFFER---------
'
);
var
number
=
fileio
.
writeSync
(
fd
,
buffer
);
console
.
info
(
'
BufferRecLog: data written:
'
+
number
);
await
sleep
(
100
);
stateFlag
=
true
;
}
});
numBuffersToCapture
--
;
}
await
sleep
(
3000
);
audioCapCallBack
.
off
(
'
periodReach
'
);
await
sleep
(
1000
);
if
(
stateFlag
==
true
)
{
audioCapCallBack
.
release
(
async
(
err
,
value
)
=>
{
console
.
info
(
'
AudioFrameworkRecLog: ---------RELEASE RECORD---------
'
);
if
(
err
)
{
console
.
info
(
'
AudioFrameworkRecLog: Capturer release :ERROR :
'
+
err
.
message
);
stateFlag
=
false
;
}
else
{
console
.
info
(
'
AudioFrameworkRecLog: ---------BEFORE CHECK AUDIO RELASED STATE---------
'
);
console
.
info
(
'
AudioFrameworkRecLog: Capturer release : SUCCESS
'
);
console
.
info
(
'
AudioFrameworkRecLog: AudioCapturer : STATE :
'
+
audioCapCallBack
.
state
);
if
((
audioCapCallBack
.
state
==
4
))
{
console
.
info
(
'
AudioFrameworkRecLog: ---------AFTER CHECK AUDIO RELEASED STATE---------
'
);
stateFlag
=
true
;
console
.
info
(
'
AudioFrameworkRenderLog: resultFlag :
'
+
stateFlag
);
expect
(
stateFlag
).
assertTrue
();
done
();
}
}
});
await
sleep
(
1000
);
}
else
{
audioCapCallBack
.
release
(
async
(
err
,
value
)
=>
{
console
.
info
(
'
AudioFrameworkRecLog: ---------RELEASE RECORD---------
'
);
if
(
err
)
{
console
.
info
(
'
AudioFrameworkRecLog: Capturer release :ERROR :
'
+
err
.
message
);
stateFlag
=
false
;
expect
(
stateFlag
).
assertTrue
();
}
else
{
console
.
info
(
'
AudioFrameworkRecLog: ---------BEFORE CHECK AUDIO RELASED STATE---------
'
);
console
.
info
(
'
AudioFrameworkRecLog: Capturer release : SUCCESS
'
);
console
.
info
(
'
AudioFrameworkRecLog: AudioCapturer : STATE :
'
+
audioCapCallBack
.
state
);
if
((
audioCapCallBack
.
state
==
4
))
{
console
.
info
(
'
AudioFrameworkRecLog: ---------AFTER CHECK AUDIO RELEASED STATE---------
'
);
console
.
info
(
'
AudioFrameworkRenderLog: resultFlag :
'
+
stateFlag
);
stateFlag
=
false
;
expect
(
stateFlag
).
assertTrue
();
done
();
}
}
});
await
sleep
(
1000
);
}
})
})
})
\ No newline at end of file
multimedia/audio/audio_js_standard/audioManager/src/main/js/test/AudioEventManagement.test.js
浏览文件 @
aeb042d9
...
...
@@ -14,25 +14,15 @@
*/
import
audio
from
'
@ohos.multimedia.audio
'
;
import
fileio
from
'
@ohos.fileio
'
;
import
{
describe
,
beforeAll
,
beforeEach
,
afterEach
,
afterAll
,
it
,
expect
}
from
'
deccjsunit/index
'
;
describe
(
'
audio
Manger_audio1
'
,
function
()
{
describe
(
'
audio
EventManger
'
,
function
()
{
console
.
info
(
'
AudioFrameworkTest: Create AudioManger Object JS Framework
'
);
const
audioManager
=
audio
.
getAudioManager
();
var
deviceRoleValue
=
null
;
var
deviceTypeValue
=
null
;
var
volErrorMesg
=
'
Error, Operation not supported or Failed
'
;
var
audioMedia
=
3
;
var
audioRingtone
=
2
;
var
minVol
=
0
;
var
maxVol
=
15
;
var
lowVol
=
5
;
var
highVol
=
14
;
var
outOfRangeVol
=
28
;
var
longValue
=
'
28374837458743875804735081439085918459801437584738967509184509813904850914375904790589104801843
'
;
function
sleep
(
ms
)
{
return
new
Promise
(
resolve
=>
setTimeout
(
resolve
,
ms
));
}
...
...
multimedia/audio/audio_js_standard/audioManager/src/main/js/test/AudioFramework.test.js
浏览文件 @
aeb042d9
...
...
@@ -17,12 +17,11 @@ import audio from '@ohos.multimedia.audio';
import
{
describe
,
beforeAll
,
beforeEach
,
afterEach
,
afterAll
,
it
,
expect
}
from
'
deccjsunit/index
'
;
describe
(
'
audio
Manger_audio2
'
,
function
()
{
describe
(
'
audio
Framework
'
,
function
()
{
console
.
info
(
'
AudioFrameworkTest: Create AudioManger Object JS Framework
'
);
const
audioManager
=
audio
.
getAudioManager
();
var
deviceRoleValue
=
null
;
var
deviceTypeValue
=
null
;
var
volErrorMesg
=
'
Error, Operation not supported or Failed
'
;
var
audioMedia
=
3
;
var
audioRingtone
=
2
;
var
minVol
=
0
;
...
...
multimedia/audio/audio_js_standard/audioManager/src/main/js/test/AudioRenderer.test.js
浏览文件 @
aeb042d9
...
...
@@ -15,16 +15,11 @@
import
audio
from
'
@ohos.multimedia.audio
'
;
import
fileio
from
'
@ohos.fileio
'
;
import
app
from
'
@system.app
'
;
import
bundle
from
'
@ohos.bundle
'
;
import
abilityAccessCtrl
from
'
@ohos.abilityAccessCtrl
'
;
import
featureAbility
from
'
@ohos.ability.featureAbility
'
import
ability_featureAbility
from
'
@ohos.ability.featureAbility
'
;
import
resourceManager
from
'
@ohos.resourceManager
'
;
import
{
describe
,
beforeAll
,
beforeEach
,
afterEach
,
afterAll
,
it
,
expect
}
from
'
deccjsunit/index
'
;
import
account
from
'
@ohos.account.osAccount
'
describe
(
'
audioRenderer
'
,
async
function
()
{
describe
(
'
audioRenderer
'
,
function
()
{
let
fdRead
;
let
readpath
;
...
...
@@ -32,31 +27,9 @@ describe('audioRenderer', async function () {
let
filePath
;
const
audioManager
=
audio
.
getAudioManager
();
console
.
info
(
'
AudioFrameworkRenderLog: Create AudioManger Object JS Framework
'
);
/*async function getPathName(){
// var path1 = '/data/accounts/account_0/appdata/';
var path1 = '/data/app/el1/bundle/public/';
var packageName;
var context = ability_featureAbility.getContext();
await context.getBundleName()
.then((data) => {
console.info('AudioFrameworkRenderLog: Cache directory obtained. Data: ' + data);
packageName = data;
}).catch((error) => {
console.error('AudioFrameworkRenderLog: Failed to obtain the cache directory. Cause:' + error.message);
});
await sleep(200);
var mediaDirTemp = path1 + packageName + '/' + packageName + '/assets/entry/resources/rawfile';
// var mediaDirTemp = path1+packageName+'/files'
console.info('AudioFrameworkRenderLog: Resource DIR Path : '+mediaDirTemp);
return mediaDirTemp;
}*/
let
userId
=
await
account
.
getAccountManager
().
getOsAccountLocalldFromProcess
();
console
.
info
(
'
userId :
'
+
userId
);
beforeAll
(
async
function
()
{
await
applyPermission
();
console
.
info
(
'
AudioFrameworkRenderLog: beforeAll: Prerequisites at the test suite level
'
);
// mediaDir = await getPathName();
})
beforeEach
(
async
function
()
{
...
...
@@ -76,18 +49,6 @@ describe('audioRenderer', async function () {
return
new
Promise
(
resolve
=>
setTimeout
(
resolve
,
ms
));
}
// 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('AudioFrameworkRenderLog:case getRawFileDescriptor err: ' + error);
// });
// });
// return fileDescriptor;
// }
async
function
closeFileDescriptor
(
fileName
)
{
await
resourceManager
.
getResourceManager
().
then
(
async
(
mgr
)
=>
{
await
mgr
.
closeRawFileDescriptor
(
fileName
).
then
(
value
=>
{
...
...
@@ -97,18 +58,7 @@ describe('audioRenderer', async function () {
});
});
}
// async function getFdRead(pathName, done) {
// await getFileDescriptor(pathName).then((res) => {
// if (res == undefined) {
// expect().assertFail();
// console.info('AudioFrameworkRenderLog:case error fileDescriptor undefined, open file fail');
// done();
// } else {
// fdRead = res.fd;
// console.info("AudioFrameworkRenderLog:case 0 fdRead is: " + fdRead);
// }
// })
// }
async
function
getFdRead
(
pathName
,
done
)
{
let
context
=
await
featureAbility
.
getContext
();
console
.
info
(
"
case0 context is
"
+
context
);
...
...
@@ -131,35 +81,7 @@ describe('audioRenderer', async function () {
console
.
info
(
'
[fileIO]case catch open fd failed
'
);
});
}
async
function
applyPermission
()
{
let
appInfo
=
await
bundle
.
getApplicationInfo
(
'
ohos.acts.multimedia.audio.audiomanager
'
,
0
,
userId
);
let
atManager
=
abilityAccessCtrl
.
createAtManager
();
if
(
atManager
!=
null
)
{
let
tokenID
=
appInfo
.
accessTokenId
;
console
.
info
(
'
AudioFrameworkRenderLog:[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
(
'
AudioFrameworkRenderLog:[permission] case grantUserGrantedPermission success :
'
+
result
);
}).
catch
((
err
)
=>
{
console
.
info
(
'
AudioFrameworkRenderLog:[permission] case grantUserGrantedPermission failed :
'
+
err
);
});
await
atManager
.
grantUserGrantedPermission
(
tokenID
,
permissionName2
,
1
).
then
((
result
)
=>
{
console
.
info
(
'
AudioFrameworkRenderLog:[permission] case grantUserGrantedPermission success :
'
+
result
);
}).
catch
((
err
)
=>
{
console
.
info
(
'
AudioFrameworkRenderLog:[permission] case grantUserGrantedPermission failed :
'
+
err
);
});
await
atManager
.
grantUserGrantedPermission
(
tokenID
,
permissionName3
,
1
).
then
((
result
)
=>
{
console
.
info
(
'
AudioFrameworkRenderLog:[permission] case grantUserGrantedPermission success :
'
+
result
);
}).
catch
((
err
)
=>
{
console
.
info
(
'
AudioFrameworkRenderLog:[permission] case grantUserGrantedPermission failed :
'
+
err
);
});
}
else
{
console
.
info
(
'
AudioFrameworkRenderLog:[permission] case apply permission failed, createAtManager failed
'
);
}
}
async
function
playbackPromise
(
AudioRendererOptions
,
pathName
,
AudioScene
)
{
var
resultFlag
=
'
new
'
;
console
.
info
(
'
AudioFrameworkRenderLog: Promise : Audio Playback Function
'
);
...
...
@@ -340,9 +262,6 @@ describe('audioRenderer', async function () {
//let audioTime = Date.now();
let
audioTimeStart
;
/*let audioTimeEnd;
let audioTimeMiddle;*/
// console.info('AudioFrameworkRenderLog: Current Time in NANOSeconds : '+audioTime);
await
audioRen
.
getAudioTime
().
then
(
async
function
(
data
)
{
// audioTime = Date.now();
...
...
multimedia/audio/audio_js_standard/audioManager/src/main/js/test/AudioVOIP.test.js
浏览文件 @
aeb042d9
...
...
@@ -23,43 +23,21 @@ import abilityAccessCtrl from '@ohos.abilityAccessCtrl';
import
featureAbility
from
'
@ohos.ability.featureAbility
'
import
resourceManager
from
'
@ohos.resourceManager
'
;
import
{
describe
,
beforeAll
,
beforeEach
,
afterEach
,
afterAll
,
it
,
expect
}
from
'
deccjsunit/index
'
;
import
account
from
'
@ohos.account.osAccount
'
describe
(
'
audio
Renderer_audo2
'
,
async
function
()
{
describe
(
'
audio
VOIP
'
,
function
()
{
var
mediaDir
;
let
fdRead
;
let
readpath
;
let
fdPath
;
let
filePath
;
/*async function getPathName(){
var path1 = '/data/app/el1/bundle/public/';
var packageName;
var context = ability_featureAbility.getContext();
await context.getBundleName()
.then((data) => {
console.info('AudioFrameworkRenderLog: Cache directory obtained. Data: ' + data);
packageName = data;
}).catch((error) => {
console.error('AudioFrameworkRenderLog: Failed to obtain the cache directory. Cause:' + error.message);
});
await sleep(200);
var mediaDirTemp = path1 + packageName + '/ohos.acts.multimedia.audio.audiomanager.filedescriptor/assets/entry/resources/rawfile';
//var mediaDirTemp = path1+packageName+'/files'
console.info('AudioFrameworkRenderLog: Resource DIR Path : '+mediaDirTemp);
return mediaDirTemp;
}*/
const
audioManager
=
audio
.
getAudioManager
();
console
.
info
(
'
AudioFrameworkRenderLog: Create AudioManger Object JS Framework
'
);
const
audioManagerRec
=
audio
.
getAudioManager
();
console
.
info
(
'
AudioFrameworkRecLog: Create AudioManger Object JS Framework
'
);
let
userId
=
await
account
.
getAccountManager
().
getOsAccountLocalldFromProcess
();
console
.
info
(
'
userId :
'
+
userId
);
beforeAll
(
async
function
()
{
await
applyPermission
();
console
.
info
(
'
AudioFrameworkTest: beforeAll: Prerequisites at the test suite level
'
);
// mediaDir = '/data/storage/el2/base/haps/entry/cache';
})
beforeEach
(
async
function
()
{
...
...
@@ -97,18 +75,6 @@ describe('audioRenderer_audo2',async function () {
});
});
}
// async function getFdRead(pathName, done) {
// await getFileDescriptor(pathName).then((res) => {
// if (res == undefined) {
// expect().assertFail();
// console.info('AudioFrameworkRenderLog:case error fileDescriptor undefined, open file fail');
// done();
// } else {
// fdRead = res.fd;
// console.info("AudioFrameworkRenderLog:case 0 fdRead is: " + fdRead);
// }
// })
// }
async
function
getFdRead
(
pathName
)
{
let
context
=
await
featureAbility
.
getContext
();
console
.
info
(
"
case0 context is
"
+
context
);
...
...
@@ -132,35 +98,6 @@ describe('audioRenderer_audo2',async function () {
});
}
async
function
applyPermission
()
{
let
appInfo
=
await
bundle
.
getApplicationInfo
(
'
ohos.acts.multimedia.audio.audiomanager
'
,
0
,
userId
);
let
atManager
=
abilityAccessCtrl
.
createAtManager
();
if
(
atManager
!=
null
)
{
let
tokenID
=
appInfo
.
accessTokenId
;
console
.
info
(
'
AudioFrameworkRenderLog:[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
(
'
AudioFrameworkRenderLog:[permission] case grantUserGrantedPermission success :
'
+
result
);
}).
catch
((
err
)
=>
{
console
.
info
(
'
AudioFrameworkRenderLog:[permission] case grantUserGrantedPermission failed :
'
+
err
);
});
await
atManager
.
grantUserGrantedPermission
(
tokenID
,
permissionName2
,
1
).
then
((
result
)
=>
{
console
.
info
(
'
AudioFrameworkRenderLog:[permission] case grantUserGrantedPermission success :
'
+
result
);
}).
catch
((
err
)
=>
{
console
.
info
(
'
AudioFrameworkRenderLog:[permission] case grantUserGrantedPermission failed :
'
+
err
);
});
await
atManager
.
grantUserGrantedPermission
(
tokenID
,
permissionName3
,
1
).
then
((
result
)
=>
{
console
.
info
(
'
AudioFrameworkRenderLog:[permission] case grantUserGrantedPermission success :
'
+
result
);
}).
catch
((
err
)
=>
{
console
.
info
(
'
AudioFrameworkRenderLog:[permission] case grantUserGrantedPermission failed :
'
+
err
);
});
}
else
{
console
.
info
(
'
AudioFrameworkRenderLog:[permission] case apply permission failed, createAtManager failed
'
);
}
}
async
function
playbackPromise
(
AudioRendererOptions
,
pathName
,
AudioScene
)
{
var
resultFlag
=
'
new
'
;
console
.
info
(
'
AudioFrameworkRenderLog: Promise : Audio Playback Function
'
);
...
...
@@ -485,7 +422,7 @@ describe('audioRenderer_audo2',async function () {
}
var
AudioCapturerInfo
=
{
source
:
audio
.
SourceType
.
SOURCE_TYPE_
MIC
,
source
:
audio
.
SourceType
.
SOURCE_TYPE_
VOICE_COMMUNICATION
,
capturerFlags
:
0
}
...
...
@@ -520,7 +457,7 @@ describe('audioRenderer_audo2',async function () {
}
var
AudioCapturerInfo
=
{
source
:
audio
.
SourceType
.
SOURCE_TYPE_
MIC
,
source
:
audio
.
SourceType
.
SOURCE_TYPE_
VOICE_COMMUNICATION
,
capturerFlags
:
0
}
...
...
multimedia/audio/audio_js_standard/audioManager/src/main/js/test/List.test.js
浏览文件 @
aeb042d9
...
...
@@ -14,10 +14,9 @@
*/
require
(
'
./getPermission.test.js
'
)
require
(
'
./AudioFramework.test.js
'
)
require
(
'
./AudioVOIP.test.js
'
)
require
(
'
./AudioCall.test.js
'
)
require
(
'
./AudioCapturer.test.js
'
)
require
(
'
./AudioEventManagement.test.js
'
)
require
(
'
./AudioRenderer.test.js
'
)
require
(
'
./AudioFramework.test.js
'
)
multimedia/audio/audio_js_standard/audioManager/src/main/js/test/getPermission.test.js
浏览文件 @
aeb042d9
...
...
@@ -16,10 +16,17 @@
import
{
describe
,
beforeAll
,
afterAll
,
it
,
expect
}
from
'
deccjsunit/index
'
;
import
abilityAccessCtrl
from
'
@ohos.abilityAccessCtrl
'
;
import
bundle
from
'
@ohos.bundle
'
;
import
account
from
'
@ohos.account.osAccount
'
describe
(
"
get_permission
"
,
async
function
()
{
let
userId
=
await
account
.
getAccountManager
().
getOsAccountLocalldFromProcess
();
console
.
info
(
'
userId :
'
+
userId
);
import
account
from
'
@ohos.account.osAccount
'
;
describe
(
"
get_permission
"
,
function
()
{
let
userId
;
async
function
getUserId
()
{
await
account
.
getAccountManager
().
getOsAccountLocalIdFromProcess
().
then
(
account
=>
{
console
.
info
(
"
getOsAccountLocalIdFromProcess userid ==========
"
+
account
);
userId
=
account
;
}).
catch
(
err
=>
{
console
.
info
(
"
getOsAccountLocalIdFromProcess err ==========
"
+
JSON
.
stringify
(
err
));
})
}
/**
* @tc.number SUB_DF_GRANT_USER_GRANTED_PERMISSION_0000
* @tc.name grant_user_granted_permission_async_000
...
...
@@ -30,6 +37,7 @@ describe("get_permission", async function () {
* @tc.require
*/
it
(
"
grant_user_granted_permission_async_000
"
,
0
,
async
function
(
done
)
{
await
getUserId
();
let
appInfo
=
await
bundle
.
getApplicationInfo
(
'
ohos.acts.multimedia.audio.audiomanager
'
,
0
,
userId
);
let
tokenID
=
appInfo
.
accessTokenId
;
let
atManager
=
abilityAccessCtrl
.
createAtManager
();
...
...
multimedia/media/media_js_standard/audioRecorder/src/main/js/test/RecorderLocalTestAudioFUNC.test.js
浏览文件 @
aeb042d9
...
...
@@ -20,7 +20,7 @@ import mediaLibrary from '@ohos.multimedia.mediaLibrary'
import
{
describe
,
beforeAll
,
beforeEach
,
afterEach
,
afterAll
,
it
,
expect
}
from
'
deccjsunit/index
'
import
account
from
'
@ohos.account.osAccount
'
describe
(
'
RecorderLocalTestAudioFUNC
'
,
async
function
()
{
describe
(
'
RecorderLocalTestAudioFUNC
'
,
function
()
{
let
audioRecorder
=
media
.
createAudioRecorder
();
const
END_STATE
=
0
;
const
PRE_STATE
=
1
;
...
...
@@ -49,8 +49,16 @@ describe('RecorderLocalTestAudioFUNC', async function () {
uri
:
'
file:///data/accounts/account_0/appdata/appdata/recorder/test.m4a
'
,
location
:
{
latitude
:
1
,
longitude
:
1
},
}
let
userId
=
await
account
.
getAccountManager
().
getOsAccountLocalldFromProcess
();
console
.
info
(
'
userId :
'
+
userId
);
let
userId
;
async
function
getUserId
()
{
await
account
.
getAccountManager
().
getOsAccountLocalIdFromProcess
().
then
(
account
=>
{
console
.
info
(
"
getOsAccountLocalIdFromProcess userid ==========
"
+
account
);
userId
=
account
;
}).
catch
(
err
=>
{
console
.
info
(
"
getOsAccountLocalIdFromProcess err ==========
"
+
JSON
.
stringify
(
err
));
})
}
console
.
info
(
'
case userId :
'
+
userId
);
function
sleep
(
time
)
{
for
(
let
t
=
Date
.
now
();
Date
.
now
()
-
t
<=
time
;);
}
...
...
@@ -64,6 +72,7 @@ describe('RecorderLocalTestAudioFUNC', async function () {
}
beforeAll
(
async
function
()
{
await
getUserId
();
await
applyPermission
();
console
.
info
(
'
beforeAll case
'
);
})
...
...
multimedia/media/media_js_standard/videoRecorder/src/main/js/test/VideoRecorderFuncCallbackTest.test.js
浏览文件 @
aeb042d9
...
...
@@ -21,7 +21,7 @@ import bundle from '@ohos.bundle'
import
{
describe
,
beforeAll
,
beforeEach
,
afterEach
,
afterAll
,
it
,
expect
}
from
'
deccjsunit/index
'
import
account
from
'
@ohos.account.osAccount
'
describe
(
'
VideoRecorderFuncCallbackTest
'
,
async
function
()
{
describe
(
'
VideoRecorderFuncCallbackTest
'
,
function
()
{
const
RECORDER_TIME
=
3000
;
const
PAUSE_TIME
=
1000
;
const
END_EVENT
=
'
end
'
;
...
...
@@ -43,6 +43,7 @@ describe('VideoRecorderFuncCallbackTest', async function () {
let
fdPath
;
let
fileAsset
;
let
fdNumber
;
let
userId
;
let
configFile
=
{
audioBitrate
:
48000
,
audioChannels
:
2
,
...
...
@@ -91,9 +92,16 @@ describe('VideoRecorderFuncCallbackTest', async function () {
function
sleep
(
time
)
{
for
(
let
t
=
Date
.
now
();
Date
.
now
()
-
t
<=
time
;);
}
let
userId
=
await
account
.
getAccountManager
().
getOsAccountLocalldFromProcess
();
console
.
info
(
'
userId :
'
+
userId
);
async
function
getUserId
()
{
await
account
.
getAccountManager
().
getOsAccountLocalIdFromProcess
().
then
(
account
=>
{
console
.
info
(
"
getOsAccountLocalIdFromProcess userid ==========
"
+
account
);
userId
=
account
;
}).
catch
(
err
=>
{
console
.
info
(
"
getOsAccountLocalIdFromProcess err ==========
"
+
JSON
.
stringify
(
err
));
})
}
beforeAll
(
async
function
()
{
await
getUserId
();
await
initCamera
();
await
applyPermission
();
console
.
info
(
'
beforeAll case
'
);
...
...
multimedia/medialibrary/mediaLibrary_js_standard/src/main/js/test/FileAssetGetThumbnailCallBack.test.js
浏览文件 @
aeb042d9
...
...
@@ -19,7 +19,7 @@ import featureAbility from '@ohos.ability.featureAbility';
import
{
describe
,
beforeAll
,
beforeEach
,
afterEach
,
afterAll
,
it
,
expect
}
from
'
deccjsunit/index
'
;
describe
(
'
FileAssetGetThumbnail
Promise
.test.js
'
,
function
()
{
describe
(
'
FileAssetGetThumbnail
CallBack
.test.js
'
,
function
()
{
var
context
=
featureAbility
.
getContext
();
console
.
info
(
'
MediaLibraryTest : getMediaLibrary IN
'
);
var
media
=
mediaLibrary
.
getMediaLibrary
(
context
);
...
...
multimedia/medialibrary/mediaLibrary_js_standard/src/main/js/test/fetchFileResultPromise.test.js
浏览文件 @
aeb042d9
...
...
@@ -460,6 +460,7 @@ describe('fetchFileResultPromise.test.js', async function() {
expect
(
true
).
assertTrue
();
fetchFileResult
.
close
();
done
();
return
;
}
expect
(
false
).
assertTrue
();
fetchFileResult
.
close
();
...
...
multimedia/medialibrary/mediaLibrary_js_standard/src/main/js/test/fileAssetTestCallback.test.js
浏览文件 @
aeb042d9
...
...
@@ -228,113 +228,6 @@ describe('fileAssetTestCallback.test.js', async function() {
//======================== FILE END ==================================
//======================== ALBUM BEGIN ==================================
/**
* @tc.number : SUB_MEDIA_MEDIALIBRARY_OPENANDCLOSE_ASSET_CALLBACK_005_04
* @tc.name : open('rw')
* @tc.desc : open -rw the type of ALBUM
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 0
*/
it
(
'
SUB_MEDIA_MEDIALIBRARY_OPENANDCLOSE_ASSET_CALLBACK_005_04
'
,
0
,
async
function
(
done
)
{
let
asset
;
let
fd
;
try
{
let
type
=
mediaLibrary
.
MediaType
.
ALBUM
;
let
fetchOp
=
{
selections
:
mediaLibrary
.
FileKey
.
MEDIA_TYPE
+
'
= ?
'
,
selectionArgs
:
[
type
.
toString
()
],
};
let
fetchFileResult
=
await
media
.
getFileAssets
(
fetchOp
);
const
dataList
=
await
fetchFileResult
.
getAllObject
();
asset
=
dataList
[
0
];
asset
.
open
(
'
rw
'
,
async
(
error
,
fd
)
=>
{
expect
(
false
).
assertTrue
();
done
();
});
}
catch
(
error
)
{
console
.
info
(
'
MediaLibraryTest : SUB_MEDIA_MEDIALIBRARY_OPENANDCLOSE_ASSET_CALLBACK_005_04 error:
'
+
error
);
expect
(
true
).
assertTrue
();
if
(
fd
>
0
)
{
asset
.
close
(
fd
);
}
done
();
}
});
/**
* @tc.number : SUB_MEDIA_MEDIALIBRARY_OPENANDCLOSE_ASSET_CALLBACK_005_05
* @tc.name : open('r')
* @tc.desc : open -r the type of ALBUM
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 0
*/
it
(
'
SUB_MEDIA_MEDIALIBRARY_OPENANDCLOSE_ASSET_CALLBACK_005_05
'
,
0
,
async
function
(
done
)
{
let
asset
;
let
fd
;
try
{
let
type
=
mediaLibrary
.
MediaType
.
ALBUM
;
let
fetchOp
=
{
selections
:
mediaLibrary
.
FileKey
.
MEDIA_TYPE
+
'
= ?
'
,
selectionArgs
:
[
type
.
toString
()
],
};
let
fetchFileResult
=
await
media
.
getFileAssets
(
fetchOp
);
const
dataList
=
await
fetchFileResult
.
getAllObject
();
asset
=
dataList
[
0
];
asset
.
open
(
'
r
'
,
async
(
error
,
fd
)
=>
{
expect
(
false
).
assertTrue
();
done
();
});
}
catch
(
error
)
{
console
.
info
(
'
MediaLibraryTest : SUB_MEDIA_MEDIALIBRARY_OPENANDCLOSE_ASSET_CALLBACK_005_05 error:
'
+
error
);
expect
(
true
).
assertTrue
();
if
(
fd
>
0
)
{
asset
.
close
(
fd
);
}
done
();
}
});
/**
* @tc.number : SUB_MEDIA_MEDIALIBRARY_OPENANDCLOSE_ASSET_CALLBACK_005_06
* @tc.name : open('w')
* @tc.desc : open -w the type of ALBUM
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 0
*/
it
(
'
SUB_MEDIA_MEDIALIBRARY_OPENANDCLOSE_ASSET_CALLBACK_005_06
'
,
0
,
async
function
(
done
)
{
let
asset
;
let
fd
;
try
{
let
type
=
mediaLibrary
.
MediaType
.
ALBUM
;
let
fetchOp
=
{
selections
:
mediaLibrary
.
FileKey
.
MEDIA_TYPE
+
'
= ?
'
,
selectionArgs
:
[
type
.
toString
()
],
};
let
fetchFileResult
=
await
media
.
getFileAssets
(
fetchOp
);
const
dataList
=
await
fetchFileResult
.
getAllObject
();
asset
=
dataList
[
0
];
asset
.
open
(
'
w
'
,
(
error
,
fd
)
=>
{
expect
(
false
).
assertTrue
();
});
}
catch
(
error
)
{
console
.
info
(
'
MediaLibraryTest : SUB_MEDIA_MEDIALIBRARY_OPENANDCLOSE_ASSET_CALLBACK_005_06 error:
'
+
error
);
expect
(
true
).
assertTrue
();
if
(
fd
>
0
)
{
asset
.
close
(
fd
);
}
done
();
}
});
//======================== ALBUM END ==================================
//======================== IMAGE BEGIN ==================================
/**
* @tc.number : SUB_MEDIA_MEDIALIBRARY_OPENANDCLOSE_ASSET_CALLBACK_005_07
...
...
multimedia/medialibrary/mediaLibrary_js_standard/src/main/js/test/fileAssetTestPromise.test.js
浏览文件 @
aeb042d9
...
...
@@ -165,105 +165,6 @@ describe('fileAssetTestPromise.test.js', async function() {
//======================== FILE END ==================================
//======================== ALBUM BEGIN ==================================
/**
* @tc.number : SUB_MEDIA_MEDIALIBRARY_OPENANDCLOSE_ASSET_PROMISE_005_04
* @tc.name : open('rw')
* @tc.desc : open -rw the type of ALBUM
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 0
*/
it
(
'
SUB_MEDIA_MEDIALIBRARY_OPENANDCLOSE_ASSET_PROMISE_005_04
'
,
0
,
async
function
(
done
)
{
let
asset
;
let
fd
;
try
{
let
type
=
mediaLibrary
.
MediaType
.
ALBUM
;
let
fetchOp
=
{
selections
:
mediaLibrary
.
FileKey
.
MEDIA_TYPE
+
'
= ?
'
,
selectionArgs
:
[
type
.
toString
()
],
};
let
fetchFileResult
=
await
media
.
getFileAssets
(
fetchOp
);
const
dataList
=
await
fetchFileResult
.
getAllObject
();
asset
=
dataList
[
0
];
fd
=
await
asset
.
open
(
'
rw
'
);
done
();
}
catch
(
error
)
{
console
.
info
(
'
MediaLibraryTest : SUB_MEDIA_MEDIALIBRARY_OPENANDCLOSE_ASSET_PROMISE_005_03 error:
'
+
error
);
expect
(
true
).
assertTrue
();
if
(
fd
>
0
)
{
asset
.
close
(
fd
);
}
done
();
}
});
/**
* @tc.number : SUB_MEDIA_MEDIALIBRARY_OPENANDCLOSE_ASSET_PROMISE_005_05
* @tc.name : open('r')
* @tc.desc : open -r the type of ALBUM
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 0
*/
it
(
'
SUB_MEDIA_MEDIALIBRARY_OPENANDCLOSE_ASSET_PROMISE_005_05
'
,
0
,
async
function
(
done
)
{
let
asset
;
let
fd
;
try
{
let
type
=
mediaLibrary
.
MediaType
.
ALBUM
;
let
fetchOp
=
{
selections
:
mediaLibrary
.
FileKey
.
MEDIA_TYPE
+
'
= ?
'
,
selectionArgs
:
[
type
.
toString
()
],
};
let
fetchFileResult
=
await
media
.
getFileAssets
(
fetchOp
);
const
dataList
=
await
fetchFileResult
.
getAllObject
();
asset
=
dataList
[
0
];
fd
=
await
asset
.
open
(
'
r
'
);
done
();
}
catch
(
error
)
{
console
.
info
(
'
MediaLibraryTest : SUB_MEDIA_MEDIALIBRARY_OPENANDCLOSE_ASSET_PROMISE_005_05 error:
'
+
error
);
expect
(
true
).
assertTrue
();
if
(
fd
>
0
)
{
asset
.
close
(
fd
);
}
done
();
}
});
/**
* @tc.number : SUB_MEDIA_MEDIALIBRARY_OPENANDCLOSE_ASSET_PROMISE_005_05
* @tc.name : open('w')
* @tc.desc : open -w the type of ALBUM
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 0
*/
it
(
'
SUB_MEDIA_MEDIALIBRARY_OPENANDCLOSE_ASSET_PROMISE_005_06
'
,
0
,
async
function
(
done
)
{
let
asset
;
let
fd
;
try
{
let
type
=
mediaLibrary
.
MediaType
.
ALBUM
;
let
fetchOp
=
{
selections
:
mediaLibrary
.
FileKey
.
MEDIA_TYPE
+
'
= ?
'
,
selectionArgs
:
[
type
.
toString
()
],
};
let
fetchFileResult
=
await
media
.
getFileAssets
(
fetchOp
);
const
dataList
=
await
fetchFileResult
.
getAllObject
();
asset
=
dataList
[
0
];
fd
=
await
asset
.
open
(
'
w
'
);
done
();
}
catch
(
error
)
{
console
.
info
(
'
MediaLibraryTest : SUB_MEDIA_MEDIALIBRARY_OPENANDCLOSE_ASSET_PROMISE_005_06 error:
'
+
error
);
expect
(
true
).
assertTrue
();
if
(
fd
>
0
)
{
asset
.
close
(
fd
);
}
done
();
}
});
//======================== ALBUM END ==================================
//======================== IMAGE BEGIN ==================================
/**
* @tc.number : SUB_MEDIA_MEDIALIBRARY_OPENANDCLOSE_ASSET_PROMISE_005_07
...
...
multimedia/medialibrary/mediaLibrary_js_standard/src/main/js/test/getPermission.test.js
浏览文件 @
aeb042d9
...
...
@@ -18,9 +18,16 @@ import abilityAccessCtrl from '@ohos.abilityAccessCtrl';
import
bundle
from
'
@ohos.bundle
'
;
import
account
from
'
@ohos.account.osAccount
'
describe
(
"
get_permission
"
,
async
function
()
{
let
userId
=
await
account
.
getAccountManager
().
getOsAccountLocalldFromProcess
();
console
.
info
(
'
userId :
'
+
userId
);
describe
(
"
get_permission
"
,
function
()
{
let
userId
;
async
function
getUserId
()
{
await
account
.
getAccountManager
().
getOsAccountLocalIdFromProcess
().
then
(
account
=>
{
console
.
info
(
"
getOsAccountLocalIdFromProcess userid ==========
"
+
account
);
userId
=
account
;
}).
catch
(
err
=>
{
console
.
info
(
"
getOsAccountLocalIdFromProcess err ==========
"
+
JSON
.
stringify
(
err
));
})
}
/**
* @tc.number SUB_DF_GRANT_USER_GRANTED_PERMISSION_0000
* @tc.name grant_user_granted_permission_async_000
...
...
@@ -31,6 +38,7 @@ describe("get_permission", async function () {
* @tc.require
*/
it
(
"
grant_user_granted_permission_async_000
"
,
0
,
async
function
(
done
)
{
await
getUserId
();
let
appInfo
=
await
bundle
.
getApplicationInfo
(
'
ohos.acts.multimedia.mediaLibrary
'
,
0
,
userId
);
let
tokenID
=
appInfo
.
accessTokenId
;
let
atManager
=
abilityAccessCtrl
.
createAtManager
();
...
...
multimedia/medialibrary/mediaLibrary_js_standard/src/main/js/test/mediaLibraryTestPromise.test.js
浏览文件 @
aeb042d9
...
...
@@ -284,10 +284,15 @@ describe('mediaLibraryTestPromise.test.js', function () {
selectionArgs
:
[
'
abc
'
],
};
try
{
media
.
getFileAssets
(
fetchOp
).
then
((
err
,
fetchFileResult
)
=>
{
expect
(
err
!=
undefined
).
assertTrue
();
don
e
();
media
.
getFileAssets
(
fetchOp
).
then
((
fetchFileResult
)
=>
{
expect
(
false
).
assertTru
e
();
})
.
catch
((
err
)
=>
{
expect
(
err
!=
undefined
).
assertTrue
();
})
done
();
}
catch
(
error
)
{
console
.
info
(
`MediaLibraryTest : getFileAssets 008 passed`
);
expect
(
true
).
assertTrue
();
...
...
@@ -309,10 +314,15 @@ describe('mediaLibraryTestPromise.test.js', function () {
selectionArgs
:
[
'
abc
'
,
audioType
.
toString
()],
};
try
{
media
.
getFileAssets
(
fetchOp
).
then
((
err
,
fetchFileResult
)
=>
{
expect
(
err
!=
undefined
).
assertTrue
();
don
e
();
media
.
getFileAssets
(
fetchOp
).
then
((
fetchFileResult
)
=>
{
expect
(
false
).
assertTru
e
();
})
.
catch
((
err
)
=>
{
expect
(
err
!=
undefined
).
assertTrue
();
})
done
();
}
catch
(
error
)
{
console
.
info
(
'
MediaLibraryTest : getFileAssets 009 passed
'
);
expect
(
true
).
assertTrue
();
...
...
@@ -340,10 +350,14 @@ describe('mediaLibraryTestPromise.test.js', function () {
selectionArgs
:
[
'
abc
'
,
videoType
.
toString
(),
fileType
.
toString
()],
};
try
{
media
.
getFileAssets
(
fetchOp
).
then
((
err
,
fetchFileResult
)
=>
{
expect
(
err
!=
undefined
).
assertTrue
();
don
e
();
media
.
getFileAssets
(
fetchOp
).
then
((
fetchFileResult
)
=>
{
expect
(
false
).
assertTru
e
();
})
.
catch
((
err
)
=>
{
expect
(
err
!=
undefined
).
assertTrue
();
})
done
();
}
catch
(
error
)
{
console
.
info
(
'
MediaLibraryTest : getFileAssets 010 passed
'
);
expect
(
true
).
assertTrue
();
...
...
@@ -373,14 +387,14 @@ describe('mediaLibraryTestPromise.test.js', function () {
selectionArgs
:
[
'
abc
'
,
videoType
.
toString
(),
fileType
.
toString
(),
audioType
.
toString
()],
};
try
{
// await media.getFileAssets(fetchOp);
// console.info('MediaLibraryTest : getFileAssets 011 failed');
// expect(false).assertTrue();
// done();
media
.
getFileAssets
(
fetchOp
).
then
((
err
,
fetchFileResult
)
=>
{
expect
(
err
!=
undefined
).
assertTrue
();
done
();
media
.
getFileAssets
(
fetchOp
).
then
((
fetchFileResult
)
=>
{
expect
(
false
).
assertTrue
();
})
.
catch
((
err
)
=>
{
expect
(
err
!=
undefined
).
assertTrue
();
})
done
();
}
catch
(
error
)
{
console
.
info
(
'
MediaLibraryTest : getFileAssets 011 passed
'
);
expect
(
true
).
assertTrue
();
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录