forked from openlp/openlp
trunk
This commit is contained in:
commit
4bef5f72f2
@ -153,10 +153,10 @@ class OpenLP(OpenLPMixin, QtWidgets.QApplication):
|
||||
self.processEvents()
|
||||
if not has_run_wizard:
|
||||
self.main_window.first_time()
|
||||
update_check = Settings().value('core/update check')
|
||||
if update_check:
|
||||
version = VersionThread(self.main_window)
|
||||
version.start()
|
||||
# update_check = Settings().value('core/update check')
|
||||
# if update_check:
|
||||
# version = VersionThread(self.main_window)
|
||||
# version.start()
|
||||
self.main_window.is_display_blank()
|
||||
self.main_window.app_startup()
|
||||
return self.exec()
|
||||
|
@ -159,6 +159,7 @@ class GeneralTab(SettingsTab):
|
||||
self.startup_layout.addWidget(self.show_splash_check_box)
|
||||
self.check_for_updates_check_box = QtWidgets.QCheckBox(self.startup_group_box)
|
||||
self.check_for_updates_check_box.setObjectName('check_for_updates_check_box')
|
||||
self.check_for_updates_check_box.setVisible(False)
|
||||
self.startup_layout.addWidget(self.check_for_updates_check_box)
|
||||
self.right_layout.addWidget(self.startup_group_box)
|
||||
# Application Settings
|
||||
|
@ -1131,7 +1131,9 @@ class ServiceManager(OpenLPMixin, RegistryMixin, QtWidgets.QWidget, Ui_ServiceMa
|
||||
:param item: The service item to be checked
|
||||
"""
|
||||
pos = item.data(0, QtCore.Qt.UserRole)
|
||||
self.service_items[pos - 1]['expanded'] = False
|
||||
# Only set root items as collapsed, and since we only have 2 levels we find them by checking for children
|
||||
if item.childCount():
|
||||
self.service_items[pos - 1]['expanded'] = False
|
||||
|
||||
def on_expand_all(self, field=None):
|
||||
"""
|
||||
@ -1149,7 +1151,9 @@ class ServiceManager(OpenLPMixin, RegistryMixin, QtWidgets.QWidget, Ui_ServiceMa
|
||||
:param item: The service item to be checked
|
||||
"""
|
||||
pos = item.data(0, QtCore.Qt.UserRole)
|
||||
self.service_items[pos - 1]['expanded'] = True
|
||||
# Only set root items as expanded, and since we only have 2 levels we find them by checking for children
|
||||
if item.childCount():
|
||||
self.service_items[pos - 1]['expanded'] = True
|
||||
|
||||
def on_service_top(self, field=None):
|
||||
"""
|
||||
|
@ -828,13 +828,13 @@ class SlideController(DisplayController, RegistryProperties):
|
||||
self.selected_row = 0
|
||||
# take a copy not a link to the servicemanager copy.
|
||||
self.service_item = copy.copy(service_item)
|
||||
if self.service_item.is_command():
|
||||
Registry().execute(
|
||||
'%s_start' % service_item.name.lower(), [self.service_item, self.is_live, self.hide_mode(), slide_no])
|
||||
# Reset blanking if needed
|
||||
if old_item and self.is_live and (old_item.is_capable(ItemCapabilities.ProvidesOwnDisplay) or
|
||||
self.service_item.is_capable(ItemCapabilities.ProvidesOwnDisplay)):
|
||||
self._reset_blank(self.service_item.is_capable(ItemCapabilities.ProvidesOwnDisplay))
|
||||
if service_item.is_command():
|
||||
Registry().execute(
|
||||
'%s_start' % service_item.name.lower(), [self.service_item, self.is_live, self.hide_mode(), slide_no])
|
||||
self.info_label.setText(self.service_item.title)
|
||||
self.slide_list = {}
|
||||
if self.is_live:
|
||||
@ -886,28 +886,28 @@ class SlideController(DisplayController, RegistryProperties):
|
||||
self.service_item.bg_image_bytes = \
|
||||
self.image_manager.get_image_bytes(frame['path'], ImageSource.ImagePlugin)
|
||||
self.preview_widget.replace_service_item(self.service_item, width, slide_no)
|
||||
self.enable_tool_bar(service_item)
|
||||
self.enable_tool_bar(self.service_item)
|
||||
# Pass to display for viewing.
|
||||
# Postpone image build, we need to do this later to avoid the theme
|
||||
# flashing on the screen
|
||||
if not self.service_item.is_image():
|
||||
self.display.build_html(self.service_item)
|
||||
if service_item.is_media():
|
||||
self.on_media_start(service_item)
|
||||
if self.service_item.is_media():
|
||||
self.on_media_start(self.service_item)
|
||||
self.slide_selected(True)
|
||||
if service_item.from_service:
|
||||
if self.service_item.from_service:
|
||||
self.preview_widget.setFocus()
|
||||
if old_item:
|
||||
# Close the old item after the new one is opened
|
||||
# This avoids the service theme/desktop flashing on screen
|
||||
# However opening a new item of the same type will automatically
|
||||
# close the previous, so make sure we don't close the new one.
|
||||
if old_item.is_command() and not service_item.is_command() or \
|
||||
old_item.is_command() and not old_item.is_media() and service_item.is_media():
|
||||
if old_item.is_command() and not self.service_item.is_command() or \
|
||||
old_item.is_command() and not old_item.is_media() and self.service_item.is_media():
|
||||
Registry().execute('%s_stop' % old_item.name.lower(), [old_item, self.is_live])
|
||||
if old_item.is_media() and not service_item.is_media():
|
||||
if old_item.is_media() and not self.service_item.is_media():
|
||||
self.on_media_close()
|
||||
Registry().execute('slidecontroller_%s_started' % self.type_prefix, [service_item])
|
||||
Registry().execute('slidecontroller_%s_started' % self.type_prefix, [self.service_item])
|
||||
|
||||
def on_slide_selected_index(self, message):
|
||||
"""
|
||||
@ -1141,8 +1141,9 @@ class SlideController(DisplayController, RegistryProperties):
|
||||
Creates an image of the current screen and updates the preview frame.
|
||||
"""
|
||||
win_id = QtWidgets.QApplication.desktop().winId()
|
||||
screen = QtWidgets.QApplication.primaryScreen()
|
||||
rect = self.screens.current['size']
|
||||
win_image = QtGui.QScreen.grabWindow(win_id, rect.x(), rect.y(), rect.width(), rect.height())
|
||||
win_image = screen.grabWindow(win_id, rect.x(), rect.y(), rect.width(), rect.height())
|
||||
win_image.setDevicePixelRatio(self.slide_preview.devicePixelRatio())
|
||||
self.slide_preview.setPixmap(win_image)
|
||||
self.slide_image = win_image
|
||||
|
@ -349,16 +349,17 @@ class MessageListener(object):
|
||||
# When presenting PDF/XPS/OXPS, we are using the image presentation code,
|
||||
# so handler & processor is set to None, and we skip adding the handler.
|
||||
self.handler = None
|
||||
if self.handler == self.media_item.automatic:
|
||||
self.handler = self.media_item.find_controller_by_type(file)
|
||||
if not self.handler:
|
||||
return
|
||||
else:
|
||||
# the saved handler is not present so need to use one based on file suffix.
|
||||
if not self.controllers[self.handler].available:
|
||||
if self.handler == self.media_item.automatic:
|
||||
self.handler = self.media_item.find_controller_by_type(file)
|
||||
if not self.handler:
|
||||
return
|
||||
else:
|
||||
# the saved handler is not present so need to use one based on file suffix.
|
||||
if not self.controllers[self.handler].available:
|
||||
self.handler = self.media_item.find_controller_by_type(file)
|
||||
if not self.handler:
|
||||
return
|
||||
if is_live:
|
||||
controller = self.live_handler
|
||||
else:
|
||||
|
@ -515,7 +515,7 @@ class EditSongForm(QtWidgets.QDialog, Ui_EditSongDialog, RegistryProperties):
|
||||
self.topics_list_view.addItem(topic_name)
|
||||
self.songbooks_list_view.clear()
|
||||
for songbook_entry in self.song.songbook_entries:
|
||||
self.add_songbook_entry_to_list(songbook_entry.songbook.id, songbook_entry.songbook.name,
|
||||
self.add_songbook_entry_to_list(songbook_entry.songbook.id, songbook_entry.songbook.name,
|
||||
songbook_entry.entry)
|
||||
self.audio_list_widget.clear()
|
||||
for media in self.song.media_files:
|
||||
|
@ -255,9 +255,9 @@ class SongMediaItem(MediaManagerItem):
|
||||
search_entry = re.sub(r'[^0-9]', '', search_keywords[2])
|
||||
|
||||
songbook_entries = (self.plugin.manager.session.query(SongBookEntry)
|
||||
.join(Book)
|
||||
.order_by(Book.name)
|
||||
.order_by(SongBookEntry.entry))
|
||||
.join(Book)
|
||||
.order_by(Book.name)
|
||||
.order_by(SongBookEntry.entry))
|
||||
for songbook_entry in songbook_entries:
|
||||
if songbook_entry.song.temporary:
|
||||
continue
|
||||
|
@ -363,9 +363,8 @@ class Htmbuilder(TestCase, TestMixin):
|
||||
"""
|
||||
Test the webkit_version() function
|
||||
"""
|
||||
# GIVEN: Webkit
|
||||
# GIVEN: Webkit
|
||||
webkit_ver = float(QtWebKit.qWebKitVersion())
|
||||
# WHEN: Retrieving the webkit version
|
||||
# THEN: Webkit versions should match
|
||||
self.assertEquals(webkit_version(), webkit_ver, "The returned webkit version doesn't match the installed one")
|
||||
|
||||
|
@ -87,8 +87,6 @@ class TestProjectorDB(TestCase):
|
||||
Set up anything necessary for all tests
|
||||
"""
|
||||
with patch('openlp.core.lib.projector.db.init_url') as mocked_init_url:
|
||||
if os.path.exists(TEST_DB):
|
||||
os.unlink(TEST_DB)
|
||||
mocked_init_url.return_value = 'sqlite:///%s' % TEST_DB
|
||||
self.projector = ProjectorDB()
|
||||
|
||||
@ -98,6 +96,15 @@ class TestProjectorDB(TestCase):
|
||||
"""
|
||||
self.projector.session.close()
|
||||
self.projector = None
|
||||
retries = 0
|
||||
while retries < 5:
|
||||
try:
|
||||
if os.path.exists(TEST_DB):
|
||||
os.unlink(TEST_DB)
|
||||
break
|
||||
except:
|
||||
time.sleep(1)
|
||||
retries += 1
|
||||
|
||||
def find_record_by_ip_test(self):
|
||||
"""
|
||||
|
@ -189,5 +189,3 @@ class TestMainWindow(TestCase, TestMixin):
|
||||
# THEN: The media manager dock is made visible
|
||||
self.assertEqual(0, mocked_media_manager_dock.setVisible.call_count)
|
||||
mocked_widget.on_focus.assert_called_with()
|
||||
|
||||
|
||||
|
@ -22,14 +22,17 @@
|
||||
"""
|
||||
Package to test the openlp.core.utils.db package.
|
||||
"""
|
||||
from tempfile import mkdtemp
|
||||
from unittest import TestCase
|
||||
import gc
|
||||
import os
|
||||
import shutil
|
||||
import sqlalchemy
|
||||
from unittest import TestCase
|
||||
from tempfile import mkdtemp
|
||||
import time
|
||||
|
||||
from openlp.core.utils.db import drop_column, drop_columns
|
||||
from openlp.core.lib.db import init_db, get_upgrade_op
|
||||
|
||||
from tests.utils.constants import TEST_RESOURCES_PATH
|
||||
|
||||
|
||||
@ -40,30 +43,41 @@ class TestUtilsDBFunctions(TestCase):
|
||||
Create temp folder for keeping db file
|
||||
"""
|
||||
self.tmp_folder = mkdtemp()
|
||||
db_path = os.path.join(TEST_RESOURCES_PATH, 'songs', 'songs-1.9.7.sqlite')
|
||||
self.db_tmp_path = os.path.join(self.tmp_folder, 'songs-1.9.7.sqlite')
|
||||
shutil.copyfile(db_path, self.db_tmp_path)
|
||||
db_url = 'sqlite:///' + self.db_tmp_path
|
||||
self.session, metadata = init_db(db_url)
|
||||
self.op = get_upgrade_op(self.session)
|
||||
|
||||
def tearDown(self):
|
||||
"""
|
||||
Clean up
|
||||
"""
|
||||
shutil.rmtree(self.tmp_folder)
|
||||
self.session.close()
|
||||
self.session = None
|
||||
gc.collect()
|
||||
retries = 0
|
||||
while retries < 5:
|
||||
try:
|
||||
if os.path.exists(self.tmp_folder):
|
||||
shutil.rmtree(self.tmp_folder)
|
||||
break
|
||||
except:
|
||||
time.sleep(1)
|
||||
retries += 1
|
||||
|
||||
def delete_column_test(self):
|
||||
"""
|
||||
Test deleting a single column in a table
|
||||
"""
|
||||
# GIVEN: A temporary song db
|
||||
db_path = os.path.join(TEST_RESOURCES_PATH, 'songs', 'songs-1.9.7.sqlite')
|
||||
db_tmp_path = os.path.join(self.tmp_folder, 'songs-1.9.7.sqlite')
|
||||
shutil.copyfile(db_path, db_tmp_path)
|
||||
db_url = 'sqlite:///' + db_tmp_path
|
||||
session, metadata = init_db(db_url)
|
||||
op = get_upgrade_op(session)
|
||||
|
||||
# WHEN: Deleting a columns in a table
|
||||
drop_column(op, 'songs', 'song_book_id')
|
||||
drop_column(self.op, 'songs', 'song_book_id')
|
||||
|
||||
# THEN: The column should have been deleted
|
||||
meta = sqlalchemy.MetaData(bind=op.get_bind())
|
||||
meta = sqlalchemy.MetaData(bind=self.op.get_bind())
|
||||
meta.reflect()
|
||||
columns = meta.tables['songs'].columns
|
||||
|
||||
@ -76,18 +90,12 @@ class TestUtilsDBFunctions(TestCase):
|
||||
Test deleting multiple columns in a table
|
||||
"""
|
||||
# GIVEN: A temporary song db
|
||||
db_path = os.path.join(TEST_RESOURCES_PATH, 'songs', 'songs-1.9.7.sqlite')
|
||||
db_tmp_path = os.path.join(self.tmp_folder, 'songs-1.9.7.sqlite')
|
||||
shutil.copyfile(db_path, db_tmp_path)
|
||||
db_url = 'sqlite:///' + db_tmp_path
|
||||
session, metadata = init_db(db_url)
|
||||
op = get_upgrade_op(session)
|
||||
|
||||
# WHEN: Deleting a columns in a table
|
||||
drop_columns(op, 'songs', ['song_book_id', 'song_number'])
|
||||
drop_columns(self.op, 'songs', ['song_book_id', 'song_number'])
|
||||
|
||||
# THEN: The columns should have been deleted
|
||||
meta = sqlalchemy.MetaData(bind=op.get_bind())
|
||||
meta = sqlalchemy.MetaData(bind=self.op.get_bind())
|
||||
meta.reflect()
|
||||
columns = meta.tables['songs'].columns
|
||||
|
||||
|
@ -104,3 +104,23 @@ class TestMessageListener(TestCase, TestMixin):
|
||||
|
||||
# THEN: The controllers will be setup.
|
||||
self.assertTrue(len(controllers), 'We have loaded a controller')
|
||||
|
||||
@patch('openlp.plugins.presentations.lib.mediaitem.MessageListener._setup')
|
||||
def start_pdf_presentation_test(self, media_mock):
|
||||
"""
|
||||
Test the startup of pdf presentation succeed.
|
||||
"""
|
||||
# GIVEN: A sservice item with a pdf
|
||||
mock_item = MagicMock()
|
||||
mock_item.processor = 'Pdf'
|
||||
mock_item.get_frame_path.return_value = "test.pdf"
|
||||
self.media_item.generate_slide_data = MagicMock()
|
||||
ml = MessageListener(self.media_item)
|
||||
ml.media_item = self.media_item
|
||||
ml.preview_handler = MagicMock()
|
||||
|
||||
# WHEN: request the presentation to start
|
||||
ml.startup([mock_item, False, False, False])
|
||||
|
||||
# THEN: The handler should be set to None
|
||||
self.assertIsNone(ml.handler, 'The handler should be None')
|
||||
|
@ -65,8 +65,6 @@ class ProjectorSourceFormTest(TestCase, TestMixin):
|
||||
"""
|
||||
Set up anything necessary for all tests
|
||||
"""
|
||||
if os.path.exists(TEST_DB):
|
||||
os.unlink(TEST_DB)
|
||||
mocked_init_url.return_value = 'sqlite:///{}'.format(TEST_DB)
|
||||
self.build_settings()
|
||||
self.setup_application()
|
||||
@ -90,6 +88,15 @@ class ProjectorSourceFormTest(TestCase, TestMixin):
|
||||
self.projectordb.session.close()
|
||||
del(self.projectordb)
|
||||
del(self.projector)
|
||||
retries = 0
|
||||
while retries < 5:
|
||||
try:
|
||||
if os.path.exists(TEST_DB):
|
||||
os.unlink(TEST_DB)
|
||||
break
|
||||
except:
|
||||
time.sleep(1)
|
||||
retries += 1
|
||||
self.destroy_settings()
|
||||
|
||||
def source_dict_test(self):
|
||||
|
@ -59,4 +59,3 @@ TEST3_DATA = dict(ip='333.333.333.333',
|
||||
name='___TEST_THREE___',
|
||||
location='location three',
|
||||
notes='notes three')
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user