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

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

Issue 6340008: Adding instant tests for popup handling and search query length 100 character... (Closed) Base URL: http://src.chromium.org/svn/trunk/src/
Patch Set: '' Created 9 years, 11 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 | no next file » | 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/python 1 #!/usr/bin/python
2 2
3 # Copyright (c) 2010 The Chromium Authors. All rights reserved. 3 # Copyright (c) 2010 The Chromium Authors. All rights reserved.
4 # Use of this source code is governed by a BSD-style license that can be 4 # Use of this source code is governed by a BSD-style license that can be
5 # found in the LICENSE file. 5 # found in the LICENSE file.
6 6
7 import os 7 import os
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
11 import urlparse
11 12
12 13
13 class InstantTest(pyauto.PyUITest): 14 class InstantTest(pyauto.PyUITest):
14 """TestCase for Omnibox Instant feature.""" 15 """TestCase for Omnibox Instant feature."""
15 16
16 def setUp(self): 17 def setUp(self):
17 pyauto.PyUITest.setUp(self) 18 pyauto.PyUITest.setUp(self)
18 self.SetPrefs(pyauto.kInstantEnabled, True) 19 self.SetPrefs(pyauto.kInstantEnabled, True)
19 20
20 def _DoneLoading(self): 21 def _DoneLoading(self):
21 info = self.GetInstantInfo() 22 info = self.GetInstantInfo()
22 return info.get('current') and not info.get('loading') 23 return info.get('current') and not info.get('loading')
23 24
25 def _DoneLoadingQuery(self, query):
Nirnimesh 2011/01/20 00:39:23 Add a docstring to explain what it's doing.
Huyen 2011/01/20 02:44:37 Done.
26 self.assertTrue(self.WaitUntil(self._DoneLoading))
27 location = self.GetInstantInfo().get('location')
28 if location is None:
29 return False
30 else:
Nirnimesh 2011/01/20 00:39:23 else: is redundant
Huyen 2011/01/20 02:44:37 Polished the logic here a bit. Should be better no
31 q = urlparse.parse_qs(location).get('q')
32 if q is None:
33 return False
34 elif q == query:
35 return True
36
24 def testInstantNavigation(self): 37 def testInstantNavigation(self):
25 """Test that instant navigates based on omnibox input.""" 38 """Test that instant navigates based on omnibox input."""
26 self.SetOmniboxText('google.com') 39 self.SetOmniboxText('google.com')
27 self.assertTrue(self.WaitUntil(self._DoneLoading)) 40 self.assertTrue(self.WaitUntil(self._DoneLoading))
28 location = self.GetInstantInfo()['location'] 41 location = self.GetInstantInfo()['location']
29 self.assertTrue('google.com' in location, 42 self.assertTrue('google.com' in location,
30 msg='No google.com in %s' % location) 43 msg='No google.com in %s' % location)
31 44
32 self.SetOmniboxText('google.es') 45 self.SetOmniboxText('google.es')
33 self.assertTrue(self.WaitUntil(self._DoneLoading)) 46 self.assertTrue(self.WaitUntil(self._DoneLoading))
(...skipping 22 matching lines...) Expand all
56 self.assertTrue(self.WaitUntil(self._DoneLoading)) 69 self.assertTrue(self.WaitUntil(self._DoneLoading))
57 history = self.GetHistoryInfo().History() 70 history = self.GetHistoryInfo().History()
58 self.assertEqual(0, len(history)) 71 self.assertEqual(0, len(history))
59 72
60 def testInstantDisabledForJavaScript(self): 73 def testInstantDisabledForJavaScript(self):
61 """Test that instant is disabled for javascript URLs.""" 74 """Test that instant is disabled for javascript URLs."""
62 self.SetOmniboxText('javascript:') 75 self.SetOmniboxText('javascript:')
63 self.assertFalse(self.GetInstantInfo()['active'], 76 self.assertFalse(self.GetInstantInfo()['active'],
64 'Instant enabled for javascript URL.') 77 'Instant enabled for javascript URL.')
65 78
79 def testInstantDisablesPopupsOnPrefetch(self):
80 """Test that instant disables popups when prefetching."""
81 file_url = self.GetFileURLForPath(os.path.join(
82 self.DataDir(), 'popup_blocker', 'popup-blocked-to-post-blank.html'))
83 self.SetOmniboxText(file_url)
84 self.assertTrue(self.WaitUntil(self._DoneLoading))
85 location = self.GetInstantInfo()['location']
86 self.assertTrue(file_url in location,
87 msg='Prefetched page is not %s' % file_url)
88 blocked_popups = self.GetBlockedPopupsInfo()
89 self.assertEqual(0, len(blocked_popups),
90 msg='Unexpected popup in instant preview.')
91
92 def testInstantLoadsFor100CharsLongQuery(self):
93 """Test that instant loads for search query of 100 characters."""
94 query = '#' * 100
95 self.SetOmniboxText(query)
96 self.assertTrue(self.WaitUntil(self._DoneLoadingQuery, args=[query]))
97
66 98
67 if __name__ == '__main__': 99 if __name__ == '__main__':
68 pyauto_functional.Main() 100 pyauto_functional.Main()
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698