Added another test or two.

This commit is contained in:
Raoul Snyman 2013-03-11 23:47:55 +02:00
parent 04acacddd6
commit 4ec065e804
2 changed files with 32 additions and 0 deletions

View File

@ -8,6 +8,7 @@ from openlp.core.lib import Registry
from openlp.core.ui import filerenameform from openlp.core.ui import filerenameform
from PyQt4 import QtGui, QtTest from PyQt4 import QtGui, QtTest
class TestStartFileRenameForm(TestCase): class TestStartFileRenameForm(TestCase):
def setUp(self): def setUp(self):

View File

@ -8,6 +8,11 @@ from PyQt4 import QtCore, QtGui, QtTest
from openlp.core.lib import Registry from openlp.core.lib import Registry
from openlp.plugins.songs.forms.editverseform import EditVerseForm from openlp.plugins.songs.forms.editverseform import EditVerseForm
VERSE_TEXT = u"""The Lord told Noah to build Him an arky arky,
Lord told Noah to build Him an arky arky,
Build it out of gopher barky barky,
Children of the Lord."""
class TestEditVerseForm(TestCase): class TestEditVerseForm(TestCase):
def setUp(self): def setUp(self):
@ -37,6 +42,18 @@ class TestEditVerseForm(TestCase):
# THEN: The default value is correct # THEN: The default value is correct
self.assertEqual(self.form.verse_text_edit.toPlainText(), u'', u'The verse edit box is empty.') self.assertEqual(self.form.verse_text_edit.toPlainText(), u'', u'The verse edit box is empty.')
def type_verse_text_tests(self):
"""
Test that typing into the verse text edit box returns the correct text
"""
# GIVEN: An instance of the EditVerseForm
# WHEN: Some verse text is typed into the text edit
QtTest.QTest.keyClicks(self.form.verse_text_edit, VERSE_TEXT)
# THEN: The verse text edit should have the verse text in it
self.assertEqual(VERSE_TEXT, self.form.verse_text_edit.toPlainText(),
u'The verse text edit should have the typed out verse')
def insert_verse_test(self): def insert_verse_test(self):
""" """
Test that clicking the insert button inserts the correct verse marker Test that clicking the insert button inserts the correct verse marker
@ -61,3 +78,17 @@ class TestEditVerseForm(TestCase):
# THEN: The verse text edit should have a Verse:1 in it # THEN: The verse text edit should have a Verse:1 in it
self.assertIn(u'---[Verse:2]---', self.form.verse_text_edit.toPlainText(), self.assertIn(u'---[Verse:2]---', self.form.verse_text_edit.toPlainText(),
u'The verse text edit should have a "Verse 2" marker') u'The verse text edit should have a "Verse 2" marker')
def insert_chorus_test(self):
"""
Test that clicking the verse type combo box and then clicking the insert button inserts the correct marker
"""
# GIVEN: An instance of the EditVerseForm
# WHEN: The verse type combo box and then the Insert button are clicked
QtTest.QTest.keyClick(self.form.verse_type_combo_box, QtCore.Qt.Key_Down)
QtTest.QTest.mouseClick(self.form.insert_button, QtCore.Qt.LeftButton)
# THEN: The verse text edit should have a Chorus:1 in it
self.assertIn(u'---[Chorus:1]---', self.form.verse_text_edit.toPlainText(),
u'The verse text edit should have a "Chorus 1" marker')