Merge Chromium + Blink git repositories
[chromium-blink-merge.git] / tools / perf / measurements / rasterize_and_record_micro_unittest.py
blobf61a26acad3ed6783c9b98354c1dc7a3f10f7adc
1 # Copyright 2013 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 import logging
7 from telemetry import decorators
8 from telemetry.page import page_test
9 from telemetry.testing import options_for_unittests
10 from telemetry.testing import page_test_test_case
11 from telemetry.util import wpr_modes
13 from measurements import rasterize_and_record_micro
16 class RasterizeAndRecordMicroUnitTest(page_test_test_case.PageTestTestCase):
17 """Smoke test for rasterize_and_record_micro measurement
19 Runs rasterize_and_record_micro measurement on a simple page and verifies
20 that all metrics were added to the results. The test is purely functional,
21 i.e. it only checks if the metrics are present and non-zero.
22 """
24 def setUp(self):
25 self._options = options_for_unittests.GetCopy()
26 self._options.browser_options.wpr_mode = wpr_modes.WPR_OFF
28 @decorators.Disabled('win', 'chromeos')
29 def testRasterizeAndRecordMicro(self):
30 ps = self.CreateStorySetFromFileInUnittestDataDir('blank.html')
31 measurement = rasterize_and_record_micro.RasterizeAndRecordMicro(
32 rasterize_repeat=1, record_repeat=1, start_wait_time=0.0,
33 report_detailed_results=True)
34 try:
35 results = self.RunMeasurement(measurement, ps, options=self._options)
36 except page_test.TestNotSupportedOnPlatformError as failure:
37 logging.warning(str(failure))
38 return
39 self.assertEquals(0, len(results.failures))
41 rasterize_time = results.FindAllPageSpecificValuesNamed('rasterize_time')
42 self.assertEquals(len(rasterize_time), 1)
43 self.assertGreater(rasterize_time[0].GetRepresentativeNumber(), 0)
45 record_time = results.FindAllPageSpecificValuesNamed('record_time')
46 self.assertEquals(len(record_time), 1)
47 self.assertGreater(record_time[0].GetRepresentativeNumber(), 0)
49 rasterized_pixels = results.FindAllPageSpecificValuesNamed(
50 'pixels_rasterized')
51 self.assertEquals(len(rasterized_pixels), 1)
52 self.assertGreater(rasterized_pixels[0].GetRepresentativeNumber(), 0)
54 recorded_pixels = results.FindAllPageSpecificValuesNamed('pixels_recorded')
55 self.assertEquals(len(recorded_pixels), 1)
56 self.assertGreater(recorded_pixels[0].GetRepresentativeNumber(), 0)
58 pixels_rasterized_with_non_solid_color = \
59 results.FindAllPageSpecificValuesNamed(
60 'pixels_rasterized_with_non_solid_color')
61 self.assertEquals(len(pixels_rasterized_with_non_solid_color), 1)
62 self.assertGreater(
63 pixels_rasterized_with_non_solid_color[0].GetRepresentativeNumber(), 0)
65 pixels_rasterized_as_opaque = \
66 results.FindAllPageSpecificValuesNamed('pixels_rasterized_as_opaque')
67 self.assertEquals(len(pixels_rasterized_as_opaque), 1)
68 self.assertGreater(
69 pixels_rasterized_as_opaque[0].GetRepresentativeNumber(), 0)
71 total_layers = results.FindAllPageSpecificValuesNamed('total_layers')
72 self.assertEquals(len(total_layers), 1)
73 self.assertGreater(total_layers[0].GetRepresentativeNumber(), 0)
75 total_picture_layers = \
76 results.FindAllPageSpecificValuesNamed('total_picture_layers')
77 self.assertEquals(len(total_picture_layers), 1)
78 self.assertGreater(total_picture_layers[0].GetRepresentativeNumber(), 0)
80 total_picture_layers_with_no_content = \
81 results.FindAllPageSpecificValuesNamed(
82 'total_picture_layers_with_no_content')
83 self.assertEquals(len(total_picture_layers_with_no_content), 1)
84 self.assertGreater(
85 total_picture_layers_with_no_content[0].GetRepresentativeNumber(), 0)
87 total_picture_layers_off_screen = \
88 results.FindAllPageSpecificValuesNamed(
89 'total_picture_layers_off_screen')
90 self.assertEquals(len(total_picture_layers_off_screen), 1)
91 self.assertEqual(
92 total_picture_layers_off_screen[0].GetRepresentativeNumber(), 0)
94 viewport_picture_size = \
95 results.FindAllPageSpecificValuesNamed('viewport_picture_size')
96 self.assertEquals(len(viewport_picture_size), 1)
97 self.assertGreater(
98 viewport_picture_size[0].GetRepresentativeNumber(), 0)
100 total_size_of_pictures_in_piles = \
101 results.FindAllPageSpecificValuesNamed(
102 'total_size_of_pictures_in_piles')
103 self.assertEquals(len(total_size_of_pictures_in_piles), 1)
104 self.assertGreater(
105 total_size_of_pictures_in_piles[0].GetRepresentativeNumber(), 0)