Update sdk/platform-tools to version 26.0.0.
[android_tools.git] / sdk / platform-tools / systrace / catapult / telemetry / telemetry / util / matching_unittest.py
bloba43c0444c06c89300a678e9aaa054882cb5d4b81
1 # Copyright 2016 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 unittest
7 from telemetry.util import matching
10 class BenchmarkFoo(object):
11 """ Benchmark Foo for testing."""
12 @classmethod
13 def Name(cls):
14 return 'FooBenchmark'
17 class BenchmarkBar(object):
18 """ Benchmark Bar for testing long description line."""
19 @classmethod
20 def Name(cls):
21 return 'BarBenchmarkkkkk'
24 class UnusualBenchmark(object):
25 @classmethod
26 def Name(cls):
27 return 'I have a very unusual name'
30 class CommandLineUnittest(unittest.TestCase):
31 def testGetMostLikelyMatchedObject(self):
32 # Test moved from telemetry/benchmark_runner_unittest.py
33 all_benchmarks = [BenchmarkFoo, BenchmarkBar, UnusualBenchmark]
34 self.assertEquals(
35 [BenchmarkFoo, BenchmarkBar],
36 matching.GetMostLikelyMatchedObject(
37 all_benchmarks, 'BenchmarkFooz', name_func=lambda x: x.Name()))
39 self.assertEquals(
40 [BenchmarkBar, BenchmarkFoo],
41 matching.GetMostLikelyMatchedObject(
42 all_benchmarks, 'BarBenchmark', name_func=lambda x: x.Name()))
44 self.assertEquals(
45 [UnusualBenchmark],
46 matching.GetMostLikelyMatchedObject(
47 all_benchmarks, 'unusual', name_func=lambda x: x.Name()))