Beispiel #1
0
class test_main(GaiaTestCase):
    def __init__(self, *args, **kwargs):
        kwargs['restart'] = True
        super(test_main, self).__init__(*args, **kwargs)

    def setUp(self):

        # Set up child objects...
        GaiaTestCase.setUp(self)
        self.UTILS = UTILS(self)
        self.contacts = Contacts(self)
        self.settings = Settings(self)

        self.gmail_user = self.UTILS.general.get_config_variable(
            "gmail_1_user", "common")
        self.gmail_passwd = self.UTILS.general.get_config_variable(
            "gmail_1_pass", "common")

        # Create test contacts.
        self.contact = MockContact()
        self.UTILS.general.insertContact(self.contact)

    def tearDown(self):
        self.UTILS.reporting.reportResults()
        GaiaTestCase.tearDown(self)

    def test_run(self):

        # Set up to use data connection.
        self.connect_to_network()

        self.contacts.launch()
        self.contacts.import_gmail_login(self.gmail_user, self.gmail_passwd)
        self.num_gmail_contacts = len(
            self.marionette.find_elements(*DOM.Contacts.import_conts_list))

        # Import them.
        self.contacts.import_all()
        self.apps.kill_all()
        self.contacts.launch()

        # Check all our contacts are in the list, both 'standard' ...
        prepopulated_contact = (
            DOM.Contacts.view_all_contact_specific_contact[0],
            DOM.Contacts.view_all_contact_specific_contact[1].format("OWD"))

        self.UTILS.element.waitForElements(prepopulated_contact,
                                           "Prepopulated Contact")

        # ... and the gmail contacts ...
        gmail_imported = (
            DOM.Contacts.view_all_contact_specific_contact[0],
            DOM.Contacts.view_all_contact_specific_contact[1].format("roy"))
        contacts = self.UTILS.element.getElements(gmail_imported,
                                                  "Gmail imported contacts")
        self.UTILS.test.test(
            len(contacts) == self.num_gmail_contacts,
            "All gmail contacts have been imported")
Beispiel #2
0
class test_main(GaiaTestCase):

    def __init__(self, *args, **kwargs):
        kwargs['restart'] = True
        super(test_main, self).__init__(*args, **kwargs)

    def setUp(self):

        # Set up child objects...
        GaiaTestCase.setUp(self)
        self.UTILS = UTILS(self)
        self.contacts = Contacts(self)
        self.settings = Settings(self)

        self.gmail_user = self.UTILS.general.get_config_variable("gmail_1_user", "common")
        self.gmail_passwd = self.UTILS.general.get_config_variable("gmail_1_pass", "common")
        self.number_of_gmail_contacts = 2

        # Create test contacts.
        self.contact = MockContact()
        self.UTILS.general.insertContact(self.contact)

    def tearDown(self):
        self.UTILS.reporting.reportResults()
        GaiaTestCase.tearDown(self)

    def test_run(self):

        # Set up to use data connection.
        self.connect_to_network()

        self.contacts.launch()
        self.contacts.import_gmail_login(self.gmail_user, self.gmail_passwd)

        # Remember all the contacts in the list.

        # Import them.
        self.contacts.import_all()
        self.apps.kill_all()
        self.contacts.launch()

        # Check all our contacts are in the list, both 'standrd' ...
    
        prepopulated_contact = (DOM.Contacts.view_all_contact_specific_contact[0],
                                DOM.Contacts.view_all_contact_specific_contact[1].format("OWD"))

        self.UTILS.element.waitForElements(prepopulated_contact, "Prepopulated Contact")

        # ... and the gmail contacts ...
        gmail_imported = (DOM.Contacts.view_all_contact_specific_contact[0],
                                DOM.Contacts.view_all_contact_specific_contact[1].format("roy"))
        contacts = self.UTILS.element.getElements(gmail_imported, "Gmail imported contacts")
        self.UTILS.test.test(len(contacts) == self.number_of_gmail_contacts, "All gmail contacts has been imported")

        x = self.UTILS.debug.screenShotOnErr()
        self.UTILS.reporting.logResult("info", "Screenshot and details", x)
Beispiel #3
0
class test_main(GaiaTestCase):

    def __init__(self, *args, **kwargs):
        kwargs['restart'] = True
        super(test_main, self).__init__(*args, **kwargs)

    def setUp(self):

        # Set up child objects...
        GaiaTestCase.setUp(self)
        self.UTILS = UTILS(self)
        self.contacts = Contacts(self)
        self.settings = Settings(self)

        self.gmail_user = self.UTILS.general.get_config_variable("gmail_1_user", "common")
        self.gmail_passwd = self.UTILS.general.get_config_variable("gmail_1_pass", "common")

        # Create test contacts.
        self.contact = MockContact()
        self.UTILS.general.insertContact(self.contact)

    def tearDown(self):
        self.UTILS.reporting.reportResults()
        GaiaTestCase.tearDown(self)

    def test_run(self):

        # Set up to use data connection.
        self.connect_to_network()

        self.contacts.launch()
        self.contacts.import_gmail_login(self.gmail_user, self.gmail_passwd)

        self.contacts.import_toggle_select_contact(1)

        self.marionette.execute_script("document.getElementById('{}').click()".format(DOM.Contacts.import_import_btn[1]))
        time.sleep(1)

        self.apps.kill_all()
        time.sleep(2)
        self.contacts.launch()

        # Check our two contacts are in the list.
        prepopulated_contact = (DOM.Contacts.view_all_contact_specific_contact[0],
                                DOM.Contacts.view_all_contact_specific_contact[1].format("OWD"))

        self.UTILS.element.waitForElements(prepopulated_contact, "Prepopulated Contact")

        gmail_imported = (DOM.Contacts.view_all_contact_specific_contact[0],
                                DOM.Contacts.view_all_contact_specific_contact[1].format("roy"))

        self.UTILS.element.waitForElements(gmail_imported, "Gmail imported contact")

        screenshot = self.UTILS.debug.screenShotOnErr()
        self.UTILS.reporting.logResult("info", "Screenshot and details", screenshot)
Beispiel #4
0
class test_main(GaiaTestCase):

    def __init__(self, *args, **kwargs):
        kwargs['restart'] = True
        super(test_main, self).__init__(*args, **kwargs)

    def setUp(self):

        # Set up child objects...
        GaiaTestCase.setUp(self)
        self.UTILS = UTILS(self)
        self.contacts = Contacts(self)

        # Create our test contacts.
        self.contact = MockContact()
        self.UTILS.general.insertContact(self.contact)

    def tearDown(self):
        self.UTILS.reporting.reportResults()
        GaiaTestCase.tearDown(self)

    def test_run(self):

        # Set up to use data connection.
        self.connect_to_network()

        # Launch contacts app.
        self.contacts.launch()

        x = self.contacts.import_gmail_login("wrongname", "wrongpass")

        self.UTILS.test.test(x == False, "Login failed.")
Beispiel #5
0
class test_main(GaiaTestCase):
    def __init__(self, *args, **kwargs):
        kwargs['restart'] = True
        super(test_main, self).__init__(*args, **kwargs)

    _gmail_pseudo_locator = ("data-url", "google")

    def setUp(self):
        GaiaTestCase.setUp(self)
        self.UTILS = UTILS(self)
        self.contacts = Contacts(self)
        self.settings = Settings(self)

        self.gmail_user = self.UTILS.general.get_config_variable(
            "gmail_1_user", "common")
        self.gmail_passwd = self.UTILS.general.get_config_variable(
            "gmail_1_pass", "common")

        self.contact = MockContact()
        self.UTILS.general.insertContact(self.contact)
        self.connect_to_network()

    def tearDown(self):
        self.UTILS.reporting.reportResults()
        GaiaTestCase.tearDown(self)

    def test_run(self):
        self.contacts.launch()
        self.contacts.import_gmail_login(self.gmail_user, self.gmail_passwd,
                                         False)

        # Cancel the login
        self.marionette.switch_to_frame()
        cancel = self.UTILS.element.getElement(
            ('xpath', '//h1[contains(text(), "Google")]/..'), "Cancel icon")
        # TODO: Change this when ShadowDOM marionette bug fixed (Bug 1061698)
        cancel.tap(25, 25)

        self.marionette.switch_to_frame()
        self.UTILS.element.waitForNotElements(("xpath", "//iframe[contains(@{}, '{}')]".\
                                    format(self._gmail_pseudo_locator[0], self._gmail_pseudo_locator[1])),
                                   "Gmail login iframe")

        self.UTILS.iframe.switchToFrame(*DOM.Contacts.frame_locator)
        self.UTILS.element.waitForElements(DOM.Contacts.import_contacts_header,
                                           "Import contacts header")
Beispiel #6
0
class test_main(GaiaTestCase):

    def __init__(self, *args, **kwargs):
        kwargs['restart'] = True
        super(test_main, self).__init__(*args, **kwargs)

    _gmail_pseudo_locator = ("data-url", "google")

    def setUp(self):
        GaiaTestCase.setUp(self)
        self.UTILS = UTILS(self)
        self.contacts = Contacts(self)
        self.settings = Settings(self)

        self.gmail_user = self.UTILS.general.get_config_variable("gmail_1_user", "common")
        self.gmail_passwd = self.UTILS.general.get_config_variable("gmail_1_pass", "common")

        self.contact = MockContact()
        self.UTILS.general.insertContact(self.contact)
        self.connect_to_network()

    def tearDown(self):
        self.UTILS.reporting.reportResults()
        GaiaTestCase.tearDown(self)

    def test_run(self):
        self.contacts.launch()
        self.contacts.import_gmail_login(self.gmail_user, self.gmail_passwd, False)

        # Cancel the login
        self.marionette.switch_to_frame()
        cancel = self.UTILS.element.getElement(('xpath', '//h1[contains(text(), "Google")]/..'), "Cancel icon")
        # TODO: Change this when ShadowDOM marionette bug fixed (Bug 1061698)
        cancel.tap(25, 25)

        self.marionette.switch_to_frame()
        self.UTILS.element.waitForNotElements(("xpath", "//iframe[contains(@{}, '{}')]".\
                                    format(self._gmail_pseudo_locator[0], self._gmail_pseudo_locator[1])),
                                   "Gmail login iframe")

        self.UTILS.iframe.switchToFrame(*DOM.Contacts.frame_locator)
        self.UTILS.element.waitForElements(DOM.Contacts.import_contacts_header, "Import contacts header")
Beispiel #7
0
class test_main(GaiaTestCase):
    def __init__(self, *args, **kwargs):
        kwargs['restart'] = True
        super(test_main, self).__init__(*args, **kwargs)

    def setUp(self):

        # Set up child objects...
        GaiaTestCase.setUp(self)
        self.UTILS = UTILS(self)
        self.contacts = Contacts(self)
        self.settings = Settings(self)

        self.gmail_user = self.UTILS.general.get_config_variable(
            "gmail_1_user", "common")
        self.gmail_passwd = self.UTILS.general.get_config_variable(
            "gmail_1_pass", "common")

        # Create test contacts.
        self.contact = MockContact()
        self.UTILS.general.insertContact(self.contact)

    def tearDown(self):
        self.UTILS.reporting.reportResults()
        GaiaTestCase.tearDown(self)

    def test_run(self):

        # Set up to use data connection.
        self.connect_to_network()

        self.contacts.launch()
        self.contacts.import_gmail_login(self.gmail_user, self.gmail_passwd)

        # Check the Import button is disabled to begin with.
        x = self.UTILS.element.getElement(DOM.Contacts.import_import_btn,
                                          "Import button")
        self.UTILS.test.test(
            x.get_attribute("disabled") == "true",
            "Import button is disabled.")

        # Tap the Select All button (can't be done with marionette yet).
        self.UTILS.reporting.logResult("info",
                                       "Tapping the 'Select All' button ...")
        self.marionette.execute_script("document.getElementById('{}').click()".\
                                       format(DOM.Contacts.import_select_all[1]))
        time.sleep(1)
        x = self.UTILS.element.getElement(DOM.Contacts.import_import_btn,
                                          "Import button")
        self.UTILS.test.test(
            x.get_attribute("disabled") != "true", "Import button is enabled.")

        self.UTILS.reporting.logResult(
            "info", "Tapping the 'Deselect All' button ...")
        self.marionette.execute_script("document.getElementById('{}').click()".\
                                       format(DOM.Contacts.import_desel_all[1]))
        time.sleep(1)
        x = self.UTILS.element.getElement(DOM.Contacts.import_import_btn,
                                          "Import button")
        self.UTILS.test.test(
            x.get_attribute("disabled") == "true",
            "Import button is disabled.")

        # Now select one contact and press Deselect all...
        self.contacts.import_toggle_select_contact(1)
        x = self.UTILS.element.getElement(DOM.Contacts.import_import_btn,
                                          "Import button")
        self.UTILS.test.test(
            x.get_attribute("disabled") != "true", "Import button is enabled.")

        self.UTILS.reporting.logResult(
            "info", "Tapping the 'Deselect All' button ...")
        self.marionette.execute_script("document.getElementById('{}').click()".\
                                       format(DOM.Contacts.import_desel_all[1]))
        time.sleep(1)
        x = self.UTILS.element.getElement(DOM.Contacts.import_import_btn,
                                          "Import button")
        self.UTILS.test.test(
            x.get_attribute("disabled") == "true",
            "Import button is disabled.")
Beispiel #8
0
class test_main(GaiaTestCase):

    def __init__(self, *args, **kwargs):
        kwargs['restart'] = True
        super(test_main, self).__init__(*args, **kwargs)

    def setUp(self):

        # Set up child objects...
        GaiaTestCase.setUp(self)
        self.UTILS = UTILS(self)
        self.contacts = Contacts(self)
        self.keyboard = Keyboard(self.marionette)

        self.gmail_user = self.UTILS.general.get_config_variable("gmail_1_user", "common")
        self.gmail_passwd = self.UTILS.general.get_config_variable("gmail_1_pass", "common")

        self.connect_to_network()

        # Create test contacts.
        self.contact = MockContact()
        self.UTILS.general.insertContact(self.contact)

    def tearDown(self):
        self.UTILS.reporting.reportResults()
        GaiaTestCase.tearDown(self)

    def test_run(self):
        self.contacts.launch()
        self.contacts.import_gmail_login(self.gmail_user, self.gmail_passwd)

        # Get the contacts.
        contact_list = self.UTILS.element.getElements(DOM.Contacts.import_conts_list, "Contact list")
        gmail_contacts = []
        for y in contact_list:
            gmail_contacts.append(y.get_attribute("data-search"))

        search_name = gmail_contacts[0][:gmail_contacts[0].index('@')]

        # Use the search bar to test ...
        self.marionette.execute_script("document.getElementById('search-start').click();")

        self.UTILS.iframe.switchToFrame(*DOM.Contacts.frame_locator)
        self.UTILS.iframe.switchToFrame(*DOM.Contacts.gmail_import_frame, via_root_frame=False)

        self.marionette.execute_script("""
        var getElementByXpath = function (path) {
            return document.evaluate(path, document, null, 9, null).singleNodeValue;
        };
        getElementByXpath("/html/body/section/section[2]/form/p/label").click();
        """)
        self.marionette.switch_to_frame()

        # Keyboard appears.
        self.UTILS.element.waitForElements(("xpath", "//iframe[contains(@{},'{}')]".\
                                    format(DOM.Keyboard.frame_locator[0], DOM.Keyboard.frame_locator[1])),
                                   "Keyboard")

        # Typing works and allows real-time filtering.
        self.UTILS.reporting.logResult("info", "Typing '{}' with the keyboard (without pressing ENTER) ...".\
                                        format(search_name))
        self.keyboard.send(search_name)

        self.UTILS.iframe.switchToFrame(*DOM.Contacts.frame_locator)
        self.UTILS.iframe.switchToFrame(*DOM.Contacts.gmail_import_frame, via_root_frame=False)
        after_search_count = self.UTILS.element.getElements(DOM.Contacts.import_search_list, "Search list")

        self.UTILS.test.test(len(after_search_count) == 1,
                        "After typing the name '{}' the search list contains 1 contact (out of {}).".\
                        format(search_name, len(gmail_contacts)))
Beispiel #9
0
class test_main(GaiaTestCase):
    def __init__(self, *args, **kwargs):
        kwargs['restart'] = True
        super(test_main, self).__init__(*args, **kwargs)

    def setUp(self):

        # Set up child objects...
        GaiaTestCase.setUp(self)
        self.UTILS = UTILS(self)
        self.contacts = Contacts(self)
        self.settings = Settings(self)

        self.gmail_user = self.UTILS.general.get_config_variable(
            "gmail_1_user", "common")
        self.gmail_passwd = self.UTILS.general.get_config_variable(
            "gmail_1_pass", "common")
        # Set up to use data connection.
        self.connect_to_network()

    def tearDown(self):
        os.system("adb shell rm sdcard/*.vcf > /dev/null 2>&1")
        self.UTILS.reporting.reportResults()
        GaiaTestCase.tearDown(self)

    def test_run(self):
        self.contacts.launch()
        self.contacts.import_gmail_login(self.gmail_user, self.gmail_passwd)

        # Log-in in Gmail and contacts imported
        x = self.UTILS.element.getElements(DOM.Contacts.import_conts_list,
                                           "Contact list", False)

        gmail_contacts = []
        for y in x:
            contact_name = y.get_attribute("data-search")
            if '#search#' not in contact_name:
                self.UTILS.reporting.logResult("info", "Adding '{}' to the list of available contacts.".\
                                               format(contact_name))
                gmail_contacts.append(contact_name)

        self.contacts.import_all()
        # Saving the number of contacts imported
        self.UTILS.element.waitForElements(("id", "statusMsg"),
                                           "x/y contact imported")
        banner = self.UTILS.element.getElement(
            DOM.Contacts.export_import_banner, "Updated x contacts")
        contacts_imported = banner.text

        # Exit contacts
        self.apps.kill_all()
        time.sleep(2)

        self.contacts.launch()
        self.contacts.export_sd_card()

        select_all_btn = self.UTILS.element.getElement(
            DOM.Contacts.action_select_all, "Select All")
        select_all_btn.tap()
        time.sleep(2)

        export_btn = self.UTILS.element.getElement(DOM.Contacts.select_action,
                                                   "Export button")
        export_btn.tap()

        # Check that there is a layer informing about the success export
        self.UTILS.element.waitForElements(("id", "statusMsg"),
                                           "x/y contact exported msg")
        banner = self.UTILS.element.getElement(
            DOM.Contacts.export_import_banner, "x/y contacts exported")
        contacts_exported = banner.text

        # Check that the number of contact imported/exported is the same
        self.UTILS.reporting.logResult(
            "info", "Contacts imported: {}".format(contacts_imported))
        self.UTILS.reporting.logResult(
            "info", "Contacts exported: {}".format(contacts_exported))
        self.UTILS.test.test(
            contacts_exported.split("/")[0] in contacts_imported,
            "OK, same contacts exported than imported")
Beispiel #10
0
class test_main(GaiaTestCase):
    def __init__(self, *args, **kwargs):
        kwargs['restart'] = True
        super(test_main, self).__init__(*args, **kwargs)

    def setUp(self):

        # Set up child objects...
        GaiaTestCase.setUp(self)
        self.UTILS = UTILS(self)
        self.contacts = Contacts(self)
        self.settings = Settings(self)

        self.gmail_user = self.UTILS.general.get_config_variable(
            "gmail_1_user", "common")
        self.gmail_passwd = self.UTILS.general.get_config_variable(
            "gmail_1_pass", "common")

        # Create test contacts.
        self.contact = MockContact()
        self.UTILS.general.insertContact(self.contact)

    def tearDown(self):
        self.UTILS.reporting.reportResults()
        GaiaTestCase.tearDown(self)

    def test_run(self):

        # Set up to use data connection.
        self.connect_to_network()

        self.contacts.launch()
        self.contacts.import_gmail_login(self.gmail_user, self.gmail_passwd)

        # Check the Import button is disabled to begin with.
        x = self.UTILS.element.getElement(DOM.Contacts.import_import_btn,
                                          "Import button")
        self.UTILS.test.test(
            x.get_attribute("disabled") == "true",
            "Import button is disabled.")
        """
        Select / de-select contacts and make sure Import button is enabled / disabled
        as expected.
        """

        self.UTILS.reporting.logResult("info", "Enable contact 1...")
        self.contacts.import_toggle_select_contact(1)

        x = self.UTILS.element.getElement(DOM.Contacts.import_import_btn,
                                          "Import button")
        self.UTILS.test.test(
            x.get_attribute("disabled") != "true", "Import button is enabled.")

        self.UTILS.reporting.logResult("info", "Enable contact 2...")
        self.contacts.import_toggle_select_contact(2)

        x = self.UTILS.element.getElement(DOM.Contacts.import_import_btn,
                                          "Import button")
        self.UTILS.test.test(
            x.get_attribute("disabled") != "true", "Import button is enabled.")

        self.UTILS.reporting.logResult("info", "Disable contact 2...")
        self.contacts.import_toggle_select_contact(2)

        x = self.UTILS.element.getElement(DOM.Contacts.import_import_btn,
                                          "Import button")
        self.UTILS.test.test(
            x.get_attribute("disabled") != "true", "Import button is enabled.")

        self.UTILS.reporting.logResult("info", "Disable contact 1...")
        self.contacts.import_toggle_select_contact(1)

        x = self.UTILS.element.getElement(DOM.Contacts.import_import_btn,
                                          "Import button")
        self.UTILS.test.test(
            x.get_attribute("disabled") == "true",
            "Import button is disabled.")

        x = self.UTILS.debug.screenShotOnErr()
        self.UTILS.reporting.logResult("info", "Screenshot and details", x)
Beispiel #11
0
class test_main(GaiaTestCase):

    def __init__(self, *args, **kwargs):
        kwargs['restart'] = True
        super(test_main, self).__init__(*args, **kwargs)

    def setUp(self):

        # Set up child objects...
        GaiaTestCase.setUp(self)
        self.UTILS = UTILS(self)
        self.contacts = Contacts(self)
        self.settings = Settings(self)

        self.gmail_user = self.UTILS.general.get_config_variable("gmail_1_user", "common")
        self.gmail_passwd = self.UTILS.general.get_config_variable("gmail_1_pass", "common")

        self.connect_to_network()
        # Create test contacts.
        self.contact = MockContact()
        self.UTILS.general.insertContact(self.contact)

    def tearDown(self):
        self.UTILS.reporting.reportResults()
        GaiaTestCase.tearDown(self)

    def test_run(self):
        self.contacts.launch()
        self.contacts.import_gmail_login(self.gmail_user, self.gmail_passwd)

        # Check the Import button is disabled to begin with.
        x = self.UTILS.element.getElement(DOM.Contacts.import_import_btn, "Import button")
        self.UTILS.test.test(x.get_attribute("disabled") == "true", "Import button is disabled.")

        # Tap the Select All button (can't be done with marionette yet).
        self.UTILS.element.waitForElements(DOM.Contacts.import_select_all, "Select_all button")
        self.UTILS.reporting.logResult("info", "Tapping the 'Select All' button ...")
        self.marionette.execute_script("document.getElementById('{}').click()".\
                                       format(DOM.Contacts.import_select_all[1]))
        time.sleep(1)

        x = self.UTILS.debug.screenShotOnErr()
        self.UTILS.reporting.logResult("info", "Screenshot and details", x)

        x = self.UTILS.element.getElement(DOM.Contacts.import_import_btn, "Import button")
        self.UTILS.test.test(x.get_attribute("disabled") != "true", "Import button is enabled.")

        """
        The only way I can see to test that all contacts are selected is to toggle
        all of them and make sure the Import button is then disabled (because that
        means all of them were selected before the toggle).
        """
        x = self.UTILS.element.getElements(("class name", "block-item"), "Contacts list")
        for i in range(len(x)):
            i_num = i + 1
            self.UTILS.reporting.logResult("info", "Disable contact {} ...".format(i_num))
            self.contacts.import_toggle_select_contact(i_num)

        x = self.UTILS.element.getElement(DOM.Contacts.import_import_btn, "Import button")
        self.UTILS.test.test(x.get_attribute("disabled") == "true", "Import button is disabled.")

        x = self.UTILS.debug.screenShotOnErr()
        self.UTILS.reporting.logResult("info", "Screenshot and details", x)
Beispiel #12
0
class test_main(GaiaTestCase):
    def __init__(self, *args, **kwargs):
        kwargs['restart'] = True
        super(test_main, self).__init__(*args, **kwargs)

    def setUp(self):

        # Set up child objects...
        GaiaTestCase.setUp(self)
        self.UTILS = UTILS(self)
        self.contacts = Contacts(self)
        self.keyboard = Keyboard(self.marionette)

        self.gmail_user = self.UTILS.general.get_config_variable(
            "gmail_1_user", "common")
        self.gmail_passwd = self.UTILS.general.get_config_variable(
            "gmail_1_pass", "common")

        self.connect_to_network()

        # Create test contacts.
        self.contact = MockContact()
        self.UTILS.general.insertContact(self.contact)

    def tearDown(self):
        self.UTILS.reporting.reportResults()
        GaiaTestCase.tearDown(self)

    def test_run(self):
        self.contacts.launch()
        self.contacts.import_gmail_login(self.gmail_user, self.gmail_passwd)

        # Get the contacts.
        contact_list = self.UTILS.element.getElements(
            DOM.Contacts.import_conts_list, "Contact list")
        gmail_contacts = []
        for y in contact_list:
            gmail_contacts.append(y.get_attribute("data-search"))

        search_name = gmail_contacts[0][:gmail_contacts[0].index('@')]

        # Use the search bar to test ...
        self.marionette.execute_script(
            "document.getElementById('search-start').click();")

        self.UTILS.iframe.switchToFrame(*DOM.Contacts.frame_locator)
        self.UTILS.iframe.switchToFrame(*DOM.Contacts.gmail_import_frame,
                                        via_root_frame=False)

        self.marionette.execute_script("""
        var getElementByXpath = function (path) {
            return document.evaluate(path, document, null, 9, null).singleNodeValue;
        };
        getElementByXpath("/html/body/section/section[2]/form/p/label").click();
        """)
        self.marionette.switch_to_frame()

        # Keyboard appears.
        self.UTILS.element.waitForElements(("xpath", "//iframe[contains(@{},'{}')]".\
                                    format(DOM.Keyboard.frame_locator[0], DOM.Keyboard.frame_locator[1])),
                                   "Keyboard")

        # Typing works and allows real-time filtering.
        self.UTILS.reporting.logResult("info", "Typing '{}' with the keyboard (without pressing ENTER) ...".\
                                        format(search_name))
        self.keyboard.send(search_name)

        self.UTILS.iframe.switchToFrame(*DOM.Contacts.frame_locator)
        self.UTILS.iframe.switchToFrame(*DOM.Contacts.gmail_import_frame,
                                        via_root_frame=False)
        after_search_count = self.UTILS.element.getElements(
            DOM.Contacts.import_search_list, "Search list")

        self.UTILS.test.test(len(after_search_count) == 1,
                        "After typing the name '{}' the search list contains 1 contact (out of {}).".\
                        format(search_name, len(gmail_contacts)))
Beispiel #13
0
class test_main(GaiaTestCase):
    def __init__(self, *args, **kwargs):
        kwargs['restart'] = True
        super(test_main, self).__init__(*args, **kwargs)

    def setUp(self):
        GaiaTestCase.setUp(self)
        self.UTILS = UTILS(self)
        self.contacts = Contacts(self)
        self.settings = Settings(self)

        self.gmail_user = self.UTILS.general.get_config_variable(
            "gmail_1_user", "common")
        self.gmail_passwd = self.UTILS.general.get_config_variable(
            "gmail_1_pass", "common")

        # Create test contacts.
        self.contact_list = [MockContact() for i in range(2)]
        self.contact_list[1]['email'] = {}
        map(self.UTILS.general.insertContact, self.contact_list)
        # Set up to use data connection.
        self.connect_to_network()

    def tearDown(self):
        self.UTILS.reporting.reportResults()
        GaiaTestCase.tearDown(self)

    def test_run(self):
        self.contacts.launch()
        self.contacts.import_gmail_login(self.gmail_user, self.gmail_passwd)
        contact_list = self.UTILS.element.getElements(
            DOM.Contacts.import_conts_list, "Contact list", False)

        gmail_contacts = []
        for c in contact_list:
            contact_name = c.get_attribute("data-search")
            if '#search#' not in contact_name:
                self.UTILS.reporting.logResult(
                    "info",
                    "Adding '{}' to the list of available contacts.".format(
                        contact_name))
                gmail_contacts.append(contact_name)

        self.contacts.import_all()

        self.apps.kill_all()
        self.contacts.launch()
        self.UTILS.reporting.logResult(
            "info", "Viewing contact '{}' ...".format(gmail_contacts[0]))
        self.contacts.view_contact("*****@*****.**", False)

        edit_btn = self.UTILS.element.getElement(
            DOM.Contacts.edit_details_button, "Edit details button")
        edit_btn.tap()
        self.UTILS.element.waitForElements(DOM.Contacts.edit_contact_header,
                                           "'Edit contacts' screen header")

        # Enter the new contact details.
        contact_fields = self.contacts.get_contact_fields()
        self.contacts.replace_str(contact_fields['givenName'],
                                  self.contact_list[1]["givenName"])
        self.contacts.replace_str(contact_fields['familyName'],
                                  self.contact_list[1]["familyName"])
        self.contacts.replace_str(contact_fields['tel'],
                                  self.contact_list[1]["tel"]["value"])
        self.contacts.replace_str(
            contact_fields['street'],
            self.contact_list[1]["addr"]["streetAddress"])
        self.contacts.replace_str(contact_fields['zip'],
                                  self.contact_list[1]["addr"]["postalCode"])
        self.contacts.replace_str(contact_fields['city'],
                                  self.contact_list[1]["addr"]["locality"])
        self.contacts.replace_str(contact_fields['country'],
                                  self.contact_list[1]["addr"]["countryName"])

        # Save the changes
        update_btn = self.UTILS.element.getElement(
            DOM.Contacts.edit_update_button, "Edit 'update' button")
        update_btn.tap()
        time.sleep(2)
Beispiel #14
0
class test_main(GaiaTestCase):

    def __init__(self, *args, **kwargs):
        kwargs['restart'] = True
        super(test_main, self).__init__(*args, **kwargs)

    def setUp(self):

        # Set up child objects...
        GaiaTestCase.setUp(self)
        self.UTILS = UTILS(self)
        self.contacts = Contacts(self)
        self.settings = Settings(self)

        self.gmail_user = self.UTILS.general.get_config_variable("gmail_1_user", "common")
        self.gmail_passwd = self.UTILS.general.get_config_variable("gmail_1_pass", "common")
        # Set up to use data connection.
        self.connect_to_network()

    def tearDown(self):
        os.system("adb shell rm sdcard/*.vcf > /dev/null 2>&1")
        self.UTILS.reporting.reportResults()
        GaiaTestCase.tearDown(self)

    def test_run(self):
        self.contacts.launch()
        self.contacts.import_gmail_login(self.gmail_user, self.gmail_passwd)

        # Log-in in Gmail and contacts imported
        x = self.UTILS.element.getElements(DOM.Contacts.import_conts_list, "Contact list", False)

        gmail_contacts = []
        for y in x:
            contact_name = y.get_attribute("data-search")
            if '#search#' not in contact_name:
                self.UTILS.reporting.logResult("info", "Adding '{}' to the list of available contacts.".\
                                               format(contact_name))
                gmail_contacts.append(contact_name)

        self.contacts.import_all()
        # Saving the number of contacts imported
        self.UTILS.element.waitForElements(("id", "statusMsg"), "x/y contact imported")
        banner = self.UTILS.element.getElement(DOM.Contacts.export_import_banner, "Updated x contacts")
        contacts_imported = banner.text

        # Exit contacts
        self.apps.kill_all()
        time.sleep(2)

        self.contacts.launch()
        self.contacts.export_sd_card()

        select_all_btn = self.UTILS.element.getElement(DOM.Contacts.action_select_all, "Select All")
        select_all_btn.tap()
        time.sleep(2)

        export_btn = self.UTILS.element.getElement(DOM.Contacts.select_action, "Export button")
        export_btn.tap()

        # Check that there is a layer informing about the success export
        self.UTILS.element.waitForElements(("id", "statusMsg"), "x/y contact exported msg")
        banner = self.UTILS.element.getElement(DOM.Contacts.export_import_banner, "x/y contacts exported")
        contacts_exported = banner.text

        # Check that the number of contact imported/exported is the same
        self.UTILS.reporting.logResult("info", "Contacts imported: {}".format(contacts_imported))
        self.UTILS.reporting.logResult("info", "Contacts exported: {}".format(contacts_exported))
        self.UTILS.test.test(contacts_exported.split("/")[0] in contacts_imported, "OK, same contacts exported than imported")
Beispiel #15
0
class test_main(GaiaTestCase):

    def __init__(self, *args, **kwargs):
        kwargs['restart'] = True
        super(test_main, self).__init__(*args, **kwargs)

    def setUp(self):

        # Set up child objects...
        GaiaTestCase.setUp(self)
        self.UTILS = UTILS(self)
        self.contacts = Contacts(self)
        self.settings = Settings(self)

        self.gmail_user = self.UTILS.general.get_config_variable("gmail_1_user", "common")
        self.gmail_passwd = self.UTILS.general.get_config_variable("gmail_1_pass", "common")

        # Create test contacts.
        self.contact = MockContact()
        self.UTILS.general.insertContact(self.contact)

    def tearDown(self):
        self.UTILS.reporting.reportResults()
        GaiaTestCase.tearDown(self)

    def test_run(self):

        # Set up to use data connection.
        self.connect_to_network()

        self.contacts.launch()
        self.contacts.import_gmail_login(self.gmail_user, self.gmail_passwd)

        # Check the Import button is disabled to begin with.
        x = self.UTILS.element.getElement(DOM.Contacts.import_import_btn, "Import button")
        self.UTILS.test.test(x.get_attribute("disabled") == "true", "Import button is disabled.")

        # Tap the Select All button (can't be done with marionette yet).
        self.UTILS.reporting.logResult("info", "Tapping the 'Select All' button ...")
        self.marionette.execute_script("document.getElementById('{}').click()".\
                                       format(DOM.Contacts.import_select_all[1]))
        time.sleep(1)
        x = self.UTILS.element.getElement(DOM.Contacts.import_import_btn, "Import button")
        self.UTILS.test.test(x.get_attribute("disabled") != "true", "Import button is enabled.")

        self.UTILS.reporting.logResult("info", "Tapping the 'Deselect All' button ...")
        self.marionette.execute_script("document.getElementById('{}').click()".\
                                       format(DOM.Contacts.import_desel_all[1]))
        time.sleep(1)
        x = self.UTILS.element.getElement(DOM.Contacts.import_import_btn, "Import button")
        self.UTILS.test.test(x.get_attribute("disabled") == "true", "Import button is disabled.")

        # Now select one contact and press Deselect all...
        self.contacts.import_toggle_select_contact(1)
        x = self.UTILS.element.getElement(DOM.Contacts.import_import_btn, "Import button")
        self.UTILS.test.test(x.get_attribute("disabled") != "true", "Import button is enabled.")

        self.UTILS.reporting.logResult("info", "Tapping the 'Deselect All' button ...")
        self.marionette.execute_script("document.getElementById('{}').click()".\
                                       format(DOM.Contacts.import_desel_all[1]))
        time.sleep(1)
        x = self.UTILS.element.getElement(DOM.Contacts.import_import_btn, "Import button")
        self.UTILS.test.test(x.get_attribute("disabled") == "true", "Import button is disabled.")
Beispiel #16
0
class test_main(GaiaTestCase):
    def __init__(self, *args, **kwargs):
        kwargs['restart'] = True
        super(test_main, self).__init__(*args, **kwargs)

    def setUp(self):

        # Set up child objects...
        GaiaTestCase.setUp(self)
        self.UTILS = UTILS(self)
        self.contacts = Contacts(self)
        self.settings = Settings(self)

        self.gmail_user = self.UTILS.general.get_config_variable(
            "gmail_1_user", "common")
        self.gmail_passwd = self.UTILS.general.get_config_variable(
            "gmail_1_pass", "common")

        # Create test contacts.
        self.contact = MockContact()
        self.UTILS.general.insertContact(self.contact)

    def tearDown(self):
        self.UTILS.reporting.reportResults()
        GaiaTestCase.tearDown(self)

    def test_run(self):

        # Set up to use data connection.
        self.connect_to_network()

        self.contacts.launch()
        self.contacts.import_gmail_login(self.gmail_user, self.gmail_passwd)

        self.contacts.import_toggle_select_contact(1)

        self.marionette.execute_script(
            "document.getElementById('{}').click()".format(
                DOM.Contacts.import_import_btn[1]))
        time.sleep(1)

        self.apps.kill_all()
        time.sleep(2)
        self.contacts.launch()

        # Check our two contacts are in the list.
        prepopulated_contact = (
            DOM.Contacts.view_all_contact_specific_contact[0],
            DOM.Contacts.view_all_contact_specific_contact[1].format("OWD"))

        self.UTILS.element.waitForElements(prepopulated_contact,
                                           "Prepopulated Contact")

        gmail_imported = (
            DOM.Contacts.view_all_contact_specific_contact[0],
            DOM.Contacts.view_all_contact_specific_contact[1].format("roy"))

        self.UTILS.element.waitForElements(gmail_imported,
                                           "Gmail imported contact")

        screenshot = self.UTILS.debug.screenShotOnErr()
        self.UTILS.reporting.logResult("info", "Screenshot and details",
                                       screenshot)
Beispiel #17
0
class test_main(GaiaTestCase):

    def __init__(self, *args, **kwargs):
        kwargs['restart'] = True
        super(test_main, self).__init__(*args, **kwargs)

    def setUp(self):

        # Set up child objects...
        GaiaTestCase.setUp(self)
        self.UTILS = UTILS(self)
        self.contacts = Contacts(self)
        self.settings = Settings(self)

        self.gmail_user = self.UTILS.general.get_config_variable("gmail_1_user", "common")
        self.gmail_passwd = self.UTILS.general.get_config_variable("gmail_1_pass", "common")

        # Create test contacts.
        self.contact = MockContact()
        self.UTILS.general.insertContact(self.contact)

    def tearDown(self):
        self.UTILS.reporting.reportResults()
        GaiaTestCase.tearDown(self)

    def test_run(self):

        # Set up to use data connection.
        self.connect_to_network()

        self.contacts.launch()
        self.contacts.import_gmail_login(self.gmail_user, self.gmail_passwd)

        # Check the Import button is disabled to begin with.
        x = self.UTILS.element.getElement(DOM.Contacts.import_import_btn, "Import button")
        self.UTILS.test.test(x.get_attribute("disabled") == "true", "Import button is disabled.")
        """
        Select / de-select contacts and make sure Import button is enabled / disabled
        as expected.
        """

        self.UTILS.reporting.logResult("info", "Enable contact 1...")
        self.contacts.import_toggle_select_contact(1)

        x = self.UTILS.element.getElement(DOM.Contacts.import_import_btn, "Import button")
        self.UTILS.test.test(x.get_attribute("disabled") != "true", "Import button is enabled.")

        self.UTILS.reporting.logResult("info", "Enable contact 2...")
        self.contacts.import_toggle_select_contact(2)

        x = self.UTILS.element.getElement(DOM.Contacts.import_import_btn, "Import button")
        self.UTILS.test.test(x.get_attribute("disabled") != "true", "Import button is enabled.")

        self.UTILS.reporting.logResult("info", "Disable contact 2...")
        self.contacts.import_toggle_select_contact(2)

        x = self.UTILS.element.getElement(DOM.Contacts.import_import_btn, "Import button")
        self.UTILS.test.test(x.get_attribute("disabled") != "true", "Import button is enabled.")

        self.UTILS.reporting.logResult("info", "Disable contact 1...")
        self.contacts.import_toggle_select_contact(1)

        x = self.UTILS.element.getElement(DOM.Contacts.import_import_btn, "Import button")
        self.UTILS.test.test(x.get_attribute("disabled") == "true", "Import button is disabled.")

        x = self.UTILS.debug.screenShotOnErr()
        self.UTILS.reporting.logResult("info", "Screenshot and details", x)