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

Unified Diff: grit/gather/chrome_html_unittest.py

Issue 23591022: Make image set insertion work in more cases (Closed) Base URL: http://grit-i18n.googlecode.com/svn/trunk/
Patch Set: Created 7 years, 3 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « grit/gather/chrome_html.py ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: grit/gather/chrome_html_unittest.py
===================================================================
--- grit/gather/chrome_html_unittest.py (revision 134)
+++ grit/gather/chrome_html_unittest.py (working copy)
@@ -246,6 +246,121 @@
'''))
tmp_dir.CleanUp()
+ def testFileResourcesMultipleBackgrounds(self):
+ '''Tests inlined image file resources with two url()s.'''
+
+ tmp_dir = util.TempDir({
+ 'test.css': '''
+ .image {
+ background: url(test.png), url(test.png);
+ }
+ ''',
+
+ 'test.png': 'PNG DATA',
+
+ '2x/test.png': '2x PNG DATA',
+ })
+
+ html = chrome_html.ChromeHtml(tmp_dir.GetPath('test.css'))
+ html.SetDefines({'scale_factors': '2x'})
+ html.SetAttributes({'flattenhtml': 'true'})
+ html.Parse()
+ self.failUnlessEqual(StandardizeHtml(html.GetData('en', 'utf-8')),
+ StandardizeHtml('''
+ .image {
+ background: -webkit-image-set(url(data:image/png;base64,UE5HIERBVEE=) 1x, url(data:image/png;base64,MnggUE5HIERBVEE=) 2x), -webkit-image-set(url(data:image/png;base64,UE5HIERBVEE=) 1x, url(data:image/png;base64,MnggUE5HIERBVEE=) 2x);
+ }
+ '''))
+ tmp_dir.CleanUp()
+
+ def testFileResourcesMultipleBackgroundsWithNewline1(self):
+ '''Tests inlined image file resources with line break after first url().'''
+
+ tmp_dir = util.TempDir({
+ 'test.css': '''
+ .image {
+ background: url(test.png),
+ url(test.png);
+ }
+ ''',
+
+ 'test.png': 'PNG DATA',
+
+ '2x/test.png': '2x PNG DATA',
+ })
+
+ html = chrome_html.ChromeHtml(tmp_dir.GetPath('test.css'))
+ html.SetDefines({'scale_factors': '2x'})
+ html.SetAttributes({'flattenhtml': 'true'})
+ html.Parse()
+ self.failUnlessEqual(StandardizeHtml(html.GetData('en', 'utf-8')),
+ StandardizeHtml('''
+ .image {
+ background: -webkit-image-set(url(data:image/png;base64,UE5HIERBVEE=) 1x, url(data:image/png;base64,MnggUE5HIERBVEE=) 2x),
+ -webkit-image-set(url(data:image/png;base64,UE5HIERBVEE=) 1x, url(data:image/png;base64,MnggUE5HIERBVEE=) 2x);
+ }
+ '''))
+ tmp_dir.CleanUp()
+
+ def testFileResourcesMultipleBackgroundsWithNewline2(self):
+ '''Tests inlined image file resources with line break before first url()
+ and before second url().'''
+
+ tmp_dir = util.TempDir({
+ 'test.css': '''
+ .image {
+ background:
+ url(test.png),
+ url(test.png);
+ }
+ ''',
+
+ 'test.png': 'PNG DATA',
+
+ '2x/test.png': '2x PNG DATA',
+ })
+
+ html = chrome_html.ChromeHtml(tmp_dir.GetPath('test.css'))
+ html.SetDefines({'scale_factors': '2x'})
+ html.SetAttributes({'flattenhtml': 'true'})
+ html.Parse()
+ self.failUnlessEqual(StandardizeHtml(html.GetData('en', 'utf-8')),
+ StandardizeHtml('''
+ .image {
+ background: -webkit-image-set(url(data:image/png;base64,UE5HIERBVEE=) 1x, url(data:image/png;base64,MnggUE5HIERBVEE=) 2x),
+ -webkit-image-set(url(data:image/png;base64,UE5HIERBVEE=) 1x, url(data:image/png;base64,MnggUE5HIERBVEE=) 2x);
+ }
+ '''))
+ tmp_dir.CleanUp()
+
+ def testFileResourcesCRLF(self):
+ '''Tests inlined image file resource when url() is preceded by a Windows
+ style line break.'''
+
+ tmp_dir = util.TempDir({
+ 'test.css': '''
+ .image {
+ background:\r\nurl(test.png);
+ }
+ ''',
+
+ 'test.png': 'PNG DATA',
+
+ '2x/test.png': '2x PNG DATA',
+ })
+
+ html = chrome_html.ChromeHtml(tmp_dir.GetPath('test.css'))
+ html.SetDefines({'scale_factors': '2x'})
+ html.SetAttributes({'flattenhtml': 'true'})
+ html.Parse()
+ self.failUnlessEqual(StandardizeHtml(html.GetData('en', 'utf-8')),
+ StandardizeHtml('''
+ .image {
+ background: -webkit-image-set(url(data:image/png;base64,UE5HIERBVEE=) 1x, url(data:image/png;base64,MnggUE5HIERBVEE=) 2x);
+ }
+ '''))
+ tmp_dir.CleanUp()
+
def testThemeResources(self):
'''Tests inserting high DPI chrome://theme references.'''
« 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