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
as page_module
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 smoothness
12 from page_sets
import repaint_helpers
15 class TestRepaintPage(page_module
.Page
):
16 def __init__(self
, page_set
, base_dir
):
17 super(TestRepaintPage
, self
).__init
__('file://blank.html',
20 def RunPageInteractions(self
, action_runner
):
21 repaint_helpers
.Repaint(action_runner
)
24 class RepaintUnitTest(page_test_test_case
.PageTestTestCase
):
25 """Smoke test for repaint measurement
27 Runs repaint measurement on a simple page and verifies
28 that all metrics were added to the results. The test is purely functional,
29 i.e. it only checks if the metrics are present and non-zero.
33 self
._options
= options_for_unittests
.GetCopy()
34 self
._options
.browser_options
.wpr_mode
= wpr_modes
.WPR_OFF
36 @decorators.Disabled('chromeos') # crbug.com/483212
37 def testRepaint(self
):
38 ps
= self
.CreateEmptyPageSet()
39 ps
.AddStory(TestRepaintPage(ps
, ps
.base_dir
))
40 measurement
= smoothness
.Repaint()
41 results
= self
.RunMeasurement(measurement
, ps
, options
=self
._options
)
42 self
.assertEquals(0, len(results
.failures
))
44 frame_times
= results
.FindAllPageSpecificValuesNamed('frame_times')
45 self
.assertEquals(len(frame_times
), 1)
46 self
.assertGreater(frame_times
[0].GetRepresentativeNumber(), 0)
48 mean_frame_time
= results
.FindAllPageSpecificValuesNamed('mean_frame_time')
49 self
.assertEquals(len(mean_frame_time
), 1)
50 self
.assertGreater(mean_frame_time
[0].GetRepresentativeNumber(), 0)
52 frame_time_discrepancy
= results
.FindAllPageSpecificValuesNamed(
53 'frame_time_discrepancy')
54 self
.assertEquals(len(frame_time_discrepancy
), 1)
55 self
.assertGreater(frame_time_discrepancy
[0].GetRepresentativeNumber(), 0)
57 percentage_smooth
= results
.FindAllPageSpecificValuesNamed(
59 self
.assertEquals(len(percentage_smooth
), 1)
60 self
.assertGreaterEqual(percentage_smooth
[0].GetRepresentativeNumber(), 0)
62 # Make sure that we don't have extra timeline based metrics that are not
63 # related to smoothness.
64 mainthread_jank
= results
.FindAllPageSpecificValuesNamed(
65 'responsive-total_big_jank_thread_time')
66 self
.assertEquals(len(mainthread_jank
), 0)
68 @decorators.Disabled('android')
69 def testCleanUpTrace(self
):
70 self
.TestTracingCleanedUp(smoothness
.Repaint
, self
._options
)