[Libreoffice-commits] online.git: test/httpwstest.cpp test/TileCacheTests.cpp
Ashod Nakashian (via logerrit)
logerrit at kemper.freedesktop.org
Tue Oct 29 01:33:12 UTC 2019
test/TileCacheTests.cpp | 47 +++++++++++++++++++++++++++++------------------
test/httpwstest.cpp | 18 +++++++++++++-----
2 files changed, 42 insertions(+), 23 deletions(-)
New commits:
commit c82760f1037c6019a0b03463405ec12669ad4f6a
Author: Ashod Nakashian <ashod.nakashian at collabora.co.uk>
AuthorDate: Mon Oct 21 11:42:03 2019 -0400
Commit: Ashod Nakashian <ashnakash at gmail.com>
CommitDate: Tue Oct 29 02:32:54 2019 +0100
test: improve TileCache tests
This fixes up some minor issues, improves stability
and logging of tests.
Reviewed-on: https://gerrit.libreoffice.org/81259
Reviewed-by: Andras Timar <andras.timar at collabora.com>
Tested-by: Andras Timar <andras.timar at collabora.com>
(cherry picked from commit a6e2dff35a4f1234066c66cb64f7e3bcd034ed58)
Change-Id: I906922c1c74427a53f9017f7be73c1f85ecf4cd7
Reviewed-on: https://gerrit.libreoffice.org/81575
Reviewed-by: Ashod Nakashian <ashnakash at gmail.com>
Tested-by: Ashod Nakashian <ashnakash at gmail.com>
diff --git a/test/TileCacheTests.cpp b/test/TileCacheTests.cpp
index 396b0e031..913d777fc 100644
--- a/test/TileCacheTests.cpp
+++ b/test/TileCacheTests.cpp
@@ -128,6 +128,7 @@ class TileCacheTests : public CPPUNIT_NS::TestFixture
const std::string& name = "checkTiles ");
void requestTiles(std::shared_ptr<LOOLWebSocket>& socket,
+ const std::string& docType,
const int part,
const int docWidth,
const int docHeight,
@@ -1079,10 +1080,18 @@ void TileCacheTests::checkTiles(std::shared_ptr<LOOLWebSocket>& socket, const st
Poco::StringTokenizer tokens(line, " ", Poco::StringTokenizer::TOK_IGNORE_EMPTY | Poco::StringTokenizer::TOK_TRIM);
#if defined CPPUNIT_ASSERT_GREATEREQUAL
- CPPUNIT_ASSERT_GREATEREQUAL(static_cast<size_t>(6), tokens.count());
+ if (docType == "presentation")
+ CPPUNIT_ASSERT_GREATEREQUAL(static_cast<size_t>(7), tokens.count()); // We have an extra field.
+ else
+ CPPUNIT_ASSERT_GREATEREQUAL(static_cast<size_t>(6), tokens.count());
+#else
+ if (docType == "presentation")
+ CPPUNIT_ASSERT_EQUAL(static_cast<size_t>(7), tokens.count()); // We have an extra field.
+ else
+ CPPUNIT_ASSERT_EQUAL(static_cast<size_t>(6), tokens.count());
#endif
- // Expected format is something like 'type= parts= current= width= height= [hiddenparts=]'.
+ // Expected format is something like 'type= parts= current= width= height='.
const std::string text = tokens[0].substr(type.size());
totalParts = std::stoi(tokens[1].substr(parts.size()));
currentPart = std::stoi(tokens[2].substr(current.size()));
@@ -1099,7 +1108,7 @@ void TileCacheTests::checkTiles(std::shared_ptr<LOOLWebSocket>& socket, const st
{
// request tiles
TST_LOG("Requesting Impress tiles.");
- requestTiles(socket, currentPart, docWidth, docHeight, name);
+ requestTiles(socket, docType, currentPart, docWidth, docHeight, name);
}
// random setclientpart
@@ -1119,7 +1128,7 @@ void TileCacheTests::checkTiles(std::shared_ptr<LOOLWebSocket>& socket, const st
// issue a new tile request as a response, which a real client would do).
assertResponseString(socket, "setpart:", name);
- requestTiles(socket, it, docWidth, docHeight, name);
+ requestTiles(socket, docType, it, docWidth, docHeight, name);
if (++requests >= 3)
{
@@ -1132,7 +1141,9 @@ void TileCacheTests::checkTiles(std::shared_ptr<LOOLWebSocket>& socket, const st
}
}
-void TileCacheTests::requestTiles(std::shared_ptr<LOOLWebSocket>& socket, const int part, const int docWidth, const int docHeight, const std::string& name)
+void TileCacheTests::requestTiles(std::shared_ptr<LOOLWebSocket>& socket,
+ const std::string& , const int part, const int docWidth,
+ const int docHeight, const std::string& name)
{
// twips
const int tileSize = 3840;
@@ -1176,7 +1187,7 @@ void TileCacheTests::requestTiles(std::shared_ptr<LOOLWebSocket>& socket, const
sendTextFrame(socket, text, name);
tile = assertResponseString(socket, "tile:", name);
- // expected tile: nviewid= part= width= height= tileposx= tileposy= tilewidth= tileheight=
+ // expected tile: part= width= height= tileposx= tileposy= tilewidth= tileheight=
Poco::StringTokenizer tokens(tile, " ", Poco::StringTokenizer::TOK_IGNORE_EMPTY | Poco::StringTokenizer::TOK_TRIM);
CPPUNIT_ASSERT_EQUAL(std::string("tile:"), tokens[0]);
CPPUNIT_ASSERT_EQUAL(0, std::stoi(tokens[1].substr(std::string("nviewid=").size())));
@@ -1273,9 +1284,9 @@ void TileCacheTests::testTileWireIDHandling()
CPPUNIT_ASSERT_MESSAGE("Expected at least two tiles.", countMessages(socket, "tile:", testname, 500) > 1);
// Let WSD know we got these so it wouldn't stop sending us modified tiles automatically.
- sendTextFrame(socket, "tileprocessed tile=0:0:0:3840:3840:0");
- sendTextFrame(socket, "tileprocessed tile=0:3840:0:3840:3840:0");
- sendTextFrame(socket, "tileprocessed tile=0:7680:0:3840:3840:0");
+ sendTextFrame(socket, "tileprocessed tile=0:0:0:3840:3840:0", testname);
+ sendTextFrame(socket, "tileprocessed tile=0:3840:0:3840:3840:0", testname);
+ sendTextFrame(socket, "tileprocessed tile=0:7680:0:3840:3840:0", testname);
// Type an other character
sendChar(socket, 'y', skNone, testname);
@@ -1342,7 +1353,7 @@ void TileCacheTests::testTileProcessed()
for(std::string& tileID : tileIDs)
{
- sendTextFrame(socket, "tileprocessed tile=" + tileID);
+ sendTextFrame(socket, "tileprocessed tile=" + tileID, testname);
}
// Now we can get the remaining tiles
@@ -1420,10 +1431,10 @@ void TileCacheTests::testTileBeingRenderedHandling()
// For the first input wsd will send all invalidated tiles
CPPUNIT_ASSERT_MESSAGE("Expected at least two tiles.", countMessages(socket, "tile:", testname, 500) > 1);
- // For the later inputs wsd will send one tile, since other ones are identical
+ // For the later inputs wsd will send one tile, since other ones are indentical
for(int i = 0; i < 5; ++i)
{
- sendTextFrame(socket, "tileprocessed tile=0:0:0:3200:3200:0");
+ sendTextFrame(socket, "tileprocessed tile=0:0:0:3200:3200:0", testname);
// Type an other character
sendChar(socket, 'y', skNone, testname);
@@ -1436,7 +1447,7 @@ void TileCacheTests::testTileBeingRenderedHandling()
// are sub-pixel different, and that results in a different hash.
CPPUNIT_ASSERT_EQUAL(2, arrivedTiles);
- sendTextFrame(socket, "tileprocessed tile=0:0:0:3200:3200:0");
+ sendTextFrame(socket, "tileprocessed tile=0:0:0:3200:3200:0", testname);
// The third time, however, we shouldn't see anything but the tile we change.
sendChar(socket, 'z', skNone, testname);
@@ -1475,9 +1486,9 @@ void TileCacheTests::testWireIDFilteringOnWSDSide()
CPPUNIT_ASSERT_MESSAGE("Expected at least two tiles.", countMessages(socket1, "tile:", testname, 500) > 1);
// Let WSD know we got these so it wouldn't stop sending us modified tiles automatically.
- sendTextFrame(socket1, "tileprocessed tile=0:0:0:3840:3840:0");
- sendTextFrame(socket1, "tileprocessed tile=0:3840:0:3840:3840:0");
- sendTextFrame(socket1, "tileprocessed tile=0:7680:0:3840:3840:0");
+ sendTextFrame(socket1, "tileprocessed tile=0:0:0:3840:3840:0", testname);
+ sendTextFrame(socket1, "tileprocessed tile=0:3840:0:3840:3840:0", testname);
+ sendTextFrame(socket1, "tileprocessed tile=0:7680:0:3840:3840:0", testname);
// Type an other character
sendChar(socket1, 'y', skNone, testname);
@@ -1490,7 +1501,7 @@ void TileCacheTests::testWireIDFilteringOnWSDSide()
// Or, at most 2. The reason is that sometimes we get line antialiasing differences that
// are sub-pixel different, and that results in a different hash.
- CPPUNIT_ASSERT_EQUAL(2, arrivedTiles);
+ CPPUNIT_ASSERT_MESSAGE("Expected at most 3 tiles.", arrivedTiles <= 3);
// The third time, however, we shouldn't see anything but the tile we change.
sendChar(socket1, 'z', skNone, testname);
@@ -1554,7 +1565,7 @@ void TileCacheTests::testLimitTileVersionsOnFly()
// When the next tileprocessed message arrive with correct tileID
// wsd sends the delayed tile
- sendTextFrame(socket, "tileprocessed tile=0:0:0:3200:3200:0");
+ sendTextFrame(socket, "tileprocessed tile=0:0:0:3200:3200:0", testname);
int arrivedTiles = 0;
bool gotTile = false;
diff --git a/test/httpwstest.cpp b/test/httpwstest.cpp
index 40b0d604f..45311e84e 100644
--- a/test/httpwstest.cpp
+++ b/test/httpwstest.cpp
@@ -689,8 +689,9 @@ void HTTPWSTest::testReloadWhileDisconnecting()
CPPUNIT_ASSERT_EQUAL(kitcount, countLoolKitProcesses(kitcount));
// Check if the document contains the pasted text.
- const std::string selection = getAllText(socket, testname);
- CPPUNIT_ASSERT_EQUAL(std::string("textselectioncontent: aaa bbb ccc"), selection);
+ const std::string expected = "aaa bbb ccc";
+ const std::string selection = getAllText(socket, testname, expected);
+ CPPUNIT_ASSERT_EQUAL(std::string("textselectioncontent: ") + expected, selection);
}
catch (const Poco::Exception& exc)
{
@@ -1147,6 +1148,8 @@ void HTTPWSTest::getPartHashCodes(const std::string& testname,
Poco::StringTokenizer tokens(line, " ", Poco::StringTokenizer::TOK_IGNORE_EMPTY | Poco::StringTokenizer::TOK_TRIM);
#if defined CPPUNIT_ASSERT_GREATEREQUAL
CPPUNIT_ASSERT_GREATEREQUAL(static_cast<size_t>(7), tokens.count());
+#else
+ CPPUNIT_ASSERT_MESSAGE("Expected at least 7 tokens.", static_cast<size_t>(7) <= tokens.count());
#endif
const std::string type = tokens[0].substr(std::string("type=").size());
@@ -2335,21 +2338,26 @@ void HTTPWSTest::testUndoConflict()
try
{
// Load first view
- sendTextFrame(socket0, "load url=" + docURL);
+ sendTextFrame(socket0, "load url=" + docURL, testname + "0 ");
response = getResponseString(socket0, "invalidatecursor:", testname + "0 ");
// Load second view
- sendTextFrame(socket1, "load url=" + docURL);
+ sendTextFrame(socket1, "load url=" + docURL, testname + "1 ");
response = getResponseString(socket1, "invalidatecursor:", testname + "1 ");
// edit first view
sendChar(socket0, 'A', skNone, testname + "0 ");
response = getResponseString(socket0, "invalidateviewcursor: ", testname + "0 ");
+ response = getResponseString(socket0, "invalidateviewcursor: ", testname + "0 ");
+
// edit second view
sendChar(socket1, 'B', skNone, testname + "1 ");
response = getResponseString(socket1, "invalidateviewcursor: ", testname + "1 ");
+ response = getResponseString(socket1, "invalidateviewcursor: ", testname + "1 ");
+
// try to undo first view
- sendTextFrame(socket0, "uno .uno:Undo", testname);
+ sendTextFrame(socket0, "uno .uno:Undo", testname + "0 ");
+
// undo conflict
response = getResponseString(socket0, "unocommandresult:", testname + "0 ");
Poco::JSON::Object::Ptr objJSON = parser.parse(response.substr(17)).extract<Poco::JSON::Object::Ptr>();
More information about the Libreoffice-commits
mailing list