コード例 #1
0
    def test_pending_system_message(self):
        """"
        The scenario we want to test is:

        1) Launch an app.
        2) Create DOM side SystemMessageManager without setting the handler.
        3) Broadcast system message internally. The message will be pending
           until the app sets the message handler.
        4) The app sets the message handler and the message should be signalled
           right away.
        """

        test_container = TestContainer(self.marionette)

        # Launch the app and call mozHasPendingMessage to ensure the
        # existence of SystemMessageManager in DOM side.
        test_container.launch()
        self.marionette.execute_script("""
            navigator.mozHasPendingMessage('whatever');
        """)

        # Broadcast the system message and the test app shouldn't receive it
        # since the hanlder is not set yet.
        test_container.broadcast_dummy_system_message(
            self._testing_message_text)

        # Set the handler and test if the message is delivered correctly.
        test_container.set_dummy_system_message_handler(
            self._testing_message_id)

        message_text = test_container.find_message_text(
            self._testing_message_id)

        self.assertEqual(message_text, self._testing_message_text)
コード例 #2
0
    def test_pending_system_message(self):
        """"
        The scenario we want to test is:

        1) Launch an app.
        2) Create DOM side SystemMessageManager without setting the handler.
        3) Broadcast system message internally. The message will be pending
           until the app sets the message handler.
        4) The app sets the message handler and the message should be signalled
           right away.
        """

        test_container = TestContainer(self.marionette)

        # Launch the app and call mozHasPendingMessage to ensure the
        # existence of SystemMessageManager in DOM side.
        test_container.launch()
        self.marionette.execute_script(
            """
            navigator.mozHasPendingMessage('whatever');
        """
        )

        # Broadcast the system message and the test app shouldn't receive it
        # since the hanlder is not set yet.
        test_container.broadcast_dummy_system_message(self._testing_message_text)

        # Set the handler and test if the message is delivered correctly.
        test_container.set_dummy_system_message_handler(self._testing_message_id)

        message_text = test_container.find_message_text(self._testing_message_id)

        self.assertEqual(message_text, self._testing_message_text)
コード例 #3
0
ファイル: test_system_message.py プロジェクト: Allan019/gaia
    def test_app_launched_by_system_message(self):
        test_container = TestContainer(self.marionette)

        message_text_json = '{value: "%s"}' % self._testing_message_text
        self.broadcast_system_message(self._testing_system_message, message_text_json)

        self.wait_for_element_present(*self._testing_app_selector)

        # We've made sure app is running.
        # Now test if the message is delivered correctly to the app
        test_container.launch()
        self.on_app_launched()
        message = self.marionette.find_element(By.ID, self._testing_message_id)
        self.assertEqual(message.text, self._testing_message_text)
コード例 #4
0
    def test_app_launched_by_system_message(self):
        test_container = TestContainer(self.marionette)

        message_text_json = '{value: "%s"}' % self._testing_message_text
        self.broadcast_system_message(self._testing_system_message,
                                      message_text_json)

        self.wait_for_element_present(*self._testing_app_selector)

        # We've made sure app is running.
        # Now test if the message is delivered correctly to the app
        test_container.launch()
        self.on_app_launched()
        message = self.marionette.find_element(By.ID, self._testing_message_id)
        self.assertEqual(message.text, self._testing_message_text)
コード例 #5
0
    def test_app_launched_by_system_message(self):
        """
        Two basic functions are going to be tested here:
        1. The testing app must be launched after broadcasting the testing
           system message.
        2. The testing app must show the same text that we broadcast together
           with the testing system message.
        """

        test_container = TestContainer(self.marionette)

        # Broadcast a system message to bring up the test app.
        test_container.broadcast_dummy_system_message(
            self._testing_message_text)

        test_container.wait_until_launched()

        # Bring the app to foreground first.
        test_container.launch()

        # Set the handler and test if the message is delivered correctly.
        test_container.set_dummy_system_message_handler(
            self._testing_message_id)

        message_text = test_container.find_message_text(
            self._testing_message_id)

        self.assertEqual(message_text, self._testing_message_text)