diff options
Diffstat (limited to 'systrace/catapult/systrace/profile_chrome/agents_unittest.py')
-rw-r--r-- | systrace/catapult/systrace/profile_chrome/agents_unittest.py | 45 |
1 files changed, 45 insertions, 0 deletions
diff --git a/systrace/catapult/systrace/profile_chrome/agents_unittest.py b/systrace/catapult/systrace/profile_chrome/agents_unittest.py new file mode 100644 index 0000000..8a22381 --- /dev/null +++ b/systrace/catapult/systrace/profile_chrome/agents_unittest.py @@ -0,0 +1,45 @@ +# Copyright 2014 The Chromium Authors. All rights reserved. +# Use of this source code is governed by a BSD-style license that can be +# found in the LICENSE file. + +import unittest + +from profile_chrome import profiler + +from devil.android import device_utils +from devil.android.sdk import intent +from devil.android.sdk import keyevent + + +class BaseAgentTest(unittest.TestCase): + def setUp(self): + devices = device_utils.DeviceUtils.HealthyDevices() + self.browser = 'stable' + self.package_info = profiler.GetSupportedBrowsers()[self.browser] + self.device = devices[0] + + curr_browser = self.GetChromeProcessID() + if curr_browser == None: + self.StartBrowser() + + def StartBrowser(self): + # Turn on the device screen. + self.device.SetScreen(True) + + # Unlock device. + self.device.SendKeyEvent(keyevent.KEYCODE_MENU) + + # Start browser. + self.device.StartActivity( + intent.Intent(activity=self.package_info.activity, + package=self.package_info.package, + data='about:blank', + extras={'create_new_tab': True}), + blocking=True, force_stop=True) + + def GetChromeProcessID(self): + chrome_processes = self.device.GetPids(self.package_info.package) + if (self.package_info.package in chrome_processes and + len(chrome_processes[self.package_info.package]) > 0): + return chrome_processes[self.package_info.package][0] + return None |