Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 # Copyright 2014 The Chromium Authors. All rights reserved. | 1 # Copyright 2014 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 unittest | 5 import unittest |
| 6 | 6 |
| 7 from profile_chrome import profiler | 7 from profile_chrome import profiler |
| 8 | 8 |
| 9 from devil.android import device_utils | 9 from devil.android import device_utils |
| 10 from devil.android.sdk import intent | 10 from devil.android.sdk import intent |
| 11 from devil.android.sdk import keyevent | |
| 11 | 12 |
| 12 | 13 |
| 13 class BaseAgentTest(unittest.TestCase): | 14 class BaseAgentTest(unittest.TestCase): |
| 14 def setUp(self): | 15 def setUp(self): |
| 15 devices = device_utils.DeviceUtils.HealthyDevices() | 16 devices = device_utils.DeviceUtils.HealthyDevices() |
| 16 self.browser = 'stable' | 17 self.browser = 'stable' |
| 17 self.package_info = profiler.GetSupportedBrowsers()[self.browser] | 18 self.package_info = profiler.GetSupportedBrowsers()[self.browser] |
| 18 self.device = devices[0] | 19 self.device = devices[0] |
| 19 | 20 |
| 20 self.device.ForceStop(self.package_info.package) | 21 curr_browser = self.GetChromeProcessID() |
| 22 if curr_browser == None: | |
|
Sami
2016/09/12 14:26:32
nit: prefer "is None" instead of "== None" (or jus
| |
| 23 self.StartBrowser() | |
| 24 | |
| 25 def StartBrowser(self): | |
| 26 # Turn on the device screen. | |
| 27 self.device.SetScreen(True) | |
| 28 | |
| 29 # Unlock device. | |
| 30 self.device.SendKeyEvent(keyevent.KEYCODE_MENU) | |
| 31 | |
| 32 # Start browser. | |
| 21 self.device.StartActivity( | 33 self.device.StartActivity( |
| 22 intent.Intent(activity=self.package_info.activity, | 34 intent.Intent(activity=self.package_info.activity, |
| 23 package=self.package_info.package), | 35 package=self.package_info.package, |
| 24 blocking=True) | 36 data='about:blank', |
| 37 extras={'create_new_tab': True}), | |
| 38 blocking=True, force_stop=True) | |
| 39 | |
| 40 def GetChromeProcessID(self): | |
| 41 chrome_processes = self.device.GetPids(self.package_info.package) | |
| 42 if (self.package_info.package in chrome_processes and | |
| 43 len(chrome_processes[self.package_info.package]) > 0): | |
| 44 return chrome_processes[self.package_info.package][0] | |
| 45 return None | |
| OLD | NEW |