~alisonken1/openlp/pjlink2-f

« back to all changes in this revision

Viewing changes to tests/functional/openlp_core_lib/test_htmlbuilder.py

  • Committer: Tim Bentley
  • Author(s): Tomas Groth
  • Date: 2017-05-17 20:30:47 UTC
  • mfrom: (2587.3.78 chords)
  • Revision ID: tim.bentley@gmail.com-20170517203047-o11dl9bfu3re2tu0
Added support for chords in Chord Pro format (using brackets), with support for chord transposing and 3 different notations.
Added support for import of song in ChordPro file format
Added support for importing chords and verseorder from songbeamer.
Add support for export and import of chords in openlyrics
Added support for importing chords from opensong.
Added support for importing chords from videopsalm.
Added support for printing chords.

Show diffs side-by-side

added added

removed removed

Lines of Context:
8
8
 
9
9
from openlp.core.common import Settings
10
10
from openlp.core.lib.htmlbuilder import build_html, build_background_css, build_lyrics_css, build_lyrics_outline_css, \
11
 
    build_lyrics_format_css, build_footer_css, webkit_version
 
11
    build_lyrics_format_css, build_footer_css, webkit_version, build_chords_css
12
12
from openlp.core.lib.theme import HorizontalType, VerticalType
13
13
 
14
14
from tests.helpers.testmixin import TestMixin
60
60
        position: relative;
61
61
        top: -0.3em;
62
62
    }
 
63
    /* Chords css */
 
64
    .chordline {
 
65
      line-height: 1.0em;
 
66
    }
 
67
    .chordline span.chord span {
 
68
      position: relative;
 
69
    }
 
70
    .chordline span.chord span strong {
 
71
      position: absolute;
 
72
      top: -0.8em;
 
73
      left: 0;
 
74
      font-size: 75%;
 
75
      font-weight: normal;
 
76
      line-height: normal;
 
77
      display: none;
 
78
    }
 
79
    .firstchordline {
 
80
        line-height: 1.0em;
 
81
    }
 
82
    .ws {
 
83
        display: none;
 
84
        white-space: pre-wrap;
 
85
    }
63
86
    </style>
64
87
    <script>
65
88
        var timer = null;
211
234
FOOTER_CSS = FOOTER_CSS_BASE % ('nowrap')
212
235
FOOTER_CSS_WRAP = FOOTER_CSS_BASE % ('normal')
213
236
FOOTER_CSS_INVALID = ''
 
237
CHORD_CSS_ENABLED = """
 
238
    .chordline {
 
239
      line-height: 2.0em;
 
240
    }
 
241
    .chordline span.chord span {
 
242
      position: relative;
 
243
    }
 
244
    .chordline span.chord span strong {
 
245
      position: absolute;
 
246
      top: -0.8em;
 
247
      left: 0;
 
248
      font-size: 75%;
 
249
      font-weight: normal;
 
250
      line-height: normal;
 
251
      display: inline;
 
252
    }
 
253
    .firstchordline {
 
254
        line-height: 2.1em;
 
255
    }
 
256
    .ws {
 
257
        display: inline;
 
258
        white-space: pre-wrap;
 
259
    }"""
 
260
 
 
261
__default_settings__ = {
 
262
    'songs/mainview chords': False,
 
263
    'songs/enable chords': True
 
264
}
214
265
 
215
266
 
216
267
class Htmbuilder(TestCase, TestMixin):
222
273
        Create the UI
223
274
        """
224
275
        self.build_settings()
 
276
        Settings().extend_default_settings(__default_settings__)
225
277
 
226
278
    def tearDown(self):
227
279
        """
403
455
        # WHEN: Retrieving the webkit version
404
456
        # THEN: Webkit versions should match
405
457
        self.assertEquals(webkit_version(), webkit_ver, "The returned webkit version doesn't match the installed one")
 
458
 
 
459
    def test_build_chords_css(self):
 
460
        """
 
461
        Test the build_chords_css() function
 
462
        """
 
463
        # GIVEN: A setting that activates chords on the mainview
 
464
        Settings().setValue('songs/enable chords', True)
 
465
        Settings().setValue('songs/mainview chords', True)
 
466
 
 
467
        # WHEN: Building the chord CSS
 
468
        chord_css = build_chords_css()
 
469
 
 
470
        # THEN: The build css should look as expected
 
471
        self.assertEqual(CHORD_CSS_ENABLED, chord_css, 'The chord CSS should look as expected')