[Libreoffice-commits] online.git: loolwsd/test

Ashod Nakashian ashod.nakashian at collabora.co.uk
Mon May 23 01:39:38 UTC 2016


 loolwsd/test/TileCacheTests.cpp |   25 ++++++++++++++++++++++++-
 loolwsd/test/helpers.hpp        |    2 +-
 2 files changed, 25 insertions(+), 2 deletions(-)

New commits:
commit 5d9140c3bbcdecff697dc4fec26a2c97a2594201
Author: Ashod Nakashian <ashod.nakashian at collabora.co.uk>
Date:   Sun May 22 21:20:10 2016 -0400

    loolwsd: simplify checkBlackTiles test
    
    Black tiles are returned when rendering fails.
    This happened due to bccu#1610 where internally
    core collected cell info on the first 1024 rows
    only. Anything beyond that always failed.
    
    This limitation is now removed using dynamic
    array to collect the cell info.
    
    Regardless, the test here needs only check that
    the last tile (really, anything beyond the 1024th row)
    doesn't return a black tile.
    
    This single tile still takes over 10 seconds to render,
    which is the other issue that Core suffers from when
    collecting cell info on a huge tab.
    
    Change-Id: I7a1a5b7c2b2ed2cc4399160e096be5e57895af77
    Reviewed-on: https://gerrit.libreoffice.org/25333
    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 0e65a11..e8524b3 100644
--- a/loolwsd/test/TileCacheTests.cpp
+++ b/loolwsd/test/TileCacheTests.cpp
@@ -442,8 +442,25 @@ void TileCacheTests::checkBlackTile(std::stringstream& tile)
     CPPUNIT_ASSERT_MESSAGE("The tile is 90% black", (black * 100) / (height * width) < 90);
 }
 
-void TileCacheTests::checkBlackTiles(Poco::Net::WebSocket& socket, const int part, const int docWidth, const int docHeight)
+void TileCacheTests::checkBlackTiles(Poco::Net::WebSocket& socket, const int /*part*/, const int /*docWidth*/, const int /*docHeight*/)
 {
+    // Check the last row of tiles to verify that the tiles
+    // render correctly and there are no black tiles.
+    const auto req = "tile part=0 width=256 height=256 tileposx=0 tileposy=2035200 tilewidth=3840 tileheight=3840";
+    sendTextFrame(socket, req);
+
+    const auto tile = getResponseMessage(socket, "tile:", "checkBlackTiles ");
+    const std::string firstLine = LOOLProtocol::getFirstLine(tile);
+#if 0
+    std::fstream outStream("/tmp/black.png", std::ios::out);
+    outStream.write(tile.data() + firstLine.size() + 1, tile.size() - firstLine.size() - 1);
+    outStream.close();
+#endif
+    std::stringstream streamTile;
+    std::copy(tile.begin() + firstLine.size() + 1, tile.end(), std::ostream_iterator<char>(streamTile));
+    checkBlackTile(streamTile);
+
+#if 0
     // twips
     const int tileSize = 3840;
     // pixel
@@ -462,6 +479,11 @@ void TileCacheTests::checkBlackTiles(Poco::Net::WebSocket& socket, const int par
     rows = docHeight / tileSize;
     cols = docWidth / tileSize;
 
+    // This is extremely slow due to an issue in Core.
+    // For each tile the full tab's cell info iss collected
+    // and that function is painfully slow.
+    // Also, this is unnecessary as we check for the last
+    // row of tiles, which is more than enough.
     for (int itRow = 0; itRow < rows; ++itRow)
     {
         for (int itCol = 0; itCol < cols; ++itCol)
@@ -482,6 +504,7 @@ void TileCacheTests::checkBlackTiles(Poco::Net::WebSocket& socket, const int par
             checkBlackTile(streamTile);
         }
     }
+#endif
 }
 
 void TileCacheTests::checkTiles(Poco::Net::WebSocket& socket, const std::string& docType)
diff --git a/loolwsd/test/helpers.hpp b/loolwsd/test/helpers.hpp
index bd26ef8..b6c39c2 100644
--- a/loolwsd/test/helpers.hpp
+++ b/loolwsd/test/helpers.hpp
@@ -205,7 +205,7 @@ std::vector<char> getResponseMessage(Poco::Net::WebSocket& ws, const std::string
     {
         int flags = 0;
         int retries = 20;
-        static const Poco::Timespan waitTime(1000000);
+        static const Poco::Timespan waitTime(2000000);
         std::vector<char> response;
 
         ws.setReceiveTimeout(0);


More information about the Libreoffice-commits mailing list