Commit 8b160034 authored by kkania@google.com's avatar kkania@google.com

Change from absolute paths to relative paths to allow tests,etc. to be located...

Change from absolute paths to relative paths to allow tests,etc. to be located in any directory, as long as the directory structure is correct.
Original review at: http://codereview.chromium.org/344013.


git-svn-id: svn://svn.chromium.org/chrome/trunk/src@30377 0039d316-1c4b-4281-b951-d872f2087c98
parent e48aeb48
...@@ -62,22 +62,21 @@ SCREEN_BPP = 32 ...@@ -62,22 +62,21 @@ SCREEN_BPP = 32
join = os.path.join join = os.path.join
if util.IsWindows(): if util.IsWindows():
IMAGE_DIFF_PATH = join(const.O3D_PATH, 'third_party', 'pdiff', 'files', IMAGE_DIFF_PATH = join(const.BASE_PATH, 'third_party', 'pdiff', 'files',
'bin', 'win', 'perceptualdiff.exe') 'bin', 'win', 'perceptualdiff.exe')
elif util.IsMac(): elif util.IsMac():
IMAGE_DIFF_PATH = join(const.O3D_PATH, 'third_party', 'pdiff', 'files', IMAGE_DIFF_PATH = join(const.BASE_PATH, 'third_party', 'pdiff', 'files',
'bin', 'mac', 'perceptualdiff') 'bin', 'mac', 'perceptualdiff')
else: else:
IMAGE_DIFF_PATH = join(const.O3D_PATH, 'third_party', 'pdiff', 'files', IMAGE_DIFF_PATH = join(const.BASE_PATH, 'third_party', 'pdiff', 'files',
'bin', 'linux', 'perceptualdiff') 'bin', 'linux', 'perceptualdiff')
SELENIUM_TEST_RUNNER_PATH = join(const.O3D_PATH, 'o3d', 'tests', 'selenium', SELENIUM_TEST_RUNNER_PATH = join(const.TEST_PATH, 'selenium', 'main.py')
'main.py')
SELENIUM_JAR_PATH = join(const.O3D_PATH, 'third_party', 'selenium_rc', 'files', SELENIUM_JAR_PATH = join(const.BASE_PATH, 'third_party', 'selenium_rc', 'files',
'selenium-server', 'selenium-server.jar') 'selenium-server', 'selenium-server.jar')
O3D_REFERENCE_IMAGES_PATH = join(const.O3D_PATH, 'o3d', 'o3d_assets', 'tests', O3D_REFERENCE_IMAGES_PATH = join(const.O3D_PATH, 'o3d_assets', 'tests',
'screenshots') 'screenshots')
SCREENSHOTS_PATH = join(const.RESULTS_PATH,'screenshots') SCREENSHOTS_PATH = join(const.RESULTS_PATH,'screenshots')
...@@ -193,23 +192,18 @@ def RunTest(browser): ...@@ -193,23 +192,18 @@ def RunTest(browser):
Returns: Returns:
True on success. True on success.
""" """
# Run selenium test.
os.chdir(const.AUTO_PATH)
if util.IsWindows(): if util.IsWindows():
if not run_util.EnsureWindowsScreenResolution(SCREEN_WIDTH, SCREEN_HEIGHT, if not run_util.EnsureWindowsScreenResolution(SCREEN_WIDTH, SCREEN_HEIGHT,
SCREEN_BPP): SCREEN_BPP):
logging.error('Failed to configure screen resolution.') logging.warn('Could not detect/change screen resolution.')
return 1
# Clear all screenshots. # Clear all screenshots.
logging.info('** Deleting previous screenshots.') logging.info('** Deleting previous screenshots.')
if os.path.exists(SCREENSHOTS_PATH): if os.path.exists(SCREENSHOTS_PATH):
shutil.rmtree(SCREENSHOTS_PATH) shutil.rmtree(SCREENSHOTS_PATH)
os.makedirs(SCREENSHOTS_PATH) os.makedirs(SCREENSHOTS_PATH)
logging.info('** Running selenium tests...') logging.info('** Running selenium tests...')
...@@ -263,7 +257,7 @@ def main(argv): ...@@ -263,7 +257,7 @@ def main(argv):
config_path = argv[1] config_path = argv[1]
else: else:
# Use default config file. # Use default config file.
config_path = os.path.join(const.HOME_PATH, 'test_config.txt') config_path = os.path.join(const.HOME, 'test_config.txt')
# Uninstall/Install plugin. # Uninstall/Install plugin.
if not run_util.UninstallO3DPlugin(): if not run_util.UninstallO3DPlugin():
......
#!/usr/bin/python2.6.2 #!/usr/bin/python2.6.2
# Copyright 2009, Google Inc. # Copyright 2009, Google Inc.
# All rights reserved. # All rights reserved.
# #
# Redistribution and use in source and binary forms, with or without # Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are # modification, are permitted provided that the following conditions are
# met: # met:
# #
# * Redistributions of source code must retain the above copyright # * Redistributions of source code must retain the above copyright
# notice, this list of conditions and the following disclaimer. # notice, this list of conditions and the following disclaimer.
# * Redistributions in binary form must reproduce the above # * Redistributions in binary form must reproduce the above
# copyright notice, this list of conditions and the following disclaimer # copyright notice, this list of conditions and the following disclaimer
# in the documentation and/or other materials provided with the # in the documentation and/or other materials provided with the
# distribution. # distribution.
# * Neither the name of Google Inc. nor the names of its # * Neither the name of Google Inc. nor the names of its
# contributors may be used to endorse or promote products derived from # contributors may be used to endorse or promote products derived from
# this software without specific prior written permission. # this software without specific prior written permission.
# #
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT # "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR # LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT # A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, # OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, # LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
"""Defines common O3D test runner constants. """Defines common O3D test runner constants. This file determines paths to
other O3D components relatively, so it must be placed in the right location.
"""
"""
import os
import sys import os
import sys
import util
import util
join = os.path.join
join = os.path.join
if util.IsWindows():
AUTO_PATH = r'C:\auto' # Make sure OS is supported.
PYTHON = r'C:\Python24\python.exe' if not util.IsWindows() and not util.IsMac() and not util.IsLinux():
if util.IsXP(): print 'Only Windows, Mac, and Linux are supported.'
HOME_PATH = r'C:\Documents and Settings\testing' sys.exit(1)
else:
HOME_PATH = r'C:\Users\testing' # This path should be root/o3d/tests.
TEST_PATH = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
elif util.IsMac(): # This path should be root/o3d.
AUTO_PATH = '/Users/testing/auto' O3D_PATH = os.path.dirname(TEST_PATH)
PYTHON = 'python' # This path should be root, i.e., the checkout location.
HOME_PATH = '/Users/testing' BASE_PATH = os.path.dirname(O3D_PATH)
elif util.IsLinux():
AUTO_PATH = '/home/testing/auto' HOME = os.path.expanduser('~')
PYTHON = 'python' if HOME == '~':
HOME_PATH = '/home/testing' print 'Cannot find user home directory.'
sys.exit(1)
else:
print 'Only Windows, Mac, and Linux are supported.' if util.IsWindows():
sys.exit(1) PYTHON = r'C:\Python24\python.exe'
else:
O3D_PATH = join(AUTO_PATH, 'o3d') PYTHON = 'python'
SCRIPTS_PATH = join(AUTO_PATH, 'scripts')
RESULTS_PATH = join(AUTO_PATH, 'results') # Note: this path may or may not exist.
SOFTWARE_PATH = join(AUTO_PATH, 'software') RESULTS_PATH = join(TEST_PATH, 'results')
# Build directories. # Build directories.
if util.IsWindows(): if util.IsWindows():
BUILD_PATH = join(O3D_PATH, 'o3d', 'build') BUILD_PATH = join(O3D_PATH, 'build')
elif util.IsMac(): elif util.IsMac():
BUILD_PATH = join(O3D_PATH, 'xcodebuild') BUILD_PATH = join(BASE_PATH, 'xcodebuild')
else: else:
BUILD_PATH = join(O3D_PATH, 'sconsbuild') BUILD_PATH = join(BASE_PATH, 'sconsbuild')
if os.path.exists(join(BUILD_PATH, 'Debug')): # Product directory.
PRODUCT_DIR_PATH = join(BUILD_PATH, 'Debug') if os.path.exists(join(BUILD_PATH, 'Debug')):
else: PRODUCT_DIR_PATH = join(BUILD_PATH, 'Debug')
PRODUCT_DIR_PATH = join(BUILD_PATH, 'Release') elif os.path.exists(join(BUILD_PATH, 'Release')):
PRODUCT_DIR_PATH = join(BUILD_PATH, 'Release')
# Plugin locations. else:
INSTALL_PATHS = [] print 'Cannot find Debug or Release folder in ' + BUILD_PATH
if util.IsWindows(): sys.exit(1)
INSTALL_PATHS += [join(HOME_PATH, 'Application Data', 'Mozilla',
'plugins', 'npo3dautoplugin.dll')] # Plugin locations.
INSTALL_PATHS += [join(HOME_PATH, 'Application Data', 'Google', 'O3D', INSTALL_PATHS = []
'o3d_host.dll')] if util.IsWindows():
elif util.IsMac(): INSTALL_PATHS += [join(HOME, 'Application Data', 'Mozilla',
INSTALL_PATHS += ['/Library/Internet Plug-Ins/O3D.plugin'] 'plugins', 'npo3dautoplugin.dll')]
else: INSTALL_PATHS += [join(HOME, 'Application Data', 'Google', 'O3D',
INSTALL_PATHS += [join(HOME_PATH, '.mozilla', 'plugins', 'o3d_host.dll')]
'libnpo3dautoplugin.so')] elif util.IsMac():
INSTALL_PATHS += ['/Library/Internet Plug-Ins/O3D.plugin']
else:
INSTALL_PATHS += [join(HOME, '.mozilla', 'plugins',
'libnpo3dautoplugin.so')]
...@@ -42,8 +42,9 @@ import sys ...@@ -42,8 +42,9 @@ import sys
import runner_constants as const import runner_constants as const
import util import util
CHANGE_RESOLUTION_PATH = (const.O3D_PATH + '/o3d/tests/lab' CHANGE_RESOLUTION_PATH = os.path.join(const.TEST_PATH, 'lab',
'/ChangeResolution/Debug/changeresolution.exe') 'ChangeResolution','Debug',
'changeresolution.exe')
def EnsureWindowsScreenResolution(width, height, bpp): def EnsureWindowsScreenResolution(width, height, bpp):
"""Performs all steps needed to configure system for testing on Windows. """Performs all steps needed to configure system for testing on Windows.
...@@ -55,10 +56,10 @@ def EnsureWindowsScreenResolution(width, height, bpp): ...@@ -55,10 +56,10 @@ def EnsureWindowsScreenResolution(width, height, bpp):
Returns: Returns:
True on success. True on success.
""" """
if not os.path.exists(CHANGE_RESOLUTION_PATH):
return False
command = 'call "%s" %d %d %d' % (CHANGE_RESOLUTION_PATH, width, height, bpp) command = 'call "%s" %d %d %d' % (CHANGE_RESOLUTION_PATH, width, height, bpp)
our_process = subprocess.Popen(command, our_process = subprocess.Popen(command,
shell=True, shell=True,
stdout=None, stdout=None,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment