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. 4 5 from measurements import repaint 6 from telemetry import test 7 from telemetry.core import wpr_modes 8 from telemetry.page import page_measurement_unittest_base 9 from telemetry.page import page as page_module 10 # pylint: disable=W0401,W0614 11 from telemetry.page.actions.all_page_actions import * 12 from telemetry.unittest import options_for_unittests 13 14 15 class TestRepaintPage(page_module.Page): 16 def __init__(self, page_set, base_dir): 17 super(TestRepaintPage, self).__init__('file://blank.html', 18 page_set, base_dir) 19 20 def RunRepaint(self, action_runner): 21 action_runner.RunAction(RepaintContinuouslyAction({'seconds': 2})) 22 23 24 class RepaintUnitTest( 25 page_measurement_unittest_base.PageMeasurementUnitTestBase): 26 """Smoke test for repaint measurement 27 28 Runs repaint measurement on a simple page and verifies 29 that all metrics were added to the results. The test is purely functional, 30 i.e. it only checks if the metrics are present and non-zero. 31 """ 32 33 def setUp(self): 34 self._options = options_for_unittests.GetCopy() 35 self._options.browser_options.wpr_mode = wpr_modes.WPR_OFF 36 37 @test.Disabled # http://crbug.com/368767 38 def testRepaint(self): 39 ps = self.CreateEmptyPageSet() 40 ps.AddPage(TestRepaintPage(ps, ps.base_dir)) 41 measurement = repaint.Repaint() 42 results = self.RunMeasurement(measurement, ps, options=self._options) 43 self.assertEquals(0, len(results.failures)) 44 45 frame_times = results.FindAllPageSpecificValuesNamed('frame_times') 46 self.assertEquals(len(frame_times), 1) 47 self.assertGreater(frame_times[0].GetRepresentativeNumber(), 0) 48 49 mean_frame_time = results.FindAllPageSpecificValuesNamed('mean_frame_time') 50 self.assertEquals(len(mean_frame_time), 1) 51 self.assertGreater(mean_frame_time[0].GetRepresentativeNumber(), 0) 52 53 jank = results.FindAllPageSpecificValuesNamed('jank') 54 self.assertEquals(len(jank), 1) 55 self.assertGreater(jank[0].GetRepresentativeNumber(), 0) 56 57 mostly_smooth = results.FindAllPageSpecificValuesNamed('mostly_smooth') 58 self.assertEquals(len(mostly_smooth), 1) 59 self.assertGreaterEqual(mostly_smooth[0].GetRepresentativeNumber(), 0) 60 61 @test.Disabled('android') 62 def testCleanUpTrace(self): 63 self.TestTracingCleanedUp(repaint.Repaint, self._options) 64