Add test for invisible elements.

This commit is contained in:
Florian Bruhin 2015-05-12 19:08:54 +02:00
parent 2b440bc8db
commit 7edfdaa271
2 changed files with 10 additions and 2 deletions

View File

@ -83,16 +83,17 @@ class JSTester:
with self._qtbot.waitSignal(page.scrollRequested): with self._qtbot.waitSignal(page.scrollRequested):
page.mainFrame().scrollToAnchor(name) page.mainFrame().scrollToAnchor(name)
def load(self, path): def load(self, path, **kwargs):
"""Load and display the given test data. """Load and display the given test data.
Args: Args:
path: The path to the test file, relative to the javascript/ path: The path to the test file, relative to the javascript/
folder. folder.
**kwargs: Passed to jinja's template.render().
""" """
template = self._jinja_env.get_template(path) template = self._jinja_env.get_template(path)
with self._qtbot.waitSignal(self.webview.loadFinished): with self._qtbot.waitSignal(self.webview.loadFinished):
self.webview.setHtml(template.render()) self.webview.setHtml(template.render(**kwargs))
def run_file(self, filename): def run_file(self, filename):
"""Run a javascript file. """Run a javascript file.

View File

@ -76,3 +76,10 @@ def test_scrolled_down(caret_tester):
caret_tester.js.scroll_anchor('anchor') caret_tester.js.scroll_anchor('anchor')
caret_tester.check_scrolled() caret_tester.check_scrolled()
caret_tester.check() caret_tester.check()
@pytest.mark.parametrize('style', ['visibility: hidden', 'display: none'])
def test_invisible(caret_tester, style):
"""Test with hidden text elements."""
caret_tester.js.load('position_caret/invisible.html', style=style)
caret_tester.check()