OLD | NEW |
1 #!/usr/bin/env python | 1 #!/usr/bin/env python |
2 | 2 |
3 # Copyright (C) 2013 Adobe Systems Incorporated. All rights reserved. | 3 # Copyright (C) 2013 Adobe Systems Incorporated. All rights reserved. |
4 # | 4 # |
5 # Redistribution and use in source and binary forms, with or without | 5 # Redistribution and use in source and binary forms, with or without |
6 # modification, are permitted provided that the following conditions | 6 # modification, are permitted provided that the following conditions |
7 # are met: | 7 # are met: |
8 # | 8 # |
9 # 1. Redistributions of source code must retain the above | 9 # 1. Redistributions of source code must retain the above |
10 # copyright notice, this list of conditions and the following | 10 # copyright notice, this list of conditions and the following |
(...skipping 22 matching lines...) Expand all Loading... |
33 | 33 |
34 from webkitpy.common.host import Host | 34 from webkitpy.common.host import Host |
35 from webkitpy.common.system.outputcapture import OutputCapture | 35 from webkitpy.common.system.outputcapture import OutputCapture |
36 from webkitpy.common.webkit_finder import WebKitFinder | 36 from webkitpy.common.webkit_finder import WebKitFinder |
37 from webkitpy.thirdparty.BeautifulSoup import BeautifulSoup | 37 from webkitpy.thirdparty.BeautifulSoup import BeautifulSoup |
38 from webkitpy.w3c.test_converter import _W3CTestConverter | 38 from webkitpy.w3c.test_converter import _W3CTestConverter |
39 | 39 |
40 DUMMY_FILENAME = 'dummy.html' | 40 DUMMY_FILENAME = 'dummy.html' |
41 DUMMY_PATH = 'dummy/testharness/path' | 41 DUMMY_PATH = 'dummy/testharness/path' |
42 | 42 |
| 43 |
43 class W3CTestConverterTest(unittest.TestCase): | 44 class W3CTestConverterTest(unittest.TestCase): |
44 | 45 |
45 # FIXME: When we move to using a MockHost, this method should be removed, si
nce | 46 # FIXME: When we move to using a MockHost, this method should be removed, si
nce |
46 # then we can just pass in a dummy dir path | 47 # then we can just pass in a dummy dir path |
47 def fake_dir_path(self, dirname): | 48 def fake_dir_path(self, dirname): |
48 filesystem = Host().filesystem | 49 filesystem = Host().filesystem |
49 webkit_root = WebKitFinder(filesystem).webkit_base() | 50 webkit_root = WebKitFinder(filesystem).webkit_base() |
50 return filesystem.abspath(filesystem.join(webkit_root, "LayoutTests", "c
ss", dirname)) | 51 return filesystem.abspath(filesystem.join(webkit_root, "LayoutTests", "c
ss", dirname)) |
51 | 52 |
52 def test_read_prefixed_property_list(self): | 53 def test_read_prefixed_property_list(self): |
(...skipping 302 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
355 test_html = """<html> | 356 test_html = """<html> |
356 <head> | 357 <head> |
357 <script src="../../some-script.js"></script> | 358 <script src="../../some-script.js"></script> |
358 <style src="../../../some-style.css"></style> | 359 <style src="../../../some-style.css"></style> |
359 </head> | 360 </head> |
360 <body> | 361 <body> |
361 <img src="../../../../some-image.jpg"> | 362 <img src="../../../../some-image.jpg"> |
362 </body> | 363 </body> |
363 </html> | 364 </html> |
364 """ | 365 """ |
365 test_reference_support_info = {'reference_relpath': '../', 'files': ['..
/../some-script.js', '../../../some-style.css', '../../../../some-image.jpg'], '
elements': ['script', 'style', 'img']} | 366 test_reference_support_info = {'reference_relpath': '../', 'files': [ |
| 367 '../../some-script.js', '../../../some-style.css', '../../../../some
-image.jpg'], 'elements': ['script', 'style', 'img']} |
366 converter = _W3CTestConverter(DUMMY_PATH, DUMMY_FILENAME, test_reference
_support_info) | 368 converter = _W3CTestConverter(DUMMY_PATH, DUMMY_FILENAME, test_reference
_support_info) |
367 | 369 |
368 oc = OutputCapture() | 370 oc = OutputCapture() |
369 oc.capture_output() | 371 oc.capture_output() |
370 | 372 |
371 try: | 373 try: |
372 converter.feed(test_html) | 374 converter.feed(test_html) |
373 converter.close() | 375 converter.close() |
374 converted = converter.output() | 376 converted = converter.output() |
375 finally: | 377 finally: |
(...skipping 15 matching lines...) Expand all Loading... |
391 resources_dir = converter.path_from_webkit_root("LayoutTests", "resource
s") | 393 resources_dir = converter.path_from_webkit_root("LayoutTests", "resource
s") |
392 | 394 |
393 # Verify the original paths are gone, and the new paths are present. | 395 # Verify the original paths are gone, and the new paths are present. |
394 orig_path_pattern = re.compile('\"/resources/testharness') | 396 orig_path_pattern = re.compile('\"/resources/testharness') |
395 self.assertEquals(len(converted.findAll(src=orig_path_pattern)), 0, 'tes
tharness src path was not converted') | 397 self.assertEquals(len(converted.findAll(src=orig_path_pattern)), 0, 'tes
tharness src path was not converted') |
396 self.assertEquals(len(converted.findAll(href=orig_path_pattern)), 0, 'te
stharness href path was not converted') | 398 self.assertEquals(len(converted.findAll(href=orig_path_pattern)), 0, 'te
stharness href path was not converted') |
397 | 399 |
398 new_relpath = os.path.relpath(resources_dir, test_path) | 400 new_relpath = os.path.relpath(resources_dir, test_path) |
399 relpath_pattern = re.compile(new_relpath) | 401 relpath_pattern = re.compile(new_relpath) |
400 self.assertEquals(len(converted.findAll(src=relpath_pattern)), num_src_p
aths, 'testharness src relative path not correct') | 402 self.assertEquals(len(converted.findAll(src=relpath_pattern)), num_src_p
aths, 'testharness src relative path not correct') |
401 self.assertEquals(len(converted.findAll(href=relpath_pattern)), num_href
_paths, 'testharness href relative path not correct') | 403 self.assertEquals(len(converted.findAll(href=relpath_pattern)), |
| 404 num_href_paths, 'testharness href relative path not co
rrect') |
402 | 405 |
403 def verify_prefixed_properties(self, converted, test_properties): | 406 def verify_prefixed_properties(self, converted, test_properties): |
404 self.assertEqual(len(set(converted[0])), len(set(test_properties)), 'Inc
orrect number of properties converted') | 407 self.assertEqual(len(set(converted[0])), len(set(test_properties)), 'Inc
orrect number of properties converted') |
405 for test_prop in test_properties: | 408 for test_prop in test_properties: |
406 self.assertTrue((test_prop in converted[1]), 'Property ' + test_prop
+ ' not found in converted doc') | 409 self.assertTrue((test_prop in converted[1]), 'Property ' + test_prop
+ ' not found in converted doc') |
407 | 410 |
408 def verify_reference_relative_paths(self, converted, reference_support_info)
: | 411 def verify_reference_relative_paths(self, converted, reference_support_info)
: |
409 idx = 0 | 412 idx = 0 |
410 for path in reference_support_info['files']: | 413 for path in reference_support_info['files']: |
411 expected_path = re.sub(reference_support_info['reference_relpath'],
'', path, 1) | 414 expected_path = re.sub(reference_support_info['reference_relpath'],
'', path, 1) |
(...skipping 14 matching lines...) Expand all Loading... |
426 # through the list to replace the double-digit tokens first | 429 # through the list to replace the double-digit tokens first |
427 index = len(test_properties) - 1 | 430 index = len(test_properties) - 1 |
428 while index >= 0: | 431 while index >= 0: |
429 # Use the unprefixed version | 432 # Use the unprefixed version |
430 test_prop = test_properties[index].replace('-webkit-', '') | 433 test_prop = test_properties[index].replace('-webkit-', '') |
431 # Replace the token | 434 # Replace the token |
432 html = html.replace('@test' + str(index) + '@', test_prop) | 435 html = html.replace('@test' + str(index) + '@', test_prop) |
433 index -= 1 | 436 index -= 1 |
434 | 437 |
435 return (test_properties, html) | 438 return (test_properties, html) |
OLD | NEW |