Fix OOP <webview> resize and autosize.
[chromium-blink-merge.git] / tools / perf / measurements / thread_times_unittest.py
blobddf4c389e9d07a047c4b04a2aa9d9b2d97d7eb03
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 from telemetry import decorators
6 from telemetry.page import page
7 from telemetry.testing import options_for_unittests
8 from telemetry.testing import page_test_test_case
9 from telemetry.util import wpr_modes
11 from measurements import thread_times
12 from metrics import timeline
15 class AnimatedPage(page.Page):
16 def __init__(self, page_set):
17 super(AnimatedPage, self).__init__(
18 url='file://animated_page.html',
19 page_set=page_set, base_dir=page_set.base_dir)
21 def RunPageInteractions(self, action_runner):
22 action_runner.Wait(.2)
25 class ThreadTimesUnitTest(page_test_test_case.PageTestTestCase):
26 def setUp(self):
27 self._options = options_for_unittests.GetCopy()
28 self._options.browser_options.wpr_mode = wpr_modes.WPR_OFF
30 @decorators.Disabled('android')
31 def testBasic(self):
32 ps = self.CreateStorySetFromFileInUnittestDataDir('scrollable_page.html')
33 measurement = thread_times.ThreadTimes()
34 timeline_options = self._options
35 results = self.RunMeasurement(measurement, ps, options = timeline_options)
36 self.assertFalse(len(results.failures), results.failures)
38 for interval in timeline.IntervalNames:
39 for category in timeline.TimelineThreadCategories.values():
40 cpu_time_name = timeline.ThreadCpuTimeResultName(category, interval)
41 cpu_time = results.FindAllPageSpecificValuesNamed(cpu_time_name)
42 self.assertEquals(len(cpu_time), 1)
44 @decorators.Disabled('chromeos') # crbug.com/483212
45 def testWithSilkDetails(self):
46 ps = self.CreateStorySetFromFileInUnittestDataDir('scrollable_page.html')
47 measurement = thread_times.ThreadTimes(report_silk_details=True)
48 results = self.RunMeasurement(measurement, ps, options = self._options)
49 self.assertEquals(0, len(results.failures))
51 main_thread = "renderer_main"
52 expected_trace_categories = ["blink", "cc", "idle"]
53 for interval in timeline.IntervalNames:
54 for trace_category in expected_trace_categories:
55 value_name = timeline.ThreadDetailResultName(
56 main_thread, interval, trace_category)
57 values = results.FindAllPageSpecificValuesNamed(value_name)
58 self.assertEquals(len(values), 1)
60 def testCleanUpTrace(self):
61 self.TestTracingCleanedUp(thread_times.ThreadTimes, self._options)