提交 142e3b4c 编写于 作者: D dy

aafwk update ets test

Signed-off-by: Ndy <dingyao5@huawei.com>
上级 17e6a0c6
......@@ -718,4 +718,133 @@ it('ACTS_ARelease_0100', 0, async function (done) {
}
})
/*
* @tc.number: ACTS_Call_0100
* @tc.name: call : Inserts a single data record into the database.
* @tc.desc: Check the return value of the interface (by promise)
* @tc.level 0
*/
it("ACTS_Call_0100", 0, async function (done) {
console.log('ACTS_Call_0100 start......');
var pacMap = {
'group_name': 'test1',
'ringtone_modify_time': 28
};
var rDAHelper
try {
rDAHelper = featureAbility.acquireDataAbilityHelper(dataAbilityUri);
console.debug('ACTS_AbeforeAll rDAHelper ====>: ' + rDAHelper + " ,JSON. " + JSON.stringify(rDAHelper));
expect(typeof (rDAHelper)).assertEqual("object");
pacMap.group_name = 'test2';
rDAHelper.call(dataAbilityUri, 'insert', '', pacMap).then((data) => {
console.info('ACTS_Call_0100 succeeded data: ' + JSON.stringify(data));
}).catch((error) => {
console.error('ACTS_Call_0100 error: ' + JSON.stringify(error));
});
done();
} catch (err) {
console.error('ACTS_Call_0100 catch(err)====>:' + err);
console.log('ACTS_Call_0100====<end catch(err)');
done();
}
console.log('ACTS_Call_0100 end......');
})
/*
* @tc.number: ACTS_Call_0200
* @tc.name: call : Queries data in the database.
* @tc.desc: Check the return value of the interface
* @tc.level 0
*/
it("ACTS_Call_0200", 0, async function (done) {
console.log('ACTS_Call_0200 start......');
var arg = "{\"equalTo\": \"group_name\"}";
var pacMap = {
"group_name": "test1",
"columns": "group_name,ringtone_modify_time"
};
var rDAHelper
try {
rDAHelper = featureAbility.acquireDataAbilityHelper(dataAbilityUri);
console.debug('ACTS_AbeforeAll rDAHelper ====>: ' + rDAHelper + " ,JSON. " + JSON.stringify(rDAHelper));
rDAHelper.call(dataAbilityUri, 'query', arg, pacMap, (err, data) => {
if (err) {
console.error('ACTS_Call_0200 error: ' + JSON.stringify(err));
} else {
console.info('ACTS_Call_0200 succeeded: ' + JSON.stringify(data));
}
});
} catch (err) {
console.error('ACTS_Call_0200 catch(err)====>:' + err);
console.log('ACTS_Call_0200====<end catch(err)');
done();
}
console.log('ACTS_Call_0200 end......');
})
/*
* @tc.number: ACTS_Call_0300
* @tc.name: call : Updates data records in the database.
* @tc.desc: Check the return value of the interface
* @tc.level 0
*/
it("ACTS_Call_0300", 0, async function (done) {
console.log('ACTS_Call_0300 start......');
var arg = "{\"equalTo\": \"ringtone_modify_time\"}";
var pacMap = {
'ringtone_modify_time': 28,
'group_name': 'testupdata1'
};
var rDAHelper
try {
rDAHelper = featureAbility.acquireDataAbilityHelper(dataAbilityUri);
console.debug('ACTS_AbeforeAll rDAHelper ====>: ' + rDAHelper + " ,JSON. " + JSON.stringify(rDAHelper));
rDAHelper.call(dataAbilityUri, 'update', arg, pacMap, (err, data) => {
if (err) {
console.error('ACTS_Call_0300 error: ' + JSON.stringify(err));
} else {
console.info('ACTS_Call_0300 succeeded: ' + JSON.stringify(data));
}
});
} catch (err) {
console.error('ACTS_Call_0300 catch(err)====>:' + err);
console.log('ACTS_Call_0300====<end catch(err)');
done();
}
console.log('ACTS_Call_0300 end......');
})
/*
* @tc.number: ACTS_Call_0400
* @tc.name: call : Deletes one or more data records from the database.
* @tc.desc: Check the return value of the interface
* @tc.level 0
*/
it("ACTS_Call_0400", 0, async function (done) {
console.log('ACTS_Call_0400 start......');
var arg = "{\"lessThan\": \"ringtone_modify_time\"}";
var pacMap = {
'ringtone_modify_time': 32,
};
var rDAHelper
try {
rDAHelper = featureAbility.acquireDataAbilityHelper(dataAbilityUri);
console.debug('ACTS_AbeforeAll rDAHelper ====>: ' + rDAHelper + " ,JSON. " + JSON.stringify(rDAHelper));
rDAHelper.call(dataAbilityUri, 'delete', arg, pacMap, (err, data) => {
if (err) {
console.error('ACTS_Call_0400 error: ' + JSON.stringify(err));
} else {
console.info('ACTS_Call_0400 succeeded: ' + JSON.stringify(data));
}
});
done();
} catch (err) {
console.error('ACTS_Call_0400 catch(err)====>:' + err);
console.log('ACTS_Call_0400====<end catch(err)');
done();
}
console.log('ACTS_Call_0400 end......');
})
})
\ No newline at end of file
......@@ -17,7 +17,7 @@ import featureAbility from '@ohos.ability.featureAbility'
import {describe, beforeEach, afterEach, it, expect} from "deccjsunit/index.ets";
import Utils from './Utils';
export default function contextJsunit() {
export default function ContextJsunit() {
describe('appInfoTest', function () {
beforeEach(async function (done) {
console.info("context before each called");
......@@ -47,11 +47,11 @@ export default function contextJsunit() {
})
} catch (error) {
console.log("logMessage context_getCacheDir_test_0100: error = " + error);
expect(error).assertEqual("/data/accounts/account_0/appdata/com.ohos.acecollaboration/cache");
expect(error).assertEqual("/data/storage/el2/base/haps/entry/caches");
}
var data1 = await context.getCacheDir();
expect(typeof (data1)).assertEqual("string");
expect(data1).assertEqual("/data/accounts/account_0/appdata/com.ohos.acecollaboration/cache");
expect(data1).assertEqual("/data/storage/el2/base/haps/entry/caches");
done();
console.log("------------------end context_getCacheDir_test_0100-------------------");
});
......@@ -74,11 +74,11 @@ export default function contextJsunit() {
});
} catch (error) {
console.log("logMessage context_getCacheDir_test_0200: error = " + error);
expect(error).assertEqual("/data/accounts/account_0/appdata/com.ohos.acecollaboration/cache");
expect(error).assertEqual("/data/storage/el2/base/haps/entry/caches");
}
var data1 = await context.getCacheDir();
expect(typeof (data1)).assertEqual("string");
expect(data1).assertEqual("/data/accounts/account_0/appdata/com.ohos.acecollaboration/cache");
expect(data1).assertEqual("/data/storage/el2/base/haps/entry/caches");
done();
console.log("------------------end context_getCacheDir_test_0200-------------------");
});
......@@ -101,11 +101,11 @@ export default function contextJsunit() {
})
} catch (error) {
console.log("logMessage context_getFilesDir_test_0100: error = " + error);
expect(error).assertEqual("/data/accounts/account_0/appdata/com.ohos.acecollaboration/files");
expect(error).assertEqual("/data/storage/el2/base/haps/entry/files");
}
var data1 = await context.getFilesDir();
expect(typeof (data1)).assertEqual("string");
expect(data1).assertEqual("/data/accounts/account_0/appdata/com.ohos.acecollaboration/files");
expect(data1).assertEqual("/data/storage/el2/base/haps/entry/files");
done();
console.log("------------------end context_getFilesDir_test_0100-------------------");
});
......@@ -128,11 +128,11 @@ export default function contextJsunit() {
});
} catch (error) {
console.log("logMessage context_getFilesDir_test_0200: error = " + error);
expect(error).assertEqual("/data/accounts/account_0/appdata/com.ohos.acecollaboration/files");
expect(error).assertEqual("/data/storage/el2/base/haps/entry/files");
}
var data1 = await context.getFilesDir();
expect(typeof (data1)).assertEqual("string");
expect(data1).assertEqual("/data/accounts/account_0/appdata/com.ohos.acecollaboration/files");
expect(data1).assertEqual("/data/storage/el2/base/haps/entry/files");
done();
console.log("------------------end context_getFilesDir_test_0200-------------------");
});
......
......@@ -19,11 +19,9 @@ import getAbilityInfoJsunit from './getAbilityInfoJsunit.test.ets';
import getApplicationContext from './getApplicationContextJsunit.test.ets';
import getAppVersionInfoJsunit from './getAppVersionInfoJsunit.test.ets';
import ContextJsunit from './ContextJsunit.test.ets';
import DataAbilityJsunit from './DataAbility.test.ets';
export default function testsuite() {
ContextJsunit();
DataAbilityJsunit();
addContextAndAbilityJsunit();
getHapModuleInfoJsunit();
getAbilityInfoJsunit();
......
......@@ -30,7 +30,6 @@ const TAG_TEST_0900 = ' context_featureAbility_test_0100 ';
const TAG_TEST_0010 = ' context_featureAbility_test_0200 ';
const TAG_TEST_0011 = ' context_featureAbility_test_0300 ';
const TAG_TEST_0012 = ' context_featureAbility_test_0400 ';
const TAG_TEST_0013 = ' context_particleAbility_test_0100 ';
export default function addContextAndAbilityJsunit() {
describe('appInfoTest', function () {
......@@ -298,19 +297,5 @@ export default function addContextAndAbilityJsunit() {
done();
console.log('------------------ ' + TAG_TEST_0012 + ' end -------------------');
});
/*
* @tc.number: context_particleAbility_test_0100
* @tc.name: particleAbility.ErrorCode : particleAbility.ErrorCode
* @tc.desc: Check the particleAbility.ErrorCode.INVALID_PARAMETER
* @tc.level 0
*/
it(TAG_TEST_0013, 0, async function (done) {
console.info(TAG_TEST_0013 + ' INVALID_PARAMETER START');
var invalid_parameter = ability_particleAbility.ErrorCode.INVALID_PARAMETER
console.info(TAG_TEST_0013 + ' featureAbility invalid_parameter is: ' + invalid_parameter);
done();
console.log('------------------ ' + TAG_TEST_0013 + ' end -------------------');
});
})
}
\ No newline at end of file
......@@ -75,29 +75,6 @@ export default function getHapModuleInfoJsunit() {
done();
});
/**
* @tc.number: context_getHapModuleInfo_test_0300_1
* @tc.name: getHapModuleInfo:Obtains the HapModuleInfo object of the application.
* @tc.desc: Check the return value of the interface
* @tc.level 0
*/
it('context_getHapModuleInfo_test_0300_1', 0, async function (done) {
console.info('[context_getHapModuleInfo_test_0300_1] START');
var str = {
"want": {
"bundleName": "com.ohos.acecollaboration",
"abilityName": "com.example.myapplication1.MainAbility",
},
};
ability_featureAbility.startAbility(str)
.then((data) => {
console.info('[context_getHapModuleInfo_test_0300_1] start myapplication1 successful: ' + JSON.stringify(data))
}).catch((error) => {
console.error('[context_getHapModuleInfo_test_0300_1] start myapplication1 Cause: ' + JSON.stringify(error));
})
done();
});
function checkHapModuleInfo(msg, data) {
console.log(msg + "checkHapModuleInfo start " + JSON.stringify(data));
console.log(msg + "checkHapModuleInfo name : " + data.name);
......@@ -147,10 +124,7 @@ export default function getHapModuleInfoJsunit() {
expect(data.backgroundImg).assertEqual("");
expect(data.supportedModes).assertEqual(0);
expect(data.deviceTypes[0]).assertEqual("phone");
for (var i = 0; i < data.abilityInfos.length; i++) {
console.log(msg + "-------AbilityInfo data.abilityInfos[" + i + "] : START ------" );
checkAbilityInfo(msg,data.abilityInfos[i]);
}
checkAbilityInfo(msg,data.abilityInfos[0]);
expect(data.moduleName).assertEqual("entry")
expect(data.mainAbilityName).assertEqual("");
expect(data.installationFree).assertEqual(false);
......@@ -233,8 +207,6 @@ export default function getHapModuleInfoJsunit() {
expect(data.label).assertEqual("$string:entry_MainAbility");
expect(data.description).assertEqual("$string:mainability_description");
expect(data.icon).assertEqual("$media:icon");
expect(data.descriptionId > 0).assertTrue();
expect(data.iconId > 0).assertTrue();
expect(data.moduleName).assertEqual("entry");
expect(data.process).assertEqual("");
expect(data.targetAbility).assertEqual("");
......@@ -247,106 +219,15 @@ export default function getHapModuleInfoJsunit() {
expect(data.deviceTypes[0]).assertEqual("phone");
expect(data.readPermission).assertEqual("");
expect(data.writePermission).assertEqual("");
checkApplicationInfo(msg,data.applicationInfo);
expect(data.formEntity).assertEqual(0);
expect(data.minFormHeight).assertEqual(0);
expect(data.defaultFormHeight).assertEqual(0);
expect(data.minFormWidth).assertEqual(0);
expect(data.defaultFormWidth).assertEqual(0);
expect(data.uri).assertEqual("");
expect(data.labelId > 0).assertTrue();
expect(data.subType).assertEqual(0);
console.log(msg+ "---checkAbilityInfo End--- ");
}
function checkApplicationInfo(msg,info) {
console.log(msg+ "checkApplicationInfo start : " + JSON.stringify(info));
console.log(msg+ "checkApplicationInfo name : " + info.name);
console.log(msg+ "checkApplicationInfo description : " + info.description);
console.log(msg+ "checkApplicationInfo descriptionId : " + info.descriptionId);
console.log(msg+ "checkApplicationInfo systemApp : " + info.systemApp);
console.log(msg+ "checkApplicationInfo enabled : " + info.enabled);
console.log(msg+ "checkApplicationInfo label : " + info.label);
console.log(msg+ "checkApplicationInfo labelId : " + info.labelId);
console.log(msg+ "checkApplicationInfo icon : " + info.icon);
console.log(msg+ "checkApplicationInfo iconId : " + info.iconId);
console.log(msg+ "checkApplicationInfo process : " + info.process);
console.log(msg+ "checkApplicationInfo supportedModes : " + info.supportedModes);
console.log(msg+ "checkApplicationInfo moduleSourceDirs length : " + info.moduleSourceDirs.length);
for (var j = 0; j < info.moduleSourceDirs.length; j++) {
console.log(msg+ "checkApplicationInfo info.moduleSourceDirs[" + j + "] : " + info.moduleSourceDirs[j]);
}
console.log(msg+ "checkApplicationInfo permissions length : " + info.permissions.length);
for (var k = 0; k < info.permissions.length; k++) {
console.log(msg+ "checkApplicationInfo info.permissions[" + k + "] : " + info.permissions[k]);
}
console.log(msg+ "checkApplicationInfo moduleInfos length : " + info.moduleInfos.length);
for (var i = 0; i < info.moduleInfos.length; i++) {
console.log(msg+ "checkApplicationInfo info.moduleInfos[" + i + "].moduleName : " +
info.moduleInfos[i].moduleName);
console.log(msg+ "checkApplicationInfo info.moduleInfos[" + i + "].moduleSourceDir : " +
info.moduleInfos[i].moduleSourceDir);
}
console.log(msg+ "checkApplicationInfo entryDir : " + info.entryDir);
expect(typeof (info)).assertEqual("object");
expect(typeof (info.name)).assertEqual("string");
expect(typeof (info.description)).assertEqual("string");
expect(typeof (info.descriptionId)).assertEqual("number");
expect(typeof (info.systemApp)).assertEqual("boolean");
expect(typeof (info.enabled)).assertEqual("boolean");
expect(typeof (info.label)).assertEqual("string");
expect(typeof (info.labelId)).assertEqual("string");
expect(typeof (info.icon)).assertEqual("string");
expect(typeof (info.iconId)).assertEqual("string");
expect(typeof (info.process)).assertEqual("string");
expect(typeof (info.supportedModes)).assertEqual("number");
expect(Array.isArray(info.moduleSourceDirs)).assertEqual(true);
expect(Array.isArray(info.permissions)).assertEqual(true);
expect(Array.isArray(info.moduleInfos)).assertEqual(true);
expect(typeof (info.entryDir)).assertEqual("string");
if (info.moduleSourceDirs.length == 1){
expect(info.moduleInfos[0].moduleName).assertEqual("entry");
expect(info.moduleInfos[0].moduleSourceDir).assertEqual("/data/app/el1/bundle/public/" +
"com.ohos.acecollaboration/com.ohos.acecollaboration");
}else if(info.moduleSourceDirs.length == 2) {
if (info.moduleInfos[0].moduleName == "myapplication1") {
expect(info.moduleInfos[0].moduleName).assertEqual("myapplication1");
expect(info.moduleInfos[0].moduleSourceDir).assertEqual("/data/app/el1/bundle/public/" +
"com.ohos.acecollaboration/com.example.myapplication1");
expect(info.moduleInfos[1].moduleName).assertEqual("entry");
expect(info.moduleInfos[1].moduleSourceDir).assertEqual("/data/app/el1/bundle/public/" +
"com.ohos.acecollaboration/com.ohos.acecollaboration");
}else{
expect(info.moduleInfos[0].moduleName).assertEqual("myapplication2");
expect(info.moduleInfos[0].moduleSourceDir).assertEqual("/data/app/el1/bundle/public/" +
"com.ohos.acecollaboration/com.example.myapplication2");
expect(info.moduleInfos[1].moduleName).assertEqual("entry");
expect(info.moduleInfos[1].moduleSourceDir).assertEqual("/data/app/el1/bundle/public/" +
"com.ohos.acecollaboration/com.ohos.acecollaboration");
}
}else {
expect(info.moduleInfos[0].moduleName).assertEqual("myapplication1");
expect(info.moduleInfos[0].moduleSourceDir).assertEqual("/data/app/el1/bundle/public/" +
"com.ohos.acecollaboration/com.example.myapplication1");
expect(info.moduleInfos[1].moduleName).assertEqual("myapplication2");
expect(info.moduleInfos[1].moduleSourceDir).assertEqual("/data/app/el1/bundle/public/" +
"com.ohos.acecollaboration/com.example.myapplication2");
expect(info.moduleInfos[2].moduleName).assertEqual("entry");
expect(info.moduleInfos[2].moduleSourceDir).assertEqual("/data/app/el1/bundle/public/" +
"com.ohos.acecollaboration/com.ohos.acecollaboration");
}
expect(info.name).assertEqual("com.ohos.acecollaboration");
expect(info.description).assertEqual("$string:mainability_description");
expect(info.descriptionId > 0).assertTrue();
expect(info.systemApp).assertEqual(true);
expect(info.enabled).assertEqual(true);
expect(info.label).assertEqual("$string:entry_MainAbility");
expect(info.icon).assertEqual("$media:icon");
expect(info.process).assertEqual("");
expect(info.supportedModes).assertEqual(0);
expect(info.entryDir).assertEqual("/data/app/el1/bundle/public/" +
"com.ohos.acecollaboration/com.ohos.acecollaboration");
console.log(msg+ "---checkApplicationInfo End--- ");
}
})
}
\ No newline at end of file
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册