Add test for wrap footer setting

This commit is contained in:
Stewart Becker 2014-07-21 18:13:20 +01:00
parent 73ec92ae13
commit 2555bc50d4

View File

@ -6,10 +6,12 @@ from unittest import TestCase
from PyQt4 import QtCore
from openlp.core.common import Settings
from openlp.core.lib.htmlbuilder import build_html, build_background_css, build_lyrics_css, build_lyrics_outline_css, \
build_lyrics_format_css, build_footer_css
from openlp.core.lib.theme import HorizontalType, VerticalType
from tests.functional import MagicMock, patch
from tests.helpers.testmixin import TestMixin
HTML = """
@ -184,7 +186,7 @@ LYRICS_OUTLINE_CSS = ' -webkit-text-stroke: 0.125em #000000; -webkit-text-fill-c
LYRICS_FORMAT_CSS = ' 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; '
FOOTER_CSS = """
FOOTER_CSS_BASE = """
left: 10px;
bottom: 0px;
width: 1260px;
@ -192,11 +194,29 @@ FOOTER_CSS = """
font-size: 12pt;
color: #FFFFFF;
text-align: left;
white-space: nowrap;
white-space: %s;
"""
FOOTER_CSS = FOOTER_CSS_BASE % ('nowrap')
FOOTER_CSS_WRAP = FOOTER_CSS_BASE % ('normal')
class Htmbuilder(TestCase, TestMixin):
"""
Test the functions in the Htmlbuilder module
"""
def setUp(self):
"""
Create the UI
"""
self.build_settings()
def tearDown(self):
"""
Delete all the C++ objects at the end so that we don't have a segfault
"""
self.destroy_settings()
class Htmbuilder(TestCase):
def build_html_test(self):
"""
Test the build_html() function
@ -316,8 +336,15 @@ class Htmbuilder(TestCase):
item.theme_data.font_footer_color = '#FFFFFF'
height = 1024
# WHEN: create the css.
# WHEN: create the css with default settings.
css = build_footer_css(item, height)
# THEN: THE css should be the same.
assert FOOTER_CSS == css, 'The footer strings should be equal.'
# WHEN: Settings say that footer should wrap
Settings().setValue('themes/wrap footer', True)
css = build_footer_css(item, height)
# THEN: Footer should wrap
assert FOOTER_CSS_WRAP == css, 'The footer strings should be equal.'