def testComposition(self): class P1(power_monitor.PowerMonitor): def StartMonitoringPower(self, browser): raise NotImplementedError() def StopMonitoringPower(self): raise NotImplementedError() class P2(power_monitor.PowerMonitor): def __init__(self, value): self._value = value def CanMonitorPower(self): return True def StartMonitoringPower(self, browser): pass def StopMonitoringPower(self): return self._value controller = power_monitor_controller.PowerMonitorController( [P1(), P2(1), P2(2)]) self.assertEqual(controller.CanMonitorPower(), True) controller.StartMonitoringPower(None) self.assertEqual(controller.StopMonitoringPower(), 1)
def __init__(self, device, finder_options): assert device, ( 'AndroidPlatformBackend can only be initialized from remote device' ) super(AndroidPlatformBackend, self).__init__(device) self._adb = adb_commands.AdbCommands(device=device.device_id) installed_prebuilt_tools = _SetupPrebuiltTools(self._adb) if not installed_prebuilt_tools: logging.error( '%s detected, however prebuilt android tools could not ' 'be used. To run on Android you must build them first:\n' ' $ ninja -C out/Release android_tools' % device.name) raise exceptions.PlatformError() # Trying to root the device, if possible. if not self._adb.IsRootEnabled(): # Ignore result. self._adb.EnableAdbRoot() self._device = self._adb.device() self._battery = battery_utils.BatteryUtils(self._device) self._enable_performance_mode = device.enable_performance_mode self._surface_stats_collector = None self._perf_tests_setup = perf_control.PerfControl(self._device) self._thermal_throttle = thermal_throttle.ThermalThrottle(self._device) self._raw_display_frame_rate_measurements = [] try: self._can_access_protected_file_contents = (self._device.HasRoot() or self._device.NeedsSU()) except: logging.exception('New exception caused by DeviceUtils conversion') raise self._device_copy_script = None power_controller = power_monitor_controller.PowerMonitorController([ monsoon_power_monitor.MonsoonPowerMonitor(self._device, self), android_ds2784_power_monitor.DS2784PowerMonitor( self._device, self), android_dumpsys_power_monitor.DumpsysPowerMonitor( self._battery, self), ]) self._power_monitor = android_temperature_monitor.AndroidTemperatureMonitor( power_controller, self._device) self._video_recorder = None self._installed_applications = None self._wpr_ca_cert_path = None self._device_cert_util = None self._is_test_ca_installed = False self._use_rndis_forwarder = ( finder_options.android_rndis or finder_options.browser_options.netsim or platform.GetHostPlatform().GetOSName() != 'linux') _FixPossibleAdbInstability()
def __init__(self, adb, no_performance_mode): super(AndroidPlatformBackend, self).__init__() self._adb = adb self._surface_stats_collector = None self._perf_tests_setup = perf_control.PerfControl(self._adb) self._thermal_throttle = thermal_throttle.ThermalThrottle(self._adb) self._no_performance_mode = no_performance_mode self._raw_display_frame_rate_measurements = [] self._host_platform_backend = factory.GetPlatformBackendForCurrentOS() self._can_access_protected_file_contents = \ self._adb.CanAccessProtectedFileContents() self._powermonitor = power_monitor_controller.PowerMonitorController([ monsoon_power_monitor.MonsoonPowerMonitor(), android_ds2784_power_monitor.DS2784PowerMonitor(adb) ]) self._video_recorder = None self._video_output = None if self._no_performance_mode: logging.warning('CPU governor will not be set!')
def __init__(self, device, no_performance_mode): super(AndroidPlatformBackend, self).__init__() self._device = device self._surface_stats_collector = None self._perf_tests_setup = perf_control.PerfControl(self._device) self._thermal_throttle = thermal_throttle.ThermalThrottle(self._device) self._no_performance_mode = no_performance_mode self._raw_display_frame_rate_measurements = [] self._can_access_protected_file_contents = \ self._device.old_interface.CanAccessProtectedFileContents() power_controller = power_monitor_controller.PowerMonitorController([ monsoon_power_monitor.MonsoonPowerMonitor(), android_ds2784_power_monitor.DS2784PowerMonitor(device), android_dumpsys_power_monitor.DumpsysPowerMonitor(device), ]) self._power_monitor = android_temperature_monitor.AndroidTemperatureMonitor( power_controller, device) self._video_recorder = None if self._no_performance_mode: logging.warning('CPU governor will not be set!')
def __init__(self, device): assert device, ( 'AndroidPlatformBackend can only be initialized from remote device' ) super(AndroidPlatformBackend, self).__init__(device) self._adb = adb_commands.AdbCommands(device=device.device_id) installed_prebuilt_tools = adb_commands.SetupPrebuiltTools(self._adb) if not installed_prebuilt_tools: logging.error( '%s detected, however prebuilt android tools could not ' 'be used. To run on Android you must build them first:\n' ' $ ninja -C out/Release android_tools' % device.name) raise exceptions.PlatformError() # Trying to root the device, if possible. if not self._adb.IsRootEnabled(): # Ignore result. self._adb.EnableAdbRoot() self._device = self._adb.device() self._enable_performance_mode = device.enable_performance_mode self._surface_stats_collector = None self._perf_tests_setup = perf_control.PerfControl(self._device) self._thermal_throttle = thermal_throttle.ThermalThrottle(self._device) self._raw_display_frame_rate_measurements = [] self._can_access_protected_file_contents = \ self._device.old_interface.CanAccessProtectedFileContents() power_controller = power_monitor_controller.PowerMonitorController([ monsoon_power_monitor.MonsoonPowerMonitor(self._device, self), android_ds2784_power_monitor.DS2784PowerMonitor( self._device, self), android_dumpsys_power_monitor.DumpsysPowerMonitor( self._device, self), ]) self._power_monitor = android_temperature_monitor.AndroidTemperatureMonitor( power_controller, self._device) self._video_recorder = None self._installed_applications = None self._wpr_ca_cert_path = None self._device_cert_util = None self._is_test_ca_installed = False