tools/test-harness/jssh-driver/test_layout_engine.py

changeset 0
6474c204b198
equal deleted inserted replaced
-1:000000000000 0:5cf30507b586
1 #!/usr/bin/env python
2 # This Source Code Form is subject to the terms of the Mozilla Public
3 # License, v. 2.0. If a copy of the MPL was not distributed with this
4 # file, You can obtain one at http://mozilla.org/MPL/2.0/.
5 import unittest
6 import sys, os
7 import re, glob
8 import difflib
9
10 this_dir = os.path.abspath(os.path.dirname(__file__))
11 data_dir = os.path.join(this_dir, 'data')
12
13 from jssh_driver import JsshTester
14
15 class LayoutEngineTests(unittest.TestCase):
16
17 def setUp(self):
18 self.tester = JsshTester("localhost")
19 self.get_files_from_data_dir()
20
21 def get_files_from_data_dir(self):
22 self.html_files = glob.glob("%s/*.html" % data_dir)
23 print self.html_files
24 self.golden_images = [re.sub("\.html$", "_inner_html.txt", filename) for filename in self.html_files]
25 print self.golden_images
26
27 def test_inner_html(self):
28 self.failUnless(len(self.html_files) == len(self.golden_images))
29 failures = 0
30 for file, golden_image in zip(self.html_files, self.golden_images):
31 local_url = "file:///" + file
32 local_url = re.sub(r"\\", "/", local_url)
33 print local_url
34 inner_html = self.tester.get_innerHTML_from_URL(local_url)
35 golden_inner_html = open(golden_image).read()
36 if inner_html != golden_inner_html:
37 failures += 1
38 self.failUnless(failures == 0)
39
40 def main():
41 unittest.main()
42
43 if __name__ == '__main__':
44 main()

mercurial