| 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 cStringIO | 5 import cStringIO | 
| 6 import json | 6 import json | 
| 7 import logging | 7 import logging | 
| 8 import os | 8 import os | 
| 9 import unittest | 9 import unittest | 
| 10 | 10 | 
| 11 from telemetry import tab_test_case | 11 from telemetry.core import util | 
| 12 from telemetry import tracing_backend | 12 from telemetry.core.chrome import tracing_backend | 
| 13 from telemetry import util | 13 from telemetry.test import tab_test_case | 
| 14 | 14 | 
| 15 | 15 | 
| 16 class TracingBackendTest(tab_test_case.TabTestCase): | 16 class TracingBackendTest(tab_test_case.TabTestCase): | 
| 17   def _StartServer(self): | 17   def _StartServer(self): | 
| 18     base_dir = os.path.dirname(__file__) | 18     base_dir = os.path.dirname(__file__) | 
| 19     self._browser.SetHTTPServerDirectory(os.path.join(base_dir, '..', | 19     self._browser.SetHTTPServerDirectory( | 
| 20         'unittest_data')) | 20         os.path.join(base_dir, '..', '..', '..', 'unittest_data')) | 
| 21 | 21 | 
| 22   def _WaitForAnimationFrame(self): | 22   def _WaitForAnimationFrame(self): | 
| 23     def _IsDone(): | 23     def _IsDone(): | 
| 24       js_is_done = """done""" | 24       js_is_done = """done""" | 
| 25       return bool(self._tab.EvaluateJavaScript(js_is_done)) | 25       return bool(self._tab.EvaluateJavaScript(js_is_done)) | 
| 26     util.WaitFor(_IsDone, 5) | 26     util.WaitFor(_IsDone, 5) | 
| 27 | 27 | 
| 28   def testGotTrace(self): | 28   def testGotTrace(self): | 
| 29     if not self._browser.supports_tracing: | 29     if not self._browser.supports_tracing: | 
| 30       logging.warning('Browser does not support tracing, skipping test.') | 30       logging.warning('Browser does not support tracing, skipping test.') | 
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 65         '"bar"', | 65         '"bar"', | 
| 66         '"baz"']) | 66         '"baz"']) | 
| 67     f = cStringIO.StringIO() | 67     f = cStringIO.StringIO() | 
| 68     ri.Serialize(f) | 68     ri.Serialize(f) | 
| 69     v = f.getvalue() | 69     v = f.getvalue() | 
| 70 | 70 | 
| 71     j = json.loads(v) | 71     j = json.loads(v) | 
| 72     assert 'traceEvents' in j | 72     assert 'traceEvents' in j | 
| 73     self.assertEquals(j['traceEvents'], | 73     self.assertEquals(j['traceEvents'], | 
| 74                       ['foo', 'bar', 'baz']) | 74                       ['foo', 'bar', 'baz']) | 
| OLD | NEW | 
|---|