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

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

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

Powered by Google App Engine
This is Rietveld 408576698