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

Side by Side Diff: grit/gather/chrome_html_unittest.py

Issue 10795100: Accept CSS url()s without quotes. (Closed) Base URL: http://grit-i18n.googlecode.com/svn/trunk
Patch Set: Created 8 years, 5 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 | Annotate | Revision Log
« no previous file with comments | « grit/gather/chrome_html.py ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 '''Unit tests for grit.gather.chrome_html''' 6 '''Unit tests for grit.gather.chrome_html'''
7 7
8 8
9 import os 9 import os
10 import re 10 import re
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after
104 html.SetAttributes({'flattenhtml': 'false'}) 104 html.SetAttributes({'flattenhtml': 'false'})
105 html.Parse() 105 html.Parse()
106 self.failUnlessEqual(StandardizeHtml(html.GetData('en', 'utf-8')), 106 self.failUnlessEqual(StandardizeHtml(html.GetData('en', 'utf-8')),
107 StandardizeHtml(''' 107 StandardizeHtml('''
108 .image { 108 .image {
109 background: -webkit-image-set(url("test.png") 1x, url("1.4x/test.png") 1 .4x, url("1.8x/test.png") 1.8x); 109 background: -webkit-image-set(url("test.png") 1x, url("1.4x/test.png") 1 .4x, url("1.8x/test.png") 1.8x);
110 } 110 }
111 ''')) 111 '''))
112 tmp_dir.CleanUp() 112 tmp_dir.CleanUp()
113 113
114 def testFileResourcesDoubleQuotes(self):
115 '''Tests inlined image file resources if url() filename is double quoted.'''
116
117 tmp_dir = util.TempDir({
118 'test.css': '''
119 .image {
120 background: url("test.png");
121 }
122 ''',
123
124 'test.png': 'PNG DATA',
125 })
126
127 html = chrome_html.ChromeHtml(tmp_dir.GetPath('test.css'))
128 html.SetAttributes({'flattenhtml': 'true'})
129 html.Parse()
130 self.failUnlessEqual(StandardizeHtml(html.GetData('en', 'utf-8')),
131 StandardizeHtml('''
132 .image {
133 background: -webkit-image-set(url("data:image/png;base64,UE5HIERBVEE=") 1x);
134 }
135 '''))
136 tmp_dir.CleanUp()
137
138 def testFileResourcesNoQuotes(self):
139 '''Tests inlined image file resources when url() filename is unquoted.'''
140
141 tmp_dir = util.TempDir({
142 'test.css': '''
143 .image {
144 background: url(test.png);
145 }
146 ''',
147
148 'test.png': 'PNG DATA',
149 })
150
151 html = chrome_html.ChromeHtml(tmp_dir.GetPath('test.css'))
152 html.SetAttributes({'flattenhtml': 'true'})
153 html.Parse()
154 self.failUnlessEqual(StandardizeHtml(html.GetData('en', 'utf-8')),
155 StandardizeHtml('''
156 .image {
157 background: -webkit-image-set(url("data:image/png;base64,UE5HIERBVEE=") 1x);
158 }
159 '''))
160 tmp_dir.CleanUp()
161
114 def testFileResourcesNoFile(self): 162 def testFileResourcesNoFile(self):
115 '''Tests inlined image file resources without available high DPI assets.''' 163 '''Tests inlined image file resources without available high DPI assets.'''
116 164
117 tmp_dir = util.TempDir({ 165 tmp_dir = util.TempDir({
118 'index.html': ''' 166 'index.html': '''
119 <!DOCTYPE HTML> 167 <!DOCTYPE HTML>
120 <html> 168 <html>
121 <head> 169 <head>
122 <link rel="stylesheet" href="test.css"> 170 <link rel="stylesheet" href="test.css">
123 </head> 171 </head>
(...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after
252 </head> 300 </head>
253 <body> 301 <body>
254 <!-- Don't need a body. --> 302 <!-- Don't need a body. -->
255 </body> 303 </body>
256 </html> 304 </html>
257 ''')) 305 '''))
258 tmp_dir.CleanUp() 306 tmp_dir.CleanUp()
259 307
260 if __name__ == '__main__': 308 if __name__ == '__main__':
261 unittest.main() 309 unittest.main()
OLDNEW
« no previous file with comments | « grit/gather/chrome_html.py ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698