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 measurements
import repaint
6 from telemetry
.core
import wpr_modes
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
10 from telemetry
.unittest_util
import test
13 class TestRepaintPage(page_module
.Page
):
14 def __init__(self
, page_set
, base_dir
):
15 super(TestRepaintPage
, self
).__init
__('file://blank.html',
18 def RunRepaint(self
, action_runner
):
19 action_runner
.RepaintContinuously(seconds
=2)
22 class RepaintUnitTest(page_test_test_case
.PageTestTestCase
):
23 """Smoke test for repaint measurement
25 Runs repaint measurement on a simple page and verifies
26 that all metrics were added to the results. The test is purely functional,
27 i.e. it only checks if the metrics are present and non-zero.
31 self
._options
= options_for_unittests
.GetCopy()
32 self
._options
.browser_options
.wpr_mode
= wpr_modes
.WPR_OFF
34 def testRepaint(self
):
35 ps
= self
.CreateEmptyPageSet()
36 ps
.AddPage(TestRepaintPage(ps
, ps
.base_dir
))
37 measurement
= repaint
.Repaint()
38 results
= self
.RunMeasurement(measurement
, ps
, options
=self
._options
)
39 self
.assertEquals(0, len(results
.failures
))
41 frame_times
= results
.FindAllPageSpecificValuesNamed('frame_times')
42 self
.assertEquals(len(frame_times
), 1)
43 self
.assertGreater(frame_times
[0].GetRepresentativeNumber(), 0)
45 mean_frame_time
= results
.FindAllPageSpecificValuesNamed('mean_frame_time')
46 self
.assertEquals(len(mean_frame_time
), 1)
47 self
.assertGreater(mean_frame_time
[0].GetRepresentativeNumber(), 0)
49 frame_time_discrepancy
= results
.FindAllPageSpecificValuesNamed(
50 'frame_time_discrepancy')
51 self
.assertEquals(len(frame_time_discrepancy
), 1)
52 self
.assertGreater(frame_time_discrepancy
[0].GetRepresentativeNumber(), 0)
54 percentage_smooth
= results
.FindAllPageSpecificValuesNamed(
56 self
.assertEquals(len(percentage_smooth
), 1)
57 self
.assertGreaterEqual(percentage_smooth
[0].GetRepresentativeNumber(), 0)
59 @test.Disabled('android')
60 def testCleanUpTrace(self
):
61 self
.TestTracingCleanedUp(repaint
.Repaint
, self
._options
)