[GCM] Persistence of account mappings.
[chromium-blink-merge.git] / tools / perf / measurements / rasterize_and_record_micro_unittest.py
blob3543d6124caf94259e8ac3a67aed17028f398ed0
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.core import wpr_modes
9 from telemetry.page import page_measurement_unittest_base
10 from telemetry.page import page_test
11 from telemetry.unittest import test
12 from telemetry.unittest import options_for_unittests
15 class RasterizeAndRecordMicroUnitTest(
16 page_measurement_unittest_base.PageMeasurementUnitTestBase):
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
27 self._options.rasterize_repeat = 1
28 self._options.record_repeat = 1
29 self._options.start_wait_time = 0.0
30 self._options.report_detailed_results = True
32 @test.Disabled('win')
33 def testRasterizeAndRecordMicro(self):
34 ps = self.CreatePageSetFromFileInUnittestDataDir('blank.html')
35 measurement = rasterize_and_record_micro.RasterizeAndRecordMicro()
36 try:
37 results = self.RunMeasurement(measurement, ps, options=self._options)
38 except page_test.TestNotSupportedOnPlatformFailure as failure:
39 logging.warning(str(failure))
40 return
41 self.assertEquals(0, len(results.failures))
43 rasterize_time = results.FindAllPageSpecificValuesNamed('rasterize_time')
44 self.assertEquals(len(rasterize_time), 1)
45 self.assertGreater(rasterize_time[0].GetRepresentativeNumber(), 0)
47 record_time = results.FindAllPageSpecificValuesNamed('record_time')
48 self.assertEquals(len(record_time), 1)
49 self.assertGreater(record_time[0].GetRepresentativeNumber(), 0)
51 rasterized_pixels = results.FindAllPageSpecificValuesNamed(
52 'pixels_rasterized')
53 self.assertEquals(len(rasterized_pixels), 1)
54 self.assertGreater(rasterized_pixels[0].GetRepresentativeNumber(), 0)
56 recorded_pixels = results.FindAllPageSpecificValuesNamed('pixels_recorded')
57 self.assertEquals(len(recorded_pixels), 1)
58 self.assertGreater(recorded_pixels[0].GetRepresentativeNumber(), 0)
60 pixels_rasterized_with_non_solid_color = \
61 results.FindAllPageSpecificValuesNamed(
62 'pixels_rasterized_with_non_solid_color')
63 self.assertEquals(len(pixels_rasterized_with_non_solid_color), 1)
64 self.assertGreater(
65 pixels_rasterized_with_non_solid_color[0].GetRepresentativeNumber(), 0)
67 pixels_rasterized_as_opaque = \
68 results.FindAllPageSpecificValuesNamed('pixels_rasterized_as_opaque')
69 self.assertEquals(len(pixels_rasterized_as_opaque), 1)
70 self.assertGreater(
71 pixels_rasterized_as_opaque[0].GetRepresentativeNumber(), 0)
73 total_layers = results.FindAllPageSpecificValuesNamed('total_layers')
74 self.assertEquals(len(total_layers), 1)
75 self.assertGreater(total_layers[0].GetRepresentativeNumber(), 0)
77 total_picture_layers = \
78 results.FindAllPageSpecificValuesNamed('total_picture_layers')
79 self.assertEquals(len(total_picture_layers), 1)
80 self.assertGreater(total_picture_layers[0].GetRepresentativeNumber(), 0)
82 total_picture_layers_with_no_content = \
83 results.FindAllPageSpecificValuesNamed(
84 'total_picture_layers_with_no_content')
85 self.assertEquals(len(total_picture_layers_with_no_content), 1)
86 self.assertGreater(
87 total_picture_layers_with_no_content[0].GetRepresentativeNumber(), 0)
89 total_picture_layers_off_screen = \
90 results.FindAllPageSpecificValuesNamed(
91 'total_picture_layers_off_screen')
92 self.assertEquals(len(total_picture_layers_off_screen), 1)
93 self.assertEqual(
94 total_picture_layers_off_screen[0].GetRepresentativeNumber(), 0)