Ejemplo n.º 1
0
 def GetChromedriverPath():
     if util.IsWin():
         return 'chrome-win32.test/chromedriver.exe'
     elif util.IsMac():
         return 'chrome-mac.test/chromedriver'
     elif util.IsLinux():
         return 'chrome-linux.test/chromedriver'
Ejemplo n.º 2
0
 def GetDirName(revision):
   if util.IsWindows():
     return 'chrome-win' if int(revision) > 591478 else 'chrome-win32'
   elif util.IsMac():
     return 'chrome-mac'
   elif util.IsLinux():
     return 'chrome-linux'
Ejemplo n.º 3
0
def MaybeRelease(revision):
  # Version is embedded as: const char kChromeDriverVersion[] = "0.1";
  # Minimum supported Chrome version is embedded as:
  # const int kMinimumSupportedChromeVersion[] = {27, 0, 1453, 0};
  with open(os.path.join(_THIS_DIR, 'chrome', 'version.cc'), 'r') as f:
    lines = f.readlines()
    version_line = filter(lambda x: 'kChromeDriverVersion' in x, lines)
    chrome_min_version_line = filter(
        lambda x: 'kMinimumSupportedChromeVersion' in x, lines)
  version = version_line[0].split('"')[1]
  chrome_min_version = chrome_min_version_line[0].split('{')[1].split(',')[0]
  with open(os.path.join(chrome_paths.GetSrc(), 'chrome', 'VERSION'), 'r') as f:
    chrome_max_version = f.readlines()[0].split('=')[1]

  bitness = '32'
  if util.IsLinux() and platform.architecture()[0] == '64bit':
    bitness = '64'
  zip_name = 'chromedriver_%s%s_%s.zip' % (
      util.GetPlatformName(), bitness, version)

  site = 'https://code.google.com/p/chromedriver/downloads/list'
  s = urllib2.urlopen(site)
  downloads = s.read()
  s.close()

  if zip_name in downloads:
    return 0

  util.MarkBuildStepStart('releasing %s' % zip_name)
  if util.IsWindows():
    server_orig_name = 'chromedriver2_server.exe'
    server_name = 'chromedriver.exe'
  else:
    server_orig_name = 'chromedriver2_server'
    server_name = 'chromedriver'
  server = os.path.join(chrome_paths.GetBuildDir([server_orig_name]),
                        server_orig_name)

  print 'Zipping ChromeDriver server', server
  temp_dir = util.MakeTempDir()
  zip_path = os.path.join(temp_dir, zip_name)
  f = zipfile.ZipFile(zip_path, 'w', zipfile.ZIP_DEFLATED)
  f.write(server, server_name)
  f.close()

  cmd = [
      sys.executable,
      os.path.join(_THIS_DIR, 'third_party', 'googlecode',
                   'googlecode_upload.py'),
      '--summary',
      'ChromeDriver server for %s%s (v%s.%s.dyu) supports Chrome v%s-%s' % (
          util.GetPlatformName(), bitness, version, revision,
          chrome_min_version, chrome_max_version),
      '--project', 'chromedriver',
      '--user', '*****@*****.**',
      zip_path
  ]
  with open(os.devnull, 'wb') as no_output:
    if subprocess.Popen(cmd, stdout=no_output, stderr=no_output).wait():
      util.MarkBuildStepError()
Ejemplo n.º 4
0
 def GetChromePathFromPackage():
     if util.IsWindows():
         return 'chrome.exe'
     elif util.IsMac():
         return 'Chromium.app/Contents/MacOS/Chromium'
     elif util.IsLinux():
         return 'chrome'
Ejemplo n.º 5
0
def GetLatestSnapshotPosition():
  """Returns the latest commit position of snapshot build."""
  latest_revision = GetLatestSnapshotVersion()
  if util.IsLinux() and platform.architecture()[0] == '32bit':
    return GetCommitPositionFromGitHash(latest_revision)
  else:
    return latest_revision
Ejemplo n.º 6
0
 def GetZipName(revision):
     if util.IsWindows():
         return revision + '/chrome-win32.zip'
     elif util.IsMac():
         return revision + '/chrome-mac.zip'
     elif util.IsLinux():
         return revision + '/chrome-linux.zip'
Ejemplo n.º 7
0
 def GetZipName():
     if util.IsWindows():
         return 'chrome-win32'
     elif util.IsMac():
         return 'chrome-mac'
     elif util.IsLinux():
         return 'chrome-linux'
Ejemplo n.º 8
0
def GetLatestSnapshotPosition():
    """Returns the latest commit position of snapshot build."""
    latest_revision = GetLatestRevision()
    if util.IsLinux() and not util.Is64Bit():
        return GetCommitPositionFromGitHash(latest_revision)
    else:
        return latest_revision
Ejemplo n.º 9
0
 def GetZipName(revision):
   if util.IsWindows():
     return revision + (
         '/chrome-win.zip' if int(revision) > 591478 else '/chrome-win32.zip')
   elif util.IsMac():
     return revision + '/chrome-mac.zip'
   elif util.IsLinux():
     return revision + '/chrome-linux.zip'
Ejemplo n.º 10
0
def _GetDownloadPlatform():
  """Returns the name for this platform on the archive site."""
  if util.IsWindows():
    return 'Win'
  elif util.IsMac():
    return 'Mac'
  elif util.IsLinux():
    return 'Linux_x64'
Ejemplo n.º 11
0
def _GetDownloadPlatform():
  """Returns the name for this platform on the archive site."""
  if util.IsWindows():
    return 'win32_rel'
  elif util.IsMac():
    return 'mac_rel'
  elif util.IsLinux():
    return 'linux_rel'
def main():
    parser = optparse.OptionParser()
    parser.add_option(
        '',
        '--android-packages',
        help='Comma separated list of application package names, '
        'if running tests on Android.')
    parser.add_option('-r', '--revision', type='int', help='Chromium revision')
    parser.add_option(
        '',
        '--update-log',
        action='store_true',
        help='Update the test results log (only applicable to Android)')
    options, _ = parser.parse_args()

    bitness = '32'
    if util.IsLinux() and platform_module.architecture()[0] == '64bit':
        bitness = '64'
    platform = '%s%s' % (util.GetPlatformName(), bitness)
    if options.android_packages:
        platform = 'android'

    if platform != 'android':
        _KillChromes()
    _CleanTmpDir()

    if platform == 'android':
        if not options.revision and options.update_log:
            parser.error('Must supply a --revision with --update-log')
        _DownloadPrebuilts()
    else:
        if not options.revision:
            parser.error('Must supply a --revision')
        if platform == 'linux64':
            _ArchivePrebuilts(options.revision)
        _WaitForLatestSnapshot(options.revision)

    _AddToolsToPath(platform)

    cmd = [
        sys.executable,
        os.path.join(_THIS_DIR, 'test', 'run_all_tests.py'),
    ]
    if platform == 'android':
        cmd.append('--android-packages=' + options.android_packages)

    passed = (util.RunCommand(cmd) == 0)

    _ArchiveServerLogs()

    if platform == 'android':
        if options.update_log:
            util.MarkBuildStepStart('update test result log')
            _UpdateTestResultsLog(platform, options.revision, passed)
    elif passed:
        _ArchiveGoodBuild(platform, options.revision)
        _MaybeRelease(platform)
Ejemplo n.º 13
0
 def GetZipName(revision):
     if util.IsWindows():
         return revision + '/chrome-win32.zip'
     elif util.IsMac():
         return revision + '/chrome-mac.zip'
     elif util.IsLinux():
         if util.Is64Bit():
             return revision + '/chrome-linux.zip'
         else:
             return 'full-build-linux_' + revision + '.zip'
Ejemplo n.º 14
0
 def GetDirName():
     if util.IsWindows():
         return 'chrome-win32'
     elif util.IsMac():
         return 'chrome-mac'
     elif util.IsLinux():
         if util.Is64Bit():
             return 'chrome-linux'
         else:
             return 'full-build-linux'
Ejemplo n.º 15
0
 def GetDirName():
   if util.IsWindows():
     return 'chrome-win32'
   elif util.IsMac():
     return 'chrome-mac'
   elif util.IsLinux():
     if platform.architecture()[0] == '64bit':
       return 'chrome-linux'
     else:
       return 'full-build-linux'
Ejemplo n.º 16
0
 def GetZipName(revision):
   if util.IsWindows():
     return revision + '/chrome-win32.zip'
   elif util.IsMac():
     return revision + '/chrome-mac.zip'
   elif util.IsLinux():
     if platform.architecture()[0] == '64bit':
       return revision + '/chrome-linux.zip'
     else:
       return 'full-build-linux_' + revision + '.zip'
Ejemplo n.º 17
0
class WindowTest(ChromeDriverTest):
  """Tests for WebDriver window commands."""

  def setUp(self):
    super(WindowTest, self).setUp()
    self._driver = self.GetNewDriver()

  def testSize(self):
    size = self._driver.get_window_size()
    self._driver.set_window_size(size['width'], size['height'])
    self.assertEquals(size, self._driver.get_window_size())
    self._driver.set_window_size(800, 600)
    self.assertEquals(800, self._driver.get_window_size()['width'])
    self.assertEquals(600, self._driver.get_window_size()['height'])

  def testPosition(self):
    pos = self._driver.get_window_position()
    self._driver.set_window_position(pos['x'], pos['y'])
    self.assertEquals(pos, self._driver.get_window_position())
    self._driver.set_window_position(100, 200)
    self.assertEquals(100, self._driver.get_window_position()['x'])
    self.assertEquals(200, self._driver.get_window_position()['y'])

  # Systems without window manager (Xvfb, Xvnc) do not implement maximization.
  @SkipIf(util.IsLinux())
  def testMaximize(self):
    old_size = self._driver.get_window_size()
    self._driver.maximize_window()
    new_size = self._driver.get_window_size()
    self.assertTrue(old_size['width'] <= new_size['width'])
    self.assertTrue(old_size['height'] <= new_size['height'])

  def testWindowHandle(self):
    """Test specifying window handle."""
    self._driver.execute_script(
        'window.open("about:blank", "name", "height=200, width=200")')
    windows = self._driver.window_handles
    self.assertEquals(2, len(windows))
    self._driver.set_window_size(400, 300, windows[1])
    self.assertEquals(400, self._driver.get_window_size(windows[1])['width'])
    self.assertEquals(300, self._driver.get_window_size(windows[1])['height'])
    self.assertNotEquals(self._driver.get_window_size(windows[1]),
                         self._driver.get_window_size(windows[0]))

  def testInvalidWindowHandle(self):
    """Tests specifying invalid handle."""
    invalid_handle = 'f1-120'
    self.assertRaises(WebDriverException, self._driver.set_window_size,
                      400, 300, invalid_handle)
    self.assertRaises(NoSuchWindowException, self._driver.get_window_size,
                      invalid_handle)
    self.assertRaises(NoSuchWindowException, self._driver.set_window_position,
                      1, 1, invalid_handle)
    self.assertRaises(NoSuchWindowException, self._driver.get_window_position,
                      invalid_handle)
Ejemplo n.º 18
0
def _GetDownloadPlatform():
    """Returns the name for this platform on the archive site."""
    if util.IsWindows():
        return 'Win'
    elif util.IsMac():
        return 'Mac'
    elif util.IsLinux():
        if util.Is64Bit():
            return 'Linux_x64'
        else:
            return 'Linux Builder (dbg)(32)'
Ejemplo n.º 19
0
def _GetDownloadPlatform():
    """Returns the name for this platform on the archive site."""
    if util.IsWindows():
        return 'Win'
    elif util.IsMac():
        return 'Mac'
    elif util.IsLinux():
        if platform.architecture()[0] == '64bit':
            return 'Linux_x64'
        else:
            return 'Linux'
Ejemplo n.º 20
0
def _GetDownloadPlatform(legacy=False):
    """Returns the name for this platform on the archive site.

  Args:
    legacy: When True, return name used for builds before revision 579575.
            TODO([email protected]): Remove when we stop supporting m69.
  """
    if legacy:
        if util.IsWindows():
            return 'Win'
        elif util.IsMac():
            return 'Mac'
        elif util.IsLinux():
            return 'Linux_x64'

    if util.IsWindows():
        return 'win32_rel'
    elif util.IsMac():
        return 'mac_rel'
    elif util.IsLinux():
        return 'linux_rel'
Ejemplo n.º 21
0
 def _FindChrome():
   possible_paths = []
   if util.IsWin():
     possible_paths += ['chrome.exe']
   elif util.IsMac():
     possible_paths += ['Chromium.app/Contents/MacOS/Chromium',
                        'Google Chrome.app/Contents/MacOS/Google Chrome']
   elif util.IsLinux():
     possible_paths += ['chrome']
   for dir in _DefaultExeLocations():
     for chrome_path in possible_paths:
       path = os.path.abspath(os.path.join(dir, chrome_path))
       if os.path.exists(path):
         return path
   return None
Ejemplo n.º 22
0
def _Release(build, version, platform):
  """Releases the given candidate build."""
  release_name = 'chromedriver_%s.zip' % platform
  util.MarkBuildStepStart('releasing %s' % release_name)
  temp_dir = util.MakeTempDir()
  slave_utils.GSUtilCopy(build, temp_dir)
  zip_path = os.path.join(temp_dir, os.path.basename(build))

  if util.IsLinux():
    util.Unzip(zip_path, temp_dir)
    server_path = os.path.join(temp_dir, 'chromedriver')
    util.RunCommand(['strip', server_path])
    zip_path = util.Zip(server_path)

  slave_utils.GSUtilCopy(
      zip_path, '%s/%s/%s' % (GS_CHROMEDRIVER_BUCKET, version, release_name))

  _MaybeUpdateLatestRelease(version)
Ejemplo n.º 23
0
def main():
    parser = optparse.OptionParser()
    parser.add_option(
        '',
        '--android-package',
        help='Application package name, if running tests on Android.')
    parser.add_option('-r',
                      '--revision',
                      type='string',
                      default=None,
                      help='Chromium revision')
    options, _ = parser.parse_args()

    if not options.android_package:
        KillChromes()
    CleanTmpDir()

    if options.android_package:
        Download()
    else:
        if not options.revision:
            parser.error('Must supply a --revision')

        if util.IsLinux() and platform.architecture()[0] == '64bit':
            Archive(options.revision)

        WaitForLatestSnapshot(options.revision)

    cmd = [
        sys.executable,
        os.path.join(_THIS_DIR, 'run_all_tests.py'),
    ]
    if options.android_package:
        cmd.append('--android-package=' + options.android_package)

    passed = (util.RunCommand(cmd) == 0)

    if not options.android_package and passed:
        MaybeRelease(options.revision)
Ejemplo n.º 24
0
_THIS_DIR = os.path.abspath(os.path.dirname(__file__))
sys.path.insert(1, os.path.join(_THIS_DIR, os.pardir))
sys.path.insert(1, os.path.join(_THIS_DIR, os.pardir, 'client'))
sys.path.insert(1, os.path.join(_THIS_DIR, os.pardir, 'server'))

import chrome_paths
import chromedriver
import unittest_util
import util
import server
from webelement import WebElement
import webserver

_TEST_DATA_DIR = os.path.join(chrome_paths.GetTestData(), 'chromedriver')

if util.IsLinux():
  sys.path.insert(0, os.path.join(chrome_paths.GetSrc(), 'build', 'android'))
  from pylib import android_commands
  from pylib import constants
  from pylib import forwarder
  from pylib import valgrind_tools
  from pylib.device import device_utils


_NEGATIVE_FILTER = [
    # https://code.google.com/p/chromedriver/issues/detail?id=213
    'ChromeDriverTest.testClickElementInSubFrame',
    # This test is flaky since it uses setTimeout.
    # Re-enable once crbug.com/177511 is fixed and we can remove setTimeout.
    'ChromeDriverTest.testAlert',
]
Ejemplo n.º 25
0
        option.click()
        self.assertTrue(option.is_selected())

    def testClickDoesUseFirstClientRect(self):
        self._driver.get(self.GetTestDataUrl() + '/test_page.html')
        self._driver.find_element_by_name('wrapped').click()
        self.assertTrue(self._driver.execute_script('return window.success'))

    def testThrowErrorIfNotClickable(self):
        self._driver.get(self.GetTestDataUrl() + '/not_clickable.html')
        elem = self._driver.find_element_by_name('click')
        self.assertRaises(WebDriverException, elem.click)


# crbug.com/109698: when running in xvfb, 2 extra mouse moves are received.
@SkipIf(util.IsLinux())
class MouseEventTest(ChromeDriverTest):
    """Tests for checking the correctness of mouse events."""
    def setUp(self):
        super(MouseEventTest, self).setUp()
        self._driver = self.GetNewDriver()
        self._driver.command_executor._commands['_keys_'] = (
            'POST', '/session/$sessionId/keys')
        self._driver.execute('_keys_', {'value': [Keys.CONTROL, Keys.SHIFT]})
        self._driver.get(self.GetTestDataUrl() + '/events.html')
        self._divs = self._driver.find_elements_by_tag_name('div')

    def _CheckEvent(self, event, event_type, mouse_button, x, y):
        """Checks the given event properties.

    This function expects the ctrl and shift keys to be pressed.
Ejemplo n.º 26
0
def main():
    parser = optparse.OptionParser()
    parser.add_option(
        '',
        '--android-packages',
        help='Comma separated list of application package names, '
        'if running tests on Android.')
    # Option 'chrome-version' is for desktop only.
    parser.add_option(
        '',
        '--chrome-version',
        help='Version of chrome, e.g., \'HEAD\', \'27\', or \'26\'.'
        'Default is to run tests against all of these versions.'
        'Notice: this option only applies to desktop.')
    options, _ = parser.parse_args()

    exe_postfix = ''
    if util.IsWindows():
        exe_postfix = '.exe'
    cpp_tests_name = 'chromedriver_tests' + exe_postfix
    server_name = 'chromedriver' + exe_postfix

    required_build_outputs = [server_name]
    if not options.android_packages:
        required_build_outputs += [cpp_tests_name]
    try:
        build_dir = chrome_paths.GetBuildDir(required_build_outputs)
    except RuntimeError:
        util.MarkBuildStepStart('check required binaries')
        traceback.print_exc()
        util.MarkBuildStepError()
    constants.SetBuildType(os.path.basename(build_dir))
    print 'Using build outputs from', build_dir

    chromedriver = os.path.join(build_dir, server_name)
    platform_name = util.GetPlatformName()
    if util.IsLinux() and util.Is64Bit():
        platform_name += '64'
    ref_chromedriver = os.path.join(
        chrome_paths.GetSrc(), 'chrome', 'test', 'chromedriver', 'third_party',
        'java_tests', 'reference_builds',
        'chromedriver_%s%s' % (platform_name, exe_postfix))

    if options.android_packages:
        os.environ['PATH'] += os.pathsep + os.path.join(
            _THIS_DIR, os.pardir, 'chrome')
        code = 0
        for package in options.android_packages.split(','):
            code1 = RunPythonTests(chromedriver,
                                   ref_chromedriver,
                                   chrome_version_name=package,
                                   android_package=package)
            code2 = RunJavaTests(chromedriver,
                                 chrome_version_name=package,
                                 android_package=package,
                                 verbose=True)
            code = code or code1 or code2
        return code
    else:
        versions = {'HEAD': archive.GetLatestRevision()}
        if util.IsLinux() and not util.Is64Bit():
            # Linux32 builds need to be special-cased, because 1) they are keyed by
            # git hash rather than commit position, and 2) come from a different
            # download site (so we can't just convert the commit position to a hash).
            versions['55'] = 'e9bc4e0245c9a1e570ed2cf8e12152b9122275f2'
            versions['54'] = '13d140acdaa710770f42790044825b49f99e466c'
            versions['53'] = 'ac799c2fd50b8fb62b7a8186ff78b025de5b8718'
            # TODO(samuong): speculative fix for crbug.com/611886
            os.environ['CHROME_DEVEL_SANDBOX'] = '/opt/chromium/chrome_sandbox'
        else:
            versions['55'] = '423791'
            versions['54'] = '414545'
            versions['53'] = '403392'
        code = 0
        for version, revision in versions.iteritems():
            if options.chrome_version and version != options.chrome_version:
                continue
            download_site = archive.GetDownloadSite()
            version_name = version
            if version_name == 'HEAD':
                version_name = revision
            temp_dir, chrome_path = DownloadChrome(version_name, revision,
                                                   download_site)
            if not chrome_path:
                code = 1
                continue
            code1 = RunPythonTests(chromedriver,
                                   ref_chromedriver,
                                   chrome=chrome_path,
                                   chrome_version=version,
                                   chrome_version_name='v%s' % version_name)
            code2 = RunJavaTests(chromedriver,
                                 chrome=chrome_path,
                                 chrome_version=version,
                                 chrome_version_name='v%s' % version_name)
            code = code or code1 or code2
            _KillChromes()
            shutil.rmtree(temp_dir)
        cpp_tests = os.path.join(build_dir, cpp_tests_name)
        return RunCppTests(cpp_tests) or code
Ejemplo n.º 27
0
def main():
    parser = optparse.OptionParser()
    parser.add_option(
        '',
        '--android-package',
        help='Application package name, if running tests on Android.')
    # Option 'chrome-version' is for desktop only.
    parser.add_option(
        '',
        '--chrome-version',
        help='Version of chrome, e.g., \'HEAD\', \'27\', or \'26\'.'
        'Default is to run tests against all of these versions.'
        'Notice: this option only applies to desktop.')
    options, _ = parser.parse_args()

    exe_postfix = ''
    if util.IsWindows():
        exe_postfix = '.exe'
    cpp_tests_name = 'chromedriver2_tests' + exe_postfix
    server_name = 'chromedriver2_server' + exe_postfix

    required_build_outputs = [server_name]
    if not options.android_package:
        required_build_outputs += [cpp_tests_name]
    build_dir = chrome_paths.GetBuildDir(required_build_outputs)
    print 'Using build outputs from', build_dir

    chromedriver = os.path.join(build_dir, server_name)
    platform_name = util.GetPlatformName()
    if util.IsLinux() and platform.architecture()[0] == '64bit':
        platform_name += '64'
    ref_chromedriver = os.path.join(
        chrome_paths.GetSrc(), 'chrome', 'test', 'chromedriver', 'third_party',
        'java_tests', 'reference_builds',
        'chromedriver_%s%s' % (platform_name, exe_postfix))

    if util.IsLinux():
        # Set LD_LIBRARY_PATH to enable successful loading of shared object files,
        # when chromedriver2.so is not a static build.
        _AppendEnvironmentPath('LD_LIBRARY_PATH',
                               os.path.join(build_dir, 'lib'))
    elif util.IsWindows():
        # For Windows bots: add ant, java(jre) and the like to system path.
        _AddToolsToSystemPathForWindows()

    if options.android_package:
        os.environ['PATH'] += os.pathsep + os.path.join(_THIS_DIR, 'chrome')
        code1 = RunPythonTests(chromedriver,
                               ref_chromedriver,
                               android_package=options.android_package)
        code2 = RunJavaTests(chromedriver,
                             android_package=options.android_package)
        return code1 or code2
    else:
        latest_snapshot_revision = archive.GetLatestRevision(
            archive.Site.SNAPSHOT)
        versions = [['HEAD', latest_snapshot_revision],
                    ['28', archive.CHROME_28_REVISION],
                    ['27', archive.CHROME_27_REVISION]]
        code = 0
        for version in versions:
            if options.chrome_version and version[0] != options.chrome_version:
                continue
            download_site = archive.Site.CONTINUOUS
            version_name = version[0]
            if version_name == 'HEAD':
                version_name = version[1]
                download_site = archive.Site.SNAPSHOT
            chrome_path = archive.DownloadChrome(version[1],
                                                 util.MakeTempDir(),
                                                 download_site)
            code1 = RunPythonTests(chromedriver,
                                   ref_chromedriver,
                                   chrome=chrome_path,
                                   chrome_version=version[0],
                                   chrome_version_name=version_name)
            code2 = RunJavaTests(chromedriver,
                                 chrome=chrome_path,
                                 chrome_version=version[0],
                                 chrome_version_name=version_name)
            code = code or code1 or code2
        cpp_tests = os.path.join(build_dir, cpp_tests_name)
        return RunCppTests(cpp_tests) or code
Ejemplo n.º 28
0
def main():
  parser = optparse.OptionParser()
  parser.add_option(
      '', '--android-packages',
      help='Comma separated list of application package names, '
           'if running tests on Android.')
  # Option 'chrome-version' is for desktop only.
  parser.add_option(
      '', '--chrome-version',
      help='Version of chrome, e.g., \'HEAD\', \'27\', or \'26\'.'
           'Default is to run tests against all of these versions.'
           'Notice: this option only applies to desktop.')
  options, _ = parser.parse_args()

  exe_postfix = ''
  if util.IsWindows():
    exe_postfix = '.exe'
  cpp_tests_name = 'chromedriver_tests' + exe_postfix
  server_name = 'chromedriver' + exe_postfix

  required_build_outputs = [server_name]
  if not options.android_packages:
    required_build_outputs += [cpp_tests_name]
  try:
    build_dir = chrome_paths.GetBuildDir(required_build_outputs)
  except RuntimeError:
    util.MarkBuildStepStart('check required binaries')
    traceback.print_exc()
    util.MarkBuildStepError()
  constants.SetBuildType(os.path.basename(build_dir))
  print 'Using build outputs from', build_dir

  chromedriver = os.path.join(build_dir, server_name)
  platform_name = util.GetPlatformName()
  if util.IsLinux() and util.Is64Bit():
    platform_name += '64'
  ref_chromedriver = os.path.join(
      chrome_paths.GetSrc(),
      'chrome', 'test', 'chromedriver', 'third_party', 'java_tests',
      'reference_builds',
      'chromedriver_%s%s' % (platform_name, exe_postfix))

  if options.android_packages:
    os.environ['PATH'] += os.pathsep + os.path.join(
        _THIS_DIR, os.pardir, 'chrome')
    code = 0
    for package in options.android_packages.split(','):
      code1 = RunPythonTests(chromedriver,
                             ref_chromedriver,
                             chrome_version_name=package,
                             android_package=package)
      code2 = RunJavaTests(chromedriver,
                           chrome_version_name=package,
                           android_package=package,
                           verbose=True)
      code = code or code1 or code2
    return code
  else:
    versions = {'HEAD': archive.GetLatestRevision()}
    if util.IsLinux() and not util.Is64Bit():
      # Linux32 builds need to be special-cased, because 1) they are keyed by
      # git hash rather than commit position, and 2) come from a different
      # download site (so we can't just convert the commit position to a hash).
      versions['63'] = 'adb61db19020ed8ecee5e91b1a0ea4c924ae2988'
      versions['62'] = '17030e3a08cfbb6e591991f7dbf0eb703454b365'
      versions['61'] = '77132a2bc78e8dc9ce411e8166bfd009f6476f6f'

      # TODO(samuong): speculative fix for crbug.com/611886
      os.environ['CHROME_DEVEL_SANDBOX'] = '/opt/chromium/chrome_sandbox'

    # Linux64 build numbers
    elif util.IsLinux():
      versions['65'] = '530372'
      versions['64'] = '520842'
      versions['63'] = '508578'

    # Mac build numbers
    elif util.IsMac():
      versions['65'] = '530368'
      versions['64'] = '520840'
      versions['63'] = '508578'

    # Windows build numbers
    elif util.IsWindows():
      versions['65'] = '530366'
      versions['64'] = '520840'
      versions['63'] = '508578'

    code = 0
    for version, revision in versions.iteritems():
      if options.chrome_version and version != options.chrome_version:
        continue
      download_site = archive.GetDownloadSite()
      version_name = version
      if version_name == 'HEAD':
        version_name = revision
      temp_dir, chrome_path = DownloadChrome(version_name, revision,
                                             download_site)
      if not chrome_path:
        code = 1
        continue
      code1 = RunPythonTests(chromedriver,
                             ref_chromedriver,
                             chrome=chrome_path,
                             chrome_version=version,
                             chrome_version_name='v%s' % version_name)
      code2 = RunJavaTests(chromedriver, chrome=chrome_path,
                           chrome_version=version,
                           chrome_version_name='v%s' % version_name)
      code = code or code1 or code2
      _KillChromes()
      shutil.rmtree(temp_dir)
    cpp_tests = os.path.join(build_dir, cpp_tests_name)
    return RunCppTests(cpp_tests) or code
Ejemplo n.º 29
0
def main():
    parser = optparse.OptionParser()
    parser.add_option(
        '',
        '--android-packages',
        help='Comma separated list of application package names, '
        'if running tests on Android.')
    # Option 'chrome-version' is for desktop only.
    parser.add_option(
        '',
        '--chrome-version',
        help='Version of chrome, e.g., \'HEAD\', \'27\', or \'26\'.'
        'Default is to run tests against all of these versions.'
        'Notice: this option only applies to desktop.')
    options, _ = parser.parse_args()

    exe_postfix = ''
    if util.IsWindows():
        exe_postfix = '.exe'
    cpp_tests_name = 'chromedriver_tests' + exe_postfix
    server_name = 'chromedriver' + exe_postfix

    required_build_outputs = [server_name]
    if not options.android_packages:
        required_build_outputs += [cpp_tests_name]
    try:
        build_dir = chrome_paths.GetBuildDir(required_build_outputs)
    except RuntimeError:
        util.MarkBuildStepStart('check required binaries')
        traceback.print_exc()
        util.MarkBuildStepError()
    constants.SetBuildType(os.path.basename(build_dir))
    print 'Using build outputs from', build_dir

    chromedriver = os.path.join(build_dir, server_name)
    platform_name = util.GetPlatformName()
    if util.IsLinux() and util.Is64Bit():
        platform_name += '64'
    ref_chromedriver = os.path.join(
        chrome_paths.GetSrc(), 'chrome', 'test', 'chromedriver', 'third_party',
        'java_tests', 'reference_builds',
        'chromedriver_%s%s' % (platform_name, exe_postfix))

    if options.android_packages:
        os.environ['PATH'] += os.pathsep + os.path.join(
            _THIS_DIR, os.pardir, 'chrome')
        code = 0
        for package in options.android_packages.split(','):
            code1 = RunPythonTests(chromedriver,
                                   ref_chromedriver,
                                   chrome_version_name=package,
                                   android_package=package)
            code2 = RunJavaTests(chromedriver,
                                 chrome_version_name=package,
                                 android_package=package,
                                 verbose=True)
            code = code or code1 or code2
        return code
    else:
        versions = {'HEAD': archive.GetLatestRevision()}
        if util.IsLinux() and not util.Is64Bit():
            # Linux32 builds need to be special-cased, because 1) they are keyed by
            # git hash rather than commit position, and 2) come from a different
            # download site (so we can't just convert the commit position to a hash).
            versions['51'] = '5a161bb6fe3d6bfbe2dafc0a7dd5831478f34277'
            versions['50'] = '4acbec91b57f31a501264906aded632cc64c9300'
            versions['49'] = '7acdedefe3ddcb27b3fc826027f519bdb5d04d7e'
        else:
            versions['51'] = '386266'
            versions['50'] = '378110'
            versions['49'] = '369932'
        code = 0
        for version, revision in versions.iteritems():
            if options.chrome_version and version != options.chrome_version:
                continue
            download_site = archive.GetDownloadSite()
            version_name = version
            if version_name == 'HEAD':
                version_name = revision
            temp_dir, chrome_path = DownloadChrome(version_name, revision,
                                                   download_site)
            if not chrome_path:
                code = 1
                continue
            code1 = RunPythonTests(chromedriver,
                                   ref_chromedriver,
                                   chrome=chrome_path,
                                   chrome_version=version,
                                   chrome_version_name='v%s' % version_name)
            code2 = RunJavaTests(chromedriver,
                                 chrome=chrome_path,
                                 chrome_version=version,
                                 chrome_version_name='v%s' % version_name)
            code = code or code1 or code2
            _KillChromes()
            shutil.rmtree(temp_dir)
        cpp_tests = os.path.join(build_dir, cpp_tests_name)
        return RunCppTests(cpp_tests) or code
Ejemplo n.º 30
0
def _Run(java_tests_src_dir, test_filter, ready_to_run_tests,
         chromedriver_path, chrome_path, log_path, android_package_key,
         verbose, debug):
    """Run the WebDriver Java tests and return the test results.

  Args:
    java_tests_src_dir: the java test source code directory.
    test_filter: the filter to use when choosing tests to run. Format is same
        as Google C++ Test format.
    readyToRunTests: tests that need to run regardless of
        @NotYetImplemented annotation
    chromedriver_path: path to ChromeDriver exe.
    chrome_path: path to Chrome exe.
    log_path: path to server log.
    android_package_key: name of Chrome's Android package.
    verbose: whether the output should be verbose.
    debug: whether the tests should wait until attached by a debugger.

  Returns:
    A list of |TestResult|s.
  """

    sys_props = [
        'selenium.browser=chrome',
        'webdriver.chrome.driver=' + os.path.abspath(chromedriver_path)
    ]
    if chrome_path:
        if util.IsLinux() and android_package_key is None:
            # Workaround for crbug.com/611886 and
            # https://bugs.chromium.org/p/chromedriver/issues/detail?id=1695
            chrome_wrapper_path = os.path.join(java_tests_src_dir,
                                               'chrome-wrapper-no-sandbox')
            with open(chrome_wrapper_path, 'w') as f:
                f.write('#!/bin/sh\n')
                f.write('exec "%s" --no-sandbox --disable-gpu "$@"\n' %
                        os.path.abspath(chrome_path))
            st = os.stat(chrome_wrapper_path)
            os.chmod(chrome_wrapper_path, st.st_mode | stat.S_IEXEC)
        elif util.IsMac():
            # Use srgb color profile, otherwise the default color profile on Mac
            # causes some color adjustments, so screenshots have unexpected colors.
            chrome_wrapper_path = os.path.join(java_tests_src_dir,
                                               'chrome-wrapper')
            with open(chrome_wrapper_path, 'w') as f:
                f.write('#!/bin/sh\n')
                f.write('exec "%s" --force-color-profile=srgb "$@"\n' %
                        os.path.abspath(chrome_path))
            st = os.stat(chrome_wrapper_path)
            os.chmod(chrome_wrapper_path, st.st_mode | stat.S_IEXEC)
        else:
            chrome_wrapper_path = os.path.abspath(chrome_path)
        sys_props += ['webdriver.chrome.binary=' + chrome_wrapper_path]
    if log_path:
        sys_props += ['webdriver.chrome.logfile=' + log_path]
    if android_package_key:
        android_package = constants.PACKAGE_INFO[android_package_key].package
        sys_props += ['webdriver.chrome.android_package=' + android_package]
        if android_package_key == 'chromedriver_webview_shell':
            android_activity = constants.PACKAGE_INFO[
                android_package_key].activity
            android_process = '%s:main' % android_package
            sys_props += [
                'webdriver.chrome.android_activity=' + android_activity
            ]
            sys_props += [
                'webdriver.chrome.android_process=' + android_process
            ]
    if test_filter:
        # Test jar actually takes a regex. Convert from glob.
        test_filter = test_filter.replace('*', '.*')
        sys_props += ['filter=' + test_filter]
    if ready_to_run_tests:
        sys_props += ['readyToRun=' + ready_to_run_tests]

    jvm_args = []
    if debug:
        transport = 'dt_socket'
        if util.IsWindows():
            transport = 'dt_shmem'
        jvm_args += [
            '-agentlib:jdwp=transport=%s,server=y,suspend=y,'
            'address=33081' % transport
        ]

    return _RunAntTest(java_tests_src_dir, jvm_args, verbose, sys_props)