diff --git a/aafwk/aafwk_standard/ActsDataAbilityJsTest/entry/src/main/js/test/ActsDataAbilityJsTest.test.js b/aafwk/aafwk_standard/ActsDataAbilityJsTest/entry/src/main/js/test/ActsDataAbilityJsTest.test.js index c0880a187dab1b4ed91940bf8d0cad36d69e9762..a8d8b5ea872daa7eb2a31c974e4832a1fe62b3dd 100644 --- a/aafwk/aafwk_standard/ActsDataAbilityJsTest/entry/src/main/js/test/ActsDataAbilityJsTest.test.js +++ b/aafwk/aafwk_standard/ActsDataAbilityJsTest/entry/src/main/js/test/ActsDataAbilityJsTest.test.js @@ -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====: ' + 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====: ' + 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====: ' + 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==== { - var timeNewStamp = Utils.getNowTime(); - Utils.getDurationTime(INSERT_ONE + '001', timeOldStamp, timeNewStamp); - if (err) { - wrong = err; - console.error(INSERT_ONE + '001 error: ' + JSON.stringify(err)); - } else { - details = data; - console.info(INSERT_ONE + '001 succeeded data: ' + JSON.stringify(data)); - } - }); - await Utils.sleep(1000); - details != null ? expectDetails(details, true, 1) : expectDetails(wrong, true, 2); - done(); - console.log(INSERT_ONE + '001 end ......'); - }); - - /* - * @tc.number: dataAbility_insert_test_002 - * @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(INSERT_ONE + '002', 0, async function (done) { - let details; - let wrong; - console.log(INSERT_ONE + '002 start......'); - pacMap.group_name = 'test2'; - var timeOldStamp = await Utils.getNowTime(); - dataAbilityHelper.call(contactUri, 'insert', '', pacMap).then((data) => { - var timeNewStamp = Utils.getNowTime(); - Utils.getDurationTime(INSERT_ONE + '002', timeOldStamp, timeNewStamp); - details = data; - console.info(INSERT_ONE + '002 succeeded data: ' + JSON.stringify(data)); - }).catch((error) => { - wrong = error; - console.error(INSERT_ONE + '002 error: ' + JSON.stringify(error)); - }); - await Utils.sleep(1000); - details != null ? expectDetails(details, true, 1) : expectDetails(wrong, true, 2); - done(); - console.log(INSERT_ONE + '002 end......'); - }); - - /* - * @tc.number: dataAbility_insert_test_003 - * @tc.name: call : Inserts a incorrect uri data record into the database. - * @tc.desc: Check the return value of the interface - * @tc.level 0 - */ - it(INSERT_ONE + '003', 0, async function (done) { - let details; - let wrong; - console.log(INSERT_ONE + '003 start......'); - dataAbilityHelper.call(contactUri2, 'insert', '', pacMap).then((data) => { - details = data - console.info(INSERT_ONE + '003 succeeded: ' + JSON.stringify(data)); - }).catch((error) => { - wrong = error; - console.error(INSERT_ONE + '003 error: ' + JSON.stringify(error)); - }); - await Utils.sleep(1000); - details != null ? expectDetails(details, true, 1) : expectDetails(wrong, true, 2); - done(); - console.log(INSERT_ONE + '003 end......'); - }); - - /* - * @tc.number: dataAbility_insert_test_004 - * @tc.name: call : Inserts a null uri data record into the database. - * @tc.desc: Check the return value of the interface - * @tc.level 0 - */ - it(INSERT_ONE + '004', 0, async function (done) { - let details; - let wrong; - console.log(INSERT_ONE + '004 start......'); - dataAbilityHelper.call('', 'insert', '', pacMap).then((data) => { - details = data; - console.info(INSERT_ONE + '004 succeeded: ' + JSON.stringify(data)); - }).catch((error) => { - wrong = error; - console.error(INSERT_ONE + '004 error: ' + JSON.stringify(error)); - }); - await Utils.sleep(1000); - details != null ? expectDetails(details, true, 1) : expectDetails(wrong, true, 2); - done(); - console.log(INSERT_ONE + '004 end......'); - }); - - /* - * @tc.number: dataAbility_insert_test_005 - * @tc.name: call : Inserts a null methold data record into the database. - * @tc.desc: Check the return value of the interface - * @tc.level 0 - */ - it(INSERT_ONE + '005', 0, async function (done) { - let details; - let wrong; - console.log(INSERT_ONE + '005 start......'); - let pacMap = { - 'group_name': 'test4', - 'ringtone_modify_time': 28 - }; - dataAbilityHelper.call(contactUri, "", "", pacMap).then((data) => { - details = data; - console.info(INSERT_ONE + '005 succeeded: ' + JSON.stringify(data)); - }).catch((error) => { - wrong = error; - console.error(INSERT_ONE + '005 error: ' + JSON.stringify(error)); - }); - await Utils.sleep(1000); - details != null ? expectDetails(details, true, 1) : expectDetails(wrong, true, 2); - done(); - console.log(INSERT_ONE + '005 end......'); - }); - - /* - * @tc.number: dataAbility_query_test_001 - * @tc.name: call : Queries data in the database. - * @tc.desc: Check the return value of the interface - * @tc.level 0 - */ - it(QUERY_TWO + '001', 0, async function (done) { - let details; - let wrong; - console.log(QUERY_TWO + '001 start......'); - let arg = "{\"equalTo\": \"group_name\"}"; - let pacMap = { - "group_name": "test1", - "columns": "group_name,ringtone_modify_time" - }; - var timeOldStamp = await Utils.getNowTime(); - dataAbilityHelper.call(contactUri, 'query', arg, pacMap, (err, data) => { - var timeNewStamp = Utils.getNowTime(); - Utils.getDurationTime(QUERY_TWO + '001', timeOldStamp, timeNewStamp); - wrong = err; - if (wrong) { - console.error(QUERY_TWO + '001 error: ' + JSON.stringify(wrong)); - } else { - details = data; - console.info(QUERY_TWO + '001 succeeded: ' + JSON.stringify(data)); - } - }); - await Utils.sleep(1000); - details != null ? expectDetails(details, false, 4) : expectDetails(wrong, true, 2); - done(); - console.log(QUERY_TWO + '001 end......'); - }); - - /* - * @tc.number: dataAbility_query_test_002 - * @tc.name: call : Queries data in the database. - * @tc.desc: Check the return value of the interface - * @tc.level 0 - */ - it(QUERY_TWO + '002', 0, async function (done) { - let details; - let wrong; - console.log(QUERY_TWO + '002 start......'); - let arg = "{\"between\": \"ringtone_modify_time\"}"; - let pacMap = { - 'ringtone_modify_time': "15, 30", - "columns": "group_name,ringtone_modify_time" - }; - var timeOldStamp = await Utils.getNowTime(); - dataAbilityHelper.call(contactUri, 'query', arg, pacMap, (err, data) => { - var timeNewStamp = Utils.getNowTime(); - Utils.getDurationTime(QUERY_TWO + '002', timeOldStamp, timeNewStamp); - wrong = err; - if (wrong) { - console.error(QUERY_TWO + '002 error: ' + JSON.stringify(wrong)); - } else { - details = data; - console.info(QUERY_TWO + '002 succeeded: ' + JSON.stringify(data)); - } - }); - await Utils.sleep(1000); - details != null ? expectDetails(details, false, 4) : expectDetails(wrong, true, 2); - done(); - console.log(QUERY_TWO + '002 end......'); - }); - - /* - * @tc.number: dataAbility_query_test_003 - * @tc.name: call : Queries data in the database. - * @tc.desc: Check the return value of the interface - * @tc.level 0 - */ - it(QUERY_TWO + '003', 0, async function (done) { - let details; - let wrong; - console.log(QUERY_TWO + '003 start......'); - let arg = { - 'like': 'group_name' - }; - let pacMap = { - 'group_name': '%test%', - 'columns': 'group_name,ringtone_modify_time' - }; - var timeOldStamp = await Utils.getNowTime(); - dataAbilityHelper.call(contactUri, 'query', arg, pacMap, (err, data) => { - var timeNewStamp = Utils.getNowTime(); - Utils.getDurationTime(QUERY_TWO + '003', timeOldStamp, timeNewStamp); - wrong = err; - if (wrong) { - console.error(QUERY_TWO + '003 error: ' + JSON.stringify(wrong)); - } else { - details = data; - console.info(QUERY_TWO + '003 succeeded: ' + JSON.stringify(data)); - } - }); - await Utils.sleep(1000); - details != null ? expectDetails(details, false, 4) : expectDetails(wrong, true, 2); - done(); - console.log(QUERY_TWO + '003 end......'); - }); - - /* - * @tc.number: dataAbility_query_test_004 - * @tc.name: call : Queries data in the database. - * @tc.desc: Check the return value of the interface - * @tc.level 0 - */ - it(QUERY_TWO + '004', 0, async function (done) { - let details; - let wrong; - console.log(QUERY_TWO + '004 start......'); - let arg = { - 'greaterThanOrEqualTo': 'ringtone_modify_time' - }; - let pacMap = { - 'ringtone_modify_time': 20, - 'columns': 'group_name,ringtone_modify_time' - }; - var timeOldStamp = await Utils.getNowTime(); - dataAbilityHelper.call(contactUri, 'query', arg, pacMap, (err, data) => { - var timeNewStamp = Utils.getNowTime(); - Utils.getDurationTime(QUERY_TWO + '004', timeOldStamp, timeNewStamp); - if (err) { - wrong = err; - console.error(QUERY_TWO + '004 error: ' + JSON.stringify(err)); - return; - } else { - details = data; - console.info(QUERY_TWO + '004 succeeded: ' + JSON.stringify(data)); - } - }); - await Utils.sleep(1000); - details != null ? expectDetails(details, false, 4) : expectDetails(wrong, true, 2); - done(); - console.log(QUERY_TWO + '004 end......'); - }); - - /* - * @tc.number: dataAbility_query_test_005 - * @tc.name: call : Queries abnormal data in the database. - * @tc.desc: Check the return value of the interface - * @tc.level 0 - */ - it(QUERY_TWO + '005', 0, async function (done) { - let details; - let wrong; - let pacMap = { - 'ringtone_modify_time': 20, - 'columns': 'group_name,ringtone_modify_time' - }; - console.log(INSERT_ONE + '003 start......'); - dataAbilityHelper.call(contactUri2, 'query', '', pacMap).then((data) => { - details = data - console.info(QUERY_TWO + '005 succeeded: ' + JSON.stringify(data)); - }).catch((error) => { - wrong = error; - console.error(QUERY_TWO + '005 error: ' + JSON.stringify(error)); - }); - await Utils.sleep(1000); - details != null ? expectDetails(details, false, 4) : expectDetails(wrong, true, 2); - done(); - console.log(QUERY_TWO + '005 end......'); - }); - - /* - * @tc.number: dataAbility_query_test_006 - * @tc.name: call : Queries abnormal data in the database. - * @tc.desc: Check the return value of the interface - * @tc.level 0 - */ - it(QUERY_TWO + '006', 0, async function (done) { - let details; - let wrong; - let pacMap = { - 'ringtone_modify_time': 20, - 'columns': 'group_name,ringtone_modify_time' - }; - console.log(QUERY_TWO + '004 start......'); - dataAbilityHelper.call('', 'query', '', pacMap).then((data) => { - details = data; - console.info(QUERY_TWO + '006 succeeded: ' + JSON.stringify(data)); - }).catch((error) => { - wrong = error; - console.error(QUERY_TWO + '006 error: ' + JSON.stringify(error)); - }); - await Utils.sleep(1000); - details != null ? expectDetails(details, false, 4) : expectDetails(wrong, true, 2); - done(); - console.log(QUERY_TWO + '006 end......'); - }); - - /* - * @tc.number: dataAbility_update_test_001 - * @tc.name: call : Updates data records in the database. - * @tc.desc: Check the return value of the interface - * @tc.level 0 - */ - it(UPDATE_THREE + '001', 0, async function (done) { - let details; - let wrong; - console.log(UPDATE_THREE + '001 start......'); - let arg = "{\"equalTo\": \"ringtone_modify_time\"}"; - let pacMap = { - 'ringtone_modify_time': 28, - 'group_name': 'testupdata1' - }; - var timeOldStamp = await Utils.getNowTime(); - dataAbilityHelper.call(contactUri, 'update', arg, pacMap, (err, data) => { - var timeNewStamp = Utils.getNowTime(); - Utils.getDurationTime(UPDATE_THREE + '001', timeOldStamp, timeNewStamp); - if (err) { - wrong = err; - console.error(UPDATE_THREE + '001 error: ' + JSON.stringify(err)); - } else { - details = data; - console.info(UPDATE_THREE + '001 succeeded: ' + JSON.stringify(data)); - } - }); - await Utils.sleep(1000); - details != null ? expectDetails(details, true, 3) : expectDetails(wrong, true, 2); - done(); - console.log(UPDATE_THREE + '001 end......'); - }); - - /* - * @tc.number: dataAbility_update_test_002 - * @tc.name: call : Updates data records in the database. - * @tc.desc: Check the return value of the interface - * @tc.level 0 - */ - it(UPDATE_THREE + '002', 0, async function (done) { - let details; - let wrong; - console.log(UPDATE_THREE + '002 start......'); - let arg = "{\"between\": \"ringtone_modify_time\"}"; - let pacMap = { - 'ringtone_modify_time': "15, 30", - 'group_name': 'testupdata2' - }; - var timeOldStamp = await Utils.getNowTime(); - dataAbilityHelper.call(contactUri, 'update', arg, pacMap, (err, data) => { - var timeNewStamp = Utils.getNowTime(); - Utils.getDurationTime(UPDATE_THREE + '002', timeOldStamp, timeNewStamp); - if (err) { - wrong = err; - console.error(UPDATE_THREE + '002 error: ' + JSON.stringify(err)); - } else { - details = data; - console.info(UPDATE_THREE + '002 succeeded: ' + JSON.stringify(data)); - } - }); - await Utils.sleep(1000); - details != null ? expectDetails(details, true, 3) : expectDetails(wrong, true, 2); - done(); - console.log(UPDATE_THREE + '002 end......'); - }); - - /* - * @tc.number: dataAbility_update_test_003 - * @tc.name: call : Updates data records in the database. - * @tc.desc: Check the return value of the interface - * @tc.level 0 - */ - it(UPDATE_THREE + '003', 0, async function (done) { - let details; - let wrong; - console.log(UPDATE_THREE + '003 start......'); - let arg = { - 'contains': 'group_name' - }; - let pacMap = { - 'group_name': 'ata2', - 'ringtone_modify_time': 100 - }; - var timeOldStamp = await Utils.getNowTime(); - dataAbilityHelper.call(contactUri, 'update', arg, pacMap, (err, data) => { - var timeNewStamp = Utils.getNowTime(); - Utils.getDurationTime(UPDATE_THREE + '003', timeOldStamp, timeNewStamp); - if (err) { - wrong = err; - console.error(UPDATE_THREE + '003 error: ' + JSON.stringify(err)); - } else { - details = data; - console.info(UPDATE_THREE + '003 succeeded: ' + JSON.stringify(data)); - } - }); - await Utils.sleep(1000); - details != null ? expectDetails(details, true, 3) : expectDetails(wrong, true, 2); - done(); - console.log(UPDATE_THREE + '003 end......'); - }); - - /* - * @tc.number: dataAbility_update_test_004 - * @tc.name: call : Updates data records in the database. - * @tc.desc: Check the return value of the interface - * @tc.level 0 - */ - it(UPDATE_THREE + '004', 0, async function (done) { - let details; - let wrong; - console.log(UPDATE_THREE + '004 start......'); - let arg = { - 'lessThan': 'ringtone_modify_time' - }; - let pacMap = { - 'ringtone_modify_time': 32, - 'group_name': 'testupdata2' - }; - var timeOldStamp = await Utils.getNowTime(); - dataAbilityHelper.call(contactUri, 'update', arg, pacMap, (err, data) => { - var timeNewStamp = Utils.getNowTime(); - Utils.getDurationTime(UPDATE_THREE + '004', timeOldStamp, timeNewStamp); - if (err) { - wrong = err; - console.error(UPDATE_THREE + '004 error: ' + JSON.stringify(err)); - } else { - details = data; - console.info(UPDATE_THREE + '004 succeeded: ' + JSON.stringify(data)); - } - }); - await Utils.sleep(1000); - details != null ? expectDetails(details, true, 3) : expectDetails(wrong, true, 2); - done(); - console.log(UPDATE_THREE + '004 end......'); - }); - - /* - * @tc.number: dataAbility_update_test_005 - * @tc.name: call : Updates abnormal data records in the database. - * @tc.desc: Check the return value of the interface - * @tc.level 0 - */ - it(UPDATE_THREE + '005', 0, async function (done) { - let details; - let wrong; - console.log(UPDATE_THREE + '005 start......'); - - let pacMap = { - 'ringtone_modify_time': 32, - 'group_name': 'testupdata2' - }; - var timeOldStamp = await Utils.getNowTime(); - dataAbilityHelper.call(contactUri2, 'update', '', pacMap, (err, data) => { - var timeNewStamp = Utils.getNowTime(); - Utils.getDurationTime(UPDATE_THREE + '005', timeOldStamp, timeNewStamp); - if (err) { - wrong = err; - console.error(UPDATE_THREE + '005 error: ' + JSON.stringify(err)); - } else { - details = data; - console.info(UPDATE_THREE + '005 succeeded: ' + JSON.stringify(data)); - } - }); - await Utils.sleep(1000); - details != null ? expectDetails(details, true, 3) : expectDetails(wrong, true, 2); - done(); - console.log(UPDATE_THREE + '005 end......'); - }); - - /* - * @tc.number: dataAbility_update_test_006 - * @tc.name: call : Updates abnormal data records in the database. - * @tc.desc: Check the return value of the interface - * @tc.level 0 - */ - it(UPDATE_THREE + '006', 0, async function (done) { - let details; - let wrong; - console.log(UPDATE_THREE + '006 start......'); - let pacMap = { - 'ringtone_modify_time': 32, - 'group_name': 'testupdata2' - }; - var timeOldStamp = await Utils.getNowTime(); - dataAbilityHelper.call('', 'update', '', pacMap, (err, data) => { - var timeNewStamp = Utils.getNowTime(); - Utils.getDurationTime(UPDATE_THREE + '006', timeOldStamp, timeNewStamp); - if (err) { - wrong = err; - console.error(UPDATE_THREE + '006 error: ' + JSON.stringify(err)); - } else { - details = data; - console.info(UPDATE_THREE + '006 succeeded: ' + JSON.stringify(data)); - } - }); - await Utils.sleep(1000); - details != null ? expectDetails(details, true, 3) : expectDetails(wrong, true, 2); - done(); - console.log(UPDATE_THREE + '006 end......'); - }); - - /* - * @tc.number: dataAbility_delete_test_001 - * @tc.name: call : Deletes one or more data records from the database. - * @tc.desc: Check the return value of the interface - * @tc.level 0 - */ - dataAbilityHelper.call(contactUri, 'insert', '', pacMap, (err, data) => { - if (err) { - console.error('Operation failed1. Cause: ' + JSON.stringify(err)); - return; - } - console.info('Operation succeeded1: ' + JSON.stringify(data)); - }); - it(DELETE_FOUR + '001', 0, async function (done) { - let details; - let wrong; - console.log(DELETE_FOUR + '001 start......'); - let arg2 = "{\"equalTo\": \"group_name\"}"; - let pacMap2 = { - 'group_name': 'test1' - }; - var timeOldStamp = await Utils.getNowTime(); - dataAbilityHelper.call(contactUri, 'delete', arg2, pacMap2, (err2, data2) => { - var timeNewStamp = Utils.getNowTime(); - Utils.getDurationTime(DELETE_FOUR + '001', timeOldStamp, timeNewStamp); - if (err2) { - wrong = err2; - console.error(DELETE_FOUR + '001 error: ' + JSON.stringify(err2)); - } else { - details = data2; - console.info(DELETE_FOUR + '001 succeeded: ' + JSON.stringify(data2)); - } - }); - await Utils.sleep(1000); - details != null ? expectDetails(details, true, 3) : expectDetails(wrong, true, 2); - done(); - console.log(DELETE_FOUR + '001 end......'); - }); - - /* - * @tc.number: dataAbility_delete_test_002 - * @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(DELETE_FOUR + '002', 0, async function (done) { - let details; - let wrong - console.log(DELETE_FOUR + '002 start......'); - let arg = "{\"lessThan\": \"ringtone_modify_time\"}"; - let pacMap = { - 'ringtone_modify_time': 32, - }; - var timeOldStamp = await Utils.getNowTime(); - dataAbilityHelper.call(contactUri, 'delete', arg, pacMap, (err, data) => { - var timeNewStamp = Utils.getNowTime(); - Utils.getDurationTime(DELETE_FOUR + '002', timeOldStamp, timeNewStamp); - if (err) { - wrong = err; - console.error(DELETE_FOUR + '002 error: ' + JSON.stringify(err)); - } else { - details = data; - console.info(DELETE_FOUR + '002 succeeded: ' + JSON.stringify(data)); - } - }); - await Utils.sleep(1000); - details != null ? expectDetails(details, true, 3) : expectDetails(wrong, true, 2); - done(); - console.log(DELETE_FOUR + '002 end......'); - }); - - /* - * @tc.number: dataAbility_delete_test_003 - * @tc.name: call : Deletes one or more data records from the database. - * @tc.desc: Check the return value of the interface - * @tc.level 0 - */ - dataAbilityHelper.call(contactUri, 'insert', '', pacMap_3, (err, data) => { - if (err) { - console.error('Operation failed3. Cause: ' + JSON.stringify(err)); - return; - } - console.info('Operation succeeded3: ' + JSON.stringify(data)); - }); - it(DELETE_FOUR + '003', 0, async function (done) { - let details; - let wrong; - console.log(DELETE_FOUR + '003 start......'); - let arg2 = { - 'like': 'group_name' - }; - let pacMap2 = { - 'group_name': '%test%' - }; - var timeOldStamp = await Utils.getNowTime(); - dataAbilityHelper.call(contactUri, 'delete', arg2, pacMap2, (err2, data2) => { - var timeNewStamp = Utils.getNowTime(); - Utils.getDurationTime(DELETE_FOUR + '003', timeOldStamp, timeNewStamp); - if (err2) { - wrong = err2; - console.error(DELETE_FOUR + '003 error: ' + JSON.stringify(err2)); - } else { - details = data2; - console.info(DELETE_FOUR + '003 delete succeeded: ' + JSON.stringify(data2)); - } - }); - await Utils.sleep(1000); - details != null ? expectDetails(details, true, 3) : expectDetails(wrong, true, 2); - done(); - console.log(DELETE_FOUR + '003 delete end......'); - }); - - /* - * @tc.number: dataAbility_delete_test_004 - * @tc.name: call : Deletes one or more data records from the database. - * @tc.desc: Check the return value of the interface - * @tc.level 0 - */ - dataAbilityHelper.call(contactUri, 'insert', '', pacMap_4, (err, data) => { - if (err) { - console.error('Operation failed4. Cause: ' + JSON.stringify(err)); - return; - } - console.info('Operation succeeded4: ' + JSON.stringify(data)); - }); - it(DELETE_FOUR + '004', 0, async function (done) { - let details; - let wrong; - console.log(DELETE_FOUR + '004 start......'); - let arg2 = { - 'greaterThanOrEqualTo': 'ringtone_modify_time' - }; - let pacMap2 = { - 'ringtone_modify_time': 40 - }; - var timeOldStamp = await Utils.getNowTime(); - dataAbilityHelper.call(contactUri, 'delete', arg2, pacMap2, (err2, data2) => { - var timeNewStamp = Utils.getNowTime(); - Utils.getDurationTime(DELETE_FOUR + '004', timeOldStamp, timeNewStamp); - if (err2) { - wrong = err2; - console.error(DELETE_FOUR + '004 error: ' + JSON.stringify(err2)); - } else { - details = data2; - console.info(DELETE_FOUR + '004 delete succeeded: ' + JSON.stringify(data2)); - } - }); - await Utils.sleep(1000); - details != null ? expectDetails(details, true, 3) : expectDetails(wrong, true, 2); - done(); - console.log(DELETE_FOUR + '004 delete end......'); - }); - - /* - * @tc.number: dataAbility_delete_test_005 - * @tc.name: call : Deletes abnormal data records from the database. - * @tc.desc: Check the return value of the interface - * @tc.level 0 - */ - dataAbilityHelper.call(contactUri, 'insert', '', pacMap_4, (err, data) => { - if (err) { - console.error('Operation failed4. Cause: ' + JSON.stringify(err)); - return; - } - console.info('Operation succeeded5: ' + JSON.stringify(data)); - }); - it(DELETE_FOUR + '005', 0, async function (done) { - let details; - let wrong; - console.log(DELETE_FOUR + '005 start......'); - let pacMap2 = { - 'ringtone_modify_time': 40 - }; - var timeOldStamp = await Utils.getNowTime(); - dataAbilityHelper.call(contactUri2, 'delete', '', pacMap2, (err2, data2) => { - var timeNewStamp = Utils.getNowTime(); - Utils.getDurationTime(DELETE_FOUR + '005', timeOldStamp, timeNewStamp); - if (err2) { - wrong = err2; - console.error(DELETE_FOUR + '005 error: ' + JSON.stringify(err2)); - } else { - details = data2; - console.info(DELETE_FOUR + '005 delete succeeded: ' + JSON.stringify(data2)); - } - }); - await Utils.sleep(1000); - details != null ? expectDetails(details, true, 3) : expectDetails(wrong, true, 2); - done(); - console.log(DELETE_FOUR + '005 delete end......'); - }); - - /* - * @tc.number: dataAbility_delete_test_006 - * @tc.name: call : Deletes abnormal data records from the database. - * @tc.desc: Check the return value of the interface - * @tc.level 0 - */ - dataAbilityHelper.call(contactUri, 'insert', '', pacMap_4, (err, data) => { - if (err) { - console.error('Operation failed4. Cause: ' + JSON.stringify(err)); - return; - } - console.info('Operation succeeded4: ' + JSON.stringify(data)); - }); - it(DELETE_FOUR + '006', 0, async function (done) { - let details; - let wrong; - console.log(DELETE_FOUR + '006 start......'); - let pacMap2 = { - 'ringtone_modify_time': 40 - }; - var timeOldStamp = await Utils.getNowTime(); - dataAbilityHelper.call('', 'delete', '', pacMap2, (err2, data2) => { - var timeNewStamp = Utils.getNowTime(); - Utils.getDurationTime(DELETE_FOUR + '006', timeOldStamp, timeNewStamp); - if (err2) { - wrong = err2; - console.error(DELETE_FOUR + '006 error: ' + JSON.stringify(err2)); - } else { - details = data2; - console.info(DELETE_FOUR + '006 delete succeeded: ' + JSON.stringify(data2)); - } - }); - await Utils.sleep(1000); - details != null ? expectDetails(details, true, 3) : expectDetails(wrong, true, 2); - done(); - console.log(DELETE_FOUR + '006 delete end......'); - }); - }) - - function expectDetails(data, isTrue, keyStatus) { - if (data != -1) { - expect(typeof (data)).assertEqual("object"); - expect(typeof (data.result)).assertEqual(isTrue ? 'number' : 'string'); - } - switch (keyStatus) { - case 1: - expect(data.result > 0).assertTrue(); - break - - case 2: - expect(data == -1).assertTrue(); - break - - case 3: - expect(data.result).assertEqual(0); - break - } - } -} \ No newline at end of file diff --git a/aafwk/aafwk_standard/actsabilitymanageretstest/entry/src/main/ets/MainAbility/test/List.test.ets b/aafwk/aafwk_standard/actsabilitymanageretstest/entry/src/main/ets/MainAbility/test/List.test.ets index 023315f7c62d5e8ca4b19fef1d668d6c9dc74d82..fea9b55619a3c88c223e58ba0c03d203ad1be8ca 100644 --- a/aafwk/aafwk_standard/actsabilitymanageretstest/entry/src/main/ets/MainAbility/test/List.test.ets +++ b/aafwk/aafwk_standard/actsabilitymanageretstest/entry/src/main/ets/MainAbility/test/List.test.ets @@ -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(); diff --git a/aafwk/aafwk_standard/actsabilitymanageretstest/entry/src/main/ets/MainAbility/test/addContextAndAbilityJsunit.test.ets b/aafwk/aafwk_standard/actsabilitymanageretstest/entry/src/main/ets/MainAbility/test/addContextAndAbilityJsunit.test.ets index 6d5189cac6f7dd841895455241802c9ceb746dba..526912a76997b15814d57c6aa5c9fc14c3725ac2 100644 --- a/aafwk/aafwk_standard/actsabilitymanageretstest/entry/src/main/ets/MainAbility/test/addContextAndAbilityJsunit.test.ets +++ b/aafwk/aafwk_standard/actsabilitymanageretstest/entry/src/main/ets/MainAbility/test/addContextAndAbilityJsunit.test.ets @@ -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 diff --git a/aafwk/aafwk_standard/actsabilitymanageretstest/entry/src/main/ets/MainAbility/test/getHapModuleInfoJsunit.test.ets b/aafwk/aafwk_standard/actsabilitymanageretstest/entry/src/main/ets/MainAbility/test/getHapModuleInfoJsunit.test.ets index 7d99f6be366de1d94e506061ae4af379bccd8c37..1c9973bd55bce92641dadfa084a81183e507f5f9 100644 --- a/aafwk/aafwk_standard/actsabilitymanageretstest/entry/src/main/ets/MainAbility/test/getHapModuleInfoJsunit.test.ets +++ b/aafwk/aafwk_standard/actsabilitymanageretstest/entry/src/main/ets/MainAbility/test/getHapModuleInfoJsunit.test.ets @@ -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