diff --git a/updater/update_test/gradle/entry/src/main/js/test/update.test.js b/updater/update_test/gradle/entry/src/main/js/test/update.test.js index 53c89ce2c585307ef6af0d230e27d6a62f18f29c..d8070edafcff2296904ae8dc41fa14894027562f 100755 --- a/updater/update_test/gradle/entry/src/main/js/test/update.test.js +++ b/updater/update_test/gradle/entry/src/main/js/test/update.test.js @@ -17,9 +17,10 @@ import {describe, beforeAll, beforeEach, afterEach, afterAll, it, expect} from ' import client from '@ohos.update'; let updater; -var param_value1 = 444; -var param_value2 = 555; -var expect_value = 100; +var param_value1 = 0; +var param_value2 = 0; +var expect_value = 0; + var updateState = { UPDATE_STATE_INIT : 0, UPDATE_STATE_CHECK_VERSION_ON : 10, @@ -46,33 +47,39 @@ var updateState = { describe('updateclient', function() { beforeAll(function() { - if (updater == undefined) { - updater = client.getUpdater('/data/updater/updater.zip', 'OTA'); - console.info("beforeAll updater" + updater); - } + param_value1 = 444; + param_value2 = 555; + expect_value = 100; }); beforeEach(function() { - if (updater == undefined) { + if (updater === undefined) { updater = client.getUpdater('/data/updater/updater.zip', 'OTA'); console.info("beforeEach updater" + updater); } }); - afterEach(function() {}); + afterEach(function() { + updater = None; + }); + afterAll(function() { + param_value1 = 0; + param_value2 = 0; + expect_value = 0; + }); /** * @tc.number SUB_UPDATE_JS_API_0001 * @tc.name testGetUpdate - * @tc.desc . + * @tc.desc Test get update obj. */ it('testGetUpdate', 0, function() { console.info('testGetUpdate START'); try { - if (client == undefined) { + if (client === undefined) { console.error("client not defined"); return; } let tmpUpdater = client.getUpdater('/data/updater/updater.zip', 'OTA'); - expect(tmpUpdater != undefined); + expect(tmpUpdater != undefined).assertTrue(); } catch(e) { console.error('[testGetUpdate] fail.' + e); } @@ -89,13 +96,13 @@ describe('updateclient', function() { it('testGetUpdate2', 0, function() { console.info('testGetUpdate2 START'); try { - if (client == undefined) { + if (client === undefined) { console.error("client not defined"); return; } let tmpUpdater = client.getUpdater('/data/updater/updater.zip', '44444'); console.info("testGetUpdate3 updater" + tmpUpdater); - expect(tmpUpdater == undefined); + expect(tmpUpdater === undefined).assertTrue(); } catch(e) { console.error('[testGetUpdate] fail.' + e); } @@ -112,14 +119,14 @@ describe('updateclient', function() { it('testGetUpdate3', 0, function() { console.info('testGetUpdate3 START'); try { - if (client == undefined) { + if (client === undefined) { console.error("client not defined"); return; } let tmpUpdater = client.getUpdater('/data/updater/updater.zip', 'patch'); console.info("testGetUpdate3 updater" + tmpUpdater); - expect(tmpUpdater != undefined); - if (tmpUpdater == undefined) { + expect(tmpUpdater != undefined).assertTrue(); + if (tmpUpdater === undefined) { console.error("Fail to get updater"); return; } @@ -140,13 +147,13 @@ describe('updateclient', function() { it('testGetUpdate4', 0, function() { console.info('testGetUpdate4 START'); try { - if (client == undefined) { + if (client === undefined) { console.error("client not defined"); return; } let tmpUpdater = client.getUpdater(function(){ }); - expect(tmpUpdater == undefined); + expect(tmpUpdater === undefined).assertTrue(); } catch(e) { console.error('[testGetUpdate4] fail.' + e); } @@ -163,12 +170,12 @@ describe('updateclient', function() { it('testGetUpdate5', 0, function() { console.info('testGetUpdate5 START'); try { - if (client == undefined) { + if (client === undefined) { console.error("client not defined"); return; } let tmpUpdater = client.getUpdater(param_value1, param_value2); - expect(tmpUpdater == undefined); + expect(tmpUpdater === undefined).assertTrue(); } catch(e) { console.error('[testGetUpdate] fail.' + e); } @@ -189,7 +196,7 @@ describe('updateclient', function() { console.log("getNewVersionInfo success" + data); expect(data.status).assertEqual(0); // Has new version. }); - expect(ret != 0); + expect(ret).assertInstanceOf('Number'); } catch(e) { console.error('[testGetUpdate] fail.' + e); } @@ -206,7 +213,7 @@ describe('updateclient', function() { console.info('testGetNewVersionInfo2 START'); try { let ret = updater.getNewVersionInfo(); - expect(ret != 0); + expect(ret != 0).assertTrue(); console.info('[getNewVersionInfo] success.'); console.info('testGetNewVersionInfo2 END'); } catch(e) { @@ -223,7 +230,7 @@ describe('updateclient', function() { console.info('testGetNewVersionInfo3 START'); try { let ret = updater.getNewVersionInfo("dddddd"); - expect(ret != 0); + expect(ret != 0).assertTrue(); console.info('[getNewVersionInfo] success.'); console.info('testGetNewVersionInfo2 END'); } catch(e) { @@ -240,7 +247,7 @@ describe('updateclient', function() { console.info('testGetNewVersionInfo4 START'); try { let ret = updater.getNewVersionInfo(param_value1); - expect(ret != 0); + expect(ret != 0).assertTrue(); console.info('[getNewVersionInfo] success.'); console.info('testGetNewVersionInfo5 END'); } catch(e) { @@ -257,7 +264,7 @@ describe('updateclient', function() { console.info('testGetNewVersionInfo5 START'); try { let ret = updater.getNewVersionInfo(param_value1, param_value2); - expect(ret != 0); + expect(ret != 0).assertTrue(); console.info('[getNewVersionInfo] success.'); console.info('testGetNewVersionInfo5 END'); } catch(e) { @@ -276,7 +283,7 @@ describe('updateclient', function() { let ret = updater.getNewVersionInfo().then(data => { console.log("getNewVersionInfo success " + data); expect(data.status).assertEqual(0); // Has new version. - expect(data.checkResults.size > 0); + expect(data.checkResults.size > 0).assertTrue(); console.log(`info versionName = ` + data.checkResults[0].versionName); console.log(`info versionCode = ` + data.checkResults[0].versionCode); console.log(`info verifyInfo = ` + data.checkResults[0].verifyInfo); @@ -286,7 +293,7 @@ describe('updateclient', function() { }).catch(error => console.error("getNewVersionInfo catch " + error) ); - expect(ret != 0); + expect(ret != 0).assertTrue(); } catch(e) { console.error("getNewVersionInfo catch " + e); } @@ -307,7 +314,7 @@ describe('updateclient', function() { }).catch(error => console.error("getNewVersionInfo catch " + error) ); - expect(ret != 0); + expect(ret != 0).assertTrue(); } catch(e) { console.error("getNewVersionInfo catch " + e); } @@ -327,7 +334,7 @@ describe('updateclient', function() { }).catch(error => console.error("getNewVersionInfo catch " + error) ); - expect(ret != 0); + expect(ret != 0).assertTrue(); } catch(e) { console.error("getNewVersionInfo catch " + e); } @@ -347,7 +354,7 @@ describe('updateclient', function() { }).catch(error => console.error("getNewVersionInfo catch " + error) ); - expect(ret != 0); + expect(ret != 0).assertTrue(); } catch(e) { console.error("getNewVersionInfo catch " + e); } @@ -367,7 +374,7 @@ describe('updateclient', function() { }).catch(error => console.error("getNewVersionInfo error " + error) ); - expect(ret != 0); + expect(ret != 0).assertTrue(); } catch(e) { console.error("getNewVersionInfo catch " + e); } @@ -386,7 +393,7 @@ describe('updateclient', function() { let ret = updater.checkNewVersion(function(err, data){ console.log("checkNewVersion success" + data); expect(data.status).assertEqual(0); // Has new version. - expect(data.checkResults.size > 0); + expect(data.checkResults.size > 0).assertTrue(); console.log(`info versionName = ` + data.checkResults[0].versionName); console.log(`info versionCode = ` + data.checkResults[0].versionCode); console.log(`info verifyInfo = ` + data.checkResults[0].verifyInfo); @@ -397,7 +404,7 @@ describe('updateclient', function() { error => { console.log("checkNewVersion error" + error) }); - expect(ret != 0); + expect(ret).assertInstanceOf('Number'); } catch(e) { console.error("checkNewVersion catch " + e); } @@ -414,7 +421,7 @@ describe('updateclient', function() { console.info('testCheckNewVersion2 START'); try { let ret = updater.checkNewVersion(); - expect(ret != 0); + expect(ret != 0).assertTrue(); console.info('[checkNewVersion] success.' + ret); console.info('testCheckNewVersion2 END'); } catch(e) { @@ -431,7 +438,7 @@ describe('updateclient', function() { console.info('testCheckNewVersion3 START'); try { let ret = updater.checkNewVersion("33333"); - expect(ret != 0); + expect(ret != 0).assertTrue(); console.info('[checkNewVersion] success.' + ret); console.info('testCheckNewVersion3 END'); } catch(e) { @@ -448,7 +455,7 @@ describe('updateclient', function() { console.info('testCheckNewVersion4 START'); try { let ret = updater.checkNewVersion(param_value1); - expect(ret != 0); + expect(ret != 0).assertTrue(); console.info('[checkNewVersion] success.' + ret); console.info('testCheckNewVersion4 END'); } catch(e) { @@ -465,7 +472,7 @@ describe('updateclient', function() { console.info('testCheckNewVersion4 START'); try { let ret = updater.checkNewVersion(param_value1, param_value2); - expect(ret != 0); + expect(ret != 0).assertTrue(); console.info('[checkNewVersion] success.' + ret); console.info('testCheckNewVersion5 END'); } catch(e) { @@ -484,7 +491,7 @@ describe('updateclient', function() { let ret = updater.checkNewVersion().then(data => { console.log("checkNewVersion success" + data); expect(data.status).assertEqual(0); - expect(data.checkResults.size > 0); + expect(data.checkResults.size > 0).assertTrue(); console.log(`info versionName = ` + data.checkResults[0].versionName); console.log(`info versionCode = ` + data.checkResults[0].versionCode); console.log(`info verifyInfo = ` + data.checkResults[0].verifyInfo); @@ -494,7 +501,7 @@ describe('updateclient', function() { }).catch(error => console.error("checkNewVersion error " + error) ); - expect(ret != 0); + expect(ret != 0).assertTrue(); } catch(e) { console.error("checkNewVersion catch " + e) } @@ -514,7 +521,7 @@ describe('updateclient', function() { }).catch(error => console.error("checkNewVersion error " + error) ); - expect(ret != 0); + expect(ret != 0).assertTrue(); } catch(e) { console.error("checkNewVersion catch " + e); } @@ -534,7 +541,7 @@ describe('updateclient', function() { }).catch(error => console.error("checkNewVersion error " + error) ); - expect(ret != 0); + expect(ret != 0).assertTrue(); } catch(e) { console.error("checkNewVersion catch " + e); } @@ -554,7 +561,7 @@ describe('updateclient', function() { }).catch(error => console.error("checkNewVersion error " + error) ); - expect(ret != 0); + expect(ret != 0).assertTrue(); } catch(e) { console.error("checkNewVersion catch " + e); } @@ -574,7 +581,7 @@ describe('updateclient', function() { }).catch(error => console.error("checkNewVersion error " + error) ); - expect(ret != 0); + expect(ret != 0).assertTrue(); } catch(e) { console.error("checkNewVersion catch " + e); } @@ -602,7 +609,7 @@ describe('updateclient', function() { console.log("setUpdatePolicy success" + data); expect(data).assertEqual(0); }); - expect(ret != 0); + expect(ret).assertInstanceOf('Number'); } catch(e) { console.error('[testSetUpdatePolicy001] fail.' + e); } @@ -613,7 +620,7 @@ describe('updateclient', function() { /** * @tc.number SUB_UPDATE_JS_API_0027 * @tc.name testGetUpdatePolicy001 - * @tc.desc . + * @tc.desc Test get update, policy func 001. */ it('testGetUpdatePolicy001', 0, function() { console.info('testGetUpdatePolicy001 START'); @@ -627,7 +634,7 @@ describe('updateclient', function() { expect(data.autoUpgradeInterval[1]).assertEqual(3); }); - expect(ret != 0); + expect(ret).assertInstanceOf('Number'); } catch(e) { console.error('[testGetUpdatePolicy001] fail.' + e); } @@ -654,7 +661,7 @@ describe('updateclient', function() { console.log("setUpdatePolicy success" + data); expect(data).assertEqual(0); }); - expect(ret != 0); + expect(ret).assertInstanceOf('Number'); } catch(e) { console.error('[testSetUpdatePolicy002] fail.' + e); } @@ -679,7 +686,7 @@ describe('updateclient', function() { expect(data.autoUpgradeInterval[0]).assertEqual(2); expect(data.autoUpgradeInterval[1]).assertEqual(3); }); - expect(ret != 0); + expect(ret).assertInstanceOf('Number'); } catch(e) { console.error('[testGetUpdatePolicy002] fail.' + e); } @@ -708,7 +715,7 @@ describe('updateclient', function() { console.log("setUpdatePolicy success" + data); expect(data).assertEqual(0); }) - expect(ret != 0); + expect(ret).assertInstanceOf('Number'); } catch(e) { console.error('[testSetUpdatePolicy003] fail.' + e); } @@ -732,7 +739,7 @@ describe('updateclient', function() { expect(data.autoUpgradeInterval[0]).assertEqual(2); expect(data.autoUpgradeInterval[1]).assertEqual(3); }) - expect(ret != 0); + expect(ret).assertInstanceOf('Number'); } catch(e) { console.error('[testGetUpdatePolicy003] fail.' + e); } @@ -760,7 +767,7 @@ describe('updateclient', function() { console.log("setUpdatePolicy success" + data); expect(data).assertEqual(0); }) - expect(ret != 0); + expect(ret).assertInstanceOf('Number'); } catch(e) { console.error('[testGetUpdatePolicy003] fail.' + e); } @@ -784,7 +791,7 @@ describe('updateclient', function() { expect(data.autoUpgradeInterval[0]).assertEqual(expect_value); expect(data.autoUpgradeInterval[1]).assertEqual(expect_value); }) - expect(ret != 0); + expect(ret).assertInstanceOf('Number'); } catch(e) { console.error('[testGetUpdatePolicy004] fail.' + e); } @@ -804,7 +811,7 @@ describe('updateclient', function() { console.log("setUpdatePolicy success" + data); expect(data).assertEqual(0); }); - expect(ret != 0); + expect(ret != 0).assertTrue(); } catch(e) { console.error('[testSetUpdatePolicy005] fail.' + e); } @@ -822,7 +829,7 @@ describe('updateclient', function() { try { let ret = updater.getUpdatePolicy("", function(err, data){ }) - expect(ret != 0); + expect(ret != 0).assertTrue(); } catch(e) { console.error('[testSetUpdatePolicy005] fail.' + e); } @@ -852,7 +859,7 @@ describe('updateclient', function() { }).catch(error => console.error("setUpdatePolicy error " + error) ); - expect(ret != 0); + expect(ret != 0).assertTrue(); } catch(e) { console.error('[testSetUpdatePolicyPromise] fail.' + e); } @@ -879,7 +886,7 @@ describe('updateclient', function() { }).catch(error => console.error("getUpdatePolicy catch " + error) ); - expect(ret != 0); + expect(ret != 0).assertTrue(); } catch(e) { console.error('[testGetUpdatePolicyPromise] fail.' + e); } @@ -908,7 +915,7 @@ describe('updateclient', function() { }).catch(error => console.error("setUpdatePolicy error " + error) ); - expect(ret != 0); + expect(ret != 0).assertTrue(); } catch(e) { console.error('[setUpdatePolicy] fail.' + e); } @@ -932,7 +939,7 @@ describe('updateclient', function() { expect(data.autoUpgradeInterval[0]).assertEqual(2); expect(data.autoUpgradeInterval[1]).assertEqual(3); }); - expect(ret != 0); + expect(ret != 0).assertTrue(); } catch(e) { console.error('[testGetUpdatePolicyPromise002] fail.' + e); } @@ -962,7 +969,7 @@ describe('updateclient', function() { }).catch(error => { console.info('[setUpdatePolicy] error ' + error) }) - expect(ret != 0); + expect(ret != 0).assertTrue(); } catch(e) { console.error('[testSetUpdatePolicyPromise003] fail.' + e); } @@ -988,7 +995,7 @@ describe('updateclient', function() { }).catch(error => { console.info('[getUpdatePolicy] error ' + error) }) - expect(ret != 0); + expect(ret != 0).assertTrue(); } catch(e) { console.info('[getUpdatePolicy] catch ' + e) } @@ -1018,7 +1025,7 @@ describe('updateclient', function() { }).catch(error => { console.info('[setUpdatePolicy] error ' + error) }) - expect(ret != 0); + expect(ret != 0).assertTrue(); } catch(e) { console.info('[testSetUpdatePolicyPromise004] catch ' + e) } @@ -1044,7 +1051,7 @@ describe('updateclient', function() { }).catch(error => { console.info('[getUpdatePolicy] error ' + error) }) - expect(ret != 0); + expect(ret != 0).assertTrue(); } catch(e) { console.info('[testSetUpdatePolicyPromise004] catch ' + e) } @@ -1064,7 +1071,7 @@ describe('updateclient', function() { console.log("setUpdatePolicy success" + data); expect(data).assertEqual(0); }); - expect(ret != 0); + expect(ret != 0).assertTrue(); } catch (e) { console.info('[setUpdatePolicy] catch ' + e); } @@ -1082,7 +1089,7 @@ describe('updateclient', function() { try{ let ret = updater.getUpdatePolicy(param_value1).then(data => { }) - expect(ret != 0); + expect(ret != 0).assertTrue(); } catch (e) { console.info('[setUpdatePolicy] catch ' + e); } @@ -1104,14 +1111,14 @@ describe('updateclient', function() { console.log(`downloadProgress status: ` + progress.status); console.log(`downloadProgress percent: ` + progress.percent); console.log(`downloadProgress endReason: ` + progress.endReason); - if (progress.status == updateState.UPDATE_STATE_DOWNLOAD_SUCCESS || - progress.status == updateState.UPDATE_STATE_VERIFY_SUCCESS) { + if (progress.status === updateState.UPDATE_STATE_DOWNLOAD_SUCCESS || + progress.status === updateState.UPDATE_STATE_VERIFY_SUCCESS) { expect(progress.percent).assertEqual(expect_value); updater.off("downloadProgress"); } }) let ret = updater.download(); - expect(ret != 0); + expect(ret).assertInstanceOf('Number'); } catch (e) { console.info('[testDownloadVersion] catch ' + e); } @@ -1134,15 +1141,15 @@ describe('updateclient', function() { console.log(`downloadProgress status: ` + progress.status); console.log(`downloadProgress percent: ` + progress.percent); console.log(`downloadProgress endReason: ` + progress.endReason); - if (progress.status == updateState.UPDATE_STATE_DOWNLOAD_SUCCESS || - progress.status == updateState.UPDATE_STATE_VERIFY_SUCCESS) { + if (progress.status === updateState.UPDATE_STATE_DOWNLOAD_SUCCESS || + progress.status === updateState.UPDATE_STATE_VERIFY_SUCCESS) { expect(progress.percent).assertEqual(expect_value); } }) let ret = updater.download(); // Cancel subscription immediately, no callback will be received. updater.off("downloadProgress"); - expect(ret != 0); + expect(ret).assertInstanceOf('Number'); } catch (e) { console.info('[testDownloadVersion02] catch ' + e); } @@ -1163,12 +1170,12 @@ describe('updateclient', function() { console.log(`downloadProgress status: ` + progress.status); console.log(`downloadProgress percent: ` + progress.percent); console.log(`downloadProgress endReason: ` + progress.endReason); - if (progress.status == updateState.UPDATE_STATE_DOWNLOAD_SUCCESS || - progress.status == updateState.UPDATE_STATE_VERIFY_SUCCESS) { + if (progress.status === updateState.UPDATE_STATE_DOWNLOAD_SUCCESS || + progress.status === updateState.UPDATE_STATE_VERIFY_SUCCESS) { expect(progress.percent).assertEqual(expect_value); } }) - expect(ret != 0); + expect(ret).assertInstanceOf('Number'); } catch (e) { console.info('[testDownloadVersion03] catch ' + e); } @@ -1186,12 +1193,12 @@ describe('updateclient', function() { try{ // Open download monitor. let ret = updater.on('downloadProgress'); - expect(ret != 0); + expect(ret).assertInstanceOf('Number'); let ret_download = updater.download(); - expect(ret_download != 0); + expect(ret_download).assertInstanceOf('Number'); // Cancel subscription immediately, no callback will be received. let ret_off = updater.off("downloadProgress"); - expect(ret_off != 0); + expect(ret_off).assertInstanceOf('Number'); } catch (e) { console.info('[testDownloadVersion04] catch ' + e); } @@ -1215,13 +1222,13 @@ describe('updateclient', function() { try{ // Open download monitor. let ret = updater.on('downloadProgress', testFunction); - expect(ret == 0); + expect(ret).assertInstanceOf('Number'); let ret_download = updater.download(); - expect(ret_download != 0); + expect(ret_download).assertInstanceOf('Number'); // Cancel subscription immediately, no callback will be received. let ret_off = updater.off("downloadProgress", testFunction); - expect(ret_off != 0); + expect(ret_off).assertInstanceOf('Number'); } catch (e) { console.info('[testDownloadVersion05] catch ' + e); } @@ -1244,14 +1251,14 @@ describe('updateclient', function() { console.log(`upgradeProgress status: ` + progress.status); console.log(`upgradeProgress percent: ` + progress.percent); console.log(`upgradeProgress endReason: ` + progress.endReason); - if (progress.status == updateState.UPDATE_STATE_DOWNLOAD_SUCCESS || - progress.status == updateState.UPDATE_STATE_VERIFY_SUCCESS) { + if (progress.status === updateState.UPDATE_STATE_DOWNLOAD_SUCCESS || + progress.status === updateState.UPDATE_STATE_VERIFY_SUCCESS) { expect(progress.percent).assertEqual(expect_value); updater.off("upgradeProgress"); } }) let ret = updater.upgrade(); - expect(ret != 0); + expect(ret).assertInstanceOf('Number'); } catch (e) { console.info('[testUpgradeVersion01] catch ' + e); } @@ -1273,17 +1280,17 @@ describe('updateclient', function() { console.log(`upgradeProgress status: ` + progress.status); console.log(`upgradeProgress percent: ` + progress.percent); console.log(`upgradeProgress endReason: ` + progress.endReason); - if (progress.status == updateState.UPDATE_STATE_DOWNLOAD_SUCCESS || - progress.status == updateState.UPDATE_STATE_VERIFY_SUCCESS) { + if (progress.status === updateState.UPDATE_STATE_DOWNLOAD_SUCCESS || + progress.status === updateState.UPDATE_STATE_VERIFY_SUCCESS) { expect(progress.percent).assertEqual(expect_value); } }) - expect(ret_on != 0); + expect(ret_on).assertInstanceOf('Number'); let ret = updater.upgrade(); - expect(ret != 0); + expect(ret).assertInstanceOf('Number'); // Cancel subscription immediately, no callback will be received. let ret_off = updater.off("upgradeProgress"); - expect(ret_off != 0); + expect(ret_off).assertInstanceOf('Number'); } catch (e) { console.info('[testUpgradeVersion02] catch ' + e); } @@ -1304,12 +1311,12 @@ describe('updateclient', function() { console.log(`upgradeProgress status: ` + progress.status); console.log(`upgradeProgress percent: ` + progress.percent); console.log(`upgradeProgress endReason: ` + progress.endReason); - if (progress.status == updateState.UPDATE_STATE_DOWNLOAD_SUCCESS || - progress.status == updateState.UPDATE_STATE_VERIFY_SUCCESS) { + if (progress.status === updateState.UPDATE_STATE_DOWNLOAD_SUCCESS || + progress.status === updateState.UPDATE_STATE_VERIFY_SUCCESS) { expect(progress.percent).assertEqual(expect_value); } }) - expect(ret != 0); + expect(ret).assertInstanceOf('Number'); } catch (e) { console.info('[testUpgradeVersion03] catch ' + e); } @@ -1327,12 +1334,12 @@ describe('updateclient', function() { try{ // Open download monitor. let ret = updater.on('upgradeProgress'); - expect(ret != 0); + expect(ret).assertInstanceOf('Number'); let ret_upgrade = updater.upgrade(); - expect(ret_upgrade != 0); + expect(ret_upgrade).assertInstanceOf('Number'); // Cancel subscription immediately, no callback will be received. let ret_off = updater.off("upgradeProgress"); - expect(ret_off != 0); + expect(ret_off).assertInstanceOf('Number'); } catch (e) { console.info('[testUpgradeVersion04] catch ' + e); } @@ -1355,13 +1362,13 @@ describe('updateclient', function() { console.info('testUpgradeVersion05 START'); try{ let ret = updater.on('upgradeProgress', testFunction); - expect(ret == 0); + expect(ret).assertInstanceOf('Number'); let ret_upgrade = updater.upgrade(); - expect(ret_upgrade != 0); + expect(ret_upgrade).assertInstanceOf('Number'); let ret_off = updater.off("upgradeProgress", testFunction); - expect(ret_off != 0); + expect(ret_off).assertInstanceOf('Number'); } catch (e) { console.info('[testUpgradeVersion05] catch ' + e); } @@ -1378,7 +1385,7 @@ describe('updateclient', function() { console.info('testOnDownload START'); try{ let ret = updater.on(function(){}); - expect(ret != 0); + expect(ret != 0).assertTrue(); } catch (e) { console.info('[testOnDownload] catch ' + e); } @@ -1395,7 +1402,7 @@ describe('updateclient', function() { console.info('testOnDownload2 START'); try{ let ret = updater.on(); - expect(ret != 0); + expect(ret != 0).assertTrue(); } catch (e) { console.info('[testOnDownload2] catch ' + e); } @@ -1412,7 +1419,7 @@ describe('updateclient', function() { console.info('testOnDownload3 START'); try{ let ret = updater.on("333333333"); - expect(ret != 0); + expect(ret != 0).assertTrue(); } catch (e) { console.info('[testOnDownload3] catch ' + e); } @@ -1429,7 +1436,7 @@ describe('updateclient', function() { console.info('testOnDownload3 START'); try{ let ret = updater.on(param_value2); - expect(ret != 0); + expect(ret != 0).assertTrue(); } catch (e) { console.info('[testOnDownload4] catch ' + e); } @@ -1446,7 +1453,7 @@ describe('updateclient', function() { console.info('testOnDownload5 START'); try{ let ret = updater.on(param_value2, "4444444444444"); - expect(ret != 0); + expect(ret != 0).assertTrue(); } catch (e) { console.info('[testOnDownload5] catch ' + e); } @@ -1463,7 +1470,7 @@ describe('updateclient', function() { console.info('testOffDownload START'); try{ let ret = updater.off(); - expect(ret != 0); + expect(ret != 0).assertTrue(); } catch (e) { console.info('[testOffDownload] catch ' + e); } @@ -1480,7 +1487,7 @@ describe('updateclient', function() { console.info('testOffDownload2 START'); try{ let ret = updater.off("333333333"); - expect(ret != 0); + expect(ret).assertInstanceOf('Number'); } catch (e) { console.info('[testOffDownload2] catch ' + e); } @@ -1497,7 +1504,7 @@ describe('updateclient', function() { console.info('testOffDownload3 START'); try{ let ret = updater.on(param_value2); - expect(ret != 0); + expect(ret != 0).assertTrue(); } catch (e) { console.info('[testOffDownload3] catch ' + e); } @@ -1514,7 +1521,7 @@ describe('updateclient', function() { console.info('testOffDownload4 START'); try{ let ret = updater.off(param_value2, "4444444444444"); - expect(ret != 0); + expect(ret != 0).assertTrue(); } catch (e) { console.info('[testOffDownload4] catch ' + e); } @@ -1531,7 +1538,7 @@ describe('updateclient', function() { console.info('testOffDownload5 START'); try{ let ret = updater.off(function(){}); - expect(ret != 0); + expect(ret != 0).assertTrue(); } catch (e) { console.info('[testOffDownload5] catch ' + e); } @@ -1548,7 +1555,7 @@ describe('updateclient', function() { console.info('testOnUpgrade START'); try{ let ret = updater.on("upgradeProgress", function(){}); - expect(ret != 0); + expect(ret).assertInstanceOf('Number'); } catch (e) { console.info('[testOnUpgrade] catch ' + e); } @@ -1565,7 +1572,7 @@ describe('updateclient', function() { console.info('testOnUpgrade2 START'); try{ let ret = updater.on("upgradeProgress"); - expect(ret != 0); + expect(ret != 0).assertTrue(); } catch (e) { console.info('[testOnUpgrade2] catch ' + e); } @@ -1582,7 +1589,7 @@ describe('updateclient', function() { console.info('testOnUpgrade3 START'); try{ let ret = updater.on("upgradeProgress", "333333333"); - expect(ret != 0); + expect(ret != 0).assertTrue(); } catch (e) { console.info('[testOnUpgrade3] catch ' + e); } @@ -1599,7 +1606,7 @@ describe('updateclient', function() { console.info('testOnUpgrade4 START'); try{ let ret = updater.on("upgradeProgress", param_value2); - expect(ret != 0); + expect(ret != 0).assertTrue(); } catch (e) { console.info('[testOnUpgrade3] catch ' + e); } @@ -1616,7 +1623,7 @@ describe('updateclient', function() { console.info('testOnUpgrade5 START'); try{ let ret = updater.on(param_value2, "4444444444444"); - expect(ret != 0); + expect(ret != 0).assertTrue(); } catch (e) { console.info('[testOnUpgrade5] catch ' + e); } @@ -1633,7 +1640,7 @@ describe('updateclient', function() { console.info('testOffUpgrade START'); try{ let ret = updater.off("upgradeProgress"); - expect(ret != 0); + expect(ret).assertInstanceOf('Number'); } catch (e) { console.info('[testOffUpgrade] catch ' + e); } @@ -1650,7 +1657,7 @@ describe('updateclient', function() { console.info('testOffUpgrade2 START'); try{ let ret = updater.off("upgradeProgress", "333333333"); - expect(ret != 0); + expect(ret != 0).assertTrue(); } catch (e) { console.info('[testOffUpgrade] catch ' + e); } @@ -1667,7 +1674,7 @@ describe('updateclient', function() { console.info('testOffDownload3 START'); try{ let ret = updater.on("upgradeProgress", param_value2); - expect(ret != 0); + expect(ret != 0).assertTrue(); } catch (e) { console.info('[testOffUpgrade3] catch ' + e); } @@ -1684,7 +1691,7 @@ describe('updateclient', function() { console.info('testOffUpgrade4 START'); try{ let ret = updater.off("upgradeProgress", param_value2, "4444444444444"); - expect(ret != 0); + expect(ret != 0).assertTrue(); } catch (e) { console.info('[testOffUpgrade4] catch ' + e); } @@ -1701,7 +1708,7 @@ describe('updateclient', function() { console.info('testOffUpgrade5 START'); try{ let ret = updater.off("upgradeProgress", "6"); - expect(ret != 0); + expect(ret != 0).assertTrue(); } catch (e) { console.info('[testOffUpgrade5] catch ' + e); } @@ -1719,7 +1726,7 @@ describe('updateclient', function() { try{ let ret = updater.cancel(); console.info('updater.cancelUpgrade' + ret); - expect(ret == 0); + expect(ret === 0).assertTrue(); } catch (e) { console.info('[cancel] catch ' + e); } @@ -1741,18 +1748,18 @@ describe('updateclient', function() { console.log(`downloadProgress status: ` + progress.status); console.log(`downloadProgress percent: ` + progress.percent); console.log(`downloadProgress endReason: ` + progress.endReason); - if (progress.status == updateState.UPDATE_STATE_DOWNLOAD_SUCCESS || - progress.status == updateState.UPDATE_STATE_VERIFY_SUCCESS) { + if (progress.status === updateState.UPDATE_STATE_DOWNLOAD_SUCCESS || + progress.status === updateState.UPDATE_STATE_VERIFY_SUCCESS) { expect(progress.percent).assertEqual(expect_value); updater.off("downloadProgress"); } }) let ret = updater.download(); - expect(ret == 0); + expect(ret === 0).assertTrue(); ret = updater.cancel(); console.info('updater.cancel' + ret); - expect(ret == 0); + expect(ret === 0).assertTrue(); } catch (e) { console.info('[cancel] catch ' + e); } @@ -1770,7 +1777,7 @@ describe('updateclient', function() { try{ let ret = updater.cancel(); console.info('updater.cancel' + ret); - expect(ret == 0); + expect(ret === 0).assertTrue(); } catch (e) { console.info('[cancel] catch ' + e); } @@ -1788,7 +1795,7 @@ describe('updateclient', function() { try{ let ret = updater.cancel(""); console.info('updater.cancel' + ret); - expect(ret == undefined); + expect(ret === undefined).assertTrue(); } catch (e) { console.info('[cancel] catch ' + e); } @@ -1805,7 +1812,7 @@ describe('updateclient', function() { try{ let ret = updater.cancel(function(){}); console.info('updater.cancel' + ret); - expect(ret == undefined); + expect(ret === undefined).assertTrue(); } catch (e) { console.info('[cancel] catch ' + e); } diff --git a/updater/update_test/gradle/entry/src/ohosTest/js/test/update.test.js b/updater/update_test/gradle/entry/src/ohosTest/js/test/update.test.js index 53c89ce2c585307ef6af0d230e27d6a62f18f29c..d8070edafcff2296904ae8dc41fa14894027562f 100755 --- a/updater/update_test/gradle/entry/src/ohosTest/js/test/update.test.js +++ b/updater/update_test/gradle/entry/src/ohosTest/js/test/update.test.js @@ -17,9 +17,10 @@ import {describe, beforeAll, beforeEach, afterEach, afterAll, it, expect} from ' import client from '@ohos.update'; let updater; -var param_value1 = 444; -var param_value2 = 555; -var expect_value = 100; +var param_value1 = 0; +var param_value2 = 0; +var expect_value = 0; + var updateState = { UPDATE_STATE_INIT : 0, UPDATE_STATE_CHECK_VERSION_ON : 10, @@ -46,33 +47,39 @@ var updateState = { describe('updateclient', function() { beforeAll(function() { - if (updater == undefined) { - updater = client.getUpdater('/data/updater/updater.zip', 'OTA'); - console.info("beforeAll updater" + updater); - } + param_value1 = 444; + param_value2 = 555; + expect_value = 100; }); beforeEach(function() { - if (updater == undefined) { + if (updater === undefined) { updater = client.getUpdater('/data/updater/updater.zip', 'OTA'); console.info("beforeEach updater" + updater); } }); - afterEach(function() {}); + afterEach(function() { + updater = None; + }); + afterAll(function() { + param_value1 = 0; + param_value2 = 0; + expect_value = 0; + }); /** * @tc.number SUB_UPDATE_JS_API_0001 * @tc.name testGetUpdate - * @tc.desc . + * @tc.desc Test get update obj. */ it('testGetUpdate', 0, function() { console.info('testGetUpdate START'); try { - if (client == undefined) { + if (client === undefined) { console.error("client not defined"); return; } let tmpUpdater = client.getUpdater('/data/updater/updater.zip', 'OTA'); - expect(tmpUpdater != undefined); + expect(tmpUpdater != undefined).assertTrue(); } catch(e) { console.error('[testGetUpdate] fail.' + e); } @@ -89,13 +96,13 @@ describe('updateclient', function() { it('testGetUpdate2', 0, function() { console.info('testGetUpdate2 START'); try { - if (client == undefined) { + if (client === undefined) { console.error("client not defined"); return; } let tmpUpdater = client.getUpdater('/data/updater/updater.zip', '44444'); console.info("testGetUpdate3 updater" + tmpUpdater); - expect(tmpUpdater == undefined); + expect(tmpUpdater === undefined).assertTrue(); } catch(e) { console.error('[testGetUpdate] fail.' + e); } @@ -112,14 +119,14 @@ describe('updateclient', function() { it('testGetUpdate3', 0, function() { console.info('testGetUpdate3 START'); try { - if (client == undefined) { + if (client === undefined) { console.error("client not defined"); return; } let tmpUpdater = client.getUpdater('/data/updater/updater.zip', 'patch'); console.info("testGetUpdate3 updater" + tmpUpdater); - expect(tmpUpdater != undefined); - if (tmpUpdater == undefined) { + expect(tmpUpdater != undefined).assertTrue(); + if (tmpUpdater === undefined) { console.error("Fail to get updater"); return; } @@ -140,13 +147,13 @@ describe('updateclient', function() { it('testGetUpdate4', 0, function() { console.info('testGetUpdate4 START'); try { - if (client == undefined) { + if (client === undefined) { console.error("client not defined"); return; } let tmpUpdater = client.getUpdater(function(){ }); - expect(tmpUpdater == undefined); + expect(tmpUpdater === undefined).assertTrue(); } catch(e) { console.error('[testGetUpdate4] fail.' + e); } @@ -163,12 +170,12 @@ describe('updateclient', function() { it('testGetUpdate5', 0, function() { console.info('testGetUpdate5 START'); try { - if (client == undefined) { + if (client === undefined) { console.error("client not defined"); return; } let tmpUpdater = client.getUpdater(param_value1, param_value2); - expect(tmpUpdater == undefined); + expect(tmpUpdater === undefined).assertTrue(); } catch(e) { console.error('[testGetUpdate] fail.' + e); } @@ -189,7 +196,7 @@ describe('updateclient', function() { console.log("getNewVersionInfo success" + data); expect(data.status).assertEqual(0); // Has new version. }); - expect(ret != 0); + expect(ret).assertInstanceOf('Number'); } catch(e) { console.error('[testGetUpdate] fail.' + e); } @@ -206,7 +213,7 @@ describe('updateclient', function() { console.info('testGetNewVersionInfo2 START'); try { let ret = updater.getNewVersionInfo(); - expect(ret != 0); + expect(ret != 0).assertTrue(); console.info('[getNewVersionInfo] success.'); console.info('testGetNewVersionInfo2 END'); } catch(e) { @@ -223,7 +230,7 @@ describe('updateclient', function() { console.info('testGetNewVersionInfo3 START'); try { let ret = updater.getNewVersionInfo("dddddd"); - expect(ret != 0); + expect(ret != 0).assertTrue(); console.info('[getNewVersionInfo] success.'); console.info('testGetNewVersionInfo2 END'); } catch(e) { @@ -240,7 +247,7 @@ describe('updateclient', function() { console.info('testGetNewVersionInfo4 START'); try { let ret = updater.getNewVersionInfo(param_value1); - expect(ret != 0); + expect(ret != 0).assertTrue(); console.info('[getNewVersionInfo] success.'); console.info('testGetNewVersionInfo5 END'); } catch(e) { @@ -257,7 +264,7 @@ describe('updateclient', function() { console.info('testGetNewVersionInfo5 START'); try { let ret = updater.getNewVersionInfo(param_value1, param_value2); - expect(ret != 0); + expect(ret != 0).assertTrue(); console.info('[getNewVersionInfo] success.'); console.info('testGetNewVersionInfo5 END'); } catch(e) { @@ -276,7 +283,7 @@ describe('updateclient', function() { let ret = updater.getNewVersionInfo().then(data => { console.log("getNewVersionInfo success " + data); expect(data.status).assertEqual(0); // Has new version. - expect(data.checkResults.size > 0); + expect(data.checkResults.size > 0).assertTrue(); console.log(`info versionName = ` + data.checkResults[0].versionName); console.log(`info versionCode = ` + data.checkResults[0].versionCode); console.log(`info verifyInfo = ` + data.checkResults[0].verifyInfo); @@ -286,7 +293,7 @@ describe('updateclient', function() { }).catch(error => console.error("getNewVersionInfo catch " + error) ); - expect(ret != 0); + expect(ret != 0).assertTrue(); } catch(e) { console.error("getNewVersionInfo catch " + e); } @@ -307,7 +314,7 @@ describe('updateclient', function() { }).catch(error => console.error("getNewVersionInfo catch " + error) ); - expect(ret != 0); + expect(ret != 0).assertTrue(); } catch(e) { console.error("getNewVersionInfo catch " + e); } @@ -327,7 +334,7 @@ describe('updateclient', function() { }).catch(error => console.error("getNewVersionInfo catch " + error) ); - expect(ret != 0); + expect(ret != 0).assertTrue(); } catch(e) { console.error("getNewVersionInfo catch " + e); } @@ -347,7 +354,7 @@ describe('updateclient', function() { }).catch(error => console.error("getNewVersionInfo catch " + error) ); - expect(ret != 0); + expect(ret != 0).assertTrue(); } catch(e) { console.error("getNewVersionInfo catch " + e); } @@ -367,7 +374,7 @@ describe('updateclient', function() { }).catch(error => console.error("getNewVersionInfo error " + error) ); - expect(ret != 0); + expect(ret != 0).assertTrue(); } catch(e) { console.error("getNewVersionInfo catch " + e); } @@ -386,7 +393,7 @@ describe('updateclient', function() { let ret = updater.checkNewVersion(function(err, data){ console.log("checkNewVersion success" + data); expect(data.status).assertEqual(0); // Has new version. - expect(data.checkResults.size > 0); + expect(data.checkResults.size > 0).assertTrue(); console.log(`info versionName = ` + data.checkResults[0].versionName); console.log(`info versionCode = ` + data.checkResults[0].versionCode); console.log(`info verifyInfo = ` + data.checkResults[0].verifyInfo); @@ -397,7 +404,7 @@ describe('updateclient', function() { error => { console.log("checkNewVersion error" + error) }); - expect(ret != 0); + expect(ret).assertInstanceOf('Number'); } catch(e) { console.error("checkNewVersion catch " + e); } @@ -414,7 +421,7 @@ describe('updateclient', function() { console.info('testCheckNewVersion2 START'); try { let ret = updater.checkNewVersion(); - expect(ret != 0); + expect(ret != 0).assertTrue(); console.info('[checkNewVersion] success.' + ret); console.info('testCheckNewVersion2 END'); } catch(e) { @@ -431,7 +438,7 @@ describe('updateclient', function() { console.info('testCheckNewVersion3 START'); try { let ret = updater.checkNewVersion("33333"); - expect(ret != 0); + expect(ret != 0).assertTrue(); console.info('[checkNewVersion] success.' + ret); console.info('testCheckNewVersion3 END'); } catch(e) { @@ -448,7 +455,7 @@ describe('updateclient', function() { console.info('testCheckNewVersion4 START'); try { let ret = updater.checkNewVersion(param_value1); - expect(ret != 0); + expect(ret != 0).assertTrue(); console.info('[checkNewVersion] success.' + ret); console.info('testCheckNewVersion4 END'); } catch(e) { @@ -465,7 +472,7 @@ describe('updateclient', function() { console.info('testCheckNewVersion4 START'); try { let ret = updater.checkNewVersion(param_value1, param_value2); - expect(ret != 0); + expect(ret != 0).assertTrue(); console.info('[checkNewVersion] success.' + ret); console.info('testCheckNewVersion5 END'); } catch(e) { @@ -484,7 +491,7 @@ describe('updateclient', function() { let ret = updater.checkNewVersion().then(data => { console.log("checkNewVersion success" + data); expect(data.status).assertEqual(0); - expect(data.checkResults.size > 0); + expect(data.checkResults.size > 0).assertTrue(); console.log(`info versionName = ` + data.checkResults[0].versionName); console.log(`info versionCode = ` + data.checkResults[0].versionCode); console.log(`info verifyInfo = ` + data.checkResults[0].verifyInfo); @@ -494,7 +501,7 @@ describe('updateclient', function() { }).catch(error => console.error("checkNewVersion error " + error) ); - expect(ret != 0); + expect(ret != 0).assertTrue(); } catch(e) { console.error("checkNewVersion catch " + e) } @@ -514,7 +521,7 @@ describe('updateclient', function() { }).catch(error => console.error("checkNewVersion error " + error) ); - expect(ret != 0); + expect(ret != 0).assertTrue(); } catch(e) { console.error("checkNewVersion catch " + e); } @@ -534,7 +541,7 @@ describe('updateclient', function() { }).catch(error => console.error("checkNewVersion error " + error) ); - expect(ret != 0); + expect(ret != 0).assertTrue(); } catch(e) { console.error("checkNewVersion catch " + e); } @@ -554,7 +561,7 @@ describe('updateclient', function() { }).catch(error => console.error("checkNewVersion error " + error) ); - expect(ret != 0); + expect(ret != 0).assertTrue(); } catch(e) { console.error("checkNewVersion catch " + e); } @@ -574,7 +581,7 @@ describe('updateclient', function() { }).catch(error => console.error("checkNewVersion error " + error) ); - expect(ret != 0); + expect(ret != 0).assertTrue(); } catch(e) { console.error("checkNewVersion catch " + e); } @@ -602,7 +609,7 @@ describe('updateclient', function() { console.log("setUpdatePolicy success" + data); expect(data).assertEqual(0); }); - expect(ret != 0); + expect(ret).assertInstanceOf('Number'); } catch(e) { console.error('[testSetUpdatePolicy001] fail.' + e); } @@ -613,7 +620,7 @@ describe('updateclient', function() { /** * @tc.number SUB_UPDATE_JS_API_0027 * @tc.name testGetUpdatePolicy001 - * @tc.desc . + * @tc.desc Test get update, policy func 001. */ it('testGetUpdatePolicy001', 0, function() { console.info('testGetUpdatePolicy001 START'); @@ -627,7 +634,7 @@ describe('updateclient', function() { expect(data.autoUpgradeInterval[1]).assertEqual(3); }); - expect(ret != 0); + expect(ret).assertInstanceOf('Number'); } catch(e) { console.error('[testGetUpdatePolicy001] fail.' + e); } @@ -654,7 +661,7 @@ describe('updateclient', function() { console.log("setUpdatePolicy success" + data); expect(data).assertEqual(0); }); - expect(ret != 0); + expect(ret).assertInstanceOf('Number'); } catch(e) { console.error('[testSetUpdatePolicy002] fail.' + e); } @@ -679,7 +686,7 @@ describe('updateclient', function() { expect(data.autoUpgradeInterval[0]).assertEqual(2); expect(data.autoUpgradeInterval[1]).assertEqual(3); }); - expect(ret != 0); + expect(ret).assertInstanceOf('Number'); } catch(e) { console.error('[testGetUpdatePolicy002] fail.' + e); } @@ -708,7 +715,7 @@ describe('updateclient', function() { console.log("setUpdatePolicy success" + data); expect(data).assertEqual(0); }) - expect(ret != 0); + expect(ret).assertInstanceOf('Number'); } catch(e) { console.error('[testSetUpdatePolicy003] fail.' + e); } @@ -732,7 +739,7 @@ describe('updateclient', function() { expect(data.autoUpgradeInterval[0]).assertEqual(2); expect(data.autoUpgradeInterval[1]).assertEqual(3); }) - expect(ret != 0); + expect(ret).assertInstanceOf('Number'); } catch(e) { console.error('[testGetUpdatePolicy003] fail.' + e); } @@ -760,7 +767,7 @@ describe('updateclient', function() { console.log("setUpdatePolicy success" + data); expect(data).assertEqual(0); }) - expect(ret != 0); + expect(ret).assertInstanceOf('Number'); } catch(e) { console.error('[testGetUpdatePolicy003] fail.' + e); } @@ -784,7 +791,7 @@ describe('updateclient', function() { expect(data.autoUpgradeInterval[0]).assertEqual(expect_value); expect(data.autoUpgradeInterval[1]).assertEqual(expect_value); }) - expect(ret != 0); + expect(ret).assertInstanceOf('Number'); } catch(e) { console.error('[testGetUpdatePolicy004] fail.' + e); } @@ -804,7 +811,7 @@ describe('updateclient', function() { console.log("setUpdatePolicy success" + data); expect(data).assertEqual(0); }); - expect(ret != 0); + expect(ret != 0).assertTrue(); } catch(e) { console.error('[testSetUpdatePolicy005] fail.' + e); } @@ -822,7 +829,7 @@ describe('updateclient', function() { try { let ret = updater.getUpdatePolicy("", function(err, data){ }) - expect(ret != 0); + expect(ret != 0).assertTrue(); } catch(e) { console.error('[testSetUpdatePolicy005] fail.' + e); } @@ -852,7 +859,7 @@ describe('updateclient', function() { }).catch(error => console.error("setUpdatePolicy error " + error) ); - expect(ret != 0); + expect(ret != 0).assertTrue(); } catch(e) { console.error('[testSetUpdatePolicyPromise] fail.' + e); } @@ -879,7 +886,7 @@ describe('updateclient', function() { }).catch(error => console.error("getUpdatePolicy catch " + error) ); - expect(ret != 0); + expect(ret != 0).assertTrue(); } catch(e) { console.error('[testGetUpdatePolicyPromise] fail.' + e); } @@ -908,7 +915,7 @@ describe('updateclient', function() { }).catch(error => console.error("setUpdatePolicy error " + error) ); - expect(ret != 0); + expect(ret != 0).assertTrue(); } catch(e) { console.error('[setUpdatePolicy] fail.' + e); } @@ -932,7 +939,7 @@ describe('updateclient', function() { expect(data.autoUpgradeInterval[0]).assertEqual(2); expect(data.autoUpgradeInterval[1]).assertEqual(3); }); - expect(ret != 0); + expect(ret != 0).assertTrue(); } catch(e) { console.error('[testGetUpdatePolicyPromise002] fail.' + e); } @@ -962,7 +969,7 @@ describe('updateclient', function() { }).catch(error => { console.info('[setUpdatePolicy] error ' + error) }) - expect(ret != 0); + expect(ret != 0).assertTrue(); } catch(e) { console.error('[testSetUpdatePolicyPromise003] fail.' + e); } @@ -988,7 +995,7 @@ describe('updateclient', function() { }).catch(error => { console.info('[getUpdatePolicy] error ' + error) }) - expect(ret != 0); + expect(ret != 0).assertTrue(); } catch(e) { console.info('[getUpdatePolicy] catch ' + e) } @@ -1018,7 +1025,7 @@ describe('updateclient', function() { }).catch(error => { console.info('[setUpdatePolicy] error ' + error) }) - expect(ret != 0); + expect(ret != 0).assertTrue(); } catch(e) { console.info('[testSetUpdatePolicyPromise004] catch ' + e) } @@ -1044,7 +1051,7 @@ describe('updateclient', function() { }).catch(error => { console.info('[getUpdatePolicy] error ' + error) }) - expect(ret != 0); + expect(ret != 0).assertTrue(); } catch(e) { console.info('[testSetUpdatePolicyPromise004] catch ' + e) } @@ -1064,7 +1071,7 @@ describe('updateclient', function() { console.log("setUpdatePolicy success" + data); expect(data).assertEqual(0); }); - expect(ret != 0); + expect(ret != 0).assertTrue(); } catch (e) { console.info('[setUpdatePolicy] catch ' + e); } @@ -1082,7 +1089,7 @@ describe('updateclient', function() { try{ let ret = updater.getUpdatePolicy(param_value1).then(data => { }) - expect(ret != 0); + expect(ret != 0).assertTrue(); } catch (e) { console.info('[setUpdatePolicy] catch ' + e); } @@ -1104,14 +1111,14 @@ describe('updateclient', function() { console.log(`downloadProgress status: ` + progress.status); console.log(`downloadProgress percent: ` + progress.percent); console.log(`downloadProgress endReason: ` + progress.endReason); - if (progress.status == updateState.UPDATE_STATE_DOWNLOAD_SUCCESS || - progress.status == updateState.UPDATE_STATE_VERIFY_SUCCESS) { + if (progress.status === updateState.UPDATE_STATE_DOWNLOAD_SUCCESS || + progress.status === updateState.UPDATE_STATE_VERIFY_SUCCESS) { expect(progress.percent).assertEqual(expect_value); updater.off("downloadProgress"); } }) let ret = updater.download(); - expect(ret != 0); + expect(ret).assertInstanceOf('Number'); } catch (e) { console.info('[testDownloadVersion] catch ' + e); } @@ -1134,15 +1141,15 @@ describe('updateclient', function() { console.log(`downloadProgress status: ` + progress.status); console.log(`downloadProgress percent: ` + progress.percent); console.log(`downloadProgress endReason: ` + progress.endReason); - if (progress.status == updateState.UPDATE_STATE_DOWNLOAD_SUCCESS || - progress.status == updateState.UPDATE_STATE_VERIFY_SUCCESS) { + if (progress.status === updateState.UPDATE_STATE_DOWNLOAD_SUCCESS || + progress.status === updateState.UPDATE_STATE_VERIFY_SUCCESS) { expect(progress.percent).assertEqual(expect_value); } }) let ret = updater.download(); // Cancel subscription immediately, no callback will be received. updater.off("downloadProgress"); - expect(ret != 0); + expect(ret).assertInstanceOf('Number'); } catch (e) { console.info('[testDownloadVersion02] catch ' + e); } @@ -1163,12 +1170,12 @@ describe('updateclient', function() { console.log(`downloadProgress status: ` + progress.status); console.log(`downloadProgress percent: ` + progress.percent); console.log(`downloadProgress endReason: ` + progress.endReason); - if (progress.status == updateState.UPDATE_STATE_DOWNLOAD_SUCCESS || - progress.status == updateState.UPDATE_STATE_VERIFY_SUCCESS) { + if (progress.status === updateState.UPDATE_STATE_DOWNLOAD_SUCCESS || + progress.status === updateState.UPDATE_STATE_VERIFY_SUCCESS) { expect(progress.percent).assertEqual(expect_value); } }) - expect(ret != 0); + expect(ret).assertInstanceOf('Number'); } catch (e) { console.info('[testDownloadVersion03] catch ' + e); } @@ -1186,12 +1193,12 @@ describe('updateclient', function() { try{ // Open download monitor. let ret = updater.on('downloadProgress'); - expect(ret != 0); + expect(ret).assertInstanceOf('Number'); let ret_download = updater.download(); - expect(ret_download != 0); + expect(ret_download).assertInstanceOf('Number'); // Cancel subscription immediately, no callback will be received. let ret_off = updater.off("downloadProgress"); - expect(ret_off != 0); + expect(ret_off).assertInstanceOf('Number'); } catch (e) { console.info('[testDownloadVersion04] catch ' + e); } @@ -1215,13 +1222,13 @@ describe('updateclient', function() { try{ // Open download monitor. let ret = updater.on('downloadProgress', testFunction); - expect(ret == 0); + expect(ret).assertInstanceOf('Number'); let ret_download = updater.download(); - expect(ret_download != 0); + expect(ret_download).assertInstanceOf('Number'); // Cancel subscription immediately, no callback will be received. let ret_off = updater.off("downloadProgress", testFunction); - expect(ret_off != 0); + expect(ret_off).assertInstanceOf('Number'); } catch (e) { console.info('[testDownloadVersion05] catch ' + e); } @@ -1244,14 +1251,14 @@ describe('updateclient', function() { console.log(`upgradeProgress status: ` + progress.status); console.log(`upgradeProgress percent: ` + progress.percent); console.log(`upgradeProgress endReason: ` + progress.endReason); - if (progress.status == updateState.UPDATE_STATE_DOWNLOAD_SUCCESS || - progress.status == updateState.UPDATE_STATE_VERIFY_SUCCESS) { + if (progress.status === updateState.UPDATE_STATE_DOWNLOAD_SUCCESS || + progress.status === updateState.UPDATE_STATE_VERIFY_SUCCESS) { expect(progress.percent).assertEqual(expect_value); updater.off("upgradeProgress"); } }) let ret = updater.upgrade(); - expect(ret != 0); + expect(ret).assertInstanceOf('Number'); } catch (e) { console.info('[testUpgradeVersion01] catch ' + e); } @@ -1273,17 +1280,17 @@ describe('updateclient', function() { console.log(`upgradeProgress status: ` + progress.status); console.log(`upgradeProgress percent: ` + progress.percent); console.log(`upgradeProgress endReason: ` + progress.endReason); - if (progress.status == updateState.UPDATE_STATE_DOWNLOAD_SUCCESS || - progress.status == updateState.UPDATE_STATE_VERIFY_SUCCESS) { + if (progress.status === updateState.UPDATE_STATE_DOWNLOAD_SUCCESS || + progress.status === updateState.UPDATE_STATE_VERIFY_SUCCESS) { expect(progress.percent).assertEqual(expect_value); } }) - expect(ret_on != 0); + expect(ret_on).assertInstanceOf('Number'); let ret = updater.upgrade(); - expect(ret != 0); + expect(ret).assertInstanceOf('Number'); // Cancel subscription immediately, no callback will be received. let ret_off = updater.off("upgradeProgress"); - expect(ret_off != 0); + expect(ret_off).assertInstanceOf('Number'); } catch (e) { console.info('[testUpgradeVersion02] catch ' + e); } @@ -1304,12 +1311,12 @@ describe('updateclient', function() { console.log(`upgradeProgress status: ` + progress.status); console.log(`upgradeProgress percent: ` + progress.percent); console.log(`upgradeProgress endReason: ` + progress.endReason); - if (progress.status == updateState.UPDATE_STATE_DOWNLOAD_SUCCESS || - progress.status == updateState.UPDATE_STATE_VERIFY_SUCCESS) { + if (progress.status === updateState.UPDATE_STATE_DOWNLOAD_SUCCESS || + progress.status === updateState.UPDATE_STATE_VERIFY_SUCCESS) { expect(progress.percent).assertEqual(expect_value); } }) - expect(ret != 0); + expect(ret).assertInstanceOf('Number'); } catch (e) { console.info('[testUpgradeVersion03] catch ' + e); } @@ -1327,12 +1334,12 @@ describe('updateclient', function() { try{ // Open download monitor. let ret = updater.on('upgradeProgress'); - expect(ret != 0); + expect(ret).assertInstanceOf('Number'); let ret_upgrade = updater.upgrade(); - expect(ret_upgrade != 0); + expect(ret_upgrade).assertInstanceOf('Number'); // Cancel subscription immediately, no callback will be received. let ret_off = updater.off("upgradeProgress"); - expect(ret_off != 0); + expect(ret_off).assertInstanceOf('Number'); } catch (e) { console.info('[testUpgradeVersion04] catch ' + e); } @@ -1355,13 +1362,13 @@ describe('updateclient', function() { console.info('testUpgradeVersion05 START'); try{ let ret = updater.on('upgradeProgress', testFunction); - expect(ret == 0); + expect(ret).assertInstanceOf('Number'); let ret_upgrade = updater.upgrade(); - expect(ret_upgrade != 0); + expect(ret_upgrade).assertInstanceOf('Number'); let ret_off = updater.off("upgradeProgress", testFunction); - expect(ret_off != 0); + expect(ret_off).assertInstanceOf('Number'); } catch (e) { console.info('[testUpgradeVersion05] catch ' + e); } @@ -1378,7 +1385,7 @@ describe('updateclient', function() { console.info('testOnDownload START'); try{ let ret = updater.on(function(){}); - expect(ret != 0); + expect(ret != 0).assertTrue(); } catch (e) { console.info('[testOnDownload] catch ' + e); } @@ -1395,7 +1402,7 @@ describe('updateclient', function() { console.info('testOnDownload2 START'); try{ let ret = updater.on(); - expect(ret != 0); + expect(ret != 0).assertTrue(); } catch (e) { console.info('[testOnDownload2] catch ' + e); } @@ -1412,7 +1419,7 @@ describe('updateclient', function() { console.info('testOnDownload3 START'); try{ let ret = updater.on("333333333"); - expect(ret != 0); + expect(ret != 0).assertTrue(); } catch (e) { console.info('[testOnDownload3] catch ' + e); } @@ -1429,7 +1436,7 @@ describe('updateclient', function() { console.info('testOnDownload3 START'); try{ let ret = updater.on(param_value2); - expect(ret != 0); + expect(ret != 0).assertTrue(); } catch (e) { console.info('[testOnDownload4] catch ' + e); } @@ -1446,7 +1453,7 @@ describe('updateclient', function() { console.info('testOnDownload5 START'); try{ let ret = updater.on(param_value2, "4444444444444"); - expect(ret != 0); + expect(ret != 0).assertTrue(); } catch (e) { console.info('[testOnDownload5] catch ' + e); } @@ -1463,7 +1470,7 @@ describe('updateclient', function() { console.info('testOffDownload START'); try{ let ret = updater.off(); - expect(ret != 0); + expect(ret != 0).assertTrue(); } catch (e) { console.info('[testOffDownload] catch ' + e); } @@ -1480,7 +1487,7 @@ describe('updateclient', function() { console.info('testOffDownload2 START'); try{ let ret = updater.off("333333333"); - expect(ret != 0); + expect(ret).assertInstanceOf('Number'); } catch (e) { console.info('[testOffDownload2] catch ' + e); } @@ -1497,7 +1504,7 @@ describe('updateclient', function() { console.info('testOffDownload3 START'); try{ let ret = updater.on(param_value2); - expect(ret != 0); + expect(ret != 0).assertTrue(); } catch (e) { console.info('[testOffDownload3] catch ' + e); } @@ -1514,7 +1521,7 @@ describe('updateclient', function() { console.info('testOffDownload4 START'); try{ let ret = updater.off(param_value2, "4444444444444"); - expect(ret != 0); + expect(ret != 0).assertTrue(); } catch (e) { console.info('[testOffDownload4] catch ' + e); } @@ -1531,7 +1538,7 @@ describe('updateclient', function() { console.info('testOffDownload5 START'); try{ let ret = updater.off(function(){}); - expect(ret != 0); + expect(ret != 0).assertTrue(); } catch (e) { console.info('[testOffDownload5] catch ' + e); } @@ -1548,7 +1555,7 @@ describe('updateclient', function() { console.info('testOnUpgrade START'); try{ let ret = updater.on("upgradeProgress", function(){}); - expect(ret != 0); + expect(ret).assertInstanceOf('Number'); } catch (e) { console.info('[testOnUpgrade] catch ' + e); } @@ -1565,7 +1572,7 @@ describe('updateclient', function() { console.info('testOnUpgrade2 START'); try{ let ret = updater.on("upgradeProgress"); - expect(ret != 0); + expect(ret != 0).assertTrue(); } catch (e) { console.info('[testOnUpgrade2] catch ' + e); } @@ -1582,7 +1589,7 @@ describe('updateclient', function() { console.info('testOnUpgrade3 START'); try{ let ret = updater.on("upgradeProgress", "333333333"); - expect(ret != 0); + expect(ret != 0).assertTrue(); } catch (e) { console.info('[testOnUpgrade3] catch ' + e); } @@ -1599,7 +1606,7 @@ describe('updateclient', function() { console.info('testOnUpgrade4 START'); try{ let ret = updater.on("upgradeProgress", param_value2); - expect(ret != 0); + expect(ret != 0).assertTrue(); } catch (e) { console.info('[testOnUpgrade3] catch ' + e); } @@ -1616,7 +1623,7 @@ describe('updateclient', function() { console.info('testOnUpgrade5 START'); try{ let ret = updater.on(param_value2, "4444444444444"); - expect(ret != 0); + expect(ret != 0).assertTrue(); } catch (e) { console.info('[testOnUpgrade5] catch ' + e); } @@ -1633,7 +1640,7 @@ describe('updateclient', function() { console.info('testOffUpgrade START'); try{ let ret = updater.off("upgradeProgress"); - expect(ret != 0); + expect(ret).assertInstanceOf('Number'); } catch (e) { console.info('[testOffUpgrade] catch ' + e); } @@ -1650,7 +1657,7 @@ describe('updateclient', function() { console.info('testOffUpgrade2 START'); try{ let ret = updater.off("upgradeProgress", "333333333"); - expect(ret != 0); + expect(ret != 0).assertTrue(); } catch (e) { console.info('[testOffUpgrade] catch ' + e); } @@ -1667,7 +1674,7 @@ describe('updateclient', function() { console.info('testOffDownload3 START'); try{ let ret = updater.on("upgradeProgress", param_value2); - expect(ret != 0); + expect(ret != 0).assertTrue(); } catch (e) { console.info('[testOffUpgrade3] catch ' + e); } @@ -1684,7 +1691,7 @@ describe('updateclient', function() { console.info('testOffUpgrade4 START'); try{ let ret = updater.off("upgradeProgress", param_value2, "4444444444444"); - expect(ret != 0); + expect(ret != 0).assertTrue(); } catch (e) { console.info('[testOffUpgrade4] catch ' + e); } @@ -1701,7 +1708,7 @@ describe('updateclient', function() { console.info('testOffUpgrade5 START'); try{ let ret = updater.off("upgradeProgress", "6"); - expect(ret != 0); + expect(ret != 0).assertTrue(); } catch (e) { console.info('[testOffUpgrade5] catch ' + e); } @@ -1719,7 +1726,7 @@ describe('updateclient', function() { try{ let ret = updater.cancel(); console.info('updater.cancelUpgrade' + ret); - expect(ret == 0); + expect(ret === 0).assertTrue(); } catch (e) { console.info('[cancel] catch ' + e); } @@ -1741,18 +1748,18 @@ describe('updateclient', function() { console.log(`downloadProgress status: ` + progress.status); console.log(`downloadProgress percent: ` + progress.percent); console.log(`downloadProgress endReason: ` + progress.endReason); - if (progress.status == updateState.UPDATE_STATE_DOWNLOAD_SUCCESS || - progress.status == updateState.UPDATE_STATE_VERIFY_SUCCESS) { + if (progress.status === updateState.UPDATE_STATE_DOWNLOAD_SUCCESS || + progress.status === updateState.UPDATE_STATE_VERIFY_SUCCESS) { expect(progress.percent).assertEqual(expect_value); updater.off("downloadProgress"); } }) let ret = updater.download(); - expect(ret == 0); + expect(ret === 0).assertTrue(); ret = updater.cancel(); console.info('updater.cancel' + ret); - expect(ret == 0); + expect(ret === 0).assertTrue(); } catch (e) { console.info('[cancel] catch ' + e); } @@ -1770,7 +1777,7 @@ describe('updateclient', function() { try{ let ret = updater.cancel(); console.info('updater.cancel' + ret); - expect(ret == 0); + expect(ret === 0).assertTrue(); } catch (e) { console.info('[cancel] catch ' + e); } @@ -1788,7 +1795,7 @@ describe('updateclient', function() { try{ let ret = updater.cancel(""); console.info('updater.cancel' + ret); - expect(ret == undefined); + expect(ret === undefined).assertTrue(); } catch (e) { console.info('[cancel] catch ' + e); } @@ -1805,7 +1812,7 @@ describe('updateclient', function() { try{ let ret = updater.cancel(function(){}); console.info('updater.cancel' + ret); - expect(ret == undefined); + expect(ret === undefined).assertTrue(); } catch (e) { console.info('[cancel] catch ' + e); }