From aae831e90dbf416342ae087d93bf51f2ad1b4263 Mon Sep 17 00:00:00 2001 From: Tomas Groth Date: Fri, 26 Dec 2014 22:52:14 +0000 Subject: [PATCH 1/4] Disable webkit and phonon mediaplayers on Mac for now --- openlp/core/ui/media/phononplayer.py | 7 ++++++- openlp/core/ui/media/webkitplayer.py | 8 ++++++-- 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/openlp/core/ui/media/phononplayer.py b/openlp/core/ui/media/phononplayer.py index b343755a0..587309e87 100644 --- a/openlp/core/ui/media/phononplayer.py +++ b/openlp/core/ui/media/phononplayer.py @@ -39,6 +39,7 @@ from openlp.core.lib import translate from openlp.core.ui.media import MediaState from openlp.core.ui.media.mediaplayer import MediaPlayer +from openlp.core.common import is_macosx log = logging.getLogger(__name__) @@ -124,7 +125,11 @@ class PhononPlayer(MediaPlayer): """ Check if the player is available """ - return True + # At the moment we don't have support for phononplayer on Mac OS X + if is_macosx(): + return False + else: + return True def load(self, display): """ diff --git a/openlp/core/ui/media/webkitplayer.py b/openlp/core/ui/media/webkitplayer.py index 38e691494..673f2fc1a 100644 --- a/openlp/core/ui/media/webkitplayer.py +++ b/openlp/core/ui/media/webkitplayer.py @@ -33,7 +33,7 @@ from PyQt4 import QtGui import logging -from openlp.core.common import Settings +from openlp.core.common import Settings, is_macosx from openlp.core.lib import translate from openlp.core.ui.media import MediaState from openlp.core.ui.media.mediaplayer import MediaPlayer @@ -231,7 +231,11 @@ class WebkitPlayer(MediaPlayer): """ Check the availability of the media player """ - return True + # At the moment we don't have support for webkitplayer on Mac OS X + if is_macosx(): + return False + else: + return True def load(self, display): """ From 1e95bc7fbbf577720d6760419f59aa983bf43d9f Mon Sep 17 00:00:00 2001 From: Tomas Groth Date: Wed, 31 Dec 2014 14:57:41 +0000 Subject: [PATCH 2/4] Added simple tests for webkit and phonon players --- .../openlp_core_ui_media/test_phononplayer.py | 57 +++++++++++++++++++ .../openlp_core_ui_media/test_webkitplayer.py | 57 +++++++++++++++++++ 2 files changed, 114 insertions(+) create mode 100644 tests/functional/openlp_core_ui_media/test_phononplayer.py create mode 100644 tests/functional/openlp_core_ui_media/test_webkitplayer.py diff --git a/tests/functional/openlp_core_ui_media/test_phononplayer.py b/tests/functional/openlp_core_ui_media/test_phononplayer.py new file mode 100644 index 000000000..7c2e3625a --- /dev/null +++ b/tests/functional/openlp_core_ui_media/test_phononplayer.py @@ -0,0 +1,57 @@ +# -*- coding: utf-8 -*- +# vim: autoindent shiftwidth=4 expandtab textwidth=120 tabstop=4 softtabstop=4 + +############################################################################### +# OpenLP - Open Source Lyrics Projection # +# --------------------------------------------------------------------------- # +# Copyright (c) 2008-2014 Raoul Snyman # +# Portions copyright (c) 2008-2014 Tim Bentley, Gerald Britton, Jonathan # +# 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 # +############################################################################### +""" +Package to test the openlp.core.ui.media.phononplayer package. +""" +from unittest import TestCase + +from openlp.core.ui.media.phononplayer import PhononPlayer +from openlp.core.common import is_macosx + + +class TestPhononPlayer(TestCase): + """ + Test the functions in the :mod:`phononplayer` module. + """ + + def check_available_test(self): + """ + Simple test of phononplayer availability + """ + # GIVEN: A PhononPlayer + phonon_player = PhononPlayer(None) + + # WHEN: An checking if the player is available + available = phonon_player.check_available() + + # THEN: The player should be available, except on Mac OS X + if is_macosx(): + self.assertEqual(False, available, 'The PhononPlayer should not be available on Mac OS X.') + else: + self.assertEqual(True, available, 'The PhononPlayer should be available on this platform.') diff --git a/tests/functional/openlp_core_ui_media/test_webkitplayer.py b/tests/functional/openlp_core_ui_media/test_webkitplayer.py new file mode 100644 index 000000000..db317688a --- /dev/null +++ b/tests/functional/openlp_core_ui_media/test_webkitplayer.py @@ -0,0 +1,57 @@ +# -*- coding: utf-8 -*- +# vim: autoindent shiftwidth=4 expandtab textwidth=120 tabstop=4 softtabstop=4 + +############################################################################### +# OpenLP - Open Source Lyrics Projection # +# --------------------------------------------------------------------------- # +# Copyright (c) 2008-2014 Raoul Snyman # +# Portions copyright (c) 2008-2014 Tim Bentley, Gerald Britton, Jonathan # +# 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 # +############################################################################### +""" +Package to test the openlp.core.ui.media.webkitplayer package. +""" +from unittest import TestCase + +from openlp.core.ui.media.webkitplayer import WebkitPlayer +from openlp.core.common import is_macosx + + +class TestPhononPlayer(TestCase): + """ + Test the functions in the :mod:`webkitplayer` module. + """ + + def check_available_test(self): + """ + Simple test of webkitplayer availability + """ + # GIVEN: A WebkitPlayer + webkit_player = WebkitPlayer(None) + + # WHEN: An checking if the player is available + available = webkit_player.check_available() + + # THEN: The player should be available, except on Mac OS X + if is_macosx(): + self.assertEqual(False, available, 'The WebkitPlayer should not be available on Mac OS X.') + else: + self.assertEqual(True, available, 'The WebkitPlayer should be available on this platform.') From e5c5a229a4fc0541d6823347f0559c07ce24b24d Mon Sep 17 00:00:00 2001 From: Tomas Groth Date: Wed, 31 Dec 2014 15:06:35 +0000 Subject: [PATCH 3/4] Update to 2015 --- tests/functional/openlp_core_ui_media/test_phononplayer.py | 4 ++-- tests/functional/openlp_core_ui_media/test_webkitplayer.py | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/tests/functional/openlp_core_ui_media/test_phononplayer.py b/tests/functional/openlp_core_ui_media/test_phononplayer.py index 7c2e3625a..ac51def1d 100644 --- a/tests/functional/openlp_core_ui_media/test_phononplayer.py +++ b/tests/functional/openlp_core_ui_media/test_phononplayer.py @@ -4,8 +4,8 @@ ############################################################################### # OpenLP - Open Source Lyrics Projection # # --------------------------------------------------------------------------- # -# Copyright (c) 2008-2014 Raoul Snyman # -# Portions copyright (c) 2008-2014 Tim Bentley, Gerald Britton, Jonathan # +# Copyright (c) 2008-2015 Raoul Snyman # +# Portions copyright (c) 2008-2015 Tim Bentley, Gerald Britton, Jonathan # # 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, # diff --git a/tests/functional/openlp_core_ui_media/test_webkitplayer.py b/tests/functional/openlp_core_ui_media/test_webkitplayer.py index db317688a..70a6f6320 100644 --- a/tests/functional/openlp_core_ui_media/test_webkitplayer.py +++ b/tests/functional/openlp_core_ui_media/test_webkitplayer.py @@ -4,8 +4,8 @@ ############################################################################### # OpenLP - Open Source Lyrics Projection # # --------------------------------------------------------------------------- # -# Copyright (c) 2008-2014 Raoul Snyman # -# Portions copyright (c) 2008-2014 Tim Bentley, Gerald Britton, Jonathan # +# Copyright (c) 2008-2015 Raoul Snyman # +# Portions copyright (c) 2008-2015 Tim Bentley, Gerald Britton, Jonathan # # 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, # From 9b2660bf7f98e0cece75fada6c322a40dc7fea5f Mon Sep 17 00:00:00 2001 From: Tomas Groth Date: Thu, 1 Jan 2015 17:41:32 +0000 Subject: [PATCH 4/4] Rewrote tests for webkit and phonon player --- .../openlp_core_ui_media/test_phononplayer.py | 36 ++++++++++++------ .../openlp_core_ui_media/test_webkitplayer.py | 38 +++++++++++++------ 2 files changed, 51 insertions(+), 23 deletions(-) diff --git a/tests/functional/openlp_core_ui_media/test_phononplayer.py b/tests/functional/openlp_core_ui_media/test_phononplayer.py index ac51def1d..d7c194e5d 100644 --- a/tests/functional/openlp_core_ui_media/test_phononplayer.py +++ b/tests/functional/openlp_core_ui_media/test_phononplayer.py @@ -30,9 +30,9 @@ Package to test the openlp.core.ui.media.phononplayer package. """ from unittest import TestCase +from tests.functional import patch from openlp.core.ui.media.phononplayer import PhononPlayer -from openlp.core.common import is_macosx class TestPhononPlayer(TestCase): @@ -40,18 +40,32 @@ class TestPhononPlayer(TestCase): Test the functions in the :mod:`phononplayer` module. """ - def check_available_test(self): + def check_available_mac_test(self): """ - Simple test of phononplayer availability + Simple test of phononplayer availability on Mac OS X """ - # GIVEN: A PhononPlayer - phonon_player = PhononPlayer(None) + # GIVEN: A PhononPlayer and a mocked is_macosx + with patch('openlp.core.ui.media.phononplayer.is_macosx') as mocked_is_macosx: + mocked_is_macosx.return_value = True + phonon_player = PhononPlayer(None) - # WHEN: An checking if the player is available - available = phonon_player.check_available() + # WHEN: An checking if the player is available + available = phonon_player.check_available() - # THEN: The player should be available, except on Mac OS X - if is_macosx(): + # THEN: The player should not be available on Mac OS X self.assertEqual(False, available, 'The PhononPlayer should not be available on Mac OS X.') - else: - self.assertEqual(True, available, 'The PhononPlayer should be available on this platform.') + + def check_available_non_mac_test(self): + """ + Simple test of phononplayer availability when not on Mac OS X + """ + # GIVEN: A PhononPlayer and a mocked is_macosx + with patch('openlp.core.ui.media.phononplayer.is_macosx') as mocked_is_macosx: + mocked_is_macosx.return_value = False + phonon_player = PhononPlayer(None) + + # WHEN: An checking if the player is available + available = phonon_player.check_available() + + # THEN: The player should be available when not on Mac OS X + self.assertEqual(True, available, 'The PhononPlayer should be available when not on Mac OS X.') diff --git a/tests/functional/openlp_core_ui_media/test_webkitplayer.py b/tests/functional/openlp_core_ui_media/test_webkitplayer.py index 70a6f6320..94eb3ea8d 100644 --- a/tests/functional/openlp_core_ui_media/test_webkitplayer.py +++ b/tests/functional/openlp_core_ui_media/test_webkitplayer.py @@ -30,28 +30,42 @@ Package to test the openlp.core.ui.media.webkitplayer package. """ from unittest import TestCase +from tests.functional import patch from openlp.core.ui.media.webkitplayer import WebkitPlayer -from openlp.core.common import is_macosx -class TestPhononPlayer(TestCase): +class TestWebkitPlayer(TestCase): """ Test the functions in the :mod:`webkitplayer` module. """ - def check_available_test(self): + def check_available_mac_test(self): """ - Simple test of webkitplayer availability + Simple test of webkitplayer availability on Mac OS X """ - # GIVEN: A WebkitPlayer - webkit_player = WebkitPlayer(None) + # GIVEN: A WebkitPlayer and a mocked is_macosx + with patch('openlp.core.ui.media.webkitplayer.is_macosx') as mocked_is_macosx: + mocked_is_macosx.return_value = True + webkit_player = WebkitPlayer(None) - # WHEN: An checking if the player is available - available = webkit_player.check_available() + # WHEN: An checking if the player is available + available = webkit_player.check_available() - # THEN: The player should be available, except on Mac OS X - if is_macosx(): + # THEN: The player should not be available on Mac OS X self.assertEqual(False, available, 'The WebkitPlayer should not be available on Mac OS X.') - else: - self.assertEqual(True, available, 'The WebkitPlayer should be available on this platform.') + + def check_available_non_mac_test(self): + """ + Simple test of webkitplayer availability when not on Mac OS X + """ + # GIVEN: A WebkitPlayer and a mocked is_macosx + with patch('openlp.core.ui.media.webkitplayer.is_macosx') as mocked_is_macosx: + mocked_is_macosx.return_value = False + webkit_player = WebkitPlayer(None) + + # WHEN: An checking if the player is available + available = webkit_player.check_available() + + # THEN: The player should be available when not on Mac OS X + self.assertEqual(True, available, 'The WebkitPlayer should be available when not on Mac OS X.')