testing/firefox-ui/tests/puppeteer/test_update_wizard.py
author Henrik Skupin <mail@hskupin.info>
Tue, 20 Dec 2016 17:34:18 +0100
changeset 454320 a82d159dd357d3e8707e6b946d8fdd7a6e88503f
parent 449017 476845a2cafb42d02a5215fe63187c0638548edf
child 454582 2e66156585e44f973357ccc2acd4e38544a9d8a0
child 454670 f071218bd87fd28124cf061928700c0590f05ec3
permissions -rw-r--r--
Bug 1277090 - Make use of get_property() in firefox-ui tests where necessary. r=maja_zf Given that Marionette supports the get_property() method, all the calls to get_attribute() have to be audited and updated to get_property() if needed. It's necessary because get_attribute() will only retrieve attributes from now on. MozReview-Commit-ID: 8SmdNoiG8uP

# 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 import PuppeteerMixin
from firefox_puppeteer.ui.update_wizard import UpdateWizardDialog
from marionette_harness import MarionetteTestCase


class TestUpdateWizard(PuppeteerMixin, MarionetteTestCase):

    def setUp(self):
        super(TestUpdateWizard, self).setUp()

        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.puppeteer.windows.close_all([self.browser])
        finally:
            super(TestUpdateWizard, self).tearDown()

    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_property('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_property('localName'),
                             'button')

        panels = ('checking', 'downloading', 'dummy', 'error_patching', 'error',
                  'error_extra', 'finished', 'finished_background',
                  'manual_update', 'no_updates_found', 'updates_found_basic',
                  )
        for panel in panels:
            self.assertEqual(getattr(self.wizard, panel).element.get_property('localName'),
                             'wizardpage')

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

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