[Libreoffice-commits] online.git: test/httpwstest.cpp test/Makefile.am test/run_unit.sh.in test/UnitLargePaste.cpp
Miklos Vajna (via logerrit)
logerrit at kemper.freedesktop.org
Tue Oct 8 06:51:22 UTC 2019
test/Makefile.am | 4 ++
test/UnitLargePaste.cpp | 71 ++++++++++++++++++++++++++++++++++++++++++++++++
test/httpwstest.cpp | 38 -------------------------
test/run_unit.sh.in | 2 -
4 files changed, 76 insertions(+), 39 deletions(-)
New commits:
commit a6eff7ed2dd71fa0cece102832d1032c6f33010f
Author: Miklos Vajna <vmiklos at collabora.com>
AuthorDate: Tue Oct 8 08:50:05 2019 +0200
Commit: Miklos Vajna <vmiklos at collabora.com>
CommitDate: Tue Oct 8 08:51:03 2019 +0200
Convert large paste testcase to a new-style one
And fix run_unit.sh to to do the quoting properly, so -la does not match
the \.la pattern.
Change-Id: I6fd81166abc43f87d82123c104ee4e74238bd714
diff --git a/test/Makefile.am b/test/Makefile.am
index 9d1bd5aa3..309b159c7 100644
--- a/test/Makefile.am
+++ b/test/Makefile.am
@@ -22,6 +22,7 @@ noinst_LTLIBRARIES = \
unit-wopi-ownertermination.la unit-wopi-versionrestore.la \
unit-wopi-documentconflict.la unit_wopi_renamefile.la \
unit-tiff-load.la \
+ unit-large-paste.la \
unit-wopi-loadencoded.la unit-wopi-temp.la
MAGIC_TO_FORCE_SHLIB_CREATION = -rpath /dummy
@@ -122,6 +123,8 @@ unit_wopi_temp_la_SOURCES = UnitWOPITemplate.cpp
unit_wopi_temp_la_LIBADD = $(CPPUNIT_LIBS)
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)
if HAVE_LO_PATH
SYSTEM_STAMP = @SYSTEMPLATE_PATH@/system_stamp
@@ -142,6 +145,7 @@ TESTS = unit-copy-paste.la unit-typing.la unit-convert.la unit-prefork.la unit-t
unit-wopi-documentconflict.la unit_wopi_renamefile.la \
unit-http.la \
unit-tiff-load.la \
+ unit-large-paste.la \
unit-wopi-loadencoded.la unit-wopi-temp.la
# TESTS = unit-client.la
# TESTS += unit-admin.la
diff --git a/test/UnitLargePaste.cpp b/test/UnitLargePaste.cpp
new file mode 100644
index 000000000..5665611e7
--- /dev/null
+++ b/test/UnitLargePaste.cpp
@@ -0,0 +1,71 @@
+/* -*- 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;
+
+/// Large paste testcase.
+class UnitLargePaste : public UnitWSD
+{
+public:
+ UnitLargePaste();
+
+ void invokeTest() override;
+};
+
+UnitLargePaste::UnitLargePaste() {}
+
+void UnitLargePaste::invokeTest()
+{
+ const char testname[] = "UnitLargePaste";
+
+ // 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);
+
+ helpers::sendTextFrame(socket, "uno .uno:SelectAll", testname);
+ helpers::sendTextFrame(socket, "uno .uno:Delete", testname);
+
+ // Paste some text into it.
+ std::ostringstream oss;
+ for (int i = 0; i < 1000; ++i)
+ {
+ oss << Util::encodeId(Util::rng::getNext(), 6);
+ }
+
+ const std::string documentContents = oss.str();
+ TST_LOG("Pasting " << documentContents.size() << " characters into document.");
+ helpers::sendTextFrame(socket, "paste mimetype=text/html\n" + documentContents, testname);
+
+ // Check if the server is still alive.
+ // This resulted first in a hang, as respose for the message never arrived, then a bit later in a Poco::TimeoutException.
+ 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_MESSAGE("Pasted text was either corrupted or couldn't be read back",
+ "textselectioncontent: " + documentContents, selection);
+
+ exitTest(TestResult::Ok);
+}
+
+UnitBase* unit_create_wsd(void) { return new UnitLargePaste(); }
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/test/httpwstest.cpp b/test/httpwstest.cpp
index 08a06edfb..b95a86842 100644
--- a/test/httpwstest.cpp
+++ b/test/httpwstest.cpp
@@ -103,7 +103,6 @@ class HTTPWSTest : public CPPUNIT_NS::TestFixture
CPPUNIT_TEST(testExcelLoad);
CPPUNIT_TEST(testPaste);
CPPUNIT_TEST(testPasteBlank);
- CPPUNIT_TEST(testLargePaste);
CPPUNIT_TEST(testRenderingOptions);
CPPUNIT_TEST(testPasswordProtectedDocumentWithoutPassword);
CPPUNIT_TEST(testPasswordProtectedDocumentWithWrongPassword);
@@ -163,7 +162,6 @@ class HTTPWSTest : public CPPUNIT_NS::TestFixture
void testExcelLoad();
void testPaste();
void testPasteBlank();
- void testLargePaste();
void testRenderingOptions();
void testPasswordProtectedDocumentWithoutPassword();
void testPasswordProtectedDocumentWithWrongPassword();
@@ -948,42 +946,6 @@ void HTTPWSTest::testPasteBlank()
}
}
-void HTTPWSTest::testLargePaste()
-{
- const char* testname = "LargePaste ";
- try
- {
- // Load a document and make it empty, then paste some text into it.
- std::shared_ptr<LOOLWebSocket> socket = loadDocAndGetSocket("hello.odt", _uri, testname);
-
- sendTextFrame(socket, "uno .uno:SelectAll", testname);
- sendTextFrame(socket, "uno .uno:Delete", testname);
-
- // Paste some text into it.
- std::ostringstream oss;
- for (int i = 0; i < 1000; ++i)
- {
- oss << Util::encodeId(Util::rng::getNext(), 6);
- }
-
- const std::string documentContents = oss.str();
- TST_LOG("Pasting " << documentContents.size() << " characters into document.");
- sendTextFrame(socket, "paste mimetype=text/html\n" + documentContents, testname);
-
- // Check if the server is still alive.
- // This resulted first in a hang, as respose for the message never arrived, then a bit later in a Poco::TimeoutException.
- 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_MESSAGE("Pasted text was either corrupted or couldn't be read back",
- "textselectioncontent: " + documentContents == selection);
- }
- catch (const Poco::Exception& exc)
- {
- CPPUNIT_FAIL(exc.displayText());
- }
-}
-
void HTTPWSTest::testRenderingOptions()
{
const char* testname = "renderingOptions ";
diff --git a/test/run_unit.sh.in b/test/run_unit.sh.in
index 5af9affd8..d8f957caf 100755
--- a/test/run_unit.sh.in
+++ b/test/run_unit.sh.in
@@ -54,7 +54,7 @@ echo "Running ${tst}"
echo " $cmd_line"
# drop .la suffix
-tst=`echo $tst | sed s/\.la//`;
+tst=`echo $tst | sed "s/\.la//"`;
if test "z$tst" != "z" && test "z$CPPUNIT_TEST_NAME" != "z"; then
# $tst is not empty, but $CPPUNIT_TEST_NAME is set, exit early if they
More information about the Libreoffice-commits
mailing list