class test_main(GaiaTestCase): test_msg = "Test." def setUp(self): # Set up child objects... GaiaTestCase.setUp(self) self.UTILS = UTILS(self) self.messages = Messages(self) self.contacts = Contacts(self) self.gallery = Gallery(self) # Import contact (adjust to the correct number). self.test_num = self.UTILS.general.get_config_variable("phone_number", "custom") self.cont = MockContact(tel={"type": "Mobile", "value": self.test_num}) self.UTILS.reporting.logComment("Using target telephone number " + self.cont["tel"]["value"]) def tearDown(self): self.UTILS.general.remove_files() self.UTILS.reporting.reportResults() GaiaTestCase.tearDown(self) def test_run(self): self.UTILS.general.add_file_to_device('./tests/_resources/imgd.jpg') # Launch messages app. self.messages.launch() # Create a new SMS self.messages.startNewSMS() # Insert the phone number in the To field self.messages.addNumbersInToField([self.test_num]) # Create MMS. self.messages.enterSMSMsg(self.test_msg) self.messages.create_mms_image() self.gallery.click_on_thumbnail_at_position_mms(0) # Click send and wait for the message to be received self.messages.sendSMS() send_time = self.messages.last_sent_message_timestamp() """ Open contacts app and create a contact with the same phone number used to send the MMS in the previous step """ self.contacts.launch() self.contacts.create_contact(self.cont) # Switch back to the messages app. self.UTILS.home.goHome() self.messages.launch() # Verify the thread now contains the name of the contact instead of the phone number self.UTILS.reporting.logComment("Trying to open the thread with name: " + self.cont["name"]) self.messages.openThread(self.cont["name"]) self.messages.wait_for_message(send_time)
class test_main(GaiaTestCase): def setUp(self): # Set up child objects... GaiaTestCase.setUp(self) self.UTILS = UTILS(self) self.messages = Messages(self) # Import contact (adjust the correct number). self.telNum = self.UTILS.general.get_config_variable("phone_number", "custom") self.UTILS.reporting.logComment("Using target telephone number " + self.telNum) def tearDown(self): self.UTILS.reporting.reportResults() GaiaTestCase.tearDown(self) def test_run(self): # Launch messages app. self.messages.launch() """ Send a message to create a thread (use number, not name as this avoids some blocking bugs just now). """ self.messages.create_and_send_sms([self.telNum], "Test message.") returnedSMS = self.messages.wait_for_message() # Examine the header. self.UTILS.element.headerCheck(self.telNum) # Close the thread and check we can find it again with this number. self.messages.closeThread() self.messages.openThread(self.telNum)
class test_main(GaiaTestCase): test_msg = "Test message." def setUp(self): # Set up child objects... GaiaTestCase.setUp(self) self.UTILS = UTILS(self) self.messages = Messages(self) self.contacts = Contacts(self) self.phone_number = self.UTILS.general.get_config_variable( "phone_number", "custom") def tearDown(self): self.UTILS.reporting.reportResults() GaiaTestCase.tearDown(self) def test_run(self): # Launch messages app. self.messages.launch() # Create and send a new test message. self.messages.create_and_send_sms([self.phone_number], "Test message.") x = self.messages.wait_for_message() # Tap the header to create a contact. self.messages.header_createContact() # Fill in some details. contFields = self.contacts.get_contact_fields() self.contacts.replace_str(contFields['givenName'], "Test") self.contacts.replace_str(contFields['familyName'], "Testerton") # Press the Done button. x = self.UTILS.element.getElement(DOM.Contacts.done_button, "Done button") x.tap() # Wait for contacts app to close and return to sms app. self.marionette.switch_to_frame() self.UTILS.element.waitForNotElements( ("xpath", "//iframe[contains(@src, '{}')]".format( DOM.Contacts.frame_locator[1])), "Contacts iframe") self.UTILS.iframe.switchToFrame(*DOM.Messages.frame_locator) # Verify the header is now the name, x = self.UTILS.element.getElement(DOM.Messages.message_header, "Message header") self.UTILS.test.test( x.text == "Test Testerton", "Message header has been changed to match the contact (it was '{}')." .format(x.text)) # Go back to the threads view and check the message name there too. self.messages.go_back() self.messages.openThread("Test Testerton")
class test_main(GaiaTestCase): def setUp(self): # Set up child objects... GaiaTestCase.setUp(self) self.UTILS = UTILS(self) self.messages = Messages(self) self.gallery = Gallery(self) timestamp = time.time() self.test_msgs = ["Hello world {} at {}".format(i, timestamp) for i in range(3)] # Establish which phone number to use. self.phone_number = self.UTILS.general.get_config_variable("phone_number", "custom") self.UTILS.reporting.logComment("Sending mms to telephone number " + self.phone_number) self.data_layer.delete_all_sms() self.UTILS.statusbar.clearAllStatusBarNotifs() def tearDown(self): self.UTILS.reporting.reportResults() GaiaTestCase.tearDown(self) def test_run(self): for msg in self.test_msgs: self.messages.create_and_send_mms("image", [self.phone_number], msg) self.messages.wait_for_message() self.messages.closeThread() self.messages.openThread(self.phone_number) self.messages.deleteMessagesInThisThread()
class test_main(GaiaTestCase): def setUp(self): # Set up child objects... GaiaTestCase.setUp(self) self.UTILS = UTILS(self) self.messages = Messages(self) # Import contact (adjust to the correct number). self.test_num = self.UTILS.general.get_config_variable("phone_number", "custom") self.contact1 = MockContact(givenName="Name 1", familyName="Surname 1", name="Name 1 Surname 1", tel={"type": "Mobile", "value": self.test_num}) self.UTILS.reporting.logComment("Using target telephone number " + self.contact1["tel"]["value"]) self.UTILS.general.insertContact(self.contact1) self.call_number = self.UTILS.general.get_config_variable("incoming_call_number", "common") self.data_layer.delete_all_sms() self.UTILS.statusbar.clearAllStatusBarNotifs() _ = setup_translations(self) def tearDown(self): self.UTILS.reporting.reportResults() GaiaTestCase.tearDown(self) def test_run(self): self.messages.launch() self.messages.startNewSMS() self.messages.addContactToField(self.contact1["name"]) # Insert the phone number in the To field self.messages.addNumbersInToField([self.call_number]) search_str = _("2 recipients") self.UTILS.element.headerCheck(search_str) # Enter the message. self.UTILS.reporting.logResult("info", "Enter the message.") self.messages.enterSMSMsg("Test 29911") # Send the message. self.messages.sendSMS() self.UTILS.statusbar.wait_for_notification_toaster_title(self.contact1["name"]) self.UTILS.iframe.switch_to_frame(*DOM.Messages.frame_locator) # Verify the number is shown in the header as there is no contact name self.messages.openThread(self.call_number) self.messages.checkThreadHeader(self.call_number) self.UTILS.reporting.logResult("info", "Verify the number is shown in the header as there is no contact name") # Return to main SMS page. self.messages.closeThread() # Verify the thread now contains the name of the contact instead of the phone number self.UTILS.reporting.logResult("info", "Trying to open the thread with name: " + self.contact1["name"]) self.messages.openThread(self.contact1["name"]) self.messages.checkThreadHeaderWithNameSurname(self.contact1["name"])
class test_main(GaiaTestCase): def setUp(self): # Set up child objects... GaiaTestCase.setUp(self) self.UTILS = UTILS(self) self.messages = Messages(self) self.gallery = Gallery(self) timestamp = time.time() self.test_msgs = [ "Hello world {} at {}".format(i, timestamp) for i in range(3) ] # Establish which phone number to use. self.phone_number = self.UTILS.general.get_config_variable( "phone_number", "custom") self.UTILS.reporting.logComment("Sending mms to telephone number " + self.phone_number) self.data_layer.delete_all_sms() self.UTILS.statusbar.clearAllStatusBarNotifs() def tearDown(self): self.UTILS.reporting.reportResults() GaiaTestCase.tearDown(self) def test_run(self): for msg in self.test_msgs: self.messages.create_and_send_mms("image", [self.phone_number], msg) self.messages.wait_for_message() self.messages.closeThread() self.messages.openThread(self.phone_number) self.messages.deleteMessagesInThisThread()
class test_main(GaiaTestCase): def setUp(self): # Set up child objects... GaiaTestCase.setUp(self) self.UTILS = UTILS(self) self.messages = Messages(self) self.actions = Actions(self.marionette) # Establish which phone number to use. self.phone_number = self.UTILS.general.get_config_variable("phone_number", "custom") self.incoming_sms_num = self.UTILS.general.get_config_variable("sms_platform_numbers", "common").split(',') self.UTILS.reporting.logComment("Sending sms to telephone number " + self.phone_number) self.data_layer.delete_all_sms() def tearDown(self): self.UTILS.reporting.reportResults() GaiaTestCase.tearDown(self) def test_run(self): self.UTILS.statusbar.clearAllStatusBarNotifs() # Send several messages to have something in the threads for i in range(4): sms_message = "Message {} " + "0123456789" * 5 sms_message = sms_message.format(i) self.UTILS.messages.create_incoming_sms(self.phone_number, sms_message) self.UTILS.statusbar.wait_for_notification_toaster_detail(sms_message, timeout=120) self.messages.launch() self.messages.openThread(self.incoming_sms_num[0]) self.messages.forwardMessage("sms", self.phone_number)
class test_main(GaiaTestCase): test_msg = "Test." def setUp(self): # Set up child objects... GaiaTestCase.setUp(self) self.UTILS = UTILS(self) self.messages = Messages(self) self.contacts = Contacts(self) # Import contact (adjust to the correct number). self.test_num = self.UTILS.general.get_config_variable( "phone_number", "custom") self.cont = MockContact(tel={"type": "Mobile", "value": self.test_num}) self.UTILS.reporting.logComment("Using target telephone number " + self.cont["tel"]["value"]) self.data_layer.delete_all_sms() def tearDown(self): self.UTILS.reporting.reportResults() GaiaTestCase.tearDown(self) def test_run(self): # Launch messages app. self.messages.launch() # Create a new SMS self.messages.startNewSMS() # Insert the phone number in the To field self.messages.addNumbersInToField([self.test_num]) # Create SMS. self.messages.enterSMSMsg(self.test_msg) # Click send and wait for the message to be received self.messages.sendSMS() self.messages.wait_for_message() self.messages.go_back() """ Open contacts app and create a contact with the same phone number used to send the SMS in the previous step """ self.contacts.launch() self.contacts.create_contact(self.cont) # Switch back to the messages app. # self.UTILS.app.switchToApp("Messages") self.messages.launch() # Verify the thread now contains the name of the contact instead of the phone number self.UTILS.reporting.logComment( "Trying to open the thread with name: " + self.cont["name"]) self.messages.openThread(self.cont["name"])
class test_main(GaiaTestCase): test_msgs = ["First message", "Second message", "Third message"] def setUp(self): # Set up child objects... GaiaTestCase.setUp(self) self.UTILS = UTILS(self) self.messages = Messages(self) # Establish which phone number to use. self.phone_number = self.UTILS.general.get_config_variable( "phone_number", "custom") self.UTILS.reporting.logComment("Sending sms to telephone number " + self.phone_number) self.data_layer.delete_all_sms() def tearDown(self): self.UTILS.reporting.reportResults() GaiaTestCase.tearDown(self) def test_run(self): self.UTILS.statusbar.clearAllStatusBarNotifs() """ Launch messages app & delete all Threads Make sure we have no threads """ self.messages.launch() time.sleep(2) for i in range(3): self.UTILS.reporting.debug("** Sending [{}]".format( self.test_msgs[i])) self.data_layer.send_sms(self.phone_number, self.test_msgs[i]) self.UTILS.statusbar.wait_for_notification_toaster_detail( self.test_msgs[i], timeout=120) self.UTILS.reporting.debug("** Opening thread to check messages") self.UTILS.iframe.switchToFrame(*DOM.Messages.frame_locator) self.messages.openThread(self.phone_number) # Check how many elements are there original_count = self.messages.countMessagesInThisThread() self.UTILS.reporting.logResult("info", "Before deletion there were {} messages in this thread.".\ format(original_count)) # Select the messages to be deleted. self.messages.deleteMessagesInThisThread([1]) # Check message isn't there anymore. msg_list = self.UTILS.element.getElements(DOM.Messages.message_list, "Messages") final_count = len(msg_list) real_count = original_count - 1 self.UTILS.test.test(final_count == (original_count - 1), "After deleting the message, there were {} messages in this thread ({}) found).".\ format(real_count, final_count))
class test_main(GaiaTestCase): links = ["www.google.com", "www.hotmail.com", "www.wikipedia.org"] test_msg = "Test " + " ".join(links) + " this." def setUp(self): # Set up child objects... GaiaTestCase.setUp(self) self.UTILS = UTILS(self) self.messages = Messages(self) self.browser = Browser(self) # Establish which phone number to use. self.phone_number = self.UTILS.general.get_config_variable( "phone_number", "custom") self.UTILS.reporting.logComment("Sending sms to telephone number " + self.phone_number) def tearDown(self): self.UTILS.reporting.reportResults() GaiaTestCase.tearDown(self) def test_run(self): self.connect_to_network() # Create and send a new test message. self.data_layer.send_sms(self.phone_number, self.test_msg) self.UTILS.statusbar.wait_for_notification_toaster_detail( self.test_msg, timeout=120) map(self.try_link, range(len(self.links)), self.links) def try_link(self, link_number, link): self.UTILS.reporting.logResult("info", "Tapping <b>{}</b> ...".format(link)) # Switch to messaging app. self.messages.launch() self.messages.openThread(self.phone_number) time.sleep(1) # Get last message. msg = self.messages.last_message_in_this_thread() # Find all URLs l = msg.find_element("xpath", "//a[text()='{}']".format(link)) # Tap on required link. self.UTILS.element.simulateClick(l) self.marionette.switch_to_frame() self.browser.wait_for_page_to_load() self.UTILS.test.test( link in self.browser.loaded_url(), "Web page loaded #{} correctly.".format(link_number + 1))
class test_main(GaiaTestCase): test_msg = "Test message." def setUp(self): GaiaTestCase.setUp(self) self.UTILS = UTILS(self) self.messages = Messages(self) self.contacts = Contacts(self) self.phone_number = self.UTILS.general.get_config_variable("phone_number", "custom") self.contact = MockContact() self.UTILS.general.insertContact(self.contact) def tearDown(self): self.UTILS.reporting.reportResults() GaiaTestCase.tearDown(self) def test_run(self): # Launch messages app. self.messages.launch() # Create and send a new test message. self.messages.create_and_send_sms([self.phone_number], "Test message.") self.messages.wait_for_message() # Tap the header to create a contact. self.messages.header_addToContact() # Select our contact. self.contacts.view_contact(self.contact["givenName"], False) # Check the phone number. second_phone = self.UTILS.element.getElement(("id", "number_1"), "2nd phone number.") self.UTILS.test.test(second_phone.get_attribute("value") == self.phone_number, "Contact now has a 2nd number which is '{}' (it was '{}').".format(self.phone_number, second_phone.get_attribute("value"))) # Press the Done button. done_btn = self.UTILS.element.getElement(DOM.Contacts.edit_update_button, "Update button") done_btn.tap() # Wait for contacts app to close and return to sms app. self.marionette.switch_to_frame() self.UTILS.element.waitForNotElements(("xpath", "//iframe[contains(@src, '{}')]".format(DOM.Contacts.frame_locator[1])), "Contacts iframe") self.UTILS.iframe.switchToFrame(*DOM.Messages.frame_locator) # Verify the header is now the name, header = self.UTILS.element.getElement(DOM.Messages.message_header, "Message header") self.UTILS.test.test(header.text == self.contact["name"], "Message header has been changed to match the contact (it was '{}').".format(header.text)) # Go back to the threads view and check the message name there too. self.messages.go_back() self.messages.openThread(self.contact["name"])
class test_main(GaiaTestCase): test_msgs = ["First message", "Second message", "Third message"] def setUp(self): # Set up child objects... GaiaTestCase.setUp(self) self.UTILS = UTILS(self) self.messages = Messages(self) # Establish which phone number to use. self.phone_number = self.UTILS.general.get_config_variable("phone_number", "custom") self.UTILS.reporting.logComment("Sending sms to telephone number " + self.phone_number) self.data_layer.delete_all_sms() def tearDown(self): self.UTILS.reporting.reportResults() GaiaTestCase.tearDown(self) def test_run(self): """ Launch messages app & delete all Threads Make sure we have no threads """ self.messages.launch() for i in range(3): self.UTILS.reporting.debug("** Sending [{}]".format(self.test_msgs[i])) self.data_layer.send_sms(self.phone_number, self.test_msgs[i]) self.UTILS.statusbar.wait_for_notification_toaster_detail(self.test_msgs[i], timeout=120) self.UTILS.iframe.switchToFrame(*DOM.Messages.frame_locator) self.messages.openThread(self.phone_number) # Go into edit mode.. edit_btn = self.UTILS.element.getElement(DOM.Messages.edit_messages_icon, "Edit button") edit_btn.tap() select_btn = self.UTILS.element.getElement(DOM.Messages.edit_msgs_select_btn, "Select messages button") select_btn.tap() # Select all select_all_btn = self.UTILS.element.getElement(DOM.Messages.check_all_messages_btn, "Select all button") select_all_btn.tap() # Tap delete self.messages.deleteSelectedMessages() # Check conversation isn't there anymore. self.UTILS.element.waitForNotElements(("xpath", DOM.Messages.thread_selector_xpath.format(self.phone_number)), "Thread") time.sleep(1) fnam = self.UTILS.debug.screenShotOnErr() self.UTILS.reporting.logResult("info", "Screenshot of final position:", fnam)
class test_main(GaiaTestCase): test_msg = "Test." def setUp(self): # Set up child objects... GaiaTestCase.setUp(self) self.UTILS = UTILS(self) self.messages = Messages(self) self.contacts = Contacts(self) # Import contact (adjust to the correct number). self.test_num = self.UTILS.general.get_config_variable("phone_number", "custom") self.cont = MockContact(tel={"type": "Mobile", "value": self.test_num}) self.UTILS.reporting.logComment("Using target telephone number " + self.cont["tel"]["value"]) self.data_layer.delete_all_sms() def tearDown(self): self.UTILS.reporting.reportResults() GaiaTestCase.tearDown(self) def test_run(self): # Launch messages app. self.messages.launch() # Create a new SMS self.messages.startNewSMS() # Insert the phone number in the To field self.messages.addNumbersInToField([self.test_num]) # Create SMS. self.messages.enterSMSMsg(self.test_msg) # Click send and wait for the message to be received self.messages.sendSMS() self.messages.wait_for_message() self.messages.go_back() """ Open contacts app and create a contact with the same phone number used to send the SMS in the previous step """ self.contacts.launch() self.contacts.create_contact(self.cont) # Switch back to the messages app. # self.UTILS.app.switchToApp("Messages") self.messages.launch() # Verify the thread now contains the name of the contact instead of the phone number self.UTILS.reporting.logComment("Trying to open the thread with name: " + self.cont["name"]) self.messages.openThread(self.cont["name"])
class test_main(GaiaTestCase): test_msg = "Test message." def setUp(self): # Set up child objects... GaiaTestCase.setUp(self) self.UTILS = UTILS(self) self.messages = Messages(self) self.contacts = Contacts(self) self.phone_number = self.UTILS.general.get_config_variable("phone_number", "custom") def tearDown(self): self.UTILS.reporting.reportResults() GaiaTestCase.tearDown(self) def test_run(self): # Launch messages app. self.messages.launch() # Create and send a new test message. self.messages.create_and_send_sms([self.phone_number], "Test message.") x = self.messages.wait_for_message() # Tap the header to create a contact. self.messages.header_createContact() # Fill in some details. contFields = self.contacts.get_contact_fields() self.contacts.replace_str(contFields['givenName'], "Test") self.contacts.replace_str(contFields['familyName'], "Testerton") # Press the Done button. x = self.UTILS.element.getElement(DOM.Contacts.done_button, "Done button") x.tap() # Wait for contacts app to close and return to sms app. self.marionette.switch_to_frame() self.UTILS.element.waitForNotElements(("xpath", "//iframe[contains(@src, '{}')]".format(DOM.Contacts.frame_locator[1])), "Contacts iframe") self.UTILS.iframe.switchToFrame(*DOM.Messages.frame_locator) # Verify the header is now the name, x = self.UTILS.element.getElement(DOM.Messages.message_header, "Message header") self.UTILS.test.test(x.text == "Test Testerton", "Message header has been changed to match the contact (it was '{}').".format(x.text)) # Go back to the threads view and check the message name there too. self.messages.go_back() self.messages.openThread("Test Testerton")
class test_main(GaiaTestCase): def setUp(self): # Set up child objects... GaiaTestCase.setUp(self) self.UTILS = UTILS(self) self.messages = Messages(self) self.target_num = self.UTILS.general.get_config_variable("phone_number", "custom") self.test_msg = "Test." self.data_layer.delete_all_sms() def tearDown(self): self.UTILS.reporting.reportResults() self.UTILS.statusbar.toggleViaStatusBar('airplane') def test_run(self): # Create a new SMS self.messages.launch() self.messages.startNewSMS() # Insert the phone number in the To field self.messages.addNumbersInToField([self.target_num]) # Create SMS. self.messages.enterSMSMsg(self.test_msg) # Click send. self.messages.sendSMS() send_time = self.messages.last_sent_message_timestamp() # Wait for the SMS to arrive. self.messages.wait_for_message(send_time=send_time) self.UTILS.home.goHome() # Put the phone into airplane mode. self.UTILS.statusbar.toggleViaStatusBar('airplane') self.UTILS.reporting.debug("*** Launching messages again!!!") self.messages.launch() # Open sms app and go to the previous thread self.messages.openThread(self.target_num) # Create another SMS. self.messages.enterSMSMsg(self.test_msg) # Click send. self.messages.sendSMS() # Check that popup appears. self.messages.checkAirplaneModeWarning()
class test_main(GaiaTestCase): def setUp(self): # Set up child objects... GaiaTestCase.setUp(self) self.UTILS = UTILS(self) self.messages = Messages(self) self.target_num = self.UTILS.general.get_config_variable( "phone_number", "custom") self.test_msg = "Test." self.data_layer.delete_all_sms() def tearDown(self): self.UTILS.reporting.reportResults() self.UTILS.statusbar.toggleViaStatusBar('airplane') def test_run(self): # Create a new SMS self.messages.launch() self.messages.startNewSMS() # Insert the phone number in the To field self.messages.addNumbersInToField([self.target_num]) # Create SMS. self.messages.enterSMSMsg(self.test_msg) # Click send. self.messages.sendSMS() send_time = self.messages.last_sent_message_timestamp() # Wait for the SMS to arrive. self.messages.wait_for_message(send_time=send_time) self.UTILS.home.goHome() # Put the phone into airplane mode. self.UTILS.statusbar.toggleViaStatusBar('airplane') self.UTILS.reporting.debug("*** Launching messages again!!!") self.messages.launch() # Open sms app and go to the previous thread self.messages.openThread(self.target_num) # Create another SMS. self.messages.enterSMSMsg(self.test_msg) # Click send. self.messages.sendSMS() # Check that popup appears. self.messages.checkAirplaneModeWarning()
class test_main(GaiaTestCase): test_msgs = ["First message", "Second message", "Third message"] def setUp(self): # Set up child objects... GaiaTestCase.setUp(self) self.UTILS = UTILS(self) self.messages = Messages(self) # Establish which phone number to use. self.phone_number = self.UTILS.general.get_config_variable("phone_number", "custom") self.UTILS.reporting.logComment("Sending sms to telephone number " + self.phone_number) self.data_layer.delete_all_sms() def tearDown(self): self.UTILS.reporting.reportResults() GaiaTestCase.tearDown(self) def test_run(self): self.UTILS.statusbar.clearAllStatusBarNotifs() """ Launch messages app & delete all Threads Make sure we have no threads """ self.messages.launch() time.sleep(2) for i in range(3): self.UTILS.reporting.debug("** Sending [{}]".format(self.test_msgs[i])) self.data_layer.send_sms(self.phone_number, self.test_msgs[i]) self.UTILS.statusbar.wait_for_notification_toaster_detail(self.test_msgs[i], timeout=120) self.UTILS.reporting.debug("** Opening thread to check messages") self.UTILS.iframe.switchToFrame(*DOM.Messages.frame_locator) self.messages.openThread(self.phone_number) # Check how many elements are there original_count = self.messages.countMessagesInThisThread() self.UTILS.reporting.logResult("info", "Before deletion there were {} messages in this thread.".\ format(original_count)) # Select the messages to be deleted. self.messages.deleteMessagesInThisThread([1]) # Check message isn't there anymore. msg_list = self.UTILS.element.getElements(DOM.Messages.message_list, "Messages") final_count = len(msg_list) real_count = original_count - 1 self.UTILS.test.test(final_count == (original_count - 1), "After deleting the message, there were {} messages in this thread ({}) found).".\ format(real_count, final_count))
class test_main(GaiaTestCase): def setUp(self): # Set up child objects... GaiaTestCase.setUp(self) self.UTILS = UTILS(self) self.messages = Messages(self) # Import contact (adjust the correct number). self.phone_number = self.UTILS.general.get_config_variable("phone_number", "custom") self.data_layer.delete_all_sms() def tearDown(self): self.UTILS.reporting.reportResults() GaiaTestCase.tearDown(self) def test_run(self): # Send some messages to create a thread self.texts = ["Test 1", "Test 2", "Test 3"] self.directions = ["outgoing", "incoming"] self.create_test_sms(self.phone_number, self.texts) # Launch messages app. self.messages.launch() # Enter the thread. self.messages.openThread(self.phone_number) # Find the first message. time.sleep(2) msg_list = self.UTILS.element.getElements(DOM.Messages.message_list, "Message list", False) msgs = [(text, direction) for text in self.texts for direction in self.directions] for (msg, expected) in zip(msg_list, msgs): direction = "outgoing" if "outgoing" in msg.get_attribute("class") else "incoming" text = self.marionette.find_element(*DOM.Messages.last_message_text_nested, id=msg.id).text self.UTILS.test.test(text == expected[0], "**** Text: {} Expected: {}".format(text, expected[0])) self.UTILS.test.test(direction == expected[1], "Direction: {} Expected: {}".\ format(direction, expected[1])) # Tap the message area. x = self.UTILS.element.getElement(DOM.Messages.input_message_area, "Message area") x.tap() # Check the keyboard is now present. self.UTILS.iframe.switchToFrame(*DOM.Keyboard.frame_locator) def create_test_sms(self, number, msg_list): """Send messages in the list to populate a thread. """ for msg in msg_list: self.data_layer.send_sms(number, msg) self.UTILS.statusbar.wait_for_notification_toaster_detail(msg, timeout=120)
class test_main(GaiaTestCase): links = ["www.google.com", "www.hotmail.com", "www.wikipedia.org"] test_msg = "Test " + " ".join(links) + " this." def setUp(self): # Set up child objects... GaiaTestCase.setUp(self) self.UTILS = UTILS(self) self.messages = Messages(self) self.browser = Browser(self) # Establish which phone number to use. self.phone_number = self.UTILS.general.get_config_variable("phone_number", "custom") self.UTILS.reporting.logComment("Sending sms to telephone number " + self.phone_number) def tearDown(self): self.UTILS.reporting.reportResults() GaiaTestCase.tearDown(self) def test_run(self): self.connect_to_network() # Create and send a new test message. self.data_layer.send_sms(self.phone_number, self.test_msg) self.UTILS.statusbar.wait_for_notification_toaster_detail(self.test_msg, timeout=120) map(self.try_link, range(len(self.links)), self.links) def try_link(self, link_number, link): self.UTILS.reporting.logResult("info", "Tapping <b>{}</b> ...".format(link)) # Switch to messaging app. self.messages.launch() self.messages.openThread(self.phone_number) time.sleep(1) # Get last message. msg = self.messages.last_message_in_this_thread() # Find all URLs l = msg.find_element("xpath", "//a[text()='{}']".format(link)) # Tap on required link. self.UTILS.element.simulateClick(l) self.marionette.switch_to_frame() self.browser.wait_for_page_to_load() self.UTILS.test.test( link in self.browser.loaded_url(), "Web page loaded #{} correctly.".format(link_number + 1))
class test_main(GaiaTestCase): def setUp(self): # Set up child objects... GaiaTestCase.setUp(self) self.UTILS = UTILS(self) self.messages = Messages(self) self.gallery = Gallery(self) self.test_msg1 = "Hello World 1" self.test_msg2 = "Hello World 2" # Establish which phone number to use. self.phone_number = self.UTILS.general.get_config_variable( "phone_number", "custom") self.UTILS.reporting.logComment("Sending mms to telephone number " + self.phone_number) self.data_layer.delete_all_sms() def tearDown(self): self.UTILS.reporting.reportResults() GaiaTestCase.tearDown(self) def test_run(self): self.UTILS.statusbar.clearAllStatusBarNotifs() self.create_test_msgs([self.test_msg1, self.test_msg2]) self.messages.openThread(self.phone_number) import time time.sleep(5) self.messages.deleteMessagesInThisThread([0]) time.sleep(5) # After deleting one message, check there are three messages left msg_list = self.UTILS.element.getElements(DOM.Messages.message_list, "Remaining messages") self.UTILS.test.test( len(msg_list) == 3, "There are {} messages left (expected {})".format( len(msg_list), 3)) def create_test_msgs(self, msgs): for msg in msgs: # Create and Send a MMS. self.messages.create_and_send_mms("image", [self.phone_number], msg) self.messages.wait_for_message() self.messages.closeThread()
class test_main(GaiaTestCase): def setUp(self): # Set up child objects... GaiaTestCase.setUp(self) self.UTILS = UTILS(self) self.messages = Messages(self) # Establish which phone number to use. self.phone_number = self.UTILS.general.get_config_variable( "phone_number", "custom") self.cp_incoming_number = self.UTILS.general.get_config_variable( "sms_platform_numbers", "common").split(',') self.UTILS.reporting.logComment("Sending sms to telephone number " + self.phone_number) self.test_msg = "Test message." self.data_layer.delete_all_sms() def tearDown(self): self.UTILS.reporting.reportResults() GaiaTestCase.tearDown(self) def test_run(self): # Start by making sure we have no other notifications. self.UTILS.statusbar.clearAllStatusBarNotifs() self.UTILS.messages.create_incoming_sms(self.phone_number, self.test_msg) self.UTILS.statusbar.wait_for_notification_toaster_detail( self.test_msg, timeout=120) title = self.UTILS.statusbar.wait_for_notification_toaster_with_titles( self.cp_incoming_number, timeout=5) # Click the notifier. self.UTILS.statusbar.click_on_notification_title( title, DOM.Messages.frame_locator) self.messages.check_last_message_contents(self.test_msg) self.messages.go_back() # Check the message via the thread. self.messages.openThread(title) self.messages.check_last_message_contents(self.test_msg)
class test_main(GaiaTestCase): def setUp(self): # Set up child objects... GaiaTestCase.setUp(self) self.UTILS = UTILS(self) self.messages = Messages(self) self.contacts = Contacts(self) # Prepare the contact we're going to insert. self.phone_number = self.UTILS.general.get_config_variable("phone_number", "custom") self.contact_1 = MockContact(tel={'type': '', 'value': self.phone_number}) self.contact_2 = MockContact(tel={'type': '', 'value': self.phone_number}) self.UTILS.general.insertContact(self.contact_1) self.UTILS.reporting.logComment("Using target telephone number " + self.contact_1["tel"]["value"]) def tearDown(self): self.UTILS.reporting.reportResults() GaiaTestCase.tearDown(self) def test_run(self): # Launch messages app. self.messages.launch() """ Send a message to create a thread (use number, not name as this avoids some blocking bugs just now). """ self.messages.create_and_send_sms([self.contact_1["tel"]["value"]], "Test message.") self.messages.wait_for_message() # Open contacts app and modify the contact used to send the SMS in the previous step self.contacts.launch() self.UTILS.reporting.logComment("Using target telephone number " + self.contact_2["tel"]["value"]) self.contacts.edit_contact(self.contact_1["name"], self.contact_2) # Re-launch messages app. self.messages.launch() # Verify the thread now contains the name of the contact instead of the phone number self.UTILS.reporting.logComment("Trying to open the thread with name: " + self.contact_2["name"]) self.messages.openThread(self.contact_2["name"])
class test_main(GaiaTestCase): def setUp(self): # Set up child objects... GaiaTestCase.setUp(self) self.UTILS = UTILS(self) self.messages = Messages(self) # Establish which phone number to use. self.phone_number = self.UTILS.general.get_config_variable( "phone_number", "custom") self.incoming_sms_num = self.UTILS.general.get_config_variable( "sms_platform_numbers", "common").split(',') self.UTILS.reporting.logComment("Sending sms to telephone number " + self.phone_number) self.data_layer.delete_all_sms() # Prepare the contact we're going to insert. self.phone_number = self.UTILS.general.get_config_variable( "phone_number", "custom") self.contact = MockContact(tel={ 'type': '', 'value': self.phone_number }) self.UTILS.general.insertContact(self.contact) def tearDown(self): self.UTILS.reporting.reportResults() GaiaTestCase.tearDown(self) def test_run(self): self.UTILS.statusbar.clearAllStatusBarNotifs() # Send several messages to have something in the threads for i in range(4): sms_message = "Message {} " + "0123456789" * 5 sms_message = sms_message.format(i) self.UTILS.messages.create_incoming_sms(self.phone_number, sms_message) self.UTILS.statusbar.wait_for_notification_toaster_detail( sms_message, timeout=120) self.messages.launch() self.messages.openThread(self.incoming_sms_num[0]) self.messages.forwardMessageToContact("sms", self.contact["name"])
class test_main(GaiaTestCase): def setUp(self): # Set up child objects... GaiaTestCase.setUp(self) self.UTILS = UTILS(self) self.messages = Messages(self) self.gallery = Gallery(self) self.settings = Settings(self) self.test_msg = "Hello World" self.phone_number = self.UTILS.general.get_config_variable("incoming_call_number", "common") self.UTILS.reporting.logComment("Sending mms to telephone number " + self.phone_number) self.data_layer.delete_all_sms() self.UTILS.statusbar.clearAllStatusBarNotifs() def tearDown(self): self.UTILS.reporting.reportResults() GaiaTestCase.tearDown(self) def test_run(self): self.messages.launch() # Create and Send all MMS for msg in ["Test {}".format(i) for i in range(3)]: self.messages.create_and_send_mms("image", [self.phone_number], msg) self.messages.closeThread() self.messages.openThread(self.phone_number) # Check the messages msg_list = self.UTILS.element.getElements(DOM.Messages.message_list, "Message list", False) pos = 0 for (pos, msg) in enumerate(msg_list): # Do the check for each message. self.UTILS.test.test(msg.find_element("css selector", "p span").text == "Test {}".format(pos), "The message at position {} contains the string 'Test {}'.".format(pos, pos)) self.UTILS.test.test("outgoing" in msg.get_attribute("class"), "The message at position {} is outgoing.".format(pos))
class test_main(GaiaTestCase): def setUp(self): # Set up child objects... GaiaTestCase.setUp(self) self.UTILS = UTILS(self) self.contacts = Contacts(self) self.messages = Messages(self) # Prepare the contact we're going to insert. self.phone_number = self.UTILS.general.get_config_variable("phone_number", "custom") self.contact = MockContact(tel={'type': '', 'value': self.phone_number}) self.test_msg = "Test." self.UTILS.general.insertContact(self.contact) self.UTILS.reporting.logComment("Using target telephone number " + self.contact["tel"]["value"]) self.data_layer.delete_all_sms() def tearDown(self): self.UTILS.reporting.reportResults() GaiaTestCase.tearDown(self) def test_run(self): msgapp = self.messages.launch() self.messages.create_and_send_sms([self.phone_number], "Test") send_time = self.messages.last_sent_message_timestamp() self.messages.wait_for_message(send_time=send_time) self.messages.go_back() self.messages.openThread(self.contact["name"]) # Delete the contact self.apps.kill(msgapp) self.contacts.launch() self.contacts.delete_contact(self.contact["name"]) # Go back to SMS app and try to open the thread by phone number self.messages.launch() self.messages.openThread(self.contact["tel"]["value"])
class test_main(GaiaTestCase): def setUp(self): # Set up child objects... GaiaTestCase.setUp(self) self.UTILS = UTILS(self) self.messages = Messages(self) # Establish which phone number to use. self.phone_number = self.UTILS.general.get_config_variable("phone_number", "custom") self.cp_incoming_number = self.UTILS.general.get_config_variable("sms_platform_numbers", "common").split(',') self.UTILS.reporting.logComment("Sending sms to telephone number " + self.phone_number) self.test_msg = "Test message." self.data_layer.delete_all_sms() def tearDown(self): self.UTILS.reporting.reportResults() GaiaTestCase.tearDown(self) def test_run(self): # Start by making sure we have no other notifications. self.UTILS.statusbar.clearAllStatusBarNotifs() self.UTILS.messages.create_incoming_sms(self.phone_number, self.test_msg) self.UTILS.statusbar.wait_for_notification_toaster_detail(self.test_msg, timeout=120) title = self.UTILS.statusbar.wait_for_notification_toaster_with_titles(self.cp_incoming_number, timeout=5) # Click the notifier. self.UTILS.statusbar.click_on_notification_title(title, DOM.Messages.frame_locator) self.messages.check_last_message_contents(self.test_msg) self.messages.go_back() # Check the message via the thread. self.messages.openThread(title) self.messages.check_last_message_contents(self.test_msg)
class test_main(GaiaTestCase): test_msg = "Test message." def setUp(self): GaiaTestCase.setUp(self) self.UTILS = UTILS(self) self.messages = Messages(self) self.contacts = Contacts(self) self.phone_number = self.UTILS.general.get_config_variable( "phone_number", "custom") self.contact = MockContact() self.UTILS.general.insertContact(self.contact) def tearDown(self): self.UTILS.reporting.reportResults() GaiaTestCase.tearDown(self) def test_run(self): # Launch messages app. self.messages.launch() # Create and send a new test message. self.messages.create_and_send_sms([self.phone_number], "Test message.") self.messages.wait_for_message() # Tap the header to create a contact. self.messages.header_addToContact() # Select our contact. self.contacts.view_contact(self.contact["givenName"], False) # Check the phone number. second_phone = self.UTILS.element.getElement(("id", "number_1"), "2nd phone number.") self.UTILS.test.test( second_phone.get_attribute("value") == self.phone_number, "Contact now has a 2nd number which is '{}' (it was '{}').".format( self.phone_number, second_phone.get_attribute("value"))) # Press the Done button. done_btn = self.UTILS.element.getElement( DOM.Contacts.edit_update_button, "Update button") done_btn.tap() # Wait for contacts app to close and return to sms app. self.marionette.switch_to_frame() self.UTILS.element.waitForNotElements( ("xpath", "//iframe[contains(@src, '{}')]".format( DOM.Contacts.frame_locator[1])), "Contacts iframe") self.UTILS.iframe.switchToFrame(*DOM.Messages.frame_locator) # Verify the header is now the name, header = self.UTILS.element.getElement(DOM.Messages.message_header, "Message header") self.UTILS.test.test( header.text == self.contact["name"], "Message header has been changed to match the contact (it was '{}')." .format(header.text)) # Go back to the threads view and check the message name there too. self.messages.go_back() self.messages.openThread(self.contact["name"])
class test_main(GaiaTestCase): test_msg = "Test message." def setUp(self): # Set up child objects... GaiaTestCase.setUp(self) self.UTILS = UTILS(self) self.messages = Messages(self) self.Dialer = Dialer(self) self.phone_number = self.UTILS.general.get_config_variable("phone_number", "custom") self.dummy_nums = ["00342222222", "+343333333"] self.incoming_sms_num = self.UTILS.general.get_config_variable("sms_platform_numbers", "common").split(',') def tearDown(self): self.UTILS.reporting.reportResults() GaiaTestCase.tearDown(self) def test_run(self): # Create and send a new test message containing all of our CORRECT numbers.. msg_app = self.messages.launch() msg_text = "International num: {}, and {}.".format(self.dummy_nums[0], self.dummy_nums[1]) self.UTILS.messages.create_incoming_sms(self.phone_number, msg_text) self.UTILS.statusbar.wait_for_notification_toaster_detail(msg_text, timeout=120) title = self.UTILS.statusbar.wait_for_notification_toaster_with_titles(self.incoming_sms_num, timeout=5) self.UTILS.statusbar.click_on_notification_title(title, DOM.Messages.frame_locator) sms = self.messages.last_message_in_this_thread() # Tap the number to call. msg_nums = sms.find_elements("tag name", "a") self.UTILS.test.test(len(msg_nums) == 2, "There are <b>{}</b> numbers highlighted in the received text (expected <b>2</b>).".\ format(len(msg_nums))) x = self.UTILS.debug.screenShotOnErr() self.UTILS.reporting.logResult("info", "SMS in app", x) self.try_number(msg_nums, 1) # Kill everything, then re-launch the messaging app etc ... self.apps.kill(msg_app) time.sleep(3) self.messages.launch() self.messages.openThread(title) x = self.messages.last_message_in_this_thread() msg_nums = x.find_elements("tag name", "a") self.try_number(msg_nums, 0) def try_number(self, p_msgs, p_num): link_num = self.dummy_nums[p_num] self.UTILS.reporting.logResult("info", "Tapping link to number: {}.".format(link_num)) self.UTILS.reporting.logResult("info", "Link text is '{}'.".format(p_msgs[p_num].text)) p_msgs[p_num].tap() time.sleep(1) x = self.UTILS.element.getElement(DOM.Messages.header_call_btn, "Call button") x.tap() self.UTILS.iframe.switchToFrame(*DOM.Dialer.frame_locator) time.sleep(2) x = self.UTILS.debug.screenShotOnErr() self.UTILS.reporting.logResult("info", "Screenshot of dialer after clicking the link for number {}".\ format(link_num), x) x = self.UTILS.element.getElement(DOM.Dialer.phone_number, "Phone number") x_num = x.get_attribute("value") self.UTILS.test.test(link_num in x_num, "Expected number ({}) matches number in dialer ({}).".\ format(link_num, x_num))
class test_main(GaiaTestCase): def setUp(self): GaiaTestCase.setUp(self) self.UTILS = UTILS(self) self.contacts = Contacts(self) self.messages = Messages(self) tlf = self.UTILS.general.get_config_variable("phone_number", "custom") self.contact = MockContact(tel={'type': 'Mobile', 'value': tlf}) self.num2 = "123456789" self.UTILS.general.insertContact(self.contact) def tearDown(self): self.UTILS.reporting.reportResults() GaiaTestCase.tearDown(self) def test_run(self): # Create a thread for this contact. # (Just so we can switch to it later) self.messages.launch() self.messages.create_and_send_sms([self.contact["tel"]["value"]], "Test message") self.messages.wait_for_message() self.messages.go_back() self.messages.create_and_send_sms([self.num2], "Thread for a different number") self.apps.kill_all() time.sleep(2) self.UTILS.reporting.logResult( "info", "<b>If SMS app is closed when you click 'send sms' in contacts ...</b>" ) self._doTest() self.apps.kill_all() time.sleep(2) self.messages.launch() self.UTILS.reporting.logResult( "info", "<b>If SMS app is still open when you click 'send sms' in contacts ...</b>" ) self.messages.openThread(self.num2) self._doTest() def _doTest(self): # Launch contacts app etc... self.contacts.launch() self.contacts.view_contact(self.contact['name'], False) smsBTN = self.UTILS.element.getElement(DOM.Contacts.sms_button, "Send SMS button") smsBTN.tap() # Switch to sms frame and complete the tests + send the message. time.sleep(5) self.UTILS.iframe.switchToFrame(*DOM.Messages.frame_locator) self.UTILS.reporting.logResult( "info", "<b>NOTE: </b>expecting to be in a 'compose new sms' screen (not a thread) ..." ) self.messages.enterSMSMsg("Test msg.") self.messages.sendSMS() # Verify that we are now in the thread for this contact. self.UTILS.reporting.logResult( "info", "<b>NOTE: </b> expecting to be automatically taken to the thread for '{}' ..." .format(self.contact['name'])) msg_count = self.UTILS.element.getElements(DOM.Messages.message_list, "Thread messages", False, 5, False) if msg_count: self.UTILS.test.test( len(msg_count) > 1, "There are <i>some</i> messages in this thread already.") else: self.UTILS.reporting.logResult( False, "There are <i>some</i> messages in this thread already.")
class test_main(GaiaTestCase): def setUp(self): # Set up child objects... GaiaTestCase.setUp(self) self.UTILS = UTILS(self) self.messages = Messages(self) self.settings = Settings(self) self.phone_number = self.UTILS.general.get_config_variable("phone_number", "custom") self.cp_incoming_number = self.UTILS.general.get_config_variable("sms_platform_numbers", "common").split(',') self.test_msg = "Test message." self.data_layer.delete_all_sms() def tearDown(self): self.UTILS.reporting.reportResults() GaiaTestCase.tearDown(self) def test_run(self): self.UTILS.statusbar.clearAllStatusBarNotifs() self.UTILS.date_and_time.set_time_to_now("Europe", "Madrid") # Create and send a new test message. self.UTILS.messages.create_incoming_sms(self.phone_number, self.test_msg) self.UTILS.statusbar.wait_for_notification_toaster_detail(self.test_msg, timeout=120) title = self.UTILS.statusbar.wait_for_notification_toaster_with_titles(self.cp_incoming_number, timeout=5) self.UTILS.statusbar.click_on_notification_title(title, DOM.Messages.frame_locator) # Check the time of this message. time.sleep(2) _orig_msg_timestamp = self.messages.time_of_last_message_in_thread() self.UTILS.reporting.debug("*** original message timestamp = '{}'".format(_orig_msg_timestamp)) # Return to the threads screen and check the time of this thread. self.messages.go_back() time.sleep(1) # Get the time of this thread. _orig_thread_timestamp = self.messages.time_of_thread(title) self.UTILS.reporting.debug("*** original thread timestamp = '{}'".format(_orig_thread_timestamp)) # Change to a (unlikely!) timezone. self.apps.kill_all() self.UTILS.date_and_time.set_time_to_now("Antarctica", "Casey") # Open the sms app again. self.messages.launch() # Get the new thread time. _new_thread_timestamp = self.messages.time_of_thread(title) self.UTILS.reporting.debug("*** new thread timestamp = '{}'".format(_new_thread_timestamp)) # Open our thread. self.messages.openThread(title) # Get the new message time. _new_msg_timestamp = self.messages.time_of_last_message_in_thread() self.UTILS.reporting.debug("*** new message timestamp = '{}'".format(_new_msg_timestamp)) self.UTILS.test.test(_orig_thread_timestamp != _new_thread_timestamp, "Thread timestamp has changed.") self.UTILS.test.test(_orig_msg_timestamp != _new_msg_timestamp, "Message timestamp has changed.")
class test_main(GaiaTestCase): def setUp(self): # Set up child objects... GaiaTestCase.setUp(self) self.UTILS = UTILS(self) self.messages = Messages(self) self.gallery = Gallery(self) self.test_msg = "Hello World" # Establish which phone number to use. num1 = self.UTILS.general.get_config_variable("phone_number", "custom") self.contact1 = MockContact(givenName="Name 1", familyName="Surname 1", name="Name 1 Surname 1", tel={"type": "Mobile", "value": num1}) self.UTILS.reporting.logComment("Using target telephone number " + self.contact1["tel"]["value"]) self.UTILS.general.insertContact(self.contact1) num2 = self.UTILS.general.get_config_variable("incoming_call_number", "common") self.contact2 = MockContact(givenName="Name 3", familyName="Surname 3", name="Name 3 Surname 3", tel={"type": "Mobile", "value": num2}) self.UTILS.reporting.logComment("Using target telephone number " + self.contact2["tel"]["value"]) self.UTILS.general.insertContact(self.contact2) self.data_layer.delete_all_sms() self.UTILS.statusbar.clearAllStatusBarNotifs() self.test_nums = [self.contact1["tel"]["value"], self.contact2["tel"]["value"]] def tearDown(self): self.UTILS.general.remove_files() self.UTILS.reporting.reportResults() GaiaTestCase.tearDown(self) def test_run(self): self.messages.launch() # Create a new SMS self.messages.startNewSMS() # Insert the phone numbers in the To field for num in self.test_nums: self.messages.addNumbersInToField([num]) # Create MMS. self.messages.enterSMSMsg(self.test_msg) # Add an image file self.UTILS.general.add_file_to_device('./tests/_resources/80x60.jpg') self.messages.create_mms_image() self.gallery.click_on_thumbnail_at_position_mms(0) # Click send and wait for the message to be received self.messages.sendSMS() send_time = self.messages.last_sent_message_timestamp() self.messages.closeThread() self.messages.openThread(self.contact1["name"]) self.messages.wait_for_message(send_time=send_time) # Obtaining file attached type img_type = self.UTILS.element.getElement(DOM.Messages.attach_preview_img_type, "preview type") typ = img_type.get_attribute("data-attachment-type") if typ != "img": self.UTILS.test.test(False, "Incorrect file type. The file must be img ") self.messages.closeThread() # Check how many elements are there self.UTILS.reporting.logResult("info", "Check how many threads are there") original_count = self.messages.countNumberOfThreads() self.UTILS.reporting.logResult("info", "Number of threads {} in list.".format(original_count)) self.UTILS.test.test(original_count == 2, "Check how many threads are there")
class test_main(GaiaTestCase): _now = "" def setUp(self): # Set up child objects... GaiaTestCase.setUp(self) self.UTILS = UTILS(self) self.messages = Messages(self) self.num = self.UTILS.general.get_config_variable( "phone_number", "custom") self.UTILS.date_and_time.set_time_to_now() self.data_layer.delete_all_sms() def tearDown(self): self.UTILS.reporting.reportResults() GaiaTestCase.tearDown(self) def test_run(self): self.UTILS.statusbar.clearAllStatusBarNotifs() """ Launch messages app & delete all Threads Make sure we have no threads """ self.messages.launch() # Remember the 'real' current date and time. one_day = 86400 self.NOW_EPOCH = time.time() self._now = self.UTILS.date_and_time.getDateTimeFromEpochSecs( self.NOW_EPOCH) #============================================================================= self.UTILS.reporting.logResult("info", " ") self.UTILS.reporting.logResult("info", "--------------------------") self.UTILS.reporting.logResult( "info", "<b><u>Reading an sms from 2 months ago...</u></b>") t = self.UTILS.date_and_time.getDateTimeFromEpochSecs(self.NOW_EPOCH - (64 * one_day)) self.UTILS.date_and_time.setTimeToSpecific(p_year=t.year, p_month=t.mon, p_day=t.mday) expected_str = "{}/{}/{}".format( str(t.mon).zfill(2), str(t.mday).zfill(2), t.year) self.data_layer.send_sms(self.num, "2 months ago") self.UTILS.statusbar.wait_for_notification_toaster_detail( "2 months ago", timeout=120) self._checkTimeStamp(expected_str) #============================================================================= self.UTILS.reporting.logResult("info", " ") self.UTILS.reporting.logResult("info", "--------------------------") self.UTILS.reporting.logResult( "info", "<b><u>Reading an sms from 6 days ago...</u></b>") t = self.UTILS.date_and_time.getDateTimeFromEpochSecs(self.NOW_EPOCH - (6 * one_day)) x = self.UTILS.date_and_time.setTimeToSpecific(p_year=t.year, p_month=t.mon, p_day=t.mday) expected_str = "{}/{}/{}".format( str(t.mon).zfill(2), str(t.mday).zfill(2), t.year) self.data_layer.send_sms(self.num, "6 days ago") self.UTILS.statusbar.wait_for_notification_toaster_detail("6 days ago", timeout=120) self._checkTimeStamp(expected_str) #============================================================================= days = [ "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday", "Sunday" ] for i in range(5, 1, -1): self.UTILS.reporting.logResult("info", " ") self.UTILS.reporting.logResult("info", "--------------------------") t = self.UTILS.date_and_time.getDateTimeFromEpochSecs( self.NOW_EPOCH - (i * one_day)) x = self.UTILS.date_and_time.setTimeToSpecific(p_year=t.year, p_month=t.mon, p_day=t.mday) _dayname = days[x.tm_wday] self.UTILS.reporting.logResult("info", "<b><u>Reading an sms from {} days ago ({})...</u></b>".\ format(i, _dayname)) text = "DAY: {} ({} days ago).".format(_dayname, str(i)) self.data_layer.send_sms(self.num, text) self.UTILS.statusbar.wait_for_notification_toaster_detail( text, timeout=120) self._checkTimeStamp(_dayname.upper()) #============================================================================= self.UTILS.reporting.logResult("info", " ") self.UTILS.reporting.logResult("info", "--------------------------") self.UTILS.reporting.logResult( "info", "<b><u>Reading an sms from yesterday...</u></b>") t = self.UTILS.date_and_time.getDateTimeFromEpochSecs(self.NOW_EPOCH - (1 * one_day)) x = self.UTILS.date_and_time.setTimeToSpecific(p_year=t.year, p_month=t.mon, p_day=t.mday) self.data_layer.send_sms(self.num, "DAY: YESTERDAY") self.UTILS.statusbar.wait_for_notification_toaster_detail( "DAY: YESTERDAY", timeout=120) self._checkTimeStamp("YESTERDAY") #============================================================================= self.UTILS.reporting.logResult("info", " ") self.UTILS.reporting.logResult("info", "--------------------------") self.UTILS.reporting.logResult( "info", "<b><u>Reading an sms from today ...</u></b>") self.data_layer.set_time(self.NOW_EPOCH * 1000) self.data_layer.send_sms(self.num, "DAY: TODAY") self.UTILS.statusbar.wait_for_notification_toaster_detail("DAY: TODAY", timeout=120) self._checkTimeStamp("TODAY") def _checkTimeStamp(self, p_str): """ Sets the device time back to 'now', opens the sms / thread and checks that the expected timestamp header is present. """ # This is slow, but I can't find a way to see headers that are off the top # of the screen, so I ended up doing it this way. # self.UTILS.reporting.logResult( "info", "Setting device time back to the 'real' date and time.") self.data_layer.set_time(self.NOW_EPOCH * 1000) self.UTILS.date_and_time.waitForDeviceTimeToBe(p_year=self._now.year, p_month=self._now.mon, p_day=self._now.mday, p_hour=self._now.hour, p_minute=self._now.min) self.messages.launch() self.messages.openThread(self.num) time.sleep(2) x = self.UTILS.element.getElements(DOM.Messages.message_timestamps, "Message date header", False)[-1] self.UTILS.test.test(p_str == x.text.encode("utf8"), "<b>Last message timestamp header is <u>'{}'</u> </b>(expected <b>'{}'</b>).".\ format(x.text, p_str), stop_on_error=True) time.sleep(3) self.messages.closeThread()
class test_main(GaiaTestCase): test_msg = "Test message." def setUp(self): # Set up child objects... GaiaTestCase.setUp(self) self.UTILS = UTILS(self) self.messages = Messages(self) self.Dialer = Dialer(self) self.phone_number = self.UTILS.general.get_config_variable( "phone_number", "custom") self.dummy_nums = ["00342222222", "+343333333"] self.incoming_sms_num = self.UTILS.general.get_config_variable( "sms_platform_numbers", "common").split(',') def tearDown(self): self.UTILS.reporting.reportResults() GaiaTestCase.tearDown(self) def test_run(self): # Create and send a new test message containing all of our CORRECT numbers.. msg_app = self.messages.launch() msg_text = "International num: {}, and {}.".format( self.dummy_nums[0], self.dummy_nums[1]) self.UTILS.messages.create_incoming_sms(self.phone_number, msg_text) self.UTILS.statusbar.wait_for_notification_toaster_detail(msg_text, timeout=120) title = self.UTILS.statusbar.wait_for_notification_toaster_with_titles( self.incoming_sms_num, timeout=5) self.UTILS.statusbar.click_on_notification_title( title, DOM.Messages.frame_locator) sms = self.messages.last_message_in_this_thread() # Tap the number to call. msg_nums = sms.find_elements("tag name", "a") self.UTILS.test.test(len(msg_nums) == 2, "There are <b>{}</b> numbers highlighted in the received text (expected <b>2</b>).".\ format(len(msg_nums))) x = self.UTILS.debug.screenShotOnErr() self.UTILS.reporting.logResult("info", "SMS in app", x) self.try_number(msg_nums, 1) # Kill everything, then re-launch the messaging app etc ... self.apps.kill(msg_app) time.sleep(3) self.messages.launch() self.messages.openThread(title) x = self.messages.last_message_in_this_thread() msg_nums = x.find_elements("tag name", "a") self.try_number(msg_nums, 0) def try_number(self, p_msgs, p_num): link_num = self.dummy_nums[p_num] self.UTILS.reporting.logResult( "info", "Tapping link to number: {}.".format(link_num)) self.UTILS.reporting.logResult( "info", "Link text is '{}'.".format(p_msgs[p_num].text)) p_msgs[p_num].tap() time.sleep(1) x = self.UTILS.element.getElement(DOM.Messages.header_call_btn, "Call button") x.tap() self.UTILS.iframe.switchToFrame(*DOM.Dialer.frame_locator) time.sleep(2) x = self.UTILS.debug.screenShotOnErr() self.UTILS.reporting.logResult("info", "Screenshot of dialer after clicking the link for number {}".\ format(link_num), x) x = self.UTILS.element.getElement(DOM.Dialer.phone_number, "Phone number") x_num = x.get_attribute("value") self.UTILS.test.test(link_num in x_num, "Expected number ({}) matches number in dialer ({}).".\ format(link_num, x_num))
class test_main(GaiaTestCase): test_msgs = ["First message", "Second message", "Third message"] def setUp(self): # Set up child objects... GaiaTestCase.setUp(self) self.UTILS = UTILS(self) self.messages = Messages(self) # Establish which phone number to use. self.phone_number = self.UTILS.general.get_config_variable( "phone_number", "custom") self.UTILS.reporting.logComment("Sending sms to telephone number " + self.phone_number) self.data_layer.delete_all_sms() def tearDown(self): self.UTILS.reporting.reportResults() GaiaTestCase.tearDown(self) def test_run(self): """ Launch messages app & delete all Threads Make sure we have no threads """ self.messages.launch() for i in range(3): self.UTILS.reporting.debug("** Sending [{}]".format( self.test_msgs[i])) self.data_layer.send_sms(self.phone_number, self.test_msgs[i]) self.UTILS.statusbar.wait_for_notification_toaster_detail( self.test_msgs[i], timeout=120) self.UTILS.iframe.switchToFrame(*DOM.Messages.frame_locator) self.messages.openThread(self.phone_number) # Go into edit mode.. edit_btn = self.UTILS.element.getElement( DOM.Messages.edit_messages_icon, "Edit button") edit_btn.tap() select_btn = self.UTILS.element.getElement( DOM.Messages.edit_msgs_select_btn, "Select messages button") select_btn.tap() # Select all select_all_btn = self.UTILS.element.getElement( DOM.Messages.check_all_messages_btn, "Select all button") select_all_btn.tap() # Tap delete self.messages.deleteSelectedMessages() # Check conversation isn't there anymore. self.UTILS.element.waitForNotElements( ("xpath", DOM.Messages.thread_selector_xpath.format(self.phone_number)), "Thread") time.sleep(1) fnam = self.UTILS.debug.screenShotOnErr() self.UTILS.reporting.logResult("info", "Screenshot of final position:", fnam)
class test_main(GaiaTestCase): def setUp(self): # Set up child objects... GaiaTestCase.setUp(self) self.UTILS = UTILS(self) self.messages = Messages(self) self.gallery = Gallery(self) self.test_msg = "Hello World" # Establish which phone number to use. num1 = self.UTILS.general.get_config_variable("phone_number", "custom") self.contact1 = MockContact(givenName="Name 1", familyName="Surname 1", name="Name 1 Surname 1", tel={ "type": "Mobile", "value": num1 }) self.UTILS.reporting.logComment("Using target telephone number " + self.contact1["tel"]["value"]) self.UTILS.general.insertContact(self.contact1) num2 = self.UTILS.general.get_config_variable("incoming_call_number", "common") self.contact2 = MockContact(givenName="Name 3", familyName="Surname 3", name="Name 3 Surname 3", tel={ "type": "Mobile", "value": num2 }) self.UTILS.reporting.logComment("Using target telephone number " + self.contact2["tel"]["value"]) self.UTILS.general.insertContact(self.contact2) self.data_layer.delete_all_sms() self.UTILS.statusbar.clearAllStatusBarNotifs() self.test_nums = [ self.contact1["tel"]["value"], self.contact2["tel"]["value"] ] def tearDown(self): self.UTILS.general.remove_files() self.UTILS.reporting.reportResults() GaiaTestCase.tearDown(self) def test_run(self): self.messages.launch() # Create a new SMS self.messages.startNewSMS() # Insert the phone numbers in the To field for num in self.test_nums: self.messages.addNumbersInToField([num]) # Create MMS. self.messages.enterSMSMsg(self.test_msg) # Add an image file self.UTILS.general.add_file_to_device('./tests/_resources/80x60.jpg') self.messages.create_mms_image() self.gallery.click_on_thumbnail_at_position_mms(0) # Click send and wait for the message to be received self.messages.sendSMS() send_time = self.messages.last_sent_message_timestamp() self.messages.closeThread() self.messages.openThread(self.contact1["name"]) self.messages.wait_for_message(send_time=send_time) # Obtaining file attached type img_type = self.UTILS.element.getElement( DOM.Messages.attach_preview_img_type, "preview type") typ = img_type.get_attribute("data-attachment-type") if typ != "img": self.UTILS.test.test(False, "Incorrect file type. The file must be img ") self.messages.closeThread() # Check how many elements are there self.UTILS.reporting.logResult("info", "Check how many threads are there") original_count = self.messages.countNumberOfThreads() self.UTILS.reporting.logResult( "info", "Number of threads {} in list.".format(original_count)) self.UTILS.test.test(original_count == 2, "Check how many threads are there")
class test_main(GaiaTestCase): def setUp(self): # Set up child objects... GaiaTestCase.setUp(self) self.UTILS = UTILS(self) self.messages = Messages(self) # Import contact (adjust to the correct number). self.test_num = self.UTILS.general.get_config_variable( "phone_number", "custom") self.contact1 = MockContact(givenName="Name 1", familyName="Surname 1", name="Name 1 Surname 1", tel={ "type": "Mobile", "value": self.test_num }) self.UTILS.reporting.logComment("Using target telephone number " + self.contact1["tel"]["value"]) self.UTILS.general.insertContact(self.contact1) self.call_number = self.UTILS.general.get_config_variable( "incoming_call_number", "common") self.data_layer.delete_all_sms() self.UTILS.statusbar.clearAllStatusBarNotifs() _ = setup_translations(self) def tearDown(self): self.UTILS.reporting.reportResults() GaiaTestCase.tearDown(self) def test_run(self): self.messages.launch() self.messages.startNewSMS() self.messages.addContactToField(self.contact1["name"]) # Insert the phone number in the To field self.messages.addNumbersInToField([self.call_number]) search_str = _("2 recipients") self.UTILS.element.headerCheck(search_str) # Enter the message. self.UTILS.reporting.logResult("info", "Enter the message.") self.messages.enterSMSMsg("Test 29911") # Send the message. self.messages.sendSMS() self.UTILS.statusbar.wait_for_notification_toaster_title( self.contact1["name"]) self.UTILS.iframe.switch_to_frame(*DOM.Messages.frame_locator) # Verify the number is shown in the header as there is no contact name self.messages.openThread(self.call_number) self.messages.checkThreadHeader(self.call_number) self.UTILS.reporting.logResult( "info", "Verify the number is shown in the header as there is no contact name" ) # Return to main SMS page. self.messages.closeThread() # Verify the thread now contains the name of the contact instead of the phone number self.UTILS.reporting.logResult( "info", "Trying to open the thread with name: " + self.contact1["name"]) self.messages.openThread(self.contact1["name"]) self.messages.checkThreadHeaderWithNameSurname(self.contact1["name"])
class test_main(GaiaTestCase): def setUp(self): # Set up child objects... GaiaTestCase.setUp(self) self.UTILS = UTILS(self) self.messages = Messages(self) # Import contact (adjust the correct number). self.phone_number = self.UTILS.general.get_config_variable( "phone_number", "custom") self.data_layer.delete_all_sms() def tearDown(self): self.UTILS.reporting.reportResults() GaiaTestCase.tearDown(self) def test_run(self): # Send some messages to create a thread self.texts = ["Test 1", "Test 2", "Test 3"] self.directions = ["outgoing", "incoming"] self.create_test_sms(self.phone_number, self.texts) # Launch messages app. self.messages.launch() # Enter the thread. self.messages.openThread(self.phone_number) # Find the first message. time.sleep(2) msg_list = self.UTILS.element.getElements(DOM.Messages.message_list, "Message list", False) msgs = [(text, direction) for text in self.texts for direction in self.directions] for (msg, expected) in zip(msg_list, msgs): direction = "outgoing" if "outgoing" in msg.get_attribute( "class") else "incoming" text = self.marionette.find_element( *DOM.Messages.last_message_text_nested, id=msg.id).text self.UTILS.test.test( text == expected[0], "**** Text: {} Expected: {}".format(text, expected[0])) self.UTILS.test.test(direction == expected[1], "Direction: {} Expected: {}".\ format(direction, expected[1])) # Tap the message area. x = self.UTILS.element.getElement(DOM.Messages.input_message_area, "Message area") x.tap() # Check the keyboard is now present. self.UTILS.iframe.switchToFrame(*DOM.Keyboard.frame_locator) def create_test_sms(self, number, msg_list): """Send messages in the list to populate a thread. """ for msg in msg_list: self.data_layer.send_sms(number, msg) self.UTILS.statusbar.wait_for_notification_toaster_detail( msg, timeout=120)
class test_main(GaiaTestCase): def setUp(self): # Set up child objects... GaiaTestCase.setUp(self) self.UTILS = UTILS(self) self.messages = Messages(self) self.settings = Settings(self) self.phone_number = self.UTILS.general.get_config_variable( "phone_number", "custom") self.cp_incoming_number = self.UTILS.general.get_config_variable( "sms_platform_numbers", "common").split(',') self.test_msg = "Test message." self.data_layer.delete_all_sms() def tearDown(self): self.UTILS.reporting.reportResults() GaiaTestCase.tearDown(self) def test_run(self): self.UTILS.statusbar.clearAllStatusBarNotifs() self.UTILS.date_and_time.set_time_to_now("Europe", "Madrid") # Create and send a new test message. self.UTILS.messages.create_incoming_sms(self.phone_number, self.test_msg) self.UTILS.statusbar.wait_for_notification_toaster_detail( self.test_msg, timeout=120) title = self.UTILS.statusbar.wait_for_notification_toaster_with_titles( self.cp_incoming_number, timeout=5) self.UTILS.statusbar.click_on_notification_title( title, DOM.Messages.frame_locator) # Check the time of this message. time.sleep(2) _orig_msg_timestamp = self.messages.time_of_last_message_in_thread() self.UTILS.reporting.debug( "*** original message timestamp = '{}'".format( _orig_msg_timestamp)) # Return to the threads screen and check the time of this thread. self.messages.go_back() time.sleep(1) # Get the time of this thread. _orig_thread_timestamp = self.messages.time_of_thread(title) self.UTILS.reporting.debug( "*** original thread timestamp = '{}'".format( _orig_thread_timestamp)) # Change to a (unlikely!) timezone. self.apps.kill_all() self.UTILS.date_and_time.set_time_to_now("Antarctica", "Casey") # Open the sms app again. self.messages.launch() # Get the new thread time. _new_thread_timestamp = self.messages.time_of_thread(title) self.UTILS.reporting.debug( "*** new thread timestamp = '{}'".format(_new_thread_timestamp)) # Open our thread. self.messages.openThread(title) # Get the new message time. _new_msg_timestamp = self.messages.time_of_last_message_in_thread() self.UTILS.reporting.debug( "*** new message timestamp = '{}'".format(_new_msg_timestamp)) self.UTILS.test.test(_orig_thread_timestamp != _new_thread_timestamp, "Thread timestamp has changed.") self.UTILS.test.test(_orig_msg_timestamp != _new_msg_timestamp, "Message timestamp has changed.")
class test_main(GaiaTestCase): test_msg = "Test." def setUp(self): # Set up child objects... GaiaTestCase.setUp(self) self.UTILS = UTILS(self) self.messages = Messages(self) self.contacts = Contacts(self) self.gallery = Gallery(self) # Import contact (adjust to the correct number). self.test_num = self.UTILS.general.get_config_variable( "phone_number", "custom") self.cont = MockContact(tel={"type": "Mobile", "value": self.test_num}) self.UTILS.reporting.logComment("Using target telephone number " + self.cont["tel"]["value"]) def tearDown(self): self.UTILS.general.remove_files() self.UTILS.reporting.reportResults() GaiaTestCase.tearDown(self) def test_run(self): self.UTILS.general.add_file_to_device('./tests/_resources/imgd.jpg') # Launch messages app. self.messages.launch() # Create a new SMS self.messages.startNewSMS() # Insert the phone number in the To field self.messages.addNumbersInToField([self.test_num]) # Create MMS. self.messages.enterSMSMsg(self.test_msg) self.messages.create_mms_image() self.gallery.click_on_thumbnail_at_position_mms(0) # Click send and wait for the message to be received self.messages.sendSMS() send_time = self.messages.last_sent_message_timestamp() """ Open contacts app and create a contact with the same phone number used to send the MMS in the previous step """ self.contacts.launch() self.contacts.create_contact(self.cont) # Switch back to the messages app. self.UTILS.home.goHome() self.messages.launch() # Verify the thread now contains the name of the contact instead of the phone number self.UTILS.reporting.logComment( "Trying to open the thread with name: " + self.cont["name"]) self.messages.openThread(self.cont["name"]) self.messages.wait_for_message(send_time)
class test_main(GaiaTestCase): def setUp(self): GaiaTestCase.setUp(self) self.UTILS = UTILS(self) self.contacts = Contacts(self) self.messages = Messages(self) tlf = self.UTILS.general.get_config_variable("phone_number", "custom") self.contact = MockContact(tel={'type': 'Mobile', 'value': tlf}) self.num2 = "123456789" self.UTILS.general.insertContact(self.contact) def tearDown(self): self.UTILS.reporting.reportResults() GaiaTestCase.tearDown(self) def test_run(self): # Create a thread for this contact. # (Just so we can switch to it later) self.messages.launch() self.messages.create_and_send_sms([self.contact["tel"]["value"]], "Test message") self.messages.wait_for_message() self.messages.go_back() self.messages.create_and_send_sms([self.num2], "Thread for a different number") self.apps.kill_all() time.sleep(2) self.UTILS.reporting.logResult("info", "<b>If SMS app is closed when you click 'send sms' in contacts ...</b>") self._doTest() self.apps.kill_all() time.sleep(2) self.messages.launch() self.UTILS.reporting.logResult( "info", "<b>If SMS app is still open when you click 'send sms' in contacts ...</b>") self.messages.openThread(self.num2) self._doTest() def _doTest(self): # Launch contacts app etc... self.contacts.launch() self.contacts.view_contact(self.contact['name'], False) smsBTN = self.UTILS.element.getElement(DOM.Contacts.sms_button, "Send SMS button") smsBTN.tap() # Switch to sms frame and complete the tests + send the message. time.sleep(5) self.UTILS.iframe.switchToFrame(*DOM.Messages.frame_locator) self.UTILS.reporting.logResult( "info", "<b>NOTE: </b>expecting to be in a 'compose new sms' screen (not a thread) ...") self.messages.enterSMSMsg("Test msg.") self.messages.sendSMS() # Verify that we are now in the thread for this contact. self.UTILS.reporting.logResult("info", "<b>NOTE: </b> expecting to be automatically taken to the thread for '{}' ...". format(self.contact['name'])) msg_count = self.UTILS.element.getElements(DOM.Messages.message_list, "Thread messages", False, 5, False) if msg_count: self.UTILS.test.test(len(msg_count) > 1, "There are <i>some</i> messages in this thread already.") else: self.UTILS.reporting.logResult(False, "There are <i>some</i> messages in this thread already.")