tdf#107494: sw: move UITest to CppUnittest
Change-Id: I32e9f3daf866f0598889594b106383db22590d68
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/130895
Tested-by: Jenkins
Reviewed-by: Xisco Fauli <xiscofauli@libreoffice.org>
diff --git a/sw/qa/extras/uiwriter/uiwriter3.cxx b/sw/qa/extras/uiwriter/uiwriter3.cxx
index a8f2c52..c5257d5 100644
--- a/sw/qa/extras/uiwriter/uiwriter3.cxx
+++ b/sw/qa/extras/uiwriter/uiwriter3.cxx
@@ -2596,6 +2596,56 @@ CPPUNIT_TEST_FIXTURE(SwUiWriterTest3, testTdf141613)
CPPUNIT_ASSERT_EQUAL(OUString(""), getParagraph(1)->getString());
}
CPPUNIT_TEST_FIXTURE(SwUiWriterTest3, testTdf107494)
{
createSwDoc();
// Create a graphic object, but don't insert it yet.
uno::Reference<lang::XMultiServiceFactory> xFactory(mxComponent, uno::UNO_QUERY);
uno::Reference<beans::XPropertySet> xTextGraphic(
xFactory->createInstance("com.sun.star.text.TextGraphicObject"), uno::UNO_QUERY);
uno::Reference<text::XTextContent> xTextContent(xTextGraphic, uno::UNO_QUERY);
uno::Reference<beans::XPropertySet> xPageStyle(getStyles("PageStyles")->getByName("Standard"),
uno::UNO_QUERY);
xPageStyle->setPropertyValue("HeaderIsOn", uno::makeAny(true));
uno::Reference<text::XText> xHeader(
getProperty<uno::Reference<text::XText>>(xPageStyle, "HeaderText"));
CPPUNIT_ASSERT(xHeader.is());
uno::Reference<text::XTextCursor> xHeaderCursor(xHeader->createTextCursor());
xHeader->insertTextContent(xHeaderCursor, xTextContent, false);
CPPUNIT_ASSERT_EQUAL(1, getShapes());
xPageStyle->setPropertyValue("HeaderIsOn", uno::makeAny(false));
CPPUNIT_ASSERT_EQUAL(0, getShapes());
xPageStyle->setPropertyValue("FooterIsOn", uno::makeAny(true));
uno::Reference<text::XText> xFooter(
getProperty<uno::Reference<text::XText>>(xPageStyle, "FooterText"));
CPPUNIT_ASSERT(xFooter.is());
uno::Reference<text::XTextCursor> xFooterCursor(xFooter->createTextCursor());
xTextGraphic.set(xFactory->createInstance("com.sun.star.text.TextGraphicObject"),
uno::UNO_QUERY);
xTextContent.set(xTextGraphic, uno::UNO_QUERY);
xFooter->insertTextContent(xFooterCursor, xTextContent, false);
CPPUNIT_ASSERT_EQUAL(1, getShapes());
xPageStyle->setPropertyValue("FooterIsOn", uno::makeAny(false));
CPPUNIT_ASSERT_EQUAL(0, getShapes());
}
CPPUNIT_TEST_FIXTURE(SwUiWriterTest3, testTdf133358)
{
SwDoc* const pDoc = createSwDoc();
diff --git a/sw/qa/uitest/data/LibreOffice_external_logo_100px.png b/sw/qa/uitest/data/LibreOffice_external_logo_100px.png
deleted file mode 100644
index d550482..0000000
--- a/sw/qa/uitest/data/LibreOffice_external_logo_100px.png
+++ /dev/null
Binary files differ
diff --git a/sw/qa/uitest/writer_tests5/tdf107494.py b/sw/qa/uitest/writer_tests5/tdf107494.py
deleted file mode 100644
index 99f4e7d..0000000
--- a/sw/qa/uitest/writer_tests5/tdf107494.py
+++ /dev/null
@@ -1,81 +0,0 @@
# -*- tab-width: 4; indent-tabs-mode: nil; py-indent-offset: 4 -*-
#
# 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/.
#
from uitest.framework import UITestCase
from uitest.uihelper.common import get_url_for_data_file
from libreoffice.uno.propertyvalue import mkPropertyValues
#Bug 107494 - CRASH: LibreOffice crashes while deleting the header containing an image
class tdf107494(UITestCase):
def test_tdf107494_delete_header_with_image(self):
with self.ui_test.create_doc_in_start_center("writer") as document:
xWriterDoc = self.xUITest.getTopFocusWindow()
#insert header
self.assertEqual(document.StyleFamilies.PageStyles.Standard.HeaderIsOn, False)
self.xUITest.executeCommand(".uno:InsertPageHeader?PageStyle:string=Default%20Page%20Style&On:bool=true")
self.assertEqual(document.StyleFamilies.PageStyles.Standard.HeaderIsOn, True)
#insert image
text = document.getText()
cursor = text.createTextCursor()
oStyleFamilies = document.getStyleFamilies()
#https://forum.openoffice.org/en/forum/viewtopic.php?f=7&t=71227
obj2 = oStyleFamilies.getByName("PageStyles")
obj3 = obj2.getByName("Standard")
oHeaderText = obj3.HeaderText
oHeaderText.setString("New text for header") #write text to header
obj4 = oHeaderText.createTextCursor()
text = obj4.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_external_logo_100px.png")}))
textGraphic.Graphic = graphic
text.insertTextContent(cursor, textGraphic, False)
# Delete the header
with self.ui_test.execute_dialog_through_command(
".uno:InsertPageHeader?PageStyle:string=Default%20Page%20Style&On:bool=false", close_button="yes"):
pass
self.assertEqual(document.StyleFamilies.PageStyles.Standard.HeaderIsOn, False)
def test_tdf107494_delete_footer_with_image(self):
with self.ui_test.create_doc_in_start_center("writer") as document:
xWriterDoc = self.xUITest.getTopFocusWindow()
#insert footer
self.assertEqual(document.StyleFamilies.PageStyles.Standard.FooterIsOn, False)
self.xUITest.executeCommand(".uno:InsertPageFooter?PageStyle:string=Default%20Page%20Style&On:bool=true")
self.assertEqual(document.StyleFamilies.PageStyles.Standard.FooterIsOn, True)
#insert image
text = document.getText()
cursor = text.createTextCursor()
oStyleFamilies = document.getStyleFamilies()
#https://forum.openoffice.org/en/forum/viewtopic.php?f=7&t=71227
obj2 = oStyleFamilies.getByName("PageStyles")
obj3 = obj2.getByName("Standard")
oFooterText = obj3.FooterText
oFooterText.setString("New text for footer") #write text to footer
obj4 = oFooterText.createTextCursor()
text = obj4.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_external_logo_100px.png")}))
textGraphic.Graphic = graphic
text.insertTextContent(cursor, textGraphic, False)
# Delete the footer
with self.ui_test.execute_dialog_through_command(
".uno:InsertPageFooter?PageStyle:string=Default%20Page%20Style&On:bool=false", close_button="yes"):
pass
self.assertEqual(document.StyleFamilies.PageStyles.Standard.FooterIsOn, False)
# vim: set shiftwidth=4 softtabstop=4 expandtab: