| Index: chrome/test/functional/test_utils.py
|
| ===================================================================
|
| --- chrome/test/functional/test_utils.py (revision 0)
|
| +++ chrome/test/functional/test_utils.py (revision 0)
|
| @@ -0,0 +1,37 @@
|
| +#!/usr/bin/python
|
| +
|
| +# Copyright (c) 2010 The Chromium Authors. All rights reserved.
|
| +# Use of this source code is governed by a BSD-style license that can be
|
| +# found in the LICENSE file.
|
| +
|
| +import os
|
| +import unittest
|
| +
|
| +import pyauto_functional # Must be imported before pyauto
|
| +import pyauto
|
| +
|
| +
|
| +"""Commonly used functions for PyAuto tests."""
|
| +
|
| +def DownloadTestFile(test, file_name):
|
| + """Download a zip file."""
|
| + download_dir = os.path.join(os.path.abspath(test.DataDir()), 'downloads')
|
| + file_path = os.path.join(download_dir, file_name)
|
| + file_url = test.GetFileURLForPath(file_path)
|
| + downloaded_pkg = os.path.join(test.GetDownloadDirectory().value(),
|
| + file_name)
|
| + # Check if zip file already exists. If so then delete it.
|
| + if os.path.exists(downloaded_pkg):
|
| + self.RemoveTestFile(test, file_name)
|
| + test.DownloadAndWaitForStart(file_url)
|
| + # Wait for the download to finish
|
| + test.WaitForAllDownloadsToComplete()
|
| +
|
| +def RemoveTestFile(test, file_name):
|
| + """Delete a file from the downloads directory."""
|
| + downloaded_pkg = os.path.join(test.GetDownloadDirectory().value(),
|
| + file_name)
|
| + os.remove(downloaded_pkg)
|
| +
|
| +if __name__ == '__main__':
|
| + Main()
|
|
|