[Libreoffice-commits] online.git: loolwsd/test
Ashod Nakashian
ashod.nakashian at collabora.co.uk
Fri Jun 17 23:56:46 UTC 2016
loolwsd/test/TileCacheTests.cpp | 15 ----
loolwsd/test/data/calc_render.xls |binary
loolwsd/test/data/calc_render_0_512x512.3840,0.7680x7680.png |binary
loolwsd/test/helpers.hpp | 25 ++++++
loolwsd/test/httpwstest.cpp | 41 +++++++++++
5 files changed, 66 insertions(+), 15 deletions(-)
New commits:
commit bf66f7a908431e344f73215b46452ad839ac0a82
Author: Ashod Nakashian <ashod.nakashian at collabora.co.uk>
Date: Mon Jun 13 20:31:14 2016 -0400
loolwsd: Calc tile rendering test with editing
Change-Id: Ib02a079bf1e4e90c7dfb65b6038b3ca1423a673c
Reviewed-on: https://gerrit.libreoffice.org/26448
Reviewed-by: Ashod Nakashian <ashnakash at gmail.com>
Tested-by: Ashod Nakashian <ashnakash at gmail.com>
diff --git a/loolwsd/test/TileCacheTests.cpp b/loolwsd/test/TileCacheTests.cpp
index cd50d83..d537616 100644
--- a/loolwsd/test/TileCacheTests.cpp
+++ b/loolwsd/test/TileCacheTests.cpp
@@ -86,21 +86,6 @@ class TileCacheTests : public CPPUNIT_NS::TestFixture
return v;
}
- static
- std::vector<char> readDataFromFile(std::unique_ptr<std::fstream>& file)
- {
- file->seekg(0, std::ios_base::end);
- const std::streamsize size = file->tellg();
-
- std::vector<char> v;
- v.resize(size);
-
- file->seekg(0, std::ios_base::beg);
- file->read(v.data(), size);
-
- return v;
- }
-
public:
TileCacheTests()
: _uri(helpers::getTestServerURI())
diff --git a/loolwsd/test/data/calc_render.xls b/loolwsd/test/data/calc_render.xls
new file mode 100644
index 0000000..be80ea1
Binary files /dev/null and b/loolwsd/test/data/calc_render.xls differ
diff --git a/loolwsd/test/data/calc_render_0_512x512.3840,0.7680x7680.png b/loolwsd/test/data/calc_render_0_512x512.3840,0.7680x7680.png
new file mode 100644
index 0000000..cfc51c8
Binary files /dev/null and b/loolwsd/test/data/calc_render_0_512x512.3840,0.7680x7680.png differ
diff --git a/loolwsd/test/helpers.hpp b/loolwsd/test/helpers.hpp
index 54fac74..e5d3984 100644
--- a/loolwsd/test/helpers.hpp
+++ b/loolwsd/test/helpers.hpp
@@ -49,6 +49,31 @@
namespace helpers
{
inline
+std::vector<char> readDataFromFile(const std::string& filename)
+{
+ std::ifstream ifs(Poco::Path(TDOC, filename).toString());
+
+ std::istream_iterator<char> start(ifs);
+ std::istream_iterator<char> end;
+ return std::vector<char>(start, end);
+}
+
+inline
+std::vector<char> readDataFromFile(std::unique_ptr<std::fstream>& file)
+{
+ file->seekg(0, std::ios_base::end);
+ const std::streamsize size = file->tellg();
+
+ std::vector<char> v;
+ v.resize(size);
+
+ file->seekg(0, std::ios_base::beg);
+ file->read(v.data(), size);
+
+ return v;
+}
+
+inline
void getDocumentPathAndURL(const char* document, std::string& documentPath, std::string& documentURL)
{
documentPath = Util::getTempFilePath(TDOC, document);
diff --git a/loolwsd/test/httpwstest.cpp b/loolwsd/test/httpwstest.cpp
index cef99e7..6b8cb0f 100644
--- a/loolwsd/test/httpwstest.cpp
+++ b/loolwsd/test/httpwstest.cpp
@@ -14,6 +14,7 @@
#include <mutex>
#include <thread>
#include <regex>
+#include <vector>
#include <Poco/Dynamic/Var.h>
#include <Poco/FileStream.h>
@@ -81,6 +82,7 @@ class HTTPWSTest : public CPPUNIT_NS::TestFixture
CPPUNIT_TEST(testInsertAnnotationWriter);
CPPUNIT_TEST(testEditAnnotationWriter);
CPPUNIT_TEST(testInsertAnnotationCalc);
+ CPPUNIT_TEST(testCalcEditRendering);
CPPUNIT_TEST(testFontList);
CPPUNIT_TEST_SUITE_END();
@@ -112,6 +114,7 @@ class HTTPWSTest : public CPPUNIT_NS::TestFixture
void testInsertAnnotationWriter();
void testEditAnnotationWriter();
void testInsertAnnotationCalc();
+ void testCalcEditRendering();
void testFontList();
void loadDoc(const std::string& documentURL);
@@ -1532,6 +1535,44 @@ void HTTPWSTest::testInsertAnnotationCalc()
CPPUNIT_ASSERT_EQUAL(std::string("textselectioncontent: aaa bbb ccc"), res);
}
+void HTTPWSTest::testCalcEditRendering()
+{
+ std::string documentPath, documentURL;
+ getDocumentPathAndURL("calc_render.xls", documentPath, documentURL);
+ Poco::Net::HTTPRequest request(Poco::Net::HTTPRequest::HTTP_GET, documentURL);
+
+ auto socket = loadDocAndGetSocket(_uri, documentURL);
+
+ const std::string x = "5000";
+ const std::string y = "165";
+ sendTextFrame(socket, "mouse type=buttondown x=" + x + " y=" + y + " count=1 buttons=1 modifier=0");
+ sendTextFrame(socket, "mouse type=buttonup x=" + x + " y=" + y + " count=1 buttons=1 modifier=0");
+ sendTextFrame(socket, "key type=input char=97 key=0");
+ sendTextFrame(socket, "key type=input char=98 key=0");
+ sendTextFrame(socket, "key type=input char=99 key=0");
+
+ assertResponseLine(socket, "invalidatetiles:", "calcEditRendering ");
+ assertResponseLine(socket, "invalidatetiles:", "calcEditRendering ");
+
+ const auto req = "tilecombine part=0 width=512 height=512 tileposx=3840 tileposy=0 tilewidth=7680 tileheight=7680";
+ sendTextFrame(socket, req);
+
+ const auto tile = getResponseMessage(socket, "tile:", "calcEditRendering ");
+ const std::string firstLine = LOOLProtocol::getFirstLine(tile);
+
+ std::stringstream streamTile;
+ std::copy(tile.begin() + firstLine.size() + 1, tile.end(), std::ostream_iterator<char>(streamTile));
+ std::istream_iterator<char> start(streamTile);
+ std::istream_iterator<char> end;
+ std::vector<char> res(start, end);
+
+ const std::vector<char> exp = readDataFromFile("calc_render_0_512x512.3840,0.7680x7680.png");
+
+ CPPUNIT_ASSERT_EQUAL(exp.size(), res.size());
+ const bool eq = std::equal(exp.begin(), exp.end(), res.data());
+ CPPUNIT_ASSERT_MESSAGE("Tile not rendered as expected.", eq);
+}
+
std::string HTTPWSTest::getFontList(const std::string& message)
{
Poco::JSON::Parser parser;
More information about the Libreoffice-commits
mailing list