| OLD | NEW |
| 1 # Copyright 2012 The Chromium Authors. All rights reserved. | 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 | 2 # Use of this source code is governed by a BSD-style license that can be |
| 3 # found in the LICENSE file. | 3 # found in the LICENSE file. |
| 4 | 4 |
| 5 | 5 |
| 6 class App(object): | 6 class App(object): |
| 7 """ A running application instance that can be controlled in a limited way. | 7 """ A running application instance that can be controlled in a limited way. |
| 8 | 8 |
| 9 Be sure to clean up after yourself by calling Close() when you are done with | 9 Be sure to clean up after yourself by calling Close() when you are done with |
| 10 the app. Or better yet: | 10 the app. Or better yet: |
| 11 with possible_app.Create(options) as app: | 11 with possible_app.Create(options) as app: |
| 12 ... do all your operations on app here | 12 ... do all your operations on app here |
| 13 """ | 13 """ |
| 14 def __init__(self, app_backend, platform_backend): | 14 def __init__(self, app_backend, platform_backend): |
| 15 assert platform_backend.platform != None | 15 assert platform_backend.platform != None |
| 16 | 16 |
| 17 self._app_backend = app_backend | 17 self._app_backend = app_backend |
| 18 self._platform_backend = platform_backend | 18 self._platform_backend = platform_backend |
| 19 | 19 |
| 20 @property | 20 @property |
| 21 def app_backend(self): |
| 22 return self._app_backend |
| 23 |
| 24 @property |
| 21 def app_type(self): | 25 def app_type(self): |
| 22 return self._app_backend.app_type | 26 return self.app_backend.app_type |
| 23 | 27 |
| 24 @property | 28 @property |
| 25 def platform(self): | 29 def platform(self): |
| 26 return self._platform_backend.platform | 30 return self._platform_backend.platform |
| 27 | 31 |
| 28 def __enter__(self): | 32 def __enter__(self): |
| 29 return self | 33 return self |
| 30 | 34 |
| 31 def __exit__(self, *args): | 35 def __exit__(self, *args): |
| 32 self.Close() | 36 self.Close() |
| 33 | 37 |
| 34 def Close(self): | 38 def Close(self): |
| 35 raise NotImplementedError() | 39 raise NotImplementedError() |
| 36 | 40 |
| 37 def GetStandardOutput(self): | 41 def GetStandardOutput(self): |
| 38 return self._app_backend.GetStandardOutput() | 42 return self._app_backend.GetStandardOutput() |
| 39 | 43 |
| 40 def GetStackTrace(self): | 44 def GetStackTrace(self): |
| 41 return self._app_backend.GetStackTrace() | 45 return self._app_backend.GetStackTrace() |
| OLD | NEW |