| OLD | NEW |
| 1 # Copyright 2014 The Chromium Authors. All rights reserved. | 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 | 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 | 4 |
| 5 import optparse | 5 import optparse |
| 6 import unittest | 6 import unittest |
| 7 | 7 |
| 8 from telemetry import android | 8 from telemetry import android |
| 9 from telemetry import benchmark | 9 from telemetry import benchmark |
| 10 from telemetry.testing import options_for_unittests | 10 from telemetry.testing import options_for_unittests |
| (...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 131 def testBenchmarkPredicate(self): | 131 def testBenchmarkPredicate(self): |
| 132 class PredicateBenchmark(TestBenchmark): | 132 class PredicateBenchmark(TestBenchmark): |
| 133 @classmethod | 133 @classmethod |
| 134 def ValueCanBeAddedPredicate(cls, value, is_first_result): | 134 def ValueCanBeAddedPredicate(cls, value, is_first_result): |
| 135 return False | 135 return False |
| 136 | 136 |
| 137 original_run_fn = story_runner.Run | 137 original_run_fn = story_runner.Run |
| 138 validPredicate = [False] | 138 validPredicate = [False] |
| 139 | 139 |
| 140 def RunStub(test, story_set_module, finder_options, results, | 140 def RunStub(test, story_set_module, finder_options, results, |
| 141 *args): # pylint: disable=unused-argument | 141 *args, **kwargs): # pylint: disable=unused-argument |
| 142 predicate = results._value_can_be_added_predicate | 142 predicate = results._value_can_be_added_predicate |
| 143 valid = predicate == PredicateBenchmark.ValueCanBeAddedPredicate | 143 valid = predicate == PredicateBenchmark.ValueCanBeAddedPredicate |
| 144 validPredicate[0] = valid | 144 validPredicate[0] = valid |
| 145 | 145 |
| 146 story_runner.Run = RunStub | 146 story_runner.Run = RunStub |
| 147 | 147 |
| 148 try: | 148 try: |
| 149 options = options_for_unittests.GetCopy() | 149 options = options_for_unittests.GetCopy() |
| 150 options.output_formats = ['none'] | 150 options.output_formats = ['none'] |
| 151 options.suppress_gtest_report = True | 151 options.suppress_gtest_report = True |
| 152 parser = optparse.OptionParser() | 152 parser = optparse.OptionParser() |
| 153 benchmark.AddCommandLineArgs(parser) | 153 benchmark.AddCommandLineArgs(parser) |
| 154 options.MergeDefaultValues(parser.get_default_values()) | 154 options.MergeDefaultValues(parser.get_default_values()) |
| 155 | 155 |
| 156 b = PredicateBenchmark(page.Page(url='about:blank')) | 156 b = PredicateBenchmark(page.Page(url='about:blank')) |
| 157 b.Run(options) | 157 b.Run(options) |
| 158 finally: | 158 finally: |
| 159 story_runner.Run = original_run_fn | 159 story_runner.Run = original_run_fn |
| 160 | 160 |
| 161 self.assertTrue(validPredicate[0]) | 161 self.assertTrue(validPredicate[0]) |
| OLD | NEW |