[Libreoffice-commits] online.git: test/helpers.hpp
Ashod Nakashian
ashod.nakashian at collabora.co.uk
Tue May 2 04:13:26 UTC 2017
test/helpers.hpp | 31 +++++++++++++++++++++++++++++++
1 file changed, 31 insertions(+)
New commits:
commit 7b9e949adc20a7920a58d06530a60d34b6581c65
Author: Ashod Nakashian <ashod.nakashian at collabora.co.uk>
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 <ashnakash at gmail.com>
Tested-by: Ashod Nakashian <ashnakash at gmail.com>
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 <iterator>
#include <Poco/BinaryReader.h>
+#include <Poco/Dynamic/Var.h>
+#include <Poco/JSON/JSON.h>
+#include <Poco/JSON/Parser.h>
#include <Poco/Net/HTTPClientSession.h>
#include <Poco/Net/HTTPRequest.h>
#include <Poco/Net/HTTPResponse.h>
@@ -567,6 +570,34 @@ inline std::vector<char> getTileAndSave(std::shared_ptr<LOOLWebSocket>& 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<char> 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<Poco::JSON::Object>& loVersionObject = loVersionVar.extract<Poco::JSON::Object::Ptr>();
+ 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<LOOLWebSocket>& socket,
+ int& major, int& minor,
+ const std::string& testname)
+{
+ getServerVersion(*socket, major, minor, testname);
+}
+
}
#endif
More information about the Libreoffice-commits
mailing list