Roll src/third_party/WebKit 4edeb4e:c80a38a (svn 201049:201050)
[chromium-blink-merge.git] / tools / profile_chrome / chrome_controller_unittest.py
blobaec4e77e4b208a1d1223b12bbcb211cfaebea1f6
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
3 # found in the LICENSE file.
5 import os
6 import json
8 from profile_chrome import chrome_controller
9 from profile_chrome import controllers_unittest
12 class ChromeControllerTest(controllers_unittest.BaseControllerTest):
13 def testGetCategories(self):
14 # Not supported on stable yet.
15 # TODO(skyostil): Remove this once category queries roll into stable.
16 if self.browser == 'stable':
17 return
19 categories = \
20 chrome_controller.ChromeTracingController.GetCategories(
21 self.device, self.package_info)
23 self.assertEquals(len(categories), 2)
24 self.assertTrue(categories[0])
25 self.assertTrue(categories[1])
27 def testTracing(self):
28 categories = '*'
29 ring_buffer = False
30 controller = chrome_controller.ChromeTracingController(self.device,
31 self.package_info,
32 categories,
33 ring_buffer)
35 interval = 1
36 try:
37 controller.StartTracing(interval)
38 finally:
39 controller.StopTracing()
41 result = controller.PullTrace()
42 try:
43 with open(result) as f:
44 json.loads(f.read())
45 finally:
46 os.remove(result)