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

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

Issue 10836031: Remove Instant v1 API. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Update history, title, favicon 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 | « chrome/test/functional/PYAUTO_TESTS ('k') | 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/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 cgi 6 import cgi
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 11
12
13 class InstantSettingsTest(pyauto.PyUITest): 12 class InstantSettingsTest(pyauto.PyUITest):
14 """Test Chrome Instant settings.""" 13 """Test Chrome Instant settings."""
15 14
16 def testEnableDisableInstant(self): 15 def testEnableDisableInstant(self):
17 """Test to verify default Chrome Instant setting. 16 """Test to verify default Chrome Instant setting.
18 Check if the setting can be enabled and disabled.""" 17 Check if the setting can be enabled and disabled."""
19 self.assertFalse(self.GetPrefsInfo().Prefs(pyauto.kInstantEnabled), 18 self.assertFalse(self.GetPrefsInfo().Prefs(pyauto.kInstantEnabled),
20 msg='Instant is enabled by default.') 19 msg='Instant is enabled by default.')
21 # Enable instant. 20
22 self.AppendSwitchASCIIToCommandLine('instant-field-trial', 'instant'); 21 # Enable Instant.
23 self.SetPrefs(pyauto.kInstantEnabled, True) 22 self.SetPrefs(pyauto.kInstantEnabled, True)
24 self.assertTrue(self.GetPrefsInfo().Prefs(pyauto.kInstantEnabled), 23 self.assertTrue(self.GetPrefsInfo().Prefs(pyauto.kInstantEnabled),
25 msg='Instant is not enabled.') 24 msg='Instant is not enabled.')
25
26 # Make sure Instant works.
26 self.SetOmniboxText('google') 27 self.SetOmniboxText('google')
27 self.assertTrue(self.WaitUntil( 28 self.assertTrue(self.WaitUntil(
28 lambda: self.GetInstantInfo().get('current') and not 29 lambda: self.GetInstantInfo().get('current') and not
29 self.GetInstantInfo().get('loading'))) 30 self.GetInstantInfo().get('loading')))
30 title = self.GetInstantInfo()['title'] 31 title = self.GetInstantInfo()['title']
31 self.assertEqual('Google', title, msg='Instant did not load.') 32 self.assertEqual('Google', title, msg='Instant did not load.')
33
32 # Disable Instant. 34 # Disable Instant.
33 self.AppendSwitchASCIIToCommandLine('instant-field-trial', 'disabled');
34 self.SetPrefs(pyauto.kInstantEnabled, False) 35 self.SetPrefs(pyauto.kInstantEnabled, False)
35 self.assertFalse(self.GetInstantInfo()['enabled'], 36 self.assertFalse(self.GetInstantInfo()['enabled'],
36 msg='Instant is not disabled.') 37 msg='Instant is not disabled.')
37 38
38 39
39 class InstantTest(pyauto.PyUITest): 40 class InstantTest(pyauto.PyUITest):
40 """TestCase for Omnibox Instant feature.""" 41 """TestCase for Omnibox Instant feature."""
41 42
42 def setUp(self): 43 def setUp(self):
43 pyauto.PyUITest.setUp(self) 44 pyauto.PyUITest.setUp(self)
44 self.AppendSwitchASCIIToCommandLine('instant-field-trial', 'instant');
45 self.SetPrefs(pyauto.kInstantEnabled, True) 45 self.SetPrefs(pyauto.kInstantEnabled, True)
46 46
47 def _DoneLoading(self): 47 def _DoneLoading(self):
48 info = self.GetInstantInfo() 48 info = self.GetInstantInfo()
49 return info.get('current') and not info.get('loading') 49 return info.get('current') and not info.get('loading')
50 50
51 def _DoneLoadingGoogleQuery(self, query): 51 def _DoneLoadingGoogleQuery(self, query):
52 """Wait for Omnibox Instant to load Google search result 52 """Wait for Omnibox Instant to load Google search result
53 and verify location URL contains the specifed query. 53 and verify location URL contains the specifed query.
54 54
55 Args: 55 Args:
56 query: Value of query parameter. 56 query: Value of query parameter.
57 E.g., http://www.google.com?q=hi so query is 'hi'. 57 E.g., http://www.google.com?q=hi so query is 'hi'.
58 """ 58 """
59 self.assertTrue(self.WaitUntil(self._DoneLoading)) 59 self.assertTrue(self.WaitUntil(self._DoneLoading))
60 location = self.GetInstantInfo().get('location') 60 location = self.GetInstantInfo().get('location')
61 if location is not None: 61 if location is not None:
62 q = cgi.parse_qs(location).get('q') 62 q = cgi.parse_qs(location).get('q')
63 if q is not None and query in q: 63 if q is not None and query in q:
64 return True 64 return True
65 return False 65 return False
66 66
67 def testInstantNavigation(self): 67 def testInstantLoadsSearchResults(self):
68 """Test that instant navigates based on omnibox input.""" 68 """Test that Instant loads search results based on omnibox input."""
69 # Initiate instant search (at default google.com). 69 # Initiate Instant search (at default google.com).
70 self.SetOmniboxText('chrome instant') 70 self.SetOmniboxText('chrome instant')
71 self.assertTrue(self.WaitUntil(self._DoneLoading)) 71 self.assertTrue(self.WaitUntil(self._DoneLoading))
72 location = self.GetInstantInfo()['location'] 72 location = self.GetInstantInfo()['location']
73 self.assertTrue('google.com' in location, 73 self.assertTrue('google.com' in location,
74 msg='No google.com in %s' % location) 74 msg='No google.com in %s' % location)
75 75
76 def testInstantCaseSensitivity(self): 76 def testInstantCaseSensitivity(self):
77 """Verify that Chrome Instant results case insensitive.""" 77 """Verify that Chrome Instant results are case insensitive."""
78 # Text in lowercase letters. 78 # Text in lowercase letters.
79 self.SetOmniboxText('google') 79 self.SetOmniboxText('google')
80 self.assertTrue(self.WaitUntil(self._DoneLoading)) 80 self.assertTrue(self.WaitUntil(self._DoneLoading))
81 lowercase_instant_info = self.GetInstantInfo() 81 lowercase_instant_info = self.GetInstantInfo()
82
82 # Text in uppercase letters. 83 # Text in uppercase letters.
83 self.SetOmniboxText('GOOGLE') 84 self.SetOmniboxText('GOOGLE')
84 self.assertTrue(self.WaitUntil(self._DoneLoading)) 85 self.assertTrue(self.WaitUntil(self._DoneLoading))
85 uppercase_instant_info = self.GetInstantInfo() 86 uppercase_instant_info = self.GetInstantInfo()
87
86 # Check lowercase and uppercase text results are same. 88 # Check lowercase and uppercase text results are same.
87 self.assertEquals(lowercase_instant_info, uppercase_instant_info, 89 self.assertEquals(lowercase_instant_info, uppercase_instant_info,
88 msg='Lowercase and Uppercase instant info doesn\'t match') 90 msg='Lowercase and uppercase Instant info do not match.')
91
89 # Text in mixed case letters. 92 # Text in mixed case letters.
90 self.SetOmniboxText('GooGle') 93 self.SetOmniboxText('GooGle')
91 self.assertTrue(self.WaitUntil(self._DoneLoading)) 94 self.assertTrue(self.WaitUntil(self._DoneLoading))
92 mixedcase_instant_info = self.GetInstantInfo() 95 mixedcase_instant_info = self.GetInstantInfo()
96
93 # Check mixedcase and uppercase text results are same. 97 # Check mixedcase and uppercase text results are same.
94 self.assertEquals(mixedcase_instant_info, uppercase_instant_info, 98 self.assertEquals(mixedcase_instant_info, uppercase_instant_info,
95 msg='Mixedcase and Uppercase instant info doesn\'t match') 99 msg='Mixedcase and uppercase Instant info do not match.')
96 100
97 def testInstantWithSearchEngineOtherThanGoogle(self): 101 def testInstantWithNonInstantSearchEngine(self):
98 """Verify that Instant is inactive for search engines other than Google.""" 102 """Verify that Instant is inactive for non-Instant search engines."""
99 # Check with Yahoo!. 103 # Check with Yahoo!, which doesn't support Instant yet.
100 self.MakeSearchEngineDefault('yahoo.com') 104 self.MakeSearchEngineDefault('yahoo.com')
101 self.assertFalse(self.GetInstantInfo()['active'], 105 self.assertFalse(self.GetInstantInfo()['active'],
102 msg='Instant is active for Yahoo!') 106 msg='Instant is active for Yahoo!')
103 # Check with Bing. 107
108 # Check with Bing, which doesn't support Instant yet.
104 self.MakeSearchEngineDefault('bing.com') 109 self.MakeSearchEngineDefault('bing.com')
105 self.assertFalse(self.GetInstantInfo()['active'], 110 self.assertFalse(self.GetInstantInfo()['active'],
106 msg='Instant is active for Bing.') 111 msg='Instant is active for Bing.')
107 112
108 def testInstantDisabledInIncognito(self): 113 def testInstantDisabledInIncognito(self):
109 """Test that instant is disabled in Incognito mode.""" 114 """Test that Instant is disabled in incognito mode."""
110 self.RunCommand(pyauto.IDC_NEW_INCOGNITO_WINDOW) 115 self.RunCommand(pyauto.IDC_NEW_INCOGNITO_WINDOW)
111 self.SetOmniboxText('google', windex=1) 116 self.SetOmniboxText('google', windex=1)
112 self.assertFalse(self.GetInstantInfo()['active'], 117 self.assertFalse(self.GetInstantInfo()['active'],
113 'Instant enabled in Incognito mode.') 118 'Instant enabled in incognito mode.')
114
115 def testInstantOverlayNotStoredInHistory(self):
116 """Test that instant overlay page is not stored in history."""
117 self.SetOmniboxText('google')
118 self.assertTrue(self.WaitUntil(self._DoneLoading))
119 history = self.GetHistoryInfo().History()
120 self.assertEqual(0, len(history))
121 119
122 def testInstantDisabledForURLs(self): 120 def testInstantDisabledForURLs(self):
123 """Test that instant is disabled for non-search URLs.""" 121 """Test that Instant is disabled for non-search URLs."""
124 self.SetOmniboxText('http://www.google.com/') 122 self.SetOmniboxText('http://www.google.com/')
125 self.WaitUntilOmniboxQueryDone() 123 self.WaitUntilOmniboxQueryDone()
126 self.assertFalse(self.GetInstantInfo()['current'], 124 self.assertFalse(self.GetInstantInfo()['current'],
127 'Instant enabled for non-search URLs.') 125 'Instant enabled for non-search URLs.')
126
128 self.SetOmniboxText('google.es') 127 self.SetOmniboxText('google.es')
129 self.WaitUntilOmniboxQueryDone() 128 self.WaitUntilOmniboxQueryDone()
130 self.assertFalse(self.GetInstantInfo()['current'], 129 self.assertFalse(self.GetInstantInfo()['current'],
131 'Instant enabled for non-search URLs.') 130 'Instant enabled for non-search URLs.')
131
132 self.SetOmniboxText(self.GetFileURLForDataPath('title2.html')) 132 self.SetOmniboxText(self.GetFileURLForDataPath('title2.html'))
133 self.WaitUntilOmniboxQueryDone() 133 self.WaitUntilOmniboxQueryDone()
134 self.assertFalse(self.GetInstantInfo()['current'], 134 self.assertFalse(self.GetInstantInfo()['current'],
135 'Instant enabled for non-search URLs.') 135 'Instant enabled for non-search URLs.')
136 136
137 def testInstantDisabledForJavaScript(self): 137 def testInstantDisabledForJavaScript(self):
138 """Test that instant is disabled for javascript URLs.""" 138 """Test that Instant is disabled for JavaScript URLs."""
139 self.SetOmniboxText('javascript:') 139 self.SetOmniboxText('javascript:')
140 self.assertFalse(self.GetInstantInfo()['current'], 140 self.assertFalse(self.GetInstantInfo()['current'],
141 'Instant enabled for javascript URL.') 141 'Instant enabled for JavaScript URL.')
142 142
143 def testInstantLoadsFor100CharsLongQuery(self): 143 def testInstantLoadsFor100CharsLongQuery(self):
144 """Test that instant loads for search query of 100 characters.""" 144 """Test that Instant loads for search query of 100 characters."""
145 query = 'abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz' \ 145 query = 'abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz' \
146 'abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuv' 146 'abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuv'
147 self.assertEqual(100, len(query)) 147 self.assertEqual(100, len(query))
148 self.SetOmniboxText(query) 148 self.SetOmniboxText(query)
149 self.assertTrue(self.WaitUntil(self._DoneLoadingGoogleQuery, args=[query])) 149 self.assertTrue(self.WaitUntil(self._DoneLoadingGoogleQuery, args=[query]))
150 150
151 def _BringUpInstant(self): 151 def _BringUpInstant(self):
152 """Helper function to bring up instant.""" 152 """Helper function to bring up Instant."""
153 self.SetOmniboxText('google') 153 self.SetOmniboxText('google')
154 self.assertTrue(self.WaitUntil(self._DoneLoading)) 154 self.assertTrue(self.WaitUntil(self._DoneLoading))
155 self.assertTrue('www.google.com' in self.GetInstantInfo()['location'], 155 self.assertTrue('www.google.com' in self.GetInstantInfo()['location'],
156 msg='No www.google.com in %s' % 156 msg='No www.google.com in %s' %
157 self.GetInstantInfo()['location']) 157 self.GetInstantInfo()['location'])
158 158
159 def testInstantOverlayNotStoredInHistory(self):
160 """Test that Instant overlay page is not stored in history."""
161 self._BringUpInstant()
162 history = self.GetHistoryInfo().History()
163 self.assertEqual(0, len(history), msg='Instant URL stored in history.')
164
159 def testFindInCanDismissInstant(self): 165 def testFindInCanDismissInstant(self):
160 """Test that instant preview is dismissed by find-in-page.""" 166 """Test that Instant preview is dismissed by find-in-page."""
161 self._BringUpInstant() 167 self._BringUpInstant()
162 self.OpenFindInPage() 168 self.OpenFindInPage()
163 self.assertEqual(self.GetActiveTabTitle(), 'New Tab') 169 self.assertFalse(self.GetInstantInfo()['current'],
170 'Find-in-page does not dismiss Instant.')
164 171
165 def testNTPCanDismissInstant(self): 172 def testNTPCanDismissInstant(self):
166 """Test that instant preview is dismissed by adding new tab page.""" 173 """Test that Instant preview is dismissed by adding new tab page."""
167 self.NavigateToURL('about:blank'); 174 self.NavigateToURL('about:blank');
168 self._BringUpInstant() 175 self._BringUpInstant()
169 self.AppendTab(pyauto.GURL('chrome://newtab')) 176 self.AppendTab(pyauto.GURL('chrome://newtab'))
170 self.CloseTab(tab_index=1) 177 self.assertFalse(self.GetInstantInfo()['current'],
171 self.assertEqual(self.GetActiveTabTitle(), 'about:blank') 178 'NTP does not dismiss Instant.')
172 179
173 def testExtnPageCanDismissInstant(self): 180 def testExtnPageCanDismissInstant(self):
174 """Test that instant preview is dismissed by extension page.""" 181 """Test that Instant preview is dismissed by extension page."""
175 self._BringUpInstant() 182 self._BringUpInstant()
176 self.AppendTab(pyauto.GURL('chrome://extensions')) 183 self.AppendTab(pyauto.GURL('chrome://extensions'))
177 self.CloseTab(tab_index=1) 184 self.assertFalse(self.GetInstantInfo()['current'],
178 self.assertEqual(self.GetActiveTabTitle(), 'New Tab') 185 'Extension page does not dismiss Instant.')
179
180 def testNewWindowCanDismissInstant(self):
181 """Test that instant preview is dismissed by New Window."""
182 self._BringUpInstant()
183 self.OpenNewBrowserWindow(True)
184 self.CloseBrowserWindow(1)
185 self.assertEqual(self.GetActiveTabTitle(), 'New Tab')
186
187 def testPreFetchInstantURLNotInHistory(self):
188 """Test that pre-fetched URLs are not saved in History."""
189 self._BringUpInstant()
190 history = self.GetHistoryInfo().History()
191 self.assertFalse(history, msg='Pre-feteched URL saved in History')
192 186
193 def _AssertInstantDoesNotDownloadFile(self, path): 187 def _AssertInstantDoesNotDownloadFile(self, path):
194 """Asserts instant does not download the specified file. 188 """Asserts Instant does not download the specified file.
195 189
196 Args: 190 Args:
197 path: Path to file. 191 path: Path to file.
198 """ 192 """
199 self.NavigateToURL('chrome://downloads') 193 self.NavigateToURL('chrome://downloads')
200 filepath = self.GetFileURLForDataPath(path) 194 filepath = self.GetFileURLForDataPath(path)
201 self.SetOmniboxText(filepath) 195 self.SetOmniboxText(filepath)
202 self.WaitUntilOmniboxQueryDone() 196 self.WaitUntilOmniboxQueryDone()
203 self.WaitForAllDownloadsToComplete() 197 self.WaitForAllDownloadsToComplete()
204 self.assertFalse(self.GetDownloadsInfo().Downloads(), 198 self.assertFalse(self.GetDownloadsInfo().Downloads(),
205 msg='Should not download: %s' % filepath) 199 msg='Should not download: %s' % filepath)
206 200
207 def testInstantDoesNotDownloadZipFile(self): 201 def testInstantDoesNotDownloadZipFile(self):
208 """Test that instant does not download zip file.""" 202 """Test that Instant does not download zip file."""
209 self._AssertInstantDoesNotDownloadFile(os.path.join('zip', 'test.zip')) 203 self._AssertInstantDoesNotDownloadFile(os.path.join('zip', 'test.zip'))
210 204
211 def testInstantDoesNotDownloadPDFFile(self): 205 def testInstantDoesNotDownloadPDFFile(self):
212 """Test that instant does not download PDF file.""" 206 """Test that Instant does not download PDF file."""
213 self._AssertInstantDoesNotDownloadFile(os.path.join('printing', 207 self._AssertInstantDoesNotDownloadFile(os.path.join('printing',
214 'cloud_print_unittest.pdf')) 208 'cloud_print_unittest.pdf'))
215 209
216
217 if __name__ == '__main__': 210 if __name__ == '__main__':
218 pyauto_functional.Main() 211 pyauto_functional.Main()
OLDNEW
« no previous file with comments | « chrome/test/functional/PYAUTO_TESTS ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698