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 5 6class App(object): 7 """ A running application instance that can be controlled in a limited way. 8 9 Be sure to clean up after yourself by calling Close() when you are done with 10 the app. Or better yet: 11 with possible_app.Create(options) as app: 12 ... do all your operations on app here 13 """ 14 def __init__(self, app_backend, platform_backend): 15 assert platform_backend.platform != None 16 self._app_backend = app_backend 17 self._platform_backend = platform_backend 18 self._app_backend.SetApp(self) 19 20 @property 21 def app_type(self): 22 return self._app_backend.app_type 23 24 @property 25 def platform(self): 26 return self._platform_backend.platform 27 28 def __enter__(self): 29 return self 30 31 def __exit__(self, *args): 32 self.Close() 33 34 def Close(self): 35 raise NotImplementedError() 36 37 def GetStandardOutput(self): 38 return self._app_backend.GetStandardOutput() 39 40 def GetStackTrace(self): 41 return self._app_backend.GetStackTrace() 42