1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/toolkit/content/tests/unit/test_updateChannelModule.js Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,36 @@ 1.4 +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ 1.5 +/* This Source Code Form is subject to the terms of the Mozilla Public 1.6 + * License, v. 2.0. If a copy of the MPL was not distributed with this 1.7 + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ 1.8 + 1.9 +Components.utils.import("resource://gre/modules/Preferences.jsm"); 1.10 +Components.utils.import("resource://gre/modules/UpdateChannel.jsm"); 1.11 + 1.12 +const PREF_APP_UPDATE_CHANNEL = "app.update.channel"; 1.13 +const TEST_CHANNEL = "TestChannel"; 1.14 +const PREF_PARTNER_A = "app.partner.test_partner_a"; 1.15 +const TEST_PARTNER_A = "TestPartnerA"; 1.16 +const PREF_PARTNER_B = "app.partner.test_partner_b"; 1.17 +const TEST_PARTNER_B = "TestPartnerB"; 1.18 + 1.19 +function test_get() { 1.20 + let defaultPrefs = new Preferences({ defaultBranch: true }); 1.21 + let currentChannel = defaultPrefs.get(PREF_APP_UPDATE_CHANNEL); 1.22 + 1.23 + do_check_eq(UpdateChannel.get(), currentChannel); 1.24 + do_check_eq(UpdateChannel.get(false), currentChannel); 1.25 + 1.26 + defaultPrefs.set(PREF_APP_UPDATE_CHANNEL, TEST_CHANNEL); 1.27 + do_check_eq(UpdateChannel.get(), TEST_CHANNEL); 1.28 + do_check_eq(UpdateChannel.get(false), TEST_CHANNEL); 1.29 + 1.30 + defaultPrefs.set(PREF_PARTNER_A, TEST_PARTNER_A); 1.31 + defaultPrefs.set(PREF_PARTNER_B, TEST_PARTNER_B); 1.32 + do_check_eq(UpdateChannel.get(), 1.33 + TEST_CHANNEL + "-cck-" + TEST_PARTNER_A + "-" + TEST_PARTNER_B); 1.34 + do_check_eq(UpdateChannel.get(false), TEST_CHANNEL); 1.35 +} 1.36 + 1.37 +function run_test() { 1.38 + test_get(); 1.39 +}