Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 # Copyright 2015 The Chromium Authors. All rights reserved. | 1 # Copyright 2015 The Chromium Authors. All rights reserved. |
| 2 # Use of this source code is governed by a BSD-style license that can be | 2 # Use of this source code is governed by a BSD-style license that can be |
| 3 # found in the LICENSE file. | 3 # found in the LICENSE file. |
| 4 import os | |
| 5 import unittest | 4 import unittest |
| 6 | 5 |
| 7 from telemetry import benchmark | 6 from telemetry import benchmark as telemetry_benchmark |
|
Ken Russell (switch to Gerrit)
2015/10/21 22:12:08
This seems fine, or also consider "benchmark_modul
Corentin Wallez
2015/10/21 23:07:25
Done.
| |
| 8 from telemetry.core import exceptions | 7 from telemetry.core import exceptions |
| 9 from telemetry.core import util | |
| 10 from telemetry.story import story_set as story_set_module | 8 from telemetry.story import story_set as story_set_module |
| 11 from telemetry.testing import fakes | 9 from telemetry.testing import fakes |
| 12 | 10 |
| 13 import mock # pylint: disable=import-error | 11 import mock # pylint: disable=import-error |
| 14 | 12 |
| 15 import gpu_test_base | 13 from gpu_tests import gpu_test_base |
| 16 | 14 |
| 17 # Unit tests verifying invariants of classes in GpuTestBase. | 15 # Unit tests verifying invariants of classes in GpuTestBase. |
| 18 | 16 |
| 19 # | 17 # |
| 20 # Tests verifying interactions between Telemetry and GpuTestBase. | 18 # Tests verifying interactions between Telemetry and GpuTestBase. |
| 21 # | 19 # |
| 22 | 20 |
| 23 class FakeValidator(gpu_test_base.ValidatorBase): | 21 class FakeValidator(gpu_test_base.ValidatorBase): |
| 24 def __init__(self, manager_mock=None): | 22 def __init__(self, manager_mock=None): |
| 25 super(FakeValidator, self).__init__() | 23 super(FakeValidator, self).__init__() |
| (...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 156 def setupTest(self, num_test_failures=0, manager_mock=None): | 154 def setupTest(self, num_test_failures=0, manager_mock=None): |
| 157 finder_options = fakes.CreateBrowserFinderOptions() | 155 finder_options = fakes.CreateBrowserFinderOptions() |
| 158 finder_options.browser_options.platform = fakes.FakeLinuxPlatform() | 156 finder_options.browser_options.platform = fakes.FakeLinuxPlatform() |
| 159 finder_options.output_formats = ['none'] | 157 finder_options.output_formats = ['none'] |
| 160 finder_options.suppress_gtest_report = True | 158 finder_options.suppress_gtest_report = True |
| 161 finder_options.output_dir = None | 159 finder_options.output_dir = None |
| 162 finder_options.upload_bucket = 'public' | 160 finder_options.upload_bucket = 'public' |
| 163 finder_options.upload_results = False | 161 finder_options.upload_results = False |
| 164 testclass = FakeTest | 162 testclass = FakeTest |
| 165 parser = finder_options.CreateParser() | 163 parser = finder_options.CreateParser() |
| 166 benchmark.AddCommandLineArgs(parser) | 164 telemetry_benchmark.AddCommandLineArgs(parser) |
| 167 testclass.AddCommandLineArgs(parser) | 165 testclass.AddCommandLineArgs(parser) |
| 168 options, dummy_args = parser.parse_args([]) | 166 options, dummy_args = parser.parse_args([]) |
| 169 benchmark.ProcessCommandLineArgs(parser, options) | 167 telemetry_benchmark.ProcessCommandLineArgs(parser, options) |
| 170 testclass.ProcessCommandLineArgs(parser, options) | 168 testclass.ProcessCommandLineArgs(parser, options) |
| 171 test = testclass(times_to_fail_test=num_test_failures, | 169 test = testclass(times_to_fail_test=num_test_failures, |
| 172 manager_mock=manager_mock) | 170 manager_mock=manager_mock) |
| 173 return test, finder_options | 171 return test, finder_options |
| 174 | 172 |
| 175 # Test page.Run() method is called by telemetry framework before | 173 # Test page.Run() method is called by telemetry framework before |
| 176 # ValidateAndMeasurePage. | 174 # ValidateAndMeasurePage. |
| 177 def testPageRunMethodIsCalledBeforeValidateAndMeasurePage(self): | 175 def testPageRunMethodIsCalledBeforeValidateAndMeasurePage(self): |
| 178 manager = mock.Mock() | 176 manager = mock.Mock() |
| 179 test, finder_options = self.setupTest(manager_mock=manager) | 177 test, finder_options = self.setupTest(manager_mock=manager) |
| (...skipping 219 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 399 mock.call.page2.RunNavigateSteps(mock.ANY), | 397 mock.call.page2.RunNavigateSteps(mock.ANY), |
| 400 mock.call.validator.WillNavigateToPage( | 398 mock.call.validator.WillNavigateToPage( |
| 401 page2, mock.ANY), | 399 page2, mock.ANY), |
| 402 mock.call.page2.RunNavigateSteps(mock.ANY), | 400 mock.call.page2.RunNavigateSteps(mock.ANY), |
| 403 mock.call.validator.DidNavigateToPage( | 401 mock.call.validator.DidNavigateToPage( |
| 404 page2, mock.ANY), | 402 page2, mock.ANY), |
| 405 mock.call.page2.RunPageInteractions(mock.ANY), | 403 mock.call.page2.RunPageInteractions(mock.ANY), |
| 406 mock.call.validator.ValidateAndMeasurePage( | 404 mock.call.validator.ValidateAndMeasurePage( |
| 407 page2, mock.ANY, mock.ANY)] | 405 page2, mock.ANY, mock.ANY)] |
| 408 self.assertTrue(manager.mock_calls == expected) | 406 self.assertTrue(manager.mock_calls == expected) |
| OLD | NEW |