1 # -*- tab-width: 4; indent-tabs-mode: nil; py-indent-offset: 4 -*-
3 # This file is part of the LibreOffice project.
5 # This Source Code Form is subject to the terms of the Mozilla Public
6 # License, v. 2.0. If a copy of the MPL was not distributed with this
7 # file, You can obtain one at http://mozilla.org/MPL/2.0/.
10 from uitest
.framework
import UITestCase
11 from libreoffice
.uno
.propertyvalue
import mkPropertyValues
12 from uitest
.uihelper
.common
import get_url_for_data_file
14 #Bug 116474 - Undo/redo: The redo of adding caption to an image isn't working: no image
16 class tdf116474(UITestCase
):
18 def test_tdf116474_insert_caption_undo(self
):
19 with self
.ui_test
.create_doc_in_start_center("writer") as document
:
20 text
= document
.getText()
21 cursor
= text
.createTextCursor()
22 textGraphic
= document
.createInstance('com.sun.star.text.TextGraphicObject')
23 provider
= self
.xContext
.ServiceManager
.createInstance('com.sun.star.graphic.GraphicProvider')
24 graphic
= provider
.queryGraphic( mkPropertyValues({"URL": get_url_for_data_file("LibreOffice.jpg")}))
25 textGraphic
.Graphic
= graphic
26 text
.insertTextContent(cursor
, textGraphic
, False)
28 document
.getCurrentController().select(document
.getDrawPage()[0])
30 with self
.ui_test
.execute_dialog_through_command(".uno:InsertCaptionDialog") as xDialogCaption
:
32 xCapt
= xDialogCaption
.getChild("caption_edit")
33 xCapt
.executeAction("TYPE", mkPropertyValues({"TEXT":"Caption"}))
36 self
.assertEqual(document
.TextFrames
[0].Text
.String
, "Figure 1: Caption")
37 self
.assertEqual(len(document
.GraphicObjects
), 1) #nr. of images
39 self
.xUITest
.executeCommand(".uno:Undo")
40 self
.xUITest
.executeCommand(".uno:Redo")
42 self
.assertEqual(document
.TextFrames
[0].Text
.String
, "Figure 1: Caption")
43 self
.assertEqual(len(document
.GraphicObjects
), 1) #nr. of images
45 # vim: set shiftwidth=4 softtabstop=4 expandtab: