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

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

Issue 7544026: Fix for flakiness in pyauto automation hook WaitForDownloadsToComplete. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Merged with trunk; awaiting green trybots. Created 9 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/test_utils.py ('k') | chrome/test/pyautolib/download_info.py » ('j') | 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 # Copyright (c) 2011 The Chromium Authors. All rights reserved. 2 # Copyright (c) 2011 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 logging 7 import logging
8 import os 8 import os
9 import shutil 9 import shutil
10 import tempfile 10 import tempfile
(...skipping 414 matching lines...) Expand 10 before | Expand all | Expand 10 after
425 # be given unicode strings to "do the right thing" on win. 425 # be given unicode strings to "do the right thing" on win.
426 # Ref: http://boodebr.org/main/python/all-about-python-and-unicode 426 # Ref: http://boodebr.org/main/python/all-about-python-and-unicode
427 try: 427 try:
428 for filename in crazy_filenames: # filename is unicode. 428 for filename in crazy_filenames: # filename is unicode.
429 utf8_filename = filename.encode('utf-8') 429 utf8_filename = filename.encode('utf-8')
430 file_path = os.path.join(temp_dir, utf8_filename) 430 file_path = os.path.join(temp_dir, utf8_filename)
431 _CreateFile(os.path.join(temp_dir, filename)) # unicode file. 431 _CreateFile(os.path.join(temp_dir, filename)) # unicode file.
432 file_url = self.GetFileURLForPath(file_path) 432 file_url = self.GetFileURLForPath(file_path)
433 downloaded_file = os.path.join(download_dir, filename) 433 downloaded_file = os.path.join(download_dir, filename)
434 os.path.exists(downloaded_file) and os.remove(downloaded_file) 434 os.path.exists(downloaded_file) and os.remove(downloaded_file)
435 pre_download_ids = [x['id']
436 for x in self.GetDownloadsInfo().Downloads()]
435 self.DownloadAndWaitForStart(file_url) 437 self.DownloadAndWaitForStart(file_url)
436 # Wait for files and remove them as we go. 438 # Wait for files and remove them as we go.
437 self.WaitForAllDownloadsToComplete() 439 self.WaitForAllDownloadsToComplete(pre_download_ids)
438 os.path.exists(downloaded_file) and os.remove(downloaded_file) 440 os.path.exists(downloaded_file) and os.remove(downloaded_file)
439 finally: 441 finally:
440 shutil.rmtree(unicode(temp_dir)) # unicode so that win treats nicely. 442 shutil.rmtree(unicode(temp_dir)) # unicode so that win treats nicely.
441 443
442 def testHistoryNotTranslated(self): 444 def testHistoryNotTranslated(self):
443 """Tests navigating to History page with other languages.""" 445 """Tests navigating to History page with other languages."""
444 # Build the history with non-English content. 446 # Build the history with non-English content.
445 history_file = os.path.join( 447 history_file = os.path.join(
446 self.DataDir(), 'translate', 'crazy_history.txt') 448 self.DataDir(), 'translate', 'crazy_history.txt')
447 history_items = self.EvalDataFrom(history_file) 449 history_items = self.EvalDataFrom(history_file)
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
511 def testNoTranslateInfobarAfterNeverTranslate(self): 513 def testNoTranslateInfobarAfterNeverTranslate(self):
512 """Verify Translate Info bar should not stay on the page after opting 514 """Verify Translate Info bar should not stay on the page after opting
513 Never translate the page""" 515 Never translate the page"""
514 url = self._GetDefaultSpanishURL() 516 url = self._GetDefaultSpanishURL()
515 self._NavigateAndWaitForBar(url) 517 self._NavigateAndWaitForBar(url)
516 self.SelectTranslateOption('never_translate_language') 518 self.SelectTranslateOption('never_translate_language')
517 self.assertFalse(self.GetBrowserInfo()['windows'][0]['tabs'][0]['infobars']) 519 self.assertFalse(self.GetBrowserInfo()['windows'][0]['tabs'][0]['infobars'])
518 520
519 if __name__ == '__main__': 521 if __name__ == '__main__':
520 pyauto_functional.Main() 522 pyauto_functional.Main()
OLDNEW
« no previous file with comments | « chrome/test/functional/test_utils.py ('k') | chrome/test/pyautolib/download_info.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698