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

Side by Side Diff: chrome/test/functional/test_pyauto.py

Issue 10828335: [pyauto] Fix ActionTimeoutChanger (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: . Created 8 years, 4 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 | « no previous file | chrome/test/pyautolib/pyauto.py » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 #!/usr/bin/env python 1 #!/usr/bin/env python
2 # Copyright (c) 2012 The Chromium Authors. All rights reserved. 2 # Copyright (c) 2012 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 time
6 import unittest 7 import unittest
7 8
8 import pyauto_functional # Must be imported before pyauto 9 import pyauto_functional # Must be imported before pyauto
9 import pyauto 10 import pyauto
10 import pyauto_errors 11 import pyauto_errors
11 12
12 13
13 class PyAutoTest(pyauto.PyUITest): 14 class PyAutoTest(pyauto.PyUITest):
14 """Test functionality of the PyAuto framework.""" 15 """Test functionality of the PyAuto framework."""
15 16
(...skipping 27 matching lines...) Expand all
43 lambda: self.FindInPage('some text', windex=1)) # invalid window 44 lambda: self.FindInPage('some text', windex=1)) # invalid window
44 45
45 def testJSONInterfaceTimeout(self): 46 def testJSONInterfaceTimeout(self):
46 """Verify that an exception is raised when the JSON interface times out.""" 47 """Verify that an exception is raised when the JSON interface times out."""
47 self.ClearEventQueue() 48 self.ClearEventQueue()
48 self.AddDomEventObserver('foo') 49 self.AddDomEventObserver('foo')
49 self.assertRaises( 50 self.assertRaises(
50 pyauto_errors.JSONInterfaceError, 51 pyauto_errors.JSONInterfaceError,
51 lambda: self.GetNextEvent(timeout=2000)) # event queue is empty 52 lambda: self.GetNextEvent(timeout=2000)) # event queue is empty
52 53
54 def testActionTimeoutChanger(self):
55 """Verify that ActionTimeoutChanger works."""
56 new_timeout = 1000 # 1 sec
57 changer = pyauto.PyUITest.ActionTimeoutChanger(self, new_timeout)
58 self.assertEqual(self.action_timeout_ms(), new_timeout)
59
60 # Verify the amount of time taken for automation timeout
61 then = time.time()
62 self.assertRaises(
63 pyauto_errors.JSONInterfaceError,
64 lambda: self.ExecuteJavascript('invalid js should timeout'))
65 elapsed = time.time() - then
66 self.assertTrue(elapsed < new_timeout / 1000.0 + 2, # margin of 2 secs
67 msg='ActionTimeoutChanger did not work. '
68 'Automation timeout took %f secs' % elapsed)
53 69
54 70
55 if __name__ == '__main__': 71 if __name__ == '__main__':
56 pyauto_functional.Main() 72 pyauto_functional.Main()
OLDNEW
« no previous file with comments | « no previous file | chrome/test/pyautolib/pyauto.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698