OLD | NEW |
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 os | 6 import os |
7 | 7 |
8 import pyauto_functional # must be imported before pyauto | 8 import pyauto_functional # must be imported before pyauto |
9 | 9 |
10 import chromeos.file_browser | 10 import chromeos.file_browser |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
45 path = os.path.abspath(os.path.join(self.DataDir(), | 45 path = os.path.abspath(os.path.join(self.DataDir(), |
46 'pyauto_private', 'office')) | 46 'pyauto_private', 'office')) |
47 # Copy sample files to Downloads directory. | 47 # Copy sample files to Downloads directory. |
48 for (path, dirs, private_office_files) in os.walk(path): | 48 for (path, dirs, private_office_files) in os.walk(path): |
49 # Open sample files: .ppt, .pptx, .doc, .docx, xls, xlsx. | 49 # Open sample files: .ppt, .pptx, .doc, .docx, xls, xlsx. |
50 for fname in private_office_files: | 50 for fname in private_office_files: |
51 test_utils.CopyFileFromDataDirToDownloadDir(self, os.path.join(path, | 51 test_utils.CopyFileFromDataDirToDownloadDir(self, os.path.join(path, |
52 fname)) | 52 fname)) |
53 file_browser = self._GetFullPageFileBrowser() | 53 file_browser = self._GetFullPageFileBrowser() |
54 self.assertTrue(file_browser, msg='File browser failed to initialize.') | 54 self.assertTrue(file_browser, msg='File browser failed to initialize.') |
55 self.assertTrue(file_browser.Select(fname), | 55 |
| 56 def _SelectFile(): |
| 57 try: |
| 58 file_browser.Select(fname) |
| 59 return True |
| 60 except AssertionError: |
| 61 return False |
| 62 |
| 63 self.assertTrue(self.WaitUntil(_SelectFile), |
56 msg='"%s" does not exist.' % fname) | 64 msg='"%s" does not exist.' % fname) |
57 file_browser.ExecuteDefaultTask() | 65 file_browser.ExecuteDefaultTask() |
58 self.assertTrue(self.WaitUntil(self.GetActiveTabTitle, | 66 self.assertTrue(self.WaitUntil(self.GetActiveTabTitle, |
59 expect_retval=fname), | 67 expect_retval=fname), |
60 msg='"%s" does not open.' % fname) | 68 msg='"%s" does not open.' % fname) |
61 # Close the document viewing tab after use. | 69 # Close the document viewing tab after use. |
62 self.CloseTab(tab_index=1) | 70 self.CloseTab(tab_index=1) |
63 | 71 |
64 | 72 |
65 if __name__ == '__main__': | 73 if __name__ == '__main__': |
66 pyauto_functional.Main() | 74 pyauto_functional.Main() |
OLD | NEW |