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

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

Issue 10095018: Added a new PyAuto method WaitForDomNode() which allows tests to block until a specified node exist… (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created a new exception class JavascriptRuntimeException in place of RuntimeException. Created 8 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 | « no previous file | chrome/test/pyautolib/dom_mutation_observer.js » ('j') | 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 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 import domselector 7 import domselector
8 8
9 class PyAutoEventsTest(pyauto.PyUITest): 9 class PyAutoEventsTest(pyauto.PyUITest):
10 """Tests using the event queue.""" 10 """Tests using the event queue."""
11 11
12 def testBasicEvents(self): 12 def testBasicEvents(self):
13 """Basic test for the event queue.""" 13 """Basic test for the event queue."""
14 url = self.GetHttpURLForDataPath('apptest', 'basic.html') 14 url = self.GetHttpURLForDataPath('apptest', 'basic.html')
15 driver = self.NewWebDriver() 15 driver = self.NewWebDriver()
16 event_id = self.AddDomEventObserver(automation_id=4444, recurring=True) 16 event_id = self.AddDomEventObserver(automation_id=4444, recurring=True)
17 success_id = self.AddDomEventObserver('test success', automation_id=4444) 17 success_id = self.AddDomEventObserver('test success', automation_id=4444)
18 self.NavigateToURL(url) 18 self.NavigateToURL(url)
19 self._ExpectEvent(event_id, 'init') 19 self._ExpectEvent(event_id, 'init')
20 self._ExpectEvent(event_id, 'login ready') 20 self._ExpectEvent(event_id, 'login ready')
21 driver.find_element_by_id('login').click() 21 driver.find_element_by_id('login').click()
22 self._ExpectEvent(event_id, 'login start') 22 self._ExpectEvent(event_id, 'login start')
23 self._ExpectEvent(event_id, 'login done') 23 self._ExpectEvent(event_id, 'login done')
24 self.GetNextEvent(success_id) 24 self.GetNextEvent(success_id)
25 25
26 def testDomMutationEvents(self): 26 def testDomMutationEvents(self):
27 """Basic tests for Dom Mutation observers.""" 27 """Basic tests for WaitForDomNode."""
28 url = self.GetHttpURLForDataPath('apptest', 'dom_mutations.html')
29 self.NavigateToURL(url)
30 self.WaitForDomNode(domselector.CSSSelector('#login'), 'Log In')
31 self.NewWebDriver().find_element_by_id('login').click()
32 self.WaitForDomNode(domselector.XPath('id(\'console\')'), '.*succeeded.*')
33
34 def testDomMutationObservers(self):
35 """Tests for the various types of Dom Mutation observers."""
28 url = self.GetHttpURLForDataPath('apptest', 'dom_mutations.html') 36 url = self.GetHttpURLForDataPath('apptest', 'dom_mutations.html')
29 self.NavigateToURL(url) 37 self.NavigateToURL(url)
30 self.GetNextEvent(self.AddDomMutationObserver( 38 self.GetNextEvent(self.AddDomMutationObserver(
31 'add', domselector.XPath('/html/body'))) 39 'exists', domselector.XPath('/html/body')))
32 self.GetNextEvent(self.AddDomMutationObserver( 40 self.GetNextEvent(self.AddDomMutationObserver(
33 'add', domselector.CSSSelector('#login'), expected_value='Log In')) 41 'add', domselector.CSSSelector('#login'), expected_value='Log In'))
34 success_id = self.AddDomMutationObserver( 42 success_id = self.AddDomMutationObserver(
35 'change', domselector.XPath('id(\'console\')'), 43 'change', domselector.XPath('id(\'console\')'),
36 expected_value='.*succeeded.*') 44 expected_value='.*succeeded.*')
37 self.NewWebDriver().find_element_by_id('login').click() 45 self.NewWebDriver().find_element_by_id('login').click()
38 self.GetNextEvent(self.AddDomMutationObserver( 46 self.GetNextEvent(self.AddDomMutationObserver(
39 'remove', domselector.XPath('id(\'fail\')/a'))) 47 'remove', domselector.XPath('id(\'fail\')/a')))
40 self.GetNextEvent(success_id) 48 self.GetNextEvent(success_id)
41 49
42 def _ExpectEvent(self, event_id, expected_event_name): 50 def _ExpectEvent(self, event_id, expected_event_name):
43 """Checks that the next event is expected.""" 51 """Checks that the next event is expected."""
44 e = self.GetNextEvent(event_id) 52 e = self.GetNextEvent(event_id)
45 self.assertEqual(e.get('name'), expected_event_name, 53 self.assertEqual(e.get('name'), expected_event_name,
46 msg="unexpected event: %s" % e) 54 msg="unexpected event: %s" % e)
47 55
48 56
49 if __name__ == '__main__': 57 if __name__ == '__main__':
50 pyauto_functional.Main() 58 pyauto_functional.Main()
OLDNEW
« no previous file with comments | « no previous file | chrome/test/pyautolib/dom_mutation_observer.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698