[Telemetry] Remove smoothness's reliance on auto issuing marker feature of smoothness...
[chromium-blink-merge.git] / tools / perf / measurements / thread_times_unittest.py
bloba6a2426e265ec0c1a44a71bef1a25da6ddf1f7e3
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.core import wpr_modes
6 from telemetry import decorators
7 from telemetry.page import page
8 from telemetry.unittest_util import options_for_unittests
9 from telemetry.unittest_util import page_test_test_case
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.CreatePageSetFromFileInUnittestDataDir('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 category in timeline.TimelineThreadCategories.values():
39 cpu_time_name = timeline.ThreadCpuTimeResultName(category)
40 cpu_time = results.FindAllPageSpecificValuesNamed(cpu_time_name)
41 self.assertEquals(len(cpu_time), 1)
43 def testBasicForPageWithNoGesture(self):
44 ps = self.CreateEmptyPageSet()
45 ps.AddUserStory(AnimatedPage(ps))
47 measurement = thread_times.ThreadTimes()
48 timeline_options = self._options
49 results = self.RunMeasurement(measurement, ps, options = timeline_options)
50 self.assertEquals(0, len(results.failures))
52 for category in timeline.TimelineThreadCategories.values():
53 cpu_time_name = timeline.ThreadCpuTimeResultName(category)
54 cpu_time = results.FindAllPageSpecificValuesNamed(cpu_time_name)
55 self.assertEquals(len(cpu_time), 1)
57 def testWithSilkDetails(self):
58 ps = self.CreatePageSetFromFileInUnittestDataDir('scrollable_page.html')
59 measurement = thread_times.ThreadTimes(report_silk_details=True)
60 results = self.RunMeasurement(measurement, ps, options = self._options)
61 self.assertEquals(0, len(results.failures))
63 main_thread = "renderer_main"
64 expected_trace_categories = ["blink", "cc", "idle"]
65 for trace_category in expected_trace_categories:
66 value_name = timeline.ThreadDetailResultName(main_thread, trace_category)
67 values = results.FindAllPageSpecificValuesNamed(value_name)
68 self.assertEquals(len(values), 1)
70 def testCleanUpTrace(self):
71 self.TestTracingCleanedUp(thread_times.ThreadTimes, self._options)