[Libreoffice-commits] core.git: sw/qa

Xisco Fauli (via logerrit) logerrit at kemper.freedesktop.org
Tue Jan 26 12:27:16 UTC 2021


 sw/qa/extras/uiwriter/uiwriter3.cxx     |   48 ++++++++++++++++++++++++++++++++
 sw/qa/uitest/writer_tests4/tdf108124.py |   42 ----------------------------
 2 files changed, 48 insertions(+), 42 deletions(-)

New commits:
commit e0df00a1c3ec9340fca917dcad2a86d527e7d1dd
Author:     Xisco Fauli <xiscofauli at libreoffice.org>
AuthorDate: Mon Jan 25 19:31:43 2021 +0100
Commit:     Xisco Fauli <xiscofauli at libreoffice.org>
CommitDate: Tue Jan 26 13:26:31 2021 +0100

    tdf#108124: sw: Move UItest to CppUnitTest
    
    Change-Id: I130ec18719c6ae959df8cb2c923fef634d17eaf4
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/109925
    Tested-by: Jenkins
    Reviewed-by: Xisco Fauli <xiscofauli at libreoffice.org>

diff --git a/sw/qa/uitest/data/tdf108124.odt b/sw/qa/extras/uiwriter/data3/tdf108124.odt
similarity index 100%
rename from sw/qa/uitest/data/tdf108124.odt
rename to sw/qa/extras/uiwriter/data3/tdf108124.odt
diff --git a/sw/qa/extras/uiwriter/uiwriter3.cxx b/sw/qa/extras/uiwriter/uiwriter3.cxx
index 95503190218d..f6b67313889f 100644
--- a/sw/qa/extras/uiwriter/uiwriter3.cxx
+++ b/sw/qa/extras/uiwriter/uiwriter3.cxx
@@ -968,6 +968,54 @@ CPPUNIT_TEST_FIXTURE(SwUiWriterTest3, testTdf124397)
     CPPUNIT_ASSERT_EQUAL(sal_Int32(1), xIndexAccess->getCount());
 }
 
+CPPUNIT_TEST_FIXTURE(SwUiWriterTest3, testTdf108124)
+{
+    load(DATA_DIRECTORY, "tdf108124.odt");
+
+    SwXTextDocument* pTextDoc = dynamic_cast<SwXTextDocument*>(mxComponent.get());
+    CPPUNIT_ASSERT(pTextDoc);
+
+    uno::Reference<text::XTextGraphicObjectsSupplier> xTextGraphicObjectsSupplier(mxComponent,
+                                                                                  uno::UNO_QUERY);
+    uno::Reference<container::XIndexAccess> xIndexAccess(
+        xTextGraphicObjectsSupplier->getGraphicObjects(), uno::UNO_QUERY);
+
+    CPPUNIT_ASSERT_EQUAL(sal_Int32(2), xIndexAccess->getCount());
+
+    dispatchCommand(mxComponent, ".uno:SelectAll", {});
+
+    SwWrtShell* pWrtShell = pTextDoc->GetDocShell()->GetWrtShell();
+    rtl::Reference<SwTransferable> xTransfer = new SwTransferable(*pWrtShell);
+    xTransfer->Copy();
+
+    TransferableDataHelper aHelper(xTransfer.get());
+    SwTransferable::Paste(*pWrtShell, aHelper);
+
+    CPPUNIT_ASSERT_EQUAL(sal_Int32(2), xIndexAccess->getCount());
+
+    uno::Reference<drawing::XShape> xOldShape1(xIndexAccess->getByIndex(0), uno::UNO_QUERY);
+    uno::Reference<drawing::XShape> xOldShape2(xIndexAccess->getByIndex(1), uno::UNO_QUERY);
+
+    dispatchCommand(mxComponent, ".uno:Undo", {});
+
+    CPPUNIT_ASSERT_EQUAL(sal_Int32(2), xIndexAccess->getCount());
+
+    uno::Reference<drawing::XShape> xNewShape1(xIndexAccess->getByIndex(0), uno::UNO_QUERY);
+    uno::Reference<drawing::XShape> xNewShape2(xIndexAccess->getByIndex(1), uno::UNO_QUERY);
+
+    // there should be 2 different objects now but they have the same names,
+    // so rely on the object identity for testing...
+    CPPUNIT_ASSERT(xOldShape1.get() != xNewShape1.get());
+    CPPUNIT_ASSERT(xOldShape1.get() != xNewShape2.get());
+    CPPUNIT_ASSERT(xOldShape2.get() != xNewShape1.get());
+    CPPUNIT_ASSERT(xOldShape2.get() != xNewShape2.get());
+
+    // Without the fix in place, this test would have crashed here
+    dispatchCommand(mxComponent, ".uno:Redo", {});
+
+    CPPUNIT_ASSERT_EQUAL(sal_Int32(2), xIndexAccess->getCount());
+}
+
 CPPUNIT_TEST_FIXTURE(SwUiWriterTest3, testTdf107975)
 {
     // This test also covers tdf#117185 tdf#110442
diff --git a/sw/qa/uitest/writer_tests4/tdf108124.py b/sw/qa/uitest/writer_tests4/tdf108124.py
deleted file mode 100644
index e5f1a7f4979e..000000000000
--- a/sw/qa/uitest/writer_tests4/tdf108124.py
+++ /dev/null
@@ -1,42 +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 tdf108124(UITestCase):
-
-   def test_tdf108124(self):
-    writer_doc = self.ui_test.load_file(get_url_for_data_file("tdf108124.odt"))
-    xWriterDoc = self.xUITest.getTopFocusWindow()
-    xWriterEdit = xWriterDoc.getChild("writer_edit")
-    document = self.ui_test.get_component()
-
-    self.assertEqual(document.GraphicObjects.getCount(), 2)  #nr. of images
-
-    xWriterEdit.executeAction("TYPE", mkPropertyValues({"KEYCODE":"CTRL+a"})) # select all
-    xWriterEdit.executeAction("TYPE", mkPropertyValues({"KEYCODE":"CTRL+c"})) # copy
-    xWriterEdit.executeAction("TYPE", mkPropertyValues({"KEYCODE":"CTRL+v"})) # paste
-    self.assertEqual(document.GraphicObjects.getCount(), 2)
-    xObj1Old = document.GraphicObjects[0]
-    xObj2Old = document.GraphicObjects[1]
-    self.xUITest.executeCommand(".uno:Undo")  #Undo
-    self.assertEqual(document.GraphicObjects.getCount(), 2)
-    xObj1New = document.GraphicObjects[0]
-    xObj2New = document.GraphicObjects[1]
-    # there should be 2 different objects now but they have the same names,
-    # so rely on the object identity for testing...
-    self.assertNotEqual(xObj1Old, xObj1New)
-    self.assertNotEqual(xObj1Old, xObj2New)
-    self.assertNotEqual(xObj2Old, xObj1New)
-    self.assertNotEqual(xObj2Old, xObj2New)
-    self.xUITest.executeCommand(".uno:Redo")  #Redo
-    self.assertEqual(document.GraphicObjects.getCount(), 2)
-
-    self.ui_test.close_doc()
-
-# vim: set shiftwidth=4 softtabstop=4 expandtab:


More information about the Libreoffice-commits mailing list