[Session restore] Rename group name Enabled to Restore.
[chromium-blink-merge.git] / tools / perf / measurements / repaint_unittest.py
blobd71fd51df79d30cf95a42686f67d693e723c9078
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 as page_module
8 from telemetry.unittest_util import options_for_unittests
9 from telemetry.unittest_util import page_test_test_case
11 from measurements import repaint
14 class TestRepaintPage(page_module.Page):
15 def __init__(self, page_set, base_dir):
16 super(TestRepaintPage, self).__init__('file://blank.html',
17 page_set, base_dir)
19 def RunPageInteractions(self, action_runner):
20 action_runner.RepaintContinuously(seconds=2)
23 class RepaintUnitTest(page_test_test_case.PageTestTestCase):
24 """Smoke test for repaint measurement
26 Runs repaint measurement on a simple page and verifies
27 that all metrics were added to the results. The test is purely functional,
28 i.e. it only checks if the metrics are present and non-zero.
29 """
31 def setUp(self):
32 self._options = options_for_unittests.GetCopy()
33 self._options.browser_options.wpr_mode = wpr_modes.WPR_OFF
35 def testRepaint(self):
36 ps = self.CreateEmptyPageSet()
37 ps.AddUserStory(TestRepaintPage(ps, ps.base_dir))
38 measurement = repaint.Repaint()
39 results = self.RunMeasurement(measurement, ps, options=self._options)
40 self.assertEquals(0, len(results.failures))
42 frame_times = results.FindAllPageSpecificValuesNamed('frame_times')
43 self.assertEquals(len(frame_times), 1)
44 self.assertGreater(frame_times[0].GetRepresentativeNumber(), 0)
46 mean_frame_time = results.FindAllPageSpecificValuesNamed('mean_frame_time')
47 self.assertEquals(len(mean_frame_time), 1)
48 self.assertGreater(mean_frame_time[0].GetRepresentativeNumber(), 0)
50 frame_time_discrepancy = results.FindAllPageSpecificValuesNamed(
51 'frame_time_discrepancy')
52 self.assertEquals(len(frame_time_discrepancy), 1)
53 self.assertGreater(frame_time_discrepancy[0].GetRepresentativeNumber(), 0)
55 percentage_smooth = results.FindAllPageSpecificValuesNamed(
56 'percentage_smooth')
57 self.assertEquals(len(percentage_smooth), 1)
58 self.assertGreaterEqual(percentage_smooth[0].GetRepresentativeNumber(), 0)
60 @decorators.Disabled('android')
61 def testCleanUpTrace(self):
62 self.TestTracingCleanedUp(repaint.Repaint, self._options)