[Libreoffice-commits] online.git: test/httpwstest.cpp

Ashod Nakashian ashod.nakashian at collabora.co.uk
Mon Jan 9 06:26:50 UTC 2017


 test/httpwstest.cpp |  114 ++++++++++++++++++++++++++++++----------------------
 1 file changed, 66 insertions(+), 48 deletions(-)

New commits:
commit a775f5e585b27f0e673551d3e8e2c86e472c3bb7
Author: Ashod Nakashian <ashod.nakashian at collabora.co.uk>
Date:   Sun Jan 8 23:28:46 2017 -0500

    wsd: split testStateUnoCommand one for each app
    
    Change-Id: I4f6275e289c1a64a05df5b5e4c2708b8ab5b3f83
    Reviewed-on: https://gerrit.libreoffice.org/32871
    Reviewed-by: Ashod Nakashian <ashnakash at gmail.com>
    Tested-by: Ashod Nakashian <ashnakash at gmail.com>

diff --git a/test/httpwstest.cpp b/test/httpwstest.cpp
index 309055b..e533959 100644
--- a/test/httpwstest.cpp
+++ b/test/httpwstest.cpp
@@ -88,7 +88,9 @@ class HTTPWSTest : public CPPUNIT_NS::TestFixture
     CPPUNIT_TEST(testInsertAnnotationCalc);
     CPPUNIT_TEST(testCalcEditRendering);
     CPPUNIT_TEST(testFontList);
-    CPPUNIT_TEST(testStateUnoCommand);
+    CPPUNIT_TEST(testStateUnoCommandWriter);
+    CPPUNIT_TEST(testStateUnoCommandCalc);
+    CPPUNIT_TEST(testStateUnoCommandImpress);
     CPPUNIT_TEST(testColumnRowResize);
     CPPUNIT_TEST(testOptimalResize);
     CPPUNIT_TEST(testInvalidateViewCursor);
@@ -136,7 +138,9 @@ class HTTPWSTest : public CPPUNIT_NS::TestFixture
     void testInsertAnnotationCalc();
     void testCalcEditRendering();
     void testFontList();
-    void testStateUnoCommand();
+    void testStateUnoCommandWriter();
+    void testStateUnoCommandCalc();
+    void testStateUnoCommandImpress();
     void testColumnRowResize();
     void testOptimalResize();
     void testInvalidateViewCursor();
@@ -175,7 +179,7 @@ class HTTPWSTest : public CPPUNIT_NS::TestFixture
                      const std::string& testname);
 
     std::string getFontList(const std::string& message);
-    void testStateChanged(const std::string& filename, std::vector<std::string>& vecComands);
+    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);
     void testEachView(const std::string& doc, const std::string& type, const std::string& protocol, const std::string& view, const std::string& testname);
@@ -1592,56 +1596,53 @@ void HTTPWSTest::testFontList()
     }
 }
 
-void HTTPWSTest::testStateChanged(const std::string& filename, std::vector<std::string>& vecCommands)
+void HTTPWSTest::testStateChanged(const std::string& filename, std::set<std::string>& commands)
 {
-    const auto testname = "stateChanged ";
+    const auto testname = "stateChanged_" + filename + " ";
+
+    Poco::RegularExpression reUno("\\.[a-zA-Z]*\\:[a-zA-Z]*\\=");
 
     auto socket = loadDocAndGetSocket(filename, _uri, testname);
     SocketProcessor(testname, socket,
         [&](const std::string& msg)
         {
             Poco::RegularExpression::MatchVec matches;
-            Poco::RegularExpression reUno("\\.[a-zA-Z]*\\:[a-zA-Z]*\\=");
-
             if (reUno.match(msg, 0, matches) > 0 && matches.size() == 1)
             {
-                const auto str = msg.substr(matches[0].offset, matches[0].length);
-                auto result = std::find(std::begin(vecCommands), std::end(vecCommands), str);
-
-                if (result != std::end(vecCommands))
-                {
-                    vecCommands.erase(result);
-                }
+                commands.erase(msg.substr(matches[0].offset, matches[0].length));
             }
 
-            if (vecCommands.size() == 0)
-                return false;
-
-            return true;
+            return !commands.empty();
         });
 
-    if (vecCommands.size() > 0 )
+    if (!commands.empty())
     {
         std::ostringstream ostr;
-
         ostr << filename << " : Missing Uno Commands: " << std::endl;
-        for (auto & itUno : vecCommands)
+        for (auto & itUno : commands)
+        {
             ostr << itUno << std::endl;
+        }
 
         CPPUNIT_FAIL(ostr.str());
     }
 }
 
-void HTTPWSTest::testStateUnoCommand()
+void HTTPWSTest::testStateUnoCommandWriter()
 {
-    std::vector<std::string> calcCommands
+    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=",
@@ -1668,33 +1669,41 @@ void HTTPWSTest::testStateUnoCommand()
         ".uno:InsertColumnsAfter=",
         ".uno:DeleteRows=",
         ".uno:DeleteColumns=",
-        ".uno:StatusDocPos=",
-        ".uno:RowColSelCount=",
-        ".uno:StatusPageStyle=",
+        ".uno:DeleteTable=",
+        ".uno:SelectTable=",
+        ".uno:EntireRow=",
+        ".uno:EntireColumn=",
+        ".uno:EntireCell=",
         ".uno:InsertMode=",
-        ".uno:StatusSelectionMode=",
         ".uno:StateTableCell=",
-        ".uno:StatusBarFunc=",
-        ".uno:WrapText=",
-        ".uno:ToggleMergeCells=",
+        ".uno:StatePageNumber=",
+        ".uno:StateWordCount=",
+        ".uno:SelectionMode=",
         ".uno:NumberFormatCurrency=",
         ".uno:NumberFormatPercent=",
         ".uno:NumberFormatDate="
     };
 
-    std::vector<std::string> writerCommands
+    try
+    {
+        testStateChanged("empty.odt", writerCommands);
+    }
+    catch (const Poco::Exception& exc)
+    {
+        CPPUNIT_FAIL(exc.displayText());
+    }
+}
+
+void HTTPWSTest::testStateUnoCommandCalc()
+{
+    std::set<std::string> calcCommands
     {
-        ".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=",
@@ -1721,22 +1730,33 @@ void HTTPWSTest::testStateUnoCommand()
         ".uno:InsertColumnsAfter=",
         ".uno:DeleteRows=",
         ".uno:DeleteColumns=",
-        ".uno:DeleteTable=",
-        ".uno:SelectTable=",
-        ".uno:EntireRow=",
-        ".uno:EntireColumn=",
-        ".uno:EntireCell=",
+        ".uno:StatusDocPos=",
+        ".uno:RowColSelCount=",
+        ".uno:StatusPageStyle=",
         ".uno:InsertMode=",
+        ".uno:StatusSelectionMode=",
         ".uno:StateTableCell=",
-        ".uno:StatePageNumber=",
-        ".uno:StateWordCount=",
-        ".uno:SelectionMode=",
+        ".uno:StatusBarFunc=",
+        ".uno:WrapText=",
+        ".uno:ToggleMergeCells=",
         ".uno:NumberFormatCurrency=",
         ".uno:NumberFormatPercent=",
         ".uno:NumberFormatDate="
     };
 
-    std::vector<std::string> impressCommands
+    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=",
@@ -1785,9 +1805,7 @@ void HTTPWSTest::testStateUnoCommand()
 
     try
     {
-        testStateChanged(std::string("setclientpart.ods"), calcCommands);
-        testStateChanged(std::string("hello.odt"), writerCommands);
-        testStateChanged(std::string("setclientpart.odp"), impressCommands);
+        testStateChanged("empty.odp", impressCommands);
     }
     catch (const Poco::Exception& exc)
     {


More information about the Libreoffice-commits mailing list