[Libreoffice-commits] online.git: loolwsd/test
Ashod Nakashian
ashod.nakashian at collabora.co.uk
Mon Aug 22 05:53:15 UTC 2016
loolwsd/test/helpers.hpp | 37 +++++++++++++++++++++++++------------
1 file changed, 25 insertions(+), 12 deletions(-)
New commits:
commit a46d9a55b3b0d9d697d8c4c74a192ba04a6051b0
Author: Ashod Nakashian <ashod.nakashian at collabora.co.uk>
Date: Sun Aug 21 20:16:56 2016 -0400
loolwsd: refactor getTileMessage
Move CppUnit assertions into assertTileMessage
to allow for reusing getTileMessage without
dependency on CppUnit.
Change-Id: I35592d440910854dc207db533292efd6f1520c0b
Reviewed-on: https://gerrit.libreoffice.org/28308
Reviewed-by: Ashod Nakashian <ashnakash at gmail.com>
Tested-by: Ashod Nakashian <ashnakash at gmail.com>
diff --git a/loolwsd/test/helpers.hpp b/loolwsd/test/helpers.hpp
index 43eebff..ce6032e 100644
--- a/loolwsd/test/helpers.hpp
+++ b/loolwsd/test/helpers.hpp
@@ -478,18 +478,6 @@ std::vector<char> getTileMessage(Poco::Net::WebSocket& ws, const std::string& na
response.resize(size);
bytes = ws.receiveFrame(response.data(), response.size(), flags);
response.resize(bytes >= 0 ? bytes : 0);
-
- const std::string firstLine = LOOLProtocol::getFirstLine(response);
- Poco::StringTokenizer tileTokens(firstLine, " ", Poco::StringTokenizer::TOK_IGNORE_EMPTY | Poco::StringTokenizer::TOK_TRIM);
- CPPUNIT_ASSERT_EQUAL(std::string("tile:"), tileTokens[0]);
- CPPUNIT_ASSERT_EQUAL(std::string("part="), tileTokens[1].substr(0, std::string("part=").size()));
- CPPUNIT_ASSERT_EQUAL(std::string("width="), tileTokens[2].substr(0, std::string("width=").size()));
- CPPUNIT_ASSERT_EQUAL(std::string("height="), tileTokens[3].substr(0, std::string("height=").size()));
- CPPUNIT_ASSERT_EQUAL(std::string("tileposx="), tileTokens[4].substr(0, std::string("tileposx=").size()));
- CPPUNIT_ASSERT_EQUAL(std::string("tileposy="), tileTokens[5].substr(0, std::string("tileposy=").size()));
- CPPUNIT_ASSERT_EQUAL(std::string("tilewidth="), tileTokens[6].substr(0, std::string("tilewidth=").size()));
- CPPUNIT_ASSERT_EQUAL(std::string("tileheight="), tileTokens[7].substr(0, std::string("tileheight=").size()));
- std::cerr << name << " Got " << firstLine << std::endl;
return response;
}
}
@@ -509,6 +497,31 @@ std::vector<char> getTileMessage(Poco::Net::WebSocket& ws, const std::string& na
return std::vector<char>();
}
+inline
+std::vector<char> assertTileMessage(Poco::Net::WebSocket& ws, const std::string& name = "")
+{
+ const auto response = getTileMessage(ws, name);
+
+ const std::string firstLine = LOOLProtocol::getFirstLine(response);
+ Poco::StringTokenizer tileTokens(firstLine, " ", Poco::StringTokenizer::TOK_IGNORE_EMPTY | Poco::StringTokenizer::TOK_TRIM);
+ CPPUNIT_ASSERT_EQUAL(std::string("tile:"), tileTokens[0]);
+ CPPUNIT_ASSERT_EQUAL(std::string("part="), tileTokens[1].substr(0, std::string("part=").size()));
+ CPPUNIT_ASSERT_EQUAL(std::string("width="), tileTokens[2].substr(0, std::string("width=").size()));
+ CPPUNIT_ASSERT_EQUAL(std::string("height="), tileTokens[3].substr(0, std::string("height=").size()));
+ CPPUNIT_ASSERT_EQUAL(std::string("tileposx="), tileTokens[4].substr(0, std::string("tileposx=").size()));
+ CPPUNIT_ASSERT_EQUAL(std::string("tileposy="), tileTokens[5].substr(0, std::string("tileposy=").size()));
+ CPPUNIT_ASSERT_EQUAL(std::string("tilewidth="), tileTokens[6].substr(0, std::string("tilewidth=").size()));
+ CPPUNIT_ASSERT_EQUAL(std::string("tileheight="), tileTokens[7].substr(0, std::string("tileheight=").size()));
+
+ return response;
+}
+
+inline
+std::vector<char> assertTileMessage(const std::shared_ptr<Poco::Net::WebSocket>& ws, const std::string& name = "")
+{
+ return assertTileMessage(*ws, name);
+}
+
enum SpecialKey { skNone=0, skShift=0x1000, skCtrl=0x2000, skAlt=0x4000 };
inline int getCharChar(char ch, SpecialKey specialKeys)
More information about the Libreoffice-commits
mailing list