From 439f595e6e74d34b66f8745e0a6013ec738f23df Mon Sep 17 00:00:00 2001 From: Michael Meeks Date: Fri, 25 Oct 2019 19:58:35 +0100 Subject: lok: improve tilebench and add an unpleasant text rendering test case. Change-Id: I9e769cff6db794389bcef821c08ca1cd60173ab9 Reviewed-on: https://gerrit.libreoffice.org/81531 Tested-by: Jenkins Reviewed-by: Michael Meeks --- libreofficekit/qa/data/join/README | 4 +++ .../qa/data/join/calc-100-textjitter.xlsx | Bin 0 -> 5761 bytes libreofficekit/qa/tilebench/tilebench.cxx | 37 ++++++++++++--------- 3 files changed, 25 insertions(+), 16 deletions(-) create mode 100644 libreofficekit/qa/data/join/README create mode 100644 libreofficekit/qa/data/join/calc-100-textjitter.xlsx diff --git a/libreofficekit/qa/data/join/README b/libreofficekit/qa/data/join/README new file mode 100644 index 000000000000..35762e1f0525 --- /dev/null +++ b/libreofficekit/qa/data/join/README @@ -0,0 +1,4 @@ +Files to run through tilebench --join to detect problems. + +bin/run tilebench instdir/program libreofficekit/qa/join/ --join + diff --git a/libreofficekit/qa/data/join/calc-100-textjitter.xlsx b/libreofficekit/qa/data/join/calc-100-textjitter.xlsx new file mode 100644 index 000000000000..94a3e5254d9a Binary files /dev/null and b/libreofficekit/qa/data/join/calc-100-textjitter.xlsx differ diff --git a/libreofficekit/qa/tilebench/tilebench.cxx b/libreofficekit/qa/tilebench/tilebench.cxx index a1d415fe56bb..fef5271bdf27 100644 --- a/libreofficekit/qa/tilebench/tilebench.cxx +++ b/libreofficekit/qa/tilebench/tilebench.cxx @@ -72,19 +72,21 @@ static void dumpTile(const char *pNameStem, nTotalWidth = nWidth; auto pBuffer = reinterpret_cast(pBufferU); + static int counter = 0; std::string aName = "/tmp/dump_tile"; aName += pNameStem; + aName += "_" + std::to_string(counter); aName += ".ppm"; #ifndef IOS std::ofstream ofs(aName); #else NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES); NSString *documentsDirectory = [paths objectAtIndex:0]; - static int counter = 0; - NSString *path = [NSString stringWithFormat:@"%@/dump_tile_%d.ppm", documentsDirectory, counter++]; + NSString *path = [NSString stringWithFormat:@"%@/dump_tile_%d.ppm", documentsDirectory, counter]; std::ofstream ofs([path UTF8String]); std::cerr << "---> Dumping tile\n"; #endif + counter++; ofs << "P6\n" << nWidth << " " << nHeight << "\n" @@ -356,7 +358,7 @@ static bool testJoinsAt( Document *pDocument, long nX, long nY, } // Check that our tiles join nicely ... -static void testJoin( Document *pDocument) +static int testJoin( Document *pDocument) { // Ignore parts - just the first for now ... long nWidth = 0, nHeight = 0; @@ -366,20 +368,23 @@ static void testJoin( Document *pDocument) // Use realistic dimensions, similar to the Online client. long const nTilePixelSize = 256; long const nTileTwipSize = 1852; + long nFails = 0; for( long y = 0; y < 5; ++y ) { for( long x = 0; x < 5; ++x ) { if ( !testJoinsAt( pDocument, x, y, nTilePixelSize, nTileTwipSize ) ) - { - fprintf( stderr, "failed\n" ); - return; - } + nFails++; } } - fprintf( stderr, "All joins compared correctly\n" ); + if (nFails > 0) + fprintf( stderr, "Failed %ld joins\n", nFails ); + else + fprintf( stderr, "All joins compared correctly\n" ); + + return nFails; } static std::atomic bDialogRendered(false); @@ -512,7 +517,7 @@ int main( int argc, char* argv[] ) aTimes.emplace_back("initialization"); // coverity[tainted_string] - build time test tool - Office *pOffice = lok_cpp_init(install_path, user_profile); + std::unique_ptr pOffice( lok_cpp_init(install_path, user_profile) ); if (pOffice == nullptr) { fprintf(stderr, "Failed to initialize Office from %s\n", argv[1]); @@ -521,13 +526,13 @@ int main( int argc, char* argv[] ) aTimes.emplace_back(); pOffice->registerCallback(ignoreCallback, nullptr); - Document *pDocument = nullptr; + std::unique_ptr pDocument; pOffice->setOptionalFeatures(LOK_FEATURE_NO_TILED_ANNOTATIONS); aTimes.emplace_back("load document"); if (doc_url != nullptr) - pDocument = pOffice->documentLoad(doc_url); + pDocument.reset(pOffice->documentLoad(doc_url)); aTimes.emplace_back(); if (pDocument) @@ -540,11 +545,11 @@ int main( int argc, char* argv[] ) int max_tiles = (argc > arg ? atoi(argv[arg++]) : -1); const bool dump = true; - testTile (pDocument, max_parts, max_tiles, dump); + testTile (pDocument.get(), max_parts, max_tiles, dump); } else if (!strcmp(mode, "--join")) { - testJoin (pDocument); + return testJoin (pDocument.get()); } else if (!strcmp (mode, "--dialog")) { @@ -563,16 +568,16 @@ int main( int argc, char* argv[] ) return help("missing argument to --dialog and no default"); } } - testDialog (pDocument, uno_cmd); + testDialog (pDocument.get(), uno_cmd); } else return help ("unknown parameter"); } aTimes.emplace_back("destroy document"); - delete pDocument; + pDocument.reset(); aTimes.emplace_back(); - delete pOffice; + pOffice.reset(); double nTotal = 0.0; fprintf (stderr, "profile run:\n"); -- cgit