test/TileCacheTests.cpp | 38 ++++++++++++++++++++++---------------- test/httpwstest.cpp | 18 ++++++++++++------ 2 files changed, 34 insertions(+), 22 deletions(-)
New commits: commit a6e2dff35a4f1234066c66cb64f7e3bcd034ed58 Author: Ashod Nakashian <[email protected]> AuthorDate: Mon Oct 21 11:42:03 2019 -0400 Commit: Andras Timar <[email protected]> CommitDate: Tue Oct 22 19:23:11 2019 +0200 test: improve tests This fixes up some minor issues, improves stability and logging of tests. Change-Id: I906922c1c74427a53f9017f7be73c1f85ecf4cd7 Reviewed-on: https://gerrit.libreoffice.org/81259 Reviewed-by: Andras Timar <[email protected]> Tested-by: Andras Timar <[email protected]> diff --git a/test/TileCacheTests.cpp b/test/TileCacheTests.cpp index add630168..9d528998b 100644 --- a/test/TileCacheTests.cpp +++ b/test/TileCacheTests.cpp @@ -124,6 +124,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, @@ -1032,7 +1033,10 @@ void TileCacheTests::checkTiles(std::shared_ptr<LOOLWebSocket>& socket, const st std::getline(istr, line); Poco::StringTokenizer tokens(line, " ", Poco::StringTokenizer::TOK_IGNORE_EMPTY | Poco::StringTokenizer::TOK_TRIM); - CPPUNIT_ASSERT_EQUAL(static_cast<size_t>(6), tokens.count()); + 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()); // Expected format is something like 'type= parts= current= width= height='. const std::string text = tokens[0].substr(type.size()); @@ -1051,7 +1055,7 @@ void TileCacheTests::checkTiles(std::shared_ptr<LOOLWebSocket>& socket, const st { // request tiles std::cerr << "Requesting Impress tiles." << std::endl; - requestTiles(socket, currentPart, docWidth, docHeight, name); + requestTiles(socket, docType, currentPart, docWidth, docHeight, name); } // random setclientpart @@ -1071,7 +1075,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) { @@ -1084,7 +1088,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; @@ -1131,7 +1137,7 @@ void TileCacheTests::requestTiles(std::shared_ptr<LOOLWebSocket>& socket, const // 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(part, std::stoi(tokens[1].substr(std::string("nviewid=").size()))); + CPPUNIT_ASSERT_EQUAL(0, std::stoi(tokens[1].substr(std::string("nviewid=").size()))); CPPUNIT_ASSERT_EQUAL(part, std::stoi(tokens[2].substr(std::string("part=").size()))); CPPUNIT_ASSERT_EQUAL(pixTileSize, std::stoi(tokens[3].substr(std::string("width=").size()))); CPPUNIT_ASSERT_EQUAL(pixTileSize, std::stoi(tokens[4].substr(std::string("height=").size()))); @@ -1225,9 +1231,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); @@ -1294,7 +1300,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 @@ -1375,7 +1381,7 @@ void TileCacheTests::testTileBeingRenderedHandling() // 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); @@ -1388,7 +1394,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); @@ -1427,9 +1433,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); @@ -1442,7 +1448,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); @@ -1506,7 +1512,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 92110fbc9..8fd886365 100644 --- a/test/httpwstest.cpp +++ b/test/httpwstest.cpp @@ -875,8 +875,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) { @@ -1494,7 +1495,7 @@ void HTTPWSTest::getPartHashCodes(const std::string& testname, // Expected format is something like 'type= parts= current= width= height= viewid='. Poco::StringTokenizer tokens(line, " ", Poco::StringTokenizer::TOK_IGNORE_EMPTY | Poco::StringTokenizer::TOK_TRIM); - CPPUNIT_ASSERT_EQUAL(static_cast<size_t>(6), tokens.count()); + CPPUNIT_ASSERT_EQUAL(static_cast<size_t>(7), tokens.count()); const std::string type = tokens[0].substr(std::string("type=").size()); CPPUNIT_ASSERT_MESSAGE("Expected presentation or spreadsheet type to read part names/codes.", @@ -2682,21 +2683,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>(); _______________________________________________ Libreoffice-commits mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits
