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 math | 5 import math |
6 import os | 6 import os |
7 import StringIO | 7 import StringIO |
8 import sys | 8 import sys |
9 import unittest | 9 import unittest |
10 | 10 |
(...skipping 1018 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1029 mock.call.test.WillRunStory(root_mock.state.platform), | 1029 mock.call.test.WillRunStory(root_mock.state.platform), |
1030 mock.call.state.WillRunStory(root_mock.story), | 1030 mock.call.state.WillRunStory(root_mock.story), |
1031 mock.call.state.CanRunStory(root_mock.story), | 1031 mock.call.state.CanRunStory(root_mock.story), |
1032 mock.call.state.RunStory(root_mock.results), | 1032 mock.call.state.RunStory(root_mock.results), |
1033 mock.call.test.Measure(root_mock.state.platform, root_mock.results), | 1033 mock.call.test.Measure(root_mock.state.platform, root_mock.results), |
1034 mock.call.state.DumpStateUponFailure(root_mock.story, root_mock.results), | 1034 mock.call.state.DumpStateUponFailure(root_mock.story, root_mock.results), |
1035 mock.call.results.AddValue(FailureValueMatcher('foo')), | 1035 mock.call.results.AddValue(FailureValueMatcher('foo')), |
1036 mock.call.state.DidRunStory(root_mock.results), | 1036 mock.call.state.DidRunStory(root_mock.results), |
1037 mock.call.test.DidRunStory(root_mock.state.platform) | 1037 mock.call.test.DidRunStory(root_mock.state.platform) |
1038 ]) | 1038 ]) |
1039 | |
1040 def testRunBenchmarkTimeDuration(self): | |
nednguyen
2017/03/17 20:49:32
Can you only mock time and not other story_runner.
nednguyen
2017/03/23 21:29:20
Ping
martiniss
2017/03/23 23:22:21
Done.
| |
1041 benchmark_mock = mock.Mock() | |
1042 opts = mock.MagicMock() | |
1043 opts.__class__.__name__ = '_FakeBrowserFinderOptions' | |
1044 opts.upload_results = False | |
1045 | |
1046 with mock.patch('telemetry.internal.story_runner.Run'): | |
1047 create_mock = mock.Mock() | |
1048 create_mock.failures = [] | |
1049 create_mock.AddSummaryValue = add_value = mock.Mock() | |
1050 | |
1051 c_mock = mock.MagicMock() | |
1052 c_mock.__enter__ = mock.Mock(return_value=create_mock) | |
1053 wrapper = mock.MagicMock(return_value=c_mock) | |
1054 with mock.patch( | |
1055 'telemetry.internal.story_runner.results_options.CreateResults', | |
1056 new=wrapper): | |
1057 | |
1058 res = story_runner.RunBenchmark(benchmark_mock, opts) | |
1059 self.assertEqual(res, 0) | |
1060 | |
1061 self.assertEquals(len(add_value.call_args_list), 1) | |
1062 self.assertEquals(len(add_value.call_args_list[0][0]), 1) | |
1063 # First call -> index into the call object -> first item in call tuple | |
1064 arg = add_value.call_args_list[0][0][0] | |
1065 self.assertTrue(isinstance(arg, scalar.ScalarValue)) | |
1066 self.assertEqual(arg.name, 'BenchmarkDuration') | |
1067 | |
OLD | NEW |