Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 #!/usr/bin/python | 1 #!/usr/bin/python |
| 2 # Copyright (c) 2010 The Chromium Authors. All rights reserved. | 2 # Copyright (c) 2010 The Chromium Authors. All rights reserved. |
| 3 # Use of this source code is governed by a BSD-style license that can be | 3 # Use of this source code is governed by a BSD-style license that can be |
| 4 # found in the LICENSE file. | 4 # found in the LICENSE file. |
| 5 | 5 |
| 6 import os | 6 import os |
| 7 import time | 7 import time |
| 8 | 8 |
| 9 import pyauto_functional # Must be imported before pyauto | 9 import pyauto_functional # Must be imported before pyauto |
| 10 import pyauto | 10 import pyauto |
| (...skipping 165 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 176 | 176 |
| 177 Note the history system can tweak values (e.g. lower-case a URL or | 177 Note the history system can tweak values (e.g. lower-case a URL or |
| 178 append an '/' on it) so be careful with exact comparison. | 178 append an '/' on it) so be careful with exact comparison. |
| 179 """ | 179 """ |
| 180 assert not self.GetHistoryInfo().History(), 'Expecting clean history.' | 180 assert not self.GetHistoryInfo().History(), 'Expecting clean history.' |
| 181 # Minimal interface | 181 # Minimal interface |
| 182 self.AddHistoryItem({'url': 'http://ZOINKS'}) | 182 self.AddHistoryItem({'url': 'http://ZOINKS'}) |
| 183 history = self.GetHistoryInfo().History() | 183 history = self.GetHistoryInfo().History() |
| 184 self.assertEqual(1, len(history)) | 184 self.assertEqual(1, len(history)) |
| 185 self.assertTrue('zoinks' in history[0]['url']) # yes it gets lower-cased. | 185 self.assertTrue('zoinks' in history[0]['url']) # yes it gets lower-cased. |
| 186 # Python's time might be slightly off (~10 ms) from Chrome's time (on win). | |
| 187 # time.time() on win counts in 1ms steps whereas it's 1us on linux. | |
| 188 # So give the new history item some time separation, so that we can rely | |
| 189 # on the history ordering. | |
| 190 now = time.time() + 5 | |
|
John Grabowski
2010/07/02 23:53:02
perhaps refactor into a routine called getNextTime
Nirnimesh
2010/07/03 00:15:18
Part of the problem is that Chrome's time is sligh
| |
| 186 # Full interface (specify both title and url) | 191 # Full interface (specify both title and url) |
| 187 now = time.time() | |
| 188 self.AddHistoryItem({'title': 'Google', | 192 self.AddHistoryItem({'title': 'Google', |
| 189 'url': 'http://www.google.com', | 193 'url': 'http://www.google.com', |
| 190 'time': now}) | 194 'time': now}) |
| 191 # Expect a second item | 195 # Expect a second item |
| 192 history = self.GetHistoryInfo().History() | 196 history = self.GetHistoryInfo().History() |
| 193 self.assertEqual(2, len(history)) | 197 self.assertEqual(2, len(history)) |
| 194 # And make sure our forged item is there. | 198 # And make sure our forged item is there. |
| 195 self.assertEqual('Google', history[0]['title']) | 199 self.assertEqual('Google', history[0]['title']) |
| 196 self.assertTrue('google.com' in history[0]['url']) | 200 self.assertTrue('google.com' in history[0]['url']) |
| 197 self.assertTrue(abs(now - history[0]['time']) < 1.0) | 201 self.assertTrue(abs(now - history[0]['time']) < 1.0) |
| 198 | 202 |
| 199 | 203 |
| 200 if __name__ == '__main__': | 204 if __name__ == '__main__': |
| 201 pyauto_functional.Main() | 205 pyauto_functional.Main() |
| OLD | NEW |