| OLD | NEW |
| (Empty) |
| 1 # Copyright (C) 2010 Google Inc. All rights reserved. | |
| 2 # | |
| 3 # Redistribution and use in source and binary forms, with or without | |
| 4 # modification, are permitted provided that the following conditions are | |
| 5 # met: | |
| 6 # | |
| 7 # * Redistributions of source code must retain the above copyright | |
| 8 # notice, this list of conditions and the following disclaimer. | |
| 9 # * Redistributions in binary form must reproduce the above | |
| 10 # copyright notice, this list of conditions and the following disclaimer | |
| 11 # in the documentation and/or other materials provided with the | |
| 12 # distribution. | |
| 13 # * Neither the name of Google Inc. nor the names of its | |
| 14 # contributors may be used to endorse or promote products derived from | |
| 15 # this software without specific prior written permission. | |
| 16 # | |
| 17 # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS | |
| 18 # "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT | |
| 19 # LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR | |
| 20 # A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT | |
| 21 # OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, | |
| 22 # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT | |
| 23 # LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | |
| 24 # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | |
| 25 # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | |
| 26 # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | |
| 27 # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | |
| 28 | |
| 29 """Unit tests for update_webgl_conformance_tests.""" | |
| 30 | |
| 31 import unittest | |
| 32 | |
| 33 from webkitpy.webgl import update_webgl_conformance_tests as webgl | |
| 34 | |
| 35 | |
| 36 def construct_script(name): | |
| 37 return "<script src=\"" + name + "\"></script>\n" | |
| 38 | |
| 39 | |
| 40 def construct_style(name): | |
| 41 return "<link rel=\"stylesheet\" href=\"" + name + "\">" | |
| 42 | |
| 43 | |
| 44 class TestTranslation(unittest.TestCase): | |
| 45 def assert_unchanged(self, text): | |
| 46 self.assertEqual(text, webgl.translate_khronos_test(text)) | |
| 47 | |
| 48 def assert_translate(self, input, output): | |
| 49 self.assertEqual(output, webgl.translate_khronos_test(input)) | |
| 50 | |
| 51 def test_simple_unchanged(self): | |
| 52 self.assert_unchanged("") | |
| 53 self.assert_unchanged("<html></html>") | |
| 54 | |
| 55 def test_header_strip(self): | |
| 56 single_line_header = "<!-- single line header. -->" | |
| 57 multi_line_header = """<!-- this is a multi-line | |
| 58 header. it should all be removed too. | |
| 59 -->""" | |
| 60 text = "<html></html>" | |
| 61 self.assert_translate(single_line_header, "") | |
| 62 self.assert_translate(single_line_header + text, text) | |
| 63 self.assert_translate(multi_line_header + text, text) | |
| 64 | |
| 65 def dont_strip_other_headers(self): | |
| 66 self.assert_unchanged("<html>\n<!-- don't remove comments on other lines
. -->\n</html>") | |
| 67 | |
| 68 def test_include_rewriting(self): | |
| 69 # Mappings to None are unchanged | |
| 70 styles = { | |
| 71 "../resources/js-test-style.css": "../../js/resources/js-test-style.
css", | |
| 72 "fail.css": None, | |
| 73 "resources/stylesheet.css": None, | |
| 74 "../resources/style.css": None, | |
| 75 } | |
| 76 scripts = { | |
| 77 "../resources/js-test-pre.js": "../../js/resources/js-test-pre.js", | |
| 78 "../resources/js-test-post.js": "../../js/resources/js-test-post.js"
, | |
| 79 "../resources/desktop-gl-constants.js": "resources/desktop-gl-consta
nts.js", | |
| 80 | |
| 81 "resources/shadow-offset.js": None, | |
| 82 "../resources/js-test-post-async.js": None, | |
| 83 } | |
| 84 | |
| 85 input_text = "" | |
| 86 output_text = "" | |
| 87 for input, output in styles.items(): | |
| 88 input_text += construct_style(input) | |
| 89 output_text += construct_style(output if output else input) | |
| 90 for input, output in scripts.items(): | |
| 91 input_text += construct_script(input) | |
| 92 output_text += construct_script(output if output else input) | |
| 93 | |
| 94 head = '<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">\n<html>\n<head>\n
' | |
| 95 foot = '</head>\n<body>\n</body>\n</html>' | |
| 96 input_text = head + input_text + foot | |
| 97 output_text = head + output_text + foot | |
| 98 self.assert_translate(input_text, output_text) | |
| OLD | NEW |