Index: install_test/install_test.py |
=================================================================== |
--- install_test/install_test.py (revision 172669) |
+++ install_test/install_test.py (working copy) |
@@ -10,22 +10,18 @@ |
tests. Currently the only platform it supports is Windows. |
""" |
-import atexit |
import os |
-import platform |
-import stat |
import sys |
-import tempfile |
import unittest |
import urllib |
import chrome_installer_win |
_DIRECTORY = os.path.dirname(os.path.abspath(__file__)) |
-sys.path.append(os.path.join(os.path.dirname(_DIRECTORY), 'pyautolib')) |
sys.path.append(os.path.join(_DIRECTORY, os.path.pardir, os.path.pardir, |
os.path.pardir, 'third_party', 'webdriver', |
'pylib')) |
+sys.path.append(os.path.join(_DIRECTORY, os.path.pardir, 'pylib')) |
# This import should go after sys.path is set appropriately. |
from chrome import Chrome |
@@ -33,38 +29,9 @@ |
import selenium.webdriver.chrome.service as service |
from selenium.webdriver.chrome.service import WebDriverException |
-import pyauto_utils |
+from common import util |
-def MakeTempDir(parent_dir=None): |
- """Creates a temporary directory and returns an absolute path to it. |
- |
- The temporary directory is automatically deleted when the python interpreter |
- exits normally. |
- |
- Args: |
- parent_dir: the directory to create the temp dir in. If None, the system |
- temp dir is used. |
- |
- Returns: |
- The absolute path to the temporary directory. |
- """ |
- path = tempfile.mkdtemp(dir=parent_dir) |
- def DeleteDir(): |
- # Don't use shutil.rmtree because it can't delete read-only files on Win. |
- for root, dirs, files in os.walk(path, topdown=False): |
- for name in files: |
- filename = os.path.join(root, name) |
- os.chmod(filename, stat.S_IWRITE) |
- os.remove(filename) |
- for name in dirs: |
- os.rmdir(os.path.join(root, name)) |
- # Delete parent directory after its contents have been removed. |
- os.rmdir(path) |
- atexit.register(DeleteDir) |
- return path |
- |
- |
class InstallTest(unittest.TestCase): |
"""Base updater test class. |
@@ -154,7 +121,7 @@ |
if self._install_type == chrome_installer_win.InstallationType.SYSTEM: |
options.append('--system-level') |
if master_pref: |
- options.append('--installerdata="%s"' % master_pref) |
Paweł Hajdan Jr.
2012/12/13 19:28:02
What's the problem with quotes here?
nkang1
2012/12/13 19:45:59
The installer doesn't load the master preferences
|
+ options.append('--installerdata=%s' % master_pref) |
self._installation = chrome_installer_win.Install( |
self._installer_paths[build], |
self._install_type, |
@@ -177,7 +144,7 @@ |
url: URL where the file is located. |
path: Location where file will be downloaded. |
""" |
- if not pyauto_utils.DoesUrlExist(url): |
+ if not util.DoesUrlExist(url): |
raise RuntimeError('Either the URL or the file name is invalid.') |
urllib.urlretrieve(url, path) |
@@ -209,13 +176,11 @@ |
base_url: Base url of the 'official chrome builds' page. |
options: A list that contains options to be passed to Chrome installer. |
""" |
- system = ({'Windows': 'win', |
- 'Darwin': 'mac', |
- 'Linux': 'linux'}).get(platform.system()) |
+ system = util.GetPlatformName() |
InstallTest._install_build = install_build |
InstallTest._update_builds = update_builds |
InstallTest._installer_options = options |
- tempdir = MakeTempDir() |
+ tempdir = util.MakeTempDir() |
builds = [] |
if InstallTest._install_build: |
builds.append(InstallTest._install_build) |