| OLD | NEW |
| 1 # Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 # Copyright (c) 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 import json | 5 import json |
| 6 import logging | 6 import logging |
| 7 import os | 7 import os |
| 8 import subprocess | 8 import subprocess |
| 9 import sys | 9 import sys |
| 10 import tempfile | 10 import tempfile |
| 11 import time | 11 import time |
| 12 | 12 |
| 13 from telemetry import adb_commands | 13 from telemetry import adb_commands |
| 14 from telemetry import browser_backend | 14 from telemetry import browser_backend |
| 15 from telemetry import browser_gone_exception | 15 from telemetry import browser_gone_exception |
| 16 | 16 |
| 17 class AndroidBrowserBackend(browser_backend.BrowserBackend): | 17 class AndroidBrowserBackend(browser_backend.BrowserBackend): |
| 18 """The backend for controlling a browser instance running on Android. | 18 """The backend for controlling a browser instance running on Android. |
| 19 """ | 19 """ |
| 20 def __init__(self, options, adb, package, | 20 def __init__(self, options, adb, package, |
| 21 is_content_shell, cmdline_file, activity, devtools_remote_port): | 21 is_content_shell, cmdline_file, activity, devtools_remote_port): |
| 22 super(AndroidBrowserBackend, self).__init__(is_content_shell, options) | 22 super(AndroidBrowserBackend, self).__init__(is_content_shell, options) |
| 23 if len(options.extensions_to_load) > 0: |
| 24 raise Exception('Cannot load extensions for android browser!') |
| 23 # Initialize fields so that an explosion during init doesn't break in Close. | 25 # Initialize fields so that an explosion during init doesn't break in Close. |
| 24 self._options = options | 26 self._options = options |
| 25 self._adb = adb | 27 self._adb = adb |
| 26 self._package = package | 28 self._package = package |
| 27 self._cmdline_file = cmdline_file | 29 self._cmdline_file = cmdline_file |
| 28 self._activity = activity | 30 self._activity = activity |
| 29 if not options.keep_test_server_ports: | 31 if not options.keep_test_server_ports: |
| 30 adb_commands.ResetTestServerPortAllocation() | 32 adb_commands.ResetTestServerPortAllocation() |
| 31 self._port = adb_commands.AllocateTestServerPort() | 33 self._port = adb_commands.AllocateTestServerPort() |
| 32 self._devtools_remote_port = devtools_remote_port | 34 self._devtools_remote_port = devtools_remote_port |
| (...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 179 '-dump', f.name], stdout=subprocess.PIPE).communicate()[0] | 181 '-dump', f.name], stdout=subprocess.PIPE).communicate()[0] |
| 180 except Exception: | 182 except Exception: |
| 181 pass | 183 pass |
| 182 if symbolized_stack: | 184 if symbolized_stack: |
| 183 return symbolized_stack | 185 return symbolized_stack |
| 184 # Otherwise, just return the last 100 lines of logcat. | 186 # Otherwise, just return the last 100 lines of logcat. |
| 185 return '\n'.join(self._adb.RunShellCommand('logcat -d -t 100')) | 187 return '\n'.join(self._adb.RunShellCommand('logcat -d -t 100')) |
| 186 | 188 |
| 187 def CreateForwarder(self, *port_pairs): | 189 def CreateForwarder(self, *port_pairs): |
| 188 return adb_commands.Forwarder(self._adb, *port_pairs) | 190 return adb_commands.Forwarder(self._adb, *port_pairs) |
| OLD | NEW |