PageRenderTime 26ms CodeModel.GetById 12ms app.highlight 9ms RepoModel.GetById 1ms app.codeStats 0ms

/toolkit/mozapps/update/test/unit/test_0063_manager.js

http://github.com/zpao/v8monkey
JavaScript | 84 lines | 33 code | 11 blank | 40 comment | 0 complexity | e49b3958788af38d272c4be284a6f426 MD5 | raw file
 1/* ***** BEGIN LICENSE BLOCK *****
 2 * Version: MPL 1.1/GPL 2.0/LGPL 2.1
 3 *
 4 * The contents of this file are subject to the Mozilla Public License Version
 5 * 1.1 (the "License"); you may not use this file except in compliance with
 6 * the License. You may obtain a copy of the License at
 7 * http://www.mozilla.org/MPL/
 8 *
 9 * Software distributed under the License is distributed on an "AS IS" basis,
10 * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
11 * for the specific language governing rights and limitations under the
12 * License.
13 *
14 * The Original Code is the Application Update Service.
15 *
16 * The Initial Developer of the Original Code is
17 * Robert Strong <robert.bugzilla@gmail.com>.
18 *
19 * Portions created by the Initial Developer are Copyright (C) 2009
20 * the Mozilla Foundation <http://www.mozilla.org/>. All Rights Reserved.
21 *
22 * Contributor(s):
23 *
24 * Alternatively, the contents of this file may be used under the terms of
25 * either the GNU General Public License Version 2 or later (the "GPL"), or
26 * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
27 * in which case the provisions of the GPL or the LGPL are applicable instead
28 * of those above. If you wish to allow use of your version of this file only
29 * under the terms of either the GPL or the LGPL, and not to allow others to
30 * use your version of this file under the terms of the MPL, indicate your
31 * decision by deleting the provisions above and replace them with the notice
32 * and other provisions required by the GPL or the LGPL. If you do not delete
33 * the provisions above, a recipient may use your version of this file under
34 * the terms of any one of the MPL, the GPL or the LGPL.
35 *
36 * ***** END LICENSE BLOCK *****
37 */
38
39/* General Update Manager Tests */
40
41function run_test() {
42  do_test_pending();
43  do_register_cleanup(end_test);
44
45  logTestInfo("testing removing an active update for a channel that is not" +
46              "valid due to switching channels (bug 486275)");
47  removeUpdateDirsAndFiles();
48  setUpdateChannel("original_channel");
49
50  var patches, update, update;
51
52  patches = getLocalPatchString(null, null, null, null, null, null,
53                                STATE_DOWNLOADING);
54  updates = getLocalUpdateString(patches, null, null, "version 1.0", "1.0");
55  writeUpdatesToXMLFile(getLocalUpdatesXMLString(updates), true);
56  writeStatusFile(STATE_DOWNLOADING);
57
58  patches = getLocalPatchString(null, null, null, null, null, null,
59                                STATE_FAILED);
60  updates = getLocalUpdateString(patches, null, "Existing", "version 3.0",
61                                 "3.0", "3.0", null, null, null, null, null,
62                                 getString("patchApplyFailure"));
63  writeUpdatesToXMLFile(getLocalUpdatesXMLString(updates), false);
64
65  standardInit();
66
67  do_check_eq(gUpdateManager.updateCount, 1);
68  update = gUpdateManager.getUpdateAt(0);
69  do_check_eq(update.name, "Existing");
70
71  do_check_eq(gUpdateManager.activeUpdate, null);
72  // Verify that the active-update.xml file has had the update from the old
73  // channel removed.
74  file = getCurrentProcessDir();
75  file.append(FILE_UPDATE_ACTIVE);
76  logTestInfo("verifying contents of " + FILE_UPDATE_ACTIVE);
77  do_check_eq(readFile(file), getLocalUpdatesXMLString(""));
78
79  do_test_finished();
80}
81
82function end_test() {
83  cleanUp();
84}