| OLD | NEW |
| 1 # Copyright (C) 2013 Adobe Systems Incorporated. All rights reserved. | 1 # Copyright (C) 2013 Adobe Systems Incorporated. All rights reserved. |
| 2 # | 2 # |
| 3 # Redistribution and use in source and binary forms, with or without | 3 # Redistribution and use in source and binary forms, with or without |
| 4 # modification, are permitted provided that the following conditions | 4 # modification, are permitted provided that the following conditions |
| 5 # are met: | 5 # are met: |
| 6 # | 6 # |
| 7 # 1. Redistributions of source code must retain the above | 7 # 1. Redistributions of source code must retain the above |
| 8 # copyright notice, this list of conditions and the following | 8 # copyright notice, this list of conditions and the following |
| 9 # disclaimer. | 9 # disclaimer. |
| 10 # 2. Redistributions in binary form must reproduce the above | 10 # 2. Redistributions in binary form must reproduce the above |
| (...skipping 11 matching lines...) Expand all Loading... |
| 22 # PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | 22 # PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
| 23 # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR | 23 # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR |
| 24 # TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF | 24 # TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF |
| 25 # THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | 25 # THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF |
| 26 # SUCH DAMAGE. | 26 # SUCH DAMAGE. |
| 27 | 27 |
| 28 import re | 28 import re |
| 29 import unittest | 29 import unittest |
| 30 | 30 |
| 31 from webkitpy.common.host import Host | 31 from webkitpy.common.host import Host |
| 32 from webkitpy.common.system.output_capture import OutputCapture | |
| 33 from webkitpy.common.webkit_finder import WebKitFinder | 32 from webkitpy.common.webkit_finder import WebKitFinder |
| 34 from webkitpy.w3c.test_converter import _W3CTestConverter, convert_for_webkit | 33 from webkitpy.w3c.test_converter import _W3CTestConverter, convert_for_webkit |
| 35 from webkitpy.common.system.system_host_mock import MockSystemHost | 34 from webkitpy.common.system.system_host_mock import MockSystemHost |
| 36 from webkitpy.common.system.filesystem_mock import MockFileSystem | 35 from webkitpy.common.system.filesystem_mock import MockFileSystem |
| 37 | 36 |
| 38 DUMMY_FILENAME = 'dummy.html' | 37 DUMMY_FILENAME = 'dummy.html' |
| 39 DUMMY_PATH = 'dummy/testharness/path' | 38 DUMMY_PATH = 'dummy/testharness/path' |
| 40 | 39 |
| 41 | 40 |
| 42 class W3CTestConverterTest(unittest.TestCase): | 41 class W3CTestConverterTest(unittest.TestCase): |
| (...skipping 29 matching lines...) Expand all Loading... |
| 72 CSS FOR TEST | 71 CSS FOR TEST |
| 73 ]]></style> | 72 ]]></style> |
| 74 </head> | 73 </head> |
| 75 <body> | 74 <body> |
| 76 CONTENT OF TEST | 75 CONTENT OF TEST |
| 77 </body> | 76 </body> |
| 78 </html> | 77 </html> |
| 79 """ | 78 """ |
| 80 converter = _W3CTestConverter(DUMMY_PATH, DUMMY_FILENAME, None) | 79 converter = _W3CTestConverter(DUMMY_PATH, DUMMY_FILENAME, None) |
| 81 | 80 |
| 82 oc = OutputCapture() | 81 converter.feed(test_html) |
| 83 oc.capture_output() | 82 converter.close() |
| 84 try: | 83 converted = converter.output() |
| 85 converter.feed(test_html) | |
| 86 converter.close() | |
| 87 converted = converter.output() | |
| 88 finally: | |
| 89 oc.restore_output() | |
| 90 | 84 |
| 91 self.verify_no_conversion_happened(converted, test_html) | 85 self.verify_no_conversion_happened(converted, test_html) |
| 92 | 86 |
| 93 def test_convert_for_webkit_properties_only(self): | 87 def test_convert_for_webkit_properties_only(self): |
| 94 """Tests convert_for_webkit() using a test that has 2 prefixed propertie
s: 1 in a style block + 1 inline style.""" | 88 """Tests convert_for_webkit() using a test that has 2 prefixed propertie
s: 1 in a style block + 1 inline style.""" |
| 95 | 89 |
| 96 test_html = """<html> | 90 test_html = """<html> |
| 97 <head> | 91 <head> |
| 98 <link href="/resources/testharness.css" rel="stylesheet" type="text/css"> | 92 <link href="/resources/testharness.css" rel="stylesheet" type="text/css"> |
| 99 <script src="/resources/testharness.js"></script> | 93 <script src="/resources/testharness.js"></script> |
| 100 <style type="text/css"> | 94 <style type="text/css"> |
| 101 | 95 |
| 102 #block1 { @test0@: propvalue; } | 96 #block1 { @test0@: propvalue; } |
| 103 | 97 |
| 104 </style> | 98 </style> |
| 105 </head> | 99 </head> |
| 106 <body> | 100 <body> |
| 107 <div id="elem1" style="@test1@: propvalue;"></div> | 101 <div id="elem1" style="@test1@: propvalue;"></div> |
| 108 </body> | 102 </body> |
| 109 </html> | 103 </html> |
| 110 """ | 104 """ |
| 111 fake_dir_path = self.fake_dir_path('harnessandprops') | 105 fake_dir_path = self.fake_dir_path('harnessandprops') |
| 112 converter = _W3CTestConverter(fake_dir_path, DUMMY_FILENAME, None) | 106 converter = _W3CTestConverter(fake_dir_path, DUMMY_FILENAME, None) |
| 113 test_content = self.generate_test_content(converter.prefixed_properties,
1, test_html) | 107 test_content = self.generate_test_content(converter.prefixed_properties,
1, test_html) |
| 114 | 108 |
| 115 oc = OutputCapture() | 109 converter.feed(test_content[1]) |
| 116 oc.capture_output() | 110 converter.close() |
| 117 try: | 111 converted = converter.output() |
| 118 converter.feed(test_content[1]) | |
| 119 converter.close() | |
| 120 converted = converter.output() | |
| 121 finally: | |
| 122 oc.restore_output() | |
| 123 | 112 |
| 124 self.verify_conversion_happened(converted) | 113 self.verify_conversion_happened(converted) |
| 125 self.verify_prefixed_properties(converted, test_content[0]) | 114 self.verify_prefixed_properties(converted, test_content[0]) |
| 126 | 115 |
| 127 def test_convert_prefixed_properties(self): | 116 def test_convert_prefixed_properties(self): |
| 128 """Tests convert_prefixed_properties() file that has 20 properties requi
ring the -webkit- prefix. | 117 """Tests convert_prefixed_properties() file that has 20 properties requi
ring the -webkit- prefix. |
| 129 | 118 |
| 130 The properties are: | 119 The properties are: |
| 131 10 in one style block + 5 in another style | 120 10 in one style block + 5 in another style |
| 132 block + 5 inline styles, including one with multiple prefixed properties
. | 121 block + 5 inline styles, including one with multiple prefixed properties
. |
| (...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 192 /* @test20@: propvalue */ | 181 /* @test20@: propvalue */ |
| 193 @test21@: propvalue; | 182 @test21@: propvalue; |
| 194 } | 183 } |
| 195 | 184 |
| 196 ]]></style> | 185 ]]></style> |
| 197 </html> | 186 </html> |
| 198 """ | 187 """ |
| 199 converter = _W3CTestConverter(DUMMY_PATH, DUMMY_FILENAME, None) | 188 converter = _W3CTestConverter(DUMMY_PATH, DUMMY_FILENAME, None) |
| 200 test_content = self.generate_test_content(converter.prefixed_properties,
4, test_html) | 189 test_content = self.generate_test_content(converter.prefixed_properties,
4, test_html) |
| 201 | 190 |
| 202 oc = OutputCapture() | 191 converter.feed(test_content[1]) |
| 203 oc.capture_output() | 192 converter.close() |
| 204 try: | 193 converted = converter.output() |
| 205 converter.feed(test_content[1]) | |
| 206 converter.close() | |
| 207 converted = converter.output() | |
| 208 finally: | |
| 209 oc.restore_output() | |
| 210 | 194 |
| 211 self.verify_conversion_happened(converted) | 195 self.verify_conversion_happened(converted) |
| 212 self.verify_prefixed_properties(converted, test_content[0]) | 196 self.verify_prefixed_properties(converted, test_content[0]) |
| 213 | 197 |
| 214 def test_convert_attributes_if_needed(self): | 198 def test_convert_attributes_if_needed(self): |
| 215 """Tests convert_attributes_if_needed() using a reference file that has
some relative src paths.""" | 199 """Tests convert_attributes_if_needed() using a reference file that has
some relative src paths.""" |
| 216 | 200 |
| 217 test_html = """<html> | 201 test_html = """<html> |
| 218 <head> | 202 <head> |
| 219 <script src="../../some-script.js"></script> | 203 <script src="../../some-script.js"></script> |
| 220 <style src="../../../some-style.css"></style> | 204 <style src="../../../some-style.css"></style> |
| 221 </head> | 205 </head> |
| 222 <body> | 206 <body> |
| 223 <img src="../../../../some-image.jpg"> | 207 <img src="../../../../some-image.jpg"> |
| 224 </body> | 208 </body> |
| 225 </html> | 209 </html> |
| 226 """ | 210 """ |
| 227 test_reference_support_info = { | 211 test_reference_support_info = { |
| 228 'reference_relpath': '../', | 212 'reference_relpath': '../', |
| 229 'files': ['../../some-script.js', '../../../some-style.css', '../../
../../some-image.jpg'], | 213 'files': ['../../some-script.js', '../../../some-style.css', '../../
../../some-image.jpg'], |
| 230 'elements': ['script', 'style', 'img'] | 214 'elements': ['script', 'style', 'img'] |
| 231 } | 215 } |
| 232 converter = _W3CTestConverter(DUMMY_PATH, DUMMY_FILENAME, test_reference
_support_info) | 216 converter = _W3CTestConverter(DUMMY_PATH, DUMMY_FILENAME, test_reference
_support_info) |
| 233 | 217 |
| 234 oc = OutputCapture() | 218 converter.feed(test_html) |
| 235 oc.capture_output() | 219 converter.close() |
| 236 | 220 converted = converter.output() |
| 237 try: | |
| 238 converter.feed(test_html) | |
| 239 converter.close() | |
| 240 converted = converter.output() | |
| 241 finally: | |
| 242 oc.restore_output() | |
| 243 | 221 |
| 244 self.verify_conversion_happened(converted) | 222 self.verify_conversion_happened(converted) |
| 245 self.verify_reference_relative_paths(converted, test_reference_support_i
nfo) | 223 self.verify_reference_relative_paths(converted, test_reference_support_i
nfo) |
| 246 | 224 |
| 247 def verify_conversion_happened(self, converted): | 225 def verify_conversion_happened(self, converted): |
| 248 self.assertTrue(converted, "conversion didn't happen") | 226 self.assertTrue(converted, "conversion didn't happen") |
| 249 | 227 |
| 250 def verify_no_conversion_happened(self, converted, original): | 228 def verify_no_conversion_happened(self, converted, original): |
| 251 self.assertEqual(converted[1], original, 'test should not have been conv
erted') | 229 self.assertEqual(converted[1], original, 'test should not have been conv
erted') |
| 252 | 230 |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 299 test_html = """<FONT></FONT>""" | 277 test_html = """<FONT></FONT>""" |
| 300 converter = _W3CTestConverter(DUMMY_PATH, DUMMY_FILENAME, None) | 278 converter = _W3CTestConverter(DUMMY_PATH, DUMMY_FILENAME, None) |
| 301 converter.feed(test_html) | 279 converter.feed(test_html) |
| 302 self.assertEqual(converter.output(), ([], """<FONT></FONT>""")) | 280 self.assertEqual(converter.output(), ([], """<FONT></FONT>""")) |
| 303 | 281 |
| 304 def test_for_comments(self): | 282 def test_for_comments(self): |
| 305 test_html = """<!--abc--><!-- foo -->""" | 283 test_html = """<!--abc--><!-- foo -->""" |
| 306 converter = _W3CTestConverter(DUMMY_PATH, DUMMY_FILENAME, None) | 284 converter = _W3CTestConverter(DUMMY_PATH, DUMMY_FILENAME, None) |
| 307 converter.feed(test_html) | 285 converter.feed(test_html) |
| 308 self.assertEqual(converter.output(), ([], """<!--abc--><!-- foo -->""")) | 286 self.assertEqual(converter.output(), ([], """<!--abc--><!-- foo -->""")) |
| OLD | NEW |