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..6cb380676d8cddbbb10b2ec6151a38a2400f32d5 |
--- /dev/null |
+++ b/chrome/test/chromedriver/embed_mobile_devices_in_cpp.py |
@@ -0,0 +1,48 @@ |
+#!/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_device_list', |
+ 'chrome/test/chromedriver/chrome', |
+ options.directory, {'kMobileDevices': devices}) |
+ |
+ |
+if __name__ == '__main__': |
+ sys.exit(main()) |