Add tests which override existing css

This commit is contained in:
Jay Kamat 2017-11-08 12:59:59 -05:00
parent e7fdff5632
commit 9a1d10ca11
No known key found for this signature in database
GPG Key ID: 5D2E399600F4F7B5
2 changed files with 25 additions and 10 deletions

View File

@ -0,0 +1,9 @@
{% extends "base.html" %}
{% block style %}
body {
background-color: rgb(255, 0, 0);
}
{% endblock %}
{% block content %}
<p>Hello World!</p>
{% endblock %}

View File

@ -65,17 +65,23 @@ def stylesheet_tester(js_tester_webengine):
ss_tester.js.webview.show()
return ss_tester
def test_no_set_stylesheet(stylesheet_tester):
stylesheet_tester.js.load('stylesheet/simple.html')
stylesheet_tester.init_stylesheet()
stylesheet_tester.check_set("background-color", DEFAULT_BODY_BG)
@pytest.mark.parametrize('init', [False, True])
@pytest.mark.parametrize('page,expected', [('stylesheet/simple.html', DEFAULT_BODY_BG),
('stylesheet/simple_bg_set_red.html', "rgb(255, 0, 0)")])
def test_no_set_stylesheet(stylesheet_tester, init, page, expected):
stylesheet_tester.js.load(page)
if init:
stylesheet_tester.init_stylesheet()
stylesheet_tester.check_set("background-color", expected)
def test_no_set_stylesheet_no_load(stylesheet_tester):
stylesheet_tester.js.load('stylesheet/simple.html')
stylesheet_tester.check_set("background-color", DEFAULT_BODY_BG)
def test_simple_set_bg(stylesheet_tester):
stylesheet_tester.js.load('stylesheet/simple.html')
@pytest.mark.parametrize('page', ['stylesheet/simple.html',
'stylesheet/simple_bg_set_red.html'])
@pytest.mark.parametrize('set_js', [True, False])
def test_simple_set_bg(stylesheet_tester, page, set_js):
stylesheet_tester.js.load(page)
if set_js:
stylesheet_tester.js.run('document.body.style.backgroundColor = "red";', 'red')
pytest.xfail("overring values set with js does not work.")
stylesheet_tester.init_stylesheet()
stylesheet_tester.set_css("body {background-color: rgb(10, 10, 10);}")
stylesheet_tester.check_set("background-color", "rgb(10, 10, 10)")