提交 786949fd 编写于 作者: W wuhao 提交者: Gitee

Merge branch 'master' of gitee.com:openharmony/xts_acts into master

Signed-off-by: Nwuhao <wuhao30@huawei.com>
......@@ -14,7 +14,7 @@
*/
import Ability from '@ohos.application.Ability'
import AbilityDelegatorRegistry from '@ohos.application.abilityDelegatorRegistry'
import { Hypium } from 'hypium/index'
import { Hypium } from '@ohos/hypium'
import testsuite from '../test/List.test'
export default class MainAbility extends Ability {
......
......@@ -12,7 +12,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from 'hypium/index'
import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from '@ohos/hypium'
import abilityDelegatorRegistry from '@ohos.application.abilityDelegatorRegistry'
import Subscriber from '@ohos.commonEvent'
......
......@@ -47,6 +47,14 @@ var subscriberInfo = {
var caseDepBundles = [];
var subscriber = null;
const ERROR_CODE_INVALID_PARAM = 401;
const ERROR_CODE_CALLER_RELEASED = 16200001;
const ERROR_CODE_CLAAEE_INVALID = 16200002;
const ERROR_CODE_FUNC_REGISTERED = 16200004;
const ERROR_CODE_FUNC_NOT_EXIST = 16200005;
const ERROR_CODE_INNER_ERROR = 16000050;
const ERROR_CODE_TYPE_ERROR = 16000002;
class MySequenceable {
num: number = 0;
str: String = "default";
......@@ -588,19 +596,21 @@ export default function abilityTest() {
*/
it('ACTS_CommonComponent_Call_1700', 0, async function (done) {
console.log('ACTS_CommonComponent_Call_1700 begin');
var caller;
var exceptionFlag = false;
try {
caller = await globalThis.globalThis.abilityContext.startAbilityByCall({
bundleName: systemAppCalleeABundleName,
abilityName: systemAppCalleeAThirdAbilityName,
});
} catch(err) {
console.log('ACTS_CommonComponent_Call_1700 exception' + err);
await globalThis.globalThis.abilityContext.startAbilityByCall({
bundleName: systemAppCalleeABundleName,
abilityName: systemAppCalleeAThirdAbilityName,
}).then(data => {
expect().assertFail();
done();
}).catch(err => {
console.log('ACTS_CommonComponent_Call_1700 call err.code: ' + JSON.stringify(err.code) +
' err.msg: ' + JSON.stringify(err.message));
expect(err.code).assertEqual(ERROR_CODE_TYPE_ERROR);
exceptionFlag = true;
expect(err.message).assertEqual("function request remote error");
}
});
expect(exceptionFlag).assertEqual(true);
done();
})
......@@ -655,8 +665,9 @@ export default function abilityTest() {
try {
globalThis.callee.on('', onTest);
} catch (err) {
console.log('ACTS_CommonComponent_Call_3100 callee.on err' + err);
expect(err.message).assertEqual("function input parameter error");
console.log('ACTS_CommonComponent_Call_3100 call err.code: ' + JSON.stringify(err.code) +
' err.msg: ' + JSON.stringify(err.message));
expect(err.code).assertEqual(ERROR_CODE_INVALID_PARAM);
finishFlag = 1;
}
......@@ -680,8 +691,9 @@ export default function abilityTest() {
try {
globalThis.callee.on(null, onTest);
} catch (err) {
console.log('ACTS_CommonComponent_Call_3200 callee.on err' + err);
expect(err.message).assertEqual("function input parameter error");
console.log('ACTS_CommonComponent_Call_3200 call err.code: ' + JSON.stringify(err.code) +
' err.msg: ' + JSON.stringify(err.message));
expect(err.code).assertEqual(ERROR_CODE_INVALID_PARAM);
finishFlag = 1;
}
......@@ -705,8 +717,9 @@ export default function abilityTest() {
try {
globalThis.callee.on(undefined, onTest);
} catch (err) {
console.log('ACTS_CommonComponent_Call_3300 callee.on err' + err);
expect(err.message).assertEqual("function input parameter error");
console.log('ACTS_CommonComponent_Call_3300 call err.code: ' + JSON.stringify(err.code) +
' err.msg: ' + JSON.stringify(err.message));
expect(err.code).assertEqual(ERROR_CODE_INVALID_PARAM);
finishFlag = 1;
}
......@@ -726,8 +739,9 @@ export default function abilityTest() {
try {
globalThis.callee.off('');
} catch (err) {
console.log('ACTS_CommonComponent_Call_3400 callee.off err' + err);
expect(err.message).assertEqual("function input parameter error");
console.log('ACTS_CommonComponent_Call_3400 call err.code: ' + JSON.stringify(err.code) +
' err.msg: ' + JSON.stringify(err.message));
expect(err.code).assertEqual(ERROR_CODE_INVALID_PARAM);
finishFlag = 1;
}
......@@ -747,8 +761,9 @@ export default function abilityTest() {
try {
globalThis.callee.off(null);
} catch (err) {
console.log('ACTS_CommonComponent_Call_3500 callee.off err' + err);
expect(err.message).assertEqual("function input parameter error");
console.log('ACTS_CommonComponent_Call_3500 call err.code: ' + JSON.stringify(err.code) +
' err.msg: ' + JSON.stringify(err.message));
expect(err.code).assertEqual(ERROR_CODE_INVALID_PARAM);
finishFlag = 1;
}
......@@ -768,8 +783,9 @@ export default function abilityTest() {
try {
globalThis.callee.off(undefined);
} catch (err) {
console.log('ACTS_CommonComponent_Call_3600 callee.off err' + err);
expect(err.message).assertEqual("function input parameter error");
console.log('ACTS_CommonComponent_Call_3600 call err.code: ' + JSON.stringify(err.code) +
' err.msg: ' + JSON.stringify(err.message));
expect(err.code).assertEqual(ERROR_CODE_INVALID_PARAM);
finishFlag = 1;
}
......@@ -788,8 +804,9 @@ export default function abilityTest() {
try {
globalThis.callee.on('testCall', "");
} catch (err) {
console.log('ACTS_CommonComponent_Call_4300 call err' + err);
expect(err.message).assertEqual("function input parameter error");
console.log('ACTS_CommonComponent_Call_4300 call err.code: ' + JSON.stringify(err.code) +
' err.msg: ' + JSON.stringify(err.message));
expect(err.code).assertEqual(ERROR_CODE_INVALID_PARAM);
finishFlag = 1;
}
......@@ -808,8 +825,9 @@ export default function abilityTest() {
try {
globalThis.callee.on('testCall', null);
} catch (err) {
console.log('ACTS_CommonComponent_Call_4400 call err' + err);
expect(err.message).assertEqual("function input parameter error");
console.log('ACTS_CommonComponent_Call_4400 call err.code: ' + JSON.stringify(err.code) +
' err.msg: ' + JSON.stringify(err.message));
expect(err.code).assertEqual(ERROR_CODE_INVALID_PARAM);
finishFlag = 1;
}
......@@ -828,8 +846,9 @@ export default function abilityTest() {
try {
globalThis.callee.on('testCall', undefined);
} catch (err) {
console.log('ACTS_CommonComponent_Call_4500 call err' + err);
expect(err.message).assertEqual("function input parameter error");
console.log('ACTS_CommonComponent_Call_4500 call err.code: ' + JSON.stringify(err.code) +
' err.msg: ' + JSON.stringify(err.message));
expect(err.code).assertEqual(ERROR_CODE_INVALID_PARAM);
finishFlag = 1;
}
......@@ -861,8 +880,9 @@ export default function abilityTest() {
try {
globalThis.callee.on('ACTS_CommonComponent_Call_5000', testCallback_5100);
} catch (err) {
console.log('ACTS_CommonComponent_Call_5000 call err' + err);
expect(err.message).assertEqual("function is registered");
console.log('ACTS_CommonComponent_Call_5000 call err.code: ' + JSON.stringify(err.code) +
' err.msg: ' + JSON.stringify(err.message));
expect(err.code).assertEqual(ERROR_CODE_FUNC_REGISTERED);
finishFlag = 1;
}
......@@ -897,8 +917,9 @@ export default function abilityTest() {
try {
globalThis.callee.off('ACTS_CommonComponent_Call_5100');
} catch (err) {
console.log('ACTS_CommonComponent_Call_5100 call err' + err);
expect(err.message).assertEqual("function not registered");
console.log('ACTS_CommonComponent_Call_5100 call err.code: ' + JSON.stringify(err.code) +
' err.msg: ' + JSON.stringify(err.message));
expect(err.code).assertEqual(ERROR_CODE_FUNC_NOT_EXIST);
finishFlag = 1;
}
......@@ -914,17 +935,19 @@ export default function abilityTest() {
*/
it('ACTS_CommonComponent_Call_5200', 0, async function (done) {
console.log('ACTS_CommonComponent_Call_5200 begin');
let caller;
let exceptionFlag = false;
try {
caller = await globalThis.globalThis.abilityContext.startAbilityByCall(null);
console.log('ACTS_CommonComponent_Call_5200 startAbilityByCall' + JSON.stringify(caller))
} catch(err) {
console.log('ACTS_CommonComponent_Call_5200 exception' + err);
exceptionFlag = true;
expect(err.message).assertEqual("function input parameter error");
}
await globalThis.globalThis.abilityContext.startAbilityByCall(null)
.then(data => {
expect().assertFail();
done();
}).catch(err => {
console.log('ACTS_CommonComponent_Call_5200 call err.code: ' + JSON.stringify(err.code) +
' err.msg: ' + JSON.stringify(err.message));
expect(err.code).assertEqual(ERROR_CODE_INVALID_PARAM);
exceptionFlag = true;
});
expect(exceptionFlag).assertEqual(true);
done();
......@@ -937,20 +960,20 @@ export default function abilityTest() {
*/
it('ACTS_CommonComponent_Call_5300', 0, async function (done) {
console.log('ACTS_CommonComponent_Call_5300 begin');
let caller;
let exceptionFlag = false;
try {
caller = await globalThis.globalThis.abilityContext.startAbilityByCall({
bundleName: "",
abilityName: "",
});
console.log('ACTS_CommonComponent_Call_5300 startAbilityByCall' + JSON.stringify(caller))
} catch(err) {
console.log('ACTS_CommonComponent_Call_5300 exception' + err);
await globalThis.globalThis.abilityContext.startAbilityByCall({
bundleName: "",
abilityName: "",
}).then(data => {
expect().assertFail();
done();
}).catch(err => {
console.log('ACTS_CommonComponent_Call_5300 call err.code: ' + JSON.stringify(err.code) +
' err.msg: ' + JSON.stringify(err.message));
expect(err.code).assertEqual(ERROR_CODE_INNER_ERROR);
exceptionFlag = true;
expect(err.message).assertEqual("function request remote error");
}
});
expect(exceptionFlag).assertEqual(true);
done();
......@@ -963,17 +986,18 @@ export default function abilityTest() {
*/
it('ACTS_CommonComponent_Call_5400', 0, async function (done) {
console.log('ACTS_CommonComponent_Call_5400 begin');
let caller;
let exceptionFlag = false;
try {
caller = await globalThis.globalThis.abilityContext.startAbilityByCall(undefined);
console.log('ACTS_CommonComponent_Call_5400 startAbilityByCall' + JSON.stringify(caller))
} catch(err) {
console.log('ACTS_CommonComponent_Call_5400 exception' + err);
await globalThis.globalThis.abilityContext.startAbilityByCall(undefined)
.then(data => {
expect().assertFail();
done();
}).catch(err => {
console.log('ACTS_CommonComponent_Call_5400 call err.code: ' + JSON.stringify(err.code) +
' err.msg: ' + JSON.stringify(err.message));
expect(err.code).assertEqual(ERROR_CODE_INVALID_PARAM);
exceptionFlag = true;
expect(err.message).assertEqual("function input parameter error");
}
});
expect(exceptionFlag).assertEqual(true);
done();
......
......@@ -134,21 +134,21 @@ export default function singleusermodelTest() {
*/
it('ACTS_SingleUserModel_1600', 0, async function (done) {
console.debug("====>start startAbilityWithAccount====>");
console.info("====>start startAbilityWithAccount====>");
try {
await globalThis.abilityContext.startAbilityWithAccount(
{
bundleName: 'com.singleusermodel.actssingleusertest',
abilityName: 'SingleUserModel1600'
}, null).then((data) => {
console.debug("====>startAbilityWithAccount 1600 end====>" + data);
console.info("====>startAbilityWithAccount 1600 end====>" + data);
}).catch((err) => {
console.debug("====>startAbilityWithAccount 1600 end====>" + err);
console.info("====>startAbilityWithAccount 1600 end====>" + err);
})
} catch (err) {
let e = err.toString()
let errLog = "Cannot read property then of undefined"
console.debug("====>e====>" + e);
let errLog = "Invalid input parameter"
console.info("ACTS_SingleUserModel_1600 ====>e====>" + e);
expect(e.indexOf(errLog) >= 0).assertTrue()
}
setTimeout(async () => {
......@@ -176,7 +176,7 @@ export default function singleusermodelTest() {
console.debug('ACTS_SingleUserModel_1600====>timeout====>');
}, START_ABILITY_TIMEOUT)
setTimeout(() => {
console.debug('ACTS_SingleUserModel_1600====>done====>');
console.info('ACTS_SingleUserModel_1600====>done====>');
done();
}, ABILITY_TIMEOUT)
})
......@@ -202,7 +202,7 @@ export default function singleusermodelTest() {
})
} catch (err) {
let e = err.toString()
let errLog = "Cannot read property then of undefined"
let errLog = "Invalid input parameter"
console.debug("====>e====>" + e);
expect(e.indexOf(errLog) >= 0).assertTrue()
}
......
......@@ -182,23 +182,30 @@ export default function singleusermodelTest() {
*/
it('ACTS_ExtensionSingleUserModel_0700', 0, async function (done) {
console.log("ACTS_ExtensionSingleUserModel_0700====>callback start====>");
let connId;
console.debug("====>start connectAbilityWithAccount====>");
connId = globalThis.abilityContext.connectAbilityWithAccount(
{
bundleName: "com.singleusermodel.actssingleusertest",
abilityName: "ServiceAbility3",
action: "StartAbilityPromise"
},
null,
{
onConnect: onConnectCallbackC,
onDisconnect: onDisconnectCallbackC,
onFailed: onFailedCallbackC,
}
);
console.log('ACTS_ExtensionSingleUserModel_0700====>StartConnectNative ' +
'connectAbilityWithAccount connId : ' + connId);
try {
let connId;
console.debug("====>start connectAbilityWithAccount====>");
connId = globalThis.abilityContext.connectAbilityWithAccount(
{
bundleName: "com.singleusermodel.actssingleusertest",
abilityName: "ServiceAbility3",
action: "StartAbilityPromise"
},
null,
{
onConnect: onConnectCallbackC,
onDisconnect: onDisconnectCallbackC,
onFailed: onFailedCallbackC,
}
);
console.log('ACTS_ExtensionSingleUserModel_0700====>StartConnectNative ' +
'connectAbilityWithAccount connId : ' + connId);
} catch (err) {
let e = err.toString()
let errLog = "Invalid input parameter"
console.debug("====>e====>" + e);
expect(e.indexOf(errLog) >= 0).assertTrue()
}
setTimeout(async () => {
let abilityDelegator = undefined
......@@ -318,23 +325,30 @@ export default function singleusermodelTest() {
*/
it('ACTS_ExtensionSingleUserModel_1300', 0, async function (done) {
console.log("ACTS_ExtensionSingleUserModel_1300====>callback start====>");
let connId;
try {
let connId;
connId = globalThis.abilityContext.connectAbilityWithAccount(
{
bundleName: "com.singleusermodel.actssingleusertest",
abilityName: "ServiceAbility5",
action: "StartAbilityPromise"
},
undefined,
{
onConnect: onConnectCallbackE,
onDisconnect: onDisconnectCallbackE,
onFailed: onFailedCallbackE,
}
);
console.log('ACTS_ExtensionSingleUserModel_1300====>StartConnectNative ' +
'connectAbilityWithAccount connId : ' + connId);
} catch (err) {
let e = err.toString()
let errLog = "Invalid input parameter"
console.debug("====>e====>" + e);
expect(e.indexOf(errLog) >= 0).assertTrue()
}
connId = globalThis.abilityContext.connectAbilityWithAccount(
{
bundleName: "com.singleusermodel.actssingleusertest",
abilityName: "ServiceAbility5",
action: "StartAbilityPromise"
},
undefined,
{
onConnect: onConnectCallbackE,
onDisconnect: onDisconnectCallbackE,
onFailed: onFailedCallbackE,
}
);
console.log('ACTS_ExtensionSingleUserModel_1300====>StartConnectNative ' +
'connectAbilityWithAccount connId : ' + connId);
setTimeout(async () => {
let abilityDelegator = undefined
abilityDelegator = AbilityDelegatorRegistry.getAbilityDelegator()
......
......@@ -183,24 +183,31 @@ export default function singleusermodelTest() {
*/
it('ACTS_ExtensionSingleUserModel_1600', 0, async function(done){
console.log("ACTS_ExtensionSingleUserModel_1600====>callback start====>");
let connId;
console.debug("====>start connectAbilityWithAccount====>");
connId = globalThis.abilityContext.connectAbilityWithAccount(
{
bundleName: "com.singleusermodel.actssingleusertest",
abilityName: "ServiceAbility3",
action: "StartAbilityPromise"
},
null,
{
onConnect: onConnectCallbackC,
onDisconnect: onDisconnectCallbackC,
onFailed: onFailedCallbackC,
}
);
console.log('ACTS_ExtensionSingleUserModel_1600====>StartConnectNative ' +
'connectAbilityWithAccount connId : ' + connId);
try {
let connId;
console.debug("====>start connectAbilityWithAccount====>");
connId = globalThis.abilityContext.connectAbilityWithAccount(
{
bundleName: "com.singleusermodel.actssingleusertest",
abilityName: "ServiceAbility3",
action: "StartAbilityPromise"
},
null,
{
onConnect: onConnectCallbackC,
onDisconnect: onDisconnectCallbackC,
onFailed: onFailedCallbackC,
}
);
console.log('ACTS_ExtensionSingleUserModel_1600====>StartConnectNative ' +
'connectAbilityWithAccount connId : ' + connId);
} catch (err) {
let e = err.toString()
let errLog = "Invalid input parameter"
console.debug("====>e====>" + e);
expect(e.indexOf(errLog) >= 0).assertTrue()
}
setTimeout(async()=> {
let abilityDelegator = undefined
......@@ -323,22 +330,31 @@ export default function singleusermodelTest() {
*/
it('ACTS_ExtensionSingleUserModel_1900', 0, async function(done){
console.log("ACTS_ExtensionSingleUserModel_1900====>callback start====>");
let connId;
connId = globalThis.abilityContext.connectAbilityWithAccount(
{
bundleName: "com.singleusermodel.actssingleusertest",
abilityName: "ServiceAbility5",
action: "StartAbilityPromise"
},
undefined,
{
onConnect: onConnectCallbackE,
onDisconnect: onDisconnectCallbackE,
onFailed: onFailedCallbackE,
}
);
console.log('ACTS_ExtensionSingleUserModel_1900====>StartConnectNative ' +
'connectAbilityWithAccount connId : ' + connId);
try {
let connId;
connId = globalThis.abilityContext.connectAbilityWithAccount(
{
bundleName: "com.singleusermodel.actssingleusertest",
abilityName: "ServiceAbility5",
action: "StartAbilityPromise"
},
undefined,
{
onConnect: onConnectCallbackE,
onDisconnect: onDisconnectCallbackE,
onFailed: onFailedCallbackE,
}
);
console.log('ACTS_ExtensionSingleUserModel_1900====>StartConnectNative ' +
'connectAbilityWithAccount connId : ' + connId);
} catch (err) {
let e = err.toString()
let errLog = "Invalid input parameter"
console.debug("====>e====>" + e);
expect(e.indexOf(errLog) >= 0).assertTrue()
}
setTimeout(async()=> {
let abilityDelegator = undefined
abilityDelegator = AbilityDelegatorRegistry.getAbilityDelegator()
......
......@@ -150,7 +150,7 @@ export default function singleusermodelTest() {
})
} catch (err) {
let e = err.toString();
let errLog = "Cannot read property then of undefined"
let errLog = "Invalid input parameter"
console.debug("====>e====>" + e);
expect(e.indexOf(errLog) >= 0).assertTrue()
}
......@@ -252,7 +252,7 @@ export default function singleusermodelTest() {
})
} catch (err) {
let e = err.toString();
let errLog = "Cannot read property then of undefined"
let errLog = "Invalid input parameter"
console.debug("====>e====>" + e);
expect(e.indexOf(errLog) >= 0).assertTrue()
}
......
......@@ -46,9 +46,13 @@ export default class MainAbility extends Ability {
onForeground() {
console.log("MainAbility3 onForeground")
globalThis.abilityContext3.terminateSelfWithResult({
resultCode: 1
})
try {
globalThis.abilityContext3.terminateSelfWithResult({
resultCode: 1
})
} catch (error) {
}
}
onBackground() {
......
......@@ -24,9 +24,9 @@ import appManager from '@ohos.application.appManager'
import applicationContext from '@ohos.application.context'
import commonEvent from '@ohos.commonEvent';
import ability from '@ohos.ability.ability'
FormDimension
var EXTENSION_INFO_ERR = 2097152
var USERID_ERR = 2097177
var EXTENSION_INFO_ERR = 16000001
var CROSS_USER_DENY = 201
var trueInfo;
var array = new Array();
function sleep(time) {
......@@ -102,7 +102,7 @@ export default function ApiCoverTest() {
expect("case execute failed").assertEqual("data");
}).catch((error) => {
console.error(`Ability: startServiceExtensionAbilityWithAccount failed: ${JSON.stringify(error)}`);
expect(USERID_ERR).assertEqual(error.code);
expect(CROSS_USER_DENY).assertEqual(error.code);
})
done()
})
......@@ -124,7 +124,7 @@ export default function ApiCoverTest() {
expect("case execute failed").assertEqual(data);
}).catch((error) => {
console.error(`Ability: stopServiceExtensionAbilityWithAccount failed: ${JSON.stringify(error)}`);
expect(USERID_ERR).assertEqual(error.code);
expect(CROSS_USER_DENY).assertEqual(error.code);
})
done()
})
......@@ -193,7 +193,7 @@ export default function ApiCoverTest() {
await globalThis.abilityContext.startServiceExtensionAbilityWithAccount(want, 999, (err, data) => {
if (err.code) {
console.error(`Ability: startServiceExtensionAbilityWithAccount failed: ${JSON.stringify(err)}`);
expect(USERID_ERR).assertEqual(err.code);
expect(CROSS_USER_DENY).assertEqual(err.code);
} else {
console.log(`Ability: startServiceExtensionAbilityWithAccount success: ${JSON.stringify(data)}`);
expect("case execute failed").assertEqual(data);
......@@ -217,7 +217,7 @@ export default function ApiCoverTest() {
globalThis.abilityContext.stopServiceExtensionAbilityWithAccount(want, 999, (err, data) => {
if (err.code) {
console.error(`Ability: stopServiceExtensionAbilityWithAccount failed: ${JSON.stringify(err)}`);
expect(USERID_ERR).assertEqual(err.code);
expect(CROSS_USER_DENY).assertEqual(err.code);
} else {
console.log(`Ability: stopServiceExtensionAbilityWithAccount success: ${JSON.stringify(data)}`);
expect("case execute failed").assertEqual(data);
......
......@@ -18,6 +18,7 @@ import AbilityConstant from "@ohos.application.AbilityConstant";
import appManager from "@ohos.application.appManager";
import wantConstant from '@ohos.ability.wantConstant';
var INVALID_PARAM = 401
var TAG
export default function verificationTest(){
......@@ -280,34 +281,34 @@ export default function verificationTest(){
*/
it('SUB_AA_OpenHarmony_SetMissionLabel_0100', 0, async function(done) {
TAG = 'SUB_AA_OpenHarmony_SetMissionLabel_0100 ==>';
let label = undefined;
let code1 = 0;
let code2 = 0;
try {
let label = undefined
let code1 = 0
let code2 = 0
globalThis.abilityContext.setMissionLabel(label).then((data) => {
await globalThis.abilityContext.setMissionLabel(label).then((data) => {
console.info(TAG + "setMissionLabel data = " + JSON.stringify(data));
}).catch((err) => {
code1 = err.code
console.info(TAG + "setMissionLabel err = " + JSON.stringify(err));
});
} catch (err) {
console.info(TAG + "setMissionLabel err = " + JSON.stringify(err));
expect(err.code).assertEqual(INVALID_PARAM);
}
globalThis.abilityContext.setMissionLabel(label, (err, data) => {
try {
await globalThis.abilityContext.setMissionLabel(label, (err, data) => {
code2 = err.code
console.info(TAG + "setMissionLabel err = " + JSON.stringify(err));
console.info(TAG + "setMissionLabel data = " + JSON.stringify(data));
})
setTimeout(()=>{
expect(code1).assertEqual(-1);
expect(code2).assertEqual(-1);
done()
}, 3000)
} catch (err) {
console.info(TAG + "catch err = " + JSON.stringify(err));
expect().assertFail();
done();
console.info(TAG + "setMissionLabel err = " + JSON.stringify(err));
expect(err.code).assertEqual(INVALID_PARAM);
}
done();
})
/*
......
......@@ -14,7 +14,7 @@
*/
import Ability from '@ohos.application.Ability'
import AbilityDelegatorRegistry from '@ohos.application.abilityDelegatorRegistry'
import { Hypium } from 'hypium/index'
import { Hypium } from '@ohos/hypium'
import testsuite from '../test/List.test'
export default class TestAbility extends Ability {
......
......@@ -12,7 +12,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from 'hypium/index'
import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from '@ohos/hypium'
import commonEvent from '@ohos.commonEvent'
var subscriberInfo_MainAbility = {
......
......@@ -30,6 +30,8 @@ export default function actsCreateModuleContextTest() {
it("SUB_AA_CreateModuleContext_0100", 0, async function (done) {
console.info("SUB_AA_AbilityStage_0100 begin");
createModuleContext = null;
createModuleContext =
globalThis.abilityContext.createModuleContext("entry_test");
......@@ -47,7 +49,9 @@ export default function actsCreateModuleContextTest() {
* @tc.level: 3
*/
it("SUB_AA_CreateModuleContext_0200", 0, async function (done) {
console.log("SUB_AA_AbilityStage_0100 begin");
console.log("SUB_AA_CreateModuleContext_0200 begin");
createModuleContext = null;
createModuleContext =
globalThis.abilityContext.createModuleContext("feature");
......@@ -68,10 +72,19 @@ export default function actsCreateModuleContextTest() {
it("SUB_AA_CreateModuleContext_0300", 0, async function (done) {
console.info("SUB_AA_CreateModuleContext_0300 begin");
createModuleContext =
globalThis.abilityContext.createModuleContext("entry_assist");
createModuleContext = null;
try {
createModuleContext =
globalThis.abilityContext.createModuleContext("entry_assist");
} catch (err) {
let e = err.toString();
let errLog = "Invalid input parameter"
console.debug("====>e====>" + e);
expect(e.indexOf(errLog) >= 0).assertTrue();
}
expect(createModuleContext).assertUndefined();
expect(createModuleContext).assertEqual(null);
done();
});
......@@ -84,10 +97,19 @@ export default function actsCreateModuleContextTest() {
it("SUB_AA_CreateModuleContext_0400", 0, async function (done) {
console.info("SUB_AA_CreateModuleContext_0400 begin");
createModuleContext =
globalThis.abilityContext.createModuleContext("abc");
createModuleContext = null;
try {
createModuleContext =
globalThis.abilityContext.createModuleContext("abc");
} catch (err) {
let e = err.toString();
let errLog = "Invalid input parameter"
console.debug("====>e====>" + e);
expect(e.indexOf(errLog) >= 0).assertTrue();
}
expect(createModuleContext).assertUndefined();
expect(createModuleContext).assertEqual(null);
done();
});
......@@ -100,10 +122,20 @@ export default function actsCreateModuleContextTest() {
it("SUB_AA_CreateModuleContext_0500", 0, async function (done) {
console.info("SUB_AA_CreateModuleContext_0500 begin");
createModuleContext =
globalThis.abilityContext.createModuleContext(undefined);
createModuleContext = null;
try {
createModuleContext =
globalThis.abilityContext.createModuleContext(undefined);
} catch (err) {
let e = err.toString();
let errLog = "Invalid input parameter"
console.info("SUB_AA_CreateModuleContext_0500 createModuleContext is " + JSON.stringify(createModuleContext));
console.debug("====>e====>" + e);
expect(e.indexOf(errLog) >= 0).assertTrue();
}
expect(createModuleContext).assertUndefined();
expect(createModuleContext).assertEqual(null);
done();
});
......@@ -117,6 +149,8 @@ export default function actsCreateModuleContextTest() {
it("SUB_AA_CreateModuleContext_0600", 0, async function (done) {
console.info("SUB_AA_CreateModuleContext_0600 begin");
createModuleContext = null;
createModuleContext =
globalThis.abilityStageContext.createModuleContext("entry_test");
......@@ -136,6 +170,8 @@ export default function actsCreateModuleContextTest() {
it("SUB_AA_CreateModuleContext_0700", 0, async function (done) {
console.info("SUB_AA_CreateModuleContext_0700 begin");
createModuleContext = null;
createModuleContext =
globalThis.abilityStageContext.createModuleContext("feature");
......@@ -155,10 +191,19 @@ export default function actsCreateModuleContextTest() {
it("SUB_AA_CreateModuleContext_0800", 0, async function (done) {
console.info("SUB_AA_CreateModuleContext_0800 begin");
createModuleContext =
globalThis.abilityContext.createModuleContext("entry_assist");
createModuleContext = null;
try {
createModuleContext =
globalThis.abilityContext.createModuleContext("entry_assist");
} catch (err) {
let e = err.toString();
let errLog = "Invalid input parameter"
console.debug("====>e====>" + e);
expect(e.indexOf(errLog) >= 0).assertTrue();
}
expect(createModuleContext).assertUndefined();
expect(createModuleContext).assertEqual(null);
done();
});
......@@ -171,10 +216,19 @@ export default function actsCreateModuleContextTest() {
it("SUB_AA_CreateModuleContext_0900", 0, async function (done) {
console.info("SUB_AA_CreateModuleContext_0900 begin");
createModuleContext =
globalThis.abilityContext.createModuleContext("createmodue");
createModuleContext = null;
try {
createModuleContext =
globalThis.abilityContext.createModuleContext("createmodue");
} catch (err) {
let e = err.toString();
let errLog = "Invalid input parameter"
console.debug("====>e====>" + e);
expect(e.indexOf(errLog) >= 0).assertTrue();
}
expect(createModuleContext).assertUndefined();
expect(createModuleContext).assertEqual(null);
done();
});
......@@ -187,10 +241,20 @@ export default function actsCreateModuleContextTest() {
it("SUB_AA_CreateModuleContext_1000", 0, async function (done) {
console.info("SUB_AA_CreateModuleContext_1000 begin");
createModuleContext =
globalThis.abilityStageContext.createModuleContext(undefined);
createModuleContext = null;
try {
createModuleContext =
globalThis.abilityStageContext.createModuleContext(undefined);
} catch (err) {
let e = err.toString();
let errLog = "Invalid input parameter"
console.info("SUB_AA_CreateModuleContext_1000 createModuleContext is " + JSON.stringify(createModuleContext));
console.debug("====>e====>" + e);
expect(e.indexOf(errLog) >= 0).assertTrue();
}
expect(createModuleContext).assertUndefined();
expect(createModuleContext).assertEqual(null);
done();
});
});
......
......@@ -24,7 +24,9 @@ import Prompt from '@system.prompt';
import abilityManager from '@ohos.application.abilityManager';
import commonEvent from '@ohos.commonEvent';
const SYSTEM_INNER_ERROR = 16000050
const ERR_COMPONENT_NOF_FOUND = 16000001
const ERR_NOT_TOP = 16000053
export default function startAbilityTest(abilityContext) {
describe('startAbilityTest', function () {
......@@ -228,7 +230,7 @@ export default function startAbilityTest(abilityContext) {
console.log(TAG + ": startAbility success. data: " + JSON.stringify(data));
}).catch((error) => {
console.log(TAG + ": startAbility fail. err: " + JSON.stringify(error));
expect(error.code == 4).assertTrue();
expect(error.code == SYSTEM_INNER_ERROR).assertTrue();
});
await sleep(2000);
console.info("------------end FreeInstall_Stage_Local_StartAbility_0300-------------");
......@@ -504,7 +506,7 @@ export default function startAbilityTest(abilityContext) {
console.log(TAG + ": startAbility success. data: " + JSON.stringify(data));
}).catch((error) => {
console.log(TAG + ": startAbility fail. err: " + JSON.stringify(error));
expect(error.code == 1).assertTrue();
expect(error.code == ERR_COMPONENT_NOF_FOUND).assertTrue();
});
await sleep(2000);
console.info("------------end FreeInstall_Stage_Local_StartAbility_1100-------------");
......@@ -568,7 +570,7 @@ export default function startAbilityTest(abilityContext) {
console.log(TAG + ": startAbility success. data: " + JSON.stringify(data));
}).catch((error) => {
console.log(TAG + ": startAbility fail. err: " + JSON.stringify(error));
expect(error.code == 1).assertTrue();
expect(error.code == ERR_COMPONENT_NOF_FOUND).assertTrue();
});
await sleep(2000);
console.info("------------end FreeInstall_Stage_Local_StartAbility_1300-------------");
......@@ -632,7 +634,7 @@ export default function startAbilityTest(abilityContext) {
console.log(TAG + ": startAbility success. data: " + JSON.stringify(data));
}).catch((error) => {
console.log(TAG + ": startAbility fail. err: " + JSON.stringify(error));
expect(error.code == 1).assertTrue();
expect(error.code == ERR_COMPONENT_NOF_FOUND).assertTrue();
});
await sleep(2000);
console.info("------------end FreeInstall_Stage_Local_StartAbility_1500-------------");
......@@ -694,7 +696,7 @@ export default function startAbilityTest(abilityContext) {
console.log(TAG + ": startAbility success. data: " + JSON.stringify(data));
}).catch((error) => {
console.log(TAG + ": startAbility fail. err: " + JSON.stringify(error));
expect(error.code == 1).assertTrue();
expect(error.code == ERR_COMPONENT_NOF_FOUND).assertTrue();
});
await sleep(2000);
console.info("------------end FreeInstall_Stage_Local_StartAbility_1700-------------");
......@@ -831,7 +833,7 @@ export default function startAbilityTest(abilityContext) {
console.log(TAG + ": startAbility success. data: " + JSON.stringify(data));
}).catch((error) => {
console.log(TAG + ": startAbility fail. err: " + JSON.stringify(error));
expect(error.code == 13).assertTrue();
expect(error.code == ERR_NOT_TOP).assertTrue();
});
await sleep(2000);
console.info("------------end FreeInstall_Stage_Local_StartAbility_2300-------------");
......@@ -866,7 +868,7 @@ export default function startAbilityTest(abilityContext) {
console.log(TAG + ": startAbility success. data: " + JSON.stringify(data));
}).catch((error) => {
console.log(TAG + ": startAbility fail. err: " + JSON.stringify(error));
expect(error.code == 13).assertTrue();
expect(error.code == ERR_NOT_TOP).assertTrue();
});
await sleep(2000);
console.info("------------end FreeInstall_Stage_Local_StartAbility_2400-------------");
......@@ -914,7 +916,7 @@ export default function startAbilityTest(abilityContext) {
console.log(TAG + ": startAbility success. data: " + JSON.stringify(data));
}).catch((error) => {
console.log(TAG + ": startAbility fail. err: " + JSON.stringify(error));
expect(error.code == 3).assertTrue();
expect(error.code == SYSTEM_INNER_ERROR).assertTrue();
});
await sleep(2000);
console.info("------------end FreeInstall_Stage_Local_StartAbility_2500-------------");
......@@ -1010,7 +1012,7 @@ export default function startAbilityTest(abilityContext) {
console.log(TAG + ": startAbility success. data: " + JSON.stringify(data));
}).catch((error) => {
console.log(TAG + ": startAbility fail. err: " + JSON.stringify(error));
expect(error.code == 4).assertTrue();
expect(error.code == SYSTEM_INNER_ERROR).assertTrue();
});
await sleep(2000);
console.info("------------end FreeInstall_Stage_Local_StartAbility_3100-------------");
......@@ -1049,7 +1051,7 @@ export default function startAbilityTest(abilityContext) {
console.log(TAG + ": startAbility success. data: " + JSON.stringify(data));
}).catch((error) => {
console.log(TAG + ": startAbility fail. err: " + JSON.stringify(error));
expect(error.code == 1).assertTrue();
expect(error.code == SYSTEM_INNER_ERROR).assertTrue();
});
await sleep(2000);
console.info("------------end FreeInstall_Stage_Local_StartAbility_3200-------------");
......@@ -1077,7 +1079,7 @@ export default function startAbilityTest(abilityContext) {
console.log(TAG + ": startAbility success. data: " + JSON.stringify(data));
}).catch((error) => {
console.log(TAG + ": startAbility fail. err: " + JSON.stringify(error));
expect(error.code == 1).assertTrue();
expect(error.code == SYSTEM_INNER_ERROR).assertTrue();
});
await sleep(2000);
console.info("------------end FreeInstall_Stage_Local_StartAbility_3300-------------");
......@@ -1181,7 +1183,7 @@ export default function startAbilityTest(abilityContext) {
console.log(TAG + ": startAbility success. data: " + JSON.stringify(data));
}).catch((error) => {
console.log(TAG + ": startAbility fail. err: " + JSON.stringify(error));
expect(error.code == 13).assertTrue();
expect(error.code == ERR_NOT_TOP).assertTrue();
});
await sleep(2000);
console.info("------------end FreeInstall_Stage_Local_StartAbility_1900-------------");
......@@ -1228,7 +1230,7 @@ export default function startAbilityTest(abilityContext) {
console.log(TAG + ": startAbility success. data: " + JSON.stringify(data));
}).catch((error) => {
console.log(TAG + ": startAbility fail. err: " + JSON.stringify(error));
expect(error.code == 13).assertTrue();
expect(error.code == ERR_NOT_TOP).assertTrue();
});
await sleep(2000);
console.info("------------end FreeInstall_Stage_Local_StartAbility_2000-------------");
......
......@@ -344,7 +344,7 @@ export default function ActsAccountAppAccess() {
appAccountManager.addAccount(name, (err)=>{
console.debug("====>ActsAccountDeleteAccountCredential_0100 add_account_err:" + JSON.stringify(err));
expect(err).assertEqual(null);
appAccountManager.setAccountCredential(name, "PIN", (err, data)=>{
appAccountManager.setAccountCredential(name, "PIN", '123456', (err, data)=>{
console.debug("====>ActsAccountDeleteAccountCredential_0100 setAccountCredential_err:" + JSON.stringify(err));
expect(err).assertEqual(null);
console.debug("====>ActsAccountDeleteAccountCredential_0100 setAccountCredential_data:" + JSON.stringify(data));
......@@ -384,7 +384,7 @@ export default function ActsAccountAppAccess() {
var appAccountManager = account.createAppAccountManager();
appAccountManager.addAccount(name, 'test_extraInfo').then((data) =>{
console.debug("====>ActsAccountDeleteAccountCredential_0200 add_account_success");
appAccountManager.setAccountCredential(name, "PIN").then(() =>{
appAccountManager.setAccountCredential(name, "PIN", '123456').then(() =>{
console.debug("====>ActsAccountDeleteAccountCredential_0200 setAccountCredential_success");
appAccountManager.getAccountCredential(name, "PIN").then((data) =>{
console.debug("====>ActsAccountDeleteAccountCredential_0200 getAccountCredential_data:" + JSON.stringify(data));
......
......@@ -16,10 +16,20 @@ import osaccount from '@ohos.account.osAccount'
import bundle from '@ohos.bundle'
import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from '@ohos/hypium'
const ERR_OS_ACCOUNT_SERVICE_MANAGER_BAD_UID_ERR = 4653057;
export default function ActsOsAccountThirdPartyTest_third_2() {
describe('ActsOsAccountThirdPartyTest_third_2', function () {
afterEach(async function (done) {
console.debug("====>afterEach start====");
var osAccountManager = osaccount.getAccountManager();
var accounts = await osAccountManager.queryAllCreatedOsAccounts()
for (i=0;i<accounts.length;i++){
var localId = accounts[i].localId
if(localId!=100){
await osAccountManager.removeOsAccount(localId)
}
}
done();
})
/*
* @tc.number : ActsOsAccountGetIdFormUid_0100
* @tc.name : getOsAccountLocalIdFromUid callback
......@@ -79,7 +89,7 @@ export default function ActsOsAccountThirdPartyTest_third_2() {
osAccountManager.getOsAccountLocalIdFromUid(incorrectUid, (err, localId)=>{
console.debug("====>get localId err: " + JSON.stringify(err));
console.debug("====>localId obtained by uid:" + localId);
expect(err.code).assertEqual(ERR_OS_ACCOUNT_SERVICE_MANAGER_BAD_UID_ERR);
expect(err.code !=0 ).assertEqual(true);
expect(localId).assertEqual(null);
console.debug("====>ActsOsAccountGetIdFormUid_0300 end====");
done();
......@@ -100,7 +110,7 @@ export default function ActsOsAccountThirdPartyTest_third_2() {
await osAccountManager.getOsAccountLocalIdFromUid(incorrectUid);
}catch(err){
console.debug("====>get localId by uid err:" +JSON.stringify(err));
expect(err.code).assertEqual(ERR_OS_ACCOUNT_SERVICE_MANAGER_BAD_UID_ERR);
expect(err.code !=0 ).assertEqual(true);
console.debug("====>ActsOsAccountGetIdFormUid_0400 end====");
done();
}
......@@ -119,7 +129,7 @@ export default function ActsOsAccountThirdPartyTest_third_2() {
osAccountManager.getOsAccountLocalIdFromUid(incorrectUid, (err, localId)=>{
console.debug("====>get localId err: " + JSON.stringify(err));
console.debug("====>localId obtained by uid:" + localId);
expect(err.code).assertEqual(ERR_OS_ACCOUNT_SERVICE_MANAGER_BAD_UID_ERR);
expect(err.code !=0 ).assertEqual(true);
expect(localId).assertEqual(null);
console.debug("====>ActsOsAccountGetIdFormUid_0500 end====");
done();
......@@ -140,7 +150,7 @@ export default function ActsOsAccountThirdPartyTest_third_2() {
await osAccountManager.getOsAccountLocalIdFromUid(incorrectUid);
}catch(err){
console.debug("====>get localId by uid err:" +JSON.stringify(err));
expect(err.code).assertEqual(ERR_OS_ACCOUNT_SERVICE_MANAGER_BAD_UID_ERR);
expect(err.code !=0 ).assertEqual(true);
console.debug("====>ActsOsAccountGetIdFormUid_0600 end====");
done();
}
......@@ -387,7 +397,7 @@ export default function ActsOsAccountThirdPartyTest_third_2() {
var osAccountManager = osaccount.getAccountManager();
console.debug("====>get AccountManager finish====");
var localId;
var OsAccountInfo = await osAccountManager.createOsAccount("accountIdSerialB", osaccount.OsAccountType.Guest);
var OsAccountInfo = await osAccountManager.createOsAccount("accountIdSerialB", osaccount.OsAccountType.GUEST);
console.debug("====>create os account OsAccountInfo: " + JSON.stringify(OsAccountInfo));
expect(OsAccountInfo.localName).assertEqual("accountIdSerialB");
localId = OsAccountInfo.localId;
......@@ -505,7 +515,8 @@ export default function ActsOsAccountThirdPartyTest_third_2() {
osAccountManager.queryActivatedOsAccountIds((err,dataArray)=>{
console.info("====>ActsOsAccountGQueryActicedOsAccountIds_0100 err :" + JSON.stringify(err));
expect(err).assertEqual(null)
console.info("====>ActsOsAccountGQueryActicedOsAccountIds_0100 dataArray" + dataArray.length);
console.info("====>ActsOsAccountGQueryActicedOsAccountIds_0100 dataArray:" + dataArray);
expect(dataArray.length).assertEqual(1)
done();
})
})
......@@ -518,8 +529,9 @@ export default function ActsOsAccountThirdPartyTest_third_2() {
it('ActsOsAccountQueryActivedOsAccountIds_0200', 0, async function (done) {
console.debug("====>ActsOsAccountQueryActivedOsAccountIds_0200 start====");
var osAccountManager = osaccount.getAccountManager();
osAccountManager.queryActivatedOsAccountIds().then((data)=>{
console.debug("====>ActsOsAccountQueryActivedOsAccountIds_0200 data" + JSON.stringify(data))
osAccountManager.queryActivatedOsAccountIds().then((dataArray)=>{
console.debug("====>ActsOsAccountQueryActivedOsAccountIds_0200 data" + JSON.stringify(dataArray))
expect(dataArray.length).assertEqual(1)
done();
}).catch((err)=>{
console.info("====>ActsOsAccountQueryActivedOsAccountIds_0200 err " + JSON.stringify(err));
......
......@@ -17,8 +17,6 @@ import distributedAccount from '@ohos.account.distributedAccount'
import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from '@ohos/hypium'
const TIMEOUT = 1000;
const ERR_OSACCOUNT_KIT_IS_OS_ACCOUNT_ACTIVED_ERROR = 4587542;
const ERR_OSACCOUNT_KIT_IS_OS_ACCOUNT_VERIFIED_ERROR = 4587545;
export default function ActsOsAccountThirdPartyTest_third_1() {
describe('ActsOsAccountThirdPartyTest_third_1', function () {
......@@ -132,7 +130,7 @@ export default function ActsOsAccountThirdPartyTest_third_1() {
var nonExistLocalId = 1000;
AccountManager.isOsAccountActived(nonExistLocalId, (err)=>{
console.debug("====>isOsAccountActived err:" + JSON.stringify(err));
expect(err.code).assertEqual(ERR_OSACCOUNT_KIT_IS_OS_ACCOUNT_ACTIVED_ERROR);
expect(err.code !=0 ).assertEqual(true);
console.debug("====>ActsOsAccountIsActived_0300 end");
done();
})
......@@ -153,7 +151,7 @@ export default function ActsOsAccountThirdPartyTest_third_1() {
}
catch(err){
console.debug("====>isOsAccountActived err:" + JSON.stringify(err));
expect(err.code).assertEqual(ERR_OSACCOUNT_KIT_IS_OS_ACCOUNT_ACTIVED_ERROR);
expect(err.code !=0 ).assertEqual(true);
console.debug("====>ActsOsAccountIsActived_0400 end");
done();
}
......@@ -208,7 +206,7 @@ export default function ActsOsAccountThirdPartyTest_third_1() {
console.debug("====>get os AccountManager finish====");
AccountManager.isOsAccountActived(undefined, (err, data)=>{
console.debug("====>ActsOsAccountIsActived_0700 err:" + JSON.stringify(err));
expect(err != 0).assertEqual(true)
expect(err.code != 0).assertEqual(true)
console.debug("====>receive isOsAccountActived data: " + JSON.stringify(data));
done();
})
......@@ -225,7 +223,7 @@ export default function ActsOsAccountThirdPartyTest_third_1() {
console.debug("====>ActsOsAccountIsActived_0800 get os AccountManager finish====");
AccountManager.isOsAccountActived(undefined).then((data)=>{
console.debug("====>ActsOsAccountIsActived_0800 get active status is: " + JSON.stringify(data));
done()
done();
}).catch((err)=>{
console.debug("====>ActsOsAccountIsActived_0800 err:" + JSON.stringify(err))
expect(err != 0).assertEqual(true);
......@@ -439,7 +437,7 @@ export default function ActsOsAccountThirdPartyTest_third_1() {
var osAccountLocalId = 1000;
AccountManager.isOsAccountVerified(osAccountLocalId, (err)=>{
console.debug("====>isOsAccountVerified err:" + JSON.stringify(err));
expect(err.code).assertEqual(ERR_OSACCOUNT_KIT_IS_OS_ACCOUNT_VERIFIED_ERROR);
expect(err.code !=0 ).assertEqual(true);
console.debug("====>ActsOsAccountIsVerified_0900 end====");
done();
})
......@@ -460,7 +458,7 @@ export default function ActsOsAccountThirdPartyTest_third_1() {
}
catch(err){
console.debug("====>isOsAccountVerified err:" + JSON.stringify(err));
expect(err.code).assertEqual(ERR_OSACCOUNT_KIT_IS_OS_ACCOUNT_VERIFIED_ERROR);
expect(err.code !=0 ).assertEqual(true);
console.debug("====>ActsOsAccountIsVerified_1000 end====");
done();
}
......
......@@ -20,6 +20,7 @@ import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from
var dir = "";
var infos = "";
var SRC_FILE_INVALID = 90001;
export default function ActsZlibTest() {
describe('ActsZlibTest', function () {
beforeEach(async (done) => {
......@@ -1093,6 +1094,153 @@ it('ACTS_ZipFile_5000', 0, async function (done) {
});
console.log("==================ACTS_ZipFile_5000 end==================");
})
/*
* @tc.number: SUB_BMS_TOOL_ZLIB_0076
* @tc.name: compressFile success
* @tc.desc: inFile and out file is valid
*/
it('SUB_BMS_TOOL_ZLIB_0077', 0, async function (done) {
console.log("==================ACTS_compressFile_0100 start==================");
var path = dir + "/SUB_BMS_TOOL_ZLIB_0077.txt";
var zipDest = dir + "/SUB_BMS_TOOL_ZLIB_0077.zip";
var fd = fileio.openSync(path, 0o100 | 0o2, 0o666);
fileio.write(fd, infos).then(function (number) {
console.info("SUB_BMS_TOOL_ZLIB_0077 write data to file successfully :" + number);
var options = {};
options.level = zlib.CompressLevel.COMPRESS_LEVEL_DEFAULT_COMPRESSION;
console.info("SUB_BMS_TOOL_ZLIB_0077 start compressFile");
zlib.compressFile(path, zipDest, options).then((data) => {
console.log("SUB_BMS_TOOL_ZLIB_0077 data: " + data);
var zipStat = fileio.statSync(zipDest);
var isFile = zipStat.isFile();
expect(isFile).assertTrue();
var srcSize = fileio.statSync(path).size;
var destSize = zipStat.size;
expect(srcSize > destSize).assertTrue();
expect(data).assertEqual(null);
done();
}).catch((err) => {
console.log("SUB_BMS_TOOL_ZLIB_0077 zipFile fail: " + err);
expect(data).assertFail();
})
}).catch(function (err) {
console.info("SUB_BMS_TOOL_ZLIB_0077 write data to file failed with error:" + err);
expect(err).assertFail();
done();
});
console.log("==================SUB_BMS_TOOL_ZLIB_0077 end==================");
})
/*
* @tc.number: SUB_BMS_TOOL_ZLIB_0077
* @tc.name: compressFile src file is invalid
* @tc.desc: inFile is not exist
*/
it('SUB_BMS_TOOL_ZLIB_0078', 0, async function (done) {
console.log("==================SUB_BMS_TOOL_ZLIB_0078 start==================");
var path ="nonexist.txt";
var zipDest = dir + "/SUB_BMS_TOOL_ZLIB_0078.zip"
var options = {};
options.level = zlib.CompressLevel.COMPRESS_LEVEL_NO_COMPRESSION;
zlib.compressFile(path, zipDest, options).then((data) => {
console.log("SUB_BMS_TOOL_ZLIB_0078 invalid src file success!")
expect(data).assertFail();
done();
}).catch((err) => {
console.log("SUB_BMS_TOOL_ZLIB_0078 zipFile fail: " + err);
expect(err.code).assertEqual(SRC_FILE_INVALID);
done();
})
console.log("==================SUB_BMS_TOOL_ZLIB_0078 end==================");
})
/*
* @tc.number: SUB_BMS_TOOL_ZLIB_0077
* @tc.name: decompressFile success
* @tc.desc: inFile and out file is valid
*/
it('SUB_BMS_TOOL_ZLIB_0087', 0, async function (done) {
console.log("==================SUB_BMS_TOOL_ZLIB_0087 start==================");
var path = dir + "/SUB_BMS_TOOL_ZLIB_0087.txt";
var zipDest = dir + "/SUB_BMS_TOOL_ZLIB_0087.zip"
var unzipdir = dir + "/SUB_BMS_TOOL_ZLIB_0087";
var finalFile = unzipdir + "/SUB_BMS_TOOL_ZLIB_0087.txt";
var options = {};
options.strategy = zlib.CompressStrategy.COMPRESS_STRATEGY_FIXED;
var fd = fileio.openSync(path, 0o100 | 0o2, 0o666);
fileio.write(fd, infos).then(function (number) {
console.info("SUB_BMS_TOOL_ZLIB_0087 write data to file successfully:" + number);
zlib.compressFile(path, zipDest, options).then(data => {
var zipStat = fileio.statSync(zipDest);
var isFile = zipStat.isFile();
expect(isFile).assertTrue();
var srcSize = fileio.statSync(path).size;
var destSize = zipStat.size;
expect(srcSize > destSize).assertTrue();
expect(data).assertEqual(null);
fileio.mkdir(unzipdir).then(function () {
console.info("SUB_BMS_TOOL_ZLIB_0087 mkdir successfully");
zlib.decompressFile(zipDest, unzipdir, options).then(data => {
console.log("SUB_BMS_TOOL_ZLIB_0087 data: " + data);
var zipStat = fileio.statSync(finalFile);
var isFile = zipStat.isFile();
expect(isFile).assertTrue();
expect(data).assertEqual(null);
done();
}).catch(err => {
console.log("decomepressFile fail: " + err);
expect(err).assertFail();
done();
})
}).catch(function (error) {
console.info("SUB_BMS_TOOL_ZLIB_0087 mkdir failed with error:" + error);
expect(error).assertFail();
done();
});
}).catch(err => {
console.log("compress fail: " + err);
expect(err).assertFail();
done();
})
}).catch(function (err) {
console.info("SUB_BMS_TOOL_ZLIB_0087 write data to file failed with error:" + err);
expect(err).assertFail();
done();
});
console.log("==================SUB_BMS_TOOL_ZLIB_0087 end==================");
})
/*
* @tc.number: ACTS_decompressFile_0200
* @tc.name: decompressFile src file invalid
* @tc.desc: inFile is empty
*/
it('SUB_BMS_TOOL_ZLIB_0088', 0, async function (done) {
console.log("==================SUB_BMS_TOOL_ZLIB_0088 start==================");
var zipDest = dir + "/noneexist.zip"
var unzipdir = dir + "/SUB_BMS_TOOL_ZLIB_0088";
var options = {};
options.strategy = zlib.CompressStrategy.COMPRESS_STRATEGY_FIXED;
fileio.mkdir(unzipdir).then(function () {
console.info("SUB_BMS_TOOL_ZLIB_0088 mkdir successfully");
zlib.decompressFile(zipDest, unzipdir, options).then(data => {
console.log("SUB_BMS_TOOL_ZLIB_0088 data: " + data);
expect(data).assertEqual(null);
done();
}).catch(err => {
console.log("decompress fail: " + err);
expect(err.code).assertEqual(SRC_FILE_INVALID);
done();
})
}).catch(function (error) {
console.info("SUB_BMS_TOOL_ZLIB_0088 mkdir failed with error:" + error);
expect(error).assertFail();
done();
});
console.log("==================SUB_BMS_TOOL_ZLIB_0088 end==================");
})
})
}
......@@ -18,6 +18,7 @@
#include <cstdlib>
#include <fstream>
#include <gtest/gtest.h>
#include <mutex>
#include <securec.h>
#include <sstream>
#include <string>
......@@ -38,9 +39,12 @@ static int SIX = 6;
static int EIGHT = 8;
static int GARBAGE_LEN = strlen(GARBAGE);
static unsigned BUFFER_SIZE = 8192;
std::mutex gzMutex_;
std::mutex puMutex_;
static unsigned pull(void *desc, unsigned char **buf)
{
std::lock_guard<std::mutex> lock(puMutex_);
static unsigned int next = 0;
static unsigned char dat[] = {0x63, 0, 2, 0};
......@@ -53,12 +57,14 @@ static unsigned pull(void *desc, unsigned char **buf)
static int push(void *desc, unsigned char *buf, unsigned len)
{
std::lock_guard<std::mutex> lock(puMutex_);
buf += len;
return desc != nullptr; /* force error if desc not null */
}
static int TestGzPrintf(gzFile file, const char *format, ...)
{
std::lock_guard<std::mutex> lock(gzMutex_);
va_list va;
int ret;
......
......@@ -14,7 +14,6 @@
*/
import rdbStoreBackupRestoreCallbackTest from './RdbstoreBackupRestoreCallbackJsunit.test.js'
import rdbStoreBackupRestoreWithFAContextTest from './RdbstoreBackupRestoreWithFAContextJsunit.test.js'
import rdbstoreChangeEncryptKeyTest from './RdbstoreChangeEncryptKeyJsunit.test.js'
import rdbStoreDeleteTest from './RdbstoreDeleteJsunit.test.js'
import rdbStoreDistributedTest from './RdbStoreDistributedJsunit.test.js'
import rdbstoreInsertTest from './RdbstoreInsertJsunit.test.js'
......@@ -30,7 +29,6 @@ import rdbStoreEncryptionTest from './RdbstoreEncryptionJsunit.test.js'
export default function testsuite() {
rdbStoreBackupRestoreCallbackTest()
rdbStoreBackupRestoreWithFAContextTest()
rdbstoreChangeEncryptKeyTest()
rdbStoreDeleteTest()
rdbStoreDistributedTest()
rdbstoreInsertTest()
......
// @ts-nocheck
/*
* Copyright (C) 2021 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 {describe, beforeAll, beforeEach, afterEach, afterAll, it, expect} from '@ohos/hypium'
import dataRdb from '@ohos.data.rdb';
const TAG = "[RDB_JSKITS_TEST]"
const CREATE_TABLE_TEST = "CREATE TABLE IF NOT EXISTS test (" + "id INTEGER PRIMARY KEY AUTOINCREMENT, "
+ "name TEXT NOT NULL, " + "age INTEGER, " + "salary REAL, " + "blobType BLOB)";
const STORE_CONFIG = {
name: "EncryptNoKeyInsertTest.db",
encryptKey: new Uint8Array([1, 2, 3])
}
const STORE_CONFIG_NO_KEY = {
name: "EncryptNoKeyInsertTest.db"
}
var i = 1;
var rdbStore = undefined;
export default function rdbstoreChangeEncryptKeyTest() {
describe('rdbstoreChangeEncryptKeyTest', function () {
beforeAll(async function () {
console.info(TAG + 'beforeAll')
})
beforeEach(async function () {
if ( i== 2){
rdbStore = await dataRdb.getRdbStore(STORE_CONFIG_NO_KEY, 1);
}
rdbStore = await dataRdb.getRdbStore(STORE_CONFIG, 1);
await rdbStore.executeSql(CREATE_TABLE_TEST);
console.info(TAG + 'beforeEach')
})
afterEach(async function () {
i ++;
console.info(TAG + 'afterEach')
rdbStore = null
await dataRdb.deleteRdbStore("EncryptNoKeyInsertTest.db");
})
afterAll(async function () {
console.info(TAG + 'afterAll')
})
console.info(TAG + "*************Unit Test Begin*************");
/**
* @tc.name testRdbStoreChangeEncryptKey0001
* @tc.number SUB_DDM_Encrypt_ChangeKey0001
* @tc.desc encrypt the db at start, then change the encrypt key
*/
it('testRdbStoreChangeEncryptKey0001', 0, async function (done) {
console.info(TAG + "************* testRdbStoreChangeEncryptKey0001 start *************");
var u8 = new Uint8Array([1, 2, 3])
{
const valueBucket = {
"name": "zhangsan",
"age": 18,
"salary": 100.5,
"blobType": u8,
}
await rdbStore.insert("test", valueBucket)
}
var newKey = new Uint8Array([1, 2])
await rdbStore.changeEncryptKey(newKey);
let predicates = new dataRdb.RdbPredicates("test");
predicates.equalTo("name", "zhangsan")
let resultSet = await rdbStore.query(predicates)
try {
console.info(TAG + "resultSet query done");
resultSet.goToFirstRow()
const id = resultSet.getLong(resultSet.getColumnIndex("id"))
expect(1).assertEqual(id);
} catch (e) {
console.info("insert1 error " + e);
}
done()
console.info(TAG + "************* testRdbStoreChangeEncryptKey0001 end *************");
})
/**
* @tc.name testRdbStoreChangeEncryptKey0002
* @tc.number SUB_DDM_Encrypt_ChangeKey0002
* @tc.desc encrypt the db at start, then change the encrypt key
*/
it('testRdbStoreChangeEncryptKey0002', 0, async function (done) {
console.info(TAG + "************* testRdbStoreChangeEncryptKey0002 start *************");
var u8 = new Uint8Array([1, 2, 3])
let result = 1;
{
const valueBucket = {
"name": "zhangsan",
"age": 18,
"salary": 100.5,
"blobType": u8,
}
await rdbStore.insert("test", valueBucket)
}
try {
let result = await rdbStore.changeEncryptKey(new Uint8Array([1, 2]));
} catch (e) {
expect(1).assertEqual(result);
console.info(TAG + "can not change encrypt key, since config with no key");
}
done()
console.info(TAG + "************* testRdbStoreChangeEncryptKey0002 end *************");
})
/**
* @tc.name testRdbStoreChangeEncryptKey0003
* @tc.number SUB_DDM_Encrypt_ChangeKey0003
* @tc.desc encrypt the db at start, then clear the encrypt key
* now sqlite does not support this feature, switch encrypt to non-encrypt.
*/
it('testRdbStoreChangeEncryptKey0003', 0, async function (done) {
console.info(TAG + "************* testRdbStoreChangeEncryptKey0003 start *************");
let result = -1;
var u8 = new Uint8Array([1, 2, 3])
{
const valueBucket = {
"name": "zhangsan",
"age": 18,
"salary": 100.5,
"blobType": u8,
}
await rdbStore.insert("test", valueBucket)
}
try{
result = await rdbStore.changeEncryptKey(new Uint8Array());
} catch (e) {
expect(-1).assertEqual(result);
console.info(TAG + "can not clear encrypt key 2");
}
done()
console.info(TAG + "************* testRdbStoreChangeEncryptKey0003 end *************");
})
console.info(TAG + "*************Unit Test End*************");
})}
......@@ -14,6 +14,7 @@
*/
import hidebug from '@ohos.hidebug'
import fileio from '@ohos.fileio'
import featureAbility from '@ohos.ability.featureAbility'
import {describe, it, expect} from '@ohos/hypium'
export default function HidebugJsTest() {
......@@ -337,47 +338,74 @@ describe('HidebugJsTest', function () {
*/
it('DFX_DFR_Hiprofiler_Interface_1100', 0, function() {
console.log('************* DFX_DFR_Hiprofiler_Interface_1100 Test start*************');
try {
let temp = hidebug.getServiceDump(10);
console.info("ServiceDump is " + temp);
expect(temp.indexOf('Success')!=-1).assertTrue();
} catch (error) {
expect().assertFail();
}
let context = featureAbility.getContext();
context.getFilesDir().then((data) => {
var path = data + "/serviceInfo1.txt"
let fd = fileio.openSync(path, 0o102, 0o666)
var serviceId = 10
var args = new Array("allInfo")
try {
hidebug.getServiceDump(serviceId, fd, args)
expect(true).assertTrue();
} catch (error) {
expect().assertFail();
console.info(error.code)
console.info(error.message)
}
fileio.closeSync(fd);
})
console.log('************* DFX_DFR_Hiprofiler_Interface_1100 Test end*************');
});
/*
* @tc.number : DFX_DFR_Hiprofiler_Interface_0900
* @tc.name : getServiceDump with abnormal parameter
* @tc.name : getServiceDump with parameter error
* @tc.desc : getServiceDump
*/
it('DFX_DFR_Hiprofiler_Interface_0900', 0, function() {
console.log('************* DFX_DFR_Hiprofiler_Interface_0900 Test start*************');
try {
let temp = hidebug.getServiceDump(-1);
console.info("ServiceDump is " + temp);
expect(temp=="Error: no such system ability service.").assertTrue();
} catch (error) {
expect().assertFail();
}
let context = featureAbility.getContext();
context.getFilesDir().then((data) => {
var path = data + "/serviceInfo2.txt"
let fd = fileio.openSync(path, 0o102, 0o666)
var serviceId = 10
var args = new Array("allInfo")
try {
hidebug.getServiceDump(serviceId)
expect().assertFail();
} catch (error) {
console.info(error.code)
console.info(error.message)
expect(error.code == 401).assertTrue();
}
fileio.closeSync(fd);
})
console.log('************* DFX_DFR_Hiprofiler_Interface_0900 Test end*************');
});
/*
* @tc.number : DFX_DFR_Hiprofiler_Interface_1000
* @tc.name : getServiceDump with overlog parameter
* @tc.name : getServiceDump with check system ability failed
* @tc.desc : getServiceDump
*/
it('DFX_DFR_Hiprofiler_Interface_1000', 0, function() {
console.log('************* DFX_DFR_Hiprofiler_Interface_1000 Test start*************');
try {
let temp = hidebug.getServiceDump(9007199254740993);
console.info("ServiceDump is " + temp);
expect(temp=="Error: invalid param").assertTrue();
} catch (error) {
expect().assertFail();
}
let context = featureAbility.getContext();
context.getFilesDir().then((data) => {
var path = data + "/serviceInfo3.txt"
let fd = fileio.openSync(path, 0o102, 0o666)
var serviceId = -10
var args = new Array("allInfo")
try {
hidebug.getServiceDump(serviceId, fd, args)
expect().assertFail();
} catch (error) {
console.info(error.code)
console.info(error.message)
expect(error.code == 11400101).assertTrue();
}
fileio.closeSync(fd);
})
console.log('************* DFX_DFR_Hiprofiler_Interface_1000 Test end*************');
});
......
......@@ -20,7 +20,7 @@ config("utils_config") {
include_dirs = [
"//third_party/cJSON/",
"//third_party/zlib/",
"//commonlibrary/c_utils/base/",
"//third_party/bounds_checking_function/",
]
}
......
......@@ -342,28 +342,28 @@ export default function cameraJSUnitOutput(surfaceId: any) {
/**
* @tc.number : SUB_MULTIMEDIA_CAMERA_CREATE_CAMERA_INPUT_PROMISE_0100
* @tc.number : SUB_MULTIMEDIA_CAMERA_CREATE_CAMERA_OUTPUT_PROMISE_0100
* @tc.name : Create previewOutput instance async api
* @tc.desc : Create previewOutput instance async api
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 2
*/
it('SUB_MULTIMEDIA_CAMERA_CREATE_CAMERA_INPUT_PROMISE_0100', 2, async function (done) {
console.info(TAG + " --------------SUB_MULTIMEDIA_CAMERA_CREATE_CAMERA_INPUT_PROMISE_0100--------------");
it('SUB_MULTIMEDIA_CAMERA_CREATE_CAMERA_OUTPUT_PROMISE_0100', 2, async function (done) {
console.info(TAG + " --------------SUB_MULTIMEDIA_CAMERA_CREATE_CAMERA_OUTPUT_PROMISE_0100--------------");
if (isEmpty(cameraManager)) {
console.info(TAG + "Entering CREATE_CAMERA_INPUT cameraManager == null || undefined")
expect().assertFail();
} else {
cameraInput = await cameraManager.createCameraInput(cameraDevicesArray[0]);
if (isEmpty(cameraInput)) {
console.info(TAG + "SUB_MULTIMEDIA_CAMERA_CREATE_CAMERA_INPUT_PROMISE_0100 FAILED");
console.info(TAG + "SUB_MULTIMEDIA_CAMERA_CREATE_CAMERA_OUTPUT_PROMISE_0100 FAILED");
}
cameraInput.open(async (err) => {
if (!err) {
console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_CREATE_CAMERA_INPUT_PROMISE_0100 open callback");
console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_CREATE_CAMERA_OUTPUT_PROMISE_0100 open callback");
} else {
console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_CREATE_CAMERA_INPUT_PROMISE_0100 FAILED: " + err.message);
console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_CREATE_CAMERA_OUTPUT_PROMISE_0100 FAILED: " + err.message);
}
await sleep(1000);
done();
......
......@@ -293,24 +293,24 @@ describe('CameraManagerTest', function () {
})
/**
* @tc.number : SUB_MULTIMEDIA_CAMERA_GET_CAMERA_MANAGER_0100
* @tc.number : SUB_MULTIMEDIA_CAMERA_GET_CAMERAMANAGER_CALLBACK_0100
* @tc.name : Create camera manager instance async api
* @tc.desc : Create camera manager instance async api
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 2
*/
it('SUB_MULTIMEDIA_CAMERA_GET_CAMERA_MANAGER_CALLBACK_0100', 2, async function (done) {
console.info("--------------SUB_MULTIMEDIA_CAMERA_GET_CAMERA_MANAGER_0100--------------");
it('SUB_MULTIMEDIA_CAMERA_GET_CAMERAMANAGER_CALLBACK_0100', 2, async function (done) {
console.info("--------------SUB_MULTIMEDIA_CAMERA_GET_CAMERAMANAGER_CALLBACK_0100--------------");
cameraObj.getCameraManager(null, async (err, data) => {
if (!err) {
expect(isEmpty(data)).assertFalse();
console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_GET_CAMERA_MANAGER_0100 success");
console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_GET_CAMERAMANAGER_CALLBACK_0100 success");
} else {
expect().assertFail();
console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_GET_CAMERA_MANAGER_0100 FAILED: " + err.message);
console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_GET_CAMERAMANAGER_CALLBACK_0100 FAILED: " + err.message);
}
console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_GET_CAMERA_MANAGER_0100 ends here");
console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_GET_CAMERAMANAGER_CALLBACK_0100 ends here");
await sleep(1000);
done();
})
......@@ -336,57 +336,57 @@ describe('CameraManagerTest', function () {
})
/**
* @tc.number : SUB_MULTIMEDIA_CAMERA_GET_CAMERAS_CALLBACK_0100
* @tc.number : SUB_MULTIMEDIA_CAMERA_GET_SUPPORTED_CAMERAS_CALLBACK_0100
* @tc.name : Get camera from cameramanager to get array of camera async api
* @tc.desc : Get camera from cameramanager to get array of camera async api
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 2
*/
it('SUB_MULTIMEDIA_CAMERA_GET_CAMERAS_CALLBACK_0100', 2, async function (done) {
console.info("--------------SUB_MULTIMEDIA_CAMERA_GET_CAMERAS_CALLBACK_0100--------------");
it('SUB_MULTIMEDIA_CAMERA_GET_SUPPORTED_CAMERAS_CALLBACK_0100', 2, async function (done) {
console.info("--------------SUB_MULTIMEDIA_CAMERA_GET_SUPPORTED_CAMERAS_CALLBACK_0100--------------");
if (isEmpty(mCameraManager)) {
console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_GET_CAMERAS_PROMISE_0100 cameraManager == null || undefined")
console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_GET_SUPPORTED_CAMERAS_CALLBACK_0100 cameraManager == null || undefined")
expect().assertFail();
}
mCameraManager.getSupportedCameras(async (err, data) => {
if (!err) {
console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_GET_CAMERAS_CALLBACK_0100 success");
console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_GET_SUPPORTED_CAMERAS_CALLBACK_0100 success");
if (!isEmpty(data)) {
mCameraDevicesArray = data;
console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_GET_CAMERAS_CALLBACK_0100 data is " + mCameraDevicesArray.length);
console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_GET_SUPPORTED_CAMERAS_CALLBACK_0100 data is " + mCameraDevicesArray.length);
if (mCameraDevicesArray.length > 0) {
for (let i = 0; i < mCameraDevicesArray.length; i++) {
// Get the variables from camera object
let cameraId = mCameraDevicesArray[i].cameraId;
expect(isEmpty(cameraId)).assertFalse();
console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_GET_CAMERAS_CALLBACK_0100 camera" + i + "Id: " + cameraId);
console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_GET_SUPPORTED_CAMERAS_CALLBACK_0100 camera" + i + "Id: " + cameraId);
let cameraPosition = mCameraDevicesArray[i].cameraPosition;
expect(isEmpty(cameraPosition)).assertFalse();
console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_GET_CAMERAS_CALLBACK_0100 camera" + i + "Position: " + cameraPosition);
console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_GET_SUPPORTED_CAMERAS_CALLBACK_0100 camera" + i + "Position: " + cameraPosition);
let cameraType = mCameraDevicesArray[i].cameraType;
expect(isEmpty(cameraType)).assertFalse();
console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_GET_CAMERAS_CALLBACK_0100 camera" + i + "Type: " + cameraType);
console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_GET_SUPPORTED_CAMERAS_CALLBACK_0100 camera" + i + "Type: " + cameraType);
let connectionType = mCameraDevicesArray[i].connectionType
expect(isEmpty(connectionType)).assertFalse();
console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_GET_CAMERAS_CALLBACK_0100 connection" + i + "Type: " + connectionType);
console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_GET_SUPPORTED_CAMERAS_CALLBACK_0100 connection" + i + "Type: " + connectionType);
}
expect(true).assertTrue();
console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_GET_CAMERAS_CALLBACK_0100 PASSED");
console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_GET_SUPPORTED_CAMERAS_CALLBACK_0100 PASSED");
} else {
expect().assertFail();
console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_GET_CAMERAS_CALLBACK_0100 FAILED cameraArray is null || undefined");
console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_GET_SUPPORTED_CAMERAS_CALLBACK_0100 FAILED cameraArray is null || undefined");
}
console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_GET_CAMERAS_CALLBACK_0100 ends here");
console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_GET_SUPPORTED_CAMERAS_CALLBACK_0100 ends here");
await sleep(1000);
done();
} else {
expect().assertFail();
console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_GET_CAMERAS_CALLBACK_0100 FAILED cameraArray is null || undefined");
console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_GET_SUPPORTED_CAMERAS_CALLBACK_0100 FAILED cameraArray is null || undefined");
}
} else {
expect().assertFail();
console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_GET_CAMERAS_CALLBACK_0100 FAILED , err = " + err.message);
console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_GET_SUPPORTED_CAMERAS_CALLBACK_0100 FAILED , err = " + err.message);
}
})
await sleep(1000);
......@@ -958,30 +958,30 @@ describe('CameraManagerTest', function () {
})
/**
* @tc.number : SUB_MULTIMEDIA_CAMERA_CREATE_CAPTURE_SESSION_CALLBACK_0100
* @tc.number : SUB_MULTIMEDIA_CAMERA_MANAGER_CREATE_CAPTURE_SESSION_CALLBACK_0100
* @tc.name : Create CaptureSession instance api
* @tc.desc : Create CaptureSession instance api
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 2
*/
it('SUB_MULTIMEDIA_CAMERA_CREATE_CAPTURE_SESSION_CALLBACK_0100', 2, async function (done) {
console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_CREATE_CAPTURE_SESSION_CALLBACK_0100 to operate");
it('SUB_MULTIMEDIA_CAMERA_MANAGER_CREATE_CAPTURE_SESSION_CALLBACK_0100', 2, async function (done) {
console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_MANAGER_CREATE_CAPTURE_SESSION_CALLBACK_0100 to operate");
let cameraSession;
mCameraManager.createCaptureSession(async (err, data) => {
if (!err) {
console.info(TAG + "Entering createCaptureSession success");
if (isEmpty(data)) {
console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_CREATE_CAPTURE_SESSION_CALLBACK_0100 data == null || undefined")
console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_MANAGER_CREATE_CAPTURE_SESSION_CALLBACK_0100 data == null || undefined")
expect().assertFail();
} else {
cameraSession = data;
console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_CREATE_CAPTURE_SESSION_CALLBACK_0100 PASSED");
console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_MANAGER_CREATE_CAPTURE_SESSION_CALLBACK_0100 PASSED");
}
} else {
expect().assertFail();
console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_CREATE_CAPTURE_SESSION_CALLBACK_0100 FAILED : " + err.message);
console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_CREATE_CAPTURE_SESSION_CALLBACK_0100 ends here");
console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_MANAGER_CREATE_CAPTURE_SESSION_CALLBACK_0100 FAILED : " + err.message);
console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_MANAGER_CREATE_CAPTURE_SESSION_CALLBACK_0100 ends here");
}
await sleep(1000);
done();
......
......@@ -14,12 +14,14 @@
import("//test/xts/tools/build/suite.gni")
module_output_path = "acts/ActsAvcodecNdkTest"
MEDIA_ROOT_DIR = "//foundation/multimedia/player_framework/"
ohos_moduletest_suite("ActsAvcodecNdkTest") {
module_out_path = module_output_path
sources = [
"audioDecEncNdk/src/ADecEncNdkSample.cpp",
"audioDecEncNdk/src/ActsAudioDecEncNdkTest.cpp",
"codecFormatNdk/ActsCodecFormatNdkTest.cpp",
"videoDecEncNdk/src/ActsVideoDecEncNdkTest.cpp",
"videoDecEncNdk/src/VDecEncNdkSample.cpp",
]
......@@ -28,13 +30,17 @@ ohos_moduletest_suite("ActsAvcodecNdkTest") {
"audioDecEncNdk/include",
"videoDecEncNdk/include",
"//foundation/multimedia/audio_framework/interfaces/inner_api/native/audiocommon/include",
"//foundation/multimedia/player_framework/interfaces/inner_api/native",
"//foundation/multimedia/player_framework/interfaces/kits/c",
"//foundation/multimedia/player_framework/frameworks/native/capi/common",
"//commonlibrary/c_utils/base/include",
"//foundation/graphic/graphic_2d/frameworks/surface/include",
"//foundation/graphic/graphic_2d/interfaces/inner_api/surface",
"//foundation/graphic/graphic_2d/interfaces/inner_api/common",
"//foundation//window/window_manager/interfaces/innerkits/wm",
"//graphic/graphic_2d/interfaces/kits/surface",
"//graphic/graphic_2d/interfaces/inner_api/surface",
"//foundation/graphic/graphic_2d/frameworks/surface/include",
"$MEDIA_ROOT_DIR/interfaces/inner_api/native",
"$MEDIA_ROOT_DIR/interfaces/kits/c",
"$MEDIA_ROOT_DIR/frameworks/native/capi/common",
"$MEDIA_ROOT_DIR/interfaces/kits/c",
"$MEDIA_ROOT_DIR/interfaces/inner_api/native",
]
cflags = [
......@@ -56,14 +62,17 @@ ohos_moduletest_suite("ActsAvcodecNdkTest") {
]
deps = [
"$MEDIA_ROOT_DIR/interfaces/inner_api/native:media_client",
"$MEDIA_ROOT_DIR/interfaces/kits/c:native_media_adec",
"$MEDIA_ROOT_DIR/interfaces/kits/c:native_media_aenc",
"$MEDIA_ROOT_DIR/interfaces/kits/c:native_media_codecbase",
"$MEDIA_ROOT_DIR/interfaces/kits/c:native_media_core",
"$MEDIA_ROOT_DIR/interfaces/kits/c:native_media_vdec",
"$MEDIA_ROOT_DIR/interfaces/kits/c:native_media_venc",
"//foundation/graphic/graphic_2d:libsurface",
"//foundation/graphic/graphic_2d/frameworks/surface:surface",
"//foundation/multimedia/player_framework/interfaces/kits/c:native_media_adec",
"//foundation/multimedia/player_framework/interfaces/kits/c:native_media_aenc",
"//foundation/multimedia/player_framework/interfaces/kits/c:native_media_codecbase",
"//foundation/multimedia/player_framework/interfaces/kits/c:native_media_core",
"//foundation/multimedia/player_framework/interfaces/kits/c:native_media_vdec",
"//foundation/multimedia/player_framework/interfaces/kits/c:native_media_venc",
"//foundation/graphic/graphic_2d/rosen/modules/render_service_client:librender_service_client",
"//foundation/window/window_manager/wm:libwm",
]
external_deps = [
"c_utils:utils",
......
......@@ -64,8 +64,10 @@ public:
ADecEncNdkSample() = default;
~ADecEncNdkSample();
struct OH_AVCodec* CreateAudioDecoder(std::string mimetype);
struct OH_AVCodec* CreateAudioDecoderByMime(std::string mimetype);
struct OH_AVCodec* CreateAudioDecoderByName(std::string name);
int32_t ConfigureDec(struct OH_AVFormat *format);
int32_t SetParameterDec(struct OH_AVFormat *format);
int32_t PrepareDec();
int32_t StartDec();
int32_t StopDec();
......@@ -73,8 +75,10 @@ public:
int32_t ResetDec();
int32_t ReleaseDec();
struct OH_AVCodec* CreateAudioEncoder(std::string mimetype);
struct OH_AVCodec* CreateAudioEncoderByMime(std::string mimetype);
struct OH_AVCodec* CreateAudioEncoderByName(std::string name);
int32_t ConfigureEnc(struct OH_AVFormat *format);
int32_t SetParameterEnc(struct OH_AVFormat *format);
int32_t PrepareEnc();
int32_t StartEnc();
int32_t StopEnc();
......
......@@ -16,6 +16,8 @@
#include "ADecEncNdkSample.h"
#include "native_avmemory.h"
#include "native_averrors.h"
#include "native_avcodec_base.h"
using namespace OHOS;
using namespace OHOS::Media;
using namespace std;
......@@ -124,9 +126,13 @@ ADecEncNdkSample::~ADecEncNdkSample()
acodecSignal_ = nullptr;
}
struct OH_AVCodec* ADecEncNdkSample::CreateAudioDecoder(std::string mimetype)
struct OH_AVCodec* ADecEncNdkSample::CreateAudioDecoderByMime(std::string mimetype)
{
adec_ = OH_AudioDecoder_CreateByMime(mimetype.c_str());
if (mimetype == "audio/mp4a-latm") {
adec_ = OH_AudioDecoder_CreateByMime(OH_AVCODEC_MIMETYPE_AUDIO_AAC);
} else {
adec_ = OH_AudioDecoder_CreateByMime(mimetype.c_str());
}
NDK_CHECK_AND_RETURN_RET_LOG(adec_ != nullptr, nullptr, "Fatal: OH_AudioDecoder_CreateByMime");
acodecSignal_ = new ADecEncSignal();
......@@ -141,11 +147,33 @@ struct OH_AVCodec* ADecEncNdkSample::CreateAudioDecoder(std::string mimetype)
return adec_;
}
struct OH_AVCodec* ADecEncNdkSample::CreateAudioDecoderByName(std::string name)
{
adec_ = OH_AudioDecoder_CreateByName(name.c_str());
NDK_CHECK_AND_RETURN_RET_LOG(adec_ != nullptr, nullptr, "Fatal: OH_AudioDecoder_CreateByName");
acodecSignal_ = new ADecEncSignal();
NDK_CHECK_AND_RETURN_RET_LOG(acodecSignal_ != nullptr, nullptr, "Fatal: No Memory");
cbDec_.onError = AdecAsyncError;
cbDec_.onStreamChanged = AdecAsyncStreamChanged;
cbDec_.onNeedInputData = AdecAsyncNeedInputData;
cbDec_.onNeedOutputData = AdecAsyncNewOutputData;
int32_t ret = OH_AudioDecoder_SetCallback(adec_, cbDec_, static_cast<void *>(acodecSignal_));
NDK_CHECK_AND_RETURN_RET_LOG(ret == AV_ERR_OK, NULL, "Fatal: OH_AudioDecoder_SetCallback");
return adec_;
}
int32_t ADecEncNdkSample::ConfigureDec(struct OH_AVFormat *format)
{
return OH_AudioDecoder_Configure(adec_, format);
}
int32_t ADecEncNdkSample::SetParameterDec(struct OH_AVFormat *format)
{
return OH_AudioDecoder_SetParameter(adec_, format);
}
int32_t ADecEncNdkSample::PrepareDec()
{
return OH_AudioDecoder_Prepare(adec_);
......@@ -385,9 +413,13 @@ void ADecEncNdkSample::InputFuncDec()
}
}
struct OH_AVCodec* ADecEncNdkSample::CreateAudioEncoder(std::string mimetype)
struct OH_AVCodec* ADecEncNdkSample::CreateAudioEncoderByMime(std::string mimetype)
{
aenc_ = OH_AudioEncoder_CreateByMime(mimetype.c_str());
if (mimetype == "audio/mp4a-latm") {
aenc_ = OH_AudioEncoder_CreateByMime(OH_AVCODEC_MIMETYPE_AUDIO_AAC);
} else {
aenc_ = OH_AudioEncoder_CreateByMime(mimetype.c_str());
}
NDK_CHECK_AND_RETURN_RET_LOG(aenc_ != nullptr, nullptr, "Fatal: OH_AudioEncoder_CreateByMime");
cbEnc_.onError = AencAsyncError;
cbEnc_.onStreamChanged = AencAsyncStreamChanged;
......@@ -398,11 +430,28 @@ struct OH_AVCodec* ADecEncNdkSample::CreateAudioEncoder(std::string mimetype)
return aenc_;
}
struct OH_AVCodec* ADecEncNdkSample::CreateAudioEncoderByName(std::string name)
{
aenc_ = OH_AudioEncoder_CreateByName(name.c_str());
NDK_CHECK_AND_RETURN_RET_LOG(aenc_ != nullptr, nullptr, "Fatal: OH_AudioEncoder_CreateByName");
cbEnc_.onError = AencAsyncError;
cbEnc_.onStreamChanged = AencAsyncStreamChanged;
cbEnc_.onNeedInputData = AencAsyncNeedInputData;
cbEnc_.onNeedOutputData = AencAsyncNewOutputData;
int32_t ret = OH_AudioEncoder_SetCallback(aenc_, cbEnc_, static_cast<void *>(acodecSignal_));
NDK_CHECK_AND_RETURN_RET_LOG(ret == AV_ERR_OK, NULL, "Fatal: OH_AudioEncoder_SetCallback");
return aenc_;
}
int32_t ADecEncNdkSample::ConfigureEnc(struct OH_AVFormat *format)
{
return OH_AudioEncoder_Configure(aenc_, format);
}
int32_t ADecEncNdkSample::SetParameterEnc(struct OH_AVFormat *format)
{
return OH_AudioEncoder_SetParameter(aenc_, format);
}
int32_t ADecEncNdkSample::PrepareEnc()
{
......
......@@ -48,8 +48,11 @@ uint32_t ES_AAC_48000_32_1[] = {
381, 375, 373, 349, 391, 357, 384, 395, 384, 380, 386, 372, 386, 383, 378, 385, 385,
384, 342, 390, 379, 387, 386, 393, 397, 362, 393, 394, 391, 383, 385, 377, 379, 381,
369, 375, 379, 346, 382, 356, 361, 366, 394, 393, 385, 362, 406, 399, 384, 377, 385};
constexpr uint32_t ES_AAC_48000_32_1_Length = sizeof(ES_AAC_48000_32_1) / sizeof(uint32_t);
const string MIME_TYPE_AAC = "audio/mp4a-latm";
const string DECODER_AAC = "avdec_aac";
const string ENCODER_AAC = "avenc_aac";
constexpr uint32_t DEFAULT_SAMPLE_RATE = 44100;
constexpr uint32_t DEFAULT_CHANNELS = 2;
const char* READPATH = "/data/media/AAC_48000_32_1.aac";
......@@ -107,8 +110,9 @@ HWTEST_F(ActsAudioDecEncNdkTest, SUB_MULTIMEDIA_MEDIA_AUDIO_DEC_ENC_FUNCTION_010
OH_AVFormat *AudioFormat = OH_AVFormat_Create();
ASSERT_NE(nullptr, AudioFormat);
ASSERT_EQ(true, SetFormat(AudioFormat, AudioParam));
OH_AVFormat_SetStringValue(AudioFormat, OH_MD_KEY_CODEC_MIME, OH_AVCODEC_MIMETYPE_AUDIO_AAC);
struct OH_AVCodec* audDec = aDecEncSample->CreateAudioDecoder(MIME_TYPE_AAC);
struct OH_AVCodec* audDec = aDecEncSample->CreateAudioDecoderByName(DECODER_AAC);
ASSERT_NE(nullptr, audDec);
ASSERT_EQ(AV_ERR_OK, aDecEncSample->ConfigureDec(AudioFormat));
OH_AVFormat *OutDescDec = OH_AudioDecoder_GetOutputDescription(audDec);
......@@ -116,7 +120,7 @@ HWTEST_F(ActsAudioDecEncNdkTest, SUB_MULTIMEDIA_MEDIA_AUDIO_DEC_ENC_FUNCTION_010
ASSERT_EQ(true, CheckDecDesc(AudioParam, OutDescDec));
ASSERT_EQ(AV_ERR_OK, aDecEncSample->PrepareDec());
struct OH_AVCodec* audEnc = aDecEncSample->CreateAudioEncoder(MIME_TYPE_AAC);
struct OH_AVCodec* audEnc = aDecEncSample->CreateAudioEncoderByName(ENCODER_AAC);
ASSERT_NE(nullptr, audEnc);
ASSERT_EQ(AV_ERR_OK, aDecEncSample->ConfigureEnc(AudioFormat));
OH_AVFormat *OutDescEnc = OH_AudioEncoder_GetOutputDescription(audEnc);
......@@ -127,7 +131,9 @@ HWTEST_F(ActsAudioDecEncNdkTest, SUB_MULTIMEDIA_MEDIA_AUDIO_DEC_ENC_FUNCTION_010
aDecEncSample->SetReadPath(READPATH, ES_AAC_48000_32_1, ES_AAC_48000_32_1_Length);
aDecEncSample->SetSavePath("/data/media/AAC_48000_32_1_out1.aac");
ASSERT_EQ(AV_ERR_OK, aDecEncSample->StartEnc());
ASSERT_EQ(AV_ERR_OK, aDecEncSample->SetParameterEnc(AudioFormat));
ASSERT_EQ(AV_ERR_OK, aDecEncSample->StartDec());
ASSERT_EQ(AV_ERR_OK, aDecEncSample->SetParameterDec(AudioFormat));
while (!aDecEncSample->GetEncEosState()) {};
ASSERT_EQ(AV_ERR_OK, aDecEncSample->StopDec());
......@@ -150,17 +156,19 @@ HWTEST_F(ActsAudioDecEncNdkTest, SUB_MULTIMEDIA_MEDIA_AUDIO_DEC_ENC_FUNCTION_020
{
ADecEncNdkSample *aDecEncSample = new ADecEncNdkSample();
struct OH_AVCodec* audDec = aDecEncSample->CreateAudioDecoder(MIME_TYPE_AAC);
struct OH_AVCodec* audDec = aDecEncSample->CreateAudioDecoderByMime(MIME_TYPE_AAC);
ASSERT_NE(nullptr, audDec);
OH_AVFormat *AudioFormat = OH_AVFormat_Create();
ASSERT_NE(nullptr, AudioFormat);
OH_AVFormat_SetIntValue(AudioFormat, OH_MD_KEY_AUD_CHANNEL_COUNT, DEFAULT_CHANNELS);
OH_AVFormat_SetIntValue(AudioFormat, OH_MD_KEY_AUD_SAMPLE_RATE, DEFAULT_SAMPLE_RATE);
OH_AVFormat_SetIntValue(AudioFormat, OH_MD_KEY_AUDIO_SAMPLE_FORMAT, AudioStandard::SAMPLE_S16LE);
OH_AVFormat_SetIntValue(AudioFormat, OH_MD_KEY_TRACK_TYPE, MEDIA_TYPE_AUD);
ASSERT_EQ(AV_ERR_OK, aDecEncSample->ConfigureDec(AudioFormat));
ASSERT_EQ(AV_ERR_OK, aDecEncSample->PrepareDec());
struct OH_AVCodec* audEnc = aDecEncSample->CreateAudioEncoder(MIME_TYPE_AAC);
struct OH_AVCodec* audEnc = aDecEncSample->CreateAudioEncoderByMime(MIME_TYPE_AAC);
ASSERT_NE(nullptr, audEnc);
ASSERT_EQ(AV_ERR_OK, aDecEncSample->ConfigureEnc(AudioFormat));
ASSERT_EQ(AV_ERR_OK, aDecEncSample->PrepareEnc());
......@@ -190,17 +198,19 @@ HWTEST_F(ActsAudioDecEncNdkTest, SUB_MULTIMEDIA_MEDIA_AUDIO_DEC_ENC_FUNCTION_030
{
ADecEncNdkSample *aDecEncSample = new ADecEncNdkSample();
struct OH_AVCodec* audDec = aDecEncSample->CreateAudioDecoder(MIME_TYPE_AAC);
struct OH_AVCodec* audDec = aDecEncSample->CreateAudioDecoderByMime(MIME_TYPE_AAC);
ASSERT_NE(nullptr, audDec);
OH_AVFormat *AudioFormat = OH_AVFormat_Create();
ASSERT_NE(nullptr, AudioFormat);
OH_AVFormat_SetIntValue(AudioFormat, OH_MD_KEY_AUD_CHANNEL_COUNT, DEFAULT_CHANNELS);
OH_AVFormat_SetIntValue(AudioFormat, OH_MD_KEY_AUD_SAMPLE_RATE, DEFAULT_SAMPLE_RATE);
OH_AVFormat_SetIntValue(AudioFormat, OH_MD_KEY_AUDIO_SAMPLE_FORMAT, AudioStandard::SAMPLE_S16LE);
OH_AVFormat_SetIntValue(AudioFormat, OH_MD_KEY_PROFILE, AAC_PROFILE_LC);
ASSERT_EQ(AV_ERR_OK, aDecEncSample->ConfigureDec(AudioFormat));
ASSERT_EQ(AV_ERR_OK, aDecEncSample->PrepareDec());
struct OH_AVCodec* audEnc = aDecEncSample->CreateAudioEncoder(MIME_TYPE_AAC);
struct OH_AVCodec* audEnc = aDecEncSample->CreateAudioEncoderByMime(MIME_TYPE_AAC);
ASSERT_NE(nullptr, audEnc);
ASSERT_EQ(AV_ERR_OK, aDecEncSample->ConfigureEnc(AudioFormat));
ASSERT_EQ(AV_ERR_OK, aDecEncSample->PrepareEnc());
......@@ -228,7 +238,7 @@ HWTEST_F(ActsAudioDecEncNdkTest, SUB_MULTIMEDIA_MEDIA_AUDIO_DEC_ENC_FUNCTION_040
{
ADecEncNdkSample *aDecEncSample = new ADecEncNdkSample();
struct OH_AVCodec* audDec = aDecEncSample->CreateAudioDecoder(MIME_TYPE_AAC);
struct OH_AVCodec* audDec = aDecEncSample->CreateAudioDecoderByMime(MIME_TYPE_AAC);
ASSERT_NE(nullptr, audDec);
OH_AVFormat *AudioFormat = OH_AVFormat_Create();
ASSERT_NE(nullptr, AudioFormat);
......@@ -238,7 +248,7 @@ HWTEST_F(ActsAudioDecEncNdkTest, SUB_MULTIMEDIA_MEDIA_AUDIO_DEC_ENC_FUNCTION_040
ASSERT_EQ(AV_ERR_OK, aDecEncSample->ConfigureDec(AudioFormat));
ASSERT_EQ(AV_ERR_OK, aDecEncSample->PrepareDec());
struct OH_AVCodec* audEnc = aDecEncSample->CreateAudioEncoder(MIME_TYPE_AAC);
struct OH_AVCodec* audEnc = aDecEncSample->CreateAudioEncoderByMime(MIME_TYPE_AAC);
ASSERT_NE(nullptr, audEnc);
ASSERT_EQ(AV_ERR_OK, aDecEncSample->ConfigureEnc(AudioFormat));
ASSERT_EQ(AV_ERR_OK, aDecEncSample->PrepareEnc());
......@@ -248,7 +258,7 @@ HWTEST_F(ActsAudioDecEncNdkTest, SUB_MULTIMEDIA_MEDIA_AUDIO_DEC_ENC_FUNCTION_040
ASSERT_EQ(AV_ERR_OK, aDecEncSample->StartEnc());
ASSERT_EQ(AV_ERR_OK, aDecEncSample->StartDec());
while (aDecEncSample->GetFrameCount() < 50) {};
while (aDecEncSample->GetFrameCount() < 350) {};
ASSERT_EQ(AV_ERR_OK, aDecEncSample->FlushDec());
ASSERT_EQ(AV_ERR_OK, aDecEncSample->FlushEnc());
aDecEncSample->ReRead();
......@@ -278,7 +288,7 @@ HWTEST_F(ActsAudioDecEncNdkTest, SUB_MULTIMEDIA_MEDIA_AUDIO_DEC_ENC_FUNCTION_050
{
ADecEncNdkSample *aDecEncSample = new ADecEncNdkSample();
struct OH_AVCodec* audDec = aDecEncSample->CreateAudioDecoder(MIME_TYPE_AAC);
struct OH_AVCodec* audDec = aDecEncSample->CreateAudioDecoderByMime(MIME_TYPE_AAC);
ASSERT_NE(nullptr, audDec);
OH_AVFormat *AudioFormat = OH_AVFormat_Create();
ASSERT_NE(nullptr, AudioFormat);
......@@ -288,7 +298,7 @@ HWTEST_F(ActsAudioDecEncNdkTest, SUB_MULTIMEDIA_MEDIA_AUDIO_DEC_ENC_FUNCTION_050
ASSERT_EQ(AV_ERR_OK, aDecEncSample->ConfigureDec(AudioFormat));
ASSERT_EQ(AV_ERR_OK, aDecEncSample->PrepareDec());
struct OH_AVCodec* audEnc = aDecEncSample->CreateAudioEncoder(MIME_TYPE_AAC);
struct OH_AVCodec* audEnc = aDecEncSample->CreateAudioEncoderByMime(MIME_TYPE_AAC);
ASSERT_NE(nullptr, audEnc);
ASSERT_EQ(AV_ERR_OK, aDecEncSample->ConfigureEnc(AudioFormat));
ASSERT_EQ(AV_ERR_OK, aDecEncSample->PrepareEnc());
......@@ -310,8 +320,6 @@ HWTEST_F(ActsAudioDecEncNdkTest, SUB_MULTIMEDIA_MEDIA_AUDIO_DEC_ENC_FUNCTION_050
ASSERT_EQ(AV_ERR_OK, aDecEncSample->StartEnc());
ASSERT_EQ(AV_ERR_OK, aDecEncSample->StartDec());
aDecEncSample->SetEosState(true);
sleep(2);
ASSERT_EQ(AV_ERR_OK, aDecEncSample->CalcuError());
while (!aDecEncSample->GetEncEosState()) {};
ASSERT_EQ(AV_ERR_OK, aDecEncSample->ReleaseDec());
......@@ -333,7 +341,7 @@ HWTEST_F(ActsAudioDecEncNdkTest, SUB_MULTIMEDIA_MEDIA_AUDIO_DEC_ENC_FUNCTION_060
{
ADecEncNdkSample *aDecEncSample = new ADecEncNdkSample();
struct OH_AVCodec* audDec = aDecEncSample->CreateAudioDecoder(MIME_TYPE_AAC);
struct OH_AVCodec* audDec = aDecEncSample->CreateAudioDecoderByMime(MIME_TYPE_AAC);
ASSERT_NE(nullptr, audDec);
OH_AVFormat *AudioFormat = OH_AVFormat_Create();
ASSERT_NE(nullptr, AudioFormat);
......@@ -343,7 +351,7 @@ HWTEST_F(ActsAudioDecEncNdkTest, SUB_MULTIMEDIA_MEDIA_AUDIO_DEC_ENC_FUNCTION_060
ASSERT_EQ(AV_ERR_OK, aDecEncSample->ConfigureDec(AudioFormat));
ASSERT_EQ(AV_ERR_OK, aDecEncSample->PrepareDec());
struct OH_AVCodec* audEnc = aDecEncSample->CreateAudioEncoder(MIME_TYPE_AAC);
struct OH_AVCodec* audEnc = aDecEncSample->CreateAudioEncoderByMime(MIME_TYPE_AAC);
ASSERT_NE(nullptr, audEnc);
ASSERT_EQ(AV_ERR_OK, aDecEncSample->ConfigureEnc(AudioFormat));
ASSERT_EQ(AV_ERR_OK, aDecEncSample->PrepareEnc());
......@@ -353,7 +361,7 @@ HWTEST_F(ActsAudioDecEncNdkTest, SUB_MULTIMEDIA_MEDIA_AUDIO_DEC_ENC_FUNCTION_060
ASSERT_EQ(AV_ERR_OK, aDecEncSample->StartEnc());
ASSERT_EQ(AV_ERR_OK, aDecEncSample->StartDec());
while (aDecEncSample->GetFrameCount() < 50) {};
while (aDecEncSample->GetFrameCount() < 350) {};
ASSERT_EQ(AV_ERR_OK, aDecEncSample->StopDec());
ASSERT_EQ(AV_ERR_OK, aDecEncSample->StopEnc());
aDecEncSample->ReRead();
......@@ -385,7 +393,7 @@ HWTEST_F(ActsAudioDecEncNdkTest, SUB_MULTIMEDIA_MEDIA_AUDIO_DEC_ENC_FUNCTION_070
{
ADecEncNdkSample *aDecEncSample = new ADecEncNdkSample();
struct OH_AVCodec* audDec = aDecEncSample->CreateAudioDecoder(MIME_TYPE_AAC);
struct OH_AVCodec* audDec = aDecEncSample->CreateAudioDecoderByMime(MIME_TYPE_AAC);
ASSERT_NE(nullptr, audDec);
OH_AVFormat *AudioFormat = OH_AVFormat_Create();
ASSERT_NE(nullptr, AudioFormat);
......@@ -395,7 +403,7 @@ HWTEST_F(ActsAudioDecEncNdkTest, SUB_MULTIMEDIA_MEDIA_AUDIO_DEC_ENC_FUNCTION_070
ASSERT_EQ(AV_ERR_OK, aDecEncSample->ConfigureDec(AudioFormat));
ASSERT_EQ(AV_ERR_OK, aDecEncSample->PrepareDec());
struct OH_AVCodec* audEnc = aDecEncSample->CreateAudioEncoder(MIME_TYPE_AAC);
struct OH_AVCodec* audEnc = aDecEncSample->CreateAudioEncoderByMime(MIME_TYPE_AAC);
ASSERT_NE(nullptr, audEnc);
ASSERT_EQ(AV_ERR_OK, aDecEncSample->ConfigureEnc(AudioFormat));
ASSERT_EQ(AV_ERR_OK, aDecEncSample->PrepareEnc());
......
/*
* 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.
*/
#include <string>
#include "securec.h"
#include "gtest/gtest.h"
#include "audio_info.h"
#include "native_avcodec_base.h"
#include "native_avformat.h"
using namespace std;
using namespace testing::ext;
namespace {
class ActsCodecFormatNdkTest : public testing::Test {
public:
static void SetUpTestCase();
static void TearDownTestCase();
void SetUp() override;
void TearDown() override;
};
void ActsCodecFormatNdkTest::SetUpTestCase() {}
void ActsCodecFormatNdkTest::TearDownTestCase() {}
void ActsCodecFormatNdkTest::SetUp() {}
void ActsCodecFormatNdkTest::TearDown() {}
bool CheckDecDesc(map<string, int> InDesc, OH_AVFormat* OutDesc)
{
int32_t out ;
for (const auto& t: InDesc) {
bool res = OH_AVFormat_GetIntValue(OutDesc, t.first.c_str(), &out);
cout << "key: " << t.first << "; out: " << out <<endl;
if (!res) {
cout << "OH_AVFormat_GetIntValue Fail. key:" << t.first << endl;
return false;
}
if (out != t.second) {
cout << "OH_AVFormat_GetIntValue error. key: " << t.first
<< "; expect: "<< t.second
<< ", actual: "<< out << endl;
return false;
}
out = 0;
}
return true;
}
bool SetFormat(struct OH_AVFormat *format, map<string, int> mediaDescription)
{
const char *key;
for (const auto& t: mediaDescription) {
key = t.first.c_str();
if (not OH_AVFormat_SetIntValue(format, key, t.second)) {
cout << "OH_AV_FormatPutIntValue Fail. format key: " << t.first
<< ", value: "<< t.second << endl;
return false;
}
}
return true;
}
}
/**
* @tc.number : SUB_MULTIMEDIA_MEDIA_CODEC_FORMAT_0100
* @tc.name : test codec format set key
* @tc.desc : Basic function test
*/
HWTEST_F(ActsCodecFormatNdkTest, SUB_MULTIMEDIA_MEDIA_CODEC_FORMAT_0100, TestSize.Level1)
{
OH_AVFormat *codecFormatIn = OH_AVFormat_Create();
ASSERT_NE(nullptr, codecFormatIn);
OH_AVFormat *codecFormatOut = OH_AVFormat_Create();
ASSERT_NE(nullptr, codecFormatOut);
map<string, int> CodecParam = {
{OH_ED_KEY_TIME_STAMP, 200}, // set timestamp 200ms
{OH_ED_KEY_EOS, 1}, // set end of stream
{OH_MD_KEY_TRACK_TYPE, 1}, // set track type video
{OH_MD_KEY_DURATION, 200}, // set key duration 200ms
{OH_MD_KEY_BITRATE, 48000}, // set key bitrate 48000
{OH_MD_KEY_MAX_INPUT_SIZE, 2000}, // set key max input size 2000
{OH_MD_KEY_VIDEO_ENCODE_BITRATE_MODE, 0}, // set videoencoder bitrate mode CBR
{OH_MD_KEY_PROFILE, 1}, // set encode profile AVC_PROFILE_BASELINE
{OH_MD_KEY_I_FRAME_INTERVAL, 1}, // set key i frame 1ms
{OH_MD_KEY_ROTATION, 90}, // set key rotation 0 degree
};
ASSERT_EQ(true, SetFormat(codecFormatIn, CodecParam));
OH_AVFormat_Copy(codecFormatOut, codecFormatIn);
ASSERT_EQ(true, CheckDecDesc(CodecParam, codecFormatOut));
ASSERT_NE(nullptr, OH_AVFormat_DumpInfo(codecFormatOut));
cout << OH_AVFormat_DumpInfo(codecFormatIn) << endl;
OH_AVFormat_Destroy(codecFormatIn);
codecFormatIn = nullptr;
OH_AVFormat_Destroy(codecFormatOut);
codecFormatIn = nullptr;
}
/**
* @tc.number : SUB_MULTIMEDIA_MEDIA_CODEC_FORMAT_0200
* @tc.name : test codec format set and get value
* @tc.desc : Basic function test
*/
HWTEST_F(ActsCodecFormatNdkTest, SUB_MULTIMEDIA_MEDIA_CODEC_FORMAT_0200, TestSize.Level1)
{
const char *intKey = "int value key";
const char *longKey = "long value key";
const char *floatKey = "float value key";
const char *doubleKey = "double value key";
const char *stringKey = "string value key";
const char *stringValue = "string_value";
int32_t intValue = 1;
int64_t longValue = 1;
float floatValue = 1.0;
double doubleValue = 1.0;
OH_AVFormat *codecFormatIn = OH_AVFormat_Create();
ASSERT_NE(nullptr, codecFormatIn);
OH_AVFormat *codecFormatOut = OH_AVFormat_Create();
ASSERT_NE(nullptr, codecFormatOut);
OH_AVFormat_SetIntValue(codecFormatIn, intKey, intValue);
OH_AVFormat_SetLongValue(codecFormatIn, longKey, longValue);
OH_AVFormat_SetFloatValue(codecFormatIn, floatKey, floatValue);
OH_AVFormat_SetDoubleValue(codecFormatIn, doubleKey, doubleValue);
OH_AVFormat_SetStringValue(codecFormatIn, stringKey, stringValue);
OH_AVFormat_Copy(codecFormatOut, codecFormatIn);
int32_t intValueOut;
OH_AVFormat_GetIntValue(codecFormatOut, intKey, &intValueOut);
ASSERT_EQ(intValueOut, intValue);
int64_t longValueOut;
OH_AVFormat_GetLongValue(codecFormatOut, longKey, &longValueOut);
ASSERT_EQ(longValueOut, longValue);
float floatValueOut;
OH_AVFormat_GetFloatValue(codecFormatOut, floatKey, &floatValueOut);
ASSERT_EQ(floatValueOut, floatValue);
double doubleValueOut;
OH_AVFormat_GetDoubleValue(codecFormatOut, doubleKey, &doubleValueOut);
ASSERT_EQ(doubleValueOut, doubleValue);
const char *stringValueOut;
OH_AVFormat_GetStringValue(codecFormatOut, stringKey, &stringValueOut);
ASSERT_EQ(*stringValueOut, *stringValue);
OH_AVFormat_Destroy(codecFormatIn);
codecFormatIn = nullptr;
OH_AVFormat_Destroy(codecFormatOut);
codecFormatOut = nullptr;
}
/**
* @tc.number : SUB_MULTIMEDIA_MEDIA_CODEC_FORMAT_0300
* @tc.name : test codec format set and get buffer
* @tc.desc : Basic function test
*/
HWTEST_F(ActsCodecFormatNdkTest, SUB_MULTIMEDIA_MEDIA_CODEC_FORMAT_0300, TestSize.Level1)
{
const char *bufferKey = "buffer value key";
OH_AVFormat *codecFormatIn = OH_AVFormat_Create();
ASSERT_NE(nullptr, codecFormatIn);
OH_AVFormat *codecFormatOut = OH_AVFormat_Create();
ASSERT_NE(nullptr, codecFormatOut);
int32_t buffernum = 10;
size_t sizeIn = buffernum * sizeof(uint8_t);
uint8_t *buffer = reinterpret_cast<uint8_t *>(malloc(sizeIn));
(void)memset_s(buffer, sizeIn, 1, sizeIn);
OH_AVFormat_SetBuffer(codecFormatIn, bufferKey, buffer, sizeIn);
OH_AVFormat_Copy(codecFormatOut, codecFormatIn);
uint8_t *addrout;
size_t sizeOut;
OH_AVFormat_GetBuffer(codecFormatOut, bufferKey, &addrout, &sizeOut);
ASSERT_EQ(sizeIn, sizeOut);
for (int32_t i = 0; i < buffernum; i++) {
ASSERT_EQ(buffer[i], addrout[i]);
}
OH_AVFormat_Destroy(codecFormatIn);
codecFormatIn = nullptr;
OH_AVFormat_Destroy(codecFormatOut);
codecFormatOut = nullptr;
}
\ No newline at end of file
......@@ -30,6 +30,7 @@
#include "ndktest_log.h"
#include "native_avmagic.h"
#include "surface.h"
#include "native_avcodec_base.h"
#include "native_avcodec_videodecoder.h"
#include "native_avcodec_videoencoder.h"
......@@ -69,6 +70,7 @@ public:
struct OH_AVCodec* CreateVideoDecoderByMime(std::string mimetype);
struct OH_AVCodec* CreateVideoDecoderByName(std::string name);
int32_t ConfigureDec(struct OH_AVFormat *format);
int32_t SetParameterDec(struct OH_AVFormat *format);
int32_t SetOutputSurface();
int32_t PrepareDec();
int32_t StartDec();
......@@ -80,6 +82,7 @@ public:
struct OH_AVCodec* CreateVideoEncoderByMime(std::string mimetype);
struct OH_AVCodec* CreateVideoEncoderByName(std::string name);
int32_t ConfigureEnc(struct OH_AVFormat *format);
int32_t SetParameterEnc(struct OH_AVFormat *format);
int32_t GetSurface();
int32_t PrepareEnc();
int32_t StartEnc();
......@@ -108,6 +111,7 @@ public:
bool isDecOutputEOS = false;
bool isEncOutputEOS = false;
bool setEos = true;
bool needRender = true;
private:
OHNativeWindow *nativeWindow_;
......
......@@ -89,6 +89,7 @@ struct OH_AVFormat* createFormat()
OH_AVFormat_SetIntValue(DefaultFormat, OH_MD_KEY_HEIGHT, DEFAULT_HEIGHT);
OH_AVFormat_SetIntValue(DefaultFormat, OH_MD_KEY_PIXEL_FORMAT, DEFAULT_PIXELFORMAT);
OH_AVFormat_SetIntValue(DefaultFormat, OH_MD_KEY_FRAME_RATE, DEFAULT_FRAMERATE);
OH_AVFormat_SetStringValue(DefaultFormat, OH_MD_KEY_CODEC_MIME, OH_AVCODEC_MIMETYPE_VIDEO_AVC);
return DefaultFormat;
}
}
......@@ -101,13 +102,13 @@ struct OH_AVFormat* createFormat()
HWTEST_F(ActsVideoDecEncNdkTest, SUB_MULTIMEDIA_MEDIA_VIDEO_DEC_ENC_FUNCTION_0100, TestSize.Level1)
{
VDecEncNdkSample *vDecEncSample = new VDecEncNdkSample();
struct OH_AVCodec* videoDec = vDecEncSample->CreateVideoDecoderByMime(MIME_TYPE_AVC);
ASSERT_NE(nullptr, videoDec);
struct OH_AVCodec* videoEnc = vDecEncSample->CreateVideoEncoderByMime(MIME_TYPE_MPEG4);
ASSERT_NE(nullptr, videoEnc);
vDecEncSample->SetReadPath(READPATH);
vDecEncSample->SetSavePath("/data/media/video_001.es");
vDecEncSample->SetSavePath("/data/media/video_001.h264");
OH_AVFormat *VideoFormat = OH_AVFormat_Create();
ASSERT_NE(nullptr, VideoFormat);
......@@ -118,6 +119,8 @@ HWTEST_F(ActsVideoDecEncNdkTest, SUB_MULTIMEDIA_MEDIA_VIDEO_DEC_ENC_FUNCTION_010
{OH_MD_KEY_FRAME_RATE, DEFAULT_FRAMERATE},
};
ASSERT_EQ(true, SetFormat(VideoFormat, VideoParam));
OH_AVFormat_SetIntValue(VideoFormat, OH_MD_KEY_TRACK_TYPE, MEDIA_TYPE_VID);
ASSERT_EQ(AV_ERR_OK, vDecEncSample->ConfigureDec(VideoFormat));
OH_AVFormat *OutDescDec = OH_VideoDecoder_GetOutputDescription(videoDec);
ASSERT_NE(nullptr, OutDescDec);
......@@ -161,17 +164,20 @@ HWTEST_F(ActsVideoDecEncNdkTest, SUB_MULTIMEDIA_MEDIA_VIDEO_DEC_ENC_FUNCTION_020
struct OH_AVCodec* videoEnc = vDecEncSample->CreateVideoEncoderByMime(MIME_TYPE_AVC);
ASSERT_NE(nullptr, videoEnc);
vDecEncSample->SetReadPath(READPATH);
vDecEncSample->SetSavePath("/data/media/video_002.es");
vDecEncSample->SetSavePath("/data/media/video_002.h264");
OH_AVFormat *VideoFormat = createFormat();
ASSERT_EQ(AV_ERR_OK, vDecEncSample->ConfigureDec(VideoFormat));
OH_AVFormat_SetIntValue(VideoFormat, OH_MD_KEY_VIDEO_ENCODE_BITRATE_MODE, CBR);
ASSERT_EQ(AV_ERR_OK, vDecEncSample->ConfigureEnc(VideoFormat));
ASSERT_EQ(AV_ERR_OK, vDecEncSample->GetSurface());
ASSERT_EQ(AV_ERR_OK, vDecEncSample->SetOutputSurface());
ASSERT_EQ(AV_ERR_OK, vDecEncSample->PrepareEnc());
ASSERT_EQ(AV_ERR_OK, vDecEncSample->PrepareDec());
ASSERT_EQ(AV_ERR_OK, vDecEncSample->StartEnc());
ASSERT_EQ(AV_ERR_OK, vDecEncSample->SetParameterDec(VideoFormat));
ASSERT_EQ(AV_ERR_OK, vDecEncSample->StartDec());
ASSERT_EQ(AV_ERR_OK, vDecEncSample->SetParameterEnc(VideoFormat));
while (!vDecEncSample->GetEncEosState()) {};
ASSERT_EQ(AV_ERR_OK, vDecEncSample->ResetDec());
......@@ -185,7 +191,6 @@ HWTEST_F(ActsVideoDecEncNdkTest, SUB_MULTIMEDIA_MEDIA_VIDEO_DEC_ENC_FUNCTION_020
ASSERT_EQ(AV_ERR_OK, vDecEncSample->CalcuError());
}
/**
* @tc.number : SUB_MULTIMEDIA_MEDIA_VIDEO_DEC_ENC_FUNCTION_0300
* @tc.name : release at end of stream
......@@ -200,9 +205,11 @@ HWTEST_F(ActsVideoDecEncNdkTest, SUB_MULTIMEDIA_MEDIA_VIDEO_DEC_ENC_FUNCTION_030
struct OH_AVCodec* videoEnc = vDecEncSample->CreateVideoEncoderByMime(MIME_TYPE_AVC);
ASSERT_NE(nullptr, videoEnc);
vDecEncSample->SetReadPath(READPATH);
vDecEncSample->SetSavePath("/data/media/video_003.es");
vDecEncSample->SetSavePath("/data/media/video_003.h264");
OH_AVFormat *VideoFormat = createFormat();
OH_AVFormat_SetIntValue(VideoFormat, OH_MD_KEY_PROFILE, AVC_PROFILE_BASELINE);
ASSERT_EQ(AV_ERR_OK, vDecEncSample->ConfigureDec(VideoFormat));
ASSERT_EQ(AV_ERR_OK, vDecEncSample->ConfigureEnc(VideoFormat));
ASSERT_EQ(AV_ERR_OK, vDecEncSample->GetSurface());
......@@ -237,9 +244,11 @@ HWTEST_F(ActsVideoDecEncNdkTest, SUB_MULTIMEDIA_MEDIA_VIDEO_DEC_ENC_FUNCTION_040
ASSERT_NE(nullptr, videoEnc);
vDecEncSample->SetReadPath(READPATH);
vDecEncSample->SetEosState(false);
vDecEncSample->SetSavePath("/data/media/video_004.es");
vDecEncSample->SetSavePath("/data/media/video_004.h264");
OH_AVFormat *VideoFormat = createFormat();
OH_AVFormat_SetIntValue(VideoFormat, OH_MD_KEY_PROFILE, AVC_PROFILE_HIGH);
ASSERT_EQ(AV_ERR_OK, vDecEncSample->ConfigureDec(VideoFormat));
ASSERT_EQ(AV_ERR_OK, vDecEncSample->ConfigureEnc(VideoFormat));
ASSERT_EQ(AV_ERR_OK, vDecEncSample->GetSurface());
......@@ -256,7 +265,7 @@ HWTEST_F(ActsVideoDecEncNdkTest, SUB_MULTIMEDIA_MEDIA_VIDEO_DEC_ENC_FUNCTION_040
vDecEncSample->ResetDecParam();
vDecEncSample->ResetEncParam();
vDecEncSample->SetEosState(true);
vDecEncSample->SetSavePath("/data/media/video_004_2.es");
vDecEncSample->SetSavePath("/data/media/video_004_2.h264");
ASSERT_EQ(AV_ERR_OK, vDecEncSample->StartEnc());
ASSERT_EQ(AV_ERR_OK, vDecEncSample->StartDec());
......@@ -287,9 +296,11 @@ HWTEST_F(ActsVideoDecEncNdkTest, SUB_MULTIMEDIA_MEDIA_VIDEO_DEC_ENC_FUNCTION_050
ASSERT_NE(nullptr, videoEnc);
vDecEncSample->SetReadPath(READPATH);
vDecEncSample->SetEosState(false);
vDecEncSample->SetSavePath("/data/media/video_005.es");
vDecEncSample->SetSavePath("/data/media/video_005.h264");
OH_AVFormat *VideoFormat = createFormat();
OH_AVFormat_SetIntValue(VideoFormat, OH_MD_KEY_PROFILE, AVC_PROFILE_MAIN);
ASSERT_EQ(AV_ERR_OK, vDecEncSample->ConfigureDec(VideoFormat));
ASSERT_EQ(AV_ERR_OK, vDecEncSample->ConfigureEnc(VideoFormat));
ASSERT_EQ(AV_ERR_OK, vDecEncSample->GetSurface());
......@@ -306,7 +317,7 @@ HWTEST_F(ActsVideoDecEncNdkTest, SUB_MULTIMEDIA_MEDIA_VIDEO_DEC_ENC_FUNCTION_050
vDecEncSample->ReRead();
vDecEncSample->ResetDecParam();
vDecEncSample->ResetEncParam();
vDecEncSample->SetSavePath("/data/media/video_005_2.es");
vDecEncSample->SetSavePath("/data/media/video_005_2.h264");
vDecEncSample->SetEosState(true);
ASSERT_EQ(AV_ERR_OK, vDecEncSample->CalcuError());
ASSERT_EQ(AV_ERR_OK, vDecEncSample->StartEnc());
......@@ -338,7 +349,7 @@ HWTEST_F(ActsVideoDecEncNdkTest, SUB_MULTIMEDIA_MEDIA_VIDEO_DEC_ENC_FUNCTION_060
ASSERT_NE(nullptr, videoEnc);
vDecEncSample->SetReadPath(READPATH);
vDecEncSample->SetEosState(false);
vDecEncSample->SetSavePath("/data/media/video_006.es");
vDecEncSample->SetSavePath("/data/media/video_006.h264");
OH_AVFormat *VideoFormat = createFormat();
ASSERT_EQ(AV_ERR_OK, vDecEncSample->ConfigureDec(VideoFormat));
......@@ -357,7 +368,7 @@ HWTEST_F(ActsVideoDecEncNdkTest, SUB_MULTIMEDIA_MEDIA_VIDEO_DEC_ENC_FUNCTION_060
vDecEncSample->ResetDecParam();
vDecEncSample->ResetEncParam();
vDecEncSample->SetEosState(true);
vDecEncSample->SetSavePath("/data/media/video_006_2.es");
vDecEncSample->SetSavePath("/data/media/video_006_2.h264");
ASSERT_EQ(AV_ERR_OK, vDecEncSample->StartEnc());
ASSERT_EQ(AV_ERR_OK, vDecEncSample->StartDec());
......@@ -389,7 +400,7 @@ HWTEST_F(ActsVideoDecEncNdkTest, SUB_MULTIMEDIA_MEDIA_VIDEO_DEC_ENC_FUNCTION_070
ASSERT_NE(nullptr, videoEnc);
vDecEncSample->SetReadPath(READPATH);
vDecEncSample->SetEosState(false);
vDecEncSample->SetSavePath("/data/media/video_007.es");
vDecEncSample->SetSavePath("/data/media/video_007.h264");
OH_AVFormat *VideoFormat = createFormat();
ASSERT_EQ(AV_ERR_OK, vDecEncSample->ConfigureDec(VideoFormat));
......@@ -408,7 +419,7 @@ HWTEST_F(ActsVideoDecEncNdkTest, SUB_MULTIMEDIA_MEDIA_VIDEO_DEC_ENC_FUNCTION_070
vDecEncSample->ReRead();
vDecEncSample->ResetDecParam();
vDecEncSample->ResetEncParam();
vDecEncSample->SetSavePath("/data/media/video_007_2.es");
vDecEncSample->SetSavePath("/data/media/video_007_2.h264");
vDecEncSample->SetEosState(true);
ASSERT_EQ(AV_ERR_OK, vDecEncSample->StartEnc());
ASSERT_EQ(AV_ERR_OK, vDecEncSample->StartDec());
......
......@@ -16,6 +16,7 @@
#include "gtest/gtest.h"
#include "audio_info.h"
#include "av_common.h"
#include "native_avcodec_base.h"
#include "avcodec_video_encoder.h"
#include "avcodec_video_decoder.h"
#include "native_avmemory.h"
......@@ -196,7 +197,12 @@ void VDecEncNdkSample::ResetEncParam()
struct OH_AVCodec* VDecEncNdkSample::CreateVideoDecoderByMime(std::string mimetype)
{
vdec_ = OH_VideoDecoder_CreateByMime(mimetype.c_str());
if (mimetype == "video/avc") {
cout << "mimetype == 'video/avc'" << endl;
vdec_ = OH_VideoDecoder_CreateByMime(OH_AVCODEC_MIMETYPE_VIDEO_AVC);
} else {
vdec_ = OH_VideoDecoder_CreateByMime(mimetype.c_str());
}
NDK_CHECK_AND_RETURN_RET_LOG(vdec_ != nullptr, nullptr, "Fatal: OH_VideoDecoder_CreateByMime");
if (vcodecSignal_ == nullptr) {
vcodecSignal_ = new VDecEncSignal();
......@@ -233,6 +239,11 @@ int32_t VDecEncNdkSample::ConfigureDec(struct OH_AVFormat *format)
return OH_VideoDecoder_Configure(vdec_, format);
}
int32_t VDecEncNdkSample::SetParameterDec(struct OH_AVFormat *format)
{
return OH_VideoDecoder_SetParameter(vdec_, format);
}
int32_t VDecEncNdkSample::PrepareDec()
{
return OH_VideoDecoder_Prepare(vdec_);
......@@ -485,7 +496,12 @@ void VDecEncNdkSample::OutputFuncDec()
uint32_t index = vcodecSignal_->outQueueDec_.front();
uint32_t outflag = vcodecSignal_->flagQueueDec_.front();
if (outflag == 0) {
uint32_t ret = OH_VideoDecoder_RenderOutputData(vdec_, index);
uint32_t ret;
if (needRender) {
ret = OH_VideoDecoder_RenderOutputData(vdec_, index);
} else {
ret = OH_VideoDecoder_FreeOutputData(vdec_, index);
}
if (ret == 0) {
decOutCnt_ += 1;
cout << "DEC OUT.: render output success, decOutCnt_ is " << decOutCnt_ << endl;
......@@ -505,7 +521,11 @@ void VDecEncNdkSample::OutputFuncDec()
struct OH_AVCodec* VDecEncNdkSample::CreateVideoEncoderByMime(std::string mimetype)
{
venc_ = OH_VideoEncoder_CreateByMime(mimetype.c_str());
if (mimetype == "video/avc") {
venc_ = OH_VideoEncoder_CreateByMime(OH_AVCODEC_MIMETYPE_VIDEO_AVC);
} else {
venc_ = OH_VideoEncoder_CreateByMime(mimetype.c_str());
}
NDK_CHECK_AND_RETURN_RET_LOG(venc_ != nullptr, nullptr, "Fatal: OH_VideoEncoder_CreateByMime");
if (vcodecSignal_ == nullptr) {
......@@ -542,6 +562,11 @@ int32_t VDecEncNdkSample::ConfigureEnc(struct OH_AVFormat *format)
return OH_VideoEncoder_Configure(venc_, format);
}
int32_t VDecEncNdkSample::SetParameterEnc(struct OH_AVFormat *format)
{
return OH_VideoEncoder_SetParameter(venc_, format);
}
struct VEncObject : public OH_AVCodec {
explicit VEncObject(const std::shared_ptr<AVCodecVideoEncoder> &encoder)
: OH_AVCodec(AVMagic::MEDIA_MAGIC_VIDEO_ENCODER), videoEncoder_(encoder) {}
......
......@@ -20,7 +20,7 @@ import dataSharePredicates from '@ohos.data.dataSharePredicates';
const presetsCount = {
ActsUserFileMgrAlbumJsTest: { albumsCount: 3, assetsCount: 3 },
ActsUserFileMgrBaseJsTest: { albumsCount: 9, assetsCount: 18 },
ActsUserFileMgrBaseJsTest: { albumsCount: 18, assetsCount: 33 },
ActsUserFileMgrFileAssetJsTest: { albumsCount: 45, assetsCount: 87 },
}
......
......@@ -70,9 +70,9 @@ export default function albumCommitModifyCallback(abilityContext) {
* @tc.desc : image album modify albumname
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 0
* @tc.level : Level 2
*/
it('SUB_USERFILE_MGR_ALBUM_COMMITMODIFY_CALLBACK_01', 0, async function (done) {
it('SUB_USERFILE_MGR_ALBUM_COMMITMODIFY_CALLBACK_01', 2, async function (done) {
const testNum = 'SUB_USERFILE_MGR_ALBUM_COMMITMODIFY_CALLBACK_01';
let currentFetchOp = albumFetchOps(testNum, 'Pictures/', 'DynamicCb');
await albumCommitModify(done, testNum, currentFetchOp);
......
......@@ -69,9 +69,9 @@ export default function albumCommitModifyPromise(abilityContext) {
* @tc.desc : album modify albumname
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 0
* @tc.level : Level 2
*/
it('SUB_USERFILE_MGR_ALBUM_COMMITMODIFY_PROMISE_01', 0, async function (done) {
it('SUB_USERFILE_MGR_ALBUM_COMMITMODIFY_PROMISE_01', 2, async function (done) {
const testNum = 'SUB_USERFILE_MGR_ALBUM_COMMITMODIFY_PROMISE_01';
let currentFetchOp = albumFetchOps(testNum, 'Pictures/', 'DynamicPro');
await albumCommitModify(done, testNum, currentFetchOp);
......
......@@ -101,9 +101,9 @@ export default function albumGetFileAssetsCallback(abilityContext) {
* @tc.desc : Album getPhotoAssets
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 0
* @tc.level : Level 1
*/
it('SUB_USERFILE_MGR_ALBUM_GETPHOTOASSETS_CALLBACK_01', 0, async function (done) {
it('SUB_USERFILE_MGR_ALBUM_GETPHOTOASSETS_CALLBACK_01', 1, async function (done) {
const testNum = 'SUB_USERFILE_MGR_ALBUM_GETPHOTOASSETS_CALLBACK_01';
let currentFetchOp = albumFetchOps(testNum, 'Pictures/', 'Static');
await getPhotoAssetsTest(done, testNum, currentFetchOp);
......@@ -115,9 +115,9 @@ export default function albumGetFileAssetsCallback(abilityContext) {
* @tc.desc : invalid AlbumFetchOptions
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 0
* @tc.level : Level 3
*/
it('SUB_USERFILE_MGR_ALBUM_GETPHOTOASSETS_ERRCODE_CALLBACK_01', 0, async function (done) {
it('SUB_USERFILE_MGR_ALBUM_GETPHOTOASSETS_ERRCODE_CALLBACK_01', 3, async function (done) {
const testNum = 'SUB_USERFILE_MGR_ALBUM_GETPHOTOASSETS_ERRCODE_CALLBACK_01';
let currentFetchOp = albumFetchOps(testNum, 'Pictures/', 'Static');
await getPhotoAssetsErrCodeTest(done, testNum, currentFetchOp);
......
......@@ -95,9 +95,9 @@ export default function albumGetFileAssetsPromise(abilityContext) {
* @tc.desc : Album getPhotoAssets
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 0
* @tc.level : Level 1
*/
it('SUB_USERFILE_MGR_ALBUM_GETPHOTOASSETS_PROMISE_01', 0, async function (done) {
it('SUB_USERFILE_MGR_ALBUM_GETPHOTOASSETS_PROMISE_01', 1, async function (done) {
const testNum = 'SUB_USERFILE_MGR_ALBUM_GETPHOTOASSETS_PROMISE_01';
let currentFetchOp = albumFetchOps(testNum, 'Pictures/', 'Static');
await getPhotoAssetsTest(done, testNum, currentFetchOp);
......@@ -109,9 +109,9 @@ export default function albumGetFileAssetsPromise(abilityContext) {
* @tc.desc : invalid AlbumFetchOptions
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 0
* @tc.level : Level 3
*/
it('SUB_USERFILE_MGR_ALBUM_GETPHOTOASSETS_ERRCODE_PROMISE_01', 0, async function (done) {
it('SUB_USERFILE_MGR_ALBUM_GETPHOTOASSETS_ERRCODE_PROMISE_01', 3, async function (done) {
const testNum = 'SUB_USERFILE_MGR_ALBUM_GETPHOTOASSETS_ERRCODE_PROMISE_01';
let currentFetchOp = albumFetchOps(testNum, 'Pictures/', 'Static');
await getPhotoAssetsErrCodeTest(done, testNum, currentFetchOp);
......
......@@ -31,13 +31,16 @@
{
"type": "ShellKit",
"run-command": [
"mkdir -pv /storage/media/100/local/files/Pictures/{Static,On,Off,myAlbum}",
"mkdir -pv /storage/media/100/local/files/Videos/{Static,On,Off,myAlbum}",
"mkdir -pv /storage/media/100/local/files/Audios/{Static,On,Off,myAlbum}",
"mkdir -pv /storage/media/100/local/files/Pictures/{Static,On,Off,myAlbum,deleteCb,deletePro}",
"mkdir -pv /storage/media/100/local/files/Videos/{Static,On,Off,myAlbum,deleteCb,deletePro}",
"mkdir -pv /storage/media/100/local/files/Audios/{Static,On,Off,myAlbum,deleteCb,deletePro}",
"for d in Static; do for i in $$(seq 4); do cp /storage/media/100/local/temp/01.jpg /storage/media/100/local/files/Pictures/$$d/0$$i.jpg; done;done;",
"for d in Static; do for i in $$(seq 4); do cp /storage/media/100/local/temp/01.mp3 /storage/media/100/local/files/Audios/$$d/0$$i.mp3; done;done;",
"for d in Static; do for i in $$(seq 4); do cp /storage/media/100/local/temp/01.mp4 /storage/media/100/local/files/Videos/$$d/0$$i.mp4; done;done;",
"for d in deleteCb deletePro; do for i in $$(seq 2); do cp /storage/media/100/local/temp/01.jpg /storage/media/100/local/files/Pictures/$$d/0$$i.jpg; done;done;",
"for d in deleteCb deletePro; do for i in $$(seq 2); do cp /storage/media/100/local/temp/01.mp3 /storage/media/100/local/files/Audios/$$d/0$$i.mp3; done;done;",
"for d in deleteCb deletePro; do for i in $$(seq 2); do cp /storage/media/100/local/temp/01.mp4 /storage/media/100/local/files/Videos/$$d/0$$i.mp4; done;done;",
"for d in On Off myAlbum; do for i in $$(seq 1); do cp /storage/media/100/local/temp/01.jpg /storage/media/100/local/files/Pictures/$$d/0$$i.jpg; done;done;",
"for d in On Off myAlbum; do for i in $$(seq 1); do cp /storage/media/100/local/temp/01.mp3 /storage/media/100/local/files/Audios/$$d/0$$i.mp3; done;done;",
"for d in On Off myAlbum; do for i in $$(seq 1); do cp /storage/media/100/local/temp/01.mp4 /storage/media/100/local/files/Videos/$$d/0$$i.mp4; done;done;",
......
......@@ -13,6 +13,8 @@
* limitations under the License.
*/
import deleteCallbackTest from './deleteCallback.test.ets'
import deletePromiseTest from './deletePromise.test.ets'
import getAlbumsCallbackTest from './getAlbumsCallback.test.ets'
import getAlbumsPromiseTest from './getAlbumsPromise.test.ets'
import getFileAssetsCallbackTest from './getFileAssetsCallback.test.ets'
......@@ -20,6 +22,8 @@ import getFileAssetsPromiseTest from './getFileAssetsPromise.test.ets'
import getUserFileMgrTest from './getUserFileMgr.test.ets'
import onOffReleasePromiseTest from './onOffReleasePromise.test.ets'
export default function testsuite(abilityContext) {
deleteCallbackTest(abilityContext)
deletePromiseTest(abilityContext)
getAlbumsCallbackTest(abilityContext)
getAlbumsPromiseTest(abilityContext)
getFileAssetsCallbackTest(abilityContext)
......
/*
* 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 userFileManager from '@ohos.filemanagement.userFileManager';
import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from 'deccjsunit/index';
import {
sleep,
audioFetchOps,
imageVideoFetchOps,
checkPresetsAssets,
checkAssetsCount,
getPermission,
} from '../../../../../../common';
export default function deleteCallbackTest(abilityContext) {
describe('deleteCallbackTest', function () {
const userfilemgr = userFileManager.getUserFileMgr(abilityContext);
beforeAll(async function () {
console.info('beforeAll case');
await getPermission();
await checkPresetsAssets(userfilemgr, 'ActsUserFileMgrAlbumJsTest');
});
beforeEach(function () {
console.info('beforeEach case');
});
afterEach(async function () {
console.info('afterEach case');
await sleep()
});
afterAll(function () {
console.info('afterAll case');
});
const deleteTest = async function (done, testNum, fetchOp, isAudio) {
try {
let fetchAssetResult;
if (isAudio) {
fetchAssetResult = await userfilemgr.getAudioAssets(fetchOp);
} else {
fetchAssetResult = await userfilemgr.getPhotoAssets(fetchOp);
}
let expectCount = 2;
let checkAssetCountPass = await checkAssetsCount(done, testNum, fetchAssetResult, expectCount);
if (!checkAssetCountPass) return;
const asset = await fetchAssetResult.getFirstObject();
fetchAssetResult.close();
userfilemgr.delete(asset.uri, async() => {
let newFetchResult;
if (isAudio) {
newFetchResult = await userfilemgr.getAudioAssets(fetchOp);
} else {
newFetchResult = await userfilemgr.getPhotoAssets(fetchOp);
}
expect(newFetchResult.getCount()).assertEqual(1);
newFetchResult.close();
done();
});
} catch (error) {
console.info(`${testNum}, failed: ${error}`);
expect(false).assertTrue();
done();
}
}
/**
* @tc.number : SUB_USERFILE_MGR_DELETE_CALLBACK_01
* @tc.name : delete
* @tc.desc : delete image
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 2
*/
it('SUB_USERFILE_MGR_DELETE_CALLBACK_01', 2, async function (done) {
let testNum = 'SUB_USERFILE_MGR_DELETE_CALLBACK_01';
let currentFetchOp = imageVideoFetchOps(testNum, 'Pictures/deleteCb/');
let isAudio = false;
await deleteTest(done, testNum, currentFetchOp, isAudio);
});
/**
* @tc.number : SUB_USERFILE_MGR_DELETE_CALLBACK_02
* @tc.name : delete
* @tc.desc : delete video
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 2
*/
it('SUB_USERFILE_MGR_DELETE_CALLBACK_02', 2, async function (done) {
let testNum = 'SUB_USERFILE_MGR_DELETE_CALLBACK_02';
let currentFetchOp = imageVideoFetchOps(testNum, 'Videos/deleteCb/');
let isAudio = false;
await deleteTest(done, testNum, currentFetchOp, isAudio);
});
/**
* @tc.number : SUB_USERFILE_MGR_DELETE_CALLBACK_03
* @tc.name : delete
* @tc.desc : delete audio
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 2
*/
it('SUB_USERFILE_MGR_DELETE_CALLBACK_03', 2, async function (done) {
let testNum = 'SUB_USERFILE_MGR_DELETE_CALLBACK_03';
let currentFetchOp = audioFetchOps(testNum, 'Audios/deleteCb/');
let isAudio = true;
await deleteTest(done, testNum, currentFetchOp, isAudio);
});
});
}
/*
* 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 userFileManager from '@ohos.filemanagement.userFileManager';
import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from 'deccjsunit/index';
import {
sleep,
audioFetchOps,
imageVideoFetchOps,
checkPresetsAssets,
checkAssetsCount,
} from '../../../../../../common';
export default function deletePromiseTest(abilityContext) {
describe('deletePromiseTest', function () {
const userfilemgr = userFileManager.getUserFileMgr(abilityContext);
beforeAll(async function () {
console.info('beforeAll case');
await checkPresetsAssets(userfilemgr, 'ActsUserFileMgrAlbumJsTest');
});
beforeEach(function () {
console.info('beforeEach case');
});
afterEach(async function () {
console.info('afterEach case');
await sleep()
});
afterAll(function () {
console.info('afterAll case');
});
const deleteTest = async function (done, testNum, fetchOp, isAudio) {
try {
let fetchAssetResult;
if (isAudio) {
fetchAssetResult = await userfilemgr.getAudioAssets(fetchOp);
} else {
fetchAssetResult = await userfilemgr.getPhotoAssets(fetchOp);
}
let expectCount = 2;
let checkAssetCountPass = await checkAssetsCount(done, testNum, fetchAssetResult, expectCount);
if (!checkAssetCountPass) return;
let asset = await fetchAssetResult.getFirstObject();
fetchAssetResult.close();
await userfilemgr.delete(asset.uri);
let newFetchResult;
if (isAudio) {
newFetchResult = await userfilemgr.getAudioAssets(fetchOp);
} else {
newFetchResult = await userfilemgr.getPhotoAssets(fetchOp);
}
expect(newFetchResult.getCount()).assertEqual(1);
newFetchResult.close();
done();
} catch (error) {
console.info(`${testNum}, failed: ${error}`);
expect(false).assertTrue();
done();
}
}
/**
* @tc.number : SUB_USERFILE_MGR_DELETE_PROMISE_01
* @tc.name : delete
* @tc.desc : delete image
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 2
*/
it('SUB_USERFILE_MGR_DELETE_PROMISE_01', 2, async function (done) {
let testNum = 'SUB_USERFILE_MGR_DELETE_PROMISE_01';
let currentFetchOp = imageVideoFetchOps(testNum, 'Pictures/deletePro/');
let isAudio = false;
await deleteTest(done, testNum, currentFetchOp, isAudio);
});
/**
* @tc.number : SUB_USERFILE_MGR_DELETE_PROMISE_02
* @tc.name : delete
* @tc.desc : delete video
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 2
*/
it('SUB_USERFILE_MGR_DELETE_PROMISE_02', 2, async function (done) {
let testNum = 'SUB_USERFILE_MGR_DELETE_PROMISE_02';
let currentFetchOp = imageVideoFetchOps(testNum, 'Videos/deletePro/');
let isAudio = false;
await deleteTest(done, testNum, currentFetchOp, isAudio);
});
/**
* @tc.number : SUB_USERFILE_MGR_DELETE_PROMISE_03
* @tc.name : delete
* @tc.desc : delete audio
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 2
*/
it('SUB_USERFILE_MGR_DELETE_PROMISE_03', 2, async function (done) {
let testNum = 'SUB_USERFILE_MGR_DELETE_PROMISE_03';
let currentFetchOp = audioFetchOps(testNum, 'Audios/deletePro/');
let isAudio = true;
await deleteTest(done, testNum, currentFetchOp, isAudio);
});
});
}
......@@ -22,7 +22,6 @@ import {
albumFetchOps,
checkPresetsAssets,
checkAssetsCount,
getPermission,
isNum,
} from '../../../../../../common';
......@@ -32,7 +31,6 @@ export default function getAlbumsCallbackTest(abilityContext) {
const userfilemgr = userFileManager.getUserFileMgr(abilityContext);
beforeAll(async function () {
console.info('beforeAll case');
await getPermission();
await checkPresetsAssets(userfilemgr, 'ActsUserFileMgrAlbumJsTest');
});
beforeEach(function () {
......@@ -135,9 +133,9 @@ export default function getAlbumsCallbackTest(abilityContext) {
* @tc.desc : getPhotoAlbums by relativePath && albumName, print all album info
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 0
* @tc.level : Level 1
*/
it('SUB_USERFILE_MGR_GETPHOTOALBUMS_CALLBACK_01', 0, async function (done) {
it('SUB_USERFILE_MGR_GETPHOTOALBUMS_CALLBACK_01', 1, async function (done) {
let testNum = 'SUB_USERFILE_MGR_GETPHOTOALBUMS_CALLBACK_01';
let currentFetchOp = albumFetchOps(testNum, 'Pictures/', 'myAlbum');
let relativePaths = 'Pictures/';
......@@ -150,9 +148,9 @@ export default function getAlbumsCallbackTest(abilityContext) {
* @tc.desc : getPhotoAlbums by invalid
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 0
* @tc.level : Level 3
*/
it('SUB_USERFILE_MGR_GETPHOTOALBUMS_ERRCODE_CALLBACK_01', 0, async function (done) {
it('SUB_USERFILE_MGR_GETPHOTOALBUMS_ERRCODE_CALLBACK_01', 3, async function (done) {
let testNum = 'SUB_USERFILE_MGR_GETPHOTOALBUMS_ERRCODE_CALLBACK_01';
await getPhotoAlbumsErrCodeTest(done, testNum);
});
......
......@@ -115,9 +115,9 @@ export default function getAlbumsPromiseTest(abilityContext) {
* @tc.desc : getPhotoAlbums by relativePath && albumName, print all album info
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 0
* @tc.level : Level 1
*/
it('SUB_USERFILE_MGR_GETPHOTOALBUMS_PROMISE_01', 0, async function (done) {
it('SUB_USERFILE_MGR_GETPHOTOALBUMS_PROMISE_01', 1, async function (done) {
let testNum = 'SUB_USERFILE_MGR_GETPHOTOALBUMS_PROMISE_01';
let currentFetchOp = albumFetchOps(testNum, 'Pictures/', 'myAlbum');
let relativePaths = 'Pictures/';
......@@ -130,9 +130,9 @@ export default function getAlbumsPromiseTest(abilityContext) {
* @tc.desc : getPhotoAlbums by invalid
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 0
* @tc.level : Level 3
*/
it('SUB_USERFILE_MGR_GETPHOTOALBUMS_ERRCODE_PROMISE_01', 0, async function (done) {
it('SUB_USERFILE_MGR_GETPHOTOALBUMS_ERRCODE_PROMISE_01', 3, async function (done) {
let testNum = 'SUB_USERFILE_MGR_GETPHOTOALBUMS_ERRCODE_PROMISE_01';
await getPhotoAlbumsErrCodeTest(done, testNum);
});
......
......@@ -22,6 +22,7 @@ import {
imageVideoFetchOps,
checkPresetsAssets,
checkAssetsCount,
albumFetchOps,
} from '../../../../../../common';
......@@ -71,9 +72,7 @@ export default function onOffReleasePromiseTest(abilityContext) {
const offTest = async (done, testNum, fetchOp, type, newName, isAudio) => {
try {
let count = 0;
userfilemgr.on(type, () => {
count++;
});
userfilemgr.on(type, () => { count++; });
let fetchAssetResult;
if (isAudio) {
fetchAssetResult = await userfilemgr.getAudioAssets(fetchOp);
......@@ -98,15 +97,15 @@ export default function onOffReleasePromiseTest(abilityContext) {
}
/**
* @tc.number : SUB_USERFILE_MGR_ON_PROMISE_01
* @tc.number : SUB_USERFILE_MGR_ON_01
* @tc.name : ON
* @tc.desc : ON image ASSET
* @tc.desc : ON imageChange
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 0
* @tc.level : Level 2
*/
it('SUB_USERFILE_MGR_ON_PROMISE_01', 0, async function (done) {
let testNum = 'SUB_USERFILE_MGR_ON_PROMISE_01';
it('SUB_USERFILE_MGR_ON_01', 2, async function (done) {
let testNum = 'SUB_USERFILE_MGR_ON_01';
let currentFetchOps = imageVideoFetchOps(testNum, 'Pictures/On/');
let type = 'imageChange';
let newName = 'imageChange.jpg';
......@@ -115,15 +114,32 @@ export default function onOffReleasePromiseTest(abilityContext) {
});
/**
* @tc.number : SUB_USERFILE_MGR_ON_PROMISE_02
* @tc.number : SUB_USERFILE_MGR_ON_02
* @tc.name : ON
* @tc.desc : ON audio ASSET
* @tc.desc : ON videoChange
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 0
* @tc.level : Level 2
*/
it('SUB_USERFILE_MGR_ON_PROMISE_02', 0, async function (done) {
let testNum = 'SUB_USERFILE_MGR_ON_PROMISE_02';
it('SUB_USERFILE_MGR_ON_02', 2, async function (done) {
let testNum = 'SUB_USERFILE_MGR_ON_02';
let currentFetchOps = imageVideoFetchOps(testNum, 'Videos/On/');
let type = 'videoChange';
let newName = 'videoChange.mp4';
let isAudio = false;
await onTest(done, testNum, currentFetchOps, type, newName, isAudio)
});
/**
* @tc.number : SUB_USERFILE_MGR_ON_03
* @tc.name : ON
* @tc.desc : ON audioChange
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 2
*/
it('SUB_USERFILE_MGR_ON_03', 2, async function (done) {
let testNum = 'SUB_USERFILE_MGR_ON_03';
let currentFetchOps = audioFetchOps(testNum, 'Audios/On/');
let type = 'audioChange';
let newName = 'audioChange.mp3';
......@@ -132,32 +148,50 @@ export default function onOffReleasePromiseTest(abilityContext) {
});
/**
* @tc.number : SUB_USERFILE_MGR_ON_PROMISE_03
* @tc.number : SUB_USERFILE_MGR_ON_04
* @tc.name : ON
* @tc.desc : ON video ASSET
* @tc.desc : ON albumChange
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 0
* @tc.level : Level 2
*/
it('SUB_USERFILE_MGR_ON_PROMISE_03', 0, async function (done) {
let testNum = 'SUB_USERFILE_MGR_ON_PROMISE_03';
let currentFetchOps = imageVideoFetchOps(testNum, 'Videos/On/');
let type = 'videoChange';
let newName = 'videoChange.mp4';
let isAudio = false;
await onTest(done, testNum, currentFetchOps, type, newName, isAudio)
it('SUB_USERFILE_MGR_ON_04', 2, async function (done) {
let testNum = 'SUB_USERFILE_MGR_ON_04';
try {
let currentFetchOps = albumFetchOps(testNum, 'Pictures/', 'On');
let type: userFileManager.ChangeEvent = 'albumChange';
let count = 0;
userfilemgr.on(type, () => { count++; });
const fetchAlbumResult = await userfilemgr.getPhotoAlbums(currentFetchOps);
let checkAssetCountPass = await checkAssetsCount(done, testNum, fetchAlbumResult, 1);
if (!checkAssetCountPass) return;
const album = await fetchAlbumResult.getFirstObject();
const oldName = album.albumName;
fetchAlbumResult.close();
album.albumName = type.toString();
await album.commitModify();
await sleep(1000);
expect(count > 0).assertTrue();
album.albumName = oldName;
await album.commitModify();
done();
} catch (error) {
console.info(`${testNum}:: error :${error}`);
expect(false).assertTrue();
done();
}
});
/**
* @tc.number : SUB_USERFILE_MGR_OFF_PROMISE_01
* @tc.number : SUB_USERFILE_MGR_OFF_01
* @tc.name : off
* @tc.desc : off image ASSET
* @tc.desc : off imageChange
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 0
* @tc.level : Level 2
*/
it('SUB_USERFILE_MGR_OFF_PROMISE_01', 0, async function (done) {
let testNum = 'SUB_USERFILE_MGR_OFF_PROMISE_01';
it('SUB_USERFILE_MGR_OFF_01', 2, async function (done) {
let testNum = 'SUB_USERFILE_MGR_OFF_01';
let currentFetchOps = imageVideoFetchOps(testNum, 'Pictures/Off/');
let type = 'imageChange';
let newName = 'imageChange.jpg';
......@@ -166,15 +200,32 @@ export default function onOffReleasePromiseTest(abilityContext) {
});
/**
* @tc.number : SUB_USERFILE_MGR_OFF_PROMISE_02
* @tc.number : SUB_USERFILE_MGR_OFF_02
* @tc.name : off
* @tc.desc : off videoChange
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 2
*/
it('SUB_USERFILE_MGR_OFF_02', 2, async function (done) {
let testNum = 'SUB_USERFILE_MGR_OFF_02';
let currentFetchOps = imageVideoFetchOps(testNum, 'Videos/Off/');
let type = 'videoChange';
let newName = 'videoChange.mp4';
let isAudio = false;
await offTest(done, testNum,currentFetchOps, type, newName, isAudio)
});
/**
* @tc.number : SUB_USERFILE_MGR_OFF_03
* @tc.name : off
* @tc.desc : off audio ASSET
* @tc.desc : off audioChange
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 0
* @tc.level : Level 2
*/
it('SUB_USERFILE_MGR_OFF_PROMISE_02', 0, async function (done) {
let testNum = 'SUB_USERFILE_MGR_OFF_PROMISE_02';
it('SUB_USERFILE_MGR_OFF_03', 2, async function (done) {
let testNum = 'SUB_USERFILE_MGR_OFF_03';
let currentFetchOps = audioFetchOps(testNum, 'Audios/Off/');
let type = 'audioChange';
let newName = 'audioChange.mp3';
......@@ -182,33 +233,71 @@ export default function onOffReleasePromiseTest(abilityContext) {
await offTest(done, testNum,currentFetchOps, type, newName, isAudio)
});
/**
* @tc.number : SUB_USERFILE_MGR_OFF_PROMISE_03
/**
* @tc.number : SUB_USERFILE_MGR_OFF_04
* @tc.name : off
* @tc.desc : off video ASSET
* @tc.desc : off albumChange
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 0
* @tc.level : Level 2
*/
it('SUB_USERFILE_MGR_OFF_PROMISE_03', 0, async function (done) {
let testNum = 'SUB_USERFILE_MGR_OFF_PROMISE_03';
let currentFetchOps = imageVideoFetchOps(testNum, 'Videos/Off/');
let type = 'videoChange';
let newName = 'videoChange.mp4';
let isAudio = false;
await offTest(done, testNum,currentFetchOps, type, newName, isAudio)
it('SUB_USERFILE_MGR_OFF_04', 2, async function (done) {
let testNum = 'SUB_USERFILE_MGR_OFF_04';
try {
let currentFetchOps = albumFetchOps(testNum, 'Pictures/', 'Off');
let type: userFileManager.ChangeEvent = 'albumChange';
let count = 0;
userfilemgr.on(type, () => { count++; });
const fetchAlbumResult = await userfilemgr.getPhotoAlbums(currentFetchOps);
let checkAssetCountPass = await checkAssetsCount(done, testNum, fetchAlbumResult, 1);
if (!checkAssetCountPass) return;
const album = await fetchAlbumResult.getFirstObject();
fetchAlbumResult.close();
album.albumName = type.toString();
userfilemgr.off(type);
await album.commitModify();
await sleep(1000);
expect(count).assertEqual(0);
done();
} catch (error) {
console.info(`${testNum}:: error :${error}`);
expect(false).assertTrue();
done();
}
});
/**
* @tc.number : SUB_USERFILE_MGR_RELEASE_CALLBACK_01
* @tc.name : release
* @tc.desc : Release MediaLibrary instance
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 2
*/
it('SUB_USERFILE_MGR_RELEASE_CALLBACK_01', 2, async function (done) {
let testNum = 'SUB_USERFILE_MGR_RELEASE_CALLBACK_01';
try {
userfilemgr.release(() => {
expect(true).assertTrue();
done();
});
} catch (error) {
console.info(`${testNum}:: error :${error}`);
expect(false).assertTrue();
done();
}
});
/**
* @tc.number : SUB_USERFILE_MGR_PROMISE_PROMISE_01
* @tc.number : SUB_USERFILE_MGR_RELEASE_01
* @tc.name : release
* @tc.desc : Release MediaLibrary instance
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 0
* @tc.level : Level 2
*/
it('SUB_USERFILE_MGR_PROMISE_PROMISE_01', 0, async function (done) {
let testNum = 'SUB_USERFILE_MGR_PROMISE_PROMISE_01';
it('SUB_USERFILE_MGR_RELEASE_01', 2, async function (done) {
let testNum = 'SUB_USERFILE_MGR_RELEASE_PROMISE_01';
try {
await userfilemgr.release();
expect(true).assertTrue();
......
......@@ -22,8 +22,6 @@ import fileAssetGetThumbnailCallbackTest from './fileAssetGetThumbnailCallback.t
import fileAssetGetThumbnailPromiseTest from './fileAssetGetThumbnailPromise.test.ets'
import fileAssetOpenCallbackTest from './fileAssetOpenCallback.test.ets'
import fileAssetOpenPromiseTest from './fileAssetOpenPromise.test.ets'
import fileAssetTrashCallbackTest from './fileAssetTrashCallback.test.ets'
import fileAssetTrashPromiseTest from './fileAssetTrashPromise.test.ets'
export default function testsuite(abilityContext) {
fileAssetCommitModifyCallbackTest(abilityContext)
fileAssetCommitModifyPromiseTest(abilityContext)
......@@ -34,6 +32,4 @@ export default function testsuite(abilityContext) {
fileAssetGetThumbnailPromiseTest(abilityContext)
fileAssetOpenCallbackTest(abilityContext)
fileAssetOpenPromiseTest(abilityContext)
fileAssetTrashCallbackTest(abilityContext)
fileAssetTrashPromiseTest(abilityContext)
}
......@@ -15,6 +15,7 @@
import userFileManager from '@ohos.filemanagement.userFileManager';
import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from 'deccjsunit/index';
import dataSharePredicates from '@ohos.data.dataSharePredicates';
import {
sleep,
......@@ -50,15 +51,18 @@ export default function fileAssetCommitModifyCallbackTest(abilityContext) {
const checkCommitModify = async function (done, testNum, fetchOp, prop, val, isAudio) {
try {
let fetchAssetResult;
let fileKey;
if (isAudio) {
fetchAssetResult = await userfilemgr.getAudioAssets(fetchOp);
fileKey = userFileManager.AudioKey;
} else {
fetchAssetResult = await userfilemgr.getPhotoAssets(fetchOp);
fileKey = userFileManager.ImageVideoKey;
}
let checkAssetCountPass = await checkAssetsCount(done, testNum, fetchAssetResult, 1);
if (!checkAssetCountPass) return;
const asset = await fetchAssetResult.getFirstObject();
const oldVal = asset.get(prop);
fetchAssetResult.close();
asset.set(prop, val);
await asset.commitModify(async (err) => {
if (err) {
......@@ -67,9 +71,25 @@ export default function fileAssetCommitModifyCallbackTest(abilityContext) {
done();
return;
}
asset.set(prop, oldVal.toString());
await asset.commitModify();
fetchAssetResult.close();
let predicates = new dataSharePredicates.DataSharePredicates();
predicates.equalTo(fileKey.URI, asset.get(fileKey.URI));
let ops = {
fetchColumns: [],
predicates: predicates
};
let newResult;
if (isAudio) {
newResult = await userfilemgr.getAudioAssets(ops);
} else {
newResult = await userfilemgr.getPhotoAssets(ops);
}
let checkAssetCountPass = await checkAssetsCount(done, testNum, newResult, 1);
if (!checkAssetCountPass) return;
const newAsset = await newResult.getFirstObject();
console.info(`${testNum} newAsset : ${newAsset}`)
newResult.close();
expect(newAsset.get(fileKey.DISPLAY_NAME)).assertEqual(val);
console.info(`${testNum} DISPLAY_NAME : ${newAsset.get(fileKey.DISPLAY_NAME)}`)
done();
});
} catch (error) {
......@@ -82,16 +102,16 @@ export default function fileAssetCommitModifyCallbackTest(abilityContext) {
/**
* @tc.number : SUB_USERFILE_MGR_FILEASSET_COMMITMODIFY_CALLBACK_01
* @tc.name : commitModify
* @tc.desc : image asset modify displayName
* @tc.desc : image asset modify title
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 0
* @tc.level : Level 2
*/
it('SUB_USERFILE_MGR_FILEASSET_COMMITMODIFY_CALLBACK_01', 0, async function (done) {
it('SUB_USERFILE_MGR_FILEASSET_COMMITMODIFY_CALLBACK_01', 2, async function (done) {
let testNum = 'SUB_USERFILE_MGR_FILEASSET_COMMITMODIFY_CALLBACK_01';
let fetchOp = imageVideoNameFetchOps(testNum, 'Pictures/ModifyCb/', '01.jpg');
let prop = 'display_name';
let val = IMAGE_TYPE.toString() + '.jpg';
let prop = 'title';
let val = IMAGE_TYPE.toString();
let isAudio = false;
await checkCommitModify(done, testNum, fetchOp, prop, val, isAudio);
});
......@@ -99,34 +119,34 @@ export default function fileAssetCommitModifyCallbackTest(abilityContext) {
/**
* @tc.number : SUB_USERFILE_MGR_FILEASSET_COMMITMODIFY_CALLBACK_02
* @tc.name : commitModify
* @tc.desc : audio asset modify displayName
* @tc.desc : video asset modify title
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 0
* @tc.level : Level 2
*/
it('SUB_USERFILE_MGR_FILEASSET_COMMITMODIFY_CALLBACK_02', 0, async function (done) {
it('SUB_USERFILE_MGR_FILEASSET_COMMITMODIFY_CALLBACK_02', 2, async function (done) {
let testNum = 'SUB_USERFILE_MGR_FILEASSET_COMMITMODIFY_CALLBACK_02';
let fetchOp = audioNameFetchOps(testNum, 'Audios/ModifyCb/', '01.mp3');
let prop = 'display_name';
let val = AUDIO_TYPE.toString() + '.mp3';
let isAudio = true;
let fetchOp = imageVideoNameFetchOps(testNum, 'Videos/ModifyCb/', '01.mp4');
let prop = 'title';
let val = VIDEO_TYPE.toString();
let isAudio = false;
await checkCommitModify(done, testNum, fetchOp, prop, val, isAudio);
});
/**
* @tc.number : SUB_USERFILE_MGR_FILEASSET_COMMITMODIFY_CALLBACK_03
* @tc.name : commitModify
* @tc.desc : video asset modify displayName
* @tc.desc : audio asset modify title
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 0
* @tc.level : Level 2
*/
it('SUB_USERFILE_MGR_FILEASSET_COMMITMODIFY_CALLBACK_03', 0, async function (done) {
it('SUB_USERFILE_MGR_FILEASSET_COMMITMODIFY_CALLBACK_03', 2, async function (done) {
let testNum = 'SUB_USERFILE_MGR_FILEASSET_COMMITMODIFY_CALLBACK_03';
let fetchOp = imageVideoNameFetchOps(testNum, 'Videos/ModifyCb/', '01.mp4');
let prop = 'display_name';
let val = VIDEO_TYPE.toString() + '.mp4';
let isAudio = false;
let fetchOp = audioNameFetchOps(testNum, 'Audios/ModifyCb/', '01.mp3');
let prop = 'title';
let val = AUDIO_TYPE.toString();
let isAudio = true;
await checkCommitModify(done, testNum, fetchOp, prop, val, isAudio);
});
});
......
......@@ -15,6 +15,7 @@
import userFileManager from '@ohos.filemanagement.userFileManager';
import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from 'deccjsunit/index';
import dataSharePredicates from '@ohos.data.dataSharePredicates';
import {
sleep,
......@@ -48,20 +49,39 @@ export default function fileAssetCommitModifyPromiseTest(abilityContext) {
const checkCommitModify = async function (done, testNum, fetchOp, prop, val, isAudio) {
try {
let fetchAssetResult;
let fileKey;
if (isAudio) {
fetchAssetResult = await userfilemgr.getAudioAssets(fetchOp);
fileKey.userFileManager.AudioKey;
} else {
fetchAssetResult = await userfilemgr.getPhotoAssets(fetchOp);
fileKey = userFileManager.ImageVideoKey;
}
let checkAssetCountPass = await checkAssetsCount(done, testNum, fetchAssetResult, 1);
if (!checkAssetCountPass) return;
const asset = await fetchAssetResult.getFirstObject();
const oldVal = asset.get(prop)
fetchAssetResult.close();
asset.set(prop, val);
await asset.commitModify();
asset.set(prop, oldVal.toString());
await asset.commitModify();
fetchAssetResult.close();
let predicates = new dataSharePredicates.DataSharePredicates();
predicates.equalTo(fileKey.URI, asset.get(fileKey.URI));
let ops = {
fetchColumns: [],
predicates: predicates
};
let newResult;
if (isAudio) {
newResult = await userfilemgr.getAudioAssets(ops);
} else {
newResult = await userfilemgr.getPhotoAssets(ops);
}
checkAssetCountPass = await checkAssetsCount(done, testNum, newResult, 1);
if (!checkAssetCountPass) return;
const newAsset = await newResult.getFirstObject();
console.info(`${testNum} newAsset : ${newAsset}`)
newResult.close();
expect(newAsset.get(fileKey.DISPLAY_NAME)).assertEqual(val);
console.info(`${testNum} DISPLAY_NAME : ${newAsset.get(fileKey.DISPLAY_NAME)}`)
done();
} catch (error) {
console.info(`${testNum} error : ${error}`);
......@@ -73,16 +93,16 @@ export default function fileAssetCommitModifyPromiseTest(abilityContext) {
/**
* @tc.number : SUB_USERFILE_MGR_FILEASSET_COMMITMODIFY_PROMISE_01
* @tc.name : commitModify
* @tc.desc : image asset modify displayName
* @tc.desc : image asset modify title
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 0
* @tc.level : Level 2
*/
it('SUB_USERFILE_MGR_FILEASSET_COMMITMODIFY_PROMISE_01', 0, async function (done) {
it('SUB_USERFILE_MGR_FILEASSET_COMMITMODIFY_PROMISE_01', 2, async function (done) {
let testNum = 'SUB_USERFILE_MGR_FILEASSET_COMMITMODIFY_PROMISE_01';
let fetchOp = imageVideoNameFetchOps(testNum, 'Pictures/ModifyPro/', '01.jpg');
let prop = 'display_name';
let val = IMAGE_TYPE.toString() + '.jpg';
let prop = 'title';
let val = IMAGE_TYPE.toString();
let isAudio = false;
await checkCommitModify(done, testNum, fetchOp, prop, val, isAudio);
});
......@@ -90,34 +110,34 @@ export default function fileAssetCommitModifyPromiseTest(abilityContext) {
/**
* @tc.number : SUB_USERFILE_MGR_FILEASSET_COMMITMODIFY_PROMISE_02
* @tc.name : commitModify
* @tc.desc : audio asset modify displayName
* @tc.desc : video asset modify title
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 0
* @tc.level : Level 2
*/
it('SUB_USERFILE_MGR_FILEASSET_COMMITMODIFY_PROMISE_02', 0, async function (done) {
it('SUB_USERFILE_MGR_FILEASSET_COMMITMODIFY_PROMISE_02', 2, async function (done) {
let testNum = 'SUB_USERFILE_MGR_FILEASSET_COMMITMODIFY_PROMISE_02';
let fetchOp = audioNameFetchOps(testNum, 'Audios/ModifyPro/', '01.mp3');
let prop = 'display_name';
let val = AUDIO_TYPE.toString() + '.mp3';
let isAudio = true;
let fetchOp = imageVideoNameFetchOps(testNum, 'Videos/ModifyPro/', '01.mp4');
let prop = 'title';
let val = VIDEO_TYPE.toString();
let isAudio = false;
await checkCommitModify(done, testNum, fetchOp, prop, val, isAudio);
});
/**
* @tc.number : SUB_USERFILE_MGR_FILEASSET_COMMITMODIFY_PROMISE_03
* @tc.name : commitModify
* @tc.desc : video asset modify displayName
* @tc.desc : audio asset modify title
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 0
* @tc.level : Level 2
*/
it('SUB_USERFILE_MGR_FILEASSET_COMMITMODIFY_PROMISE_03', 0, async function (done) {
it('SUB_USERFILE_MGR_FILEASSET_COMMITMODIFY_PROMISE_03', 2, async function (done) {
let testNum = 'SUB_USERFILE_MGR_FILEASSET_COMMITMODIFY_PROMISE_03';
let fetchOp = imageVideoNameFetchOps(testNum, 'Videos/ModifyPro/', '01.mp4');
let prop = 'display_name';
let val = VIDEO_TYPE.toString() + '.mp4';
let isAudio = false;
let fetchOp = audioNameFetchOps(testNum, 'Audios/ModifyPro/', '01.mp3');
let prop = 'title';
let val = AUDIO_TYPE.toString();
let isAudio = true;
await checkCommitModify(done, testNum, fetchOp, prop, val, isAudio);
});
});
......
......@@ -54,6 +54,7 @@ export default function fileAssetFavoriteCallbackTest(abilityContext) {
let checkAssetCountPass = await checkAssetsCount(done, testNum, fetchAssetResult, 1);
if (!checkAssetCountPass) return;
let asset = await fetchAssetResult.getFirstObject();
console.info(`${testNum} asset: ${asset}`);
asset.isFavorite(async (err, isFavorite) => {
if (err) {
expect(false).assertTrue();
......@@ -82,8 +83,6 @@ export default function fileAssetFavoriteCallbackTest(abilityContext) {
let checkAssetCountPass = await checkAssetsCount(done, testNum, fetchAssetResult, 1);
if (!checkAssetCountPass) return;
const asset = await fetchAssetResult.getFirstObject();
let isFavorite = await asset.isFavorite();
console.info(`${testNum} isFavorite: ${isFavorite}`);
asset.favorite(true, async (err) => {
if(err) {
console.info(`${testNum} failed err: ${err}`);
......@@ -140,9 +139,9 @@ export default function fileAssetFavoriteCallbackTest(abilityContext) {
* @tc.desc : isFavorite(image) result false
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 0
* @tc.level : Level 2
*/
it('SUB_USERFILE_MGR_FILEASSET_FAVORITE_CALLBACK_01_001', 0, async function (done) {
it('SUB_USERFILE_MGR_FILEASSET_FAVORITE_CALLBACK_01_001', 2, async function (done) {
let testNum = 'SUB_USERFILE_MGR_FILEASSET_FAVORITE_CALLBACK_01_001';
let currentFetchOp = imageVideoNameFetchOps(testNum, 'Pictures/FavCb/', '01.jpg');
let isAudio = false;
......@@ -155,9 +154,9 @@ export default function fileAssetFavoriteCallbackTest(abilityContext) {
* @tc.desc : favorite(image) by true
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 0
* @tc.level : Level 2
*/
it('SUB_USERFILE_MGR_FILEASSET_FAVORITE_CALLBACK_01_002', 0, async function (done) {
it('SUB_USERFILE_MGR_FILEASSET_FAVORITE_CALLBACK_01_002', 2, async function (done) {
let testNum = 'SUB_USERFILE_MGR_FILEASSET_FAVORITE_CALLBACK_01_002';
let currentFetchOp = imageVideoNameFetchOps(testNum, 'Pictures/FavCb/', '02.jpg');
let isAudio = false;
......@@ -170,9 +169,9 @@ export default function fileAssetFavoriteCallbackTest(abilityContext) {
* @tc.desc : favorite(image) by false
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 0
* @tc.level : Level 2
*/
it('SUB_USERFILE_MGR_FILEASSET_FAVORITE_CALLBACK_01_003', 0, async function (done) {
it('SUB_USERFILE_MGR_FILEASSET_FAVORITE_CALLBACK_01_003', 2, async function (done) {
let testNum = 'SUB_USERFILE_MGR_FILEASSET_FAVORITE_CALLBACK_01_003';
let currentFetchOp = imageVideoNameFetchOps(testNum, 'Pictures/FavCb/', '03.jpg');
let isAudio = false;
......@@ -182,90 +181,90 @@ export default function fileAssetFavoriteCallbackTest(abilityContext) {
/**
* @tc.number : SUB_USERFILE_MGR_FILEASSET_FAVORITE_CALLBACK_02_001
* @tc.name : isFavorite
* @tc.desc : isFavorite(audio) result false
* @tc.desc : isFavorite(video) result false
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 0
* @tc.level : Level 2
*/
it('SUB_USERFILE_MGR_FILEASSET_FAVORITE_CALLBACK_02_001', 0, async function (done) {
it('SUB_USERFILE_MGR_FILEASSET_FAVORITE_CALLBACK_02_001', 2, async function (done) {
let testNum = 'SUB_USERFILE_MGR_FILEASSET_FAVORITE_CALLBACK_02_001';
let currentFetchOp = audioNameFetchOps(testNum, 'Audios/FavCb/', '01.mp3');
let isAudio = true;
let currentFetchOp = imageVideoNameFetchOps(testNum, 'Videos/FavCb/', '01.mp4');
let isAudio = false;
await favoriteDefaultState(done, testNum, currentFetchOp, isAudio);
});
/**
* @tc.number : SUB_USERFILE_MGR_FILEASSET_FAVORITE_CALLBACK_02_002
* @tc.name : favorite
* @tc.desc : favorite(audio) by true
* @tc.desc : favorite(video) by true
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 0
* @tc.level : Level 2
*/
it('SUB_USERFILE_MGR_FILEASSET_FAVORITE_CALLBACK_02_002', 0, async function (done) {
it('SUB_USERFILE_MGR_FILEASSET_FAVORITE_CALLBACK_02_002', 2, async function (done) {
let testNum = 'SUB_USERFILE_MGR_FILEASSET_FAVORITE_CALLBACK_02_002';
let currentFetchOp = audioNameFetchOps(testNum, 'Audios/FavCb/', '02.mp3');
let isAudio = true;
let currentFetchOp = imageVideoNameFetchOps(testNum, 'Videos/FavCb/', '02.mp4');
let isAudio = false;
await favoriteByTrue(done, testNum, currentFetchOp, isAudio);
});
/**
* @tc.number : SUB_USERFILE_MGR_FILEASSET_FAVORITE_CALLBACK_02_003
* @tc.name : favorite
* @tc.desc : favorite(audio) by false
* @tc.desc : favorite(video) by false
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 0
* @tc.level : Level 2
*/
it('SUB_USERFILE_MGR_FILEASSET_FAVORITE_CALLBACK_02_003', 0, async function (done) {
it('SUB_USERFILE_MGR_FILEASSET_FAVORITE_CALLBACK_02_003', 2, async function (done) {
let testNum = 'SUB_USERFILE_MGR_FILEASSET_FAVORITE_CALLBACK_02_003';
let currentFetchOp = audioNameFetchOps(testNum, 'Audios/FavCb/', '03.mp3');
let isAudio = true;
let currentFetchOp = imageVideoNameFetchOps(testNum, 'Videos/FavCb/', '03.mp4');
let isAudio = false;
await favoriteByFalse(done, testNum, currentFetchOp, isAudio);
});
/**
* @tc.number : SUB_USERFILE_MGR_FILEASSET_FAVORITE_CALLBACK_03_001
* @tc.name : isFavorite
* @tc.desc : isFavorite(video) result false
* @tc.desc : isFavorite(audio) result false
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 0
* @tc.level : Level 2
*/
it('SUB_USERFILE_MGR_FILEASSET_FAVORITE_CALLBACK_03_001', 0, async function (done) {
it('SUB_USERFILE_MGR_FILEASSET_FAVORITE_CALLBACK_03_001', 2, async function (done) {
let testNum = 'SUB_USERFILE_MGR_FILEASSET_FAVORITE_CALLBACK_03_001';
let currentFetchOp = imageVideoNameFetchOps(testNum, 'Videos/FavCb/', '01.mp4');
let isAudio = false;
let currentFetchOp = audioNameFetchOps(testNum, 'Audios/FavCb/', '01.mp3');
let isAudio = true;
await favoriteDefaultState(done, testNum, currentFetchOp, isAudio);
});
/**
* @tc.number : SUB_USERFILE_MGR_FILEASSET_FAVORITE_CALLBACK_03_002
* @tc.name : favorite
* @tc.desc : favorite(video) by true
* @tc.desc : favorite(audio) by true
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 0
* @tc.level : Level 2
*/
it('SUB_USERFILE_MGR_FILEASSET_FAVORITE_CALLBACK_03_002', 0, async function (done) {
it('SUB_USERFILE_MGR_FILEASSET_FAVORITE_CALLBACK_03_002', 2, async function (done) {
let testNum = 'SUB_USERFILE_MGR_FILEASSET_FAVORITE_CALLBACK_03_002';
let currentFetchOp = imageVideoNameFetchOps(testNum, 'Videos/FavCb/', '02.mp4');
let isAudio = false;
let currentFetchOp = audioNameFetchOps(testNum, 'Audios/FavCb/', '02.mp3');
let isAudio = true;
await favoriteByTrue(done, testNum, currentFetchOp, isAudio);
});
/**
* @tc.number : SUB_USERFILE_MGR_FILEASSET_FAVORITE_CALLBACK_03_003
* @tc.name : favorite
* @tc.desc : favorite(video) by false
* @tc.desc : favorite(audio) by false
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 0
* @tc.level : Level 2
*/
it('SUB_USERFILE_MGR_FILEASSET_FAVORITE_CALLBACK_03_003', 0, async function (done) {
it('SUB_USERFILE_MGR_FILEASSET_FAVORITE_CALLBACK_03_003', 2, async function (done) {
let testNum = 'SUB_USERFILE_MGR_FILEASSET_FAVORITE_CALLBACK_03_003';
let currentFetchOp = imageVideoNameFetchOps(testNum, 'Videos/FavCb/', '03.mp4');
let isAudio = false;
let currentFetchOp = audioNameFetchOps(testNum, 'Audios/FavCb/', '03.mp3');
let isAudio = true;
await favoriteByFalse(done, testNum, currentFetchOp, isAudio);
});
});
......
......@@ -114,9 +114,9 @@ export default function fileAssetFavoritePromiseTest(abilityContext) {
* @tc.desc : isFavorite(image) result false
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 0
* @tc.level : Level 2
*/
it('SUB_USERFILE_MGR_FILEASSET_FAVORITE_PROMISE_01_001', 0, async function (done) {
it('SUB_USERFILE_MGR_FILEASSET_FAVORITE_PROMISE_01_001', 2, async function (done) {
let testNum = 'SUB_USERFILE_MGR_FILEASSET_FAVORITE_PROMISE_01_001';
let currentFetchOp = imageVideoNameFetchOps(testNum, 'Pictures/FavPro/', '01.jpg');
let isAudio = false;
......@@ -129,9 +129,9 @@ export default function fileAssetFavoritePromiseTest(abilityContext) {
* @tc.desc : favorite(image) by true
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 0
* @tc.level : Level 2
*/
it('SUB_USERFILE_MGR_FILEASSET_FAVORITE_PROMISE_01_002', 0, async function (done) {
it('SUB_USERFILE_MGR_FILEASSET_FAVORITE_PROMISE_01_002', 2, async function (done) {
let testNum = 'SUB_USERFILE_MGR_FILEASSET_FAVORITE_PROMISE_01_002';
let currentFetchOp = imageVideoNameFetchOps(testNum, 'Pictures/FavPro/', '02.jpg');
let isAudio = false;
......@@ -144,9 +144,9 @@ export default function fileAssetFavoritePromiseTest(abilityContext) {
* @tc.desc : favorite(image) by false
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 0
* @tc.level : Level 2
*/
it('SUB_USERFILE_MGR_FILEASSET_FAVORITE_PROMISE_01_003', 0, async function (done) {
it('SUB_USERFILE_MGR_FILEASSET_FAVORITE_PROMISE_01_003', 2, async function (done) {
let testNum = 'SUB_USERFILE_MGR_FILEASSET_FAVORITE_PROMISE_01_003';
let currentFetchOp = imageVideoNameFetchOps(testNum, 'Pictures/FavPro/', '03.jpg');
let isAudio = false;
......@@ -156,90 +156,90 @@ export default function fileAssetFavoritePromiseTest(abilityContext) {
/**
* @tc.number : SUB_USERFILE_MGR_FILEASSET_FAVORITE_PROMISE_02_001
* @tc.name : isFavorite
* @tc.desc : isFavorite(audio) result false
* @tc.desc : isFavorite(video) result false
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 0
* @tc.level : Level 2
*/
it('SUB_USERFILE_MGR_FILEASSET_FAVORITE_PROMISE_02_001', 0, async function (done) {
it('SUB_USERFILE_MGR_FILEASSET_FAVORITE_PROMISE_02_001', 2, async function (done) {
let testNum = 'SUB_USERFILE_MGR_FILEASSET_FAVORITE_PROMISE_02_001';
let currentFetchOp = audioNameFetchOps(testNum, 'Audios/FavPro/', '01.mp3');
let isAudio = true;
let currentFetchOp = imageVideoNameFetchOps(testNum, 'Videos/FavPro/', '01.mp4');
let isAudio = false;
await favoriteDefaultState(done, testNum, currentFetchOp, isAudio);
});
/**
* @tc.number : SUB_USERFILE_MGR_FILEASSET_FAVORITE_PROMISE_02_002
* @tc.name : favorite
* @tc.desc : favorite(audio) by true
* @tc.desc : favorite(video) by true
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 0
* @tc.level : Level 2
*/
it('SUB_USERFILE_MGR_FILEASSET_FAVORITE_PROMISE_02_002', 0, async function (done) {
it('SUB_USERFILE_MGR_FILEASSET_FAVORITE_PROMISE_02_002', 2, async function (done) {
let testNum = 'SUB_USERFILE_MGR_FILEASSET_FAVORITE_PROMISE_02_002';
let currentFetchOp = audioNameFetchOps(testNum, 'Audios/FavPro/', '02.mp3');
let isAudio = true;
let currentFetchOp = imageVideoNameFetchOps(testNum, 'Videos/FavPro/', '02.mp4');
let isAudio = false;
await favoriteByTrue(done, testNum, currentFetchOp, isAudio);
});
/**
* @tc.number : SUB_USERFILE_MGR_FILEASSET_FAVORITE_PROMISE_03_003
* @tc.number : SUB_USERFILE_MGR_FILEASSET_FAVORITE_PROMISE_02_003
* @tc.name : favorite
* @tc.desc : favorite(audio) by false
* @tc.desc : favorite(video) by false
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 0
* @tc.level : Level 2
*/
it('SUB_USERFILE_MGR_FILEASSET_FAVORITE_PROMISE_03_003', 0, async function (done) {
let testNum = 'SUB_USERFILE_MGR_FILEASSET_FAVORITE_PROMISE_03_003';
let currentFetchOp = audioNameFetchOps(testNum, 'Audios/FavPro/', '03.mp3');
let isAudio = true;
it('SUB_USERFILE_MGR_FILEASSET_FAVORITE_PROMISE_02_003', 2, async function (done) {
let testNum = 'SUB_USERFILE_MGR_FILEASSET_FAVORITE_PROMISE_02_003';
let currentFetchOp = imageVideoNameFetchOps(testNum, 'Videos/FavPro/', '03.mp4');
let isAudio = false;
await favoriteByFalse(done, testNum, currentFetchOp, isAudio);
});
/**
* @tc.number : SUB_USERFILE_MGR_FILEASSET_FAVORITE_PROMISE_03_001
* @tc.name : isFavorite
* @tc.desc : isFavorite(video) result false
* @tc.desc : isFavorite(audio) result false
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 0
* @tc.level : Level 2
*/
it('SUB_USERFILE_MGR_FILEASSET_FAVORITE_PROMISE_03_001', 0, async function (done) {
it('SUB_USERFILE_MGR_FILEASSET_FAVORITE_PROMISE_03_001', 2, async function (done) {
let testNum = 'SUB_USERFILE_MGR_FILEASSET_FAVORITE_PROMISE_03_001';
let currentFetchOp = imageVideoNameFetchOps(testNum, 'Videos/FavPro/', '01.mp4');
let isAudio = false;
let currentFetchOp = audioNameFetchOps(testNum, 'Audios/FavPro/', '01.mp3');
let isAudio = true;
await favoriteDefaultState(done, testNum, currentFetchOp, isAudio);
});
/**
* @tc.number : SUB_USERFILE_MGR_FILEASSET_FAVORITE_PROMISE_03_002
* @tc.name : favorite
* @tc.desc : favorite(video) by true
* @tc.desc : favorite(audio) by true
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 0
* @tc.level : Level 2
*/
it('SUB_USERFILE_MGR_FILEASSET_FAVORITE_PROMISE_03_002', 0, async function (done) {
it('SUB_USERFILE_MGR_FILEASSET_FAVORITE_PROMISE_03_002', 2, async function (done) {
let testNum = 'SUB_USERFILE_MGR_FILEASSET_FAVORITE_PROMISE_03_002';
let currentFetchOp = imageVideoNameFetchOps(testNum, 'Videos/FavPro/', '02.mp4');
let isAudio = false;
let currentFetchOp = audioNameFetchOps(testNum, 'Audios/FavPro/', '02.mp3');
let isAudio = true;
await favoriteByTrue(done, testNum, currentFetchOp, isAudio);
});
/**
* @tc.number : SUB_USERFILE_MGR_FILEASSET_FAVORITE_PROMISE_03_003
* @tc.name : favorite
* @tc.desc : favorite(video) by false
* @tc.desc : favorite(audio) by false
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 0
* @tc.level : Level 2
*/
it('SUB_USERFILE_MGR_FILEASSET_FAVORITE_PROMISE_03_003', 0, async function (done) {
it('SUB_USERFILE_MGR_FILEASSET_FAVORITE_PROMISE_03_003', 2, async function (done) {
let testNum = 'SUB_USERFILE_MGR_FILEASSET_FAVORITE_PROMISE_03_003';
let currentFetchOp = imageVideoNameFetchOps(testNum, 'Videos/FavPro/', '03.mp4');
let isAudio = false;
let currentFetchOp = audioNameFetchOps(testNum, 'Audios/FavPro/', '03.mp3');
let isAudio = true;
await favoriteByFalse(done, testNum, currentFetchOp, isAudio);
});
});
......
......@@ -39,6 +39,25 @@ export default function userFileMgrNoPermissionCallback(abilityContext) {
console.info('afterAll case');
});
const getPhotoAlbumsTest = async function (done, testNum) {
try {
await userfilemgr.getPhotoAlbums(allFetchOp(), async (err, fetchAlbumResult) => {
if (err != undefined) {
console.info(`${testNum}, err: ${err}`);
expect(true).assertTrue();
done();
return;
}
expect(false).assertTrue();
done();
})
} catch (error) {
console.info(`${testNum}, failed error: ${error}`)
expect(false).assertTrue();
done();
}
}
const getPhotoAssetsTest = async function (done, testNum) {
try {
await userfilemgr.getPhotoAssets(allFetchOp(), async (err, fetchAssetResult) => {
......@@ -58,9 +77,9 @@ export default function userFileMgrNoPermissionCallback(abilityContext) {
}
}
const getPhotoAlbumsTest = async function (done, testNum) {
const getAudioAssetsTest = async function (done, testNum) {
try {
await userfilemgr.getPhotoAlbums(allFetchOp(), async (err, fetchAlbumResult) => {
await userfilemgr.getAudioAssets(allFetchOp(), async (err, fetchAssetResult) => {
if (err != undefined) {
console.info(`${testNum}, err: ${err}`);
expect(true).assertTrue();
......@@ -78,31 +97,42 @@ export default function userFileMgrNoPermissionCallback(abilityContext) {
}
/**
* @tc.number : SUB_USERFILE_MGR_GETFILEASSETS_NOPERMISSION_CALLBACK_01
* @tc.number : SUB_USERFILE_MGR_GETPHOTOALBUMS_NOPERMISSION_CALLBACK_01
* @tc.name : getPhotoAlbums
* @tc.desc : getPhotoAlbums with no permission
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 1
*/
it('SUB_USERFILE_MGR_GETPHOTOALBUMS_NOPERMISSION_CALLBACK_01', 1, async function (done) {
const testNum = 'SUB_USERFILE_MGR_GETPHOTOALBUMS_NOPERMISSION_CALLBACK_01';
await getPhotoAlbumsTest(done, testNum);
});
/**
* @tc.number : SUB_USERFILE_MGR_GETPHOTOASSETS_NOPERMISSION_CALLBACK_01
* @tc.name : getPhotoAssets
* @tc.desc : getPhotoAssets(image) with no permission
* @tc.desc : getPhotoAssets with no permission
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 0
* @tc.level : Level 1
*/
it('SUB_USERFILE_MGR_GETFILEASSETS_NOPERMISSION_CALLBACK_01', 0, async function (done) {
const testNum = 'SUB_USERFILE_MGR_GETFILEASSETS_NOPERMISSION_CALLBACK_01';
it('SUB_USERFILE_MGR_GETPHOTOASSETS_NOPERMISSION_CALLBACK_01', 1, async function (done) {
const testNum = 'SUB_USERFILE_MGR_GETPHOTOASSETS_NOPERMISSION_CALLBACK_01';
await getPhotoAssetsTest(done, testNum);
});
//--------------------------------------------------------------------------------------
/**
* @tc.number : SUB_USERFILE_MGR_GETPHOTOALBUMS_NOPERMISSION_CALLBACK_01
* @tc.name : getPhotoAlbums
* @tc.desc : getPhotoAlbums with no permission
* @tc.number : SUB_USERFILE_MGR_GETAUDIOASSETS_NOPERMISSION_CALLBACK_01
* @tc.name : getAudioAssets
* @tc.desc : getAudioAssets with no permission
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 0
* @tc.level : Level 1
*/
it('SUB_USERFILE_MGR_GETPHOTOALBUMS_NOPERMISSION_CALLBACK_01', 0, async function (done) {
const testNum = 'SUB_USERFILE_MGR_GETPHOTOALBUMS_NOPERMISSION_CALLBACK_01';
await getPhotoAlbumsTest(done, testNum);
it('SUB_USERFILE_MGR_GETAUDIOASSETS_NOPERMISSION_CALLBACK_01', 1, async function (done) {
const testNum = 'SUB_USERFILE_MGR_GETAUDIOASSETS_NOPERMISSION_CALLBACK_01';
await getAudioAssetsTest(done, testNum);
});
});
}
......
......@@ -38,6 +38,18 @@ export default function userFileMgrNoPermissionPromise(abilityContext) {
afterAll(function () {
console.info('afterAll case');
});
const getPhotoAlbumsTest = async function (done, testNum) {
try {
await userfilemgr.getPhotoAlbums(allFetchOp());
expect(false).assertTrue();
done();
} catch (error) {
console.info(`${testNum}, failed error: ${error}`)
expect(true).assertTrue();
done();
}
}
const getPhotoAssetsTest = async function (done, testNum) {
try {
......@@ -51,9 +63,9 @@ export default function userFileMgrNoPermissionPromise(abilityContext) {
}
}
const getPhotoAlbumsTest = async function (done, testNum) {
const getAudioAssetsTest = async function (done, testNum) {
try {
await userfilemgr.getPhotoAlbums(allFetchOp());
await userfilemgr.getAudioAssets(allFetchOp());
expect(false).assertTrue();
done();
} catch (error) {
......@@ -64,31 +76,42 @@ export default function userFileMgrNoPermissionPromise(abilityContext) {
}
/**
* @tc.number : SUB_USERFILE_MGR_GETFILEASSETS_NOPERMISSION_PROMISE_01
* @tc.number : SUB_USERFILE_MGR_GETALBUMS_NOPERMISSION_PROMISE_01
* @tc.name : getPhotoAlbums
* @tc.desc : getPhotoAlbums with no permission
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 1
*/
it('SUB_USERFILE_MGR_GETALBUMS_NOPERMISSION_PROMISE_01', 1, async function (done) {
const testNum = 'SUB_USERFILE_MGR_GETALBUMS_NOPERMISSION_PROMISE_01';
await getPhotoAlbumsTest(done, testNum);
});
/**
* @tc.number : SUB_USERFILE_MGR_GETPHOTOASSETS_NOPERMISSION_PROMISE_01
* @tc.name : getPhotoAssets
* @tc.desc : getPhotoAssets(image) with no permission
* @tc.desc : getPhotoAssets with no permission
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 0
* @tc.level : Level 1
*/
it('SUB_USERFILE_MGR_GETFILEASSETS_NOPERMISSION_PROMISE_01', 0, async function (done) {
const testNum = 'SUB_USERFILE_MGR_GETFILEASSETS_NOPERMISSION_PROMISE_01';
it('SUB_USERFILE_MGR_GETPHOTOASSETS_NOPERMISSION_PROMISE_01', 1, async function (done) {
const testNum = 'SUB_USERFILE_MGR_GETPHOTOASSETS_NOPERMISSION_PROMISE_01';
await getPhotoAssetsTest(done, testNum);
});
//--------------------------------------------------------------------------------------
/**
* @tc.number : SUB_USERFILE_MGR_GETALBUMS_NOPERMISSION_PROMISE_01
* @tc.name : getPhotoAlbums
* @tc.desc : getPhotoAlbums with no permission
* @tc.number : SUB_USERFILE_MGR_GETAUDIOASSETS_NOPERMISSION_PROMISE_01
* @tc.name : getAudioAssets
* @tc.desc : getAudioAssets with no permission
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 0
* @tc.level : Level 1
*/
it('SUB_USERFILE_MGR_GETALBUMS_NOPERMISSION_PROMISE_01', 0, async function (done) {
const testNum = 'SUB_USERFILE_MGR_GETALBUMS_NOPERMISSION_PROMISE_01';
await getPhotoAlbumsTest(done, testNum);
it('SUB_USERFILE_MGR_GETAUDIOASSETS_NOPERMISSION_PROMISE_01', 1, async function (done) {
const testNum = 'SUB_USERFILE_MGR_GETAUDIOASSETS_NOPERMISSION_PROMISE_01';
await getAudioAssetsTest(done, testNum);
});
});
}
......
# Copyright (c) 2021 Huawei Device Co., Ltd.
# 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
......@@ -16,6 +16,10 @@ import("//build/ohos_var.gni")
group("ces_standard") {
testonly = true
if (is_standard_system) {
deps = [ "subscribeandpublish:SubscribeAndPublish" ]
deps = [
"actsCommonEventManagerSupportTest:ActsCommonEventManagerSupportTest",
"actsCommonEventSupportTest:ActsCommonEventSupportTest",
"subscribeandpublish:SubscribeAndPublish",
]
}
}
# 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("//test/xts/tools/build/suite.gni")
ohos_js_hap_suite("ActsCommonEventManagerSupportTest") {
hap_profile = "./src/main/config.json"
deps = [
":hjs_demo_js_assets",
":hjs_demo_resources",
]
certificate_profile = "./signature/openharmony_sx.p7b"
hap_name = "ActsCommonEventManagerSupportTest"
subsystem_name = "notification"
part_name = "common_event_service"
}
ohos_js_assets("hjs_demo_js_assets") {
js2abc = true
hap_profile = "./src/main/config.json"
source_dir = "./src/main/js"
}
ohos_resources("hjs_demo_resources") {
sources = [ "./src/main/resources" ]
hap_profile = "./src/main/config.json"
}
此差异已折叠。
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册