Delete chrome.mediaGalleriesPrivate because the functionality unique to it has since...
[chromium-blink-merge.git] / tools / perf / measurements / rasterize_and_record_micro_unittest.py
blob7b1007f0e44a3f39e41cd6cbbce493da2b7c06b2
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 measurements import rasterize_and_record_micro
8 from telemetry import decorators
9 from telemetry.core import wpr_modes
10 from telemetry.page import page_test
11 from telemetry.unittest_util import options_for_unittests
12 from telemetry.unittest_util import page_test_test_case
15 class RasterizeAndRecordMicroUnitTest(page_test_test_case.PageTestTestCase):
16 """Smoke test for rasterize_and_record_micro measurement
18 Runs rasterize_and_record_micro measurement on a simple page and verifies
19 that all metrics were added to the results. The test is purely functional,
20 i.e. it only checks if the metrics are present and non-zero.
21 """
23 def setUp(self):
24 self._options = options_for_unittests.GetCopy()
25 self._options.browser_options.wpr_mode = wpr_modes.WPR_OFF
27 @decorators.Disabled('win', 'chromeos')
28 def testRasterizeAndRecordMicro(self):
29 ps = self.CreatePageSetFromFileInUnittestDataDir('blank.html')
30 measurement = rasterize_and_record_micro.RasterizeAndRecordMicro(
31 rasterize_repeat=1, record_repeat=1, start_wait_time=0.0,
32 report_detailed_results=True)
33 try:
34 results = self.RunMeasurement(measurement, ps, options=self._options)
35 except page_test.TestNotSupportedOnPlatformError as failure:
36 logging.warning(str(failure))
37 return
38 self.assertEquals(0, len(results.failures))
40 rasterize_time = results.FindAllPageSpecificValuesNamed('rasterize_time')
41 self.assertEquals(len(rasterize_time), 1)
42 self.assertGreater(rasterize_time[0].GetRepresentativeNumber(), 0)
44 record_time = results.FindAllPageSpecificValuesNamed('record_time')
45 self.assertEquals(len(record_time), 1)
46 self.assertGreater(record_time[0].GetRepresentativeNumber(), 0)
48 rasterized_pixels = results.FindAllPageSpecificValuesNamed(
49 'pixels_rasterized')
50 self.assertEquals(len(rasterized_pixels), 1)
51 self.assertGreater(rasterized_pixels[0].GetRepresentativeNumber(), 0)
53 recorded_pixels = results.FindAllPageSpecificValuesNamed('pixels_recorded')
54 self.assertEquals(len(recorded_pixels), 1)
55 self.assertGreater(recorded_pixels[0].GetRepresentativeNumber(), 0)
57 pixels_rasterized_with_non_solid_color = \
58 results.FindAllPageSpecificValuesNamed(
59 'pixels_rasterized_with_non_solid_color')
60 self.assertEquals(len(pixels_rasterized_with_non_solid_color), 1)
61 self.assertGreater(
62 pixels_rasterized_with_non_solid_color[0].GetRepresentativeNumber(), 0)
64 pixels_rasterized_as_opaque = \
65 results.FindAllPageSpecificValuesNamed('pixels_rasterized_as_opaque')
66 self.assertEquals(len(pixels_rasterized_as_opaque), 1)
67 self.assertGreater(
68 pixels_rasterized_as_opaque[0].GetRepresentativeNumber(), 0)
70 total_layers = results.FindAllPageSpecificValuesNamed('total_layers')
71 self.assertEquals(len(total_layers), 1)
72 self.assertGreater(total_layers[0].GetRepresentativeNumber(), 0)
74 total_picture_layers = \
75 results.FindAllPageSpecificValuesNamed('total_picture_layers')
76 self.assertEquals(len(total_picture_layers), 1)
77 self.assertGreater(total_picture_layers[0].GetRepresentativeNumber(), 0)
79 total_picture_layers_with_no_content = \
80 results.FindAllPageSpecificValuesNamed(
81 'total_picture_layers_with_no_content')
82 self.assertEquals(len(total_picture_layers_with_no_content), 1)
83 self.assertGreater(
84 total_picture_layers_with_no_content[0].GetRepresentativeNumber(), 0)
86 total_picture_layers_off_screen = \
87 results.FindAllPageSpecificValuesNamed(
88 'total_picture_layers_off_screen')
89 self.assertEquals(len(total_picture_layers_off_screen), 1)
90 self.assertEqual(
91 total_picture_layers_off_screen[0].GetRepresentativeNumber(), 0)
93 viewport_picture_size = \
94 results.FindAllPageSpecificValuesNamed('viewport_picture_size')
95 self.assertEquals(len(viewport_picture_size), 1)
96 self.assertGreater(
97 viewport_picture_size[0].GetRepresentativeNumber(), 0)
99 total_size_of_pictures_in_piles = \
100 results.FindAllPageSpecificValuesNamed(
101 'total_size_of_pictures_in_piles')
102 self.assertEquals(len(total_size_of_pictures_in_piles), 1)
103 self.assertGreater(
104 total_size_of_pictures_in_piles[0].GetRepresentativeNumber(), 0)