Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(98)

Side by Side Diff: tools/telemetry/telemetry/unittest/simple_mock.py

Issue 240893004: Mock timer for Telemetry unit tests (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: hide time.sleep and time.time Created 6 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « tools/telemetry/telemetry/page/actions/wait_unittest.py ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 # Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 # Copyright (c) 2012 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 """A very very simple mock object harness.""" 4 """A very very simple mock object harness."""
5 5
6 DONT_CARE = '' 6 DONT_CARE = ''
7 7
8 class MockFunctionCall(object): 8 class MockFunctionCall(object):
9 def __init__(self, name): 9 def __init__(self, name):
10 self.name = name 10 self.name = name
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after
86 repr(got_call)) 86 repr(got_call))
87 expected_call = self._trace.expected_calls[ 87 expected_call = self._trace.expected_calls[
88 self._trace.next_call_index] 88 self._trace.next_call_index]
89 expected_call.VerifyEquals(got_call) 89 expected_call.VerifyEquals(got_call)
90 self._trace.next_call_index += 1 90 self._trace.next_call_index += 1
91 for h in expected_call.when_called_handlers: 91 for h in expected_call.when_called_handlers:
92 h(*args) 92 h(*args)
93 return expected_call.return_value 93 return expected_call.return_value
94 handler.is_hook = True 94 handler.is_hook = True
95 setattr(self, func_name, handler) 95 setattr(self, func_name, handler)
96
97
98 class MockTimer(object):
99 def __init__(self):
100 self._elapsed_time = 0
101
102 def Sleep(self, time):
103 self._elapsed_time += time
104
105 def GetTime(self):
106 return self._elapsed_time
OLDNEW
« no previous file with comments | « tools/telemetry/telemetry/page/actions/wait_unittest.py ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698