test/Makefile.am | 4 ++ test/UnitRenderingOptions.cpp | 74 ++++++++++++++++++++++++++++++++++++++++++ test/httpwstest.cpp | 37 --------------------- 3 files changed, 78 insertions(+), 37 deletions(-)
New commits: commit cdec2c78700a77a1a927ec1ff7ea2d1751505da8 Author: Miklos Vajna <vmik...@collabora.com> AuthorDate: Fri Oct 25 08:54:46 2019 +0200 Commit: Miklos Vajna <vmik...@collabora.com> CommitDate: Fri Oct 25 08:54:46 2019 +0200 Convert rendering options to a new-style one So that they are in-process, which means it's easier to debug when they fail. Change-Id: I817812eaeaffea4de8bb3a90466d815d4047372c diff --git a/test/Makefile.am b/test/Makefile.am index b2cf87b2d..cb5d1dac6 100644 --- a/test/Makefile.am +++ b/test/Makefile.am @@ -25,6 +25,7 @@ noinst_LTLIBRARIES = \ unit-large-paste.la \ unit-paste.la \ unit-load-torture.la \ + unit-rendering-options.la \ unit-wopi-loadencoded.la unit-wopi-temp.la MAGIC_TO_FORCE_SHLIB_CREATION = -rpath /dummy @@ -131,6 +132,8 @@ unit_paste_la_SOURCES = UnitPaste.cpp unit_paste_la_LIBADD = $(CPPUNIT_LIBS) unit_load_torture_la_SOURCES = UnitLoadTorture.cpp unit_load_torture_la_LIBADD = $(CPPUNIT_LIBS) +unit_rendering_options_la_SOURCES = UnitRenderingOptions.cpp +unit_rendering_options_la_LIBADD = $(CPPUNIT_LIBS) if HAVE_LO_PATH SYSTEM_STAMP = @SYSTEMPLATE_PATH@/system_stamp @@ -154,6 +157,7 @@ TESTS = unit-copy-paste.la unit-typing.la unit-convert.la unit-prefork.la unit-t unit-large-paste.la \ unit-paste.la \ unit-load-torture.la \ + unit-rendering-options.la \ unit-wopi-loadencoded.la unit-wopi-temp.la # TESTS = unit-client.la # TESTS += unit-admin.la diff --git a/test/UnitRenderingOptions.cpp b/test/UnitRenderingOptions.cpp new file mode 100644 index 000000000..526eed06c --- /dev/null +++ b/test/UnitRenderingOptions.cpp @@ -0,0 +1,74 @@ +/* -*- 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; + +/// Rendering options testcase. +class UnitRenderingOptions : public UnitWSD +{ +public: + void invokeTest() override; +}; + +void UnitRenderingOptions::invokeTest() +{ + const char testname[] = "UnitRenderingOptions"; + + try + { + // Load a document and make it empty, then paste some text into it. + std::string documentPath; + std::string documentURL; + helpers::getDocumentPathAndURL("hide-whitespace.odt", documentPath, documentURL, testname); + + const std::string options + = "{\"rendering\":{\".uno:HideWhitespace\":{\"type\":\"boolean\",\"value\":\"true\"}}}"; + + Poco::Net::HTTPRequest request(Poco::Net::HTTPRequest::HTTP_GET, documentURL); + Poco::Net::HTTPResponse response; + std::shared_ptr<LOOLWebSocket> socket = helpers::connectLOKit( + Poco::URI(helpers::getTestServerURI()), request, response, testname); + + helpers::sendTextFrame(socket, "load url=" + documentURL + " options=" + options); + helpers::sendTextFrame(socket, "status"); + const auto status = helpers::assertResponseString(socket, "status:", testname); + + // Expected format is something like 'status: type=text parts=2 current=0 width=12808 height=1142'. + Poco::StringTokenizer tokens( + status, " ", Poco::StringTokenizer::TOK_IGNORE_EMPTY | Poco::StringTokenizer::TOK_TRIM); + CPPUNIT_ASSERT_EQUAL(static_cast<size_t>(7), tokens.count()); + + const std::string token = tokens[5]; + const std::string prefix = "height="; + CPPUNIT_ASSERT_EQUAL(static_cast<size_t>(0), token.find(prefix)); + const int height = std::stoi(token.substr(prefix.size())); + // HideWhitespace was ignored, this was 32532, should be around 16706. + CPPUNIT_ASSERT(height < 20000); + } + catch (const Poco::Exception& exc) + { + CPPUNIT_FAIL(exc.displayText()); + } + + exitTest(TestResult::Ok); +} + +UnitBase* unit_create_wsd(void) { return new UnitRenderingOptions(); } + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/test/httpwstest.cpp b/test/httpwstest.cpp index a934af15a..cb2ea5d27 100644 --- a/test/httpwstest.cpp +++ b/test/httpwstest.cpp @@ -98,7 +98,6 @@ class HTTPWSTest : public CPPUNIT_NS::TestFixture CPPUNIT_TEST(testReloadWhileDisconnecting); CPPUNIT_TEST(testExcelLoad); CPPUNIT_TEST(testPasteBlank); - CPPUNIT_TEST(testRenderingOptions); CPPUNIT_TEST(testPasswordProtectedDocumentWithoutPassword); CPPUNIT_TEST(testPasswordProtectedDocumentWithWrongPassword); CPPUNIT_TEST(testPasswordProtectedDocumentWithCorrectPassword); @@ -152,7 +151,6 @@ class HTTPWSTest : public CPPUNIT_NS::TestFixture void testReloadWhileDisconnecting(); void testExcelLoad(); void testPasteBlank(); - void testRenderingOptions(); void testPasswordProtectedDocumentWithoutPassword(); void testPasswordProtectedDocumentWithWrongPassword(); void testPasswordProtectedDocumentWithCorrectPassword(); @@ -746,41 +744,6 @@ void HTTPWSTest::testPasteBlank() } } -void HTTPWSTest::testRenderingOptions() -{ - const char* testname = "renderingOptions "; - try - { - // Load a document and get its size. - std::string documentPath, documentURL; - getDocumentPathAndURL("hide-whitespace.odt", documentPath, documentURL, testname); - - const std::string options = "{\"rendering\":{\".uno:HideWhitespace\":{\"type\":\"boolean\",\"value\":\"true\"}}}"; - - Poco::Net::HTTPRequest request(Poco::Net::HTTPRequest::HTTP_GET, documentURL); - std::shared_ptr<LOOLWebSocket> socket = connectLOKit(_uri, request, _response, testname); - - sendTextFrame(socket, "load url=" + documentURL + " options=" + options); - sendTextFrame(socket, "status"); - const auto status = assertResponseString(socket, "status:", testname); - - // Expected format is something like 'status: type=text parts=2 current=0 width=12808 height=1142'. - Poco::StringTokenizer tokens(status, " ", Poco::StringTokenizer::TOK_IGNORE_EMPTY | Poco::StringTokenizer::TOK_TRIM); - CPPUNIT_ASSERT_EQUAL(static_cast<size_t>(7), tokens.count()); - - const std::string token = tokens[5]; - const std::string prefix = "height="; - CPPUNIT_ASSERT_EQUAL(static_cast<size_t>(0), token.find(prefix)); - const int height = std::stoi(token.substr(prefix.size())); - // HideWhitespace was ignored, this was 32532, should be around 16706. - CPPUNIT_ASSERT(height < 20000); - } - catch (const Poco::Exception& exc) - { - CPPUNIT_FAIL(exc.displayText()); - } -} - void HTTPWSTest::testPasswordProtectedDocumentWithoutPassword() { const char* testname = "passwordProtectedDocumentWithoutPassword "; _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits