Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 # Copyright 2016 The Chromium Authors. All rights reserved. | |
|
benjhayden
2017/03/02 21:33:35
Drive-by nit: 2017
| |
| 2 # Use of this source code is governed by a BSD-style license that can be | |
| 3 # found in the LICENSE file. | |
| 4 | |
| 5 import unittest | |
| 6 | |
| 7 from benchmarks import metric_dependencies | |
| 8 from telemetry.timeline import chrome_trace_category_filter | |
| 9 from telemetry.web_perf import timeline_based_measurement | |
| 10 | |
| 11 class TestMetricDependencies(unittest.TestCase): | |
| 12 | |
| 13 def testIncludedCategory(self): | |
| 14 metric_dependencies.SetMetricDependenciesForTesting({ | |
| 15 'metric1': [ | |
| 16 'category1', | |
| 17 'disabled-by-default-category2', | |
| 18 ] | |
| 19 }) | |
| 20 options = timeline_based_measurement.Options( | |
| 21 chrome_trace_category_filter.ChromeTraceCategoryFilter()) | |
| 22 metric_dependencies.AugmentOptionsForMetrics(options, ['metric1']) | |
| 23 cat_filter = options.config.chrome_trace_config.category_filter | |
| 24 result = cat_filter.GetDictForChromeTracing() | |
| 25 self.assertEqual(result['included_categories'], | |
| 26 ['category1', 'disabled-by-default-category2']) | |
| 27 | |
| 28 def testExcludedCategory(self): | |
| 29 metric_dependencies.SetMetricDependenciesForTesting({ | |
| 30 'metric1': ['-category1'] | |
| 31 }) | |
| 32 options = timeline_based_measurement.Options( | |
| 33 chrome_trace_category_filter.ChromeTraceCategoryFilter()) | |
| 34 metric_dependencies.AugmentOptionsForMetrics(options, ['metric1']) | |
| 35 cat_filter = options.config.chrome_trace_config.category_filter | |
| 36 result = cat_filter.GetDictForChromeTracing() | |
| 37 self.assertEqual(result['excluded_categories'], ['-category1']) | |
| 38 | |
| 39 def testUnknownMetric(self): | |
| 40 metric_dependencies.SetMetricDependenciesForTesting({ | |
| 41 'metric1': ['-category1'] | |
| 42 }) | |
| 43 options = timeline_based_measurement.Options( | |
| 44 chrome_trace_category_filter.ChromeTraceCategoryFilter()) | |
| 45 self.assertRaises(AssertionError, | |
| 46 metric_dependencies.AugmentOptionsForMetrics, options, ['metric2']) | |
| OLD | NEW |