openlp/tests/functional/openlp_core_ui/test_slidecontroller.py

79 lines
3.9 KiB
Python
Raw Normal View History

2013-10-04 20:36:02 +00:00
# -*- coding: utf-8 -*-
# vim: autoindent shiftwidth=4 expandtab textwidth=120 tabstop=4 softtabstop=4
###############################################################################
# OpenLP - Open Source Lyrics Projection #
# --------------------------------------------------------------------------- #
2013-12-24 08:56:50 +00:00
# Copyright (c) 2008-2014 Raoul Snyman #
# Portions copyright (c) 2008-2014 Tim Bentley, Gerald Britton, Jonathan #
2013-10-04 20:36:02 +00:00
# Corwin, Samuel Findlay, Michael Gorven, Scott Guerrieri, Matthias Hub, #
# Meinert Jordan, Armin Köhler, Erik Lundin, Edwin Lunando, Brian T. Meyer. #
# Joshua Miller, Stevan Pettit, Andreas Preikschat, Mattias Põldaru, #
# Christian Richter, Philip Ridout, Simon Scudder, Jeffrey Smith, #
# Maikel Stuivenberg, Martin Thompson, Jon Tibble, Dave Warnock, #
# Frode Woldsund, Martin Zibricky, Patrick Zimmermann #
# --------------------------------------------------------------------------- #
# This program is free software; you can redistribute it and/or modify it #
# under the terms of the GNU General Public License as published by the Free #
# Software Foundation; version 2 of the License. #
# #
# This program is distributed in the hope that it will be useful, but WITHOUT #
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or #
# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for #
# more details. #
# #
# You should have received a copy of the GNU General Public License along #
# with this program; if not, write to the Free Software Foundation, Inc., 59 #
# Temple Place, Suite 330, Boston, MA 02111-1307 USA #
###############################################################################
2013-09-01 06:22:06 +00:00
"""
2014-01-04 11:50:27 +00:00
Package to test the openlp.core.ui.slidecontroller package.
2013-09-01 06:22:06 +00:00
"""
from unittest import TestCase
2014-01-04 11:50:27 +00:00
from openlp.core.ui import SlideController
2013-09-01 06:22:06 +00:00
2014-01-04 11:50:27 +00:00
from tests.interfaces import MagicMock, patch
2013-09-01 06:22:06 +00:00
2014-01-04 11:50:27 +00:00
class TestSlideController(TestCase):
2013-09-01 06:22:06 +00:00
2014-01-04 11:50:27 +00:00
def initial_slide_controller_test(self):
"""
Test the initial slide controller state .
"""
# GIVEN: A new slideController instance.
slide_controller = SlideController(None)
# WHEN: No SlideItem has been added yet.
# THEN: The count of items should be zero.
self.assertEqual(slide_controller.is_live, False, 'The base slide controller should not be a live controller')
2013-09-01 06:22:06 +00:00
2014-01-04 11:50:27 +00:00
def toggle_blank_test(self):
2013-09-01 06:22:06 +00:00
"""
2014-01-04 11:50:27 +00:00
Test the setting of the display blank icons by display type.
2013-09-01 06:22:06 +00:00
"""
2014-01-04 11:50:27 +00:00
# GIVEN: A new slideController instance.
slide_controller = SlideController(None)
service_item = MagicMock()
toolbar = MagicMock()
toolbar.set_widget_visible = self.dummy_widget_visible
slide_controller.toolbar = toolbar
slide_controller.service_item = service_item
# WHEN a text based service item is used
slide_controller.service_item.is_text = MagicMock(return_value=True)
slide_controller.set_blank_menu()
2013-09-01 06:22:06 +00:00
2014-01-04 11:50:27 +00:00
# THEN: then call set up the toolbar to blank the display screen.
self.assertEqual(len(self.test_widget), 3, 'There should be three icons to display on the screen')
2013-09-01 06:22:06 +00:00
2014-01-04 11:50:27 +00:00
# WHEN a non text based service item is used
slide_controller.service_item.is_text = MagicMock(return_value=False)
slide_controller.set_blank_menu()
2013-09-01 06:22:06 +00:00
2014-01-04 11:50:27 +00:00
# THEN: then call set up the toolbar to blank the display screen.
self.assertEqual(len(self.test_widget), 2, 'There should be only two icons to display on the screen')
2013-09-01 06:22:06 +00:00
2014-01-04 11:50:27 +00:00
def dummy_widget_visible(self, widget, visible=True):
self.test_widget = widget