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

2019-10-28 Thread Ashod Nakashian (via logerrit)
 test/helpers.hpp|   16 +++-
 test/httpwstest.cpp |7 ---
 2 files changed, 15 insertions(+), 8 deletions(-)

New commits:
commit d6306c5388b3d4bf964463020fd2c68898b54b0a
Author: Ashod Nakashian 
AuthorDate: Sat Oct 19 12:32:43 2019 -0400
Commit: Ashod Nakashian 
CommitDate: Tue Oct 29 02:31:01 2019 +0100

test: improve getAllText to match an expected payload

Change-Id: I4159f1e21f581ccdf90bcacf489580c8887931e5
Reviewed-on: https://gerrit.libreoffice.org/81195
Reviewed-by: Andras Timar 
Tested-by: Andras Timar 
(cherry picked from commit 9903229918d07eee2f6c1ad22ee5a287f4fd0884)
Reviewed-on: https://gerrit.libreoffice.org/81571
Reviewed-by: Ashod Nakashian 
Tested-by: Ashod Nakashian 

diff --git a/test/helpers.hpp b/test/helpers.hpp
index 30d20d3d8..6084e3337 100644
--- a/test/helpers.hpp
+++ b/test/helpers.hpp
@@ -729,20 +729,26 @@ inline void deleteAll(const 
std::shared_ptr& socket, const std::s
 }
 
 inline std::string getAllText(const std::shared_ptr& socket,
-  const std::string& testname, int retry = 
COMMAND_RETRY_COUNT)
+  const std::string& testname,
+  const std::string expected = std::string(),
+  int retry = COMMAND_RETRY_COUNT)
 {
-std::string text;
+static const std::string prefix = "textselectioncontent: ";
+
 for (int i = 0; i < retry; ++i)
 {
 selectAll(socket, testname);
 
 sendTextFrame(socket, "gettextselection 
mimetype=text/plain;charset=utf-8", testname);
-text = assertResponseString(socket, "textselectioncontent:", testname);
+const std::string text = getResponseString(socket, prefix, testname);
 if (!text.empty())
-break;
+{
+if (expected.empty() || (prefix + expected) == text)
+return text;
+}
 }
 
-return text;
+return std::string();
 }
 
 }
diff --git a/test/httpwstest.cpp b/test/httpwstest.cpp
index d9a4727cf..a6e2c2f59 100644
--- a/test/httpwstest.cpp
+++ b/test/httpwstest.cpp
@@ -515,8 +515,9 @@ void HTTPWSTest::testGetTextSelection()
 std::shared_ptr socket = loadDocAndGetSocket(_uri, 
documentURL, testname);
 std::shared_ptr socket2 = loadDocAndGetSocket(_uri, 
documentURL, testname);
 
-const std::string selection = getAllText(socket, testname);
-CPPUNIT_ASSERT_EQUAL(std::string("textselectioncontent: Hello world"), 
selection);
+static const std::string expected = "Hello world";
+const std::string selection = getAllText(socket, testname, expected);
+CPPUNIT_ASSERT_EQUAL("textselectioncontent: " + expected, selection);
 }
 catch (const Poco::Exception& exc)
 {
@@ -580,7 +581,7 @@ void HTTPWSTest::testSaveOnDisconnect()
 CPPUNIT_ASSERT_EQUAL(kitcount, countLoolKitProcesses(kitcount));
 
 // Check if the document contains the pasted text.
-const std::string selection = getAllText(socket, testname);
+const std::string selection = getAllText(socket, testname, text);
 CPPUNIT_ASSERT_EQUAL("textselectioncontent: " + text, selection);
 }
 catch (const Poco::Exception& exc)
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits

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

2019-10-28 Thread Ashod Nakashian (via logerrit)
 test/helpers.hpp|   48 +-
 test/httpwstest.cpp |  173 
 2 files changed, 140 insertions(+), 81 deletions(-)

New commits:
commit 194db8ed45e1bd47a94c5b7a23a9add0a4c0eb39
Author: Ashod Nakashian 
AuthorDate: Sat Oct 12 13:47:38 2019 -0400
Commit: Ashod Nakashian 
CommitDate: Tue Oct 29 01:41:00 2019 +0100

test: improve stability of a number of tests

There are numerous race conditions between issuing
action and getting the events. This causes a
mismatch, such that the events from SelectAll
is received when waiting for the events for a
subsequent action (say, Delete).

To make matters worse, sometimes Core issues
an invalidation whilst sending the events for
an action, and this completely messes our
accounting of what events we expect.

This latter could also be an issue with real
clients, however it's less likely to be
disruptive. Still, it is possible that
the client doesn't get key events
because Core had a hiccup, which breaks
the tests.

For the tests at least, the solution is to
re-issue the last action, such that we make
sure that we move forward only when the correct
event is received, or we timeout waiting.

The end results is that tests now don't fail
nearly as often as they used to.

Reviewed-on: https://gerrit.libreoffice.org/80894
Reviewed-by: Andras Timar 
Tested-by: Andras Timar 
(cherry picked from commit 050403daf04d6b36ef850006ba4a15eab6be9afc)

Change-Id: Ib1a658846061990649987ca083915a49c1fb092a
Reviewed-on: https://gerrit.libreoffice.org/81565
Reviewed-by: Ashod Nakashian 
Tested-by: Ashod Nakashian 

diff --git a/test/helpers.hpp b/test/helpers.hpp
index 5b484baa7..30d20d3d8 100644
--- a/test/helpers.hpp
+++ b/test/helpers.hpp
@@ -59,6 +59,9 @@
 #define TST_LOG_NAME(NAME, X) TST_LOG_NAME_BEGIN(NAME, X); TST_LOG_END
 #define TST_LOG(X) TST_LOG_NAME(testname, X)
 
+// Sometimes we need to retry some commands as they can (due to timing or 
load) soft-fail.
+constexpr int COMMAND_RETRY_COUNT = 5;
+
 /// Common helper testing functions.
 /// Avoid the temptation to reuse from LOOL code!
 /// These are supposed to be testing the latter.
@@ -675,8 +678,6 @@ inline void 
getServerVersion(std::shared_ptr& socket,
 getServerVersion(*socket, major, minor, testname);
 }
 
-}
-
 inline bool svgMatch(const char *testname, const std::vector , 
const char *templateFile)
 {
 const std::vector expectedSVG = 
helpers::readDataFromFile(templateFile);
@@ -702,6 +703,49 @@ inline bool svgMatch(const char *testname, const 
std::vector , co
 return true;
 }
 
+/// Select all and wait for the text selection update.
+inline void selectAll(const std::shared_ptr& socket, const 
std::string& testname, int repeat = COMMAND_RETRY_COUNT)
+{
+for (int i = 0; i < repeat; ++i)
+{
+sendTextFrame(socket, "uno .uno:SelectAll", testname);
+if (!getResponseString(socket, "textselection:", testname).empty())
+break;
+}
+}
+
+
+/// Delete all and wait for the text selection update.
+inline void deleteAll(const std::shared_ptr& socket, const 
std::string& testname, int repeat = COMMAND_RETRY_COUNT)
+{
+selectAll(socket, testname);
+
+for (int i = 0; i < repeat; ++i)
+{
+sendTextFrame(socket, "uno .uno:Delete", testname);
+if (!getResponseString(socket, "textselection:", testname).empty())
+break;
+}
+}
+
+inline std::string getAllText(const std::shared_ptr& socket,
+  const std::string& testname, int retry = 
COMMAND_RETRY_COUNT)
+{
+std::string text;
+for (int i = 0; i < retry; ++i)
+{
+selectAll(socket, testname);
+
+sendTextFrame(socket, "gettextselection 
mimetype=text/plain;charset=utf-8", testname);
+text = assertResponseString(socket, "textselectioncontent:", testname);
+if (!text.empty())
+break;
+}
+
+return text;
+}
+
+}
 #endif
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/test/httpwstest.cpp b/test/httpwstest.cpp
index a2c4eaf2a..f13e21582 100644
--- a/test/httpwstest.cpp
+++ b/test/httpwstest.cpp
@@ -118,6 +118,7 @@ class HTTPWSTest : public CPPUNIT_NS::TestFixture
 CPPUNIT_TEST(testSavePassiveOnDisconnect);
 CPPUNIT_TEST(testReloadWhileDisconnecting);
 CPPUNIT_TEST(testExcelLoad);
+CPPUNIT_TEST(testPaste);
 CPPUNIT_TEST(testPasteBlank);
 CPPUNIT_TEST(testInsertDelete);
 CPPUNIT_TEST(testSlideShow);
@@ -165,6 +166,7 @@ class HTTPWSTest : public CPPUNIT_NS::TestFixture
 void testSavePassiveOnDisconnect();
 void testReloadWhileDisconnecting();
 void testExcelLoad();
+void testPaste();
 void testPasteBlank();
 void testInsertDelete();
 void testSlideShow();
@@ -513,9 +515,7 @@ void HTTPWSTest::testGetTextSelection()
 

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

2019-10-28 Thread Ashod Nakashian (via logerrit)
 test/helpers.hpp|4 ++--
 test/httpwstest.cpp |   37 +
 2 files changed, 31 insertions(+), 10 deletions(-)

New commits:
commit 923030470ce4d6efa48db588a822cb66e4b772ae
Author: Ashod Nakashian 
AuthorDate: Sun Oct 13 21:27:53 2019 -0400
Commit: Michael Meeks 
CommitDate: Mon Oct 28 10:54:14 2019 +0100

test: improve SVG parser

The SVG can have self-closing tags, which wasn't accounted
for. This meant the actual SVG didn't match the expected.

Reviewed-on: https://gerrit.libreoffice.org/80895
Reviewed-by: Andras Timar 
Tested-by: Andras Timar 
(cherry picked from commit 93abce99d02aa417feeae12f9232b0be83a74e35)

Change-Id: I749ba7f59351cf635fdc1cd30b3be5260b3c6b16
Reviewed-on: https://gerrit.libreoffice.org/81566
Reviewed-by: Michael Meeks 
Tested-by: Michael Meeks 

diff --git a/test/helpers.hpp b/test/helpers.hpp
index cfbeb4e59..5b484baa7 100644
--- a/test/helpers.hpp
+++ b/test/helpers.hpp
@@ -693,9 +693,9 @@ inline bool svgMatch(const char *testname, const 
std::vector , co
 newName += ".new";
 TST_LOG_APPEND("Updated template writing to: " << newName << "\n");
 TST_LOG_END;
+
 FILE *of = fopen(Poco::Path(TDOC, newName).toString().c_str(), "w");
-size_t unused = fwrite(response.data(), response.size(), 1, of);
-(void)unused;
+CPPUNIT_ASSERT(fwrite(response.data(), response.size(), 1, of) == 
response.size());
 fclose(of);
 return false;
 }
diff --git a/test/httpwstest.cpp b/test/httpwstest.cpp
index 345c94c08..a2c4eaf2a 100644
--- a/test/httpwstest.cpp
+++ b/test/httpwstest.cpp
@@ -60,19 +60,40 @@ namespace
  */
 void stripDescriptions(std::vector& svg)
 {
+static const std::string startDesc("");
+static const std::string endDesc("");
+static const std::string selfClose("/>");
+
 while (true)
 {
-std::string startDesc("");
-auto itStart = std::search(svg.begin(), svg.end(), startDesc.begin(), 
startDesc.end());
+const auto itStart = std::search(svg.begin(), svg.end(), 
startDesc.begin(), startDesc.end());
 if (itStart == svg.end())
 return;
 
-std::string endDesc("");
-auto itEnd = std::search(svg.begin(), svg.end(), endDesc.begin(), 
endDesc.end());
-if (itEnd == svg.end())
-return;
+const auto itClose = std::search(itStart + 1, svg.end(), 
selfClose.begin(), selfClose.end());
 
-svg.erase(itStart, itEnd + endDesc.size());
+const auto itEnd = std::search(itStart + 1, svg.end(), 
endDesc.begin(), endDesc.end());
+
+if (itEnd != svg.end() && itClose != svg.end())
+{
+if (itEnd < itClose)
+svg.erase(itStart, itEnd + endDesc.size());
+else
+svg.erase(itStart, itClose + selfClose.size());
+}
+else if (itEnd != svg.end())
+{
+svg.erase(itStart, itEnd + endDesc.size());
+}
+else if (itClose != svg.end())
+{
+svg.erase(itStart, itClose + selfClose.size());
+}
+else
+{
+// No more closing tags; possibly broken, as we found an opening 
tag.
+return;
+}
 }
 }
 }
@@ -2385,7 +2406,7 @@ void HTTPWSTest::testRenderShapeSelectionWriter()
 sendTextFrame(socket, "rendershapeselection mimetype=image/svg+xml", 
testname);
 std::vector responseSVG = getResponseMessage(socket, 
"shapeselectioncontent:", testname);
 CPPUNIT_ASSERT(!responseSVG.empty());
-auto it = std::find(responseSVG.begin(), responseSVG.end(),'\n');
+auto it = std::find(responseSVG.begin(), responseSVG.end(), '\n');
 if (it != responseSVG.end())
 responseSVG.erase(responseSVG.begin(), ++it);
 
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits

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

2019-05-02 Thread Libreoffice Gerrit user
 test/helpers.hpp|   24 
 test/httpwstest.cpp |   12 ++--
 2 files changed, 30 insertions(+), 6 deletions(-)

New commits:
commit 5406a25b24bd76cb3de907527153ebed15e8d26e
Author: Michael Meeks 
AuthorDate: Thu May 2 16:14:12 2019 +0100
Commit: Michael Meeks 
CommitDate: Thu May 2 17:16:08 2019 +0200

tests: make SVG comparison tests much more helpful.

Dump the SVG we actually get as a .new file for easy upgrade and
comparison on mismatch.

Change-Id: I607a97ff27a9bf480524efc31877e46d74c5ee3d
Reviewed-on: https://gerrit.libreoffice.org/71681
Reviewed-by: Michael Meeks 
Tested-by: Michael Meeks 

diff --git a/test/helpers.hpp b/test/helpers.hpp
index 592d61b0e..2445ef3d2 100644
--- a/test/helpers.hpp
+++ b/test/helpers.hpp
@@ -643,6 +643,30 @@ inline void 
getServerVersion(std::shared_ptr& socket,
 
 }
 
+inline bool svgMatch(const char *testname, const std::vector , 
const char *templateFile)
+{
+const std::vector expectedSVG = 
helpers::readDataFromFile(templateFile);
+if (expectedSVG != response)
+{
+TST_LOG_BEGIN("Svg mismatch: response is\n");
+if(response.empty())
+TST_LOG_APPEND("");
+else
+TST_LOG_APPEND(std::string(response.data(), response.size()));
+TST_LOG_APPEND("\nvs. expected (from '" << templateFile << "' :\n");
+TST_LOG_APPEND(std::string(expectedSVG.data(), expectedSVG.size()));
+std::string newName = templateFile;
+newName += ".new";
+TST_LOG_APPEND("Updated template writing to: " << newName << "\n");
+TST_LOG_END;
+FILE *of = fopen(Poco::Path(TDOC, newName).toString().c_str(), "w");
+fwrite(response.data(), response.size(), 1, of);
+fclose(of);
+return false;
+}
+return true;
+}
+
 #endif
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/test/httpwstest.cpp b/test/httpwstest.cpp
index 8a4f23c38..687f46ae7 100644
--- a/test/httpwstest.cpp
+++ b/test/httpwstest.cpp
@@ -2739,6 +2739,7 @@ void HTTPWSTest::testRenderShapeSelectionImpress()
 }
 
 sendTextFrame(socket, "uno .uno:SelectAll", testname);
+std::this_thread::sleep_for(std::chrono::milliseconds(250));
 sendTextFrame(socket, "rendershapeselection mimetype=image/svg+xml", 
testname);
 std::vector responseSVG = getResponseMessage(socket, 
"shapeselectioncontent:", testname);
 CPPUNIT_ASSERT(!responseSVG.empty());
@@ -2746,8 +2747,7 @@ void HTTPWSTest::testRenderShapeSelectionImpress()
 if (it != responseSVG.end())
 responseSVG.erase(responseSVG.begin(), ++it);
 
-const std::vector expectedSVG = 
helpers::readDataFromFile("shapes_impress.svg");
-CPPUNIT_ASSERT(expectedSVG == responseSVG);
+CPPUNIT_ASSERT(svgMatch(testname, responseSVG, "shapes_impress.svg"));
 }
 catch (const Poco::Exception& exc)
 {
@@ -2767,6 +2767,7 @@ void HTTPWSTest::testRenderShapeSelectionWriter()
 
 // Select the shape with SHIFT + F4
 sendKeyPress(socket, 0, 771 | skShift, testname);
+std::this_thread::sleep_for(std::chrono::milliseconds(250));
 sendTextFrame(socket, "rendershapeselection mimetype=image/svg+xml", 
testname);
 std::vector responseSVG = getResponseMessage(socket, 
"shapeselectioncontent:", testname);
 CPPUNIT_ASSERT(!responseSVG.empty());
@@ -2774,8 +2775,7 @@ void HTTPWSTest::testRenderShapeSelectionWriter()
 if (it != responseSVG.end())
 responseSVG.erase(responseSVG.begin(), ++it);
 
-const std::vector expectedSVG = 
helpers::readDataFromFile("shape_writer.svg");
-CPPUNIT_ASSERT(expectedSVG == responseSVG);
+CPPUNIT_ASSERT(svgMatch(testname, responseSVG, "shapes_writer.svg"));
 }
 catch (const Poco::Exception& exc)
 {
@@ -2795,6 +2795,7 @@ void HTTPWSTest::testRenderShapeSelectionWriterImage()
 
 // Select the shape with SHIFT + F4
 sendKeyPress(socket, 0, 771 | skShift, testname);
+std::this_thread::sleep_for(std::chrono::milliseconds(250));
 sendTextFrame(socket, "rendershapeselection mimetype=image/svg+xml", 
testname);
 std::vector responseSVG = getResponseMessage(socket, 
"shapeselectioncontent:", testname);
 CPPUNIT_ASSERT(!responseSVG.empty());
@@ -2802,8 +2803,7 @@ void HTTPWSTest::testRenderShapeSelectionWriterImage()
 if (it != responseSVG.end())
 responseSVG.erase(responseSVG.begin(), ++it);
 
-const std::vector expectedSVG = 
helpers::readDataFromFile("non_shape_writer_image.svg");
-CPPUNIT_ASSERT(expectedSVG == responseSVG);
+CPPUNIT_ASSERT(svgMatch(testname, responseSVG, 
"non_shape_writer_image.svg"));
 }
 catch (const Poco::Exception& exc)
 {
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org

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

2017-05-01 Thread Ashod Nakashian
 test/helpers.hpp|   27 +++
 test/httpwstest.cpp |   46 ++
 2 files changed, 73 insertions(+)

New commits:
commit 647e5f8936b683b6ca511b967fcb35f2cd1cf463
Author: Ashod Nakashian 
Date:   Sun Apr 30 21:54:38 2017 -0400

wsd: unittest to reproduce rendering issue in Calc

The following scenario causes rendering failure
where blank tiles are returned.

1. Load doc where the cursor is saved to a top cell.
2. Page down (typically several 100th row).
3. Load a new view to the same doc (do nothing else).
4. In the first view up-arrow to move cursor and invalidate.
5. New tile is rendered incorrectly.

Change-Id: I06c7627d1b74d9e3be3e83d9d9a09cb5479ba660
Reviewed-on: https://gerrit.libreoffice.org/37129
Reviewed-by: Ashod Nakashian 
Tested-by: Ashod Nakashian 

diff --git a/test/helpers.hpp b/test/helpers.hpp
index 70bf6e4c..1b00b2e3 100644
--- a/test/helpers.hpp
+++ b/test/helpers.hpp
@@ -540,6 +540,33 @@ inline void sendText(std::shared_ptr& 
socket, const std::string&
 }
 }
 
+inline std::vector getTileAndSave(std::shared_ptr& socket,
+const std::string& req,
+const std::string& filename,
+const std::string& testname)
+{
+std::cerr << testname << "Requesting: " << req << std::endl;
+sendTextFrame(socket, req, testname);
+
+const auto tile = getResponseMessage(socket, "tile:", testname);
+std::cerr << testname << " Tile PNG size: " << tile.size() << std::endl;
+
+const std::string firstLine = LOOLProtocol::getFirstLine(tile);
+std::vector res(tile.begin() + firstLine.size() + 1, tile.end());
+std::stringstream streamRes;
+std::copy(res.begin(), res.end(), std::ostream_iterator(streamRes));
+
+if (!filename.empty())
+{
+std::fstream outStream(filename, std::ios::out);
+outStream.write(res.data(), res.size());
+outStream.close();
+std::cerr << testname << "Saved [" << firstLine << "] to [" << 
filename << "]" << std::endl;
+}
+
+return res;
+}
+
 }
 
 #endif
diff --git a/test/httpwstest.cpp b/test/httpwstest.cpp
index 917a41dd..e348a429 100644
--- a/test/httpwstest.cpp
+++ b/test/httpwstest.cpp
@@ -92,6 +92,7 @@ class HTTPWSTest : public CPPUNIT_NS::TestFixture
 //CPPUNIT_TEST(testEditAnnotationWriter);
 // FIXME CPPUNIT_TEST(testInsertAnnotationCalc);
 CPPUNIT_TEST(testCalcEditRendering);
+CPPUNIT_TEST(testCalcRenderAfterNewView);
 CPPUNIT_TEST(testFontList);
 CPPUNIT_TEST(testStateUnoCommandWriter);
 CPPUNIT_TEST(testStateUnoCommandCalc);
@@ -146,6 +147,7 @@ class HTTPWSTest : public CPPUNIT_NS::TestFixture
 void testEditAnnotationWriter();
 void testInsertAnnotationCalc();
 void testCalcEditRendering();
+void testCalcRenderAfterNewView();
 void testFontList();
 void testStateUnoCommandWriter();
 void testStateUnoCommandCalc();
@@ -1767,6 +1769,50 @@ void HTTPWSTest::testCalcEditRendering()
 }
 }
 
+/// When a second view is loaded to a Calc doc,
+/// the first stops rendering correctly.
+/// This only happens at high rows.
+void HTTPWSTest::testCalcRenderAfterNewView()
+{
+const auto testname = "calcRenderAfterNewView ";
+
+// Load a doc with the cursor saved at a top row.
+std::string documentPath, documentURL;
+getDocumentPathAndURL("empty.ods", documentPath, documentURL, testname);
+
+auto socket = loadDocAndGetSocket(_uri, documentURL, testname);
+
+// Page Down until we get to the bottom of the doc.
+for (int i = 0; i < 40; ++i)
+{
+sendTextFrame(socket, "key type=input char=0 key=1031", testname);
+}
+
+// Wait for status due to doc resize.
+assertResponseString(socket, "status:", testname);
+
+const auto req = "tilecombine part=0 width=256 height=256 tileposx=0 
tileposy=253440 tilewidth=3840 tileheight=3840";
+
+// Get tile.
+const std::vector tile1 = getTileAndSave(socket, req, 
"/tmp/calc_render_orig.png", testname);
+
+
+// Connect second client, which will load at the top.
+std::cerr << testname << "Connecting second client." << std::endl;
+auto socket2 = loadDocAndGetSocket(_uri, documentURL, testname);
+
+
+// Up one row on the first view to trigger the bug.
+std::cerr << testname << "Up." << std::endl;
+sendTextFrame(socket, "key type=input char=0 key=1025", testname);
+assertResponseString(socket, "invalidatetiles:", testname); // Up 
invalidates.
+
+// Get same tile again.
+const std::vector tile2 = getTileAndSave(socket, req, 
"/tmp/calc_render_sec.png", testname);
+
+CPPUNIT_ASSERT(tile1 == tile2);
+}
+
 std::string HTTPWSTest::getFontList(const std::string& message)
 {
 Poco::JSON::Parser parser;

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

2017-01-22 Thread Ashod Nakashian
 test/helpers.hpp|2 +-
 test/httpwstest.cpp |   19 ++-
 2 files changed, 15 insertions(+), 6 deletions(-)

New commits:
commit 0f73bd9bf2afba5f6a24aa5d0127be553ee55c02
Author: Ashod Nakashian 
Date:   Fri Jan 20 16:34:44 2017 -0500

wsd: improved testConnectNoLoad

Change-Id: I8eff5b4862067444c8623582dc4f3baa585f164e
Reviewed-on: https://gerrit.libreoffice.org/33425
Reviewed-by: Ashod Nakashian 
Tested-by: Ashod Nakashian 

diff --git a/test/helpers.hpp b/test/helpers.hpp
index 4dd8f86..cc8205e 100644
--- a/test/helpers.hpp
+++ b/test/helpers.hpp
@@ -176,7 +176,7 @@ int getErrorCode(LOOLWebSocket& ws, std::string& message, 
const std::string& tes
 bytes = ws.receiveFrame(buffer.begin(), READ_BUFFER_SIZE, flags);
 std::cerr << testname << "Got " << 
LOOLProtocol::getAbbreviatedFrameDump(buffer.begin(), bytes, flags) << 
std::endl;
 }
-while (bytes > 0 && (flags & Poco::Net::WebSocket::FRAME_OP_BITMASK) != 
Poco::Net::WebSocket::FRAME_OP_CLOSE);
+while (bytes != 0 && (flags & Poco::Net::WebSocket::FRAME_OP_BITMASK) != 
Poco::Net::WebSocket::FRAME_OP_CLOSE);
 
 if (bytes > 0)
 {
diff --git a/test/httpwstest.cpp b/test/httpwstest.cpp
index 32635d1..ff48454 100644
--- a/test/httpwstest.cpp
+++ b/test/httpwstest.cpp
@@ -360,26 +360,35 @@ void HTTPWSTest::loadDoc(const std::string& documentURL, 
const std::string& test
 
 void HTTPWSTest::testConnectNoLoad()
 {
+const auto testname1 = "connectNoLoad-1 ";
+const auto testname2 = "connectNoLoad-2 ";
+const auto testname3 = "connectNoLoad-3 ";
+
 std::string documentPath, documentURL;
 getDocumentPathAndURL("hello.odt", documentPath, documentURL);
 
 Poco::Net::HTTPRequest request(Poco::Net::HTTPRequest::HTTP_GET, 
documentURL);
-auto socket = connectLOKit(_uri, request, _response);
+std::cerr << testname1 << "Connecting." << std::endl;
+auto socket = connectLOKit(_uri, request, _response, testname1);
 CPPUNIT_ASSERT_MESSAGE("Failed to connect.", socket);
+std::cerr << testname1 << "Disconnecting." << std::endl;
 socket.reset();
 
 // Connect and load first view.
-auto socket1 = connectLOKit(_uri, request, _response);
+std::cerr << testname2 << "Connecting." << std::endl;
+auto socket1 = connectLOKit(_uri, request, _response, testname2);
 CPPUNIT_ASSERT_MESSAGE("Failed to connect.", socket1);
-sendTextFrame(socket1, "load url=" + documentURL);
+sendTextFrame(socket1, "load url=" + documentURL, testname2);
 CPPUNIT_ASSERT_MESSAGE("cannot load the document " + documentURL, 
isDocumentLoaded(socket1));
 
 // Connect but don't load second view.
-auto socket2 = connectLOKit(_uri, request, _response);
+std::cerr << testname3 << "Connecting." << std::endl;
+auto socket2 = connectLOKit(_uri, request, _response, testname3);
 CPPUNIT_ASSERT_MESSAGE("Failed to connect.", socket2);
+std::cerr << testname3 << "Disconnecting." << std::endl;
 socket2.reset();
 
-sendTextFrame(socket1, "status");
+sendTextFrame(socket1, "status", testname2);
 assertResponseString(socket1, "status:");
 }
 
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits