Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(319)

Side by Side Diff: third_party/WebKit/Tools/Scripts/webkitpy/w3c/test_converter_unittest.py

Issue 2012963002: Add and clean up docstrings in webkitpy/w3c. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebased Created 4 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
44 class W3CTestConverterTest(unittest.TestCase): 44 class W3CTestConverterTest(unittest.TestCase):
45 45
46 # 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
47 # then we can just pass in a dummy dir path 47 # then we can just pass in a dummy dir path
48 def fake_dir_path(self, dirname): 48 def fake_dir_path(self, dirname):
49 filesystem = Host().filesystem 49 filesystem = Host().filesystem
50 webkit_root = WebKitFinder(filesystem).webkit_base() 50 webkit_root = WebKitFinder(filesystem).webkit_base()
51 return filesystem.abspath(filesystem.join(webkit_root, "LayoutTests", "c ss", dirname)) 51 return filesystem.abspath(filesystem.join(webkit_root, "LayoutTests", "c ss", dirname))
52 52
53 def test_read_prefixed_property_list(self): 53 def test_read_prefixed_property_list(self):
54 """ Tests that the current list of properties requiring the -webkit- pre fix load correctly """ 54 """Tests that the current list of properties requiring the -webkit- pref ix load correctly."""
55 55
56 # FIXME: We should be passing in a MockHost here ... 56 # FIXME: We should be passing in a MockHost here ...
57 converter = _W3CTestConverter(DUMMY_PATH, DUMMY_FILENAME, None) 57 converter = _W3CTestConverter(DUMMY_PATH, DUMMY_FILENAME, None)
58 prop_list = converter.prefixed_properties 58 prop_list = converter.prefixed_properties
59 self.assertTrue(prop_list, 'No prefixed properties found') 59 self.assertTrue(prop_list, 'No prefixed properties found')
60 60
61 def test_convert_for_webkit_nothing_to_convert(self): 61 def test_convert_for_webkit_nothing_to_convert(self):
62 """ Tests convert_for_webkit() using a basic test that has nothing to co nvert """ 62 """Tests convert_for_webkit() using a basic test that has nothing to con vert."""
63 63
64 test_html = """<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" 64 test_html = """<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
65 "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> 65 "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
66 <html xmlns="http://www.w3.org/1999/xhtml"> 66 <html xmlns="http://www.w3.org/1999/xhtml">
67 <head> 67 <head>
68 <title>CSS Test: DESCRIPTION OF TEST</title> 68 <title>CSS Test: DESCRIPTION OF TEST</title>
69 <link rel="author" title="NAME_OF_AUTHOR" 69 <link rel="author" title="NAME_OF_AUTHOR"
70 href="mailto:EMAIL OR http://CONTACT_PAGE"/> 70 href="mailto:EMAIL OR http://CONTACT_PAGE"/>
71 <link rel="help" href="RELEVANT_SPEC_SECTION"/> 71 <link rel="help" href="RELEVANT_SPEC_SECTION"/>
72 <meta name="assert" content="TEST ASSERTION"/> 72 <meta name="assert" content="TEST ASSERTION"/>
(...skipping 13 matching lines...) Expand all
86 try: 86 try:
87 converter.feed(test_html) 87 converter.feed(test_html)
88 converter.close() 88 converter.close()
89 converted = converter.output() 89 converted = converter.output()
90 finally: 90 finally:
91 oc.restore_output() 91 oc.restore_output()
92 92
93 self.verify_no_conversion_happened(converted, test_html) 93 self.verify_no_conversion_happened(converted, test_html)
94 94
95 def test_convert_for_webkit_properties_only(self): 95 def test_convert_for_webkit_properties_only(self):
96 """ Tests convert_for_webkit() using a test that has 2 prefixed properti es: 1 in a style block + 1 inline style """ 96 """Tests convert_for_webkit() using a test that has 2 prefixed propertie s: 1 in a style block + 1 inline style."""
97 97
98 test_html = """<html> 98 test_html = """<html>
99 <head> 99 <head>
100 <link href="/resources/testharness.css" rel="stylesheet" type="text/css"> 100 <link href="/resources/testharness.css" rel="stylesheet" type="text/css">
101 <script src="/resources/testharness.js"></script> 101 <script src="/resources/testharness.js"></script>
102 <style type="text/css"> 102 <style type="text/css">
103 103
104 #block1 { @test0@: propvalue; } 104 #block1 { @test0@: propvalue; }
105 105
106 </style> 106 </style>
(...skipping 13 matching lines...) Expand all
120 converter.feed(test_content[1]) 120 converter.feed(test_content[1])
121 converter.close() 121 converter.close()
122 converted = converter.output() 122 converted = converter.output()
123 finally: 123 finally:
124 oc.restore_output() 124 oc.restore_output()
125 125
126 self.verify_conversion_happened(converted) 126 self.verify_conversion_happened(converted)
127 self.verify_prefixed_properties(converted, test_content[0]) 127 self.verify_prefixed_properties(converted, test_content[0])
128 128
129 def test_convert_prefixed_properties(self): 129 def test_convert_prefixed_properties(self):
130 """ Tests convert_prefixed_properties() file that has 20 properties requ iring the -webkit- prefix: 130 """Tests convert_prefixed_properties() file that has 20 properties requi ring the -webkit- prefix.
131
132 The properties are:
131 10 in one style block + 5 in another style 133 10 in one style block + 5 in another style
132 block + 5 inline styles, including one with multiple prefixed properties . 134 block + 5 inline styles, including one with multiple prefixed properties .
133 2 when prefixed properties appear in comments without ending ';'. 135 2 when prefixed properties appear in comments without ending ';'.
136
134 The properties in the test content are in all sorts of wack formatting. 137 The properties in the test content are in all sorts of wack formatting.
135 """ 138 """
136 139
137 test_html = """<html> 140 test_html = """<html>
138 <style type="text/css"><![CDATA[ 141 <style type="text/css"><![CDATA[
139 142
140 .block1 { 143 .block1 {
141 width: 300px; 144 width: 300px;
142 height: 300px 145 height: 300px
143 } 146 }
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after
234 try: 237 try:
235 converter.feed(test_html) 238 converter.feed(test_html)
236 converter.close() 239 converter.close()
237 converted = converter.output() 240 converted = converter.output()
238 finally: 241 finally:
239 oc.restore_output() 242 oc.restore_output()
240 243
241 self.assertEqual(converted[1], expected_test_html) 244 self.assertEqual(converted[1], expected_test_html)
242 245
243 def test_convert_attributes_if_needed(self): 246 def test_convert_attributes_if_needed(self):
244 """ Tests convert_attributes_if_needed() using a reference file that has some relative src paths """ 247 """Tests convert_attributes_if_needed() using a reference file that has some relative src paths."""
245 248
246 test_html = """<html> 249 test_html = """<html>
247 <head> 250 <head>
248 <script src="../../some-script.js"></script> 251 <script src="../../some-script.js"></script>
249 <style src="../../../some-style.css"></style> 252 <style src="../../../some-style.css"></style>
250 </head> 253 </head>
251 <body> 254 <body>
252 <img src="../../../../some-image.jpg"> 255 <img src="../../../../some-image.jpg">
253 </body> 256 </body>
254 </html> 257 </html>
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
302 # through the list to replace the double-digit tokens first 305 # through the list to replace the double-digit tokens first
303 index = len(test_properties) - 1 306 index = len(test_properties) - 1
304 while index >= 0: 307 while index >= 0:
305 # Use the unprefixed version 308 # Use the unprefixed version
306 test_prop = test_properties[index].replace('-webkit-', '') 309 test_prop = test_properties[index].replace('-webkit-', '')
307 # Replace the token 310 # Replace the token
308 html = html.replace('@test' + str(index) + '@', test_prop) 311 html = html.replace('@test' + str(index) + '@', test_prop)
309 index -= 1 312 index -= 1
310 313
311 return (test_properties, html) 314 return (test_properties, html)
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698