Tests - Switching channels is broken when an update is already downloading or downloaded - Bug 652016 - When switching channels, I get a failed update. r=mossop
authorRobert Strong <robert.bugzilla@gmail.com>
Wed, 18 May 2011 11:29:18 -0700
changeset 69672 062dccbd56740b4906d627277a00cef8e42b30d4
parent 69671 195b5dc114c53a4feac0fdf3178017f612149011
child 69673 962fee06b08e70e421776e357bd9f4d6a0ab48fd
push idunknown
push userunknown
push dateunknown
reviewersmossop
bugs652016
milestone6.0a1
Tests - Switching channels is broken when an update is already downloading or downloaded - Bug 652016 - When switching channels, I get a failed update. r=mossop
toolkit/mozapps/update/test/unit/test_0030_general.js
toolkit/mozapps/update/test/unit/test_0070_update_dir_cleanup.js
toolkit/mozapps/update/test/unit/test_0120_channelChange_complete.js
--- a/toolkit/mozapps/update/test/unit/test_0030_general.js
+++ b/toolkit/mozapps/update/test/unit/test_0030_general.js
@@ -90,22 +90,27 @@ function run_test_helper_pt1(aMsg, aExpe
   gNextRunFunc = aNextRunFunc;
   gExpectedStatusResult = aExpectedStatusResult;
   logTestInfo(aMsg, Components.stack.caller);
   gUpdateChecker.checkForUpdates(updateCheckListener, true);
 }
 
 function check_test_helper_pt1_1() {
   do_check_eq(gUpdateCount, 1);
+  let channelchange = getUpdatesDir();
+  channelchange.append("0");
+  channelchange.append(CHANNEL_CHANGE_FILE);
+  do_check_false(channelchange.exists());
   gCheckFunc = check_test_helper_pt1_2;
   var bestUpdate = gAUS.selectUpdate(gUpdates, gUpdateCount);
   var state = gAUS.downloadUpdate(bestUpdate, false);
   if (state == STATE_NONE || state == STATE_FAILED)
     do_throw("nsIApplicationUpdateService:downloadUpdate returned " + state);
   gAUS.addDownloadListener(downloadListener);
+  channelchange.create(AUS_Ci.nsIFile.FILE_TYPE, PERMS_FILE);
 }
 
 function check_test_helper_pt1_2() {
   do_check_eq(gStatusResult, gExpectedStatusResult);
   gAUS.removeDownloadListener(downloadListener);
   gNextRunFunc();
 }
 
--- a/toolkit/mozapps/update/test/unit/test_0070_update_dir_cleanup.js
+++ b/toolkit/mozapps/update/test/unit/test_0070_update_dir_cleanup.js
@@ -53,16 +53,21 @@ function run_test() {
   writeStatusFile(STATE_SUCCEEDED);
 
   var dir = getUpdatesDir();
   var log = dir.clone();
   log.append("0");
   log.append(FILE_UPDATE_LOG);
   writeFile(log, "Last Update Log");
 
+  let channelchange = dir.clone();
+  channelchange.append("0");
+  channelchange.append(CHANNEL_CHANGE_FILE);
+  channelchange.create(AUS_Ci.nsIFile.FILE_TYPE, PERMS_FILE);
+
   standardInit();
 
   logTestInfo("testing " + log.path + " shouldn't exist");
   do_check_false(log.exists());
 
   log = dir.clone();
   log.append(FILE_LAST_LOG);
   logTestInfo("testing " + log.path + " should exist");
@@ -75,14 +80,17 @@ function run_test() {
   log.append(FILE_BACKUP_LOG);
   logTestInfo("testing " + log.path + " shouldn't exist");
   do_check_false(log.exists());
 
   dir.append("0");
   logTestInfo("testing " + dir.path + " should exist (bug 512994)");
   do_check_true(dir.exists());
 
+  logTestInfo("testing " + channelchange.path + " shouldn't exist");
+  do_check_false(channelchange.exists());
+
   do_test_finished();
 }
 
 function end_test() {
   cleanUp();
 }
--- a/toolkit/mozapps/update/test/unit/test_0120_channelChange_complete.js
+++ b/toolkit/mozapps/update/test/unit/test_0120_channelChange_complete.js
@@ -242,19 +242,19 @@ function run_test() {
 
   setupUpdaterTest(MAR_COMPLETE_FILE);
 
   let updatesDir = do_get_file(TEST_ID + UPDATES_DIR_SUFFIX);
   let applyToDir = getApplyDirFile();
 
   // Check that trying to change channels for a complete update changes the
   // update channel (the channel-prefs.js file should be updated).
-  let force = updatesDir.clone();
-  force.append(CHANNEL_CHANGE_FILE);
-  force.create(AUS_Ci.nsIFile.FILE_TYPE, PERMS_FILE);
+  let channelchange = updatesDir.clone();
+  channelchange.append(CHANNEL_CHANGE_FILE);
+  channelchange.create(AUS_Ci.nsIFile.FILE_TYPE, PERMS_FILE);
 
   // For Mac OS X set the last modified time for the root directory to a date in
   // the past to test that the last modified time is updated on a successful
   // update (bug 600098).
   if (IS_MACOSX) {
     let now = Date.now();
     let yesterday = now - (1000 * 60 * 60 * 24);
     applyToDir.lastModifiedTime = yesterday;