Lines Matching refs:self
74 def __init__(self, message): argument
75 self._error_message = message
76 def __str__(self): argument
77 return self._error_message
150 def __init__(self, max_baseline_amps): argument
159 self._power_monitor = power_monitors.Power_Monitor(log_file_id = testid)
160 self._tcp_connect_port = 0 # any available port
162 self.setUsbEnabled(True)
163 status = self._power_monitor.GetStatus()
164 self._native_hz = status["sampleRate"] * 1000
167 self._current_test = "None"
168 self._external_storage = self.executeOnDevice(PowerTest.REQUEST_EXTERNAL_STORAGE)
169 self._max_baseline_amps = max_baseline_amps
171 def __del__(self): argument
172 self.finalize()
174 def finalize(self): argument
176 if self._tcp_connect_port > 0:
179 self.executeOnDevice(PowerTest.REQUEST_EXIT, reportErrors = False)
180 self.executeLocal("adb forward --remove tcp:%d" % self._tcp_connect_port)
181 self._tcp_connect_port = 0
182 if self._power_monitor:
183 self._power_monitor.Close()
184 self._power_monitor = None
186 def _send(self, msg, report_errors = True): argument
188 if self._tcp_connect_port == 0:
195 (_, self._tcp_connect_port) = dummysocket.getsockname()
197 assert(self._tcp_connect_port > 0)
199 status = self.executeLocal("adb forward tcp:%d localabstract:%s" %
200 (self._tcp_connect_port, PowerTest.DOMAIN_NAME))
204 self.endTestIfLostConnection(
208 self._tcp_connect_port)
214 link.connect(("localhost", self._tcp_connect_port))
219 self.endTestIfLostConnection(
233 def queryDevice(self, query): argument
236 return self._send(query) == "OK"
239 def executeOnDevice(self, cmd, reportErrors = True): argument
241 return self._send(cmd, reportErrors)
243 def executeLocal(self, cmd, check_status = True): argument
253 def reportErrorRaiseExceptionIf(self, condition, msg): argument
265 self.executeOnDevice(PowerTest.REQUEST_RAISE % (self._current_test, msg),
270 self.finalize()
274 def endTestIfLostConnection(self, lost_connection, error_message): argument
288 self.finalize()
291 def setUsbEnabled(self, enabled, verbose = True): argument
296 self._power_monitor.SetUsbPassthrough(val)
302 status = self._power_monitor.GetStatus()
307 self._power_monitor.StopDataCollection()
308 self._power_monitor.SetUsbPassthrough(val)
309 status = self._power_monitor.GetStatus()
314 self.executeLocal("adb wait-for-device")
321 if enabled and self._tcp_connect_port > 0:
322 status = self.executeLocal("adb forward tcp:%d localabstract:%s" %
323 (self._tcp_connect_port, PowerTest.DOMAIN_NAME))
324 …self.reportErrorRaiseExceptionIf(status != 0, msg = "Unable to forward requests to client over adb…
326 def computeBaselineState(self, measurements): argument
388 if median_measurement > self._max_baseline_amps:
405 def isApInSuspendState(self, measurements_amps, nominal_max_amps, test_percentile): argument
432 def getBaselineState(self): argument
446 self.setPowerOn("ALL", False)
447 self.setUsbEnabled(False)
463 measurements = self.collectMeasurements(
466 if self.computeBaselineState(measurements)[0] is True:
473 measurements = self.collectMeasurements(
476 self.reportErrorRaiseExceptionIf(
478 retval = self.computeBaselineState(measurements)
489 def waitForApSuspendMode(self): argument
509 measurements = self.collectMeasurements(NUMBER_MEASUREMENTS,
512 if self.isApInSuspendState(
517 self.reportErrorRaiseExceptionIf(
523 def collectMeasurements(self, measurementCount, rate, verbose = True): argument
534 decimate_by = self._native_hz / rate or 1
536 self._power_monitor.StartDataCollection()
544 self._power_monitor.StopDataCollection()
545 self._power_monitor.StartDataCollection()
548 additional = self._power_monitor.CollectData()
564 self._power_monitor.StopDataCollection()
566 self.reportErrorRaiseExceptionIf(measurementCount > len(measurements),
570 def requestUserAcknowledgment(self, msg): argument
572 response = self.executeOnDevice(PowerTest.REQUEST_USER_RESPONSE % msg)
573 self.reportErrorRaiseExceptionIf(
576 def setTestResult(self, test_name, test_result, test_message): argument
587 self.executeOnDevice(
590 self.reportErrorRaiseExceptionIf(
593 def setPowerOn(self, sensor, powered_on): argument
594 response = self.executeOnDevice(PowerTest.REQUEST_SENSOR_SWITCH %
596 self.reportErrorRaiseExceptionIf(
602 self, sensor, max_amperes_allowed, baseline_amps, user_request = None): argument
615 self._current_test = ("%s_Power_Test_While_%s" % (
624 response = self.executeOnDevice(
627 self.setTestResult(
628 self._current_test, test_result = "SKIPPED",
630 self.setPowerOn("ALL", False)
632 self.setTestResult(
633 self._current_test, test_result = "SKIPPED",
636 self.reportErrorRaiseExceptionIf(response != "OK", "Unable to set all sensor off")
637 self.executeOnDevice(PowerTest.REQUEST_SCREEN_OFF)
638 self.setUsbEnabled(False)
639 self.setUsbEnabled(True)
640 self.setPowerOn(sensor, True)
645 self.requestUserAcknowledgment(user_request)
646 self.executeOnDevice(PowerTest.REQUEST_SCREEN_OFF)
647 self.setUsbEnabled(False)
648 self.reportErrorRaiseExceptionIf(
651 self.waitForApSuspendMode()
653 measurements = self.collectMeasurements(PowerTest.SAMPLE_COUNT_NOMINAL,
661 self.setUsbEnabled(True, verbose = False)
663 self.executeLocal("adb shell mkdir -p %s" % self._external_storage, False)
664 self.executeLocal("adb push %s %s/." % (f.name, self._external_storage))
665 self.setUsbEnabled(False, verbose = False)
666 self.reportErrorRaiseExceptionIf(
673 self.setUsbEnabled(True)
688 self.setTestResult(
689 self._current_test,
695 self.setTestResult(self._current_test, test_result = "FAIL",