forked from openlp/openlp
Added a test
This commit is contained in:
parent
58f517b4d6
commit
79ef9315d5
@ -550,7 +550,7 @@ class MediaClipSelectorForm(QtGui.QDialog, Ui_MediaClipSelector, RegistryPropert
|
|||||||
"""
|
"""
|
||||||
Saves the current media and trackinfo as a clip to the mediamanager
|
Saves the current media and trackinfo as a clip to the mediamanager
|
||||||
"""
|
"""
|
||||||
log.debug('in on_save_button_clicked')
|
log.debug('in MediaClipSelectorForm.accept')
|
||||||
start_time = self.start_position_edit.time()
|
start_time = self.start_position_edit.time()
|
||||||
start_time_ms = start_time.hour() * 60 * 60 * 1000 + \
|
start_time_ms = start_time.hour() * 60 * 60 * 1000 + \
|
||||||
start_time.minute() * 60 * 1000 + \
|
start_time.minute() * 60 * 1000 + \
|
||||||
@ -565,10 +565,23 @@ class MediaClipSelectorForm(QtGui.QDialog, Ui_MediaClipSelector, RegistryPropert
|
|||||||
path = self.media_path_combobox.currentText()
|
path = self.media_path_combobox.currentText()
|
||||||
optical = ''
|
optical = ''
|
||||||
if self.audio_cd:
|
if self.audio_cd:
|
||||||
|
# Check for load problems
|
||||||
|
if start_time_ms is None or end_time_ms is None or title is None:
|
||||||
|
critical_error_message_box(translate('MediaPlugin.MediaClipSelectorForm', 'CD not loaded correctly'),
|
||||||
|
translate('MediaPlugin.MediaClipSelectorForm',
|
||||||
|
'The CD was not loaded correctly, please re-load and try again.'))
|
||||||
|
return
|
||||||
optical = 'optical:%d:-1:-1:%d:%d:' % (title, start_time_ms, end_time_ms)
|
optical = 'optical:%d:-1:-1:%d:%d:' % (title, start_time_ms, end_time_ms)
|
||||||
else:
|
else:
|
||||||
audio_track = self.audio_tracks_combobox.itemData(self.audio_tracks_combobox.currentIndex())
|
audio_track = self.audio_tracks_combobox.itemData(self.audio_tracks_combobox.currentIndex())
|
||||||
subtitle_track = self.subtitle_tracks_combobox.itemData(self.subtitle_tracks_combobox.currentIndex())
|
subtitle_track = self.subtitle_tracks_combobox.itemData(self.subtitle_tracks_combobox.currentIndex())
|
||||||
|
# Check for load problems
|
||||||
|
if start_time_ms is None or end_time_ms is None or title is None or audio_track is None\
|
||||||
|
or subtitle_track is None:
|
||||||
|
critical_error_message_box(translate('MediaPlugin.MediaClipSelectorForm', 'DVD not loaded correctly'),
|
||||||
|
translate('MediaPlugin.MediaClipSelectorForm',
|
||||||
|
'The DVD was not loaded correctly, please re-load and try again.'))
|
||||||
|
return
|
||||||
optical = 'optical:%d:%d:%d:%d:%d:' % (title, audio_track, subtitle_track, start_time_ms, end_time_ms)
|
optical = 'optical:%d:%d:%d:%d:%d:' % (title, audio_track, subtitle_track, start_time_ms, end_time_ms)
|
||||||
# Ask for an alternative name for the mediaclip
|
# Ask for an alternative name for the mediaclip
|
||||||
while True:
|
while True:
|
||||||
|
@ -0,0 +1,28 @@
|
|||||||
|
# -*- 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 #
|
||||||
|
###############################################################################
|
28
tests/interfaces/openlp_plugins/media/forms/__init__.py
Normal file
28
tests/interfaces/openlp_plugins/media/forms/__init__.py
Normal file
@ -0,0 +1,28 @@
|
|||||||
|
# -*- 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 #
|
||||||
|
###############################################################################
|
@ -60,6 +60,7 @@ class TestMediaClipSelectorForm(TestCase, TestMixin):
|
|||||||
# Mock VLC so we don't actually use it
|
# Mock VLC so we don't actually use it
|
||||||
self.vlc_patcher = patch('openlp.plugins.media.forms.mediaclipselectorform.vlc')
|
self.vlc_patcher = patch('openlp.plugins.media.forms.mediaclipselectorform.vlc')
|
||||||
self.vlc_patcher.start()
|
self.vlc_patcher.start()
|
||||||
|
Registry().register('application', self.app)
|
||||||
# Mock the media item
|
# Mock the media item
|
||||||
self.mock_media_item = MagicMock()
|
self.mock_media_item = MagicMock()
|
||||||
# create form to test
|
# create form to test
|
||||||
@ -67,6 +68,8 @@ class TestMediaClipSelectorForm(TestCase, TestMixin):
|
|||||||
mock_media_state_wait = MagicMock()
|
mock_media_state_wait = MagicMock()
|
||||||
mock_media_state_wait.return_value = True
|
mock_media_state_wait.return_value = True
|
||||||
self.form.media_state_wait = mock_media_state_wait
|
self.form.media_state_wait = mock_media_state_wait
|
||||||
|
self.form.application.set_busy_cursor = MagicMock()
|
||||||
|
self.form.application.set_normal_cursor = MagicMock()
|
||||||
|
|
||||||
def tearDown(self):
|
def tearDown(self):
|
||||||
"""
|
"""
|
||||||
@ -155,3 +158,21 @@ class TestMediaClipSelectorForm(TestCase, TestMixin):
|
|||||||
self.form.audio_tracks_combobox.itemData.assert_any_call(0)
|
self.form.audio_tracks_combobox.itemData.assert_any_call(0)
|
||||||
self.form.audio_tracks_combobox.itemData.assert_any_call(1)
|
self.form.audio_tracks_combobox.itemData.assert_any_call(1)
|
||||||
self.form.subtitle_tracks_combobox.itemData.assert_any_call(0)
|
self.form.subtitle_tracks_combobox.itemData.assert_any_call(0)
|
||||||
|
|
||||||
|
def click_save_button_test(self):
|
||||||
|
"""
|
||||||
|
Test that the correct function is called when save is clicked, and that it behaves as expected.
|
||||||
|
"""
|
||||||
|
# GIVEN: Mocked methods.
|
||||||
|
with patch('openlp.plugins.media.forms.mediaclipselectorform.critical_error_message_box') as \
|
||||||
|
mocked_critical_error_message_box,\
|
||||||
|
patch('PyQt4.QtGui.QDialog.exec_') as mocked_exec:
|
||||||
|
self.form.exec_()
|
||||||
|
|
||||||
|
# WHEN: The save button is clicked with a NoneType in start_time_ms or end_time_ms
|
||||||
|
self.form.accept()
|
||||||
|
|
||||||
|
# THEN: we should get an error message
|
||||||
|
mocked_critical_error_message_box.assert_called_with('DVD not loaded correctly',
|
||||||
|
'The DVD was not loaded correctly, '
|
||||||
|
'please re-load and try again.')
|
||||||
|
Loading…
Reference in New Issue
Block a user