[Libreoffice-commits] core.git: Branch 'libreoffice-7-0' - sw/qa
Caolán McNamara (via logerrit)
logerrit at kemper.freedesktop.org
Thu Sep 17 10:27:16 UTC 2020
sw/qa/extras/uiwriter/uiwriter.cxx | 14 ++-
sw/qa/extras/uiwriter/uiwriter3.cxx | 134 ++++++++++++++++++++++++++++--------
2 files changed, 117 insertions(+), 31 deletions(-)
New commits:
commit b1f76c872eb7927ddaedb2de9099ae1916d74c2f
Author: Caolán McNamara <caolanm at redhat.com>
AuthorDate: Wed Sep 16 13:19:11 2020 +0100
Commit: Caolán McNamara <caolanm at redhat.com>
CommitDate: Thu Sep 17 12:26:43 2020 +0200
avoid uno:Paste in tests
clipboard is a shared resource (except for svp) so interleaved
tests are not guaranteed to get out what they put in
Change-Id: Id3ec51417b99f3420034808f6a9fd39f6bc9a89c
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/102866
Tested-by: Jenkins
Reviewed-by: Caolán McNamara <caolanm at redhat.com>
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/102909
Reviewed-by: Xisco Fauli <xiscofauli at libreoffice.org>
diff --git a/sw/qa/extras/uiwriter/uiwriter.cxx b/sw/qa/extras/uiwriter/uiwriter.cxx
index 54ae76383693..e824be2ae56c 100644
--- a/sw/qa/extras/uiwriter/uiwriter.cxx
+++ b/sw/qa/extras/uiwriter/uiwriter.cxx
@@ -1020,7 +1020,7 @@ void SwUiWriterTest::testExportRTF()
pWrtShell->Left(CRSR_SKIP_CHARS, /*bSelect=*/true, 3, /*bBasicCall=*/false);
// Create the clipboard document.
- std::shared_ptr<SwDoc> xClpDoc(new SwDoc, o3tl::default_delete<SwDoc>());
+ rtl::Reference<SwDoc> xClpDoc(new SwDoc());
xClpDoc->SetClipBoard(true);
pWrtShell->Copy(xClpDoc.get());
@@ -1309,8 +1309,16 @@ CPPUNIT_TEST_FIXTURE(SwUiWriterTest, testTdf134250)
dispatchCommand(mxComponent, ".uno:SelectAll", {});
dispatchCommand(mxComponent, ".uno:SelectAll", {});
dispatchCommand(mxComponent, ".uno:SelectAll", {});
- dispatchCommand(mxComponent, ".uno:Copy", {});
- dispatchCommand(mxComponent, ".uno:Paste", {});
+
+ // .uno:Copy without touching shared clipboard
+ SwWrtShell* pWrtShell = pTextDoc->GetDocShell()->GetWrtShell();
+ rtl::Reference<SwTransferable> xTransfer = new SwTransferable(*pWrtShell);
+ xTransfer->Copy();
+
+ // .uno:Paste without touching shared clipboard
+ TransferableDataHelper aHelper(xTransfer.get());
+ SwTransferable::Paste(*pWrtShell, aHelper);
+
Scheduler::ProcessEventsToIdle();
CPPUNIT_ASSERT_EQUAL(sal_Int32(1), xTables->getCount());
diff --git a/sw/qa/extras/uiwriter/uiwriter3.cxx b/sw/qa/extras/uiwriter/uiwriter3.cxx
index bddb827de74b..da425a13e071 100644
--- a/sw/qa/extras/uiwriter/uiwriter3.cxx
+++ b/sw/qa/extras/uiwriter/uiwriter3.cxx
@@ -13,9 +13,10 @@
#include <com/sun/star/text/TextContentAnchorType.hpp>
#include <comphelper/propertysequence.hxx>
#include <boost/property_tree/json_parser.hpp>
+#include <fmtanchr.hxx>
#include <frameformats.hxx>
+#include <swdtflvr.hxx>
#include <textboxhelper.hxx>
-#include <fmtanchr.hxx>
#include <o3tl/safeint.hxx>
#include <wrtsh.hxx>
@@ -39,11 +40,19 @@ CPPUNIT_TEST_FIXTURE(SwUiWriterTest3, testTdf129382)
CPPUNIT_ASSERT_EQUAL(8, getShapes());
CPPUNIT_ASSERT_EQUAL(2, getPages());
+
dispatchCommand(mxComponent, ".uno:SelectAll", {});
- dispatchCommand(mxComponent, ".uno:Cut", {});
+
+ SwWrtShell* pWrtShell = pTextDoc->GetDocShell()->GetWrtShell();
+ rtl::Reference<SwTransferable> xTransfer = new SwTransferable(*pWrtShell);
+ xTransfer->Cut();
+
CPPUNIT_ASSERT_EQUAL(3, getShapes());
CPPUNIT_ASSERT_EQUAL(1, getPages());
- dispatchCommand(mxComponent, ".uno:Paste", {});
+
+ TransferableDataHelper aHelper(xTransfer.get());
+ SwTransferable::Paste(*pWrtShell, aHelper);
+
CPPUNIT_ASSERT_EQUAL(8, getShapes());
CPPUNIT_ASSERT_EQUAL(2, getPages());
dispatchCommand(mxComponent, ".uno:Undo", {});
@@ -80,18 +89,27 @@ CPPUNIT_TEST_FIXTURE(SwUiWriterTest3, testTdf126626)
CPPUNIT_ASSERT(pTextDoc);
CPPUNIT_ASSERT_EQUAL(2, getShapes());
+
dispatchCommand(mxComponent, ".uno:SelectAll", {});
- dispatchCommand(mxComponent, ".uno:Copy", {});
+
+ SwWrtShell* pWrtShell = pTextDoc->GetDocShell()->GetWrtShell();
+ rtl::Reference<SwTransferable> xTransfer = new SwTransferable(*pWrtShell);
+ xTransfer->Copy();
+
CPPUNIT_ASSERT_EQUAL(2, getShapes());
- dispatchCommand(mxComponent, ".uno:Paste", {});
+
+ TransferableDataHelper aHelper(xTransfer.get());
+ SwTransferable::Paste(*pWrtShell, aHelper);
CPPUNIT_ASSERT_EQUAL(2, getShapes());
- dispatchCommand(mxComponent, ".uno:Paste", {});
+
+ SwTransferable::Paste(*pWrtShell, aHelper);
CPPUNIT_ASSERT_EQUAL(4, getShapes());
+
dispatchCommand(mxComponent, ".uno:Undo", {});
CPPUNIT_ASSERT_EQUAL(2, getShapes());
// without the fix, it crashes
- dispatchCommand(mxComponent, ".uno:Paste", {});
+ SwTransferable::Paste(*pWrtShell, aHelper);
CPPUNIT_ASSERT_EQUAL(4, getShapes());
}
@@ -131,13 +149,19 @@ CPPUNIT_TEST_FIXTURE(SwUiWriterTest3, testTdf132187)
CPPUNIT_ASSERT(pTextDoc);
CPPUNIT_ASSERT_EQUAL(1, getPages());
+
dispatchCommand(mxComponent, ".uno:SelectAll", {});
- dispatchCommand(mxComponent, ".uno:Copy", {});
+
+ SwWrtShell* pWrtShell = pTextDoc->GetDocShell()->GetWrtShell();
+ rtl::Reference<SwTransferable> xTransfer = new SwTransferable(*pWrtShell);
+ xTransfer->Copy();
+
dispatchCommand(mxComponent, ".uno:GoToEndOfDoc", {});
+ TransferableDataHelper aHelper(xTransfer.get());
for (sal_Int32 i = 0; i < 10; ++i)
{
- dispatchCommand(mxComponent, ".uno:Paste", {});
+ SwTransferable::Paste(*pWrtShell, aHelper);
Scheduler::ProcessEventsToIdle();
}
@@ -156,11 +180,19 @@ CPPUNIT_TEST_FIXTURE(SwUiWriterTest3, testTdf128739)
CPPUNIT_ASSERT(pTextDoc);
CPPUNIT_ASSERT_EQUAL(OUString("Fehler: Verweis nicht gefunden"), getParagraph(1)->getString());
+
dispatchCommand(mxComponent, ".uno:SelectAll", {});
- dispatchCommand(mxComponent, ".uno:Cut", {});
+
+ SwWrtShell* pWrtShell = pTextDoc->GetDocShell()->GetWrtShell();
+ rtl::Reference<SwTransferable> xTransfer = new SwTransferable(*pWrtShell);
+ xTransfer->Cut();
+
CPPUNIT_ASSERT_EQUAL(OUString(""), getParagraph(1)->getString());
- dispatchCommand(mxComponent, ".uno:Paste", {});
+
+ TransferableDataHelper aHelper(xTransfer.get());
+ SwTransferable::Paste(*pWrtShell, aHelper);
CPPUNIT_ASSERT_EQUAL(OUString("Fehler: Verweis nicht gefunden"), getParagraph(1)->getString());
+
// without the fix, it crashes
dispatchCommand(mxComponent, ".uno:Undo", {});
CPPUNIT_ASSERT_EQUAL(OUString(""), getParagraph(1)->getString());
@@ -174,11 +206,19 @@ CPPUNIT_TEST_FIXTURE(SwUiWriterTest3, testTdf124722)
CPPUNIT_ASSERT(pTextDoc);
CPPUNIT_ASSERT_EQUAL(22, getPages());
+
dispatchCommand(mxComponent, ".uno:SelectAll", {});
- dispatchCommand(mxComponent, ".uno:Copy", {});
+
+ SwWrtShell* pWrtShell = pTextDoc->GetDocShell()->GetWrtShell();
+ rtl::Reference<SwTransferable> xTransfer = new SwTransferable(*pWrtShell);
+ xTransfer->Copy();
+
CPPUNIT_ASSERT_EQUAL(22, getPages());
- dispatchCommand(mxComponent, ".uno:Paste", {});
+
+ TransferableDataHelper aHelper(xTransfer.get());
+ SwTransferable::Paste(*pWrtShell, aHelper);
CPPUNIT_ASSERT_EQUAL(43, getPages());
+
dispatchCommand(mxComponent, ".uno:Undo", {});
CPPUNIT_ASSERT_EQUAL(22, getPages());
}
@@ -337,11 +377,17 @@ CPPUNIT_TEST_FIXTURE(SwUiWriterTest3, testTdf107975)
CPPUNIT_ASSERT_EQUAL(sal_Int32(1), xIndexAccess->getCount());
dispatchCommand(mxComponent, ".uno:SelectAll", {});
- dispatchCommand(mxComponent, ".uno:Copy", {});
+
+ SwWrtShell* pWrtShell = pTextDoc->GetDocShell()->GetWrtShell();
+ rtl::Reference<SwTransferable> xTransfer = new SwTransferable(*pWrtShell);
+ xTransfer->Copy();
//Position the mouse cursor (caret) after "ABC" below the blue image
dispatchCommand(mxComponent, ".uno:GoRight", {});
- dispatchCommand(mxComponent, ".uno:Paste", {});
+ {
+ TransferableDataHelper aHelper(xTransfer.get());
+ SwTransferable::Paste(*pWrtShell, aHelper);
+ }
// without the fix, it crashes
CPPUNIT_ASSERT_EQUAL(sal_Int32(2), xIndexAccess->getCount());
@@ -369,11 +415,16 @@ CPPUNIT_TEST_FIXTURE(SwUiWriterTest3, testTdf107975)
CPPUNIT_ASSERT_EQUAL(sal_Int32(1), xIndexAccess->getCount());
dispatchCommand(mxComponent, ".uno:SelectAll", {});
- dispatchCommand(mxComponent, ".uno:Copy", {});
+
+ xTransfer.set(new SwTransferable(*pWrtShell));
+ xTransfer->Copy();
//Position the mouse cursor (caret) after "ABC" below the blue image
dispatchCommand(mxComponent, ".uno:GoRight", {});
- dispatchCommand(mxComponent, ".uno:Paste", {});
+ {
+ TransferableDataHelper aHelper(xTransfer.get());
+ SwTransferable::Paste(*pWrtShell, aHelper);
+ }
// without the fix, it crashes
CPPUNIT_ASSERT_EQUAL(sal_Int32(2), xIndexAccess->getCount());
@@ -436,8 +487,11 @@ CPPUNIT_TEST_FIXTURE(SwUiWriterTest3, testTdf129805)
CPPUNIT_ASSERT_EQUAL(OUString("x"), getParagraph(1)->getString());
dispatchCommand(mxComponent, ".uno:SelectAll", {});
+
+ SwWrtShell* pWrtShell = pTextDoc->GetDocShell()->GetWrtShell();
+ rtl::Reference<SwTransferable> xTransfer = new SwTransferable(*pWrtShell);
// without the fix in place, it would crash here
- dispatchCommand(mxComponent, ".uno:Cut", {});
+ xTransfer->Cut();
CPPUNIT_ASSERT_EQUAL(OUString(""), getParagraph(1)->getString());
dispatchCommand(mxComponent, ".uno:Undo", {});
@@ -453,12 +507,17 @@ CPPUNIT_TEST_FIXTURE(SwUiWriterTest3, testTdf130685)
CPPUNIT_ASSERT_EQUAL(2, getPages());
dispatchCommand(mxComponent, ".uno:SelectAll", {});
- dispatchCommand(mxComponent, ".uno:Cut", {});
+
+ SwWrtShell* pWrtShell = pTextDoc->GetDocShell()->GetWrtShell();
+ rtl::Reference<SwTransferable> xTransfer = new SwTransferable(*pWrtShell);
+ xTransfer->Cut();
Scheduler::ProcessEventsToIdle();
+
CPPUNIT_ASSERT_EQUAL(1, getPages());
- dispatchCommand(mxComponent, ".uno:Paste", {});
- dispatchCommand(mxComponent, ".uno:Paste", {});
+ TransferableDataHelper aHelper(xTransfer.get());
+ SwTransferable::Paste(*pWrtShell, aHelper);
+ SwTransferable::Paste(*pWrtShell, aHelper);
// Without fix in place, this test would have failed with:
//- Expected: 2
@@ -511,13 +570,24 @@ CPPUNIT_TEST_FIXTURE(SwUiWriterTest3, testTdf130680)
dispatchCommand(mxComponent, ".uno:SelectAll", {});
+ rtl::Reference<SwDoc> xClpDoc(new SwDoc());
+ xClpDoc->SetClipBoard(true);
+
+ SwWrtShell* pWrtShell = pTextDoc->GetDocShell()->GetWrtShell();
+ rtl::Reference<SwTransferable> xTransfer = new SwTransferable(*pWrtShell);
// without the fix, it crashes
- dispatchCommand(mxComponent, ".uno:Cut", {});
+ xTransfer->Cut();
+
CPPUNIT_ASSERT_EQUAL(sal_Int32(0), xIndexAccess->getCount());
- dispatchCommand(mxComponent, ".uno:Paste", {});
+
+ TransferableDataHelper aHelper(xTransfer.get());
+ SwTransferable::Paste(*pWrtShell, aHelper);
CPPUNIT_ASSERT_EQUAL(sal_Int32(1), xIndexAccess->getCount());
+ xClpDoc.clear();
+
dispatchCommand(mxComponent, ".uno:Undo", {});
CPPUNIT_ASSERT_EQUAL(sal_Int32(0), xIndexAccess->getCount());
+
dispatchCommand(mxComponent, ".uno:Undo", {});
CPPUNIT_ASSERT_EQUAL(sal_Int32(23), xIndexAccess->getCount());
}
@@ -539,13 +609,17 @@ CPPUNIT_TEST_FIXTURE(SwUiWriterTest3, testTdf131684)
dispatchCommand(mxComponent, ".uno:SelectAll", {});
dispatchCommand(mxComponent, ".uno:SelectAll", {});
- dispatchCommand(mxComponent, ".uno:Cut", {});
+ SwWrtShell* pWrtShell = pTextDoc->GetDocShell()->GetWrtShell();
+ rtl::Reference<SwTransferable> xTransfer = new SwTransferable(*pWrtShell);
+ xTransfer->Cut();
+ Scheduler::ProcessEventsToIdle();
CPPUNIT_ASSERT_EQUAL(sal_Int32(0), xIndexAccess->getCount());
dispatchCommand(mxComponent, ".uno:Undo", {});
CPPUNIT_ASSERT_EQUAL(sal_Int32(1), xIndexAccess->getCount());
- dispatchCommand(mxComponent, ".uno:Paste", {});
+ TransferableDataHelper aHelper(xTransfer.get());
+ SwTransferable::Paste(*pWrtShell, aHelper);
CPPUNIT_ASSERT_EQUAL(sal_Int32(1), xIndexAccess->getCount());
// without the fix, it crashes
@@ -886,17 +960,21 @@ CPPUNIT_TEST_FIXTURE(SwUiWriterTest3, testTdf133490)
CPPUNIT_ASSERT_EQUAL(1, getShapes());
dispatchCommand(mxComponent, ".uno:SelectAll", {});
- dispatchCommand(mxComponent, ".uno:Cut", {});
+
+ SwWrtShell* pWrtShell = pTextDoc->GetDocShell()->GetWrtShell();
+ rtl::Reference<SwTransferable> xTransfer = new SwTransferable(*pWrtShell);
+ xTransfer->Cut();
Scheduler::ProcessEventsToIdle();
CPPUNIT_ASSERT_EQUAL(0, getShapes());
- dispatchCommand(mxComponent, ".uno:Paste", {});
+ TransferableDataHelper aHelper(xTransfer.get());
+ SwTransferable::Paste(*pWrtShell, aHelper);
Scheduler::ProcessEventsToIdle();
CPPUNIT_ASSERT_EQUAL(1, getShapes());
- dispatchCommand(mxComponent, ".uno:Paste", {});
+ SwTransferable::Paste(*pWrtShell, aHelper);
Scheduler::ProcessEventsToIdle();
CPPUNIT_ASSERT_EQUAL(2, getShapes());
More information about the Libreoffice-commits
mailing list