[Libreoffice-commits] core.git: Branch 'private/mmeeks/copypaste' - desktop/qa
Michael Meeks (via logerrit)
logerrit at kemper.freedesktop.org
Tue May 28 08:39:04 UTC 2019
desktop/qa/desktop_lib/test_desktop_lib.cxx | 31 ++++++++++++++++++++++++++++
1 file changed, 31 insertions(+)
New commits:
commit 00d730f6260b6fcfafb0ce4d185a0866c2eae2cb
Author: Michael Meeks <michael.meeks at collabora.com>
AuthorDate: Tue May 28 09:38:19 2019 +0100
Commit: Michael Meeks <michael.meeks at collabora.com>
CommitDate: Tue May 28 09:38:19 2019 +0100
Actually add the unit test.
Change-Id: I9ff4873fbcd7ea6c0d527a21777af0a2b5190c76
diff --git a/desktop/qa/desktop_lib/test_desktop_lib.cxx b/desktop/qa/desktop_lib/test_desktop_lib.cxx
index 2a9aefe746b8..a068137af535 100644
--- a/desktop/qa/desktop_lib/test_desktop_lib.cxx
+++ b/desktop/qa/desktop_lib/test_desktop_lib.cxx
@@ -101,6 +101,7 @@ public:
void testSaveAsCalc();
void testPasteWriter();
void testPasteWriterJPEG();
+ void testRichPaste();
void testUndoWriter();
void testRowColumnHeaders();
void testHiddenRowHeaders();
@@ -152,6 +153,7 @@ public:
CPPUNIT_TEST(testSaveAsCalc);
CPPUNIT_TEST(testPasteWriter);
CPPUNIT_TEST(testPasteWriterJPEG);
+ CPPUNIT_TEST(testRichPaste);
CPPUNIT_TEST(testUndoWriter);
CPPUNIT_TEST(testRowColumnHeaders);
CPPUNIT_TEST(testHiddenRowHeaders);
@@ -638,6 +640,35 @@ void DesktopLOKTest::testPasteWriterJPEG()
CPPUNIT_ASSERT_EQUAL(text::TextContentAnchorType_AT_CHARACTER, xShape->getPropertyValue("AnchorType").get<text::TextContentAnchorType>());
}
+void DesktopLOKTest::testRichPaste()
+{
+ comphelper::LibreOfficeKit::setActive();
+
+ LibLODocument_Impl* pDocument = loadDoc("blank_text.odt");
+
+ OUString aFileURL;
+ createFileURL("paste.jpg", aFileURL);
+ std::ifstream aImageStream(aFileURL.toUtf8().copy(strlen("file://")).getStr());
+ std::vector<char> aImageContents((std::istreambuf_iterator<char>(aImageStream)), std::istreambuf_iterator<char>());
+ CPPUNIT_ASSERT(pDocument->pClass->paste(pDocument, "image/jpeg", aImageContents.data(), aImageContents.size()));
+
+ pDocument->pClass->postUnoCommand(pDocument, ".uno:SelectAll", nullptr, false);
+ Scheduler::ProcessEventsToIdle();
+
+ const char *pMadMime = "application/x-openoffice-embed-source-xml;windows_formatname=\"Star Embed Source (XML)\"";
+ size_t nSize = 0;
+ char *pUsedMime = 0;
+ char *pData = pDocument->pClass->getBinarySelection(pDocument, pMadMime, &nSize, &pUsedMime);
+ CPPUNIT_ASSERT(nSize > 0);
+ CPPUNIT_ASSERT(pData != nullptr);
+ CPPUNIT_ASSERT(pUsedMime && !strcmp(pUsedMime, pMadMime));
+
+ LibLODocument_Impl* pDocument2 = loadDoc("blank_text.odt");
+ CPPUNIT_ASSERT(pDocument->pClass->paste(pDocument2, pMadMime, pData, nSize));
+
+ // FIXME: validate the paste actually occurred: which is the problem ...
+}
+
void DesktopLOKTest::testUndoWriter()
{
// Load a Writer document and press a key.
More information about the Libreoffice-commits
mailing list