Skip to content
This repository has been archived by the owner on Jan 20, 2022. It is now read-only.

Commit

Permalink
Bug 1141988 - Convert update-wizard ui module to Marionette. r=chmanc…
Browse files Browse the repository at this point in the history
…hester
  • Loading branch information
whimboo committed Mar 16, 2015
1 parent 0bf41b0 commit 1173d06
Show file tree
Hide file tree
Showing 10 changed files with 713 additions and 20 deletions.
3 changes: 2 additions & 1 deletion firefox_puppeteer/docs/index.rst
Expand Up @@ -33,11 +33,12 @@ The following libraries are currently implemented. More will be added in the
future. Each library is available from an instance of the FirefoxTestCase class.

.. toctree::
ui/about/window
ui/about_window/window
ui/menu
ui/pageinfo/window
ui/tabbar
ui/toolbars
ui/update_wizard/dialog
ui/windows
api/appinfo
api/keys
Expand Down
136 changes: 136 additions & 0 deletions firefox_puppeteer/docs/ui/update_wizard/dialog.rst
@@ -0,0 +1,136 @@
Update Wizard Dialog
====================

UpdateWizardDialog
------------------

.. autoclass:: firefox_puppeteer.ui.update_wizard.dialog.UpdateWizardDialog
:members:
:inherited-members:

Wizard
------

.. autoclass:: firefox_puppeteer.ui.update_wizard.wizard.Wizard
:members:
:inherited-members:

CheckingPanel
-------------

.. autoclass:: firefox_puppeteer.ui.update_wizard.wizard.CheckingPanel
:members:
:inherited-members:

DownloadingPanel
----------------

.. autoclass:: firefox_puppeteer.ui.update_wizard.wizard.DownloadingPanel
:members:
:inherited-members:

DummyPanel
----------

.. autoclass:: firefox_puppeteer.ui.update_wizard.wizard.DummyPanel
:members:
:inherited-members:

ErrorPatchingPanel
------------------

.. autoclass:: firefox_puppeteer.ui.update_wizard.wizard.ErrorPatchingPanel
:members:
:inherited-members:

ErrorPanel
----------

.. autoclass:: firefox_puppeteer.ui.update_wizard.wizard.ErrorPanel
:members:
:inherited-members:

ErrorExtraPanel
---------------

.. autoclass:: firefox_puppeteer.ui.update_wizard.wizard.ErrorExtraPanel
:members:
:inherited-members:

FinishedPanel
-------------

.. autoclass:: firefox_puppeteer.ui.update_wizard.wizard.FinishedPanel
:members:
:inherited-members:

FinishedBackgroundPanel
-----------------------

.. autoclass:: firefox_puppeteer.ui.update_wizard.wizard.FinishedBackgroundPanel
:members:
:inherited-members:

IncompatibleCheckPanel
----------------------

.. autoclass:: firefox_puppeteer.ui.update_wizard.wizard.IncompatibleCheckPanel
:members:
:inherited-members:

IncompatibleListPanel
---------------------

.. autoclass:: firefox_puppeteer.ui.update_wizard.wizard.IncompatibleListPanel
:members:
:inherited-members:

InstalledPanel
--------------

.. autoclass:: firefox_puppeteer.ui.update_wizard.wizard.InstalledPanel
:members:
:inherited-members:

LicensePanel
------------

.. autoclass:: firefox_puppeteer.ui.update_wizard.wizard.LicensePanel
:members:
:inherited-members:

ManualUpdatePanel
-----------------

.. autoclass:: firefox_puppeteer.ui.update_wizard.wizard.ManualUpdatePanel
:members:
:inherited-members:

NoUpdatesFoundPanel
-------------------

.. autoclass:: firefox_puppeteer.ui.update_wizard.wizard.NoUpdatesFoundPanel
:members:
:inherited-members:

PluginUpdatesFoundPanel
-----------------------

.. autoclass:: firefox_puppeteer.ui.update_wizard.wizard.PluginUpdatesFoundPanel
:members:
:inherited-members:

UpdatesFoundBasicPanel
----------------------

.. autoclass:: firefox_puppeteer.ui.update_wizard.wizard.UpdatesFoundBasicPanel
:members:
:inherited-members:


UpdatesFoundBillboardPanel
--------------------------

.. autoclass:: firefox_puppeteer.ui.update_wizard.wizard.UpdatesFoundBillboardPanel
:members:
:inherited-members:
72 changes: 72 additions & 0 deletions firefox_puppeteer/tests/test_update_wizard.py
@@ -0,0 +1,72 @@
# 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/.

from firefox_puppeteer.ui.update_wizard import UpdateWizardDialog

from firefox_ui_harness.testcase import FirefoxTestCase


class TestUpdateWizard(FirefoxTestCase):

def setUp(self):
FirefoxTestCase.setUp(self)

def opener(win):
self.marionette.execute_script("""
let updatePrompt = Components.classes["@mozilla.org/updates/update-prompt;1"]
.createInstance(Components.interfaces.nsIUpdatePrompt);
updatePrompt.checkForUpdates();
""")

self.dialog = self.browser.open_window(callback=opener,
expected_window_class=UpdateWizardDialog)
self.wizard = self.dialog.wizard

def tearDown(self):
try:
self.windows.close_all([self.browser])
finally:
FirefoxTestCase.tearDown(self)

def test_basic(self):
self.assertEqual(self.dialog.window_type, 'Update:Wizard')
self.assertNotEqual(self.dialog.dtds, [])
self.assertNotEqual(self.dialog.properties, [])

def test_elements(self):
"""Test correct retrieval of elements."""
self.assertEqual(self.wizard.element.get_attribute('localName'), 'wizard')

buttons = ('cancel_button', 'extra1_button', 'extra2_button',
'finish_button', 'next_button', 'previous_button',
)
for button in buttons:
self.assertEqual(getattr(self.wizard, button).get_attribute('localName'),
'button')

panels = ('checking', 'downloading', 'dummy', 'error_patching', 'error',
'error_extra', 'finished', 'finished_background', 'incompatible_check',
'incompatible_list', 'installed', 'license', 'manual_update',
'no_updates_found', 'plugin_updates_found', 'updates_found_basic',
'updates_found_billboard',
)
for panel in panels:
self.assertEqual(getattr(self.wizard, panel).element.get_attribute('localName'),
'wizardpage')

# elements of the checking panel
self.assertEqual(self.wizard.checking.progress.get_attribute('localName'),
'progressmeter')

# elements of the downloading panel
self.assertEqual(self.wizard.downloading.progress.get_attribute('localName'),
'progressmeter')

# elements of the incompatible check panel
self.assertEqual(self.wizard.incompatible_check.progress.get_attribute('localName'),
'progressmeter')

def test_patch_info(self):
self.assertEqual(self.dialog.patch_info['download_duration'], -1)
self.assertIsNotNone(self.dialog.patch_info['channel'])
4 changes: 3 additions & 1 deletion firefox_puppeteer/ui/about_window/deck.py
Expand Up @@ -97,7 +97,9 @@ def panels(self):
let panels = [];
for (let index = 0; index < deck.children.length; index++) {
panels.push(deck.children[index].id);
if (deck.children[index].id) {
panels.push(deck.children[index].id);
}
}
return panels;
Expand Down
31 changes: 14 additions & 17 deletions firefox_puppeteer/ui/about_window/window.py
Expand Up @@ -7,8 +7,9 @@
from marionette_driver import By, Wait

from ..windows import BaseWindow
from ..update_wizard import UpdateWizardDialog
from ...api.software_update import SoftwareUpdate
from deck import Deck
from .deck import Deck


class AboutWindow(BaseWindow):
Expand Down Expand Up @@ -76,23 +77,19 @@ def download(self, wait_for_finish=True, timeout=TIMEOUT_UPDATE_DOWNLOAD):
Wait(self.marionette).until(
lambda _: self.deck.selected_panel != self.deck.download_and_install)

# If there are incompatible addons we fallback on old software update dialog for updating
# If there are incompatible addons, handle the old software update dialog
if self.deck.selected_panel == self.deck.apply_billboard:
# The rest of the code inside this method uses the update wizard which is
# not being converted yet, so raise a NotImplementedError.
raise NotImplementedError('Fallback dialog logic not yet implemented.')

# self.deck.update_button.click()
#
# The current JS code is:
#
# var wizard = updateWizard.handleUpdateWizardDialog();
# wizard.waitForWizardPage(updateWizard.WIZARD_PAGES.updatesfoundbasic);
# wizard.download();
# wizard.close();
# this._downloadDuration = wizard._downloadDuration;
#
# return;
# Clicking the update button will open the old update wizard dialog
wizard = self.browser.open_window(callback=lambda _: self.deck.update_button.click(),
expected_window_class=UpdateWizardDialog)
Wait(self.marionette).until(
lambda _: wizard.deck.selected_panel == wizard.deck.updates_found_basic)

wizard.download()
wizard.close()

self._download_duration = wizard.download_duration
return

if wait_for_finish:
start_time = datetime.now()
Expand Down
4 changes: 3 additions & 1 deletion firefox_puppeteer/ui/pageinfo/deck.py
Expand Up @@ -63,7 +63,9 @@ def panels(self):
let panels = [];
for (let index = 0; index < deck.children.length; index++) {
panels.push(deck.children[index].id);
if (deck.children[index].id) {
panels.push(deck.children[index].id);
}
}
return panels;
Expand Down
5 changes: 5 additions & 0 deletions firefox_puppeteer/ui/update_wizard/__init__.py
@@ -0,0 +1,5 @@
# 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/.

from dialog import UpdateWizardDialog

0 comments on commit 1173d06

Please sign in to comment.