1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/tools/test-harness/jssh-driver/test_layout_engine.py Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,44 @@ 1.4 +#!/usr/bin/env python 1.5 +# This Source Code Form is subject to the terms of the Mozilla Public 1.6 +# License, v. 2.0. If a copy of the MPL was not distributed with this 1.7 +# file, You can obtain one at http://mozilla.org/MPL/2.0/. 1.8 +import unittest 1.9 +import sys, os 1.10 +import re, glob 1.11 +import difflib 1.12 + 1.13 +this_dir = os.path.abspath(os.path.dirname(__file__)) 1.14 +data_dir = os.path.join(this_dir, 'data') 1.15 + 1.16 +from jssh_driver import JsshTester 1.17 + 1.18 +class LayoutEngineTests(unittest.TestCase): 1.19 + 1.20 + def setUp(self): 1.21 + self.tester = JsshTester("localhost") 1.22 + self.get_files_from_data_dir() 1.23 + 1.24 + def get_files_from_data_dir(self): 1.25 + self.html_files = glob.glob("%s/*.html" % data_dir) 1.26 + print self.html_files 1.27 + self.golden_images = [re.sub("\.html$", "_inner_html.txt", filename) for filename in self.html_files] 1.28 + print self.golden_images 1.29 + 1.30 + def test_inner_html(self): 1.31 + self.failUnless(len(self.html_files) == len(self.golden_images)) 1.32 + failures = 0 1.33 + for file, golden_image in zip(self.html_files, self.golden_images): 1.34 + local_url = "file:///" + file 1.35 + local_url = re.sub(r"\\", "/", local_url) 1.36 + print local_url 1.37 + inner_html = self.tester.get_innerHTML_from_URL(local_url) 1.38 + golden_inner_html = open(golden_image).read() 1.39 + if inner_html != golden_inner_html: 1.40 + failures += 1 1.41 + self.failUnless(failures == 0) 1.42 + 1.43 +def main(): 1.44 + unittest.main() 1.45 + 1.46 +if __name__ == '__main__': 1.47 + main()