OLD | NEW |
---|---|
1 #!/usr/bin/python | 1 #!/usr/bin/python |
2 # Copyright (c) 2010 The Chromium Authors. All rights reserved. | 2 # Copyright (c) 2010 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 glob | 6 import glob |
7 import os | 7 import os |
8 import re | 8 import re |
9 import shutil | 9 import shutil |
10 import tempfile | 10 import tempfile |
(...skipping 289 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
300 old_matches = self._GetOmniboxMatchesFor(search_text) | 300 old_matches = self._GetOmniboxMatchesFor(search_text) |
301 url = self.GetFileURLForPath( | 301 url = self.GetFileURLForPath( |
302 os.path.join(self.DataDir(), 'find_in_page', 'largepage.html')) | 302 os.path.join(self.DataDir(), 'find_in_page', 'largepage.html')) |
303 self.AppendTab(pyauto.GURL(url)) | 303 self.AppendTab(pyauto.GURL(url)) |
304 self.assertTrue(self.WaitUntil(lambda: self._GotNewMatches(len(old_matches), | 304 self.assertTrue(self.WaitUntil(lambda: self._GotNewMatches(len(old_matches), |
305 search_text), timeout=1)) | 305 search_text), timeout=1)) |
306 matches = self._GetOmniboxMatchesFor(search_text) | 306 matches = self._GetOmniboxMatchesFor(search_text) |
307 matches_description = [x for x in matches if x['destination_url'] == url] | 307 matches_description = [x for x in matches if x['destination_url'] == url] |
308 self.assertEqual(1, len(matches_description)) | 308 self.assertEqual(1, len(matches_description)) |
309 | 309 |
310 def _verifyOpenHistoryPageOption(self, search_text): | |
Nirnimesh
2011/01/06 02:09:17
This is a misnomer. Doens't really 'verify'
Renam
| |
311 """Verify if history page option is available or not in the omnnibox | |
312 results""" | |
313 matches = self._GetOmniboxMatchesFor(search_text) | |
314 matches_description = [x for x in matches if x['type'] == | |
315 'open-history-page'] | |
316 if len(matches_description) == 0: | |
Nirnimesh
2011/01/06 02:09:17
return len(matches_description) != 0
| |
317 return False | |
318 return True | |
319 | |
310 def testRecentPageHistory(self): | 320 def testRecentPageHistory(self): |
311 """Verify that omnibox shows recent history option in the visited | 321 """Verify that omnibox shows recent history option in the visited |
312 url list.""" | 322 url list.""" |
313 search_text = 'file' | 323 search_text = 'file' |
314 sites = glob.glob(os.path.join(self.DataDir(), 'find_in_page', '*.html')) | 324 sites = glob.glob(os.path.join(self.DataDir(), 'find_in_page', '*.html')) |
315 for site in sites: | 325 for site in sites: |
316 self.NavigateToURL(self.GetFileURLForPath(site)) | 326 self.NavigateToURL(self.GetFileURLForPath(site)) |
317 old_matches = self._GetOmniboxMatchesFor(search_text) | |
318 # Using max timeout as 120 seconds, since expected page only shows up | 327 # Using max timeout as 120 seconds, since expected page only shows up |
319 # after > 60 seconds on some machines and default timeout is less than that. | 328 # after > 60 seconds on some machines and default timeout is less than that. |
320 # TODO (Nirnimesh): design an api using which we can push history changes to | 329 # TODO (Nirnimesh): design an api using which we can push history changes to |
321 # omnibox results. | 330 # omnibox results. |
322 self.assertTrue(self.WaitUntil( | 331 self.assertTrue(self.WaitUntil( |
323 lambda: self._GotNewMatches(len(old_matches), search_text), | 332 lambda: self._verifyOpenHistoryPageOption(search_text), |
324 timeout=120)) | 333 timeout=120)) |
325 matches = self._GetOmniboxMatchesFor(search_text) | |
326 matches_description = [x for x in matches if x['type'] == | |
327 'open-history-page'] | |
328 self.assertEqual(1, len(matches_description)) | |
329 | 334 |
330 def _VerifyHasBookmarkResult(self, matches): | 335 def _VerifyHasBookmarkResult(self, matches): |
331 """Verify that we have a bookmark result.""" | 336 """Verify that we have a bookmark result.""" |
332 matches_starred = [result for result in matches if result['starred']] | 337 matches_starred = [result for result in matches if result['starred']] |
333 self.assertTrue(matches_starred) | 338 self.assertTrue(matches_starred) |
334 self.assertEqual(1, len(matches_starred)) | 339 self.assertEqual(1, len(matches_starred)) |
335 | 340 |
336 def testBookmarkResultInNewTabAndWindow(self): | 341 def testBookmarkResultInNewTabAndWindow(self): |
337 """Verify that omnibox can recognize a bookmark within search options | 342 """Verify that omnibox can recognize a bookmark within search options |
338 in new tabs and windows.""" | 343 in new tabs and windows.""" |
(...skipping 12 matching lines...) Expand all Loading... | |
351 self.NavigateToURL(url, 1, 0) | 356 self.NavigateToURL(url, 1, 0) |
352 self._CheckBookmarkResultForVariousInputs(url, title, windex=1) | 357 self._CheckBookmarkResultForVariousInputs(url, title, windex=1) |
353 self.RunCommand(pyauto.IDC_NEW_INCOGNITO_WINDOW) | 358 self.RunCommand(pyauto.IDC_NEW_INCOGNITO_WINDOW) |
354 self.assertEqual(3, self.GetBrowserWindowCount()) | 359 self.assertEqual(3, self.GetBrowserWindowCount()) |
355 self.NavigateToURL(url, 2, 0) | 360 self.NavigateToURL(url, 2, 0) |
356 self._CheckBookmarkResultForVariousInputs(url, title, windex=2) | 361 self._CheckBookmarkResultForVariousInputs(url, title, windex=2) |
357 | 362 |
358 | 363 |
359 if __name__ == '__main__': | 364 if __name__ == '__main__': |
360 pyauto_functional.Main() | 365 pyauto_functional.Main() |
OLD | NEW |