Exemplo n.º 1
0
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()
Exemplo n.º 2
0
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()
Exemplo n.º 3
0
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"])
Exemplo n.º 4
0
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)
Exemplo n.º 5
0
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()
Exemplo n.º 6
0
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)

        # Establish which phone number to use.
        self.phone_number = self.UTILS.general.get_config_variable(
            "phone_number", "custom")
        self.UTILS.reporting.logComment("Using target telephone number " +
                                        self.phone_number)
        self.incoming_sms_num = self.UTILS.general.get_config_variable(
            "sms_platform_numbers", "common").split(',')
        self.data_layer.delete_all_sms()

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

    def test_run(self):
        self.messages.launch()

        sms_msg = "Just creating a message thread."
        self.UTILS.messages.create_incoming_sms(self.phone_number, sms_msg)
        self.UTILS.statusbar.wait_for_notification_toaster_detail(sms_msg,
                                                                  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)

        # Return to main SMS page.
        self.messages.closeThread()

        # Press the edit button (without selecting any threads).
        self.messages.editAndSelectThreads([])

        # Check that the delete button is not enabled.
        delete_btn = self.UTILS.element.getElement(
            DOM.Messages.threads_delete_button, "Delete button")
        disabled = delete_btn.get_attribute("disabled")
        self.UTILS.test.test(disabled, "Delete button is not enabled.")
Exemplo n.º 7
0
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))
Exemplo n.º 8
0
class test_main(GaiaTestCase):
    def setUp(self):

        # Set up child objects...
        GaiaTestCase.setUp(self)
        self.UTILS = UTILS(self)
        self.messages = Messages(self)

        # Define target phone numbers
        num_prefix_plus = self.UTILS.general.get_config_variable(
            "phone_number", "custom")
        num_prefix_double_zero = num_prefix_plus.replace("+", "00")
        num_no_prefix = num_prefix_plus.replace("+34", "")
        self.target_numbers = [
            num_prefix_plus, num_prefix_double_zero, num_no_prefix
        ]
        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()

        for num in self.target_numbers:
            test_msg = "Hello World at {} for {}".format(time.time(), num)
            self.messages.create_and_send_mms("image", [num], test_msg)
            self.messages.wait_for_message()
            self.messages.closeThread()
            time.sleep(3)

        # Check how many elements are there
        count = self.messages.countNumberOfThreads()
        self.UTILS.reporting.logResult(
            "info", "Number of threads {} in list.".format(count))
        self.UTILS.test.test(
            count == 1, "There are {} threads (expected {})".format(count, 1))
Exemplo n.º 9
0
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)

        # Establish which phone number to use.
        self.phone_number = self.UTILS.general.get_config_variable("phone_number", "custom")
        self.UTILS.reporting.logComment("Using target telephone number " + self.phone_number)
        self.incoming_sms_num = self.UTILS.general.get_config_variable("sms_platform_numbers", "common").split(',')
        self.data_layer.delete_all_sms()

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

    def test_run(self):
        self.messages.launch()

        sms_msg = "Just creating a message thread."
        self.UTILS.messages.create_incoming_sms(self.phone_number, sms_msg)
        self.UTILS.statusbar.wait_for_notification_toaster_detail(sms_msg, 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)

        # Return to main SMS page.
        self.messages.closeThread()

        # Press the edit button (without selecting any threads).
        self.messages.editAndSelectThreads([])

        # Check that the delete button is not enabled.
        delete_btn = self.UTILS.element.getElement(DOM.Messages.threads_delete_button, "Delete button")
        disabled = delete_btn.get_attribute("disabled")
        self.UTILS.test.test(disabled, "Delete button is not enabled.")
Exemplo n.º 10
0
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.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()

        # Leave this thread.
        self.messages.closeThread()

        # Enter EDIT mode.
        self.messages.threadEditModeON()

        # Exit EDIT mode.
        self.messages.threadEditModeOFF()
Exemplo n.º 11
0
class test_main(GaiaTestCase):

    def setUp(self):

        # Set up child objects...
        GaiaTestCase.setUp(self)
        self.UTILS = UTILS(self)
        self.messages = Messages(self)

        # Define target phone numbers
        num_prefix_plus = self.UTILS.general.get_config_variable("phone_number", "custom")
        num_prefix_double_zero = num_prefix_plus.replace("+", "00")
        num_no_prefix = num_prefix_plus.replace("+34", "")
        self.target_numbers = [num_prefix_plus, num_prefix_double_zero, num_no_prefix]
        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()

        for num in self.target_numbers:
            test_msg = "Hello World at {} for {}".format(time.time(), num)
            self.messages.create_and_send_mms("image", [num], test_msg)
            self.messages.wait_for_message()
            self.messages.closeThread()
            time.sleep(3)

        # Check how many elements are there
        count = self.messages.countNumberOfThreads()
        self.UTILS.reporting.logResult("info", "Number of threads {} in list.".format(count))
        self.UTILS.test.test(count == 1, "There are {} threads (expected {})".format(count, 1))
Exemplo n.º 12
0
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"])
Exemplo n.º 13
0
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")
Exemplo n.º 14
0
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()
Exemplo n.º 15
0
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")