test/Makefile.am    |    4 +++
 test/UnitPaste.cpp  |   65 ++++++++++++++++++++++++++++++++++++++++++++++++++++
 test/httpwstest.cpp |   30 ------------------------
 3 files changed, 69 insertions(+), 30 deletions(-)

New commits:
commit b97789eb76b63ea2b2fe073a9a4fbd918719a98b
Author:     Miklos Vajna <vmik...@collabora.com>
AuthorDate: Fri Oct 18 09:06:53 2019 +0200
Commit:     Miklos Vajna <vmik...@collabora.com>
CommitDate: Fri Oct 18 09:06:53 2019 +0200

    Convert paste testcase to a new-style one
    
    Change-Id: Ie4d8c2431bc12b94af83b802d4a627cbfb7a72e0

diff --git a/test/Makefile.am b/test/Makefile.am
index 309b159c7..a4f1eb96f 100644
--- a/test/Makefile.am
+++ b/test/Makefile.am
@@ -23,6 +23,7 @@ noinst_LTLIBRARIES = \
        unit-wopi-documentconflict.la unit_wopi_renamefile.la \
        unit-tiff-load.la \
        unit-large-paste.la \
+       unit-paste.la \
        unit-wopi-loadencoded.la unit-wopi-temp.la
 
 MAGIC_TO_FORCE_SHLIB_CREATION = -rpath /dummy
@@ -125,6 +126,8 @@ unit_tiff_load_la_SOURCES = UnitTiffLoad.cpp
 unit_tiff_load_la_LIBADD = $(CPPUNIT_LIBS)
 unit_large_paste_la_SOURCES = UnitLargePaste.cpp
 unit_large_paste_la_LIBADD = $(CPPUNIT_LIBS)
+unit_paste_la_SOURCES = UnitPaste.cpp
+unit_paste_la_LIBADD = $(CPPUNIT_LIBS)
 
 if HAVE_LO_PATH
 SYSTEM_STAMP = @SYSTEMPLATE_PATH@/system_stamp
@@ -146,6 +149,7 @@ TESTS = unit-copy-paste.la unit-typing.la unit-convert.la 
unit-prefork.la unit-t
        unit-http.la \
        unit-tiff-load.la \
        unit-large-paste.la \
+       unit-paste.la \
        unit-wopi-loadencoded.la unit-wopi-temp.la
 # TESTS = unit-client.la
 # TESTS += unit-admin.la
diff --git a/test/UnitPaste.cpp b/test/UnitPaste.cpp
new file mode 100644
index 000000000..4bf89361f
--- /dev/null
+++ b/test/UnitPaste.cpp
@@ -0,0 +1,65 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4; 
fill-column: 100 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * 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/.
+ */
+
+#include <memory>
+#include <string>
+
+#include <Poco/URI.h>
+#include <cppunit/TestAssert.h>
+
+#include <Unit.hpp>
+#include <Util.hpp>
+#include <helpers.hpp>
+
+class LOOLWebSocket;
+
+/// Paste testcase.
+class UnitPaste : public UnitWSD
+{
+public:
+    void invokeTest() override;
+};
+
+void UnitPaste::invokeTest()
+{
+    const char testname[] = "UnitPaste";
+
+    // Load a document and make it empty, then paste some text into it.
+    std::string documentPath;
+    std::string documentURL;
+    helpers::getDocumentPathAndURL("hello.odt", documentPath, documentURL, 
testname);
+    std::shared_ptr<LOOLWebSocket> socket = helpers::loadDocAndGetSocket(
+        Poco::URI(helpers::getTestServerURI()), documentURL, testname);
+
+    for (int i = 0; i < 5; ++i)
+    {
+        const std::string text = std::to_string(i + 1) + 
"_sh9le[;\"CFD7U[#B+_nW=$kXgx{sv9QE#\"l1y\"hr_" + 
Util::encodeId(Util::rng::getNext());
+        TST_LOG("Pasting text #" << i + 1 << ": " << text);
+
+        // Always delete everything to have an empty doc.
+        helpers::sendTextFrame(socket, "uno .uno:SelectAll", testname);
+        helpers::sendTextFrame(socket, "uno .uno:Delete", testname);
+
+        // Paste some text into it.
+        helpers::sendTextFrame(socket, "paste 
mimetype=text/plain;charset=utf-8\n" + text, testname);
+        const std::string expected = "textselectioncontent: " + text;
+
+        // Check if the document contains the pasted text.
+        helpers::sendTextFrame(socket, "uno .uno:SelectAll", testname);
+        helpers::sendTextFrame(socket, "gettextselection 
mimetype=text/plain;charset=utf-8", testname);
+        const auto selection = helpers::assertResponseString(socket, 
"textselectioncontent:", testname);
+        CPPUNIT_ASSERT_EQUAL(expected, selection);
+    }
+
+    exitTest(TestResult::Ok);
+}
+
+UnitBase* unit_create_wsd(void) { return new UnitPaste(); }
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/test/httpwstest.cpp b/test/httpwstest.cpp
index 5fac32874..64f211cb8 100644
--- a/test/httpwstest.cpp
+++ b/test/httpwstest.cpp
@@ -101,7 +101,6 @@ class HTTPWSTest : public CPPUNIT_NS::TestFixture
     CPPUNIT_TEST(testSavePassiveOnDisconnect);
     CPPUNIT_TEST(testReloadWhileDisconnecting);
     CPPUNIT_TEST(testExcelLoad);
-    CPPUNIT_TEST(testPaste);
     CPPUNIT_TEST(testPasteBlank);
     CPPUNIT_TEST(testRenderingOptions);
     CPPUNIT_TEST(testPasswordProtectedDocumentWithoutPassword);
@@ -160,7 +159,6 @@ class HTTPWSTest : public CPPUNIT_NS::TestFixture
     void testSavePassiveOnDisconnect();
     void testReloadWhileDisconnecting();
     void testExcelLoad();
-    void testPaste();
     void testPasteBlank();
     void testRenderingOptions();
     void testPasswordProtectedDocumentWithoutPassword();
@@ -892,34 +890,6 @@ void HTTPWSTest::testExcelLoad()
     }
 }
 
-void HTTPWSTest::testPaste()
-{
-    const char* testname = "paste ";
-
-    // Load a document and make it empty, then paste some text into it.
-    std::shared_ptr<LOOLWebSocket> socket = loadDocAndGetSocket("hello.odt", 
_uri, testname);
-
-    for (int i = 0; i < 5; ++i)
-    {
-        const std::string text = std::to_string(i + 1) + 
"_sh9le[;\"CFD7U[#B+_nW=$kXgx{sv9QE#\"l1y\"hr_" + 
Util::encodeId(Util::rng::getNext());
-        TST_LOG("Pasting text #" << i + 1 << ": " << text);
-
-        // Always delete everything to have an empty doc.
-        sendTextFrame(socket, "uno .uno:SelectAll", testname);
-        sendTextFrame(socket, "uno .uno:Delete", testname);
-
-        // Paste some text into it.
-        sendTextFrame(socket, "paste mimetype=text/plain;charset=utf-8\n" + 
text, testname);
-        const std::string expected = "textselectioncontent: " + text;
-
-        // Check if the document contains the pasted text.
-        sendTextFrame(socket, "uno .uno:SelectAll", testname);
-        sendTextFrame(socket, "gettextselection 
mimetype=text/plain;charset=utf-8", testname);
-        const auto selection = assertResponseString(socket, 
"textselectioncontent:", testname);
-        CPPUNIT_ASSERT_EQUAL(expected, selection);
-    }
-}
-
 void HTTPWSTest::testPasteBlank()
 {
     const char* testname = "pasteBlank ";
_______________________________________________
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits

Reply via email to