Bug 987185 - Add test for the functionality of the Sync button when user is signed into an account. r=Gijs, r=markh
authorMihaela Velimiroviciu <mihaela.velimiroviciu@softvisioninc.eu>
Fri, 03 Oct 2014 10:59:07 +0300
changeset 209052 23a0a5f3c0adcf5501deeaae2c007d32a8fbac82
parent 209051 ed38aba585834601686b6b6becc0e5350ba0ef62
child 209053 29fcac263c20f12cfed5e1549fa6abd8c4110338
push id27602
push userkwierso@gmail.com
push dateTue, 07 Oct 2014 02:30:49 +0000
treeherdermozilla-central@9ee9e193fc48 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersGijs, markh
bugs987185
milestone35.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 987185 - Add test for the functionality of the Sync button when user is signed into an account. r=Gijs, r=markh
browser/components/customizableui/test/browser.ini
browser/components/customizableui/test/browser_987185_syncButton.js
--- a/browser/components/customizableui/test/browser.ini
+++ b/browser/components/customizableui/test/browser.ini
@@ -130,16 +130,17 @@ skip-if = os == "linux"
 
 [browser_985815_propagate_setToolbarVisibility.js]
 [browser_981305_separator_insertion.js]
 [browser_988072_sidebar_events.js]
 [browser_989338_saved_placements_not_resaved.js]
 [browser_989751_subviewbutton_class.js]
 [browser_987177_destroyWidget_xul.js]
 [browser_987177_xul_wrapper_updating.js]
+[browser_987185_syncButton.js]
 [browser_987492_window_api.js]
 [browser_987640_charEncoding.js]
 [browser_992747_toggle_noncustomizable_toolbar.js]
 [browser_993322_widget_notoolbar.js]
 [browser_995164_registerArea_during_customize_mode.js]
 [browser_996364_registerArea_different_properties.js]
 [browser_996635_remove_non_widgets.js]
 [browser_1003588_no_specials_in_panel.js]
new file mode 100755
--- /dev/null
+++ b/browser/components/customizableui/test/browser_987185_syncButton.js
@@ -0,0 +1,69 @@
+/* This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ */
+"use strict";
+
+let syncService = {};
+Components.utils.import("resource://services-sync/service.js", syncService);
+
+let needsSetup;
+let originalSync;
+let service = syncService.Service;
+let syncWasCalled = false;
+
+add_task(function* testSyncButtonFunctionality() {
+  info("Check Sync button functionality");
+  storeInitialValues();
+  mockFunctions();
+
+  // add the Sync button to the panel
+  CustomizableUI.addWidgetToArea("sync-button", CustomizableUI.AREA_PANEL);
+
+  // check the button's functionality
+  yield PanelUI.show();
+  info("The panel menu was opened");
+
+  let syncButton = document.getElementById("sync-button");
+  ok(syncButton, "The Sync button was added to the Panel Menu");
+  syncButton.click();
+  info("The sync button was clicked");
+
+  yield waitForCondition(() => syncWasCalled);
+});
+
+add_task(function* asyncCleanup() {
+  // reset the panel UI to the default state
+  yield resetCustomization();
+  ok(CustomizableUI.inDefaultState, "The panel UI is in default state again.");
+
+  if (isPanelUIOpen()) {
+    let panelHidePromise = promisePanelHidden(window);
+    PanelUI.hide();
+    yield panelHidePromise;
+  }
+
+  restoreValues();
+});
+
+function mockFunctions() {
+  // mock needsSetup
+  gSyncUI._needsSetup = function() false;
+
+  // mock service.errorHandler.syncAndReportErrors()
+  service.errorHandler.syncAndReportErrors = mocked_syncAndReportErrors;
+}
+
+function mocked_syncAndReportErrors() {
+  syncWasCalled = true;
+}
+
+function restoreValues() {
+  gSyncUI._needsSetup = needsSetup;
+  service.sync = originalSync;
+}
+
+function storeInitialValues() {
+  needsSetup = gSyncUI._needsSetup;
+  originalSync = service.sync;
+}