Kaydet (Commit) 616917f4 authored tarafından Zdeněk Crhonek's avatar Zdeněk Crhonek Kaydeden (comit) Zdenek Crhonek

uitest for bug tdf#116474

Change-Id: I6b19626bf872c2eff61c57342579ec682a1c37d0
Reviewed-on: https://gerrit.libreoffice.org/56632
Tested-by: Jenkins
Reviewed-by: 's avatarZdenek Crhonek <zcrhonek@gmail.com>
üst e7d3976c
......@@ -134,6 +134,7 @@ $(eval $(call gb_Module_add_screenshot_targets,sw,\
$(eval $(call gb_Module_add_uicheck_targets,sw,\
UITest_writer_tests \
UITest_writer_tests2 \
))
endif
......
# This file is part of the LibreOffice project.
#
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
#
$(eval $(call gb_UITest_UITest,writer_tests2))
$(eval $(call gb_UITest_add_modules,writer_tests2,$(SRCDIR)/sw/qa/uitest,\
writer_tests2/ \
))
$(eval $(call gb_UITest_set_defs,writer_tests2, \
TDOC="$(SRCDIR)/sw/qa/uitest/writer_tests/data" \
))
# -*- tab-width: 4; indent-tabs-mode: nil; py-indent-offset: 4 -*-
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
from uitest.framework import UITestCase
from libreoffice.uno.propertyvalue import mkPropertyValues
from uitest.uihelper.common import get_state_as_dict
import time
from uitest.path import get_srcdir_url
from uitest.debug import sleep
from uitest.uihelper.common import select_pos
#Bug 116474 - Undo/redo: The redo of adding caption to an image isn't working: no image
def get_url_for_data_file(file_name):
return get_srcdir_url() + "/sw/qa/uitest/writer_tests/data/" + file_name
class tdf116474(UITestCase):
def test_tdf116474_insert_caption_undo(self):
writer_doc = self.ui_test.create_doc_in_start_center("writer")
xWriterDoc = self.xUITest.getTopFocusWindow()
xWriterEdit = xWriterDoc.getChild("writer_edit")
document = self.ui_test.get_component()
text = document.getText()
cursor = text.createTextCursor()
textGraphic = document.createInstance('com.sun.star.text.TextGraphicObject')
provider = self.xContext.ServiceManager.createInstance('com.sun.star.graphic.GraphicProvider')
graphic = provider.queryGraphic( mkPropertyValues({"URL": get_url_for_data_file("LibreOffice.jpg")}))
textGraphic.Graphic = graphic
text.insertTextContent(cursor, textGraphic, False)
#select image
document.getCurrentController().select(document.getDrawPage().getByIndex(0))
self.ui_test.execute_dialog_through_command(".uno:InsertCaptionDialog") # caption
xDialogCaption = self.xUITest.getTopFocusWindow()
xCapt = xDialogCaption.getChild("caption_edit")
xCapt.executeAction("TYPE", mkPropertyValues({"TEXT":"Caption"}))
xOkBtn=xDialogCaption.getChild("ok")
xOkBtn.executeAction("CLICK", tuple())
xFrame = document.TextFrames.getByIndex(0)
self.assertEqual(document.TextFrames.getByIndex(0).Text.String, "\nFigure 1: Caption")
self.assertEqual(document.GraphicObjects.getCount(), 1) #nr. of images
#Undo, redo
self.xUITest.executeCommand(".uno:Undo")
self.xUITest.executeCommand(".uno:Redo")
#Verify
self.assertEqual(document.TextFrames.getByIndex(0).Text.String, "\nFigure 1: Caption")
self.assertEqual(document.GraphicObjects.getCount(), 1) #nr. of images
self.ui_test.close_doc()
# vim: set shiftwidth=4 softtabstop=4 expandtab:
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment