OLD | NEW |
1 # Copyright 2013 The Chromium Authors. All rights reserved. | 1 # Copyright 2013 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 # These tests access private methods in the speedindex module. | 5 # These tests access private methods in the speedindex module. |
6 # pylint: disable=W0212 | 6 # pylint: disable=W0212 |
7 | 7 |
8 import json | 8 import json |
9 import os | 9 import os |
10 import unittest | 10 import unittest |
11 | 11 |
12 from telemetry.core.timeline import model | 12 from telemetry.core.timeline import model |
| 13 from telemetry.unittest import DisabledTestOnCrOS |
13 from metrics import speedindex | 14 from metrics import speedindex |
14 | 15 |
15 # Sample timeline data in the json format provided by devtools. | 16 # Sample timeline data in the json format provided by devtools. |
16 # The sample events will be used in several tests below. | 17 # The sample events will be used in several tests below. |
17 _TEST_DIR = os.path.join(os.path.dirname(__file__), 'unittest_data') | 18 _TEST_DIR = os.path.join(os.path.dirname(__file__), 'unittest_data') |
18 _SAMPLE_DATA = json.load(open(os.path.join(_TEST_DIR, 'sample_timeline.json'))) | 19 _SAMPLE_DATA = json.load(open(os.path.join(_TEST_DIR, 'sample_timeline.json'))) |
19 _SAMPLE_EVENTS = model.TimelineModel(event_data=_SAMPLE_DATA).GetAllEvents() | 20 _SAMPLE_EVENTS = model.TimelineModel(event_data=_SAMPLE_DATA).GetAllEvents() |
20 | 21 |
21 | 22 |
22 class FakeTimelineModel(object): | 23 class FakeTimelineModel(object): |
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
85 paint_events = impl._IncludedPaintEvents(_SAMPLE_EVENTS) | 86 paint_events = impl._IncludedPaintEvents(_SAMPLE_EVENTS) |
86 viewport = 1000, 1000 | 87 viewport = 1000, 1000 |
87 time_area_dict = impl._TimeAreaDict(paint_events, viewport) | 88 time_area_dict = impl._TimeAreaDict(paint_events, viewport) |
88 self.assertEquals(len(time_area_dict), 4) | 89 self.assertEquals(len(time_area_dict), 4) |
89 # The event that ends at time 100 is a fullscreen; it's discounted by half. | 90 # The event that ends at time 100 is a fullscreen; it's discounted by half. |
90 self.assertEquals(time_area_dict[100], 500000) | 91 self.assertEquals(time_area_dict[100], 500000) |
91 self.assertEquals(time_area_dict[300], 100000) | 92 self.assertEquals(time_area_dict[300], 100000) |
92 self.assertEquals(time_area_dict[400], 200000) | 93 self.assertEquals(time_area_dict[400], 200000) |
93 self.assertEquals(time_area_dict[800], 200000) | 94 self.assertEquals(time_area_dict[800], 200000) |
94 | 95 |
| 96 @DisabledTestOnCrOS |
95 def testVideoCompleteness(self): | 97 def testVideoCompleteness(self): |
96 frames = [ | 98 frames = [ |
97 (0.0, FakeBitmap([100, 0, 0])), | 99 (0.0, FakeBitmap([100, 0, 0])), |
98 (0.1, FakeBitmap([50, 25, 25])), | 100 (0.1, FakeBitmap([50, 25, 25])), |
99 (0.2, FakeBitmap([60, 0, 40])), | 101 (0.2, FakeBitmap([60, 0, 40])), |
100 (0.3, FakeBitmap([0, 10, 90])) | 102 (0.3, FakeBitmap([0, 10, 90])) |
101 ] | 103 ] |
102 impl = speedindex.VideoSpeedIndexImpl(FakeTab(frames)) | 104 impl = speedindex.VideoSpeedIndexImpl(FakeTab(frames)) |
103 impl.Start() | 105 impl.Start() |
104 impl.Stop() | 106 impl.Stop() |
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
173 def test2ch(self): | 175 def test2ch(self): |
174 # Page: http://2ch.net/ | 176 # Page: http://2ch.net/ |
175 # This page has several paint events, including nested paint events. | 177 # This page has several paint events, including nested paint events. |
176 self._TestJsonTimelineExpectation( | 178 self._TestJsonTimelineExpectation( |
177 '2ch_repeat_timeline.json', (997, 650), 674.58) | 179 '2ch_repeat_timeline.json', (997, 650), 674.58) |
178 | 180 |
179 | 181 |
180 if __name__ == "__main__": | 182 if __name__ == "__main__": |
181 unittest.main() | 183 unittest.main() |
182 | 184 |
OLD | NEW |