From d03b43fdb70ee975f4054bd49376179f792aa013 Mon Sep 17 00:00:00 2001 From: Xisco Fauli Date: Mon, 18 Jan 2021 09:32:18 +0100 Subject: tdf#131963: sw: Move UItest to CppUnitTest Change-Id: I19f7cdb4c345b55fe7eea27312513c05a54eb52c Reviewed-on: https://gerrit.libreoffice.org/c/core/+/109510 Tested-by: Jenkins Reviewed-by: Xisco Fauli --- sw/qa/extras/uiwriter/data3/tdf131963.docx | Bin 0 -> 34251 bytes sw/qa/extras/uiwriter/uiwriter3.cxx | 28 ++++++++++++++++++ sw/qa/uitest/data/tdf131963.docx | Bin 34251 -> 0 bytes sw/qa/uitest/writer_tests7/tdf131963.py | 45 ----------------------------- 4 files changed, 28 insertions(+), 45 deletions(-) create mode 100644 sw/qa/extras/uiwriter/data3/tdf131963.docx delete mode 100644 sw/qa/uitest/data/tdf131963.docx delete mode 100644 sw/qa/uitest/writer_tests7/tdf131963.py diff --git a/sw/qa/extras/uiwriter/data3/tdf131963.docx b/sw/qa/extras/uiwriter/data3/tdf131963.docx new file mode 100644 index 000000000000..15db34ee9dca Binary files /dev/null and b/sw/qa/extras/uiwriter/data3/tdf131963.docx differ diff --git a/sw/qa/extras/uiwriter/uiwriter3.cxx b/sw/qa/extras/uiwriter/uiwriter3.cxx index 6ba92153fb7d..6eb6c34c7f7c 100644 --- a/sw/qa/extras/uiwriter/uiwriter3.cxx +++ b/sw/qa/extras/uiwriter/uiwriter3.cxx @@ -406,6 +406,34 @@ CPPUNIT_TEST_FIXTURE(SwUiWriterTest3, testTdf132597) CPPUNIT_ASSERT_EQUAL(1, getPages()); } +CPPUNIT_TEST_FIXTURE(SwUiWriterTest3, testTdf131963) +{ + load(DATA_DIRECTORY, "tdf131963.docx"); + + SwXTextDocument* pTextDoc = dynamic_cast(mxComponent.get()); + CPPUNIT_ASSERT(pTextDoc); + + CPPUNIT_ASSERT_EQUAL(11, getPages()); + + dispatchCommand(mxComponent, ".uno:SelectAll", {}); + + SwWrtShell* pWrtShell = pTextDoc->GetDocShell()->GetWrtShell(); + rtl::Reference xTransfer = new SwTransferable(*pWrtShell); + xTransfer->Copy(); + + // Paste special as RTF + uno::Sequence aPropertyValues = comphelper::InitPropertySequence( + { { "SelectedFormat", uno::makeAny(static_cast(SotClipboardFormatId::RTF)) } }); + + dispatchCommand(mxComponent, ".uno:ClipboardFormatItems", aPropertyValues); + Scheduler::ProcessEventsToIdle(); + + // Without the fix in place, this test would have crashed here + + // tdf#133169: without the fix in place, it would have been 2 instead of 11 + CPPUNIT_ASSERT_EQUAL(11, getPages()); +} + CPPUNIT_TEST_FIXTURE(SwUiWriterTest3, testTdf126626) { load(DATA_DIRECTORY, "tdf126626.docx"); diff --git a/sw/qa/uitest/data/tdf131963.docx b/sw/qa/uitest/data/tdf131963.docx deleted file mode 100644 index 15db34ee9dca..000000000000 Binary files a/sw/qa/uitest/data/tdf131963.docx and /dev/null differ diff --git a/sw/qa/uitest/writer_tests7/tdf131963.py b/sw/qa/uitest/writer_tests7/tdf131963.py deleted file mode 100644 index 3604a526d526..000000000000 --- a/sw/qa/uitest/writer_tests7/tdf131963.py +++ /dev/null @@ -1,45 +0,0 @@ -# -*- tab-width: 4; indent-tabs-mode: nil; py-indent-offset: 4 -*- -# -# 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 libreoffice.uno.propertyvalue import mkPropertyValues -from uitest.uihelper.common import get_state_as_dict, get_url_for_data_file - -class tdf131963(UITestCase): - - def test_tdf131963(self): - writer_doc = self.ui_test.load_file(get_url_for_data_file("tdf131963.docx")) - - document = self.ui_test.get_component() - self.assertEqual(11, document.CurrentController.PageCount) - - self.xUITest.executeCommand(".uno:SelectAll") - self.xUITest.executeCommand(".uno:Copy") - self.ui_test.execute_dialog_through_command(".uno:PasteSpecial") - xDialog = self.xUITest.getTopFocusWindow() - - xList = xDialog.getChild('list') - - for childName in xList.getChildren(): - xChild = xList.getChild(childName) - if get_state_as_dict(xChild)['Text'] == "Rich text formatting (RTF)": - break - - xChild.executeAction("SELECT", tuple()) - self.assertEqual(get_state_as_dict(xList)['SelectEntryText'], "Rich text formatting (RTF)") - - xOkBtn = xDialog.getChild("ok") - self.ui_test.close_dialog_through_button(xOkBtn) - - # Without the fix in place, it would have crashed here - - # tdf#133169: without the fix in place, it would have been 2 instead of 11 - self.assertEqual(11, document.CurrentController.PageCount) - - self.ui_test.close_doc() - -# vim: set shiftwidth=4 softtabstop=4 expandtab: - -- cgit