OLD | NEW |
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 | 4 |
5 import pyauto_functional # must be imported before pyauto | 5 import pyauto_functional # must be imported before pyauto |
6 import pyauto | 6 import pyauto |
7 | 7 |
8 class PyAutoEventsTest(pyauto.PyUITest): | 8 class PyAutoEventsTest(pyauto.PyUITest): |
9 """Tests using the event queue.""" | 9 """Tests using the event queue.""" |
10 | 10 |
(...skipping 25 matching lines...) Expand all Loading... |
36 self.NavigateToURL(url) | 36 self.NavigateToURL(url) |
37 self.GetNextEvent(self.AddDomMutationObserver('exists', '/html/body')) | 37 self.GetNextEvent(self.AddDomMutationObserver('exists', '/html/body')) |
38 self.GetNextEvent(self.AddDomMutationObserver('add', 'id("login")', | 38 self.GetNextEvent(self.AddDomMutationObserver('add', 'id("login")', |
39 expected_value='Log In')) | 39 expected_value='Log In')) |
40 success_id = self.AddDomMutationObserver('change', 'id("console")', | 40 success_id = self.AddDomMutationObserver('change', 'id("console")', |
41 expected_value='.*succeeded.*') | 41 expected_value='.*succeeded.*') |
42 self.NewWebDriver().find_element_by_id('login').click() | 42 self.NewWebDriver().find_element_by_id('login').click() |
43 self.GetNextEvent(self.AddDomMutationObserver('remove', 'id("fail")/a')) | 43 self.GetNextEvent(self.AddDomMutationObserver('remove', 'id("fail")/a')) |
44 self.GetNextEvent(success_id) | 44 self.GetNextEvent(success_id) |
45 | 45 |
| 46 def testWaitUntilNavigationCompletes(self): |
| 47 """Basic test for WaitUntilNavigationCompletes.""" |
| 48 url = self.GetHttpURLForDataPath('apptest', 'dom_mutations.html') |
| 49 js = """window.location.href = "%s"; |
| 50 window.domAutomationController.send("done");""" % url |
| 51 self.ExecuteJavascript(js) |
| 52 self.WaitUntilNavigationCompletes() |
| 53 self.WaitForDomNode('id("login")') |
| 54 |
46 def _ExpectEvent(self, event_id, expected_event_name): | 55 def _ExpectEvent(self, event_id, expected_event_name): |
47 """Checks that the next event is expected.""" | 56 """Checks that the next event is expected.""" |
48 e = self.GetNextEvent(event_id) | 57 e = self.GetNextEvent(event_id) |
49 self.assertEqual(e.get('name'), expected_event_name, | 58 self.assertEqual(e.get('name'), expected_event_name, |
50 msg="unexpected event: %s" % e) | 59 msg="unexpected event: %s" % e) |
51 | 60 |
52 | 61 |
53 if __name__ == '__main__': | 62 if __name__ == '__main__': |
54 pyauto_functional.Main() | 63 pyauto_functional.Main() |
OLD | NEW |