| OLD | NEW |
| 1 #!/usr/bin/env python | 1 #!/usr/bin/env python |
| 2 # Copyright (c) 2012 The Chromium Authors. All rights reserved. | 2 # Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 3 # Use of this source code is governed by a BSD-style license that can be | 3 # Use of this source code is governed by a BSD-style license that can be |
| 4 # found in the LICENSE file. | 4 # found in the LICENSE file. |
| 5 | 5 |
| 6 """Generator script for proxy tests. | 6 """Generator script for proxy tests. |
| 7 | 7 |
| 8 See AndroidProxySelectorTest.java | 8 See AndroidProxySelectorTest.java |
| 9 and net/proxy/proxy_config_service_android_unittest.cc | 9 and net/proxy/proxy_config_service_android_unittest.cc |
| 10 | 10 |
| (...skipping 156 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 167 }, | 167 }, |
| 168 "mappings" : { | 168 "mappings" : { |
| 169 "https://example.com/" : "HTTPS httpproxy.com:443", | 169 "https://example.com/" : "HTTPS httpproxy.com:443", |
| 170 "http://example.com/" : "DIRECT", | 170 "http://example.com/" : "DIRECT", |
| 171 "ftp://example.com/" : "DIRECT", | 171 "ftp://example.com/" : "DIRECT", |
| 172 } | 172 } |
| 173 }, | 173 }, |
| 174 { | 174 { |
| 175 "name": "HttpProxyHostIPv6", | 175 "name": "HttpProxyHostIPv6", |
| 176 "description" : "Test IPv6 https.proxyHost and default port.", | 176 "description" : "Test IPv6 https.proxyHost and default port.", |
| 177 "cpp-only" : "", |
| 177 "properties" : { | 178 "properties" : { |
| 178 "http.proxyHost" : "a:b:c::d:1", | 179 "http.proxyHost" : "a:b:c::d:1", |
| 179 }, | 180 }, |
| 180 "mappings" : { | 181 "mappings" : { |
| 181 "http://example.com/" : "PROXY [a:b:c::d:1]:80", | 182 "http://example.com/" : "PROXY [a:b:c::d:1]:80", |
| 182 "ftp://example.com/" : "DIRECT", | 183 "ftp://example.com/" : "DIRECT", |
| 183 } | 184 } |
| 184 }, | 185 }, |
| 185 { | 186 { |
| 186 "name": "HttpProxyHostAndPortIPv6", | 187 "name": "HttpProxyHostAndPortIPv6", |
| 187 "description" : "Test IPv6 http.proxyHost and http.proxyPort works.", | 188 "description" : "Test IPv6 http.proxyHost and http.proxyPort works.", |
| 189 "cpp-only" : "", |
| 188 "properties" : { | 190 "properties" : { |
| 189 "http.proxyHost" : "a:b:c::d:1", | 191 "http.proxyHost" : "a:b:c::d:1", |
| 190 "http.proxyPort" : "8080", | 192 "http.proxyPort" : "8080", |
| 191 }, | 193 }, |
| 192 "mappings" : { | 194 "mappings" : { |
| 193 "http://example.com/" : "PROXY [a:b:c::d:1]:8080", | 195 "http://example.com/" : "PROXY [a:b:c::d:1]:8080", |
| 194 "ftp://example.com/" : "DIRECT", | 196 "ftp://example.com/" : "DIRECT", |
| 195 } | 197 } |
| 196 }, | 198 }, |
| 197 { | 199 { |
| 198 "name": "HttpProxyHostAndInvalidPort", | 200 "name": "HttpProxyHostAndInvalidPort", |
| 199 "description" : "Test invalid http.proxyPort does not crash.", | 201 "description" : "Test invalid http.proxyPort does not crash.", |
| 202 "cpp-only" : "", |
| 200 "properties" : { | 203 "properties" : { |
| 201 "http.proxyHost" : "a:b:c::d:1", | 204 "http.proxyHost" : "a:b:c::d:1", |
| 202 "http.proxyPort" : "65536", | 205 "http.proxyPort" : "65536", |
| 203 }, | 206 }, |
| 204 "mappings" : { | 207 "mappings" : { |
| 205 "http://example.com/" : "DIRECT", | 208 "http://example.com/" : "DIRECT", |
| 206 "ftp://example.com/" : "DIRECT", | 209 "ftp://example.com/" : "DIRECT", |
| 207 } | 210 } |
| 208 }, | 211 }, |
| 209 { | 212 { |
| (...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 295 def _GenerateMappings(self, mappings): | 298 def _GenerateMappings(self, mappings): |
| 296 for url in sorted(mappings.iterkeys()): | 299 for url in sorted(mappings.iterkeys()): |
| 297 print " TestMapping(\"%s\", \"%s\");" % (url, mappings[url]) | 300 print " TestMapping(\"%s\", \"%s\");" % (url, mappings[url]) |
| 298 | 301 |
| 299 | 302 |
| 300 class GenerateJava: | 303 class GenerateJava: |
| 301 """Generate Java test cases""" | 304 """Generate Java test cases""" |
| 302 | 305 |
| 303 def Generate(self): | 306 def Generate(self): |
| 304 for test_case in test_cases: | 307 for test_case in test_cases: |
| 308 if test_case.has_key("cpp-only"): |
| 309 continue |
| 305 if "description" in test_case: | 310 if "description" in test_case: |
| 306 self._GenerateDescription(test_case["description"]); | 311 self._GenerateDescription(test_case["description"]); |
| 307 print " @SmallTest" | 312 print " @SmallTest" |
| 313 print " @Feature({\"Android-WebView\"})" |
| 308 print " public void test%s() throws Exception {" % test_case["name"] | 314 print " public void test%s() throws Exception {" % test_case["name"] |
| 309 self._GenerateConfiguration(test_case["properties"]) | 315 self._GenerateConfiguration(test_case["properties"]) |
| 310 self._GenerateMappings(test_case["mappings"]) | 316 self._GenerateMappings(test_case["mappings"]) |
| 311 print " }" | 317 print " }" |
| 312 print "" | 318 print "" |
| 313 | 319 |
| 314 def _GenerateDescription(self, description): | 320 def _GenerateDescription(self, description): |
| 315 print " /**" | 321 print " /**" |
| 316 print " * %s" % description | 322 print " * %s" % description |
| 317 print " *" | 323 print " *" |
| 318 print " * @throws Exception" | 324 print " * @throws Exception" |
| 319 print " */" | 325 print " */" |
| 320 | 326 |
| 321 def _GenerateConfiguration(self, properties): | 327 def _GenerateConfiguration(self, properties): |
| 322 for key in sorted(properties.iterkeys()): | 328 for key in sorted(properties.iterkeys()): |
| 323 print " System.setProperty(\"%s\", \"%s\");" % ( | 329 print " System.setProperty(\"%s\", \"%s\");" % ( |
| 324 key, properties[key]) | 330 key, properties[key]) |
| 325 | 331 |
| 326 def _GenerateMappings(self, mappings): | 332 def _GenerateMappings(self, mappings): |
| 327 for url in sorted(mappings.iterkeys()): | 333 for url in sorted(mappings.iterkeys()): |
| 328 print " checkMapping(\"%s\", \"%s\");" % (url, mappings[url]) | 334 mapping = mappings[url] |
| 335 if 'HTTPS' in mapping: |
| 336 mapping = mapping.replace('HTTPS', 'PROXY') |
| 337 print " checkMapping(\"%s\", \"%s\");" % (url, mapping) |
| 329 | 338 |
| 330 | 339 |
| 331 def main(): | 340 def main(): |
| 332 parser = optparse.OptionParser() | 341 parser = optparse.OptionParser() |
| 333 parser.add_option("-j", "--java", | 342 parser.add_option("-j", "--java", |
| 334 action="store_true", dest="java"); | 343 action="store_true", dest="java"); |
| 335 (options, args) = parser.parse_args(); | 344 (options, args) = parser.parse_args(); |
| 336 if options.java: | 345 if options.java: |
| 337 generator = GenerateJava() | 346 generator = GenerateJava() |
| 338 else: | 347 else: |
| 339 generator = GenerateCPlusPlus() | 348 generator = GenerateCPlusPlus() |
| 340 generator.Generate() | 349 generator.Generate() |
| 341 | 350 |
| 342 if __name__ == '__main__': | 351 if __name__ == '__main__': |
| 343 main() | 352 main() |
| OLD | NEW |