test/Makefile.am | 4 test/UnitUNOCommand.cpp | 279 ++++++++++++++++++++++++++++++++++++++++++++++++ test/httpwstest.cpp | 225 -------------------------------------- 3 files changed, 283 insertions(+), 225 deletions(-)
New commits: commit 703eb28a979fae70bc49204d870c46084921fb58 Author: Miklos Vajna <[email protected]> AuthorDate: Mon Nov 18 08:56:35 2019 +0100 Commit: Miklos Vajna <[email protected]> CommitDate: Mon Nov 18 08:56:41 2019 +0100 Convert "uno command" tests to a new-style one So that they are in-process, which means it's easier to debug when they fail. Change-Id: I79eaa8014deda25ae31b0ad5ff38a8023ef0ae3e diff --git a/test/Makefile.am b/test/Makefile.am index 2faf25138..30632a1f6 100644 --- a/test/Makefile.am +++ b/test/Makefile.am @@ -30,6 +30,7 @@ noinst_LTLIBRARIES = \ unit-render-shape.la \ unit-each-view.la \ unit-session.la \ + unit-uno-command.la \ unit-wopi-loadencoded.la unit-wopi-temp.la MAGIC_TO_FORCE_SHLIB_CREATION = -rpath /dummy @@ -148,6 +149,8 @@ unit_each_view_la_SOURCES = UnitEachView.cpp unit_each_view_la_LIBADD = $(CPPUNIT_LIBS) unit_session_la_SOURCES = UnitSession.cpp unit_session_la_LIBADD = $(CPPUNIT_LIBS) +unit_uno_command_la_SOURCES = UnitUNOCommand.cpp +unit_uno_command_la_LIBADD = $(CPPUNIT_LIBS) if HAVE_LO_PATH SYSTEM_STAMP = @SYSTEMPLATE_PATH@/system_stamp @@ -176,6 +179,7 @@ TESTS = unit-copy-paste.la unit-typing.la unit-convert.la unit-prefork.la unit-t unit-render-shape.la \ unit-each-view.la \ unit-session.la \ + unit-uno-command.la \ unit-wopi-loadencoded.la unit-wopi-temp.la # TESTS = unit-client.la # TESTS += unit-admin.la diff --git a/test/UnitUNOCommand.cpp b/test/UnitUNOCommand.cpp new file mode 100644 index 000000000..09a67ba8b --- /dev/null +++ b/test/UnitUNOCommand.cpp @@ -0,0 +1,279 @@ +/* -*- 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 <ostream> +#include <set> +#include <string> + +#include <Poco/Exception.h> +#include <Poco/RegularExpression.h> +#include <Poco/URI.h> +#include <cppunit/TestAssert.h> + +#include <Unit.hpp> +#include <helpers.hpp> + +class LOOLWebSocket; + +namespace +{ +void testStateChanged(const std::string& filename, std::set<std::string>& commands) +{ + const auto testname = "stateChanged_" + filename + " "; + + Poco::RegularExpression reUno("\\.[a-zA-Z]*\\:[a-zA-Z]*\\="); + + std::shared_ptr<LOOLWebSocket> socket = helpers::loadDocAndGetSocket(filename, Poco::URI(helpers::getTestServerURI()), testname); + helpers::SocketProcessor(testname, socket, + [&](const std::string& msg) + { + Poco::RegularExpression::MatchVec matches; + if (reUno.match(msg, 0, matches) > 0 && matches.size() == 1) + { + commands.erase(msg.substr(matches[0].offset, matches[0].length)); + } + + return !commands.empty(); + }); + + if (!commands.empty()) + { + std::ostringstream ostr; + ostr << filename << " : Missing Uno Commands: " << std::endl; + for (auto & itUno : commands) + { + ostr << itUno << std::endl; + } + + CPPUNIT_FAIL(ostr.str()); + } +} +} + +/// Test suite for UNO commands. +class UnitUNOCommand : public UnitWSD +{ + TestResult testStateUnoCommandWriter(); + TestResult testStateUnoCommandCalc(); + TestResult testStateUnoCommandImpress(); + +public: + void invokeTest() override; +}; + +UnitBase::TestResult UnitUNOCommand::testStateUnoCommandWriter() +{ + std::set<std::string> writerCommands + { + ".uno:BackColor=", + ".uno:BackgroundColor=", + ".uno:Bold=", + ".uno:CenterPara=", + ".uno:CharBackColor=", + ".uno:CharBackgroundExt=", + ".uno:CharFontName=", + ".uno:Color=", + ".uno:DefaultBullet=", + ".uno:DefaultNumbering=", + ".uno:FontColor=", + ".uno:FontHeight=", + ".uno:Italic=", + ".uno:JustifyPara=", + ".uno:OutlineFont=", + ".uno:LeftPara=", + ".uno:RightPara=", + ".uno:Shadowed=", + ".uno:SubScript=", + ".uno:SuperScript=", + ".uno:Strikeout=", + ".uno:StyleApply=", + ".uno:Underline=", + ".uno:ModifiedStatus=", + ".uno:Undo=", + ".uno:Redo=", + ".uno:Cut=", + ".uno:Copy=", + ".uno:Paste=", + ".uno:SelectAll=", + ".uno:InsertAnnotation=", + ".uno:InsertRowsBefore=", + ".uno:InsertRowsAfter=", + ".uno:InsertColumnsBefore=", + ".uno:InsertColumnsAfter=", + ".uno:DeleteRows=", + ".uno:DeleteColumns=", + ".uno:DeleteTable=", + ".uno:SelectTable=", + ".uno:EntireRow=", + ".uno:EntireColumn=", + ".uno:EntireCell=", + ".uno:InsertMode=", + ".uno:StateTableCell=", + ".uno:StatePageNumber=", + ".uno:StateWordCount=", + ".uno:SelectionMode=", + ".uno:NumberFormatCurrency=", + ".uno:NumberFormatPercent=", + ".uno:NumberFormatDate=" + }; + + try + { + testStateChanged("empty.odt", writerCommands); + } + catch (const Poco::Exception& exc) + { + CPPUNIT_FAIL(exc.displayText()); + } + return TestResult::Ok; +} + +UnitBase::TestResult UnitUNOCommand::testStateUnoCommandCalc() +{ + std::set<std::string> calcCommands + { + ".uno:BackgroundColor=", + ".uno:Bold=", + ".uno:CenterPara=", + ".uno:CharBackColor=", + ".uno:CharFontName=", + ".uno:Color=", + ".uno:FontHeight=", + ".uno:Italic=", + ".uno:JustifyPara=", + ".uno:OutlineFont=", + ".uno:LeftPara=", + ".uno:RightPara=", + ".uno:Shadowed=", + ".uno:SubScript=", + ".uno:SuperScript=", + ".uno:Strikeout=", + ".uno:StyleApply=", + ".uno:Underline=", + ".uno:ModifiedStatus=", + ".uno:Undo=", + ".uno:Redo=", + ".uno:Cut=", + ".uno:Copy=", + ".uno:Paste=", + ".uno:SelectAll=", + ".uno:InsertAnnotation=", + ".uno:InsertRowsBefore=", + ".uno:InsertRowsAfter=", + ".uno:InsertColumnsBefore=", + ".uno:InsertColumnsAfter=", + ".uno:DeleteRows=", + ".uno:DeleteColumns=", + ".uno:StatusDocPos=", + ".uno:RowColSelCount=", + ".uno:StatusPageStyle=", + ".uno:InsertMode=", + ".uno:StatusSelectionMode=", + ".uno:StateTableCell=", + ".uno:StatusBarFunc=", + ".uno:WrapText=", + ".uno:ToggleMergeCells=", + ".uno:NumberFormatCurrency=", + ".uno:NumberFormatPercent=", + ".uno:NumberFormatDate=" + }; + + try + { + testStateChanged("empty.ods", calcCommands); + } + catch (const Poco::Exception& exc) + { + CPPUNIT_FAIL(exc.displayText()); + } + return TestResult::Ok; +} + +UnitBase::TestResult UnitUNOCommand::testStateUnoCommandImpress() +{ + std::set<std::string> impressCommands + { + ".uno:Bold=", + ".uno:CenterPara=", + ".uno:CharBackColor=", + ".uno:CharFontName=", + ".uno:Color=", + ".uno:DefaultBullet=", + ".uno:DefaultNumbering=", + ".uno:FontHeight=", + ".uno:Italic=", + ".uno:JustifyPara=", + ".uno:OutlineFont=", + ".uno:LeftPara=", + ".uno:RightPara=", + ".uno:Shadowed=", + ".uno:SubScript=", + ".uno:SuperScript=", + ".uno:Strikeout=", + ".uno:StyleApply=", + ".uno:Underline=", + ".uno:ModifiedStatus=", + ".uno:Undo=", + ".uno:Redo=", + ".uno:InsertPage=", + ".uno:DeletePage=", + ".uno:DuplicatePage=", + ".uno:Cut=", + ".uno:Copy=", + ".uno:Paste=", + ".uno:SelectAll=", + ".uno:InsertAnnotation=", + ".uno:InsertRowsBefore=", + ".uno:InsertRowsAfter=", + ".uno:InsertColumnsBefore=", + ".uno:InsertColumnsAfter=", + ".uno:DeleteRows=", + ".uno:DeleteColumns=", + ".uno:SelectTable=", + ".uno:EntireRow=", + ".uno:EntireColumn=", + ".uno:AssignLayout=", + ".uno:PageStatus=", + ".uno:LayoutStatus=", + ".uno:Context=", + ".uno:InsertSymbol=", + }; + + try + { + testStateChanged("empty.odp", impressCommands); + } + catch (const Poco::Exception& exc) + { + CPPUNIT_FAIL(exc.displayText()); + } + return TestResult::Ok; +} + +void UnitUNOCommand::invokeTest() +{ + UnitBase::TestResult result = testStateUnoCommandWriter(); + if (result != TestResult::Ok) + exitTest(result); + + result = testStateUnoCommandCalc(); + if (result != TestResult::Ok) + exitTest(result); + + result = testStateUnoCommandImpress(); + if (result != TestResult::Ok) + exitTest(result); + + exitTest(TestResult::Ok); +} + +UnitBase* unit_create_wsd(void) { return new UnitUNOCommand(); } + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/test/httpwstest.cpp b/test/httpwstest.cpp index 1bb033bdf..2a7a3db9b 100644 --- a/test/httpwstest.cpp +++ b/test/httpwstest.cpp @@ -62,9 +62,6 @@ class HTTPWSTest : public CPPUNIT_NS::TestFixture CPPUNIT_TEST(testCalcRenderAfterNewView51); CPPUNIT_TEST(testCalcRenderAfterNewView53); CPPUNIT_TEST(testFontList); - CPPUNIT_TEST(testStateUnoCommandWriter); - CPPUNIT_TEST(testStateUnoCommandCalc); - CPPUNIT_TEST(testStateUnoCommandImpress); // FIXME CPPUNIT_TEST(testColumnRowResize); // FIXME CPPUNIT_TEST(testOptimalResize); CPPUNIT_TEST(testGraphicInvalidate); @@ -97,9 +94,6 @@ class HTTPWSTest : public CPPUNIT_NS::TestFixture void testCalcRenderAfterNewView51(); void testCalcRenderAfterNewView53(); void testFontList(); - void testStateUnoCommandWriter(); - void testStateUnoCommandCalc(); - void testStateUnoCommandImpress(); void testColumnRowResize(); void testOptimalResize(); void testGraphicInvalidate(); @@ -129,7 +123,6 @@ class HTTPWSTest : public CPPUNIT_NS::TestFixture const std::string& testname); std::string getFontList(const std::string& message); - void testStateChanged(const std::string& filename, std::set<std::string>& vecComands); double getColRowSize(const std::string& property, const std::string& message, int index); double getColRowSize(const std::shared_ptr<LOOLWebSocket>& socket, const std::string& item, int index, const std::string& testname); @@ -1269,224 +1262,6 @@ void HTTPWSTest::testFontList() } } -void HTTPWSTest::testStateChanged(const std::string& filename, std::set<std::string>& commands) -{ - const auto testname = "stateChanged_" + filename + " "; - - Poco::RegularExpression reUno("\\.[a-zA-Z]*\\:[a-zA-Z]*\\="); - - std::shared_ptr<LOOLWebSocket> socket = loadDocAndGetSocket(filename, _uri, testname); - SocketProcessor(testname, socket, - [&](const std::string& msg) - { - Poco::RegularExpression::MatchVec matches; - if (reUno.match(msg, 0, matches) > 0 && matches.size() == 1) - { - commands.erase(msg.substr(matches[0].offset, matches[0].length)); - } - - return !commands.empty(); - }); - - if (!commands.empty()) - { - std::ostringstream ostr; - ostr << filename << " : Missing Uno Commands: " << std::endl; - for (auto & itUno : commands) - { - ostr << itUno << std::endl; - } - - CPPUNIT_FAIL(ostr.str()); - } -} - -void HTTPWSTest::testStateUnoCommandWriter() -{ - std::set<std::string> writerCommands - { - ".uno:BackColor=", - ".uno:BackgroundColor=", - ".uno:Bold=", - ".uno:CenterPara=", - ".uno:CharBackColor=", - ".uno:CharBackgroundExt=", - ".uno:CharFontName=", - ".uno:Color=", - ".uno:DefaultBullet=", - ".uno:DefaultNumbering=", - ".uno:FontColor=", - ".uno:FontHeight=", - ".uno:Italic=", - ".uno:JustifyPara=", - ".uno:OutlineFont=", - ".uno:LeftPara=", - ".uno:RightPara=", - ".uno:Shadowed=", - ".uno:SubScript=", - ".uno:SuperScript=", - ".uno:Strikeout=", - ".uno:StyleApply=", - ".uno:Underline=", - ".uno:ModifiedStatus=", - ".uno:Undo=", - ".uno:Redo=", - ".uno:Cut=", - ".uno:Copy=", - ".uno:Paste=", - ".uno:SelectAll=", - ".uno:InsertAnnotation=", - ".uno:InsertRowsBefore=", - ".uno:InsertRowsAfter=", - ".uno:InsertColumnsBefore=", - ".uno:InsertColumnsAfter=", - ".uno:DeleteRows=", - ".uno:DeleteColumns=", - ".uno:DeleteTable=", - ".uno:SelectTable=", - ".uno:EntireRow=", - ".uno:EntireColumn=", - ".uno:EntireCell=", - ".uno:InsertMode=", - ".uno:StateTableCell=", - ".uno:StatePageNumber=", - ".uno:StateWordCount=", - ".uno:SelectionMode=", - ".uno:NumberFormatCurrency=", - ".uno:NumberFormatPercent=", - ".uno:NumberFormatDate=" - }; - - try - { - testStateChanged("empty.odt", writerCommands); - } - catch (const Poco::Exception& exc) - { - CPPUNIT_FAIL(exc.displayText()); - } -} - -void HTTPWSTest::testStateUnoCommandCalc() -{ - std::set<std::string> calcCommands - { - ".uno:BackgroundColor=", - ".uno:Bold=", - ".uno:CenterPara=", - ".uno:CharBackColor=", - ".uno:CharFontName=", - ".uno:Color=", - ".uno:FontHeight=", - ".uno:Italic=", - ".uno:JustifyPara=", - ".uno:OutlineFont=", - ".uno:LeftPara=", - ".uno:RightPara=", - ".uno:Shadowed=", - ".uno:SubScript=", - ".uno:SuperScript=", - ".uno:Strikeout=", - ".uno:StyleApply=", - ".uno:Underline=", - ".uno:ModifiedStatus=", - ".uno:Undo=", - ".uno:Redo=", - ".uno:Cut=", - ".uno:Copy=", - ".uno:Paste=", - ".uno:SelectAll=", - ".uno:InsertAnnotation=", - ".uno:InsertRowsBefore=", - ".uno:InsertRowsAfter=", - ".uno:InsertColumnsBefore=", - ".uno:InsertColumnsAfter=", - ".uno:DeleteRows=", - ".uno:DeleteColumns=", - ".uno:StatusDocPos=", - ".uno:RowColSelCount=", - ".uno:StatusPageStyle=", - ".uno:InsertMode=", - ".uno:StatusSelectionMode=", - ".uno:StateTableCell=", - ".uno:StatusBarFunc=", - ".uno:WrapText=", - ".uno:ToggleMergeCells=", - ".uno:NumberFormatCurrency=", - ".uno:NumberFormatPercent=", - ".uno:NumberFormatDate=" - }; - - try - { - testStateChanged("empty.ods", calcCommands); - } - catch (const Poco::Exception& exc) - { - CPPUNIT_FAIL(exc.displayText()); - } -} - -void HTTPWSTest::testStateUnoCommandImpress() -{ - std::set<std::string> impressCommands - { - ".uno:Bold=", - ".uno:CenterPara=", - ".uno:CharBackColor=", - ".uno:CharFontName=", - ".uno:Color=", - ".uno:DefaultBullet=", - ".uno:DefaultNumbering=", - ".uno:FontHeight=", - ".uno:Italic=", - ".uno:JustifyPara=", - ".uno:OutlineFont=", - ".uno:LeftPara=", - ".uno:RightPara=", - ".uno:Shadowed=", - ".uno:SubScript=", - ".uno:SuperScript=", - ".uno:Strikeout=", - ".uno:StyleApply=", - ".uno:Underline=", - ".uno:ModifiedStatus=", - ".uno:Undo=", - ".uno:Redo=", - ".uno:InsertPage=", - ".uno:DeletePage=", - ".uno:DuplicatePage=", - ".uno:Cut=", - ".uno:Copy=", - ".uno:Paste=", - ".uno:SelectAll=", - ".uno:InsertAnnotation=", - ".uno:InsertRowsBefore=", - ".uno:InsertRowsAfter=", - ".uno:InsertColumnsBefore=", - ".uno:InsertColumnsAfter=", - ".uno:DeleteRows=", - ".uno:DeleteColumns=", - ".uno:SelectTable=", - ".uno:EntireRow=", - ".uno:EntireColumn=", - ".uno:AssignLayout=", - ".uno:PageStatus=", - ".uno:LayoutStatus=", - ".uno:Context=", - ".uno:InsertSymbol=", - }; - - try - { - testStateChanged("empty.odp", impressCommands); - } - catch (const Poco::Exception& exc) - { - CPPUNIT_FAIL(exc.displayText()); - } -} - double HTTPWSTest::getColRowSize(const std::string& property, const std::string& message, int index) { Poco::JSON::Parser parser; _______________________________________________ Libreoffice-commits mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits
