Skip to content
This repository has been archived by the owner on May 28, 2022. It is now read-only.

Commit

Permalink
Add unit test for click_add_tak
Browse files Browse the repository at this point in the history
  • Loading branch information
benbuckley committed Nov 26, 2014
1 parent 85001ca commit 5111b38
Show file tree
Hide file tree
Showing 2 changed files with 53 additions and 19 deletions.
36 changes: 18 additions & 18 deletions src/freeseer/frontend/talkeditor/TalkDetailsWidget.py
Original file line number Diff line number Diff line change
Expand Up @@ -112,37 +112,37 @@ def __init__(self, parent=None):
self.layout.addWidget(self.descriptionLabel, 5, 0, 1, 1)
self.layout.addWidget(self.descriptionTextEdit, 5, 1, 1, 3)

def toggle_input_fields(self, enable):
allFields = [self.titleLineEdit, self.presenterLineEdit, self.categoryLineEdit,
self.eventLineEdit, self.roomLineEdit, self.dateEdit, self.startTimeEdit,
self.endTimeEdit, self.descriptionTextEdit]
for field in allFields:
field.setEnabled(enable)

def input_fields_enabled(self):
allFields = [self.titleLineEdit, self.presenterLineEdit, self.categoryLineEdit,
self.eventLineEdit, self.roomLineEdit, self.dateEdit, self.startTimeEdit,
self.endTimeEdit, self.descriptionTextEdit]
for field in allFields:
if not field.isEnabled():
return False
return True

def enable_input_fields(self):
self.titleLineEdit.setPlaceholderText("Enter Talk Title")
self.presenterLineEdit.setPlaceholderText("Enter Presenter Name")
self.categoryLineEdit.setPlaceholderText("Enter Category Type")
self.eventLineEdit.setPlaceholderText("Enter Event Name")
self.roomLineEdit.setPlaceholderText("Enter Room Location")
self.titleLineEdit.setEnabled(True)
self.presenterLineEdit.setEnabled(True)
self.categoryLineEdit.setEnabled(True)
self.eventLineEdit.setEnabled(True)
self.roomLineEdit.setEnabled(True)
self.dateEdit.setEnabled(True)
self.startTimeEdit.setEnabled(True)
self.endTimeEdit.setEnabled(True)
self.descriptionTextEdit.setEnabled(True)
self.toggle_input_fields(True)

def disable_input_fields(self):
self.titleLineEdit.setPlaceholderText("")
self.presenterLineEdit.setPlaceholderText("")
self.categoryLineEdit.setPlaceholderText("")
self.eventLineEdit.setPlaceholderText("")
self.roomLineEdit.setPlaceholderText("")
self.titleLineEdit.setEnabled(False)
self.presenterLineEdit.setEnabled(False)
self.categoryLineEdit.setEnabled(False)
self.eventLineEdit.setEnabled(False)
self.roomLineEdit.setEnabled(False)
self.dateEdit.setEnabled(False)
self.startTimeEdit.setEnabled(False)
self.endTimeEdit.setEnabled(False)
self.descriptionTextEdit.setEnabled(False)
self.toggle_input_fields(False)

if __name__ == "__main__":
import sys
Expand Down
36 changes: 35 additions & 1 deletion src/freeseer/tests/frontend/talkeditor/test_talkeditor.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,15 @@
import unittest

from PyQt4 import QtGui
from PyQt4.QtCore import QPoint
from PyQt4.QtCore import Qt
#from PyQt4.QtCore import QTimer
#from PyQt4.QtCore import SLOT
#from PyQt4.QtGui import QApplication
from PyQt4.QtTest import QTest

from freeseer.framework.config.profile import ProfileManager
from freeseer.framework.presentation import Presentation
from freeseer.frontend.talkeditor.talkeditor import TalkEditorApp
from freeseer import settings

Expand All @@ -46,6 +48,12 @@ class TestTalkEditorApp(unittest.TestCase):
'''

@classmethod
def setUpClass(cls):
cls.presentations = []
cls.presentations.append(Presentation("test title 1", "test speaker", "test room", "test event",))
cls.presentations.append(Presentation("test title 2", "test speaker", "test room", "test event",))

def setUp(self):
'''
Stardard init method: runs before each test_* method
Expand All @@ -58,6 +66,8 @@ def setUp(self):
config = profile.get_config('freeseer.conf', settings.FreeseerConfig,
storage_args=['Global'], read_only=True)
db = profile.get_database()
for talk in self.presentations:
db.insert_presentation(talk)

self.app = QtGui.QApplication([])
self.talk_editor = TalkEditorApp(config, db)
Expand All @@ -70,6 +80,7 @@ def tearDown(self):
This method closes the TalkEditorApp by clicking the "close" button
'''
shutil.rmtree(self.profile_manager._base_folder)
#shutil.rmtree(self.profile_path)

del self.app
self.talk_editor.app.deleteLater()
Expand Down Expand Up @@ -142,13 +153,36 @@ def test_help_menu_about(self):
self.assertFalse(self.talk_editor.aboutDialog.isVisible())

def test_click_talk(self):
self.assertTrue(True)
# Make sure save prompt doesn't come up when no changes are made
xPos = self.talk_editor.tableView.columnViewportPosition(1)
yPos = self.talk_editor.tableView.rowViewportPosition(1)
QTest.mouseClick(self.talk_editor.tableView, Qt.LeftButton, Qt.NoModifier, QPoint(xPos, yPos))
self.assertFalse(self.talk_editor.savePromptWidgetTalk.isVisible())
# Make sure prompt DOES show up when changes ARE made
#QTest.mouseClick(self.talk_editor.talkDetailsWidget.titleLineEdit, Qt.LeftButton)
#QTest.keyClicks(self.talk_editor.talkDetailsWidget.titleLineEdit, "New Talk Title")
#QTest.qWait(1000)
#xPos = self.talk_editor.tableView.columnViewportPosition(0)
#yPos = self.talk_editor.tableView.rowViewportPosition(0)
#QTest.mouseClick(self.talk_editor.tableView, Qt.LeftButton, Qt.NoModifier, QPoint(xPos, yPos))
#self.assertTrue(self.talk_editor.savePromptWidgetTalk.isVisible())

def test_click_add_talk(self):
QTest.mouseClick(self.talk_editor.commandButtons.addButton, Qt.LeftButton)
self.assertTrue(self.talk_editor.newTalkWidget.isVisible())
QTest.mouseClick(self.talk_editor.newTalkWidget.cancelButton, Qt.LeftButton)
self.assertFalse(self.talk_editor.newTalkWidget.isVisible())
# Test actually adding a talk
QTest.mouseClick(self.talk_editor.commandButtons.addButton, Qt.LeftButton)
self.assertTrue(self.talk_editor.newTalkWidget.isVisible())
QTest.keyClicks(self.talk_editor.newTalkWidget.talkDetailsWidget.titleLineEdit, "New Talk Title")
QTest.mouseClick(self.talk_editor.newTalkWidget.addButton, Qt.LeftButton)
# Select the new talk and check if the title is the same
xPos = self.talk_editor.tableView.columnViewportPosition(1)
yPos = self.talk_editor.tableView.rowViewportPosition(3)
QTest.mouseClick(self.talk_editor.tableView, Qt.LeftButton, Qt.NoModifier, QPoint(xPos, yPos))
newTitle = self.talk_editor.talkDetailsWidget.titleLineEdit.text()
self.assertTrue(newTitle == "New Talk Title")

def test_show_save_prompt(self):
self.assertTrue(True)

0 comments on commit 5111b38

Please sign in to comment.