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

Miklos Vajna vmiklos at collabora.co.uk
Tue Jan 19 05:55:17 PST 2016


 desktop/qa/data/paste.jpg                   |binary
 desktop/qa/desktop_lib/test_desktop_lib.cxx |   24 ++++++++++++++++++++++++
 2 files changed, 24 insertions(+)

New commits:
commit 802564e036db1ee3df8b19593b7f9f1be0deec54
Author: Miklos Vajna <vmiklos at collabora.co.uk>
Date:   Tue Jan 19 14:29:33 2016 +0100

    CppunitTest_desktop_lib: add jpeg paste testcase
    
    Fails without commit 27c6b8586d5d2cd1fa5425b4969d915a0b739475 (svtools:
    implement clipboard import of JPEG files, 2016-01-19).
    
    Change-Id: Ic4e3b036b3a6a1c294bf15ef0b206cf1e458fc4e

diff --git a/desktop/qa/data/paste.jpg b/desktop/qa/data/paste.jpg
new file mode 100644
index 0000000..ca9183e
Binary files /dev/null and b/desktop/qa/data/paste.jpg differ
diff --git a/desktop/qa/desktop_lib/test_desktop_lib.cxx b/desktop/qa/desktop_lib/test_desktop_lib.cxx
index 01657b9..d55ae37 100644
--- a/desktop/qa/desktop_lib/test_desktop_lib.cxx
+++ b/desktop/qa/desktop_lib/test_desktop_lib.cxx
@@ -14,6 +14,7 @@
 #include <com/sun/star/awt/Key.hpp>
 #include <com/sun/star/awt/XReschedule.hpp>
 #include <com/sun/star/awt/Toolkit.hpp>
+#include <com/sun/star/drawing/XDrawPageSupplier.hpp>
 #include <boost/property_tree/json_parser.hpp>
 #include <comphelper/processfactory.hxx>
 #include <sfx2/objsh.hxx>
@@ -74,6 +75,7 @@ public:
     void testSaveAs();
     void testSaveAsCalc();
     void testPasteWriter();
+    void testPasteWriterJPEG();
     void testRowColumnHeaders();
     void testCellCursor();
     void testCommandResult();
@@ -91,6 +93,7 @@ public:
     CPPUNIT_TEST(testSaveAs);
     CPPUNIT_TEST(testSaveAsCalc);
     CPPUNIT_TEST(testPasteWriter);
+    CPPUNIT_TEST(testPasteWriterJPEG);
     CPPUNIT_TEST(testRowColumnHeaders);
     CPPUNIT_TEST(testCellCursor);
     CPPUNIT_TEST(testCommandResult);
@@ -409,6 +412,27 @@ void DesktopLOKTest::testPasteWriter()
     comphelper::LibreOfficeKit::setActive(false);
 }
 
+void DesktopLOKTest::testPasteWriterJPEG()
+{
+    comphelper::LibreOfficeKit::setActive();
+    LibLODocument_Impl* pDocument = loadDoc("blank_text.odt");
+    OString aText("hello");
+
+    OUString aFileURL;
+    createFileURL(OUString::createFromAscii("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()));
+
+    uno::Reference<drawing::XDrawPageSupplier> xDrawPageSupplier(mxComponent, uno::UNO_QUERY);
+    uno::Reference<drawing::XDrawPage> xDrawPage = xDrawPageSupplier->getDrawPage();
+    // This was 0, JPEG was not handled as a format for clipboard paste.
+    CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32>(1), xDrawPage->getCount());
+
+    comphelper::LibreOfficeKit::setActive(false);
+}
+
 void DesktopLOKTest::testRowColumnHeaders()
 {
     /*


More information about the Libreoffice-commits mailing list