diff --git a/account/osaccount/actsosaccountsystemtest/Test.json b/account/osaccount/actsosaccountsystemtest/Test.json index 7cdf991eaae997639b6b153f9165e5045accd8d6..e3b0d3326f7e038c6db1a25b86b9911eab5b2e56 100755 --- a/account/osaccount/actsosaccountsystemtest/Test.json +++ b/account/osaccount/actsosaccountsystemtest/Test.json @@ -2,7 +2,7 @@ "description": "Configuration for hjunit demo Tests", "driver": { "type": "JSUnitTest", - "test-timeout": "200000", + "test-timeout": "300000", "package": "com.example.actsosaccountsystemtest", "shell-timeout": "60000" }, diff --git a/account/osaccount/actsosaccountsystemtest/entry/src/main/js/default/pages/index/index.js b/account/osaccount/actsosaccountsystemtest/entry/src/main/js/default/pages/index/index.js index ff89334405379439f410d17e635542fecd8be44a..bf4a20cd6664116e2f57f1808a8ed6aac570c301 100755 --- a/account/osaccount/actsosaccountsystemtest/entry/src/main/js/default/pages/index/index.js +++ b/account/osaccount/actsosaccountsystemtest/entry/src/main/js/default/pages/index/index.js @@ -35,6 +35,7 @@ export default { core.init() const configService = core.getDefaultService('config') + this.timeout = 8000; configService.setConfig(this) require('../../../test/List.test') diff --git a/account/osaccount/actsosaccountsystemtest/entry/src/main/js/test/OnOff.test.js b/account/osaccount/actsosaccountsystemtest/entry/src/main/js/test/OnOff.test.js index b1cfe0c998095491671c8ff85af5a9e5ed86d8c8..c05fbce83f7c6c33448834c8ef851eb6ac72a66f 100755 --- a/account/osaccount/actsosaccountsystemtest/entry/src/main/js/test/OnOff.test.js +++ b/account/osaccount/actsosaccountsystemtest/entry/src/main/js/test/OnOff.test.js @@ -25,6 +25,179 @@ describe('ActsOsAccountSystemTest', function () { } } + /* + * @tc.number : ActsOsAccountOnOff_0100 + * @tc.name : Subscribe and unsubscribing local multi-user + * @tc.desc : Verify that the activating type subscription can receive user switching + */ + it('ActsOsAccountOnOff_0100', 0, async function (done) { + console.debug("====>ActsOsAccountOnOff_0100 start===="); + var osAccountManager = osaccount.getAccountManager(); + var localId; + console.debug("====>get AccountManager finish===="); + function onCallback(receiveLocalId){ + console.debug("====>receive localId:" + receiveLocalId); + if(receiveLocalId == localId){ + osAccountManager.off("activating", "osAccountOnOffNameA", offCallback); + } + } + function removeCallback(err){ + console.debug("====>remove localId: " + localId + " err:" + JSON.stringify(err)); + expect(err.code).assertEqual(0); + console.debug("====>ActsOsAccountOnOff_0100 end===="); + done(); + } + function offCallback(){ + console.debug("====>off enter") + osAccountManager.removeOsAccount(localId, removeCallback); + } + osAccountManager.on("activating", "osAccountOnOffNameA", onCallback); + sleep(TIMEOUT); + osAccountManager.createOsAccount("osAccountNameA", 1, (err, osAccountInfo)=>{ + console.debug("====>createOsAccount err:" + JSON.stringify(err)); + console.debug("====>createOsAccount osAccountInfo:" + JSON.stringify(osAccountInfo)); + localId = osAccountInfo.localId; + expect(err.code).assertEqual(0); + expect(osAccountInfo.localName).assertEqual("osAccountNameA"); + osAccountManager.activateOsAccount(localId, (err)=>{ + console.debug("====>activateOsAccount err:" + JSON.stringify(err)); + expect(err.code).assertEqual(0); + }); + }); + }); + + /* + * @tc.number : ActsOsAccountOnOff_0200 + * @tc.name : Subscribe and unsubscribing local multi-user + * @tc.desc : Verify that the activate type subscription can receive user switching + */ + it('ActsOsAccountOnOff_0200', 0, async function (done) { + console.debug("====>ActsOsAccountOnOff_0200 start===="); + var osAccountManager = osaccount.getAccountManager(); + var localId; + console.debug("====>get AccountManager finish===="); + function onCallback(receiveLocalId){ + console.debug("====>receive localId:" + receiveLocalId); + if(receiveLocalId == localId){ + osAccountManager.off("activate", "osAccountOnOffNameB", offCallback); + } + } + function offCallback(){ + console.debug("====>off enter") + osAccountManager.removeOsAccount(localId, (err)=>{ + console.debug("====>remove localId: " + localId + " err:" + JSON.stringify(err)); + expect(err.code).assertEqual(0); + console.debug("====>ActsOsAccountOnOff_0200 end===="); + done(); + }) + } + osAccountManager.on("activate", "osAccountOnOffNameB", onCallback); + sleep(TIMEOUT); + osAccountManager.createOsAccount("osAccountNameB", 1, (err, osAccountInfo)=>{ + console.debug("====>createOsAccount err:" + JSON.stringify(err)); + console.debug("====>createOsAccount osAccountInfo:" + JSON.stringify(osAccountInfo)); + localId = osAccountInfo.localId; + expect(err.code).assertEqual(0); + expect(osAccountInfo.localName).assertEqual("osAccountNameB"); + osAccountManager.activateOsAccount(localId, (err)=>{ + console.debug("====>activateOsAccount err:" + JSON.stringify(err)); + expect(err.code).assertEqual(0); + }); + }); + }) + + /* + * @tc.number : ActsOsAccountOnOff_0300 + * @tc.name : Subscribe and unsubscribing local multi-user + * @tc.desc : Verify that the activating type unsubscribes successfully + */ + it('ActsOsAccountOnOff_0300', 0, async function (done) { + console.debug("====>ActsOsAccountOnOff_0300 start===="); + var osAccountManager = osaccount.getAccountManager(); + var localId; + console.debug("====>get AccountManager finish===="); + function onCallback(receiveLocalId){ + console.debug("====>receive localId:" + receiveLocalId); + if(receiveLocalId == localId){ + console.debug("====>wrongly received localId: " + localId + " after unsubscribing"); + expect().assertFail(); + done(); + } + } + function offCallback(){ + console.debug("====>off enter") + } + osAccountManager.on("activating", "osAccountOnOffNameC", onCallback); + sleep(TIMEOUTHALF); + osAccountManager.off("activating", "osAccountOnOffNameC", offCallback); + sleep(TIMEOUTHALF); + osAccountManager.createOsAccount("osAccountNameC", 1, (err, osAccountInfo)=>{ + console.debug("====>createOsAccount err:" + JSON.stringify(err)); + console.debug("====>createOsAccount osAccountInfo:" + JSON.stringify(osAccountInfo)); + localId = osAccountInfo.localId; + expect(err.code).assertEqual(0); + expect(osAccountInfo.localName).assertEqual("osAccountNameC"); + osAccountManager.activateOsAccount(localId, (err)=>{ + console.debug("====>activateOsAccount err:" + JSON.stringify(err)); + expect(err.code).assertEqual(0); + setTimeout(()=>{ + osAccountManager.removeOsAccount(localId, (err)=>{ + console.debug("====>remove localId: " + localId + " err:" + JSON.stringify(err)); + expect(err.code).assertEqual(0); + console.debug("====>ActsOsAccountOnOff_0300 end===="); + done(); + }) + }, TIMEOUT); + }); + }); + }); + + /* + * @tc.number : ActsOsAccountOnOff_0400 + * @tc.name : Subscribe and unsubscribing local multi-user + * @tc.desc : Verify that the activate type unsubscribes successfully + */ + it('ActsOsAccountOnOff_0400', 0, async function (done) { + console.debug("====>ActsOsAccountOnOff_0400 start===="); + var osAccountManager = osaccount.getAccountManager(); + var localId; + console.debug("====>get AccountManager finish===="); + function onCallback(receiveLocalId){ + console.debug("====>receive localId:" + receiveLocalId); + if(receiveLocalId == localId){ + console.debug("====>wrongly received localId: " + localId + " after unsubscribing"); + expect().assertFail(); + done(); + } + } + function offCallback(){ + console.debug("====>off enter") + } + osAccountManager.on("activate", "osAccountOnOffNameD", onCallback); + sleep(TIMEOUTHALF); + osAccountManager.off("activate", "osAccountOnOffNameD", offCallback); + sleep(TIMEOUTHALF); + osAccountManager.createOsAccount("osAccountNameD", 1, (err, osAccountInfo)=>{ + console.debug("====>createOsAccount err:" + JSON.stringify(err)); + console.debug("====>createOsAccount osAccountInfo:" + JSON.stringify(osAccountInfo)); + localId = osAccountInfo.localId; + expect(err.code).assertEqual(0); + expect(osAccountInfo.localName).assertEqual("osAccountNameD"); + osAccountManager.activateOsAccount(localId, (err)=>{ + console.debug("====>activateOsAccount err:" + JSON.stringify(err)); + expect(err.code).assertEqual(0); + setTimeout(()=>{ + osAccountManager.removeOsAccount(localId, (err)=>{ + console.debug("====>remove localId: " + localId + " err:" + JSON.stringify(err)); + expect(err.code).assertEqual(0); + console.debug("====>ActsOsAccountOnOff_0400 end===="); + done(); + }) + }, TIMEOUT); + }); + }); + }); + /* * @tc.number : ActsOsAccountOnOff_0500 * @tc.name : Subscribe and unsubscribing local multi-user @@ -69,6 +242,460 @@ describe('ActsOsAccountSystemTest', function () { }, TIMEOUT); }); + /* + * @tc.number : ActsOsAccountOnOff_0700 + * @tc.name : Subscribe and unsubscribing local multi-user + * @tc.desc : Verification cannot cancel activating type not subscribed + */ + it('ActsOsAccountOnOff_0700', 0, async function (done) { + console.debug("====>ActsOsAccountOnOff_0700 start===="); + var osAccountManager = osaccount.getAccountManager(); + var localId; + console.debug("====>get AccountManager finish===="); + function onCallback(receiveLocalId){ + console.debug("====>receive localId:" + receiveLocalId); + if(receiveLocalId == localId){ + console.debug("====>wrongly received localId: " + localId + " after unsubscribing"); + expect().assertFail(); + done(); + } + } + osAccountManager.on("activating", "", onCallback); + sleep(TIMEOUTHALF); + osAccountManager.createOsAccount("osAccountNameE", 1, (err, osAccountInfo)=>{ + console.debug("====>createOsAccount err:" + JSON.stringify(err)); + console.debug("====>createOsAccount osAccountInfo:" + JSON.stringify(osAccountInfo)); + localId = osAccountInfo.localId; + expect(err.code).assertEqual(0); + expect(osAccountInfo.localName).assertEqual("osAccountNameE"); + osAccountManager.activateOsAccount(localId, (err)=>{ + console.debug("====>activateOsAccount err:" + JSON.stringify(err)); + expect(err.code).assertEqual(0); + setTimeout(()=>{ + osAccountManager.removeOsAccount(localId, (err)=>{ + console.debug("====>remove localId: " + localId + " err:" + JSON.stringify(err)); + expect(err.code).assertEqual(0); + console.debug("====>ActsOsAccountOnOff_0700 end===="); + done(); + }) + }, TIMEOUT); + }); + }); + }); + + /* + * @tc.number : ActsOsAccountOnOff_0800 + * @tc.name : Subscribe and unsubscribing local multi-user + * @tc.desc : Verification cannot cancel activating type not subscribed + */ + it('ActsOsAccountOnOff_0800', 0, async function (done) { + console.debug("====>ActsOsAccountOnOff_0800 start===="); + var osAccountManager = osaccount.getAccountManager(); + var localId; + console.debug("====>get AccountManager finish===="); + function onCallback(receiveLocalId){ + console.debug("====>receive localId:" + receiveLocalId); + if(receiveLocalId == localId){ + console.debug("====>wrongly received localId: " + localId + " after unsubscribing"); + expect().assertFail(); + done(); + } + } + osAccountManager.on("activate", "", onCallback); + sleep(TIMEOUTHALF); + osAccountManager.createOsAccount("osAccountNameF", 1, (err, osAccountInfo)=>{ + console.debug("====>createOsAccount err:" + JSON.stringify(err)); + console.debug("====>createOsAccount osAccountInfo:" + JSON.stringify(osAccountInfo)); + localId = osAccountInfo.localId; + expect(err.code).assertEqual(0); + expect(osAccountInfo.localName).assertEqual("osAccountNameF"); + osAccountManager.activateOsAccount(localId, (err)=>{ + console.debug("====>activateOsAccount err:" + JSON.stringify(err)); + expect(err.code).assertEqual(0); + setTimeout(()=>{ + osAccountManager.removeOsAccount(localId, (err)=>{ + console.debug("====>remove localId: " + localId + " err:" + JSON.stringify(err)); + expect(err.code).assertEqual(0); + console.debug("====>ActsOsAccountOnOff_0800 end===="); + done(); + }) + }, TIMEOUT); + }); + }); + }); + + /* + * @tc.number : ActsOsAccountOnOff_0900 + * @tc.name : Subscribe and unsubscribing local multi-user + * @tc.desc : Verification does not trigger callbacks for activating type subscriptions when switching fails + */ + it('ActsOsAccountOnOff_0900', 0, async function (done) { + console.debug("====>ActsOsAccountOnOff_0900 start===="); + var osAccountManager = osaccount.getAccountManager(); + var localId; + console.debug("====>get AccountManager finish===="); + function onCallback(receiveLocalId){ + console.debug("====>receive localId:" + receiveLocalId); + if(receiveLocalId == localId){ + console.debug("====>wrongly received localId: " + localId + " after unsubscribing"); + expect().assertFail(); + done(); + } + } + function offCallback(){ + console.debug("====>off enter"); + console.debug("====>ActsOsAccountOnOff_0900 end===="); + done(); + } + osAccountManager.on("activating", "osAccountOnOffNameG", onCallback); + sleep(TIMEOUTHALF); + osAccountManager.queryAllCreatedOsAccounts((err, data)=>{ + console.debug("====>queryAllCreatedOsAccounts err:" + JSON.stringify(err)); + expect(err.code).assertEqual(0); + for (var i = 0;i< data.length;i++){ + if(data[i].isActived == true){ + localId = data[i].localId; + } + } + osAccountManager.activateOsAccount(localId, (err)=>{ + console.debug("====>activateOsAccount err:" + JSON.stringify(err)); + expect(err.code !=0).assertEqual(true); + setTimeout(()=>{ + osAccountManager.off("activating", "osAccountOnOffNameG", offCallback); + }, TIMEOUT); + }); + }) + }); + + /* + * @tc.number : ActsOsAccountOnOff_1000 + * @tc.name : Subscribe and unsubscribing local multi-user + * @tc.desc : Verification does not trigger callbacks for activate type subscriptions when switching fails + */ + it('ActsOsAccountOnOff_1000', 0, async function (done) { + console.debug("====>ActsOsAccountOnOff_1000 start===="); + var osAccountManager = osaccount.getAccountManager(); + var localId; + console.debug("====>get AccountManager finish===="); + function onCallback(receiveLocalId){ + console.debug("====>receive localId:" + receiveLocalId); + if(receiveLocalId == localId){ + console.debug("====>wrongly received localId: " + localId + " after unsubscribing"); + expect().assertFail(); + done(); + } + } + function offCallback(){ + console.debug("====>off enter"); + console.debug("====>ActsOsAccountOnOff_1000 end===="); + done(); + } + osAccountManager.on("activate", "osAccountOnOffNameH", onCallback); + sleep(TIMEOUTHALF); + osAccountManager.queryAllCreatedOsAccounts((err, data)=>{ + console.debug("====>queryAllCreatedOsAccounts err:" + JSON.stringify(err)); + for (var i = 0;i< data.length;i++){ + if(data[i].isActived == true){ + localId = data[i].localId; + } + } + osAccountManager.activateOsAccount(localId, (err)=>{ + console.debug("====>activateOsAccount err:" + JSON.stringify(err)); + setTimeout(()=>{ + expect(err.code !=0).assertEqual(true); + osAccountManager.off("activate", "osAccountOnOffNameH", offCallback); + }, 2000); + }); + }) + }) + + /* + * @tc.number : ActsOsAccountOnOff_1100 + * @tc.name : Subscribe and unsubscribing local multi-user + * @tc.desc : Verify that an instance repeatedly subscribes to local users + */ + it('ActsOsAccountOnOff_1100', 0, async function (done) { + console.debug("====>ActsOsAccountOnOff_1100 start===="); + var osAccountManager = osaccount.getAccountManager(); + var localId; + var countNum = 0; + console.debug("====>get AccountManager finish===="); + function onCallback(receiveLocalId){ + console.debug("====>receive localId:" + receiveLocalId); + if(receiveLocalId == localId){ + countNum++; + } + } + function onCallbackTwice(receiveLocalId){ + console.debug("====>receive twice localId:" + receiveLocalId); + if(receiveLocalId == localId){ + countNum++; + } + } + function offCallback(){ + console.debug("====>off enter===="); + expect(countNum).assertEqual(2); + osAccountManager.removeOsAccount(localId, (err)=>{ + console.debug("====>remove localId: " + localId + " err:" + JSON.stringify(err)); + expect(err.code).assertEqual(0); + console.debug("====>ActsOsAccountOnOff_1100 end===="); + done(); + }) + } + osAccountManager.on("activate", "osAccountOnOffNameI", onCallback); + osAccountManager.on("activate", "osAccountOnOffNameI", onCallbackTwice); + sleep(TIMEOUT); + osAccountManager.createOsAccount("osAccountNameI", 1, (err, osAccountInfo)=>{ + console.debug("====>createOsAccount err:" + JSON.stringify(err)); + console.debug("====>createOsAccount osAccountInfo:" + JSON.stringify(osAccountInfo)); + localId = osAccountInfo.localId; + expect(err.code).assertEqual(0); + expect(osAccountInfo.localName).assertEqual("osAccountNameI"); + osAccountManager.activateOsAccount(localId, (err)=>{ + console.debug("====>activateOsAccount err:" + JSON.stringify(err)); + expect(err.code).assertEqual(0); + setTimeout(()=>{ + osAccountManager.off("activate", "osAccountOnOffNameI", offCallback); + }, 2000); + }); + }); + }); + + /* + * @tc.number : ActsOsAccountOnOff_1200 + * @tc.name : Subscribe and unsubscribing local multi-user + * @tc.desc : Verify that an instance unsubscribes local users afer resubscribing + */ + it('ActsOsAccountOnOff_1200', 0, async function (done) { + console.debug("====>ActsOsAccountOnOff_1200 start===="); + var osAccountManager = osaccount.getAccountManager(); + var localId; + var countNum = 0; + console.debug("====>get AccountManager finish===="); + function onCallback(receiveLocalId){ + console.debug("====>receive localId:" + receiveLocalId); + if(receiveLocalId == localId){ + countNum++; + } + } + function onCallbackTwice(receiveLocalId){ + console.debug("====>receive twice localId:" + receiveLocalId); + if(receiveLocalId == localId){ + countNum++; + } + } + function offCallback(){ + console.debug("====>off enter===="); + } + osAccountManager.on("activate", "osAccountOnOffNameJ", onCallback); + osAccountManager.on("activate", "osAccountOnOffNameJ", onCallbackTwice); + sleep(TIMEOUTHALF); + osAccountManager.off("activate", "osAccountOnOffNameJ", offCallback); + sleep(TIMEOUTHALF); + osAccountManager.createOsAccount("osAccountNameJ", 1, (err, osAccountInfo)=>{ + console.debug("====>createOsAccount err:" + JSON.stringify(err)); + console.debug("====>createOsAccount osAccountInfo:" + JSON.stringify(osAccountInfo)); + localId = osAccountInfo.localId; + expect(err.code).assertEqual(0); + expect(osAccountInfo.localName).assertEqual("osAccountNameJ"); + osAccountManager.activateOsAccount(localId, (err)=>{ + console.debug("====>activateOsAccount err:" + JSON.stringify(err)); + expect(err.code).assertEqual(0); + setTimeout(()=>{ + expect(countNum).assertEqual(0); + osAccountManager.removeOsAccount(localId, (err)=>{ + console.debug("====>remove localId: " + localId + " err:" + JSON.stringify(err)); + expect(err.code).assertEqual(0); + console.debug("====>ActsOsAccountOnOff_1200 end===="); + done(); + }) + }, TIMEOUT); + }); + }); + }); + + /* + * @tc.number : ActsOsAccountOnOff_1300 + * @tc.name : Subscribe and unsubscribing local multi-user + * @tc.desc : Verify that an instance unsubscribes local users afer resubscribing + */ + it('ActsOsAccountOnOff_1300', 0, async function (done) { + console.debug("====>ActsOsAccountOnOff_1300 start===="); + var osAccountManager = osaccount.getAccountManager(); + var osAccountManagerTwice = osaccount.getAccountManager(); + var localId; + var countFirstNum = 0; + var countSecondNum = 0; + console.debug("====>get AccountManager finish===="); + function onCallback(receiveLocalId){ + console.debug("====>receive localId:" + receiveLocalId); + if(receiveLocalId == localId){ + countFirstNum++; + } + } + function onCallbackTwice(receiveLocalId){ + console.debug("====>receive twice localId:" + receiveLocalId); + if(receiveLocalId == localId){ + countSecondNum++; + } + } + function offCallback(){ + console.debug("====>off enter===="); + } + function offCallbackTwice(){ + console.debug("====>off twice enter===="); + osAccountManager.removeOsAccount(localId, (err)=>{ + console.debug("====>remove localId: " + localId + " err:" + JSON.stringify(err)); + expect(err.code).assertEqual(0); + console.debug("====>ActsOsAccountOnOff_1300 end===="); + done(); + }) + } + osAccountManager.on("activate", "osAccountOnOffNameJ", onCallback); + osAccountManagerTwice.on("activate", "osAccountOnOffNameJ", onCallbackTwice); + sleep(TIMEOUTHALF); + osAccountManager.off("activate", "osAccountOnOffNameJ", offCallback); + sleep(TIMEOUTHALF); + osAccountManager.createOsAccount("osAccountNameK", 1, (err, osAccountInfo)=>{ + console.debug("====>createOsAccount err:" + JSON.stringify(err)); + console.debug("====>createOsAccount osAccountInfo:" + JSON.stringify(osAccountInfo)); + localId = osAccountInfo.localId; + expect(err.code).assertEqual(0); + expect(osAccountInfo.localName).assertEqual("osAccountNameK"); + osAccountManager.activateOsAccount(localId, (err)=>{ + console.debug("====>activateOsAccount err:" + JSON.stringify(err)); + expect(err.code).assertEqual(0); + setTimeout(()=>{ + expect(countFirstNum).assertEqual(0); + expect(countSecondNum).assertEqual(1); + osAccountManagerTwice.off("activate", "osAccountOnOffNameJ", offCallbackTwice); + }, TIMEOUT); + }); + }); + }); + + /* + * @tc.number : ActsOsAccountOnOff_1400 + * @tc.name : Subscribe and unsubscribing local multi-user + * @tc.desc : Validate subscription with parameter type as empty string + */ + it('ActsOsAccountOnOff_1400', 0, async function (done) { + console.debug("====>ActsOsAccountOnOff_1400 start===="); + var osAccountManager = osaccount.getAccountManager(); + var localId; + console.debug("====>get AccountManager finish===="); + function onCallback(receiveLocalId){ + console.debug("====>receive localId:" + receiveLocalId); + if(receiveLocalId == localId){ + console.debug("====>wrongly received localId: " + localId + " after unsubscribing"); + expect().assertFail(); + done(); + } + } + osAccountManager.on("", "osAccountOnOffNameL", onCallback); + sleep(TIMEOUTHALF); + osAccountManager.createOsAccount("osAccountNameL", 1, (err, osAccountInfo)=>{ + console.debug("====>createOsAccount err:" + JSON.stringify(err)); + console.debug("====>createOsAccount osAccountInfo:" + JSON.stringify(osAccountInfo)); + localId = osAccountInfo.localId; + expect(err.code).assertEqual(0); + expect(osAccountInfo.localName).assertEqual("osAccountNameL"); + osAccountManager.activateOsAccount(localId, (err)=>{ + console.debug("====>activateOsAccount err:" + JSON.stringify(err)); + expect(err.code).assertEqual(0); + setTimeout(()=>{ + osAccountManager.removeOsAccount(localId, (err)=>{ + console.debug("====>remove localId: " + localId + " err:" + JSON.stringify(err)); + expect(err.code).assertEqual(0); + console.debug("====>ActsOsAccountOnOff_1400 end===="); + done(); + }) + }, TIMEOUT); + }); + }); + }); + + /* + * @tc.number : ActsOsAccountOnOff_1500 + * @tc.name : Subscribe and unsubscribing local multi-user + * @tc.desc : Validate subscription with parameter type as other string + */ + it('ActsOsAccountOnOff_1500', 0, async function (done) { + console.debug("====>ActsOsAccountOnOff_1500 start===="); + var osAccountManager = osaccount.getAccountManager(); + var localId; + console.debug("====>get AccountManager finish===="); + function onCallback(receiveLocalId){ + console.debug("====>receive localId:" + receiveLocalId); + if(receiveLocalId == localId){ + console.debug("====>wrongly received localId: " + localId + " after unsubscribing"); + expect().assertFail(); + done(); + } + } + osAccountManager.on("Abc", "osAccountOnOffNameM", onCallback); + sleep(TIMEOUTHALF); + osAccountManager.createOsAccount("osAccountNameM", 1, (err, osAccountInfo)=>{ + console.debug("====>createOsAccount err:" + JSON.stringify(err)); + console.debug("====>createOsAccount osAccountInfo:" + JSON.stringify(osAccountInfo)); + localId = osAccountInfo.localId; + expect(err.code).assertEqual(0); + expect(osAccountInfo.localName).assertEqual("osAccountNameM"); + osAccountManager.activateOsAccount(localId, (err)=>{ + console.debug("====>activateOsAccount err:" + JSON.stringify(err)); + expect(err.code).assertEqual(0); + setTimeout(()=>{ + osAccountManager.removeOsAccount(localId, (err)=>{ + console.debug("====>remove localId: " + localId + " err:" + JSON.stringify(err)); + expect(err.code).assertEqual(0); + console.debug("====>ActsOsAccountOnOff_1500 end===="); + done(); + }) + }, TIMEOUT); + }); + }); + }); + + /* + * @tc.number : ActsOsAccountOnOff_1600 + * @tc.name : Subscribe and unsubscribing local multi-user + * @tc.desc : Validate subscription with parameter type as undefined + */ + it('ActsOsAccountOnOff_1600', 0, async function (done) { + console.debug("====>ActsOsAccountOnOff_1600 start===="); + var osAccountManager = osaccount.getAccountManager(); + var localId; + console.debug("====>get AccountManager finish===="); + function onCallback(receiveLocalId){ + console.debug("====>receive localId:" + receiveLocalId); + if(receiveLocalId == localId){ + console.debug("====>wrongly received localId: " + localId + " after unsubscribing"); + expect().assertFail(); + done(); + } + } + osAccountManager.on(undefined, "osAccountOnOffNameM", onCallback); + osAccountManager.createOsAccount("osAccountNameM", 1, (err, osAccountInfo)=>{ + console.debug("====>createOsAccount err:" + JSON.stringify(err)); + console.debug("====>createOsAccount osAccountInfo:" + JSON.stringify(osAccountInfo)); + localId = osAccountInfo.localId; + expect(err.code).assertEqual(0); + expect(osAccountInfo.localName).assertEqual("osAccountNameM"); + osAccountManager.activateOsAccount(localId, (err)=>{ + console.debug("====>activateOsAccount err:" + JSON.stringify(err)); + expect(err.code).assertEqual(0); + setTimeout(()=>{ + osAccountManager.removeOsAccount(localId, (err)=>{ + console.debug("====>remove localId: " + localId + " err:" + JSON.stringify(err)); + expect(err.code).assertEqual(0); + console.debug("====>ActsOsAccountOnOff_1600 end===="); + done(); + }) + }, TIMEOUT); + }); + }); + }); + /* * @tc.number : ActsOsAccountOnOff_1700 * @tc.name : Subscribe and unsubscribing local multi-user diff --git a/account/osaccount/actsosaccountsystemtest/entry/src/main/js/test/Query.test.js b/account/osaccount/actsosaccountsystemtest/entry/src/main/js/test/Query.test.js index 4d3213c306d941e107230d8d52f6c50a59c3e2a3..7834b26eb9cba5eb8b79e09cddbdbc793ee51d35 100755 --- a/account/osaccount/actsosaccountsystemtest/entry/src/main/js/test/Query.test.js +++ b/account/osaccount/actsosaccountsystemtest/entry/src/main/js/test/Query.test.js @@ -32,6 +32,12 @@ describe('ActsOsAccountSystemTest', function () { console.debug("====>queryOsAccountById data:" + JSON.stringify(data)); expect(err.code).assertEqual(0); expect(data.localId).assertEqual(100); + expect(data.type.ADMIN).assertEqual(0); + var serialNumberStr = data.serialNumber.toString(); + var serialIntercept = serialNumberStr.substring(8); + console.debug("====>truncate the last eight characters: " + serialIntercept); + expect(serialIntercept).assertEqual("00000001"); + expect(data.isCreateCompleted).assertTrue(); console.debug("====>ActsOsAccountQuery_0100 end===="); done(); }) @@ -49,6 +55,12 @@ describe('ActsOsAccountSystemTest', function () { var osAccountInfo = await osAccountManager.queryOsAccountById(100); console.debug("====>queryOsAccountById osAccountInfo:" + JSON.stringify(osAccountInfo)); expect(osAccountInfo.localId).assertEqual(100); + expect(osAccountInfo.type.ADMIN).assertEqual(0); + var serialNumberStr = osAccountInfo.serialNumber.toString(); + var serialIntercept = serialNumberStr.substring(8); + console.debug("====>truncate the last eight characters: " + serialIntercept); + expect(serialIntercept).assertEqual("00000001"); + expect(osAccountInfo.isCreateCompleted).assertTrue(); console.debug("====>ActsOsAccountQuery_0200 end===="); done(); }); @@ -212,7 +224,7 @@ describe('ActsOsAccountSystemTest', function () { console.debug("====>queryAllCreatedOsAccounts data:" + JSON.stringify(data)); expect(err.code).assertEqual(0); for (let i = 0, len = data.length; i < len; i++) { - dataMap.set(data[i].localId, data[i].owner) + dataMap.set(data[i].localId, data[i].localName) } expect(dataMap.has(100)).assertTrue(); console.debug("====>ActsOsAccountQuery_1100 end===="); @@ -233,13 +245,87 @@ describe('ActsOsAccountSystemTest', function () { var osAccountCreated = await osAccountManager.queryAllCreatedOsAccounts(); console.debug("====>queryAllCreatedOsAccounts:" + JSON.stringify(osAccountCreated)); for (let i = 0, len = osAccountCreated.length; i < len; i++) { - dataMap.set(osAccountCreated[i].localId, osAccountCreated[i].owner) + dataMap.set(osAccountCreated[i].localId, osAccountCreated[i].localName) } expect(dataMap.has(100)).assertTrue(); console.debug("====>ActsOsAccountQuery_1200 end===="); done(); }); + /* + * @tc.number : ActsOsAccountQuery_1300 + * @tc.name : queryAllCreatedOsAccounts callback + * @tc.desc : Verify that all local users contain 100 user and created users + */ + it('ActsOsAccountQuery_1300', 0, async function (done) { + console.debug("====>ActsOsAccountQuery_1300 start===="); + var osAccountManager = osaccount.getAccountManager(); + console.debug("====>get AccountManager finish===="); + var createIocalId; + let dataMap = new Map(); + osAccountManager.createOsAccount("osAccountNameQueryA", 1, (err, osAccountInfo)=>{ + console.debug("====>createOsAccount err:" + JSON.stringify(err)); + console.debug("====>createOsAccount osAccountInfo:" + JSON.stringify(osAccountInfo)); + createIocalId = osAccountInfo.localId; + expect(err.code).assertEqual(0); + expect(osAccountInfo.localName).assertEqual("osAccountNameQueryA"); + osAccountManager.queryAllCreatedOsAccounts((err, data)=>{ + console.debug("====>queryAllCreatedOsAccounts err:" + JSON.stringify(err)); + console.debug("====>queryAllCreatedOsAccounts data:" + JSON.stringify(data)); + expect(err.code).assertEqual(0); + for (let i = 0, len = data.length; i < len; i++) { + dataMap.set(data[i].localId, data[i].localName) + } + expect(dataMap.has(100)).assertTrue(); + expect(dataMap.has(createIocalId)).assertTrue(); + if (dataMap.has(createIocalId)) { + let createdlocalName = dataMap.get(createIocalId); + console.debug("====>query all local users containing localId: " + createIocalId); + console.debug("====>created localName" + createdlocalName); + expect(createdlocalName).assertEqual("osAccountNameQueryA"); + osAccountManager.removeOsAccount(createIocalId, (err)=>{ + console.debug("====>remove localId: " + createIocalId + " err:" + JSON.stringify(err)); + expect(err.code).assertEqual(0); + console.debug("====>ActsOsAccountQuery_1300 end===="); + done(); + }) + } + }) + }); + }); + + /* + * @tc.number : ActsOsAccountQuery_1400 + * @tc.name : queryAllCreatedOsAccounts promise + * @tc.desc : Verify that all local users contain 100 user and created users + */ + it('ActsOsAccountQuery_1400', 0, async function (done) { + console.debug("====>ActsOsAccountQuery_1400 start===="); + var osAccountManager = osaccount.getAccountManager(); + console.debug("====>get AccountManager finish===="); + var createIocalId; + let dataMap = new Map(); + var osAccountInfo = await osAccountManager.createOsAccount("osAccountNameQueryB", 1); + console.debug("====>createOsAccount osAccountInfo:" + JSON.stringify(osAccountInfo)); + createIocalId = osAccountInfo.localId; + expect(osAccountInfo.localName).assertEqual("osAccountNameQueryB"); + var data = await osAccountManager.queryAllCreatedOsAccounts(); + console.debug("====>queryAllCreatedOsAccounts data:" + JSON.stringify(data)); + for (let i = 0, len = data.length; i < len; i++) { + dataMap.set(data[i].localId, data[i].localName) + } + expect(dataMap.has(100)).assertTrue(); + expect(dataMap.has(createIocalId)).assertTrue(); + if (dataMap.has(createIocalId)) { + let createdlocalName = dataMap.get(createIocalId); + console.debug("====>query all local users containing localId: " + createIocalId); + expect(createdlocalName).assertEqual("osAccountNameQueryB"); + } + await osAccountManager.removeOsAccount(createIocalId); + console.debug("====>ActsOsAccountQuery_1400 end===="); + done(); + }); + /* * @tc.number : ActsOsAccountQuery_1500 * @tc.name : queryMaxOsAccountNumber callback diff --git a/account/osaccount/actsosaccountthirdpartytest/entry/src/main/js/test/OsAccountIs.test.js b/account/osaccount/actsosaccountthirdpartytest/entry/src/main/js/test/OsAccountIs.test.js index d70b66947980ef3fec641bb32d4570940da3cbda..9991b93521a7f8d22a0f44438ed9cb0854a6822a 100755 --- a/account/osaccount/actsosaccountthirdpartytest/entry/src/main/js/test/OsAccountIs.test.js +++ b/account/osaccount/actsosaccountthirdpartytest/entry/src/main/js/test/OsAccountIs.test.js @@ -138,6 +138,45 @@ describe('ActsOsAccountThirdPartyTest', function () { } }) + /* + * @tc.number : ActsOsAccountIsActived_0500 + * @tc.name : isOsAccountActived callback + * @tc.desc : Authentication failed to query the active status of the user that does not exist + */ + it('ActsOsAccountIsActived_0500', 0, async function(done){ + console.debug("====>ActsOsAccountIsActived_0500 start"); + var AccountManager = osAccount.getAccountManager(); + console.debug("====>get os AccountManager finish===="); + var nonExistLocalId = 1000; + AccountManager.isOsAccountActived(nonExistLocalId, (err)=>{ + console.debug("====>isOsAccountActived err:" + JSON.stringify(err)); + expect(err.code !=0).assertEqual(true); + console.debug("====>ActsOsAccountIsActived_0500 end"); + done(); + }) + }) + + /* + * @tc.number : ActsOsAccountIsActived_0600 + * @tc.name : isOsAccountActived promise + * @tc.desc : Authentication failed to query the active status of the user that does not exist + */ + it('ActsOsAccountIsActived_0600', 0, async function(done){ + console.debug("====>ActsOsAccountIsActived_0600 start===="); + var AccountManager = osAccount.getAccountManager(); + console.debug("====>get os AccountManager finish===="); + var nonExistLocalId = 1000; + try{ + await AccountManager.isOsAccountActived(nonExistLocalId); + } + catch(err){ + console.debug("====>isOsAccountActived err:" + JSON.stringify(err)); + expect(err.code !=0 ).assertTrue(); + console.debug("====>ActsOsAccountIsActived_0600 end"); + done(); + } + }) + /* * @tc.number : ActsOsAccountIsMulty_0100 * @tc.name : isMultiOsAccountEnable callback @@ -363,5 +402,4 @@ describe('ActsOsAccountThirdPartyTest', function () { console.debug("====>ActsOsAccountIsTest_0200 end===="); done(); }) -}) - +}) \ No newline at end of file