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 import mock | 4 import mock |
5 import unittest | 5 import unittest |
6 | 6 |
7 from telemetry.core import exceptions | 7 from telemetry.core import exceptions |
8 from telemetry import decorators | 8 from telemetry import decorators |
9 from telemetry.internal.actions import action_runner as action_runner_module | 9 from telemetry.internal.actions import action_runner as action_runner_module |
10 from telemetry.internal.actions import page_action | 10 from telemetry.internal.actions import page_action |
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
84 finally: | 84 finally: |
85 trace_data = self._browser.platform.tracing_controller.StopTracing() | 85 trace_data = self._browser.platform.tracing_controller.StopTracing() |
86 | 86 |
87 # If successful, i.e. we haven't balied out due to an exception, check | 87 # If successful, i.e. we haven't balied out due to an exception, check |
88 # that we can find our dump in the trace. | 88 # that we can find our dump in the trace. |
89 self.assertIsNotNone(dump_id) | 89 self.assertIsNotNone(dump_id) |
90 timeline_model = model.TimelineModel(trace_data) | 90 timeline_model = model.TimelineModel(trace_data) |
91 dump_ids = (d.dump_id for d in timeline_model.IterGlobalMemoryDumps()) | 91 dump_ids = (d.dump_id for d in timeline_model.IterGlobalMemoryDumps()) |
92 self.assertIn(dump_id, dump_ids) | 92 self.assertIn(dump_id, dump_ids) |
93 | 93 |
94 # TODO(perezju): Enable when reference browser is >= M53 | |
95 # https://github.com/catapult-project/catapult/issues/2610 | |
96 @decorators.Disabled('reference') | |
97 def testDeterministicMode(self): | 94 def testDeterministicMode(self): |
98 self._TestWithTracing(deterministic_mode=True) | 95 self._TestWithTracing(deterministic_mode=True) |
99 | 96 |
100 # TODO(perezju): Enable when reference browser is >= M53 | |
101 # https://github.com/catapult-project/catapult/issues/2610 | |
102 @decorators.Disabled('reference') | |
103 def testRealisticMode(self): | 97 def testRealisticMode(self): |
104 with mock.patch.object(self.action_runner, | 98 with mock.patch.object(self.action_runner, |
105 'ForceGarbageCollection') as mock_method: | 99 'ForceGarbageCollection') as mock_method: |
106 self._TestWithTracing(deterministic_mode=False) | 100 self._TestWithTracing(deterministic_mode=False) |
107 self.assertFalse(mock_method.called) # No forced GC in "realistic" mode. | 101 self.assertFalse(mock_method.called) # No forced GC in "realistic" mode. |
108 | 102 |
109 def testWithFailedDump(self): | 103 def testWithFailedDump(self): |
110 with mock.patch.object(self._tab.browser, 'DumpMemory') as mock_method: | 104 with mock.patch.object(self._tab.browser, 'DumpMemory') as mock_method: |
111 mock_method.return_value = False # Dump fails! | 105 mock_method.return_value = False # Dump fails! |
112 with self.assertRaises(exceptions.Error): | 106 with self.assertRaises(exceptions.Error): |
(...skipping 366 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
479 # caller. | 473 # caller. |
480 with self.assertRaises(FooException): | 474 with self.assertRaises(FooException): |
481 with action_runner_module.Interaction( | 475 with action_runner_module.Interaction( |
482 self.mock_action_runner, label='ABC', flags=[]): | 476 self.mock_action_runner, label='ABC', flags=[]): |
483 raise FooException() | 477 raise FooException() |
484 | 478 |
485 # Test that the end console.timeEnd(...) isn't called because exception was | 479 # Test that the end console.timeEnd(...) isn't called because exception was |
486 # raised. | 480 # raised. |
487 self.assertEqual(self.expected_calls[:1], | 481 self.assertEqual(self.expected_calls[:1], |
488 self.mock_action_runner.mock_calls) | 482 self.mock_action_runner.mock_calls) |
OLD | NEW |