def main():
    parser = optparse.OptionParser()
    parser.add_option(
        '',
        '--directory',
        type='string',
        default='.',
        help='Path to directory where the cc/h files should be created')
    options, args = parser.parse_args()

    devices = {}
    file_name = args[0]
    inside_list = False
    with open(file_name, 'r') as f:
        emulated_devices = json.load(f)
    extensions = emulated_devices['extensions']
    for extension in extensions:
        if extension['type'] == 'emulated-device':
            device = extension['device']
            devices[device['title']] = {
                'userAgent': device['user-agent'],
                'width': device['screen']['vertical']['width'],
                'height': device['screen']['vertical']['height'],
                'deviceScaleFactor': device['screen']['device-pixel-ratio'],
                'touch': 'touch' in device['capabilities'],
                'mobile': 'mobile' in device['capabilities'],
            }

    output_dir = 'xwalk/test/xwalkdriver/xwalk'
    cpp_source.WriteSource('mobile_device_list', output_dir, options.directory,
                           {'kMobileDevices': json.dumps(devices)})

    clang_format = ['clang-format', '-i']
    subprocess.Popen(clang_format + ['%s/mobile_device_list.cc' % output_dir])
    subprocess.Popen(clang_format + ['%s/mobile_device_list.h' % output_dir])
Ejemplo n.º 2
0
def main():
  parser = optparse.OptionParser()
  parser.add_option(
      '', '--directory', type='string', default='.',
      help='Path to directory where the cc/h files should be created')
  options, args = parser.parse_args()

  devices = '['
  file_name = args[0]
  inside_list = False
  with open(file_name, 'r') as f:
    for line in f:
      if not inside_list:
        if 'WebInspector.OverridesSupport._phones = [' in line or \
           'WebInspector.OverridesSupport._tablets = [' in line:
          inside_list = True
      else:
        if line.strip() == '];':
          inside_list = False
          continue
        devices += line.strip()

  devices += ']'
  cpp_source.WriteSource('mobile_device_list',
                         'chrome/test/chromedriver/chrome',
                         options.directory, {'kMobileDevices': devices})
Ejemplo n.º 3
0
def main():
    parser = optparse.OptionParser()
    parser.add_option(
        '',
        '--directory',
        type='string',
        default='.',
        help='Path to directory where the cc/h files should be created')
    options, args = parser.parse_args()

    networks = '['
    file_name = args[0]
    inside_list = False
    with open(file_name, 'r') as f:
        for line in f:
            if not inside_list:
                if 'WebInspector.OverridesUI._networkConditionsPresets = [' in line:
                    inside_list = True
            else:
                if line.strip() == '];':
                    inside_list = False
                    continue
                line = line.replace(UNLIMITED_THROUGHPUT, "-1")
                networks += line.strip()

    output_dir = 'chrome/test/chromedriver/chrome'
    networks += ']'
    networks = quotizeKeys(networks, ['id', 'title', 'throughput', 'latency'])
    networks = evaluateMultiplications(networks)
    cpp_source.WriteSource('network_list', output_dir, options.directory,
                           {'kNetworks': networks})

    clang_format = ['clang-format', '-i']
    subprocess.Popen(clang_format + ['%s/network_list.cc' % output_dir])
    subprocess.Popen(clang_format + ['%s/network_list.h' % output_dir])
Ejemplo n.º 4
0
def main():
  parser = optparse.OptionParser()
  parser.add_option('', '--version-file')
  parser.add_option(
      '', '--directory', type='string', default='.',
      help='Path to directory where the cc/h  file should be created')
  options, _ = parser.parse_args()

  version = open(options.version_file, 'r').read().strip()
  revision = "undefined"

  if revision:
    match = re.match('([0-9a-fA-F]+)(-refs/heads/master@{#(\d+)})?', revision)
    if match:
      git_hash = match.group(1)
      commit_position = match.group(3)
      if commit_position:
        version += '.' + commit_position
      version += ' (%s)' % git_hash
    else:
      version += ' (%s)' % revision

  global_string_map = {
      'kChromeDriverVersion': version
  }
  cpp_source.WriteSource('version',
                         'chrome/test/chromedriver',
                         options.directory, global_string_map)
Ejemplo n.º 5
0
def main():
    parser = optparse.OptionParser()
    parser.add_option('',
                      '--version-file',
                      type='string',
                      default=os.path.join(chrome_paths.GetSrc(), 'chrome',
                                           'VERSION'),
                      help='Path to Chrome version file')
    parser.add_option(
        '',
        '--directory',
        type='string',
        default='.',
        help='Path to directory where the cc/h files should be created')
    options, args = parser.parse_args()

    # The device userAgent string may contain '%s', which should be replaced with
    # current Chrome version. First we read the version file.
    version_parts = ['MAJOR', 'MINOR', 'BUILD', 'PATCH']
    version = []
    version_file = open(options.version_file, 'r')
    for part in version_parts:
        # The version file should have 4 lines, with format like MAJOR=63
        components = version_file.readline().split('=')
        if len(components) != 2 or components[0].strip() != part:
            print 'Bad version file'
            return 1
        version.append(components[1].strip())
    # Join parts of version together using '.' as separator
    version = '.'.join(version)

    devices = {}
    file_name = args[0]
    inside_list = False
    with open(file_name, 'r') as f:
        emulated_devices = json.load(f)
    extensions = emulated_devices['extensions']
    for extension in extensions:
        if extension['type'] == 'emulated-device':
            device = extension['device']
            devices[device['title']] = {
                'userAgent': device['user-agent'].replace('%s', version),
                'width': device['screen']['vertical']['width'],
                'height': device['screen']['vertical']['height'],
                'deviceScaleFactor': device['screen']['device-pixel-ratio'],
                'touch': 'touch' in device['capabilities'],
                'mobile': 'mobile' in device['capabilities'],
            }

    output_dir = 'chrome/test/chromedriver/chrome'
    cpp_source.WriteSource('mobile_device_list', output_dir, options.directory,
                           {'kMobileDevices': json.dumps(devices)})

    clang_format = ['clang-format', '-i']
    subprocess.Popen(clang_format + ['%s/mobile_device_list.cc' % output_dir])
    subprocess.Popen(clang_format + ['%s/mobile_device_list.h' % output_dir])
def main():
    parser = optparse.OptionParser()
    parser.add_option('', '--version-file')
    parser.add_option(
        '',
        '--directory',
        type='string',
        default='.',
        help='Path to directory where the cc/h  file should be created')
    options, args = parser.parse_args()

    version = open(options.version_file, 'r').read().strip()
    revision = lastchange.FetchVersionInfo(None).revision
    if revision:
        version += '.' + revision.strip()

    global_string_map = {'kChromeDriverVersion': version}
    cpp_source.WriteSource('version', 'chrome/test/chromedriver',
                           options.directory, global_string_map)
Ejemplo n.º 7
0
def main():
    parser = optparse.OptionParser()
    parser.add_option(
        '',
        '--directory',
        type='string',
        default='.',
        help='Path to directory where the cc/h files should be created')
    options, args = parser.parse_args()

    devices = '['
    file_name = args[0]
    inside_list = False
    with open(file_name, 'r') as f:
        for line in f:
            if not inside_list:
                if 'WebInspector.OverridesUI._phones = [' in line:
                    inside_list = True
                if 'WebInspector.OverridesUI._tablets = [' in line:
                    devices += ','
                    inside_list = True
                if 'WebInspector.OverridesUI._notebooks = [' in line:
                    devices += ','
                    inside_list = True
            else:
                if line.strip() == '];':
                    inside_list = False
                    continue
                devices += line.strip()

    output_dir = 'chrome/test/chromedriver/chrome'
    devices += ']'
    devices = quotizeKeys(devices, [
        'title', 'width', 'height', 'deviceScaleFactor', 'userAgent', 'touch',
        'mobile'
    ])
    cpp_source.WriteSource('mobile_device_list', output_dir, options.directory,
                           {'kMobileDevices': devices})

    clang_format = ['clang-format', '-i']
    subprocess.Popen(clang_format + ['%s/mobile_device_list.cc' % output_dir])
    subprocess.Popen(clang_format + ['%s/mobile_device_list.h' % output_dir])
def main():
    parser = optparse.OptionParser()
    parser.add_option(
        '',
        '--directory',
        type='string',
        default='.',
        help='Path to directory where the cc/h  file should be created')
    options, args = parser.parse_args()

    global_string_map = {}
    for data_file in args:
        title = os.path.basename(os.path.splitext(data_file)[0]).title()
        var_name = 'k' + title.replace('_', '')
        with open(data_file, 'r') as f:
            contents = f.read()
        global_string_map[var_name] = contents

    cpp_source.WriteSource('user_data_dir', 'chrome/test/chromedriver/chrome',
                           options.directory, global_string_map)
def main():
  parser = optparse.OptionParser()
  parser.add_option(
      '', '--directory', type='string', default='.',
      help='Path to directory where the cc/h js file should be created')
  options, args = parser.parse_args()

  global_string_map = {}
  for js_file in args:
    base_name = os.path.basename(js_file)[:-3].title().replace('_', '')
    func_name = base_name[0].lower() + base_name[1:]
    script_name = 'k%sScript' % base_name
    with open(js_file, 'r') as f:
      contents = f.read()
    script = 'function() { %s; return %s.apply(null, arguments) }' % (
        contents, func_name)
    global_string_map[script_name] = script

  cpp_source.WriteSource('js', 'xwalk/test/xwalkdriver/xwalk',
                         options.directory, global_string_map)
def main():
    parser = optparse.OptionParser()
    parser.add_option('', '--chromedriver-version-file')
    parser.add_option('', '--chrome-version-file')
    parser.add_option(
        '',
        '--directory',
        type='string',
        default='.',
        help='Path to directory where the cc/h  file should be created')
    options, _ = parser.parse_args()

    chromedriver_version = open(options.chromedriver_version_file,
                                'r').read().strip()

    # Get a VersionInfo object corresponding to the Git commit we are at,
    # using the same filter used by main function of build/util/lastchange.py.
    # On success, version_info.revision_id is a 40-digit Git hash,
    # and version_info.revision is a longer string with more information.
    # On failure, version_info is None.
    version_info = lastchange.FetchGitRevision(None, '^Change-Id:')

    version = get_release_version(options.chrome_version_file, version_info)

    if version is None:
        version = get_master_version(chromedriver_version, version_info)

    if version is None:
        if version_info is not None:
            # Not in a known branch, but has Git revision.
            version = '%s (%s)' % (chromedriver_version,
                                   version_info.revision_id)
        else:
            # Git command failed. Just use ChromeDriver version string.
            version = chromedriver_version

    global_string_map = {'kChromeDriverVersion': version}
    cpp_source.WriteSource('version', 'chrome/test/chromedriver',
                           options.directory, global_string_map)
def main():
    parser = optparse.OptionParser()
    parser.add_option(
        '',
        '--directory',
        type='string',
        default='.',
        help='Path to directory where the cc/h  file should be created')
    options, args = parser.parse_args()

    global_string_map = {}
    string_buffer = StringIO.StringIO()
    zipper = zipfile.ZipFile(string_buffer, 'w')
    for f in args:
        zipper.write(f, os.path.basename(f), zipfile.ZIP_STORED)
    zipper.close()
    global_string_map['kAutomationExtension'] = base64.b64encode(
        string_buffer.getvalue())
    string_buffer.close()

    cpp_source.WriteSource('embedded_automation_extension',
                           'chrome/test/chromedriver/chrome',
                           options.directory, global_string_map)