| 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 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 95 self.assertNotEqual(test_info, None, 'did not find a test') | 95 self.assertNotEqual(test_info, None, 'did not find a test') |
| 96 self.assertTrue('test' in test_info.keys(), 'did not find a test file') | 96 self.assertTrue('test' in test_info.keys(), 'did not find a test file') |
| 97 self.assertTrue('reference' in test_info.keys(), 'did not find a referen
ce file') | 97 self.assertTrue('reference' in test_info.keys(), 'did not find a referen
ce file') |
| 98 self.assertTrue(test_info['reference'].startswith(test_path), 'reference
path is not correct') | 98 self.assertTrue(test_info['reference'].startswith(test_path), 'reference
path is not correct') |
| 99 self.assertFalse('refsupport' in test_info.keys(), 'there should be no r
efsupport files for this test') | 99 self.assertFalse('refsupport' in test_info.keys(), 'there should be no r
efsupport files for this test') |
| 100 self.assertFalse('jstest' in test_info.keys(), 'test should not have bee
n analyzed as a jstest') | 100 self.assertFalse('jstest' in test_info.keys(), 'test should not have bee
n analyzed as a jstest') |
| 101 | 101 |
| 102 self.assertEqual(logs, 'Multiple references are not supported. Importing
the first ref defined in somefile.html\n') | 102 self.assertEqual(logs, 'Multiple references are not supported. Importing
the first ref defined in somefile.html\n') |
| 103 | 103 |
| 104 def test_analyze_test_reftest_with_ref_support_Files(self): | 104 def test_analyze_test_reftest_with_ref_support_Files(self): |
| 105 """ Tests analyze_test() using a reftest that has refers to a reference
file outside of the tests directory and the reference file has paths to other su
pport files """ | 105 """Tests analyze_test() using a reftest that has refers to a |
| 106 reference file outside of the tests directory and the reference |
| 107 file has paths to other support files. |
| 108 """ |
| 106 | 109 |
| 107 test_html = """<html> | 110 test_html = """<html> |
| 108 <head> | 111 <head> |
| 109 <link rel="match" href="../reference/green-box-ref.xht" /> | 112 <link rel="match" href="../reference/green-box-ref.xht" /> |
| 110 </head> | 113 </head> |
| 111 """ | 114 """ |
| 112 ref_html = """<head> | 115 ref_html = """<head> |
| 113 <link href="support/css/ref-stylesheet.css" rel="stylesheet" type="text/css"> | 116 <link href="support/css/ref-stylesheet.css" rel="stylesheet" type="text/css"> |
| 114 <style type="text/css"> | 117 <style type="text/css"> |
| 115 background-image: url("../../support/some-image.png") | 118 background-image: url("../../support/some-image.png") |
| (...skipping 10 matching lines...) Expand all Loading... |
| 126 | 129 |
| 127 self.assertNotEqual(test_info, None, 'did not find a test') | 130 self.assertNotEqual(test_info, None, 'did not find a test') |
| 128 self.assertTrue('test' in test_info.keys(), 'did not find a test file') | 131 self.assertTrue('test' in test_info.keys(), 'did not find a test file') |
| 129 self.assertTrue('reference' in test_info.keys(), 'did not find a referen
ce file') | 132 self.assertTrue('reference' in test_info.keys(), 'did not find a referen
ce file') |
| 130 self.assertTrue(test_info['reference'].startswith(test_path), 'reference
path is not correct') | 133 self.assertTrue(test_info['reference'].startswith(test_path), 'reference
path is not correct') |
| 131 self.assertTrue('reference_support_info' in test_info.keys(), 'there sho
uld be reference_support_info for this test') | 134 self.assertTrue('reference_support_info' in test_info.keys(), 'there sho
uld be reference_support_info for this test') |
| 132 self.assertEquals(len(test_info['reference_support_info']['files']), 3,
'there should be 3 support files in this reference') | 135 self.assertEquals(len(test_info['reference_support_info']['files']), 3,
'there should be 3 support files in this reference') |
| 133 self.assertFalse('jstest' in test_info.keys(), 'test should not have bee
n analyzed as a jstest') | 136 self.assertFalse('jstest' in test_info.keys(), 'test should not have bee
n analyzed as a jstest') |
| 134 | 137 |
| 135 def test_analyze_jstest(self): | 138 def test_analyze_jstest(self): |
| 136 """ Tests analyze_test() using a jstest """ | 139 """Tests analyze_test() using a jstest""" |
| 137 | 140 |
| 138 test_html = """<head> | 141 test_html = """<head> |
| 139 <link href="/resources/testharness.css" rel="stylesheet" type="text/css"> | 142 <link href="/resources/testharness.css" rel="stylesheet" type="text/css"> |
| 140 <script src="/resources/testharness.js"></script> | 143 <script src="/resources/testharness.js"></script> |
| 141 </head> | 144 </head> |
| 142 """ | 145 """ |
| 143 test_path = '/some/madeup/path/' | 146 test_path = '/some/madeup/path/' |
| 144 parser = TestParser(test_path + 'somefile.html', MockHost()) | 147 parser = TestParser(test_path + 'somefile.html', MockHost()) |
| 145 test_info = parser.analyze_test(test_contents=test_html) | 148 test_info = parser.analyze_test(test_contents=test_html) |
| 146 | 149 |
| 147 self.assertNotEqual(test_info, None, 'test_info is None') | 150 self.assertNotEqual(test_info, None, 'test_info is None') |
| 148 self.assertTrue('test' in test_info.keys(), 'did not find a test file') | 151 self.assertTrue('test' in test_info.keys(), 'did not find a test file') |
| 149 self.assertFalse('reference' in test_info.keys(), 'should not have found
a reference file') | 152 self.assertFalse('reference' in test_info.keys(), 'should not have found
a reference file') |
| 150 self.assertFalse('refsupport' in test_info.keys(), 'there should be no r
efsupport files for this test') | 153 self.assertFalse('refsupport' in test_info.keys(), 'there should be no r
efsupport files for this test') |
| 151 self.assertTrue('jstest' in test_info.keys(), 'test should be a jstest') | 154 self.assertTrue('jstest' in test_info.keys(), 'test should be a jstest') |
| 152 | 155 |
| 153 def test_analyze_pixel_test_all_true(self): | 156 def test_analyze_pixel_test_all_true(self): |
| 154 """ Tests analyze_test() using a test that is neither a reftest or jstes
t with all=False """ | 157 """Tests analyze_test() using a test that is neither a reftest or jstest
with all=False""" |
| 155 | 158 |
| 156 test_html = """<html> | 159 test_html = """<html> |
| 157 <head> | 160 <head> |
| 158 <title>CSS Test: DESCRIPTION OF TEST</title> | 161 <title>CSS Test: DESCRIPTION OF TEST</title> |
| 159 <link rel="author" title="NAME_OF_AUTHOR" /> | 162 <link rel="author" title="NAME_OF_AUTHOR" /> |
| 160 <style type="text/css"><![CDATA[ | 163 <style type="text/css"><![CDATA[ |
| 161 CSS FOR TEST | 164 CSS FOR TEST |
| 162 ]]></style> | 165 ]]></style> |
| 163 </head> | 166 </head> |
| 164 <body> | 167 <body> |
| 165 CONTENT OF TEST | 168 CONTENT OF TEST |
| 166 </body> | 169 </body> |
| 167 </html> | 170 </html> |
| 168 """ | 171 """ |
| 169 # Set 'all' to True so this gets found. | 172 # Set 'all' to True so this gets found. |
| 170 options = {'all': True} | 173 options = {'all': True} |
| 171 | 174 |
| 172 test_path = '/some/madeup/path/' | 175 test_path = '/some/madeup/path/' |
| 173 parser = TestParser(test_path + 'somefile.html', MockHost(), options) | 176 parser = TestParser(test_path + 'somefile.html', MockHost(), options) |
| 174 test_info = parser.analyze_test(test_contents=test_html) | 177 test_info = parser.analyze_test(test_contents=test_html) |
| 175 | 178 |
| 176 self.assertNotEqual(test_info, None, 'test_info is None') | 179 self.assertNotEqual(test_info, None, 'test_info is None') |
| 177 self.assertTrue('test' in test_info.keys(), 'did not find a test file') | 180 self.assertTrue('test' in test_info.keys(), 'did not find a test file') |
| 178 self.assertFalse('reference' in test_info.keys(), 'shold not have found
a reference file') | 181 self.assertFalse('reference' in test_info.keys(), 'shold not have found
a reference file') |
| 179 self.assertFalse('refsupport' in test_info.keys(), 'there should be no r
efsupport files for this test') | 182 self.assertFalse('refsupport' in test_info.keys(), 'there should be no r
efsupport files for this test') |
| 180 self.assertFalse('jstest' in test_info.keys(), 'test should not be a jst
est') | 183 self.assertFalse('jstest' in test_info.keys(), 'test should not be a jst
est') |
| 181 | 184 |
| 182 def test_analyze_pixel_test_all_false(self): | 185 def test_analyze_pixel_test_all_false(self): |
| 183 """ Tests analyze_test() using a test that is neither a reftest or jstes
t, with -all=False """ | 186 """Tests analyze_test() using a test that is neither a reftest or jstest
, with -all=False""" |
| 184 | 187 |
| 185 test_html = """<html> | 188 test_html = """<html> |
| 186 <head> | 189 <head> |
| 187 <title>CSS Test: DESCRIPTION OF TEST</title> | 190 <title>CSS Test: DESCRIPTION OF TEST</title> |
| 188 <link rel="author" title="NAME_OF_AUTHOR" /> | 191 <link rel="author" title="NAME_OF_AUTHOR" /> |
| 189 <style type="text/css"><![CDATA[ | 192 <style type="text/css"><![CDATA[ |
| 190 CSS FOR TEST | 193 CSS FOR TEST |
| 191 ]]></style> | 194 ]]></style> |
| 192 </head> | 195 </head> |
| 193 <body> | 196 <body> |
| 194 CONTENT OF TEST | 197 CONTENT OF TEST |
| 195 </body> | 198 </body> |
| 196 </html> | 199 </html> |
| 197 """ | 200 """ |
| 198 # Set 'all' to False so this gets skipped. | 201 # Set 'all' to False so this gets skipped. |
| 199 options = {'all': False} | 202 options = {'all': False} |
| 200 | 203 |
| 201 test_path = '/some/madeup/path/' | 204 test_path = '/some/madeup/path/' |
| 202 parser = TestParser(test_path + 'somefile.html', MockHost(), options) | 205 parser = TestParser(test_path + 'somefile.html', MockHost(), options) |
| 203 test_info = parser.analyze_test(test_contents=test_html) | 206 test_info = parser.analyze_test(test_contents=test_html) |
| 204 self.assertEqual(test_info, None, 'test should have been skipped') | 207 self.assertEqual(test_info, None, 'test should have been skipped') |
| 205 | 208 |
| 206 def test_analyze_non_html_file(self): | 209 def test_analyze_non_html_file(self): |
| 207 """ Tests analyze_test() with a file that has no html""" | 210 """Tests analyze_test() with a file that has no html""" |
| 208 # FIXME: use a mock filesystem | 211 # FIXME: use a mock filesystem |
| 209 parser = TestParser(os.path.join(os.path.dirname(__file__), 'test_parser
.py'), MockHost()) | 212 parser = TestParser(os.path.join(os.path.dirname(__file__), 'test_parser
.py'), MockHost()) |
| 210 test_info = parser.analyze_test() | 213 test_info = parser.analyze_test() |
| 211 self.assertEqual(test_info, None, 'no tests should have been found in th
is file') | 214 self.assertEqual(test_info, None, 'no tests should have been found in th
is file') |
| 212 | 215 |
| 213 def test_parser_initialization_non_existent_file(self): | 216 def test_parser_initialization_non_existent_file(self): |
| 214 parser = TestParser('some/bogus/path.html', MockHost()) | 217 parser = TestParser('some/bogus/path.html', MockHost()) |
| 215 self.assertEqual(parser.filename, 'some/bogus/path.html') | 218 self.assertEqual(parser.filename, 'some/bogus/path.html') |
| 216 self.assertIsNone(parser.test_doc) | 219 self.assertIsNone(parser.test_doc) |
| 217 self.assertIsNone(parser.ref_doc) | 220 self.assertIsNone(parser.ref_doc) |
| OLD | NEW |