Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(434)

Unified Diff: tools/telemetry/telemetry/core/backends/android_app_backend.py

Issue 776883004: Basic android app implementation (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: More review comments. Created 6 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: tools/telemetry/telemetry/core/backends/android_app_backend.py
diff --git a/tools/telemetry/telemetry/core/backends/android_app_backend.py b/tools/telemetry/telemetry/core/backends/android_app_backend.py
index ac38ae13bd3505bc37386569ffd19ff41a81fbc4..e328163e18c3150a28bde84c3ea224489b7688ff 100644
--- a/tools/telemetry/telemetry/core/backends/android_app_backend.py
+++ b/tools/telemetry/telemetry/core/backends/android_app_backend.py
@@ -2,25 +2,48 @@
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
+import time
+
from telemetry.core.backends import app_backend
+from telemetry.core.platform import android_platform_backend as \
+ android_platform_backend_module
class AndroidAppBackend(app_backend.AppBackend):
- def __init__(self):
- super(AndroidAppBackend, self).__init__()
+ def __init__(self, android_platform_backend, start_intent):
+ super(AndroidAppBackend, self).__init__(app_type=start_intent.package)
+ assert isinstance(android_platform_backend,
+ android_platform_backend_module.AndroidPlatformBackend)
+ self._android_platform_backend = android_platform_backend
+ self._start_intent = start_intent
+ self._is_running = False
@property
def pid(self):
raise NotImplementedError
+ @property
+ def _adb(self):
+ return self._android_platform_backend.adb
+
def Start(self):
- raise NotImplementedError
+ """Start an Android app and wait for it to finish launching.
+
+ AppStory derivations can customize the wait-for-ready-state to wait
+ for a more specific event if needed.
+ """
+ # TODO(slamm): check if can use "blocking=True" instead of needing to sleep.
+ # If "blocking=True" does not work, switch sleep to "ps" check.
+ self._adb.device().StartActivity(self._start_intent, blocking=False)
+ time.sleep(9)
+ self._is_running = True
def Close(self):
- raise NotImplementedError
+ self._is_running = False
+ self._android_platform_backend.KillApplication(self._start_intent.package)
def IsAppRunning(self):
- raise NotImplementedError
+ return self._is_running
def GetStandardOutput(self):
raise NotImplementedError

Powered by Google App Engine
This is Rietveld 408576698