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

2020-05-07 Thread Michael Meeks (via logerrit)
 test/helpers.hpp |2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

New commits:
commit 7fe1d60b95b5c832011656346a5542c772e4b0a6
Author: Michael Meeks 
AuthorDate: Wed May 6 22:12:17 2020 +0100
Commit: Michael Meeks 
CommitDate: Thu May 7 13:15:01 2020 +0200

Use https sessions for wss:// as well as https://

Change-Id: I1b3f193a51b538c423589276b4ae61ba760b241e
Reviewed-on: https://gerrit.libreoffice.org/c/online/+/93595
Tested-by: Jenkins CollaboraOffice 
Reviewed-by: Michael Meeks 

diff --git a/test/helpers.hpp b/test/helpers.hpp
index 341c5621c..bbbf3fc2a 100644
--- a/test/helpers.hpp
+++ b/test/helpers.hpp
@@ -229,7 +229,7 @@ inline
 Poco::Net::HTTPClientSession* createSession(const Poco::URI& uri)
 {
 #if ENABLE_SSL
-if (uri.getScheme() == "https")
+if (uri.getScheme() == "https" || uri.getScheme() == "wss")
 return new Poco::Net::HTTPSClientSession(uri.getHost(), uri.getPort());
 #endif
 return new Poco::Net::HTTPClientSession(uri.getHost(), uri.getPort());
___
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/UnitLoadTorture.cpp

2020-03-20 Thread Miklos Vajna (via logerrit)
 test/UnitLoadTorture.cpp |3 ++-
 test/helpers.hpp |6 +++---
 2 files changed, 5 insertions(+), 4 deletions(-)

New commits:
commit a83dd9a1608b1bdb2569937762a88aeaadee831c
Author: Miklos Vajna 
AuthorDate: Fri Mar 20 09:16:22 2020 +0100
Commit: Miklos Vajna 
CommitDate: Fri Mar 20 10:47:59 2020 +0100

test: increase load timeout in UnitLoadTorture

This test sometimes failed on me just because the load was aborted due
to the timeout, doubling the limit makes the problem go away.

Change-Id: Ided724d67a513391b86836065d4e627581857a92
Reviewed-on: https://gerrit.libreoffice.org/c/online/+/90771
Tested-by: Jenkins CollaboraOffice 
Reviewed-by: Miklos Vajna 

diff --git a/test/UnitLoadTorture.cpp b/test/UnitLoadTorture.cpp
index 430658635..739157c0e 100644
--- a/test/UnitLoadTorture.cpp
+++ b/test/UnitLoadTorture.cpp
@@ -64,7 +64,8 @@ int UnitLoadTorture::loadTorture(const std::string& testname, 
const std::string&
 Poco::URI(helpers::getTestServerURI()), request, response, 
testname);
 helpers::sendTextFrame(socket, "load url=" + documentURL, 
testname);
 
-const auto status = helpers::assertResponseString(socket, 
"status:", testname);
+// 20s is double of the default.
+const auto status = helpers::assertResponseString(socket, 
"status:", testname, 2);
 int viewid = -1;
 LOOLProtocol::getTokenIntegerFromMessage(status, "viewid", 
viewid);
 sum_view_ids += viewid;
diff --git a/test/helpers.hpp b/test/helpers.hpp
index 46aef7605..1b831a289 100644
--- a/test/helpers.hpp
+++ b/test/helpers.hpp
@@ -311,7 +311,7 @@ std::vector getResponseMessage(LOOLWebSocket& ws, 
const std::string& prefi
 auto now = std::chrono::steady_clock::now();
 if (now > endTime) // timedout
 {
-TST_LOG("Timeout.");
+TST_LOG("Timeout after " << timeoutMs << " ms.");
 break;
 }
 long waitTimeUs = 
std::chrono::duration_cast(endTime - now).count();
@@ -378,9 +378,9 @@ std::string getResponseString(T& ws, const std::string& 
prefix, const std::strin
 }
 
 template 
-std::string assertResponseString(T& ws, const std::string& prefix, const 
std::string& testname)
+std::string assertResponseString(T& ws, const std::string& prefix, const 
std::string& testname, const size_t timeoutMs = 1)
 {
-const auto res = getResponseString(ws, prefix, testname);
+const auto res = getResponseString(ws, prefix, testname, timeoutMs);
 LOK_ASSERT_EQUAL(prefix, res.substr(0, prefix.length()));
 return res;
 }
___
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/test.cpp

2020-02-23 Thread Ashod Nakashian (via logerrit)
 test/helpers.hpp |   76 ---
 test/test.cpp|   48 +++---
 2 files changed, 100 insertions(+), 24 deletions(-)

New commits:
commit c742ca10118f19fa2af9671b97a3ee0ad71f5c0a
Author: Ashod Nakashian 
AuthorDate: Sun Feb 23 13:32:10 2020 -0500
Commit: Ashod Nakashian 
CommitDate: Sun Feb 23 22:04:04 2020 +0100

wsd: improve test logging

Logs from test are now more atomic (less interleaving).
And each integration-test (old-style tests running from
new-style tests) will now print clearly when it begins
and when it fails, making it easier to find failures.
Misc other minor cleanups in test logging.

Change-Id: Iff664e42a04d1c6dbf1332b2884c35183ef85e21
Reviewed-on: https://gerrit.libreoffice.org/c/online/+/89309
Tested-by: Ashod Nakashian 
Reviewed-by: Ashod Nakashian 

diff --git a/test/helpers.hpp b/test/helpers.hpp
index 1a0205475..32ed6efc7 100644
--- a/test/helpers.hpp
+++ b/test/helpers.hpp
@@ -31,7 +31,6 @@
 
 #include 
 #include "common/FileUtil.hpp"
-#include "test/test.hpp"
 #include 
 #include 
 
@@ -41,22 +40,71 @@
 
 // Oh dear std::cerr and/or its re-direction is not
 // necessarily thread safe on Linux
+// This is the canonical test log function.
+inline void writeTestLog(const char* const p)
+{
+fputs(p, stderr);
+fflush(stderr);
+}
+
+inline void writeTestLog(const std::string& s) { writeTestLog(s.c_str()); }
+
 #ifdef TST_LOG_REDIRECT
-  void tstLog(const std::ostringstream );
+void tstLog(const std::ostringstream& stream);
 #else
-  inline void tstLog(const std::ostringstream )
-  {
-  fprintf(stderr, "%s", stream.str().c_str());
-  }
+inline void tstLog(const std::ostringstream& stream) { 
writeTestLog(stream.str()); }
 #endif
-#define TST_LOG_NAME_BEGIN(NAME, X) do { \
-char t[64]; Poco::DateTime time; snprintf(t, 
sizeof(t), "%.2u:%.2u:%.2u.%.6u (@%zums) ", \
-time.hour(), time.minute(), time.second(), 
time.millisecond() * 1000 + time.microsecond(), 
helpers::timeSinceTestStartMs()); \
-std::ostringstream str; str << NAME << t << X; 
tstLog(str); } while (false)
-#define TST_LOG_BEGIN(X) TST_LOG_NAME_BEGIN(testname, X)
-#define TST_LOG_APPEND(X) do { std::ostringstream str; str << X; tstLog(str); 
} while (false)
-#define TST_LOG_END do { std::ostringstream str; str << "| " << __FILE__ << 
':' << __LINE__ << std::endl; tstLog(str); } while (false)
-#define TST_LOG_NAME(NAME, X) TST_LOG_NAME_BEGIN(NAME, X); TST_LOG_END
+
+#define TST_LOG_NAME_BEGIN(OSS, NAME, X, FLUSH)
\
+do 
\
+{  
\
+char t[64];
\
+Poco::DateTime time;   
\
+snprintf(t, sizeof(t), "%.2u:%.2u:%.2u.%.6u (@%zums) ", time.hour(), 
time.minute(),\
+ time.second(), time.millisecond() * 1000 + 
time.microsecond(),\
+ helpers::timeSinceTestStartMs()); 
\
+OSS << NAME << t << X; 
\
+if (FLUSH) 
\
+tstLog(OSS);   
\
+} while (false)
+
+#define TST_LOG_BEGIN(X)   
\
+do 
\
+{  
\
+std::ostringstream oss;
\
+TST_LOG_NAME_BEGIN(oss, testname, X, true);
\
+} while (false)
+
+#define TST_LOG_APPEND(X)  
\
+do 
\
+{  
\
+std::ostringstream str;
\
+str << X;  
\
+tstLog(str);   
\
+} while (false)
+
+#define TST_LOG_END_X(OSS)   

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

2020-02-17 Thread Miklos Vajna (via logerrit)
 test/helpers.hpp |3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

New commits:
commit 8c9e539586e863adef7ca811eeec086289435ea0
Author: Miklos Vajna 
AuthorDate: Mon Feb 17 09:08:34 2020 +0100
Commit: Miklos Vajna 
CommitDate: Mon Feb 17 10:09:05 2020 +0100

test: improve timeout handling in getResponseMessage()

Sometimes unit-each-view fails on me in a situation like this:

21:00:13.331257 [ loolwsd ] TRC  debug, testEachView: waiting for message, 
timeout after 20s| UnitEachView.cpp:66
21:00:20.429615 [ loolwsd ] TRC  debug, testEachView: response is empty, 
will fail| UnitEachView.cpp:72

I.e. for some reason ws.poll() returns after 7 seconds, even if the
timeout at test/UnitEachView.cpp is clearly 20 seconds.

Fix the problem by trying again in case we got no data -- we'll still
break from the loop on timeout.

Change-Id: I913ecd692f350b9deb38705a0a2d24e8b3c799a0
Reviewed-on: https://gerrit.libreoffice.org/c/online/+/88846
Tested-by: Jenkins CollaboraOffice 
Reviewed-by: Miklos Vajna 

diff --git a/test/helpers.hpp b/test/helpers.hpp
index 9aa15d518..1a0205475 100644
--- a/test/helpers.hpp
+++ b/test/helpers.hpp
@@ -289,7 +289,8 @@ std::vector getResponseMessage(LOOLWebSocket& ws, 
const std::string& prefi
 
 if (bytes <= 0)
 {
-break;
+// Try again, timeout will be handled above.
+continue;
 }
 
 if ((flags & Poco::Net::WebSocket::FRAME_OP_BITMASK) != 
Poco::Net::WebSocket::FRAME_OP_CLOSE)
___
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/TileQueueTests.cpp test/WhiteBoxTests.cpp wsd/LOOLWSD.cpp

2019-11-22 Thread Corentin Noël (via logerrit)
 test/TileQueueTests.cpp |   38 +++
 test/WhiteBoxTests.cpp  |   58 
 test/helpers.hpp|2 -
 wsd/LOOLWSD.cpp |2 -
 4 files changed, 50 insertions(+), 50 deletions(-)

New commits:
commit 62ed202e2d7cd244e2c0a4189d9a2bdc838e6943
Author: Corentin Noël 
AuthorDate: Fri Nov 22 10:47:55 2019 +0100
Commit: Jan Holesovsky 
CommitDate: Fri Nov 22 11:20:57 2019 +0100

Fix issues with size_t and ssize_t on 32bits machines

Change-Id: I3859e12e234b0fec6b94736cacc7874cd8809476
Reviewed-on: https://gerrit.libreoffice.org/83449
Reviewed-by: Jan Holesovsky 
Tested-by: Jan Holesovsky 

diff --git a/test/TileQueueTests.cpp b/test/TileQueueTests.cpp
index 209c5ffa9..1804ee8bf 100644
--- a/test/TileQueueTests.cpp
+++ b/test/TileQueueTests.cpp
@@ -280,7 +280,7 @@ void TileQueueTests::testSenderQueue()
 
 // Empty queue
 CPPUNIT_ASSERT_EQUAL(false, queue.dequeue(item));
-CPPUNIT_ASSERT_EQUAL(0UL, queue.size());
+CPPUNIT_ASSERT_EQUAL(static_cast(0), queue.size());
 
 const std::vector messages =
 {
@@ -294,21 +294,21 @@ void TileQueueTests::testSenderQueue()
 queue.enqueue(std::make_shared(msg, Message::Dir::Out));
 }
 
-CPPUNIT_ASSERT_EQUAL(3UL, queue.size());
+CPPUNIT_ASSERT_EQUAL(static_cast(3), queue.size());
 
 CPPUNIT_ASSERT_EQUAL(true, queue.dequeue(item));
-CPPUNIT_ASSERT_EQUAL(2UL, queue.size());
+CPPUNIT_ASSERT_EQUAL(static_cast(2), queue.size());
 CPPUNIT_ASSERT_EQUAL(messages[0], std::string(item->data().data(), 
item->data().size()));
 
 CPPUNIT_ASSERT_EQUAL(true, queue.dequeue(item));
-CPPUNIT_ASSERT_EQUAL(1UL, queue.size());
+CPPUNIT_ASSERT_EQUAL(static_cast(1), queue.size());
 CPPUNIT_ASSERT_EQUAL(messages[1], std::string(item->data().data(), 
item->data().size()));
 
 CPPUNIT_ASSERT_EQUAL(true, queue.dequeue(item));
-CPPUNIT_ASSERT_EQUAL(0UL, queue.size());
+CPPUNIT_ASSERT_EQUAL(static_cast(0), queue.size());
 CPPUNIT_ASSERT_EQUAL(messages[2], std::string(item->data().data(), 
item->data().size()));
 
-CPPUNIT_ASSERT_EQUAL(0UL, queue.size());
+CPPUNIT_ASSERT_EQUAL(static_cast(0), queue.size());
 }
 
 void TileQueueTests::testSenderQueueTileDeduplication()
@@ -319,7 +319,7 @@ void TileQueueTests::testSenderQueueTileDeduplication()
 
 // Empty queue
 CPPUNIT_ASSERT_EQUAL(false, queue.dequeue(item));
-CPPUNIT_ASSERT_EQUAL(0UL, queue.size());
+CPPUNIT_ASSERT_EQUAL(static_cast(0), queue.size());
 
 const std::vector part_messages =
 {
@@ -333,12 +333,12 @@ void TileQueueTests::testSenderQueueTileDeduplication()
 queue.enqueue(std::make_shared(msg, Message::Dir::Out));
 }
 
-CPPUNIT_ASSERT_EQUAL(3UL, queue.size());
+CPPUNIT_ASSERT_EQUAL(static_cast(3), queue.size());
 CPPUNIT_ASSERT_EQUAL(true, queue.dequeue(item));
 CPPUNIT_ASSERT_EQUAL(true, queue.dequeue(item));
 CPPUNIT_ASSERT_EQUAL(true, queue.dequeue(item));
 
-CPPUNIT_ASSERT_EQUAL(0UL, queue.size());
+CPPUNIT_ASSERT_EQUAL(static_cast(0), queue.size());
 
 const std::vector dup_messages =
 {
@@ -352,13 +352,13 @@ void TileQueueTests::testSenderQueueTileDeduplication()
 queue.enqueue(std::make_shared(msg, Message::Dir::Out));
 }
 
-CPPUNIT_ASSERT_EQUAL(1UL, queue.size());
+CPPUNIT_ASSERT_EQUAL(static_cast(1), queue.size());
 CPPUNIT_ASSERT_EQUAL(true, queue.dequeue(item));
 
 // The last one should persist.
 CPPUNIT_ASSERT_EQUAL(dup_messages[2], std::string(item->data().data(), 
item->data().size()));
 
-CPPUNIT_ASSERT_EQUAL(0UL, queue.size());
+CPPUNIT_ASSERT_EQUAL(static_cast(0), queue.size());
 }
 
 void TileQueueTests::testInvalidateViewCursorDeduplication()
@@ -369,7 +369,7 @@ void TileQueueTests::testInvalidateViewCursorDeduplication()
 
 // Empty queue
 CPPUNIT_ASSERT_EQUAL(false, queue.dequeue(item));
-CPPUNIT_ASSERT_EQUAL(0UL, queue.size());
+CPPUNIT_ASSERT_EQUAL(static_cast(0), queue.size());
 
 const std::vector view_messages =
 {
@@ -383,21 +383,21 @@ void 
TileQueueTests::testInvalidateViewCursorDeduplication()
 queue.enqueue(std::make_shared(msg, Message::Dir::Out));
 }
 
-CPPUNIT_ASSERT_EQUAL(3UL, queue.size());
+CPPUNIT_ASSERT_EQUAL(static_cast(3), queue.size());
 
 CPPUNIT_ASSERT_EQUAL(true, queue.dequeue(item));
-CPPUNIT_ASSERT_EQUAL(2UL, queue.size());
+CPPUNIT_ASSERT_EQUAL(static_cast(2), queue.size());
 CPPUNIT_ASSERT_EQUAL(view_messages[0], std::string(item->data().data(), 
item->data().size()));
 
 CPPUNIT_ASSERT_EQUAL(true, queue.dequeue(item));
-CPPUNIT_ASSERT_EQUAL(1UL, queue.size());
+CPPUNIT_ASSERT_EQUAL(static_cast(1), queue.size());
 CPPUNIT_ASSERT_EQUAL(view_messages[1], std::string(item->data().data(), 
item->data().size()));
 
 CPPUNIT_ASSERT_EQUAL(true, queue.dequeue(item));
-CPPUNIT_ASSERT_EQUAL(0UL, 

[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/httpcrashtest.cpp

2019-08-30 Thread Miklos Vajna (via logerrit)
 test/helpers.hpp   |   13 +
 test/httpcrashtest.cpp |8 +++-
 2 files changed, 16 insertions(+), 5 deletions(-)

New commits:
commit 51b8ed7309979548c1f72918edab29b939eae488
Author: Miklos Vajna 
AuthorDate: Fri Aug 30 12:22:04 2019 +0200
Commit: Miklos Vajna 
CommitDate: Fri Aug 30 12:22:11 2019 +0200

Try to avoid a timing problem in HTTPCrashTest::testRecoverAfterKitCrash()

In case we fail to open the document, try again in 2 seconds (same value
as in HTTPServerTest::testConvertTo()). This seems to be needed fore
core.git dbgutil builds, but don't do that unconditionally, in case the
sleep is not needed for optimized core.git.

Change-Id: I4585d1f273bfa5fffc4b02bc6107f27a2c9e1280

diff --git a/test/helpers.hpp b/test/helpers.hpp
index 708806cd2..19bf0b516 100644
--- a/test/helpers.hpp
+++ b/test/helpers.hpp
@@ -416,7 +416,7 @@ connectLOKit(const Poco::URI& uri,
 }
 
 inline
-std::shared_ptr loadDocAndGetSocket(const Poco::URI& uri, const 
std::string& documentURL, const std::string& testname, bool isView = true)
+std::shared_ptr loadDocAndGetSocket(const Poco::URI& uri, const 
std::string& documentURL, const std::string& testname, bool isView = true, bool 
isAssert = true)
 {
 try
 {
@@ -426,7 +426,12 @@ std::shared_ptr loadDocAndGetSocket(const 
Poco::URI& uri, const s
 std::shared_ptr socket = connectLOKit(uri, request, 
response, testname);
 
 sendTextFrame(socket, "load url=" + documentURL, testname);
-CPPUNIT_ASSERT_MESSAGE("cannot load the document " + documentURL, 
isDocumentLoaded(*socket, testname, isView));
+bool isLoaded = isDocumentLoaded(*socket, testname, isView);
+if (!isLoaded && !isAssert)
+{
+return nullptr;
+}
+CPPUNIT_ASSERT_MESSAGE("cannot load the document " + documentURL, 
isLoaded);
 
 TST_LOG("Loaded document [" << documentURL << "].");
 return socket;
@@ -441,13 +446,13 @@ std::shared_ptr loadDocAndGetSocket(const 
Poco::URI& uri, const s
 }
 
 inline
-std::shared_ptr loadDocAndGetSocket(const std::string& 
docFilename, const Poco::URI& uri, const std::string& testname, bool isView = 
true)
+std::shared_ptr loadDocAndGetSocket(const std::string& 
docFilename, const Poco::URI& uri, const std::string& testname, bool isView = 
true, bool isAssert = true)
 {
 try
 {
 std::string documentPath, documentURL;
 getDocumentPathAndURL(docFilename, documentPath, documentURL, 
testname);
-return loadDocAndGetSocket(uri, documentURL, testname, isView);
+return loadDocAndGetSocket(uri, documentURL, testname, isView, 
isAssert);
 }
 catch (const Poco::Exception& exc)
 {
diff --git a/test/httpcrashtest.cpp b/test/httpcrashtest.cpp
index 8636c5cea..d0769e9ef 100644
--- a/test/httpcrashtest.cpp
+++ b/test/httpcrashtest.cpp
@@ -198,7 +198,13 @@ void HTTPCrashTest::testRecoverAfterKitCrash()
 // We expect the client connection to close.
 TST_LOG("Reconnect after kill.");
 
-std::shared_ptr socket2 = 
loadDocAndGetSocket("empty.odt", _uri, testname);
+std::shared_ptr socket2 = 
loadDocAndGetSocket("empty.odt", _uri, testname, /*isView=*/true, 
/*isAssert=*/false);
+if (!socket2)
+{
+// In case still starting up.
+sleep(2);
+socket2 = loadDocAndGetSocket("empty.odt", _uri, testname);
+}
 sendTextFrame(socket2, "status", testname);
 assertResponseString(socket2, "status:", testname);
 }
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits

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

2019-05-06 Thread Libreoffice Gerrit user
 test/helpers.hpp |3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

New commits:
commit 21012c1c74f143a5826802a8db5c964dfb0ad27f
Author: Andras Timar 
AuthorDate: Mon May 6 22:43:56 2019 +0200
Commit: Andras Timar 
CommitDate: Mon May 6 23:11:08 2019 +0200

do not ignore the result of fwrite...

... at least from compiler point of view.
On some systems with old glibc (<= 2.15) the fwrite function has
the warn_unused_result attribute. That makes the build fail.
Starting with glibc 2.16 the attribute was removed [1].

[1]
The bug: https://sourceware.org/bugzilla/show_bug.cgi?id=11959
Release notes to 2.16:
https://sourceware.org/ml/libc-alpha/2012-06/msg00807.html

Change-Id: Ia62ccff2120dce51e311303124aadc60c134a1aa
Reviewed-on: https://gerrit.libreoffice.org/71880
Reviewed-by: Andras Timar 
Tested-by: Andras Timar 

diff --git a/test/helpers.hpp b/test/helpers.hpp
index 2445ef3d2..0bbd3c686 100644
--- a/test/helpers.hpp
+++ b/test/helpers.hpp
@@ -660,7 +660,8 @@ inline bool svgMatch(const char *testname, const 
std::vector , co
 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);
+size_t unused = fwrite(response.data(), response.size(), 1, of);
+(void)unused;
 fclose(of);
 return false;
 }
___
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/test.cpp

2019-03-04 Thread Libreoffice Gerrit user
 test/helpers.hpp |   17 +
 test/test.cpp|   17 +++--
 2 files changed, 24 insertions(+), 10 deletions(-)

New commits:
commit 0c46b33e7213bf4f91d6f93ad73da9dc79718164
Author: Michael Meeks 
AuthorDate: Mon Mar 4 22:02:59 2019 +0100
Commit: Michael Meeks 
CommitDate: Mon Mar 4 22:04:46 2019 +0100

Don't use the same std::ostringstream from multiple threads.

Avoids tests crashing with obscure memory errors re-allocating the
string buffer; and hopefully cleans up the output too.

Change-Id: I3e38680c15129e84f0c7dd8cada3b505cf08ad34

diff --git a/test/helpers.hpp b/test/helpers.hpp
index bc4818d98..592d61b0e 100644
--- a/test/helpers.hpp
+++ b/test/helpers.hpp
@@ -37,11 +37,20 @@
 #error TDOC must be defined (see Makefile.am)
 #endif
 
-// Logging in unit-tests go to cerr, for now at least.
-#define TST_LOG_NAME_BEGIN(NAME, X) do { std::cerr << NAME << "(@" << 
helpers::timeSinceTestStartMs() << "ms) " << X; } while (false)
+// Oh dear std::cerr and/or its re-direction is not
+// necessarily thread safe on Linux
+#ifdef TST_LOG_REDIRECT
+  void tstLog(const std::ostringstream );
+#else
+  inline void tstLog(const std::ostringstream )
+  {
+  fprintf(stderr, "%s", stream.str().c_str());
+  }
+#endif
+#define TST_LOG_NAME_BEGIN(NAME, X) do { std::ostringstream str; str << NAME 
<< "(@" << helpers::timeSinceTestStartMs() << "ms) " << X; tstLog(str); } while 
(false)
 #define TST_LOG_BEGIN(X) TST_LOG_NAME_BEGIN(testname, X)
-#define TST_LOG_APPEND(X) do { std::cerr << X; } while (false)
-#define TST_LOG_END do { std::cerr << "| " << __FILE__ << ':' << __LINE__ << 
std::endl; } while (false)
+#define TST_LOG_APPEND(X) do { std::ostringstream str; str << X; tstLog(str); 
} while (false)
+#define TST_LOG_END do { std::ostringstream str; str << "| " << __FILE__ << 
':' << __LINE__ << std::endl; tstLog(str); } while (false)
 #define TST_LOG_NAME(NAME, X) TST_LOG_NAME_BEGIN(NAME, X); TST_LOG_END
 #define TST_LOG(X) TST_LOG_NAME(testname, X)
 
diff --git a/test/test.cpp b/test/test.cpp
index f09e1f855..0b905fb54 100644
--- a/test/test.cpp
+++ b/test/test.cpp
@@ -7,6 +7,7 @@
  * file, You can obtain one at http://mozilla.org/MPL/2.0/.
  */
 
+#define TST_LOG_REDIRECT
 #include 
 
 #include 
@@ -79,6 +80,15 @@ bool isStandalone()
 return IsStandalone;
 }
 
+static std::mutex errorMutex;
+static std::stringstream errors;
+
+void tstLog(const std::ostringstream )
+{
+std::lock_guard lock(errorMutex);
+errors << stream.str();
+}
+
 // returns true on success
 bool runClientTests(bool standalone, bool verbose)
 {
@@ -119,16 +129,11 @@ bool runClientTests(bool standalone, bool verbose)
 if (!verbose)
 {
 // redirect std::cerr temporarily
-std::stringstream errorBuffer;
-std::streambuf* oldCerr = std::cerr.rdbuf(errorBuffer.rdbuf());
-
 runner.run(controller);
 
-std::cerr.rdbuf(oldCerr);
-
 // output the errors we got during the testing
 if (!result.wasSuccessful())
-std::cerr << errorBuffer.str() << std::endl;
+std::cerr << errors.str() << std::endl;
 }
 else
 {
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits

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

2018-08-27 Thread Libreoffice Gerrit user
 test/helpers.hpp |2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

New commits:
commit 9a4626ae0d458d4dd274a25e384d97415f73e3e9
Author: Miklos Vajna 
AuthorDate: Mon Aug 27 09:10:01 2018 +0200
Commit: Miklos Vajna 
CommitDate: Mon Aug 27 09:10:10 2018 +0200

test: no need to copy testname

diff --git a/test/helpers.hpp b/test/helpers.hpp
index 54c37a8ce..13b351762 100644
--- a/test/helpers.hpp
+++ b/test/helpers.hpp
@@ -327,7 +327,7 @@ std::string assertResponseString(T& ws, const std::string& 
prefix, const std::st
 
 /// Assert that we don't get a response with the given prefix.
 template 
-std::string assertNotInResponse(T& ws, const std::string& prefix, const 
std::string testname)
+std::string assertNotInResponse(T& ws, const std::string& prefix, const 
std::string& testname)
 {
 const auto res = getResponseString(ws, prefix, testname, 1000);
 CPPUNIT_ASSERT_MESSAGE(testname + "Did not expect getting message [" + res 
+ "].", res.empty());
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


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

2018-06-15 Thread Andras Timar
 test/helpers.hpp |2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

New commits:
commit 1fd5dbd787eb4b984f6bcca0b39f9be92e9d207c
Author: Andras Timar 
Date:   Fri Jun 15 15:14:14 2018 +0200

Do not use the word 'Error' here (tinderbox)

Change-Id: If5bbfceb624974801ffb84e52e6aa1b7e599a7ae

diff --git a/test/helpers.hpp b/test/helpers.hpp
index 22b97dbcb..366ee9ff1 100644
--- a/test/helpers.hpp
+++ b/test/helpers.hpp
@@ -378,7 +378,7 @@ connectLOKit(const Poco::URI& uri,
 catch (const std::exception& ex)
 {
 TST_LOG_END;
-TST_LOG("Error connecting: " << ex.what());
+TST_LOG("Connection problem: " << ex.what());
 }
 
 
std::this_thread::sleep_for(std::chrono::milliseconds(POLL_TIMEOUT_MS));
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


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

2017-06-15 Thread Miklos Vajna
 test/helpers.hpp |1 +
 1 file changed, 1 insertion(+)

New commits:
commit de785d90b26f5462fa21736fef130e9bf775afef
Author: Miklos Vajna 
Date:   Thu Jun 15 21:03:09 2017 +0200

test: give the socket the chance to get the error in getErrorCode()

make check fails for me like this:

Test name: HTTPCrashTest::testCrashKit
equality assertion failed
- Expected: 1001
- Actual  : 65535

Failures !!!
Run: 1   Failure total: 1   Failures: 1   Errors: 0

But when I run loolwsd and ./test manually (./test is invoked by gdb) and I
step through the code, then the test passes. So I guess what happens is 
that we
read from the socket too fast, and the error we're looking for is just not
there yet. Add the same amount of sleep here (0.5s) than what's used in
connectLOKit(), with that the test passes fine.

(The sleep is in test-only code.)

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

diff --git a/test/helpers.hpp b/test/helpers.hpp
index 97f91929..220ffd30 100644
--- a/test/helpers.hpp
+++ b/test/helpers.hpp
@@ -166,6 +166,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;
+
std::this_thread::sleep_for(std::chrono::milliseconds(POLL_TIMEOUT_MS));
 }
 while (bytes > 0 && (flags & Poco::Net::WebSocket::FRAME_OP_BITMASK) != 
Poco::Net::WebSocket::FRAME_OP_CLOSE);
 
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


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

2017-05-01 Thread Ashod Nakashian
 test/helpers.hpp |   31 +++
 1 file changed, 31 insertions(+)

New commits:
commit 7b9e949adc20a7920a58d06530a60d34b6581c65
Author: Ashod Nakashian 
Date:   Tue May 2 00:01:28 2017 -0400

wsd: add test helper to get server version

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

diff --git a/test/helpers.hpp b/test/helpers.hpp
index 1b00b2e3..97f91929 100644
--- a/test/helpers.hpp
+++ b/test/helpers.hpp
@@ -13,6 +13,9 @@
 #include 
 
 #include 
+#include 
+#include 
+#include 
 #include 
 #include 
 #include 
@@ -567,6 +570,34 @@ inline std::vector 
getTileAndSave(std::shared_ptr& socket,
 return res;
 }
 
+inline void getServerVersion(LOOLWebSocket& socket,
+ int& major, int& minor,
+ const std::string& testname)
+{
+const std::string clientVersion = "loolclient 0.1";
+sendTextFrame(socket, clientVersion);
+std::vector loVersion = getResponseMessage(socket, "lokitversion", 
testname);
+std::string line = LOOLProtocol::getFirstLine(loVersion.data(), 
loVersion.size());
+line = line.substr(strlen("lokitversion "));
+Poco::JSON::Parser parser;
+Poco::Dynamic::Var loVersionVar = parser.parse(line);
+const Poco::SharedPtr& loVersionObject = 
loVersionVar.extract();
+std::string loProductVersion = 
loVersionObject->get("ProductVersion").toString();
+std::istringstream stream(loProductVersion);
+stream >> major;
+assert(stream.get() == '.');
+stream >> minor;
+
+std::cerr << testname << "Client [" << major << '.' << minor << "]." << 
std::endl;
+}
+
+inline void getServerVersion(std::shared_ptr& socket,
+ int& major, int& minor,
+ const std::string& testname)
+{
+getServerVersion(*socket, major, minor, testname);
+}
+
 }
 
 #endif
___
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

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/httpwserror.cpp test/TileCacheTests.cpp

2017-04-16 Thread Ashod Nakashian
 test/TileCacheTests.cpp |4 
 test/helpers.hpp|   21 ++---
 test/httpwserror.cpp|3 +++
 3 files changed, 9 insertions(+), 19 deletions(-)

New commits:
commit 0feea0e80e5da95baa6554ad660df676613443fd
Author: Ashod Nakashian 
Date:   Sun Apr 16 23:31:03 2017 -0400

wsd: include cleanup in test

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

diff --git a/test/TileCacheTests.cpp b/test/TileCacheTests.cpp
index 128f559d..227f7adb 100644
--- a/test/TileCacheTests.cpp
+++ b/test/TileCacheTests.cpp
@@ -9,6 +9,10 @@
 
 #include "config.h"
 
+#include 
+#include 
+#include 
+
 #include 
 
 #include "Common.hpp"
diff --git a/test/helpers.hpp b/test/helpers.hpp
index ce6aef98..70bf6e4c 100644
--- a/test/helpers.hpp
+++ b/test/helpers.hpp
@@ -10,41 +10,24 @@
 #ifndef INCLUDED_TEST_HELPERS_HPP
 #define INCLUDED_TEST_HELPERS_HPP
 
-#include 
-#include 
-#include 
-#include 
-#include 
-#include 
+#include 
 
 #include 
-#include 
-#include 
-#include 
-#include 
-#include 
-#include 
 #include 
 #include 
 #include 
 #include 
-#include 
 #include 
-#include 
-#include 
 #include 
 #include 
-#include 
 #include 
-#include 
 #include 
+
 #include 
 
 #include 
 #include "common/FileUtil.hpp"
-#include 
 #include 
-#include 
 #include 
 
 #ifndef TDOC
diff --git a/test/httpwserror.cpp b/test/httpwserror.cpp
index ff417f25..a0663f63 100644
--- a/test/httpwserror.cpp
+++ b/test/httpwserror.cpp
@@ -12,11 +12,14 @@
 #include 
 #include 
 
+#include 
 #include 
 #include 
 #include 
 #include 
+#include 
 #include 
+#include 
 #include 
 
 #include 
___
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

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


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

2017-01-15 Thread Ashod Nakashian
 test/helpers.hpp |   12 ++--
 test/httpwserror.cpp |4 ++--
 2 files changed, 8 insertions(+), 8 deletions(-)

New commits:
commit 8cbf478bfe2e8b947f42f02b8224d71cd9ef1f6b
Author: Ashod Nakashian 
Date:   Sun Jan 15 12:15:11 2017 -0500

wsd: improved getErrorCode

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

diff --git a/test/helpers.hpp b/test/helpers.hpp
index fce1cfd..4dd8f86 100644
--- a/test/helpers.hpp
+++ b/test/helpers.hpp
@@ -162,7 +162,7 @@ std::string const & getTestServerURI()
 }
 
 inline
-int getErrorCode(LOOLWebSocket& ws, std::string& message)
+int getErrorCode(LOOLWebSocket& ws, std::string& message, const std::string& 
testname = "")
 {
 int flags = 0;
 int bytes = 0;
@@ -170,13 +170,13 @@ int getErrorCode(LOOLWebSocket& ws, std::string& message)
 Poco::Buffer buffer(READ_BUFFER_SIZE);
 
 message.clear();
-Poco::Timespan timeout(500);
-ws.setReceiveTimeout(timeout);
+ws.setReceiveTimeout(Poco::Timespan(500));
 do
 {
 bytes = ws.receiveFrame(buffer.begin(), READ_BUFFER_SIZE, flags);
+std::cerr << testname << "Got " << 
LOOLProtocol::getAbbreviatedFrameDump(buffer.begin(), bytes, flags) << 
std::endl;
 }
-while ((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)
 {
@@ -189,9 +189,9 @@ int getErrorCode(LOOLWebSocket& ws, std::string& message)
 }
 
 inline
-int getErrorCode(const std::shared_ptr& ws, std::string& 
message)
+int getErrorCode(const std::shared_ptr& ws, std::string& 
message, const std::string& testname = "")
 {
-return getErrorCode(*ws, message);
+return getErrorCode(*ws, message, testname);
 }
 
 inline
diff --git a/test/httpwserror.cpp b/test/httpwserror.cpp
index e624e46..3ed8421 100644
--- a/test/httpwserror.cpp
+++ b/test/httpwserror.cpp
@@ -116,7 +116,7 @@ void HTTPWSError::testMaxDocuments()
 assertResponseString(socket, "error:", testname);
 
 std::string message;
-const auto statusCode = getErrorCode(socket, message);
+const auto statusCode = getErrorCode(socket, message, testname);
 
CPPUNIT_ASSERT_EQUAL(static_cast(Poco::Net::WebSocket::WS_POLICY_VIOLATION),
 statusCode);
 
 socket->shutdown();
@@ -171,7 +171,7 @@ void HTTPWSError::testMaxConnections()
 sendTextFrame(socketN, "load url=" + docURL, testname);
 
 std::string message;
-const auto statusCode = getErrorCode(socketN, message);
+const auto statusCode = getErrorCode(socketN, message, testname);
 
CPPUNIT_ASSERT_EQUAL(static_cast(Poco::Net::WebSocket::WS_POLICY_VIOLATION),
 statusCode);
 
 socketN->shutdown();
___
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/httpwserror.cpp

2017-01-03 Thread Ashod Nakashian
 test/helpers.hpp |6 ++
 test/httpwserror.cpp |   23 ++-
 2 files changed, 20 insertions(+), 9 deletions(-)

New commits:
commit 606f85db8753e3d1f44b8fbf10be609e9bd5ccb7
Author: Ashod Nakashian 
Date:   Tue Jan 3 17:02:53 2017 -0500

wsd: fixup max connections unittest

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

diff --git a/test/helpers.hpp b/test/helpers.hpp
index 6c70fdd..4c9d191 100644
--- a/test/helpers.hpp
+++ b/test/helpers.hpp
@@ -188,6 +188,12 @@ int getErrorCode(LOOLWebSocket& ws, std::string& message)
 }
 
 inline
+int getErrorCode(const std::shared_ptr& ws, std::string& 
message)
+{
+return getErrorCode(*ws, message);
+}
+
+inline
 std::vector getResponseMessage(LOOLWebSocket& ws, const std::string& 
prefix, std::string name = "", const size_t timeoutMs = 1)
 {
 name = name + '[' + prefix + "] ";
diff --git a/test/httpwserror.cpp b/test/httpwserror.cpp
index 3db733d..c001abf 100644
--- a/test/httpwserror.cpp
+++ b/test/httpwserror.cpp
@@ -142,8 +142,16 @@ void HTTPWSError::testMaxDocuments()
 
 void HTTPWSError::testMaxConnections()
 {
-#if MAX_CONNECTIONS > 0
+static_assert(MAX_CONNECTIONS >= 3, "MAX_CONNECTIONS must be at least 3");
 const auto testname = "maxConnections ";
+
+if (MAX_CONNECTIONS > 100)
+{
+std::cerr << "Skipping " << testname << "test since MAX_CONNECTION (" 
<< MAX_CONNECTIONS
+  << ") is too high to test. Set to a more sensible number, 
ideally a dozen or so." << std::endl;
+return;
+}
+
 try
 {
 std::cerr << "Opening max number of connections: " << MAX_CONNECTIONS 
<< std::endl;
@@ -158,7 +166,7 @@ void HTTPWSError::testMaxConnections()
 std::cerr << "Opened connect #1 of " << MAX_CONNECTIONS << std::endl;
 
 std::vector views;
-for(int it = 1; it < MAX_CONNECTIONS; it++)
+for (int it = 1; it < MAX_CONNECTIONS; ++it)
 {
 std::unique_ptr 
session(createSession(_uri));
 auto ws = std::make_shared(*session, request, 
_response);
@@ -170,24 +178,21 @@ void HTTPWSError::testMaxConnections()
 
 // try to connect MAX_CONNECTIONS + 1
 std::unique_ptr 
session(createSession(_uri));
-LOOLWebSocket socketN(*session, request, _response);
+auto socketN = std::make_shared(*session, request, 
_response);
 
-// send loolclient, load and partpagerectangles
-sendTextFrame(socketN, "loolclient ", testname);
-sendTextFrame(socketN, "load ", testname);
-sendTextFrame(socketN, "partpagerectangles ", testname);
+// Send load request, which will fail.
+sendTextFrame(socketN, "load url=" + docURL, testname);
 
 std::string message;
 const auto statusCode = getErrorCode(socketN, message);
 
CPPUNIT_ASSERT_EQUAL(static_cast(Poco::Net::WebSocket::WS_POLICY_VIOLATION),
 statusCode);
 
-socketN.shutdown();
+socketN->shutdown();
 }
 catch (const Poco::Exception& exc)
 {
 CPPUNIT_FAIL(exc.displayText());
 }
-#endif
 }
 
 CPPUNIT_TEST_SUITE_REGISTRATION(HTTPWSError);
___
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/TileCacheTests.cpp

2017-01-01 Thread Ashod Nakashian
 test/TileCacheTests.cpp |   71 +---
 test/helpers.hpp|2 -
 2 files changed, 51 insertions(+), 22 deletions(-)

New commits:
commit 7dad1c5f6a64445bbefa2821e06beda8716bbc05
Author: Ashod Nakashian 
Date:   Sun Jan 1 23:18:44 2017 -0500

wsd: more forgiving canceltiles unittests

canceltiles is not guaranteed to prevent
tiles from getting sent back to the client.

There is an obvious race between receiving
tile requets and cancelling them.

This reduces failures by repeating the
unittest when there is spurious failure.

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

diff --git a/test/TileCacheTests.cpp b/test/TileCacheTests.cpp
index 30897a0..df8e336 100644
--- a/test/TileCacheTests.cpp
+++ b/test/TileCacheTests.cpp
@@ -236,13 +236,30 @@ void TileCacheTests::testPerformance()
 void TileCacheTests::testCancelTiles()
 {
 const auto testName = "cancelTiles ";
-auto socket = loadDocAndGetSocket("setclientpart.ods", _uri, testName);
 
-// Request a huge tile, and cancel immediately.
-sendTextFrame(socket, "tilecombine part=0 width=2560 height=2560 
tileposx=0 tileposy=0 tilewidth=38400 tileheight=38400");
-sendTextFrame(socket, "canceltiles");
+// The tile response can race past the canceltiles,
+// so be forgiving to avoid spurious failures.
+const size_t repeat = 4;
+for (size_t i = 1; i <= repeat; ++i)
+{
+std::cerr << "cancelTiles try #" << i << std::endl;
+
+auto socket = loadDocAndGetSocket("setclientpart.ods", _uri, testName);
 
-assertNotInResponse(socket, "tile:", testName);
+// Request a huge tile, and cancel immediately.
+sendTextFrame(socket, "tilecombine part=0 width=2560 height=2560 
tileposx=0 tileposy=0 tilewidth=38400 tileheight=38400");
+sendTextFrame(socket, "canceltiles");
+
+const auto res = getResponseString(socket, "tile:", testName, 1000);
+if (res.empty())
+{
+break;
+}
+else if (i == repeat)
+{
+CPPUNIT_ASSERT_MESSAGE("Did not expect getting message [" + res + 
"].", res.empty());
+}
+}
 }
 
 void TileCacheTests::testCancelTilesMultiView()
@@ -250,27 +267,39 @@ void TileCacheTests::testCancelTilesMultiView()
 std::string documentPath, documentURL;
 getDocumentPathAndURL("setclientpart.ods", documentPath, documentURL);
 
-auto socket1 = loadDocAndGetSocket(_uri, documentURL, 
"cancelTilesMultiView-1 ");
-auto socket2 = loadDocAndGetSocket(_uri, documentURL, 
"cancelTilesMultiView-2 ", true);
+// The tile response can race past the canceltiles,
+// so be forgiving to avoid spurious failures.
+const size_t repeat = 4;
+for (size_t j = 1; j <= repeat; ++j)
+{
+std::cerr << "cancelTilesMultiView try #" << j << std::endl;
 
-sendTextFrame(socket1, "tilecombine part=0 width=256 height=256 
tileposx=0,3840,7680,11520,0,3840,7680,11520 
tileposy=0,0,0,0,3840,3840,3840,3840 tilewidth=3840 tileheight=3840", 
"cancelTilesMultiView-1 ");
-sendTextFrame(socket2, "tilecombine part=0 width=256 height=256 
tileposx=0,3840,7680,0 tileposy=0,0,0,22520 tilewidth=3840 tileheight=3840", 
"cancelTilesMultiView-2 ");
+// Request a huge tile, and cancel immediately.
+auto socket1 = loadDocAndGetSocket(_uri, documentURL, 
"cancelTilesMultiView-1 ");
+auto socket2 = loadDocAndGetSocket(_uri, documentURL, 
"cancelTilesMultiView-2 ", true);
 
-sendTextFrame(socket1, "canceltiles");
+sendTextFrame(socket1, "tilecombine part=0 width=256 height=256 
tileposx=0,3840,7680,11520,0,3840,7680,11520 
tileposy=0,0,0,0,3840,3840,3840,3840 tilewidth=3840 tileheight=3840", 
"cancelTilesMultiView-1 ");
+sendTextFrame(socket2, "tilecombine part=0 width=256 height=256 
tileposx=0,3840,7680,0 tileposy=0,0,0,22520 tilewidth=3840 tileheight=3840", 
"cancelTilesMultiView-2 ");
 
-for (auto i = 0; i < 4; ++i)
-{
-getTileMessage(*socket2, "cancelTilesMultiView-2 ");
-}
+sendTextFrame(socket1, "canceltiles");
+auto res = getResponseString(socket1, "tile:", "cancelTilesMultiView-1 
", 1000);
+if (!res.empty() && j == repeat)
+{
+CPPUNIT_ASSERT_MESSAGE("Did not expect getting message [" + res + 
"].", res.empty());
+}
 
-// FIXME: Note that especially when this is run on a loaded machine, the 
server might not honor
-// the 'canceltiles' but still send out a tile, or it has already sent the 
tile before it even
-// gets the 'canceltiles'. That is not an error. It is a bit silly to have 
it cause an assertion
-// failure here. Transient failures make a unit test worse than no unit 
test. Should 

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

2016-12-27 Thread Noel Grandin
 test/helpers.hpp |2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

New commits:
commit f56549753a6b34a2e1105aefd41585bb66557738
Author: Noel Grandin 
Date:   Fri Dec 23 08:23:08 2016 +0200

loplugin:passstuffbyref

Change-Id: Ib9208e7585dbb8dfeab713daa173af190d9efebc
Reviewed-on: https://gerrit.libreoffice.org/32363
Reviewed-by: Tor Lillqvist 
Tested-by: Tor Lillqvist 

diff --git a/test/helpers.hpp b/test/helpers.hpp
index 9ab7855..61820a0 100644
--- a/test/helpers.hpp
+++ b/test/helpers.hpp
@@ -145,7 +145,7 @@ Poco::Net::HTTPClientSession* createSession(const 
Poco::URI& uri)
 }
 
 inline
-std::string getTestServerURI()
+std::string const & getTestServerURI()
 {
 static const char* clientPort = std::getenv("LOOL_TEST_CLIENT_PORT");
 
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits