Index: build/android/chrome_profiler/controllers_unittest.py |
diff --git a/build/android/chrome_profiler/controllers_unittest.py b/build/android/chrome_profiler/controllers_unittest.py |
new file mode 100644 |
index 0000000000000000000000000000000000000000..e9260a45e886e0288fb93762f523e63e99b58af6 |
--- /dev/null |
+++ b/build/android/chrome_profiler/controllers_unittest.py |
@@ -0,0 +1,86 @@ |
+# 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 os |
+import json |
+import unittest |
+ |
+from chrome_profiler import controllers |
+from chrome_profiler import profiler |
+ |
+from pylib import android_commands |
+from pylib.device import device_utils |
+ |
+ |
+_BROWSER = 'stable' |
+ |
+ |
+class ControllersTest(unittest.TestCase): |
+ def setUp(self): |
+ devices = android_commands.GetAttachedDevices() |
+ self.assertEquals(len(devices), 1) |
Dominik Grewe
2014/05/22 18:07:10
Is this always true on the bots?
Sami
2014/05/27 11:03:54
You're right, it isn't. I think I'll just pick the
|
+ self.package_info = profiler.GetSupportedBrowsers()[_BROWSER] |
+ self.device = device_utils.DeviceUtils(devices[0]) |
+ |
+ adb = android_commands.AndroidCommands(devices[0]) |
+ adb.StartActivity(self.package_info.package, |
+ self.package_info.activity, |
+ wait_for_completion=True) |
+ |
+ def testChromeTracingGetCategories(self): |
+ # Not supported on stable yet. |
+ if _BROWSER == 'stable': |
Dominik Grewe
2014/05/22 18:07:10
Currently this will always be false, won't it? Are
Sami
2014/05/27 11:03:54
That's right, this is really here only for manual
|
+ return |
+ |
+ categories = \ |
+ controllers.ChromeTracingController.GetCategories(self.device, |
+ self.package_info) |
+ self.assertEquals(len(categories), 2) |
+ self.assertTrue(categories[0]) |
+ self.assertTrue(categories[1]) |
+ |
+ def testChromeTracing(self): |
+ categories = '*' |
+ ring_buffer = False |
+ controller = controllers.ChromeTracingController(self.device, |
+ self.package_info, |
+ categories, |
+ ring_buffer) |
+ |
+ interval = 1 |
+ try: |
+ controller.StartTracing(interval) |
+ finally: |
+ controller.StopTracing() |
+ |
+ result = controller.PullTrace() |
+ try: |
+ with open(result) as f: |
+ json.loads(f.read()) |
+ finally: |
+ os.remove(result) |
+ |
+ def testSystraceGetCategories(self): |
+ categories = controllers.SystraceController.GetCategories(self.device) |
+ self.assertTrue(categories) |
+ |
+ def testSystrace(self): |
+ categories = ['gfx', 'input', 'view'] |
+ ring_buffer = False |
+ controller = controllers.SystraceController(self.device, |
+ categories, |
+ ring_buffer) |
+ |
+ interval = 1 |
+ try: |
+ controller.StartTracing(interval) |
+ finally: |
+ controller.StopTracing() |
+ |
+ result = controller.PullTrace() |
+ try: |
+ with open(result) as f: |
+ self.assertTrue('CPU#' in f.read()) |
+ finally: |
+ os.remove(result) |