loolwsd/test/helpers.hpp | 36 ------------------------------------ loolwsd/test/httpwstest.cpp | 33 ++++++++++----------------------- 2 files changed, 10 insertions(+), 59 deletions(-)
New commits: commit d681d9b8d475d3dd79c940ffb84bfce441d4cd69 Author: Ashod Nakashian <ashod.nakash...@collabora.co.uk> Date: Thu Oct 6 00:52:27 2016 -0400 loolwsd: testGraphicInvalidate cleanup Change-Id: I933aceb2873d393a93b942ccb13ab544aca4db9d Reviewed-on: https://gerrit.libreoffice.org/29547 Reviewed-by: Ashod Nakashian <ashnak...@gmail.com> Tested-by: Ashod Nakashian <ashnak...@gmail.com> diff --git a/loolwsd/test/helpers.hpp b/loolwsd/test/helpers.hpp index 01922e3..da1e8f9 100644 --- a/loolwsd/test/helpers.hpp +++ b/loolwsd/test/helpers.hpp @@ -267,42 +267,6 @@ void getResponseMessage(Poco::Net::WebSocket& ws, const std::string& prefix, std } inline -void collectMessages(Poco::Net::WebSocket& ws, const std::string& prefix, std::vector<std::string>& responses, int retries, const std::string& name = "") -{ - int flags = 0; - const Poco::Timespan waitTime(1000000); - - ws.setReceiveTimeout(0); - do - { - if (ws.poll(waitTime, Poco::Net::Socket::SELECT_READ)) - { - char buffer[READ_BUFFER_SIZE]; - int bytes = ws.receiveFrame(buffer, sizeof(buffer), flags); - if (bytes > 0 && (flags & Poco::Net::WebSocket::FRAME_OP_BITMASK) != Poco::Net::WebSocket::FRAME_OP_CLOSE) - { - std::cerr << name << "Got " << bytes << " bytes: " << LOOLProtocol::getAbbreviatedMessage(buffer, bytes) << std::endl; - const std::string message = std::string(buffer, bytes); - if (message.find(prefix) == 0) - { - responses.push_back(message); - } - } - else - { - std::cerr << name << "Got " << bytes << " bytes, flags: " << std::hex << flags << std::dec << '\n'; - } - } - else - { - std::cerr << name << "Timeout waiting for " << prefix << std::endl; - --retries; - } - } - while (retries > 0 && (flags & Poco::Net::WebSocket::FRAME_OP_BITMASK) != Poco::Net::WebSocket::FRAME_OP_CLOSE); -} - -inline std::vector<char> getResponseMessage(Poco::Net::WebSocket& ws, const std::string& prefix, std::string name = "", const size_t timeoutMs = 10000) { name = name + '[' + prefix + "] "; diff --git a/loolwsd/test/httpwstest.cpp b/loolwsd/test/httpwstest.cpp index 052cc27..e836aa2 100644 --- a/loolwsd/test/httpwstest.cpp +++ b/loolwsd/test/httpwstest.cpp @@ -2069,37 +2069,24 @@ void HTTPWSTest::testGraphicViewSelection() void HTTPWSTest::testGraphicInvalidate() { + const auto testname = "graphicInvalidate "; try { // Load a document. - std::string docPath; - std::string docURL; - std::string response; - std::vector<std::string> responses; - - getDocumentPathAndURL("shape.ods", docPath, docURL); - Poco::Net::HTTPRequest request(Poco::Net::HTTPRequest::HTTP_GET, docURL); - Poco::Net::WebSocket socket = *connectLOKit(_uri, request, _response); - - sendTextFrame(socket, "load url=" + docURL); - CPPUNIT_ASSERT_MESSAGE("cannot load the document " + docURL, isDocumentLoaded(socket)); + auto socket = *loadDocAndGetSocket("shape.ods", _uri, testname); // Send click message - sendTextFrame(socket, "mouse type=buttondown x=1035 y=400 count=1 buttons=1 modifier=0"); - sendTextFrame(socket, "mouse type=buttonup x=1035 y=400 count=1 buttons=1 modifier=0"); - getResponseMessage(socket, "graphicselection:", response, false, "testGraphicInvalidate "); + sendTextFrame(socket, "mouse type=buttondown x=1035 y=400 count=1 buttons=1 modifier=0", testname); + sendTextFrame(socket, "mouse type=buttonup x=1035 y=400 count=1 buttons=1 modifier=0", testname); + getResponseLine(socket, "graphicselection:", testname); // Drag & drop graphic - sendTextFrame(socket, "mouse type=buttondown x=1035 y=400 count=1 buttons=1 modifier=0"); - sendTextFrame(socket, "mouse type=move x=1035 y=450 count=1 buttons=1 modifier=0"); - sendTextFrame(socket, "mouse type=buttonup x=1035 y=450 count=1 buttons=1 modifier=0"); + sendTextFrame(socket, "mouse type=buttondown x=1035 y=400 count=1 buttons=1 modifier=0", testname); + sendTextFrame(socket, "mouse type=move x=1035 y=450 count=1 buttons=1 modifier=0", testname); + sendTextFrame(socket, "mouse type=buttonup x=1035 y=450 count=1 buttons=1 modifier=0", testname); - collectMessages(socket, "invalidatetiles:", responses, 3, "testGraphicInvalidate "); - CPPUNIT_ASSERT_MESSAGE("No invalidatetiles: received", responses.size() > 0); - for (auto message : responses) - { - CPPUNIT_ASSERT_MESSAGE("Drag & Drop graphic invalidate all tiles", message.find("EMPTY") == std::string::npos); - } + const auto message = getResponseLine(socket, "invalidatetiles:", testname); + CPPUNIT_ASSERT_MESSAGE("Drag & Drop graphic invalidate all tiles", message.find("EMPTY") == std::string::npos); } catch (const Poco::Exception& exc) { _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits