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 filecmp | 6 import filecmp |
7 import logging | 7 import logging |
8 import os | 8 import os |
9 import shutil | 9 import shutil |
10 import sys | 10 import sys |
(...skipping 305 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
316 | 316 |
317 Args: | 317 Args: |
318 filename: the name of the file to trigger the download. | 318 filename: the name of the file to trigger the download. |
319 This should exist in the 'dangerous' directory. | 319 This should exist in the 'dangerous' directory. |
320 tab_index: tab index. Default 0. | 320 tab_index: tab index. Default 0. |
321 windex: window index. Default 0. | 321 windex: window index. Default 0. |
322 """ | 322 """ |
323 dangerous_dir = os.path.join( | 323 dangerous_dir = os.path.join( |
324 self.DataDir(), 'downloads', 'dangerous') | 324 self.DataDir(), 'downloads', 'dangerous') |
325 assert os.path.isfile(os.path.join(dangerous_dir, filename)) | 325 assert os.path.isfile(os.path.join(dangerous_dir, filename)) |
326 file_url = self.GetFileURLForDataPath(os.path.join( | 326 file_url = self.GetFileURLForPath(os.path.join( |
327 dangerous_dir, 'download-dangerous.html')) + '?' + filename | 327 dangerous_dir, 'download-dangerous.html')) + '?' + filename |
328 num_downloads = len(self.GetDownloadsInfo().Downloads()) | 328 num_downloads = len(self.GetDownloadsInfo().Downloads()) |
329 self.NavigateToURL(file_url, windex, tab_index) | 329 self.NavigateToURL(file_url, windex, tab_index) |
330 # It might take a while for the download to kick in, hold on until then. | 330 # It might take a while for the download to kick in, hold on until then. |
331 self.assertTrue(self.WaitUntil( | 331 self.assertTrue(self.WaitUntil( |
332 lambda: len(self.GetDownloadsInfo().Downloads()) == num_downloads + 1)) | 332 lambda: len(self.GetDownloadsInfo().Downloads()) == num_downloads + 1)) |
333 | 333 |
334 def testNoUnsafeDownloadsOnRestart(self): | 334 def testNoUnsafeDownloadsOnRestart(self): |
335 """Verify that unsafe file should not show up on session restart.""" | 335 """Verify that unsafe file should not show up on session restart.""" |
336 file_path = self._GetDangerousDownload() | 336 file_path = self._GetDangerousDownload() |
(...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
451 self.PerformActionOnDownload(self._GetDownloadId(), | 451 self.PerformActionOnDownload(self._GetDownloadId(), |
452 'save_dangerous_download') | 452 'save_dangerous_download') |
453 # Wait for the theme to be set automatically. | 453 # Wait for the theme to be set automatically. |
454 self.assertTrue(self.WaitUntilDownloadedThemeSet('camo theme')) | 454 self.assertTrue(self.WaitUntilDownloadedThemeSet('camo theme')) |
455 self.assertTrue(self.WaitUntil(lambda path: not os.path.exists(path), | 455 self.assertTrue(self.WaitUntil(lambda path: not os.path.exists(path), |
456 args=[downloaded_pkg])) | 456 args=[downloaded_pkg])) |
457 | 457 |
458 | 458 |
459 if __name__ == '__main__': | 459 if __name__ == '__main__': |
460 pyauto_functional.Main() | 460 pyauto_functional.Main() |
OLD | NEW |