diff options
author | nirnimesh@chromium.org <nirnimesh@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-07-03 00:44:07 +0000 |
---|---|---|
committer | nirnimesh@chromium.org <nirnimesh@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-07-03 00:44:07 +0000 |
commit | d49c07e7b1c1d80b3c41bdb7c8860dfa99c088eb (patch) | |
tree | 41e98351f15463e0843f2e628a4c26813759173c /chrome/test/functional | |
parent | 28dad08b7fafcec561576ad93092e092580fb40f (diff) | |
download | chromium_src-d49c07e7b1c1d80b3c41bdb7c8860dfa99c088eb.zip chromium_src-d49c07e7b1c1d80b3c41bdb7c8860dfa99c088eb.tar.gz chromium_src-d49c07e7b1c1d80b3c41bdb7c8860dfa99c088eb.tar.bz2 |
Fix HistoryTest.testForge on Win
Python's time might be slightly off from Chrome's time on win.
In HistoryTest.testForge this affects the ordering of the history entries.
Make the test function robust to this.
Review URL: http://codereview.chromium.org/2825036
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@51579 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/test/functional')
-rw-r--r-- | chrome/test/functional/history.py | 14 |
1 files changed, 11 insertions, 3 deletions
diff --git a/chrome/test/functional/history.py b/chrome/test/functional/history.py index f149ed8..40ea326 100644 --- a/chrome/test/functional/history.py +++ b/chrome/test/functional/history.py @@ -183,18 +183,26 @@ class HistoryTest(pyauto.PyUITest): history = self.GetHistoryInfo().History() self.assertEqual(1, len(history)) self.assertTrue('zoinks' in history[0]['url']) # yes it gets lower-cased. + # Python's time might be slightly off (~10 ms) from Chrome's time (on win). + # time.time() on win counts in 1ms steps whereas it's 1us on linux. + # So give the new history item some time separation, so that we can rely + # on the history ordering. + def _GetTimeLaterThan(tm): + y = time.time() + if y - tm < 0.5: # 0.5s should be an acceptable separation + return 0.5 + y + new_time = _GetTimeLaterThan(history[0]['time']) # Full interface (specify both title and url) - now = time.time() self.AddHistoryItem({'title': 'Google', 'url': 'http://www.google.com', - 'time': now}) + 'time': new_time}) # Expect a second item history = self.GetHistoryInfo().History() self.assertEqual(2, len(history)) # And make sure our forged item is there. self.assertEqual('Google', history[0]['title']) self.assertTrue('google.com' in history[0]['url']) - self.assertTrue(abs(now - history[0]['time']) < 1.0) + self.assertTrue(abs(new_time - history[0]['time']) < 1.0) if __name__ == '__main__': |