From e908799240565564937372fdbce900ad6dbcb1c1 Mon Sep 17 00:00:00 2001 From: Tomas Groth Date: Sun, 13 Mar 2016 22:55:47 +0100 Subject: [PATCH] Fix slide order change when splitting custom slides. Fixes bug 1554748. Fixes: https://launchpad.net/bugs/1554748 --- openlp/plugins/custom/forms/editcustomform.py | 1 + .../custom/forms/test_customform.py | 16 ++++++++++++++++ 2 files changed, 17 insertions(+) diff --git a/openlp/plugins/custom/forms/editcustomform.py b/openlp/plugins/custom/forms/editcustomform.py index 3aaee5290..b639c2692 100644 --- a/openlp/plugins/custom/forms/editcustomform.py +++ b/openlp/plugins/custom/forms/editcustomform.py @@ -198,6 +198,7 @@ class EditCustomForm(QtWidgets.QDialog, Ui_CustomEditDialog): # Insert all slides to make the old_slides list complete. for slide in slides: old_slides.insert(old_row, slide) + old_row += 1 self.slide_list_view.addItems(old_slides) self.slide_list_view.repaint() diff --git a/tests/interfaces/openlp_plugins/custom/forms/test_customform.py b/tests/interfaces/openlp_plugins/custom/forms/test_customform.py index b19f17fe7..333f03896 100644 --- a/tests/interfaces/openlp_plugins/custom/forms/test_customform.py +++ b/tests/interfaces/openlp_plugins/custom/forms/test_customform.py @@ -128,3 +128,19 @@ class TestEditCustomForm(TestCase, TestMixin): # THEN: The validate method should have returned False. assert not result, 'The _validate() method should have retured False' mocked_critical_error_message_box.assert_called_with(message='You need to add at least one slide.') + + def update_slide_list_test(self): + """ + Test the update_slide_list() method + """ + # GIVEN: Mocked slide_list_view with a slide with 3 lines + self.form.slide_list_view = MagicMock() + self.form.slide_list_view.count.return_value = 1 + self.form.slide_list_view.currentRow.return_value = 0 + self.form.slide_list_view.item.return_value = MagicMock(return_value='1st Slide\n2nd Slide\n3rd Slide') + + # WHEN: updating the slide by splitting the lines into slides + self.form.update_slide_list(['1st Slide', '2nd Slide', '3rd Slide']) + + # THEN: The slides should be created in correct order + self.form.slide_list_view.addItems.assert_called_with(['1st Slide', '2nd Slide', '3rd Slide'])