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

Thu, 22 Jan 2015 13:21:57 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Thu, 22 Jan 2015 13:21:57 +0100
branch
TOR_BUG_9701
changeset 15
b8a032363ba2
permissions
-rwxr-xr-x

Incorporate requested changes from Mozilla in review:
https://bugzilla.mozilla.org/show_bug.cgi?id=1123480#c6

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

mercurial