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

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: Fix a couple errors 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 ddd84688b458fc971aafe2c967044cc2f2f6b5c2..b949e4f4a62ede203ab4bc18404d8f3697495df0 100644
--- a/tools/telemetry/telemetry/core/backends/android_app_backend.py
+++ b/tools/telemetry/telemetry/core/backends/android_app_backend.py
@@ -2,9 +2,36 @@
# 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, 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
+ @property
+ def _adb(self):
+ return self._android_platform_backend.adb
-class AndroidAppBackend(app_backend.AppBackend):
- def __init__(self):
- super(AndroidAppBackend, self).__init__()
+ def Start(self):
+
+ self._adb.device().StartActivity(self._start_intent, blocking=False)
+
+ # Wait for the app to come up.
+ #
+ # HACK(chrishenry): Need a better way to do this. For a
+ # WebView-based app, where the app brings up WebView at startup,
+ # we can wait for the WebView, for other app, need to figure out
+ # the right thing to do here.
chrishenry 2014/12/05 06:21:01 Update the HACK comment to say something about che
slamm 2014/12/05 18:19:23 Instead of searching for the app in 'ps', I change
chrishenry 2014/12/05 18:22:36 There was a comment from wuhu in the original hack
+ import logging; logging.warn('Sleeping after start.')
nednguyen 2014/12/05 02:24:06 Let's just wait for pid to come up in this one. Cu
slamm 2014/12/05 18:19:23 Acknowledged.
+ time.sleep(10)
chrishenry 2014/12/05 06:21:01 Let's keep this here, but update the HACK remark t
slamm 2014/12/05 18:19:23 Done.
+
+ def Close(self):
+ self._android_platform_backend.KillApplication(self._start_intent.package)

Powered by Google App Engine
This is Rietveld 408576698