コード例 #1
0
    void testBreakSimpleTable() // No constraints, no known number of pages. Not so "simple".
    {
        qWarning("temporarily disabled");
#if 0
        Report report;
        report.setTableBreakingEnabled( true );
        makeSimpleTable( report );
        //report.exportToFile( "testBreakSimpleTable.pdf" ); // for debugging
        QCOMPARE( report.numberOfPages(), 3 ); // Was and should be 4. Now 3 with the new algo, see TODO in breakTables.
#endif
    }
コード例 #2
0
    void testScaleTables()
    {
        qWarning("test temporarily disabled");
#if 0
        // Note that this font is huge; each column is in fact larger than the page,
        // so it wraps. Interesting testcase :)
        QFont defaultFont( QLatin1String( s_fontName ), 48 );
        int columns = 0;
        int numOfPages = 0;
        do {
            // Add tables with as any columns as necessary to span 3 pages horizontally
            // The API doesn't allow to keep adding cells to a single table, so we
            // try this into a new report every time
            // TODO: can be done with an autotable now
            ++columns;
            Report testReport;
            testReport.setReportMode(Report::SpreadSheet);
            testReport.setDefaultFont( defaultFont );
            testReport.setTableBreakingEnabled( true );
            addTable( testReport, 1, columns );
            numOfPages = testReport.numberOfPages();
        } while ( numOfPages < 3 );

        //qDebug() << "The table has 1 row and" << columns << "columns.";
        QVERIFY( columns >= 3 );
        {
            Report report;
            report.setDefaultFont( defaultFont );
            report.setTableBreakingEnabled( true );
            addTable( report, 1, columns );
            QCOMPARE( report.numberOfPages(), 3 );
            // Right now we're 1 | 2 | 3, let's try scaling down to 1 | 2
            report.scaleTo( 2, 1 );
            //report.exportToFile( "2-1.pdf" ); // for debugging
            QCOMPARE( report.numberOfPages(), 2 );
            report.scaleTo( 2, 10 /* doesn't matter */ );
            //report.exportToFile( "2-10.pdf" ); // for debugging
            QCOMPARE( report.numberOfPages(), 2 );
            report.scaleTo( 3, 1 ); // back to orig
            QCOMPARE( report.numberOfPages(), 3 );
            report.scaleTo( 1, 1 ); // squeeze it into a single page
            QCOMPARE( report.numberOfPages(), 1 );
            report.scaleTo( 1, 10 ); // squeeze it into a single page
            // ## how to check that all columns are visible, and not truncated?
            QCOMPARE( report.numberOfPages(), 1 );
        }
        // Now add tables with more rows
        int rows = 0;
        do {
            ++rows;
            Report testReport;
            testReport.setDefaultFont( defaultFont );
            testReport.setTableBreakingEnabled( true );
            addTable( testReport, rows, columns );
            numOfPages = testReport.numberOfPages();
        } while ( numOfPages < 9 );
        //qDebug() << "Making report with a big table: " << rows << "rows and" << columns << "columns.";
        {
            Report report;
            report.setDefaultFont( defaultFont );
            report.scaleTo( 3, 3 );
            addTable( report, rows, columns );
            //report.exportToFile( "3-3.pdf" ); // for debugging
            // So now we have a table big enough for 3x3
            QCOMPARE( report.numberOfPages(), 9 );
        }
#endif
    }