Skip to content

Commit

Permalink
去除无关error log,增加instrument尝试启动
Browse files Browse the repository at this point in the history
(cherry picked from commit 61957a9ffb6224d08127fe964d16ba758a552342)
  • Loading branch information
android-A-studio authored and yimelia committed Dec 22, 2023
1 parent 33ee264 commit a90663b
Showing 1 changed file with 13 additions and 7 deletions.
20 changes: 13 additions & 7 deletions poco/drivers/android/uiautomation.py
Original file line number Diff line number Diff line change
Expand Up @@ -113,10 +113,6 @@ def stopped(self):

def run(self):
while not self.stopped():
if getattr(self.poco, "_instrument_proc", None) is not None:
stdout, stderr = self.poco._instrument_proc.communicate()
print('[pocoservice.apk] stdout: {}'.format(stdout))
print('[pocoservice.apk] stderr: {}'.format(stderr))
if not self.stopped():
self.poco._start_instrument(self.port_to_ping) # 尝试重启
time.sleep(1)
Expand Down Expand Up @@ -256,9 +252,9 @@ def _start_instrument(self, port_to_ping, force_restart=False):
self.adb_client.shell('am start -n {}/.TestActivity'.format(PocoServicePackage))

instrumentation_cmd = [
'am', 'instrument', '-w', '-e', 'debug', 'false', '-e', 'class',
'{}.InstrumentedTestAsLauncher'.format(PocoServicePackage),
'{}/androidx.test.runner.AndroidJUnitRunner'.format(PocoServicePackage)]
'am', 'instrument', '-w', '-e', 'debug', 'false', '-e', 'class',
'{}.InstrumentedTestAsLauncher'.format(PocoServicePackage),
'{}/androidx.test.runner.AndroidJUnitRunner'.format(PocoServicePackage)]
self._instrument_proc = self.adb_client.start_shell(instrumentation_cmd)

def cleanup_proc(proc):
Expand Down Expand Up @@ -287,7 +283,17 @@ def wrapped():
print('[pocoservice.apk] stderr: {}'.format(stderr))
time.sleep(1)
print("still waiting for uiautomation ready.")
try:
self.adb_client.shell(
['monkey', '-p', {PocoServicePackage}, '-c', 'android.intent.category.LAUNCHER', '1'])
except Exception as e:
pass
self.adb_client.shell('am start -n {}/.TestActivity'.format(PocoServicePackage))
instrumentation_cmd = [
'am', 'instrument', '-w', '-e', 'debug', 'false', '-e', 'class',
'{}.InstrumentedTestAsLauncher'.format(PocoServicePackage),
'{}/androidx.test.runner.AndroidJUnitRunner'.format(PocoServicePackage)]
self._instrument_proc = self.adb_client.start_shell(instrumentation_cmd)
continue
return ready

Expand Down

0 comments on commit a90663b

Please sign in to comment.