1# Copyright 2012 The Chromium Authors. All rights reserved. 2# Use of this source code is governed by a BSD-style license that can be 3# found in the LICENSE file. 4 5from telemetry.internal import app 6 7 8class AndroidApp(app.App): 9 """A running android app instance that can be controlled in a limited way. 10 11 Be sure to clean up after yourself by calling Close() when you are done with 12 the app. Or better yet: 13 with possible_android_app.Create(options) as android_app: 14 ... do all your operations on android_app here 15 """ 16 def __init__(self, app_backend, platform_backend): 17 super(AndroidApp, self).__init__(app_backend=app_backend, 18 platform_backend=platform_backend) 19 self._app_backend.Start() 20 21 @property 22 def ui(self): 23 """Returns an AppUi object to interact with the app's UI. 24 25 See devil.android.app_ui for the documentation of the API provided. 26 """ 27 return self._app_backend.GetAppUi() 28 29 def Close(self): 30 self._app_backend.Close() 31 32 def GetProcesses(self): 33 """Returns the current set of processes belonging to this app.""" 34 return self._app_backend.GetProcesses() 35 36 def GetProcess(self, subprocess_name): 37 """Returns the process with the specified subprocess name.""" 38 return self._app_backend.GetProcess(subprocess_name) 39 40 def GetWebViews(self): 41 """Returns the set of all WebViews belonging to all processes of the app.""" 42 return self._app_backend.GetWebViews() 43