| Index: chrome/test/chromedriver/embed_mobile_devices_in_cpp.py
|
| diff --git a/chrome/test/chromedriver/embed_mobile_devices_in_cpp.py b/chrome/test/chromedriver/embed_mobile_devices_in_cpp.py
|
| new file mode 100755
|
| index 0000000000000000000000000000000000000000..e81955fa6755c9247e06439bf40f6e44a5c262fa
|
| --- /dev/null
|
| +++ b/chrome/test/chromedriver/embed_mobile_devices_in_cpp.py
|
| @@ -0,0 +1,47 @@
|
| +#!/usr/bin/env python
|
| +# Copyright (c) 2014 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.
|
| +
|
| +"""Embeds standalone JavaScript snippets in C++ code.
|
| +
|
| +The script requires the OverridesView file from WebKit that lists the known
|
| +mobile devices to be passed in as the only argument. The list of known devices
|
| +will be written to a C-style string to be parsed with JSONReader.
|
| +"""
|
| +
|
| +import optparse
|
| +import os
|
| +import sys
|
| +
|
| +import cpp_source
|
| +
|
| +
|
| +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 'DeviceTab._phones = [' in line or 'DeviceTab._tablets = [' in line:
|
| + inside_list = True
|
| + else:
|
| + if line.strip() == '];':
|
| + inside_list = False
|
| + continue
|
| + devices += line.strip()
|
| +
|
| + devices += ']'
|
| + cpp_source.WriteSource('mobile_devices', 'chrome/test/chromedriver/chrome',
|
| + options.directory, {'kMobileDevices': devices})
|
| +
|
| +
|
| +if __name__ == '__main__':
|
| + sys.exit(main())
|
|
|