Skip to content
This repository has been archived by the owner on Nov 3, 2021. It is now read-only.

Commit

Permalink
Merge pull request #20694 from zacc/bug_1000037
Browse files Browse the repository at this point in the history
Bug 1000037 - Refactor and re-enable test_import_contacts_gmail.py
  • Loading branch information
Zac committed Jun 19, 2014
2 parents e67a8e4 + a707157 commit c9a08c7
Show file tree
Hide file tree
Showing 5 changed files with 41 additions and 26 deletions.
17 changes: 0 additions & 17 deletions tests/python/gaia-ui-tests/gaiatest/apps/contacts/app.py
Expand Up @@ -22,9 +22,6 @@ class Contacts(Base):
_select_all_button_locator = (By.CSS_SELECTOR, 'button[data-l10n-id="selectAll"]')
_export_button_locator = (By.ID, 'select-action')
_status_message_locator = (By.ID, 'statusMsg')
_select_contacts_to_import_frame_locator = (By.ID, 'fb-extensions')
_import_locator = (By.ID, 'import-action')
_first_contact_locator = (By.CSS_SELECTOR, 'li.block-item label.pack-checkbox')

# contacts
_contact_locator = (By.CSS_SELECTOR, 'li.contact-item')
Expand All @@ -42,20 +39,6 @@ def switch_to_contacts_frame(self):
Wait(self.marionette, ignored_exceptions=JavascriptException).until(
lambda m: m.execute_script('return window.wrappedJSObject.Contacts.asyncScriptsLoaded') is True)

def switch_to_select_contacts_frame(self):
self.switch_to_contacts_frame()
self.wait_for_element_displayed(*self._select_contacts_to_import_frame_locator)
select_contacts = self.marionette.find_element(*self._select_contacts_to_import_frame_locator)
self.marionette.switch_to_frame(select_contacts)

def tap_first_contact(self):
self.marionette.find_element(*self._first_contact_locator).tap()

def tap_import_button(self):
self.marionette.find_element(*self._import_locator).tap()
from gaiatest.apps.contacts.regions.settings_form import SettingsForm
return SettingsForm(self.marionette)

@property
def contacts(self):
return [self.Contact(marionette=self.marionette, element=contact)
Expand Down
@@ -0,0 +1,31 @@
# 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 marionette.by import By
from gaiatest.apps.base import Base

class ContactImportPicker(Base):

_contact_import_picker_frame_locator = (By.ID, 'fb-extensions')
_import_button_locator = (By.ID, 'import-action')

def __init__(self, marionette):
Base.__init__(self, marionette)
self.wait_for_element_displayed(*self._contact_import_picker_frame_locator)
select_contacts = self.marionette.find_element(*self._contact_import_picker_frame_locator)
self.marionette.switch_to_frame(select_contacts)

def tap_import_button(self):
self.marionette.execute_script('window.wrappedJSObject.importer.ui.importAll()', special_powers=True)
# TODO uncomment this when Bug 932804 is resolved
# self.marionette.find_element(*self._import_button_locator).tap()
self.apps.switch_to_displayed_app()
self.wait_for_element_not_displayed(*self._contact_import_picker_frame_locator)
from gaiatest.apps.contacts.regions.settings_form import SettingsForm
return SettingsForm(self.marionette)

def tap_select_all(self):
# TODO replace this with proper tap when Bug 932804 is resolved
self.marionette.execute_script('window.wrappedJSObject.importer.ui.selectAll()', special_powers=True)
self.wait_for_condition(lambda m : m.find_element(*self._import_button_locator).is_enabled())
Expand Up @@ -8,7 +8,7 @@

class GmailLogin(Base):

_gmail_sign_in_frame_locator = (By.CSS_SELECTOR, '#frame-container > iframe[data-url*="google"]')
_gmail_sign_in_frame_locator = (By.CSS_SELECTOR, '.popupWindow.active iframe[data-url*="google"]')
_email_locator = (By.ID, 'Email')
_password_locator = (By.ID, 'Passwd')
_sign_in_locator = (By.ID, 'signIn')
Expand All @@ -32,5 +32,8 @@ def tap_grant_access(self):
self.wait_for_condition(lambda m: grant_access_button.is_enabled())
self.marionette.execute_script("arguments[0].scrollIntoView(false);", [grant_access_button])
grant_access_button.tap()
from gaiatest.apps.contacts.app import Contacts
return Contacts(self.marionette)
# Go back to displayed Contacts app before waiting for the picker
self.wait_for_condition(lambda m: self.apps.displayed_app.name == 'Contacts')
self.apps.switch_to_displayed_app()
from gaiatest.apps.contacts.regions.contact_import_picker import ContactImportPicker
return ContactImportPicker(self.marionette)
Expand Up @@ -41,4 +41,3 @@ sdcard = true

[test_import_contacts_from_gmail.py]
online = true
disabled = Bug 932804 - Tapping on select all button doesn't work on Gmail or Outlook frame, before importing contacts
Expand Up @@ -37,12 +37,11 @@ def test_import_contacts_from_gmail(self):
# Login to gmail account
gmail.switch_to_gmail_login_frame()
gmail.gmail_login(email, password)
contacts_import = gmail.tap_grant_access()
contact_import_picker = gmail.tap_grant_access()

# Import first contact
contacts_import.switch_to_select_contacts_frame()
contacts_import.tap_first_contact()
contacts_settings = contacts_import.tap_import_button()
# Import all contacts
contact_import_picker.tap_select_all()
contacts_settings = contact_import_picker.tap_import_button()
contacts_settings.tap_back_from_import_contacts()
contacts_settings.tap_done()

Expand Down

0 comments on commit c9a08c7

Please sign in to comment.