michael@0: /* This Source Code Form is subject to the terms of the Mozilla Public michael@0: * License, v. 2.0. If a copy of the MPL was not distributed with this michael@0: * file, You can obtain one at http://mozilla.org/MPL/2.0/. michael@0: */ michael@0: michael@0: function run_test() { michael@0: setupTestCommon(); michael@0: michael@0: logTestInfo("testing addition of a successful update to " + FILE_UPDATES_DB + michael@0: " and verification of update properties including the format " + michael@0: "prior to bug 530872"); michael@0: michael@0: setUpdateChannel("test_channel"); michael@0: michael@0: var patch, patches, update, updates; michael@0: // XXXrstrong - not specifying a detailsURL will cause a leak due to bug 470244 michael@0: // and until bug 470244 is fixed this will not test the value for detailsURL michael@0: // when it isn't specified in the update xml. michael@0: patches = getLocalPatchString("partial", "http://partial/", "SHA256", "cd43", michael@0: "86", "true", STATE_PENDING); michael@0: updates = getLocalUpdateString(patches, "major", "New", "version 4", "4.0", michael@0: "4.0", "20070811053724", "http://details1/", michael@0: "http://billboard1/", "http://license1/", michael@0: "http://service1/", "1238441300314", michael@0: "test status text", "false", "test_channel", michael@0: "true", "true", "true", "345600", "true", michael@0: "test version", "3.0", "3.0", michael@0: "custom1_attr=\"custom1 value\"", michael@0: "custom2_attr=\"custom2 value\""); michael@0: michael@0: writeUpdatesToXMLFile(getLocalUpdatesXMLString(updates), true); michael@0: writeStatusFile(STATE_SUCCEEDED); michael@0: michael@0: patches = getLocalPatchString("complete", "http://complete/", "SHA1", "6232", michael@0: "75", "true", STATE_FAILED); michael@0: updates = getLocalUpdateString(patches, "major", "Existing", null, null, michael@0: "3.0", null, "http://details2/", null, null, michael@0: "http://service2/", null, michael@0: getString("patchApplyFailure"), "true", michael@0: "test_channel", "false", null, null, "691200", michael@0: null, "version 3", "3.0", null, michael@0: "custom3_attr=\"custom3 value\"", michael@0: "custom4_attr=\"custom4 value\""); michael@0: writeUpdatesToXMLFile(getLocalUpdatesXMLString(updates), false); michael@0: michael@0: standardInit(); michael@0: michael@0: do_check_eq(gUpdateManager.activeUpdate, null); michael@0: do_check_eq(gUpdateManager.updateCount, 2); michael@0: michael@0: update = gUpdateManager.getUpdateAt(0).QueryInterface(AUS_Ci.nsIPropertyBag); michael@0: do_check_eq(update.state, STATE_SUCCEEDED); michael@0: do_check_eq(update.type, "major"); michael@0: do_check_eq(update.name, "New"); michael@0: do_check_eq(update.displayVersion, "version 4"); michael@0: do_check_eq(update.appVersion, "4.0"); michael@0: do_check_eq(update.platformVersion, "4.0"); michael@0: do_check_eq(update.buildID, "20070811053724"); michael@0: do_check_eq(update.detailsURL, "http://details1/"); michael@0: do_check_eq(update.billboardURL, "http://billboard1/"); michael@0: do_check_eq(update.licenseURL, "http://license1/"); michael@0: do_check_eq(update.serviceURL, "http://service1/"); michael@0: do_check_eq(update.installDate, "1238441300314"); michael@0: // statusText is updated michael@0: do_check_eq(update.statusText, getString("installSuccess")); michael@0: do_check_false(update.isCompleteUpdate); michael@0: do_check_eq(update.channel, "test_channel"); michael@0: do_check_true(update.showPrompt); michael@0: do_check_true(update.showNeverForVersion); michael@0: do_check_eq(update.promptWaitTime, "345600"); michael@0: do_check_eq(update.previousAppVersion, "3.0"); michael@0: // Custom attributes michael@0: do_check_eq(update.getProperty("custom1_attr"), "custom1 value"); michael@0: do_check_eq(update.getProperty("custom2_attr"), "custom2 value"); michael@0: michael@0: patch = update.selectedPatch; michael@0: do_check_eq(patch.type, "partial"); michael@0: do_check_eq(patch.URL, "http://partial/"); michael@0: do_check_eq(patch.hashFunction, "SHA256"); michael@0: do_check_eq(patch.hashValue, "cd43"); michael@0: do_check_eq(patch.size, "86"); michael@0: do_check_true(patch.selected); michael@0: do_check_eq(patch.state, STATE_SUCCEEDED); michael@0: michael@0: update = gUpdateManager.getUpdateAt(1).QueryInterface(AUS_Ci.nsIPropertyBag); michael@0: do_check_eq(update.state, STATE_FAILED); michael@0: do_check_eq(update.name, "Existing"); michael@0: do_check_eq(update.type, "major"); michael@0: do_check_eq(update.displayVersion, "version 3"); michael@0: do_check_eq(update.appVersion, "3.0"); michael@0: do_check_eq(update.platformVersion, "3.0"); michael@0: do_check_eq(update.detailsURL, "http://details2/"); michael@0: do_check_eq(update.billboardURL, "http://details2/"); michael@0: do_check_eq(update.licenseURL, null); michael@0: do_check_eq(update.serviceURL, "http://service2/"); michael@0: do_check_eq(update.installDate, "1238441400314"); michael@0: do_check_eq(update.statusText, getString("patchApplyFailure")); michael@0: do_check_eq(update.buildID, "20080811053724"); michael@0: do_check_true(update.isCompleteUpdate); michael@0: do_check_eq(update.channel, "test_channel"); michael@0: do_check_true(update.showPrompt); michael@0: do_check_true(update.showNeverForVersion); michael@0: do_check_eq(update.promptWaitTime, "691200"); michael@0: do_check_eq(update.previousAppVersion, null); michael@0: // Custom attributes michael@0: do_check_eq(update.getProperty("custom3_attr"), "custom3 value"); michael@0: do_check_eq(update.getProperty("custom4_attr"), "custom4 value"); michael@0: michael@0: patch = update.selectedPatch; michael@0: do_check_eq(patch.type, "complete"); michael@0: do_check_eq(patch.URL, "http://complete/"); michael@0: do_check_eq(patch.hashFunction, "SHA1"); michael@0: do_check_eq(patch.hashValue, "6232"); michael@0: do_check_eq(patch.size, "75"); michael@0: do_check_true(patch.selected); michael@0: do_check_eq(patch.state, STATE_FAILED); michael@0: michael@0: removeUpdateDirsAndFiles(); michael@0: michael@0: // XXXrstrong - not specifying a detailsURL will cause a leak due to bug 470244 michael@0: // and until this is fixed this will not test the value for detailsURL when it michael@0: // isn't specified in the update xml. michael@0: patches = getLocalPatchString(null, null, null, null, null, null, michael@0: STATE_PENDING); michael@0: updates = getLocalUpdateString(patches, "major", "New", null, null, "4.0", michael@0: null, "http://details/", "http://billboard/", michael@0: "http://license/", "http://service/", michael@0: "1238441400314", "test status text", null, michael@0: "test_channel", "true", "true", "true", "100", michael@0: "true", "version 4.0", "4.0", "3.0"); michael@0: michael@0: writeUpdatesToXMLFile(getLocalUpdatesXMLString(updates), true); michael@0: writeStatusFile(STATE_SUCCEEDED); michael@0: michael@0: patches = getLocalPatchString(null, null, null, null, null, null, michael@0: STATE_FAILED); michael@0: updates = getLocalUpdateString(patches, "major", "Existing", "version 3.0", michael@0: "3.0", "3.0", null, "http://details/", null, michael@0: null, "http://service/", null, michael@0: getString("patchApplyFailure"), null, michael@0: "test_channel", "false", null, null, "200", michael@0: null, "version 3", null, null); michael@0: writeUpdatesToXMLFile(getLocalUpdatesXMLString(updates), false); michael@0: michael@0: reloadUpdateManagerData(); michael@0: initUpdateServiceStub(); michael@0: michael@0: do_check_eq(gUpdateManager.activeUpdate, null); michael@0: do_check_eq(gUpdateManager.updateCount, 2); michael@0: michael@0: update = gUpdateManager.getUpdateAt(0); michael@0: do_check_eq(update.state, STATE_SUCCEEDED); michael@0: do_check_eq(update.type, "major"); michael@0: do_check_eq(update.name, "New"); michael@0: do_check_eq(update.displayVersion, "version 4.0"); michael@0: do_check_eq(update.appVersion, "4.0"); michael@0: do_check_eq(update.platformVersion, "4.0"); michael@0: do_check_eq(update.detailsURL, "http://details/"); michael@0: do_check_eq(update.billboardURL, "http://billboard/"); michael@0: do_check_eq(update.licenseURL, "http://license/"); michael@0: do_check_eq(update.serviceURL, "http://service/"); michael@0: do_check_eq(update.installDate, "1238441400314"); michael@0: do_check_eq(update.statusText, getString("installSuccess")); michael@0: do_check_eq(update.buildID, "20080811053724"); michael@0: do_check_true(update.isCompleteUpdate); michael@0: do_check_eq(update.channel, "test_channel"); michael@0: do_check_true(update.showPrompt); michael@0: do_check_true(update.showNeverForVersion); michael@0: do_check_eq(update.promptWaitTime, "100"); michael@0: do_check_eq(update.previousAppVersion, "3.0"); michael@0: michael@0: patch = update.selectedPatch; michael@0: do_check_eq(patch.type, "complete"); michael@0: do_check_eq(patch.URL, URL_HOST + "/" + FILE_SIMPLE_MAR); michael@0: do_check_eq(patch.hashFunction, "MD5"); michael@0: do_check_eq(patch.hashValue, MD5_HASH_SIMPLE_MAR); michael@0: do_check_eq(patch.size, SIZE_SIMPLE_MAR); michael@0: do_check_true(patch.selected); michael@0: do_check_eq(patch.state, STATE_SUCCEEDED); michael@0: michael@0: update = gUpdateManager.getUpdateAt(1); michael@0: do_check_eq(update.state, STATE_FAILED); michael@0: do_check_eq(update.name, "Existing"); michael@0: do_check_eq(update.type, "major"); michael@0: do_check_eq(update.displayVersion, "version 3.0"); michael@0: do_check_eq(update.appVersion, "3.0"); michael@0: do_check_eq(update.platformVersion, "3.0"); michael@0: do_check_eq(update.detailsURL, "http://details/"); michael@0: do_check_eq(update.billboardURL, null); michael@0: do_check_eq(update.licenseURL, null); michael@0: do_check_eq(update.serviceURL, "http://service/"); michael@0: do_check_eq(update.installDate, "1238441400314"); michael@0: do_check_eq(update.statusText, getString("patchApplyFailure")); michael@0: do_check_eq(update.buildID, "20080811053724"); michael@0: do_check_true(update.isCompleteUpdate); michael@0: do_check_eq(update.channel, "test_channel"); michael@0: do_check_false(update.showPrompt); michael@0: do_check_false(update.showNeverForVersion); michael@0: do_check_eq(update.promptWaitTime, "200"); michael@0: do_check_eq(update.previousAppVersion, null); michael@0: michael@0: patch = update.selectedPatch; michael@0: do_check_eq(patch.type, "complete"); michael@0: do_check_eq(patch.URL, URL_HOST + "/" + FILE_SIMPLE_MAR); michael@0: do_check_eq(patch.hashFunction, "MD5"); michael@0: do_check_eq(patch.hashValue, MD5_HASH_SIMPLE_MAR); michael@0: do_check_eq(patch.size, SIZE_SIMPLE_MAR); michael@0: do_check_true(patch.selected); michael@0: do_check_eq(patch.state, STATE_FAILED); michael@0: michael@0: doTestFinish(); michael@0: }