OLD | NEW |
(Empty) | |
| 1 #!/usr/bin/python |
| 2 |
| 3 # Copyright (c) 2010 The Chromium Authors. All rights reserved. |
| 4 # Use of this source code is governed by a BSD-style license that can be |
| 5 # found in the LICENSE file. |
| 6 |
| 7 import os |
| 8 import unittest |
| 9 |
| 10 import pyauto_functional # Must be imported before pyauto |
| 11 import pyauto |
| 12 |
| 13 |
| 14 """Commonly used functions for PyAuto tests.""" |
| 15 |
| 16 def DownloadTestFile(test, file_name): |
| 17 """Download a zip file.""" |
| 18 download_dir = os.path.join(os.path.abspath(test.DataDir()), 'downloads') |
| 19 file_path = os.path.join(download_dir, file_name) |
| 20 file_url = test.GetFileURLForPath(file_path) |
| 21 downloaded_pkg = os.path.join(test.GetDownloadDirectory().value(), |
| 22 file_name) |
| 23 # Check if zip file already exists. If so then delete it. |
| 24 if os.path.exists(downloaded_pkg): |
| 25 self.RemoveTestFile(test, file_name) |
| 26 test.DownloadAndWaitForStart(file_url) |
| 27 # Wait for the download to finish |
| 28 test.WaitForAllDownloadsToComplete() |
| 29 |
| 30 def RemoveTestFile(test, file_name): |
| 31 """Delete a file from the downloads directory.""" |
| 32 downloaded_pkg = os.path.join(test.GetDownloadDirectory().value(), |
| 33 file_name) |
| 34 os.remove(downloaded_pkg) |
| 35 |
| 36 if __name__ == '__main__': |
| 37 Main() |
OLD | NEW |