Chromium Code Reviews| Index: tools/perf/benchmarks/metric_dependencies_unittest.py |
| diff --git a/tools/perf/benchmarks/metric_dependencies_unittest.py b/tools/perf/benchmarks/metric_dependencies_unittest.py |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..ff0baddad4d5341ec91257506ede6ae28173250b |
| --- /dev/null |
| +++ b/tools/perf/benchmarks/metric_dependencies_unittest.py |
| @@ -0,0 +1,46 @@ |
| +# Copyright 2016 The Chromium Authors. All rights reserved. |
|
benjhayden
2017/03/02 21:33:35
Drive-by nit: 2017
|
| +# Use of this source code is governed by a BSD-style license that can be |
| +# found in the LICENSE file. |
| + |
| +import unittest |
| + |
| +from benchmarks import metric_dependencies |
| +from telemetry.timeline import chrome_trace_category_filter |
| +from telemetry.web_perf import timeline_based_measurement |
| + |
| +class TestMetricDependencies(unittest.TestCase): |
| + |
| + def testIncludedCategory(self): |
| + metric_dependencies.SetMetricDependenciesForTesting({ |
| + 'metric1': [ |
| + 'category1', |
| + 'disabled-by-default-category2', |
| + ] |
| + }) |
| + options = timeline_based_measurement.Options( |
| + chrome_trace_category_filter.ChromeTraceCategoryFilter()) |
| + metric_dependencies.AugmentOptionsForMetrics(options, ['metric1']) |
| + cat_filter = options.config.chrome_trace_config.category_filter |
| + result = cat_filter.GetDictForChromeTracing() |
| + self.assertEqual(result['included_categories'], |
| + ['category1', 'disabled-by-default-category2']) |
| + |
| + def testExcludedCategory(self): |
| + metric_dependencies.SetMetricDependenciesForTesting({ |
| + 'metric1': ['-category1'] |
| + }) |
| + options = timeline_based_measurement.Options( |
| + chrome_trace_category_filter.ChromeTraceCategoryFilter()) |
| + metric_dependencies.AugmentOptionsForMetrics(options, ['metric1']) |
| + cat_filter = options.config.chrome_trace_config.category_filter |
| + result = cat_filter.GetDictForChromeTracing() |
| + self.assertEqual(result['excluded_categories'], ['-category1']) |
| + |
| + def testUnknownMetric(self): |
| + metric_dependencies.SetMetricDependenciesForTesting({ |
| + 'metric1': ['-category1'] |
| + }) |
| + options = timeline_based_measurement.Options( |
| + chrome_trace_category_filter.ChromeTraceCategoryFilter()) |
| + self.assertRaises(AssertionError, |
| + metric_dependencies.AugmentOptionsForMetrics, options, ['metric2']) |