Example #1
0
 def _list_redir_cmd(self):
     is_cmd_succ, output_redir_list = util.execute_console_command(
         self.telnet, CMD_REDIR_LIST, util.PORT_NO_REDIR)
     self.assert_cmd_successful(
         is_cmd_succ, 'Failed to properly list port redirection.', False,
         '', util.PORT_NO_REDIR, output_redir_list)
     return output_redir_list
Example #2
0
    def test_send_inbound_sms_text_message(self):
        """Test command for: sms send <phone number> <text message>.

    TT ID: f2c2aa1a-b793-4939-b156-0e7d82c85502
    Test steps:
      1. Launch an emulator avd
      2. From command prompt, run: telnet localhost <port>
      3. Copy the auth_token value from ~/.emulator_console_auth_token
      4. Run: auth auth_token
      5. Run: sms send <phone number> <text message>, and verify
    Verify:
      An sms is received from <phone number> with the text <text message>.
    """
        if util.WIN_BUILDER_NAME in self.builder_name:
            print 'Skip sms test on Win.'
            pass
            return

        print 'Running test: %s' % (inspect.stack()[0][3])

        util.run_script_run_adb_shell(TESTCASE_CALL_DIR)

        is_command_successful, output = util.execute_console_command(
            self.telnet, CMD_SMS_SEND, util.OK)
        self.assert_cmd_successful(is_command_successful,
                                   'Failed to properly send sms text message',
                                   False, '', util.OK, output)
        self._poll_sms_and_verify(SENDER_PHONE_NUMBER, TEXT_MESSAGE)

        util.unstall_apps(TESTCASE_CALL_DIR)
Example #3
0
    def _verify_auth_command_by_enter_help_command(self, expected_output):
        is_command_successful, output = util.execute_console_command(
            self.telnet, util.CMD_HELP, expected_output)

        self.assert_cmd_successful(
            is_command_successful,
            'Failed to properly list all command options.', False, '',
            'Pattern: \n%s' % expected_output, output)
Example #4
0
    def _verify_events_no_alias(self, command):
        is_cmd_successful, output_event_list_all = util.execute_console_command(
            self.telnet, command, util.EVENTS_CODE_NO_ALIAS)

        self.assert_cmd_successful(
            is_cmd_successful,
            'output mismatch: fail to run %s properly' % command, False, '',
            util.EVENTS_CODE_NO_ALIAS, output_event_list_all)
 def _execute_rotate_command_and_verify(self, expected_orientation,
                                        expected_rotation):
   print '\n-------------------------'
   is_command_successful, output = util.execute_console_command(
     self.telnet, util.CMD_ROTATE, '')
   self.assert_cmd_successful(
     is_command_successful, 'Failed to properly get orientation/rotation.',
     False, '', '', output)
   self._poll_orientation_rotation_and_verify(expected_orientation,
                                              expected_rotation)
    def _help_verbose_command(self, expected_output):
        """Executes help-verbose command and verifies output.

    Args:
        expected_output: Expected console output for help-vebose command.
    """
        is_command_successful, output = util.execute_console_command(
            self.telnet, util.CMD_HELP_VERBOSE, expected_output)

        self.assert_cmd_successful(
            is_command_successful,
            'Failed to properly list all command options.', False, '',
            'Pattern: \n%s' % expected_output, output)
Example #7
0
  def _execute_console_command_and_verify(self, command, expected_output):
    """Executes emulator console command and verify the command output.

    Args:
        command: Console command to be executed.
        expected_output: The expected command output.
    """
    is_command_successful, output = util.execute_console_command(
        self.telnet, command, expected_output)

    self.assert_cmd_successful(
        is_command_successful, 'Failed to properly execute: %s' % command,
        False, '', expected_output, output)
Example #8
0
    def test_geo(self):
        """Test command for: geo fix xxx

    TT ID: caad94f5-1714-470c-829c-6df616dfa358
    Test steps:
      1. Launch an emulator avd
      2. From command prompt, run: telnet localhost <port>
      3. Copy the auth_token value from ~/.emulator_console_auth_token
      4. Run: auth auth_token
      5. Open Google Maps app and accept the terms and conditions
      6. Enable location service in Google Maps
      7. Tap on My Location
      8. Run: geo fix -122 37 0
    Verify:
      Check Maps location centers on San Francisco.
    """
        if util.WIN_BUILDER_NAME in self.builder_name:
            print 'Skip geo test on Win.'
            pass
            return

        print 'Running test: %s' % (inspect.stack()[0][3])

        print 'api = ' + self.avd.api

        if self.avd.api == '23':
            print 'Skip geo test for API 23.'
            pass
            return

        if self.avd.api in ['25', '24', '23']:
            util.run_script_run_adb_shell(TESTCASE_CALL_DIR)

            self._initially_launch_google_maps_to_have_location_history(
                {'api': self.avd.api})

            is_command_successful, output = util.execute_console_command(
                self.telnet, CMD_GEO_SF, '')
            self.assert_cmd_successful(is_command_successful,
                                       'Failed to properly set geo info.',
                                       False, '', '', output)
            self._process_request_geo_service({})
            self._poll_geo_and_verify(SF_LONGITUDE, SF_LATITUDE, SF_ALTITUDE)

            util.unstall_apps(TESTCASE_CALL_DIR)
        else:
            # TODO: Add support for APIs below 23.
            print 'API is below 23, skip geo test for now.'
            pass
Example #9
0
    def _execute_command_and_verify(self, command, expected_output,
                                    assert_msg):
        """Executes console command and verify output.

    Args:
        command: Console command to be executed.
        expected_output: Expected console output.
        assert_msg: Assertion message.
    """
        is_command_successful, output = util.execute_console_command(
            self.telnet, command, expected_output)

        self.assert_cmd_successful(is_command_successful, assert_msg, False,
                                   '', 'Pattern:\n%s' % expected_output,
                                   output)
Example #10
0
    def test_geo_stress(self):
        """Stress geo location by attempting to send invalid coordinates."""
        if util.WIN_BUILDER_NAME in self.builder_name:
            print 'Skip geo test on Win.'
            pass
            return

        print 'Running test: %s' % (inspect.stack()[0][2])

        if self.avd.api in ['24', '25']:
            print 'Running test: %s' % (inspect.stack()[0][2])

            util.run_script_run_adb_shell(TESTCASE_CALL_DIR)

            self._initially_launch_google_maps_to_have_location_history(
                {'api': self.avd.api})
            is_command_successful, output = util.execute_console_command(
                self.telnet, CMD_GEO_SF, '')
            self.assert_cmd_successful(is_command_successful,
                                       'Failed to properly set geo info.',
                                       False, '', '', output)
            self._process_request_geo_service({})
            self._poll_geo_and_verify(SF_LONGITUDE, SF_LATITUDE, SF_ALTITUDE)

            for i in range(ITERATIONS):
                # Use telnet.write directly instead of execute_console_command since we expect this command to fail.
                # Will produce 'KO' rather than 'OK'. (i.e. execute_console_command hangs waiting for 'OK').
                self.telnet.write(CMD_GEO_INVALID)
                self.telnet.read_until('KO:')
                self.telnet.read_until('\n')
                self._process_request_geo_service({})
                self._poll_geo_and_verify(SF_LONGITUDE, SF_LATITUDE,
                                          SF_ALTITUDE)

            util.unstall_apps(TESTCASE_CALL_DIR)
        else:
            # TODO: Add support for APIs below 24.
            print 'Skip geo stress test for APIs below 24.'
            pass
Example #11
0
 def _auth_user_for_emulator_console(self, cmd_auth, expected_output):
     is_command_successful, output = util.execute_console_command(
         self.telnet, cmd_auth, expected_output)
     self.assert_cmd_successful(is_command_successful,
                                'Failed to properly authentication.', False,
                                '', expected_output, output)