Ejemplo n.º 1
0
    def set_up(self):
        """
        Initialize the test
        """
        # Call UseCase base Setup function
        UseCaseBase.set_up(self)

        # Check value of FILENAME parameter
        if self._audio_filename == "" or is_number(self._audio_filename):
            error_msg = "The parameter FILENAME must a string containing the local audio file or an url !"
            self.get_logger().error(error_msg)
            raise AcsConfigException(AcsConfigException.INVALID_PARAMETER, error_msg)

        # Check if needed to enable data for audio streaming
        if self._audio_filename.startswith("http://"):
            self._use_data_connection = True
        else:
            # To prevent b2b iterations
            self._use_data_connection = False

        # Check value of VOLUME parameter
        if self._multimedia_volume < 0 or self._multimedia_volume > 100:
            error_msg = "The parameter VOLUME must be an integer between 0 and 100 !"
            self.get_logger().error(error_msg)
            raise AcsConfigException(AcsConfigException.INVALID_PARAMETER, error_msg)

        # FILENAME is an url, enable data connection
        if self._use_data_connection:
            self._enable_data_connection()

        # Get audio file duration
        audio_file_duration = self._multimedia_api.get_media_file_duration(self._audio_filename)

        # Check value of DURATION parameter
        if self._audio_duration == "":
            self.get_logger().warning("The parameter DURATION is empty! The whole audio file will be played.")
            self._audio_duration = audio_file_duration
            # Add a delay to make sure the use case play whole the file
            self._audio_duration += 5

        elif self._audio_duration <= 0:
            error_msg = "The parameter DURATION must be an integer strictly upper than 0 !"
            self.get_logger().error(error_msg)
            raise AcsConfigException(AcsConfigException.INVALID_PARAMETER, error_msg)

        else:
            if self._audio_duration > audio_file_duration:
                self.get_logger().warning("The parameter DURATION is upper than audio file duration ! "
                                          "The whole audio file will be played.")
                self._audio_duration = audio_file_duration
                # Add a delay to make sure the use case play whole the file
                self._audio_duration += 5

        # Disable device lock screen
        self._phonesystem_api.disable_lockscreen(True)
        # Set phone to keep the device display on and wake it up
        self._phonesystem_api.display_on()
        self._phonesystem_api.wake_screen()

        return Global.SUCCESS, "No errors"
Ejemplo n.º 2
0
    def set_up(self):
        """
        Initialize the test
        """
        UseCaseBase.set_up(self)

        # Check mandatory parameter
        if self._channel is None or int(self._channel) <= 0:
            msg = "CHANNEL TC parameter is not defined: " + str(self._channel)
            self._logger.error(msg)
            raise AcsConfigException(AcsConfigException.INVALID_PARAMETER, msg)

        # Specific case for channel 14 in Japan
        if int(self._channel) == 14 and self._dut_crda == "JP" \
                and self._standard.lower() != "b" \
                and not self._connection_expected:
            # this case is prohibited
            msg = "For Channel 14 in Japan, "
            msg += "TC parameter CONNECTION_EXPECTED should be set to True"
            self._logger.error(msg)
            raise AcsConfigException(AcsConfigException.INVALID_PARAMETER, msg)

        # Set AP CRDA
        self._set_ap_generic_crda(self._channel)

        # Call LabWifiBase setup without connection
        LabWifiBase.set_up_without_connect(self)

        self._connection_expected = str_to_bool(str(self._connection_expected))

        # Set DUT regulatory domain
        self._networking_api.set_regulatorydomain(self._dut_crda, self._dut_wlan_iface)
        time.sleep(self._wait_btwn_cmd)

        return Global.SUCCESS, "no_error"
    def set_up(self):
        UseCaseBase.set_up(self)

        def path_join(*args):
            return os.path.normpath(os.path.join(*args))

        # get script root
        env_script_root = os.environ.get('PYUNIT_script_root', None)
        data_root_rel = self._tc_parameters.get_param_value('TEST_DATA_ROOT')

        if (env_script_root is not None):
            script_root = env_script_root
        else:
            matchobj = re.match(r'(.*)TC\/PY_UNIT\/(.*)', self._name, re.I)
            if (matchobj):
                extra_sub_folders = matchobj.group(1) + 'libs/pyunit/'
            else:
                raise Exception("Couldn't parse the script root path, \
                                please set PYUNIT_script_root!")
            script_root = path_join(Paths.EXECUTION_CONFIG, extra_sub_folders)
        test_data_root = path_join(script_root, data_root_rel)
        os.environ['TEST_DATA_ROOT'] = test_data_root
        if script_root not in sys.path:
            sys.path.insert(1, script_root)

        # find case_name
        case_name = self._tc_parameters.get_param_value('TEST_CASE')
        self._logger.info("[PyUnit] case_name: " + case_name)
        module_name = '.'.join(case_name.split('.')[:-2])
        self._logger.info("[PyUnit] module_name: " + module_name)

        # in case, some tests has code executed when imported
        serial_number = self._device.get_serial_number()
        os.environ['preferred_device'] = serial_number

        # load test case
        self.case_module = module_name
        loader = unittest.TestLoader()
        self.suite = loader.loadTestsFromName(case_name)

        # user_log_dir
        crt = self._global_conf.campaignConfig.get("campaignReportTree")
        self._create_log_folder(crt.get_report_path())
        user_log_dir = self._get_rel_path('logs')
        os.mkdir(user_log_dir)

        context = Context(serial_number, user_log_dir)

        try:
            for suite in self.suite:
                if isinstance(suite, unittest.TestCase):
                    suite.contexts = context
                    break
                for test in suite:
                    test.contexts = context
        except Exception:
            self._logger.error("SKIP injext context.")

        self.runner = unittest.TextTestRunner(verbosity=0)
        return Global.SUCCESS, "SUCCESS"
Ejemplo n.º 4
0
    def set_up(self):
        """
        Set up the test configuration
        """
        # Call UseCaseBase Setup function
        UseCaseBase.set_up(self)

        # Check if we have the second phone available
        if self._phone2 is None:
            # We are using this multi UC with only one phone
            error_msg = \
                "This test case requires two phones to be executed !"
            self._logger.error(error_msg)
            raise AcsConfigException(AcsConfigException.INVALID_BENCH_CONFIG,
                                     error_msg)

        # APx Initialization
        if self._audio_analyzer.initialization(self._device.get_phone_model(),
                                               self._test_type) != 0:
            error_msg = \
                "APX Initialization Failed !"
            self._logger.error(error_msg)
            raise TestEquipmentException(
                TestEquipmentException.OPERATION_FAILED, error_msg)

        # Release any previous call (Robustness)
        self._voice_call_api.release()
        self._voice_call_api2.release()

        return Global.SUCCESS, "No errors"
    def set_up(self):
        """
        Set up the test configuration
        """

        # Call use case base Setup function
        UseCaseBase.set_up(self)

        # The Imei is a mandatory value to check
        if self._imei.isdigit() and (len(self._imei) == 15):
            self._logger.info("The expected imei value is %s " % self._imei)
        else:
            self._logger.info("self._imei: %s : %d" % (self._imei, len(self._imei)))

            raise AcsConfigException(AcsConfigException.INVALID_PARAMETER,
                                   "imei value should be 15 decimal digit")

        # IMEISV value is optional, if the value is empty, we won't check it
        if self._imeisv in [None, ""]:
            self._logger.info("The imeisv number will not be checked ")
            self._imeisv = None
        else:
            if  self._imeisv.isdigit() and \
                    (len(self._imeisv) == 16 or len(self._imeisv) == 2):
                self._logger.info("The expected imeisv value is %s " %
                                  self._imeisv)
            else:
                raise AcsConfigException(AcsConfigException.INVALID_PARAMETER,
                                       "imeisv value should be 2 or 16 decimal digit")

        return self._test_result, "No errors"
Ejemplo n.º 6
0
    def set_up(self):
        """
        Initialize the test
        """
        # Call set_up of use case base
        UseCaseBase.set_up(self)

        # Check if we have the second phone available
        if self._phone2 is None:
            # We are using this multi UC with only one phone
            error_msg = \
                "This use case requires two phones to be executed !"
            self._logger.error(error_msg)
            raise AcsConfigException(AcsConfigException.INVALID_BENCH_CONFIG,
                                     error_msg)

        # Boot the other phone (the DUT is already booted)
        if not self._phone2.is_available():
            DeviceManager().boot_device("PHONE2")

        # Disable flight mode
        self._networking_api.set_flight_mode("off")
        self._networking_api2.set_flight_mode("off")

        return Global.SUCCESS, "No errors"
    def set_up(self):
        """
        Initialize the test
        """
        # Call UseCase base Setup function
        UseCaseBase.set_up(self)

        # Check record duration
        if self.__record_duration <= 0:
            error_msg = "Please update TC and set a record duration that is > 0 milliseconds"
            raise AcsConfigException(AcsConfigException.INVALID_PARAMETER,
                                     error_msg)

        # Check save directory
        if self.__save_directory in (None, ""):
            error_msg = "Please update TC and set a saving directory"
            raise AcsConfigException(AcsConfigException.INVALID_PARAMETER,
                                     error_msg)

        # Open camera
        self.__camera_api.launch_camera(self.__camera)
        time.sleep(self._wait_btwn_cmd)

        self.__camera_opened = True

        return (Global.SUCCESS, "No errors")
Ejemplo n.º 8
0
    def set_up(self):
        """
        Set up the test configuration
        """

        # Call UseCase base set_up function
        UseCaseBase.set_up(self)

        # Check equipment connectivity
        self.check_equipment_connectivity(self._eqp_ip_address, self._eqp_port)

        # Read and store MLAPI_DIALOG_MESSAGES table to perform dut commands
        self._parse_mlapi_messages_table()

        # Load the CONFIGURATION_FILE on the equipment
        time.sleep(self._wait_btwn_cmd)
        self._load_configuration_file(self._conf_filename)

        # Set the terminal adapter to remote
        time.sleep(self._wait_btwn_cmd)
        self._set_terminal_adapter("REMOTE")

        # Set equipment to automatic mode
        time.sleep(self._wait_btwn_cmd)
        self._set_automation_control("AUTOMATIC")

        return Global.SUCCESS, "No Errors"
    def set_up(self):
        """
        set up
        """
        UseCaseBase.set_up(self)

        # wake the screen
        self._phonesystem_api.display_on()
        time.sleep(self._wait_btwn_cmd)

        # unlock the screen
        self._phonesystem_api.set_phone_lock(0)
        time.sleep(self._wait_btwn_cmd)

        # set sleep timeout to it's maximum value
        self._phonesystem_api.set_screen_timeout(1800)
        time.sleep(self._wait_btwn_cmd)

        # Open google camera
        self._multimedia_api.open_google_camera()
        time.sleep(self._wait_btwn_cmd)

        # Close first page
        self._logger.debug("Close first Google Photos activity page.")
        self._keyevent_api.scenario(
            ["move_home", "dpad_down", "dpad_down", "enter"])
        time.sleep(self._wait_btwn_cmd)

        return self._error.Code, "No errors"
Ejemplo n.º 10
0
    def set_up(self):
        """
        Initializes the test.
        """
        # Call the inherited set_up method
        # Ugly temporary solution before implementing something
        # better using test steps.
        if self._perform_ims_registration:
            # Call inherited setup method
            self._logger.info("Performing IMS registration step as requested.")
            LiveLteImsReg.set_up(self)
        else:
            # Call the base setup method in order to be
            # compliant with ACS framework
            self._logger.info(
                "Skipping IMS registration step (assumed to be done).")
            UseCaseBase.set_up(self)
            # Simply perform a IMS registration check
            self._networking_api.check_ims_registration_before_timeout(1)

        # Compute the file name on DUT
        self._absolute_path_on_dut = "".join(
            [self._device.multimedia_path, self._ftp_file_basename])

        # Delete the FTP downloaded file on the DUT
        self._delete_file_if_exists(self._absolute_path_on_dut)

        # Disable Flight Mode on the device
        self._networking_api.set_flight_mode("off")

        # Set up is done correctly
        return (Global.SUCCESS, "No errors")
Ejemplo n.º 11
0
    def set_up(self):
        """
        Initialize the test
        """
        # Call UseCase base Setup function
        UseCaseBase.set_up(self)

        # Open camera
        self.__camera_api.launch_camera(self.__camera)
        time.sleep(self._wait_btwn_cmd)

        # Check save directory
        if self.__save_directory is None:
            error_msg = "Save directory is not set, please update the TC"
            self.get_logger().error(error_msg)
            raise AcsConfigException(AcsConfigException.INVALID_PARAMETER, error_msg)

        # check camera flash mode
        if self.__camera_flash_mode is None:
            error_msg = "Flash mode is not set, please update the TC"
            self.get_logger().error(error_msg)
            raise AcsConfigException(AcsConfigException.INVALID_PARAMETER, error_msg)

        # take picture without flash
        ref_picture_file = self.__camera_api.take_picture(self.__save_directory)
        time.sleep(self._wait_btwn_cmd)

        # download picture taken from the DUT
        self.__local_ref_picture_file = self.__camera_api.download_media_file(ref_picture_file, self.__save_folder)
        time.sleep(self._wait_btwn_cmd)

        return (Global.SUCCESS, "No errors")
Ejemplo n.º 12
0
    def set_up(self):
        """
        set up
        """
        UseCaseBase.set_up(self)

        # wake the screen
        self._phonesystem_api.display_on()
        time.sleep(self._wait_btwn_cmd)

        # unlock the screen
        self._phonesystem_api.set_phone_lock(0)
        time.sleep(self._wait_btwn_cmd)

        # set sleep timeout to it's maximum value
        self._phonesystem_api.set_screen_timeout(1800)
        time.sleep(self._wait_btwn_cmd)

        # Get the video from the real video path
        video_id = self._multimedia_api.get_video_id_from_path(
            self._video, self._mediaStoreName)
        time.sleep(self._wait_btwn_cmd)

        #Launch video from is ID
        self._multimedia_api.play_video_from_ID(video_id,
                                                self._video_orientation)
        time.sleep(self._wait_btwn_cmd)

        #Pause the video
        self._keyevent_api.media_play_pause()
        time.sleep(self._wait_btwn_cmd)

        return self._error.Code, "No errors"
Ejemplo n.º 13
0
    def set_up(self):
        """
        UC Setup, do your test configuration here
        """
        UseCaseBase.set_up(self)
        result, output = Global.SUCCESS, ""

        if not self._process_name:
            result, output = Global.FAILURE, "Please specify PROCESS_NAME parameter"

        if not self._am_extra:
            result, output = Global.FAILURE, "Please specify AM_EXTRA parameter"

        if not self._timeout:
            result, output = Global.FAILURE, "Please specify TIMEOUT parameter"

        if result == Global.SUCCESS:
            result, output = self._rm_binary()

        if result == Global.SUCCESS:
            result, output = self._install_files()

        if result == Global.SUCCESS:
            result, output = self._set_properties()

        if result == Global.SUCCESS and self._pre_reboot_device:
            if not self._device.reboot():
                result, output = Global.FAILURE, "Cannot reboot the device"

        return result, output
Ejemplo n.º 14
0
    def set_up(self):
        """
        Set up the test configuration

        """
        UseCaseBase.set_up(self)
        return Global.SUCCESS, "No errors"
Ejemplo n.º 15
0
    def set_up(self):
        """
        set up
        """
        UseCaseBase.set_up(self)

        # wake the screen
        self._phonesystem_api.display_on()
        time.sleep(self._wait_btwn_cmd)

        # unlock the screen
        self._phonesystem_api.set_phone_lock(0)
        time.sleep(self._wait_btwn_cmd)

        # set sleep timeout to it's maximum value
        self._phonesystem_api.set_screen_timeout(1800)
        time.sleep(self._wait_btwn_cmd)

        #Launch app camera2
        self._camera_api.launch_system_camera_application()
        time.sleep(self._wait_btwn_cmd)

        #Close first geo location popup
        self._keyevent_api.scenario(["move_home", "tab", "tab", "enter"])

        return self._error.Code, "No errors"
Ejemplo n.º 16
0
    def set_up(self):
        """
        Initialize the test
        """
        UseCaseBase.set_up(self)

        self.__check_tc_parameters()

        if self._phone2 is not None and not self._phone2.is_available():
            DeviceManager().boot_device(self._device2_name)

        # set wifi On on the DUT to allow regulatory domain to change
        self._networking_api.set_wifi_power("on")
        if self._networking2_api is not None:
            self._networking2_api.set_wifi_power("on")

        # set the regulatory domain
        self._networking_api.set_regulatorydomain(
            LabWifiDirectBase.DEFAULT_REGULATORY_DOMAIN, self._dut1_wlan_iface)
        if self._networking2_api is not None:
            self._networking2_api.set_regulatorydomain(
                LabWifiDirectBase.DEFAULT_REGULATORY_DOMAIN,
                self._dut2_wlan_iface)

        # set wifi Off on the DUT
        self._networking_api.set_wifi_power("off")
        if self._networking2_api is not None:
            self._networking2_api.set_wifi_power("off")

        return Global.SUCCESS, "No error"
    def set_up(self):
        """
        Initialize the test
        """
        # run setup inherit from UseCaseBase
        UseCaseBase.set_up(self)

        # If Bt to be (de-)activated for FIT tests
        if self._bt_fit_used:

            self._bt_initial_state = self._localconnectivity_api.get_bt_power_status()

            # if Bt is not at the wished value, set it to the correct one.
            if self._bt_initial_state != self._bt_wished_value:
                self._localconnectivity_api.set_bt_power(self._bt_wished_value)
                time.sleep(self._wait_btwn_cmd)
        # store original wifi power status
        self._original_wifi_power_status = \
            self._networking_api.get_wifi_power_status()

        # store original flight mode
        time.sleep(self._wait_btwn_cmd)
        self._original_flight_mode = self._networking_api.get_flight_mode()

        # Enable/Disable flight mode
        time.sleep(self._wait_btwn_cmd)
        self._networking_api.set_flight_mode(self._flight_mode)

        # disable wifi for Phone1
        time.sleep(self._wait_btwn_cmd)
        self._networking_api.set_wifi_power("off")

        return Global.SUCCESS, "No error"
    def set_up(self):
        """
        Setup the device :
        - check that NEW_PIN parameter is correct
        - check that SIM state is 'SIM_STATE_READY'
        - check that default PIN code retrieved from phone is correct
        - disable flight mode
        - cancel test if SIM lock feature is
        already enabled, preventing board to get locked (PUK required).
        """
        # Run the inherited 'set_up' method
        UseCaseBase.set_up(self)

        # use default pin and PUK set sim pin back to defaault condition
        self.sim_card_api.set_sim_pin_to_default_condition(
            self.__puk_code, self.__default_pin)

        # turn on mobile broadband
        self.networking_api.reset_mobile_broadband_mode(1)

        # wait for sim is ready
        sim_state = self.sim_card_api.check_sim_state_bfor_timeout(
            "SIM_STATE_READY", 30)
        if sim_state != self.sim_card_api.POSSIBLE_SIM_STATES[
                "SIM_STATE_READY"]:
            self._logger.info("SIM could not reach READY state")
            return Global.FAILURE, "SIM could not reach READY state"

        # Setup check has been successful
        return Global.SUCCESS, "No error"
Ejemplo n.º 19
0
    def set_up(self):
        """
        Initialize the test
        """
        # run setup inherit from UseCaseBase
        UseCaseBase.set_up(self)

        # If Bt to be (de-)activated for FIT tests
        if self._bt_fit_used:

            self._bt_initial_state = self._localconnectivity_api.get_bt_power_status(
            )

            # if Bt is not at the wished value, set it to the correct one.
            if self._bt_initial_state != self._bt_wished_value:
                self._localconnectivity_api.set_bt_power(self._bt_wished_value)
                time.sleep(self._wait_btwn_cmd)

        # Turn Wifi interface ON
        self._networking_api.set_wifi_power("on")
        sleep(self._wait_btwn_cmd)

        # Set a default regulatory domain to enable 5Ghz
        self._networking_api.set_regulatorydomain(
            self._networking_api.get_default_regulatory_domain(),
            self._dut_wlan_iface)

        self._original_band_selection = \
            self._networking_api.get_wifi_frequency_band(self._dut_wlan_iface)

        return Global.SUCCESS, "No error"
Ejemplo n.º 20
0
    def set_up(self):
        """
        Initialize the test.
        """
        # Run UC base run_test
        UseCaseBase.set_up(self)

        # Check the send command before going any further
        if self._cmd_str is None:
            message = "Invalid parameter value: %s for parameter '%s'." % (str(
                self._cmd_str), "RUN_CMD")
            self._logger.error(message)
            raise AcsConfigException(AcsConfigException.INVALID_PARAMETER,
                                     message)

        # Check the expected result str before going any further
        if self._expected_result is None:
            message = "Invalid parameter value: %s for parameter '%s'." % (str(
                self._expected_result), "EXPECTED_RESULT")
            self._logger.error(message)
            raise AcsConfigException(AcsConfigException.INVALID_PARAMETER,
                                     message)

        # Check the test execution timeout before going any further
        if self._test_timeout is None:
            message = "Invalid parameter value: %s for parameter '%s'." % (str(
                self._test_timeout), "EXECUTION_TIMEOUT")
            self._logger.error(message)
            raise AcsConfigException(AcsConfigException.INVALID_PARAMETER,
                                     message)
        # Return the status
        return Global.SUCCESS, "No error."
Ejemplo n.º 21
0
    def set_up(self):
        """
        Initialize the test
        """
        # Call set_up of use case base
        UseCaseBase.set_up(self)

        if not self.__minimum_variation or self.__minimum_variation <= 0.5:
            self.__minimum_variation = 0.5

        # Check if we have the second phone available
        if self.__phone2 is None:
            # We are using this multi UC with only one phone
            error_msg = "This use case requires two phones to be executed !"
            self._logger.error(error_msg)
            raise AcsConfigException(AcsConfigException.INVALID_BENCH_CONFIG,
                                     error_msg)

        # Boot the other phone (the DUT is already booted)
        if not self.__phone2.is_available():
            DeviceManager().boot_device("PHONE2")

        # Disable flight mode
        self.__networking_api.set_flight_mode("off")
        self.__networking_api2.set_flight_mode("off")

        # Phone1: set Ringtone volume to 0%, will be in vibration mode
        self.__system_api.adjust_specified_stream_volume('Ringtone', 0)

        return Global.SUCCESS, "No errors"
Ejemplo n.º 22
0
    def set_up(self):
        UseCaseBase.set_up(self)

        if self.__setup_script is not None:
            result, full_path = self.__get_script_path(self.__setup_script)
            if result == Global.FAILURE:
                return Global.FAILURE, "Cannot find %s" % self.__setup_script
            self.__setup_script = full_path

        result, full_path = self.__get_script_path(self.__run_script)
        if result == Global.FAILURE:
            return Global.FAILURE, "Cannot find %s" % self.__run_script
        self.__run_script = full_path

        if self.__teardown_script is not None:
            result, full_path = self.__get_script_path(self.__teardown_script)
            if result == Global.FAILURE:
                return Global.FAILURE, "Cannot find %s" % self.__teardown_script
            self.__teardown_script = full_path

        if self.__finalize_script is not None:
            result, full_path = self.__get_script_path(self.__finalize_script)
            if result == Global.FAILURE:
                return Global.FAILURE, "Cannot find %s" % self.__finalize_script
            self.__finalize_script = full_path

        verdict = Global.SUCCESS
        message = "Success"
        if self.__setup_script is not None:
            verdict, message = self.__exec_script(self.__setup_script)

        return verdict, message
Ejemplo n.º 23
0
    def set_up(self):
        """
        Initialize the test
        """
        UseCaseBase.set_up(self)

        # Disable flight mode
        self._networking_api.set_flight_mode("off")

        self._initial_pdp_context_status = self._networking_api._get_pdp_context_status(
        )

        # Clear all data connections
        time.sleep(self._wait_btwn_cmd)
        self._networking_api.clean_all_data_connections()

        time.sleep(self._wait_btwn_cmd)

        #Added Airplane mode on/off as cht_hr fails attch to cellular network after cleaning the PDP connection
        self._networking_api.set_flight_mode("on")
        time.sleep(self._wait_btwn_cmd)
        self._networking_api.set_flight_mode("off")

        # Check registration state is connected using
        # registrationTimeout from Device_Catalog.xml (Non blocking
        # for this test if function isn't implemented on CDK)
        self._modem_api.check_cdk_registration_bfor_timeout(
            self._registration_timeout)

        time.sleep(self._wait_btwn_cmd)

        # Configure Preferred Network if set
        self._stored_pref_network = \
            self._dut_config.get("defaultPreferredNetwork")
        if self._network_pref is None:
            # If there is no Network preference in the testcase.
            self._logger.warning("No preferred network set in the testcase,"
                                 " will use the one currently set on the"
                                 " phone: %s" % str(self._stored_pref_network))
        elif self._networking_api.is_preferred_network_type_valid(
                self._network_pref):
            # Setting the DUT preferred network type to the one specified
            # in the TC.
            self._networking_api.\
                set_preferred_network_type(self._network_pref)
            # Check the DUT is camped on a compatible network with the selected
            # preferred network.
            self._modem_api.\
                check_rat_with_pref_network(self._network_pref,
                                            self._registration_timeout)
        else:
            raise AcsConfigException(
                AcsConfigException.INVALID_PARAMETER,
                "Unknown network type: %s" % self._network_pref)

        self._logger.info("Activate PDP Context")
        self._networking_api.activate_pdp_context(check=False)

        return self._error.Code, "No errors"
Ejemplo n.º 24
0
    def set_up(self):
        """
        Setup for the test case
        """

        # Call set_up of use case base
        UseCaseBase.set_up(self)

        # Check if we have the second phone available
        if self._phone2 is None:
            # We are using this multi UC with only one phone
            error_msg = \
                "This use case requires two phones to be executed !"
            self._logger.error(error_msg)
            raise AcsConfigException(AcsConfigException.INVALID_BENCH_CONFIG, error_msg)
        self._sms_api.delete_all_sms()
        # Boot the other phone (the DUT is already booted)
        if not self._phone2.is_available():
            DeviceManager().boot_device("PHONE2")
        if self._default_sim == "SIM2":
            #Setting the sim to Default
            (verdict,msg)=self._setDefaultSecondSim()
        else:
            (verdict,msg)=self._setDefaultSim()

        time.sleep(10)
        self._absolute_path_on_dut = "".join([
            self._device.multimedia_path,
            self._ftp_file_basename])

        # Delete the FTP download file on the DUT
        self._delete_file_if_exists(self._absolute_path_on_dut)

        # Disable flight mode
        self._networking_api.set_flight_mode("off")

        time.sleep(self._wait_btwn_cmd)
        time.sleep(self._wait_btwn_cmd)

        # There is a preferred network to set, backup initial, then set configured one
        if self._network_pref is not None:
            self._initial_pref_network = self._dut_config.get("defaultPreferredNetwork")
            time.sleep(self._wait_btwn_cmd)

            if self._networking_api.is_preferred_network_type_valid(self._network_pref):
                # Setting the DUT preferred network type to the one specified
                # in the TC.
                self._networking_api.set_preferred_network_type(self._network_pref)
                time.sleep(self._wait_btwn_cmd)

                # Check the DUT is camped on a compatible network with the selected
                # preferred network.
                self._modem_api.check_rat_with_pref_network(self._network_pref, self._registration_timeout)
                time.sleep(self._wait_btwn_cmd)
            else:
                raise AcsConfigException(AcsConfigException.INVALID_PARAMETER,
                                         "Unknown network type: %s" % self._network_pref)

        return verdict,msg
Ejemplo n.º 25
0
    def set_up(self):
        """
        Setup the device :
        Device contains a SIM card, and SIM PIN check is activated on it.
        Device SIM is not blocked
        """
        # Run the inherited 'set_up' method
        UseCaseBase.set_up(self)

        # Check that current pin is correct
        if not is_pin_valid(self.__pin_code):
            raise AcsConfigException(AcsConfigException.INVALID_BENCH_CONFIG,
                        "Current PIN code is incorrect : it must be a number"
                        " containing 4 to 8 digits. You must override device "
                        "parameter 'defaultPINCode' in the bench config.")

        # Check that current puk is correct
        if not is_puk_valid(self.__puk_code):
            raise AcsConfigException(AcsConfigException.INVALID_BENCH_CONFIG,
                        "Current PUK code is incorrect : it must be a number"
                        " containing 8 digits. You must override device "
                        "parameter 'simPUKCode' in the bench config.")

        # Check that device contain a SIM CARD
        sim_state = self.sim_card_api.get_sim_state()
        if sim_state == \
                self.sim_card_api.POSSIBLE_SIM_STATES["SIM_STATE_ABSENT"]:
            raise DeviceException(DeviceException.INVALID_DEVICE_STATE,
                   "SIM state is not present : cancel test"
                   " execution")

        # Check that device's SIM is not locked by PUK
        sim_state = self.sim_card_api.get_sim_state()
        if sim_state == self.sim_card_api.POSSIBLE_SIM_STATES["SIM_STATE_PUK_REQUIRED"]:
            # Unlock SIM
            self.sim_card_api.supply_puk(self.__puk_code, self.__pin_code)

        # Ensure that flight mode is disabled
        self.networking_api.set_flight_mode("off")
        time.sleep(self._wait_btwn_cmd)

        self.sim_card_api.check_sim_state_bfor_timeout("SIM_STATE_READY", 30)

        # Make sure that Device initial state is correct
        is_enabled = self.sim_card_api.get_sim_lock_state()
        if not is_enabled:
            self._logger.info("SIM lock system not yet enabled, enabling it")
            self.sim_card_api.enable_sim_lock_system(self.__pin_code)

        is_enabled = self.sim_card_api.get_sim_lock_state()

        if not is_enabled:
            raise DeviceException(DeviceException.INVALID_DEVICE_STATE,
                        "SIM lock system not enabled : "
                        "cancel test because initial condition not "
                        "respected")

        # Setup check has been successful
        return Global.SUCCESS, "No error"
Ejemplo n.º 26
0
    def set_up(self):
        """
        Initialize the test
        """
        UseCaseBase.set_up(self)

        # Check save directory
        if self.__save_directory in (None, ""):
            error_msg = "Please update TC and set a saving directory"
            raise AcsConfigException(AcsConfigException.INVALID_PARAMETER, error_msg)

        # Open camera
        self.__camera_api.launch_camera(self.__camera)
        time.sleep(self._wait_btwn_cmd)

        try:
            #Set exposure mode
            self.__camera_api.set_exposure_mode(0)
            time.sleep(self._wait_btwn_cmd)
        except AcsConfigException:
            self._logger.warning("UseCase tried to set camera parameter exposure mode on a device that does not "
                                 "support this parameter.")
        except DeviceException:
            self._logger.warning("UseCase tried to set camera parameter exposure mode on a device that does not "
                                 "support this parameter.")

        #Set picture resolution
        self.__camera_api.set_picture_size(640, 480)
        time.sleep(self._wait_btwn_cmd)

        #Set white balance
        self.__camera_api.set_white_balance('auto')
        time.sleep(self._wait_btwn_cmd)

        #Set flash mode
        try:
            #if flash mode is not supported by device, then catch the exception here
            self.__camera_api.set_flash_mode('auto')
            time.sleep(self._wait_btwn_cmd)
        except AcsConfigException:
            self._logger.warning("UseCase tried to set camera parameter flash on a device that does not support this "
                                 "parameter.")
        except DeviceException:
            self._logger.warning("UseCase tried to set camera parameter flash on a device that does not support this "
                                 "parameter.")

        #Set scene mode
        try:
            self.__camera_api.set_scene_mode('auto')
            time.sleep(self._wait_btwn_cmd)
        except AcsConfigException:
            self._logger.warning("UseCase tried to set camera parameter scene mode on a device that does not support "
                                 "this parameter.")
        except DeviceException:
            self._logger.warning("UseCase tried to set camera parameter scene mode on a device that does not support "
                                 "this parameter.")

        result, output = Global.SUCCESS, ""
        return Global.SUCCESS, ""
    def set_up(self):
        """
        Initialize the test
        """
        # call the UseCaseBase Setup function
        UseCaseBase.set_up(self)

        self._logger.info("Checking if battery is as requested for the test: capacity > %s%%"\
                           % str(self._min_capacity))

        # check initial battery's capacity
        duration = datetime.datetime.now() + timedelta(
            seconds=self._charging_timeout)

        # charging DUT if it's capacity is under the minimum capacity's value
        # required for test and specified in the testcase.
        while int(self.em_api.get_msic_registers()['BATTERY']['CAPACITY']
                  [0]) < self._min_capacity:
            self._logger.info("Charging DUT for %s ms" %
                              str(duration - datetime.datetime.now()))
            time.sleep(self._charge_duration)

            if datetime.datetime.now() > duration:
                error_text = "Capacity after charging (%s%%) is lower than the minimum value required for the test"\
                "(%s%%)" % (str(self.em_api.get_msic_registers()['BATTERY']['CAPACITY'][0]), str(self._min_capacity))
                raise DeviceException(DeviceException.OPERATION_FAILED,
                                      error_text)

        # store initial Sleep Timeout value
        self._initial_seleep_timeout_value = self.phonesystem_api.get_screen_timeout(
        )
        time.sleep(self._wait_btwn_cmd)

        # wake the screen
        self.phonesystem_api.display_on()
        time.sleep(self._wait_btwn_cmd)

        # unlock the screen
        self.phonesystem_api.set_phone_lock(0)
        time.sleep(self._wait_btwn_cmd)

        # start camera
        self.camera_api.launch_camera("BACK")
        time.sleep(self._wait_btwn_cmd)

        # set camera flash mode to torch
        self.camera_api.set_flash_mode("torch")
        time.sleep(self._wait_btwn_cmd)

        # set brightness to it's maximum value
        self.phonesystem_api.set_display_brightness(100)
        time.sleep(self._wait_btwn_cmd)

        # set sleep timeout to it's maximum value
        self.phonesystem_api.set_screen_timeout(1800)
        time.sleep(self._wait_btwn_cmd)

        return Global.SUCCESS, "No errors"
Ejemplo n.º 28
0
    def set_up(self):
        """
        Initialize the test
        """

        UseCaseBase.set_up(self)
        self._logcat_extract = os.path.join(Folders.REPORTS,
                                            "parserlogcat.log")
        return Global.SUCCESS, ""
Ejemplo n.º 29
0
 def set_up(self):
     UseCaseBase.set_up(self)
     if not self._time_btw:
         raise AcsConfigException(AcsConfigException.INVALID_PARAMETER,
                                  "Time Between Events cannot be empty")
     if not self._nr_events:
         raise AcsConfigException(AcsConfigException.INVALID_PARAMETER,
                                  "Number of Events cannot be empty")
     return Global.SUCCESS, "No errors"
Ejemplo n.º 30
0
    def set_up(self):
        """
        Initialize the test
        """
        UseCaseBase.set_up(self)
        adb_chmod = "adb shell chmod -R 777 /data/app/"
        chmod_res, chmod_output = self._device.run_cmd(adb_chmod, 20)

        return Global.SUCCESS, "No errors"