2013-09-08 10:30:14 +00:00
|
|
|
"""
|
|
|
|
Package to test the openlp.core.lib.htmlbuilder module.
|
|
|
|
"""
|
|
|
|
from unittest import TestCase
|
2017-04-24 05:17:55 +00:00
|
|
|
from unittest.mock import MagicMock, patch
|
2013-09-08 10:30:14 +00:00
|
|
|
|
2016-01-03 11:47:07 +00:00
|
|
|
from PyQt5 import QtCore, QtWebKit
|
2013-09-08 10:30:14 +00:00
|
|
|
|
2017-10-07 07:05:07 +00:00
|
|
|
from openlp.core.common.settings import Settings
|
2013-09-11 13:30:23 +00:00
|
|
|
from openlp.core.lib.htmlbuilder import build_html, build_background_css, build_lyrics_css, build_lyrics_outline_css, \
|
2016-07-26 19:02:35 +00:00
|
|
|
build_lyrics_format_css, build_footer_css, webkit_version, build_chords_css
|
2013-09-11 14:22:28 +00:00
|
|
|
from openlp.core.lib.theme import HorizontalType, VerticalType
|
2014-07-21 17:13:20 +00:00
|
|
|
from tests.helpers.testmixin import TestMixin
|
2013-09-08 10:30:14 +00:00
|
|
|
|
2018-07-04 20:42:55 +00:00
|
|
|
HTML = r"""
|
2016-06-07 13:12:22 +00:00
|
|
|
<!DOCTYPE html>
|
|
|
|
<html>
|
|
|
|
<head>
|
|
|
|
<title>OpenLP Display</title>
|
|
|
|
<style>
|
|
|
|
*{
|
|
|
|
margin: 0;
|
|
|
|
padding: 0;
|
|
|
|
border: 0;
|
|
|
|
overflow: hidden;
|
|
|
|
-webkit-user-select: none;
|
|
|
|
}
|
|
|
|
body {
|
|
|
|
;
|
|
|
|
}
|
|
|
|
.size {
|
|
|
|
position: absolute;
|
|
|
|
left: 0px;
|
|
|
|
top: 0px;
|
|
|
|
width: 100%;
|
|
|
|
height: 100%;
|
|
|
|
}
|
|
|
|
#black {
|
|
|
|
z-index: 8;
|
|
|
|
background-color: black;
|
|
|
|
display: none;
|
|
|
|
}
|
|
|
|
#bgimage {
|
|
|
|
z-index: 1;
|
|
|
|
}
|
|
|
|
#image {
|
|
|
|
z-index: 2;
|
|
|
|
}
|
|
|
|
plugin CSS
|
|
|
|
#footer {
|
|
|
|
position: absolute;
|
|
|
|
z-index: 6;
|
|
|
|
dummy: dummy;
|
|
|
|
}
|
|
|
|
/* lyric css */
|
|
|
|
sup {
|
|
|
|
font-size: 0.6em;
|
|
|
|
vertical-align: top;
|
|
|
|
position: relative;
|
|
|
|
top: -0.3em;
|
|
|
|
}
|
2016-07-26 19:02:35 +00:00
|
|
|
/* Chords css */
|
|
|
|
.chordline {
|
|
|
|
line-height: 1.0em;
|
|
|
|
}
|
|
|
|
.chordline span.chord span {
|
|
|
|
position: relative;
|
|
|
|
}
|
|
|
|
.chordline span.chord span strong {
|
|
|
|
position: absolute;
|
|
|
|
top: -0.8em;
|
|
|
|
left: 0;
|
|
|
|
font-size: 75%;
|
|
|
|
font-weight: normal;
|
|
|
|
line-height: normal;
|
|
|
|
display: none;
|
|
|
|
}
|
|
|
|
.firstchordline {
|
|
|
|
line-height: 1.0em;
|
|
|
|
}
|
2017-02-21 05:17:21 +00:00
|
|
|
.ws {
|
|
|
|
display: none;
|
|
|
|
white-space: pre-wrap;
|
|
|
|
}
|
2016-06-07 13:12:22 +00:00
|
|
|
</style>
|
|
|
|
<script>
|
|
|
|
var timer = null;
|
|
|
|
var transition = false;
|
|
|
|
plugin JS
|
2013-09-11 13:30:23 +00:00
|
|
|
|
2016-06-07 13:12:22 +00:00
|
|
|
function show_image(src){
|
|
|
|
var img = document.getElementById('image');
|
|
|
|
img.src = src;
|
|
|
|
if(src == '')
|
|
|
|
img.style.display = 'none';
|
|
|
|
else
|
|
|
|
img.style.display = 'block';
|
|
|
|
}
|
2013-09-11 13:30:23 +00:00
|
|
|
|
2016-06-07 13:12:22 +00:00
|
|
|
function show_blank(state){
|
|
|
|
var black = 'none';
|
|
|
|
var lyrics = '';
|
|
|
|
switch(state){
|
|
|
|
case 'theme':
|
|
|
|
lyrics = 'hidden';
|
|
|
|
break;
|
|
|
|
case 'black':
|
|
|
|
black = 'block';
|
|
|
|
break;
|
|
|
|
case 'desktop':
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
document.getElementById('black').style.display = black;
|
|
|
|
document.getElementById('lyricsmain').style.visibility = lyrics;
|
|
|
|
document.getElementById('image').style.visibility = lyrics;
|
|
|
|
document.getElementById('footer').style.visibility = lyrics;
|
|
|
|
}
|
2013-09-11 13:30:23 +00:00
|
|
|
|
2016-06-07 13:12:22 +00:00
|
|
|
function show_footer(footertext){
|
|
|
|
document.getElementById('footer').innerHTML = footertext;
|
2013-09-11 13:30:23 +00:00
|
|
|
}
|
|
|
|
|
2016-06-07 13:12:22 +00:00
|
|
|
function show_text(new_text){
|
2018-07-05 19:18:16 +00:00
|
|
|
var match = /-webkit-text-fill-color:[^;\"]+/gi;
|
2016-06-07 13:12:22 +00:00
|
|
|
if(timer != null)
|
|
|
|
clearTimeout(timer);
|
|
|
|
/*
|
|
|
|
QtWebkit bug with outlines and justify causing outline alignment
|
|
|
|
problems. (Bug 859950) Surround each word with a <span> to workaround,
|
|
|
|
but only in this scenario.
|
|
|
|
*/
|
|
|
|
var txt = document.getElementById('lyricsmain');
|
|
|
|
if(window.getComputedStyle(txt).textAlign == 'justify'){
|
|
|
|
if(window.getComputedStyle(txt).webkitTextStrokeWidth != '0px'){
|
|
|
|
new_text = new_text.replace(/(\s| )+(?![^<]*>)/g,
|
|
|
|
function(match) {
|
|
|
|
return '</span>' + match + '<span>';
|
|
|
|
});
|
|
|
|
new_text = '<span>' + new_text + '</span>';
|
|
|
|
}
|
|
|
|
}
|
|
|
|
text_fade('lyricsmain', new_text);
|
|
|
|
}
|
2013-09-11 13:30:23 +00:00
|
|
|
|
2016-06-07 13:12:22 +00:00
|
|
|
function text_fade(id, new_text){
|
|
|
|
/*
|
|
|
|
Show the text.
|
|
|
|
*/
|
|
|
|
var text = document.getElementById(id);
|
|
|
|
if(text == null) return;
|
|
|
|
if(!transition){
|
|
|
|
text.innerHTML = new_text;
|
|
|
|
return;
|
2013-09-11 13:30:23 +00:00
|
|
|
}
|
2016-06-07 13:12:22 +00:00
|
|
|
// Fade text out. 0.1 to minimize the time "nothing" is shown on the screen.
|
|
|
|
text.style.opacity = '0.1';
|
|
|
|
// Fade new text in after the old text has finished fading out.
|
|
|
|
timer = window.setTimeout(function(){_show_text(text, new_text)}, 400);
|
2013-09-11 13:30:23 +00:00
|
|
|
}
|
|
|
|
|
2016-06-07 13:12:22 +00:00
|
|
|
function _show_text(text, new_text) {
|
|
|
|
/*
|
|
|
|
Helper function to show the new_text delayed.
|
|
|
|
*/
|
2013-09-11 13:30:23 +00:00
|
|
|
text.innerHTML = new_text;
|
2016-06-07 13:12:22 +00:00
|
|
|
text.style.opacity = '1';
|
|
|
|
// Wait until the text is completely visible. We want to save the timer id, to be able to call
|
|
|
|
// clearTimeout(timer) when the text has changed before finishing fading.
|
|
|
|
timer = window.setTimeout(function(){timer = null;}, 400);
|
2013-09-11 13:30:23 +00:00
|
|
|
}
|
|
|
|
|
2016-06-07 13:12:22 +00:00
|
|
|
function show_text_completed(){
|
|
|
|
return (timer == null);
|
|
|
|
}
|
|
|
|
</script>
|
|
|
|
</head>
|
|
|
|
<body>
|
|
|
|
<img id="bgimage" class="size" style="display:none;" />
|
|
|
|
<img id="image" class="size" style="display:none;" />
|
|
|
|
plugin HTML
|
|
|
|
<div class="lyricstable"><div id="lyricsmain" style="opacity:1" class="lyricscell lyricsmain"></div></div>
|
|
|
|
<div id="footer" class="footer"></div>
|
|
|
|
<div id="black" class="size"></div>
|
|
|
|
</body>
|
|
|
|
</html>
|
|
|
|
"""
|
2013-09-11 14:02:17 +00:00
|
|
|
BACKGROUND_CSS_RADIAL = 'background: -webkit-gradient(radial, 5 50%, 100, 5 50%, 5, from(#000000), to(#FFFFFF)) fixed'
|
2013-09-11 13:51:49 +00:00
|
|
|
LYRICS_CSS = """
|
2016-06-07 13:12:22 +00:00
|
|
|
.lyricstable {
|
|
|
|
z-index: 5;
|
|
|
|
position: absolute;
|
|
|
|
display: table;
|
|
|
|
left: 10px; top: 20px;
|
|
|
|
}
|
|
|
|
.lyricscell {
|
|
|
|
display: table-cell;
|
|
|
|
word-wrap: break-word;
|
|
|
|
-webkit-transition: opacity 0.4s ease;
|
|
|
|
lyrics_format_css
|
|
|
|
}
|
|
|
|
.lyricsmain {
|
|
|
|
text-shadow: #000000 5px 5px;
|
|
|
|
}
|
|
|
|
"""
|
2013-09-11 13:30:23 +00:00
|
|
|
LYRICS_OUTLINE_CSS = ' -webkit-text-stroke: 0.125em #000000; -webkit-text-fill-color: #FFFFFF; '
|
2016-06-06 15:16:09 +00:00
|
|
|
LYRICS_FORMAT_CSS = """
|
2016-06-07 13:12:22 +00:00
|
|
|
word-wrap: break-word;
|
|
|
|
text-align: justify;
|
|
|
|
vertical-align: bottom;
|
|
|
|
font-family: Arial;
|
|
|
|
font-size: 40pt;
|
|
|
|
color: #FFFFFF;
|
|
|
|
line-height: 108%;
|
|
|
|
margin: 0;
|
|
|
|
padding: 0;
|
|
|
|
padding-bottom: 0.5em;
|
|
|
|
padding-left: 2px;
|
|
|
|
width: 1580px;
|
|
|
|
height: 810px;
|
|
|
|
font-style: italic;
|
|
|
|
font-weight: bold;
|
|
|
|
"""
|
2014-07-21 17:13:20 +00:00
|
|
|
FOOTER_CSS_BASE = """
|
2016-06-07 13:12:22 +00:00
|
|
|
left: 10px;
|
|
|
|
bottom: 0px;
|
|
|
|
width: 1260px;
|
|
|
|
font-family: Arial;
|
|
|
|
font-size: 12pt;
|
|
|
|
color: #FFFFFF;
|
|
|
|
text-align: left;
|
|
|
|
white-space: %s;
|
|
|
|
"""
|
2014-07-21 17:13:20 +00:00
|
|
|
FOOTER_CSS = FOOTER_CSS_BASE % ('nowrap')
|
|
|
|
FOOTER_CSS_WRAP = FOOTER_CSS_BASE % ('normal')
|
2016-04-26 02:43:29 +00:00
|
|
|
FOOTER_CSS_INVALID = ''
|
2016-07-26 19:02:35 +00:00
|
|
|
CHORD_CSS_ENABLED = """
|
|
|
|
.chordline {
|
|
|
|
line-height: 2.0em;
|
|
|
|
}
|
|
|
|
.chordline span.chord span {
|
|
|
|
position: relative;
|
|
|
|
}
|
|
|
|
.chordline span.chord span strong {
|
|
|
|
position: absolute;
|
|
|
|
top: -0.8em;
|
|
|
|
left: 0;
|
|
|
|
font-size: 75%;
|
|
|
|
font-weight: normal;
|
|
|
|
line-height: normal;
|
|
|
|
display: inline;
|
|
|
|
}
|
|
|
|
.firstchordline {
|
|
|
|
line-height: 2.1em;
|
2017-02-20 21:43:18 +00:00
|
|
|
}
|
|
|
|
.ws {
|
|
|
|
display: inline;
|
|
|
|
white-space: pre-wrap;
|
2016-07-26 19:02:35 +00:00
|
|
|
}"""
|
|
|
|
|
|
|
|
__default_settings__ = {
|
|
|
|
'songs/mainview chords': False,
|
2017-02-26 21:14:49 +00:00
|
|
|
'songs/enable chords': True
|
2016-07-26 19:02:35 +00:00
|
|
|
}
|
2014-07-21 17:13:20 +00:00
|
|
|
|
|
|
|
|
|
|
|
class Htmbuilder(TestCase, TestMixin):
|
|
|
|
"""
|
|
|
|
Test the functions in the Htmlbuilder module
|
|
|
|
"""
|
|
|
|
def setUp(self):
|
|
|
|
"""
|
|
|
|
Create the UI
|
|
|
|
"""
|
|
|
|
self.build_settings()
|
2016-07-26 19:02:35 +00:00
|
|
|
Settings().extend_default_settings(__default_settings__)
|
2014-07-21 17:13:20 +00:00
|
|
|
|
|
|
|
def tearDown(self):
|
|
|
|
"""
|
|
|
|
Delete all the C++ objects at the end so that we don't have a segfault
|
|
|
|
"""
|
|
|
|
self.destroy_settings()
|
2013-09-11 13:30:23 +00:00
|
|
|
|
2016-05-31 21:40:13 +00:00
|
|
|
def test_build_html(self):
|
2013-09-11 13:30:23 +00:00
|
|
|
"""
|
|
|
|
Test the build_html() function
|
|
|
|
"""
|
|
|
|
# GIVEN: Mocked arguments and function.
|
|
|
|
with patch('openlp.core.lib.htmlbuilder.build_background_css') as mocked_build_background_css, \
|
|
|
|
patch('openlp.core.lib.htmlbuilder.build_footer_css') as mocked_build_footer_css, \
|
|
|
|
patch('openlp.core.lib.htmlbuilder.build_lyrics_css') as mocked_build_lyrics_css:
|
|
|
|
# Mocked function.
|
|
|
|
mocked_build_background_css.return_value = ''
|
|
|
|
mocked_build_footer_css.return_value = 'dummy: dummy;'
|
|
|
|
mocked_build_lyrics_css.return_value = ''
|
|
|
|
# Mocked arguments.
|
|
|
|
item = MagicMock()
|
|
|
|
item.bg_image_bytes = None
|
|
|
|
screen = MagicMock()
|
|
|
|
is_live = False
|
|
|
|
background = None
|
|
|
|
plugin = MagicMock()
|
2013-10-21 07:38:18 +00:00
|
|
|
plugin.get_display_css.return_value = 'plugin CSS'
|
|
|
|
plugin.get_display_javascript.return_value = 'plugin JS'
|
|
|
|
plugin.get_display_html.return_value = 'plugin HTML'
|
2013-09-11 13:30:23 +00:00
|
|
|
plugins = [plugin]
|
|
|
|
|
|
|
|
# WHEN: Create the html.
|
|
|
|
html = build_html(item, screen, is_live, background, plugins=plugins)
|
2013-09-08 10:30:14 +00:00
|
|
|
|
2013-09-11 13:30:23 +00:00
|
|
|
# THEN: The returned html should match.
|
2017-12-17 15:35:35 +00:00
|
|
|
assert html == HTML, 'The returned html should match'
|
2013-09-11 13:30:23 +00:00
|
|
|
|
2016-05-31 21:40:13 +00:00
|
|
|
def test_build_background_css_radial(self):
|
2013-09-11 13:30:23 +00:00
|
|
|
"""
|
2013-09-11 14:02:17 +00:00
|
|
|
Test the build_background_css() function with a radial background
|
2013-09-11 13:30:23 +00:00
|
|
|
"""
|
2013-09-11 14:02:17 +00:00
|
|
|
# GIVEN: Mocked arguments.
|
|
|
|
item = MagicMock()
|
2013-12-26 08:56:53 +00:00
|
|
|
item.theme_data.background_start_color = '#000000'
|
|
|
|
item.theme_data.background_end_color = '#FFFFFF'
|
2013-09-11 14:02:17 +00:00
|
|
|
width = 10
|
|
|
|
|
|
|
|
# WHEN: Create the css.
|
|
|
|
css = build_background_css(item, width)
|
|
|
|
|
|
|
|
# THEN: The returned css should match.
|
2017-12-17 15:35:35 +00:00
|
|
|
assert BACKGROUND_CSS_RADIAL == css, 'The background css should be equal.'
|
2013-09-08 10:30:14 +00:00
|
|
|
|
2016-05-31 21:40:13 +00:00
|
|
|
def test_build_lyrics_css(self):
|
2013-09-08 10:30:14 +00:00
|
|
|
"""
|
2013-09-11 13:30:23 +00:00
|
|
|
Test the build_lyrics_css() function
|
2013-09-08 10:30:14 +00:00
|
|
|
"""
|
2013-09-11 13:51:49 +00:00
|
|
|
# GIVEN: Mocked method and arguments.
|
|
|
|
with patch('openlp.core.lib.htmlbuilder.build_lyrics_format_css') as mocked_build_lyrics_format_css, \
|
|
|
|
patch('openlp.core.lib.htmlbuilder.build_lyrics_outline_css') as mocked_build_lyrics_outline_css:
|
|
|
|
mocked_build_lyrics_format_css.return_value = 'lyrics_format_css'
|
|
|
|
mocked_build_lyrics_outline_css.return_value = ''
|
2013-09-11 13:00:34 +00:00
|
|
|
item = MagicMock()
|
2013-09-11 13:51:49 +00:00
|
|
|
item.main = QtCore.QRect(10, 20, 10, 20)
|
2013-12-26 08:56:53 +00:00
|
|
|
item.theme_data.font_main_shadow = True
|
|
|
|
item.theme_data.font_main_shadow_color = '#000000'
|
|
|
|
item.theme_data.font_main_shadow_size = 5
|
2013-09-11 13:51:49 +00:00
|
|
|
|
|
|
|
# WHEN: Create the css.
|
|
|
|
css = build_lyrics_css(item)
|
2013-09-11 13:30:23 +00:00
|
|
|
|
2013-09-11 13:51:49 +00:00
|
|
|
# THEN: The css should be equal.
|
2017-12-17 15:35:35 +00:00
|
|
|
assert LYRICS_CSS == css, 'The lyrics css should be equal.'
|
2013-09-08 10:30:14 +00:00
|
|
|
|
2016-05-31 21:40:13 +00:00
|
|
|
def test_build_lyrics_outline_css(self):
|
2013-09-08 10:30:14 +00:00
|
|
|
"""
|
|
|
|
Test the build_lyrics_outline_css() function
|
|
|
|
"""
|
2013-09-11 13:30:23 +00:00
|
|
|
# GIVEN: The mocked theme data.
|
2013-09-08 10:30:14 +00:00
|
|
|
theme_data = MagicMock()
|
|
|
|
theme_data.font_main_outline = True
|
|
|
|
theme_data.font_main_outline_size = 2
|
|
|
|
theme_data.font_main_color = '#FFFFFF'
|
|
|
|
theme_data.font_main_outline_color = '#000000'
|
|
|
|
|
2013-09-11 13:30:23 +00:00
|
|
|
# WHEN: Create the css.
|
|
|
|
css = build_lyrics_outline_css(theme_data)
|
2013-09-08 10:30:14 +00:00
|
|
|
|
2013-09-11 13:30:23 +00:00
|
|
|
# THEN: The css should be equal.
|
2017-12-17 15:35:35 +00:00
|
|
|
assert LYRICS_OUTLINE_CSS == css, 'The outline css should be equal.'
|
2013-09-11 13:30:23 +00:00
|
|
|
|
2016-05-31 21:40:13 +00:00
|
|
|
def test_build_lyrics_format_css(self):
|
2013-09-08 10:30:14 +00:00
|
|
|
"""
|
|
|
|
Test the build_lyrics_format_css() function
|
|
|
|
"""
|
2013-09-11 14:22:28 +00:00
|
|
|
# GIVEN: Mocked arguments.
|
|
|
|
theme_data = MagicMock()
|
|
|
|
theme_data.display_horizontal_align = HorizontalType.Justify
|
|
|
|
theme_data.display_vertical_align = VerticalType.Bottom
|
|
|
|
theme_data.font_main_name = 'Arial'
|
|
|
|
theme_data.font_main_size = 40
|
|
|
|
theme_data.font_main_color = '#FFFFFF'
|
|
|
|
theme_data.font_main_italics = True
|
|
|
|
theme_data.font_main_bold = True
|
|
|
|
theme_data.font_main_line_adjustment = 8
|
|
|
|
width = 1580
|
|
|
|
height = 810
|
|
|
|
|
|
|
|
# WHEN: Get the css.
|
|
|
|
css = build_lyrics_format_css(theme_data, width, height)
|
|
|
|
|
|
|
|
# THEN: They should be equal.
|
2017-12-17 15:35:35 +00:00
|
|
|
assert LYRICS_FORMAT_CSS == css, 'The lyrics format css should be equal.'
|
2013-09-08 10:30:14 +00:00
|
|
|
|
2016-05-31 21:40:13 +00:00
|
|
|
def test_build_footer_css(self):
|
2013-12-26 08:56:53 +00:00
|
|
|
"""
|
|
|
|
Test the build_footer_css() function
|
|
|
|
"""
|
|
|
|
# GIVEN: Create a theme.
|
|
|
|
item = MagicMock()
|
|
|
|
item.footer = QtCore.QRect(10, 921, 1260, 103)
|
|
|
|
item.theme_data.font_footer_name = 'Arial'
|
|
|
|
item.theme_data.font_footer_size = 12
|
|
|
|
item.theme_data.font_footer_color = '#FFFFFF'
|
|
|
|
height = 1024
|
|
|
|
|
2014-07-21 17:13:20 +00:00
|
|
|
# WHEN: create the css with default settings.
|
2013-12-26 08:56:53 +00:00
|
|
|
css = build_footer_css(item, height)
|
|
|
|
|
|
|
|
# THEN: THE css should be the same.
|
2017-12-17 15:35:35 +00:00
|
|
|
assert FOOTER_CSS == css, 'The footer strings should be equal.'
|
2014-07-21 17:13:20 +00:00
|
|
|
|
2016-05-31 21:40:13 +00:00
|
|
|
def test_build_footer_css_wrap(self):
|
2014-07-22 20:06:48 +00:00
|
|
|
"""
|
|
|
|
Test the build_footer_css() function
|
|
|
|
"""
|
|
|
|
# GIVEN: Create a theme.
|
|
|
|
item = MagicMock()
|
|
|
|
item.footer = QtCore.QRect(10, 921, 1260, 103)
|
|
|
|
item.theme_data.font_footer_name = 'Arial'
|
|
|
|
item.theme_data.font_footer_size = 12
|
|
|
|
item.theme_data.font_footer_color = '#FFFFFF'
|
|
|
|
height = 1024
|
|
|
|
|
2014-07-21 17:13:20 +00:00
|
|
|
# WHEN: Settings say that footer should wrap
|
|
|
|
Settings().setValue('themes/wrap footer', True)
|
|
|
|
css = build_footer_css(item, height)
|
|
|
|
|
|
|
|
# THEN: Footer should wrap
|
2017-12-17 15:35:35 +00:00
|
|
|
assert FOOTER_CSS_WRAP == css, 'The footer strings should be equal.'
|
2016-01-03 11:47:07 +00:00
|
|
|
|
2016-05-31 21:40:13 +00:00
|
|
|
def test_build_footer_invalid(self):
|
2016-04-26 02:43:29 +00:00
|
|
|
"""
|
|
|
|
Test the build_footer_css() function
|
|
|
|
"""
|
|
|
|
# GIVEN: Create a theme.
|
|
|
|
css = []
|
|
|
|
item = MagicMock()
|
|
|
|
item.theme_data = None
|
|
|
|
item.footer = 'FAIL'
|
2016-04-26 02:47:38 +00:00
|
|
|
height = 1024
|
2016-04-26 02:43:29 +00:00
|
|
|
|
|
|
|
# WHEN: Settings say that footer should wrap
|
|
|
|
css.append(build_footer_css(item, height))
|
|
|
|
item.theme_data = 'TEST'
|
|
|
|
item.footer = None
|
|
|
|
css.append(build_footer_css(item, height))
|
|
|
|
|
|
|
|
# THEN: Footer should wrap
|
2017-12-17 15:35:35 +00:00
|
|
|
assert FOOTER_CSS_INVALID == css[0], 'The footer strings should be blank.'
|
|
|
|
assert FOOTER_CSS_INVALID == css[1], 'The footer strings should be blank.'
|
2016-04-26 02:43:29 +00:00
|
|
|
|
2016-05-31 21:40:13 +00:00
|
|
|
def test_webkit_version(self):
|
2016-01-03 11:47:07 +00:00
|
|
|
"""
|
|
|
|
Test the webkit_version() function
|
|
|
|
"""
|
2016-01-13 21:00:46 +00:00
|
|
|
# GIVEN: Webkit
|
2016-01-03 11:47:07 +00:00
|
|
|
webkit_ver = float(QtWebKit.qWebKitVersion())
|
|
|
|
# WHEN: Retrieving the webkit version
|
|
|
|
# THEN: Webkit versions should match
|
2017-12-17 15:35:35 +00:00
|
|
|
assert webkit_version() == webkit_ver, "The returned webkit version doesn't match the installed one"
|
2016-07-26 19:02:35 +00:00
|
|
|
|
|
|
|
def test_build_chords_css(self):
|
|
|
|
"""
|
|
|
|
Test the build_chords_css() function
|
|
|
|
"""
|
|
|
|
# GIVEN: A setting that activates chords on the mainview
|
2017-02-26 21:14:49 +00:00
|
|
|
Settings().setValue('songs/enable chords', True)
|
2016-07-26 19:02:35 +00:00
|
|
|
Settings().setValue('songs/mainview chords', True)
|
|
|
|
|
|
|
|
# WHEN: Building the chord CSS
|
|
|
|
chord_css = build_chords_css()
|
|
|
|
|
|
|
|
# THEN: The build css should look as expected
|
2017-12-17 15:35:35 +00:00
|
|
|
assert CHORD_CSS_ENABLED == chord_css, 'The chord CSS should look as expected'
|