diff options
author | Noel Power <noel.power@suse.com> | 2013-02-04 19:38:04 +0000 |
---|---|---|
committer | Noel Power <noel.power@suse.com> | 2013-02-04 20:13:51 +0000 |
commit | 7c33cc519c75c5b4aa7af642394fd035527a091c (patch) | |
tree | e3b4a35d7522eac4fc79c04df196729d69d0e6e3 /sc/qa | |
parent | 70430fb14cf25f40abf9521710457ec042a6099d (diff) |
moved the export row check to qahelper, made it useful for import/export
Moved old row test from export to qahelper in order that it can be shared with
the import only tests, also added some new test documents and test data for some
additional row height checking
Change-Id: I023844b8dba8935d4bcdaac7fd16496e99251d78
Diffstat (limited to 'sc/qa')
-rw-r--r-- | sc/qa/unit/data/ods/alldefaultheights.ods | bin | 0 -> 7535 bytes | |||
-rw-r--r-- | sc/qa/unit/data/ods/multilineoptimal.ods | bin | 0 -> 8407 bytes | |||
-rw-r--r-- | sc/qa/unit/helper/qahelper.hxx | 50 | ||||
-rw-r--r-- | sc/qa/unit/subsequent_export-test.cxx | 57 | ||||
-rw-r--r-- | sc/qa/unit/subsequent_filters-test.cxx | 36 |
5 files changed, 104 insertions, 39 deletions
diff --git a/sc/qa/unit/data/ods/alldefaultheights.ods b/sc/qa/unit/data/ods/alldefaultheights.ods Binary files differnew file mode 100644 index 000000000000..ab3516615b84 --- /dev/null +++ b/sc/qa/unit/data/ods/alldefaultheights.ods diff --git a/sc/qa/unit/data/ods/multilineoptimal.ods b/sc/qa/unit/data/ods/multilineoptimal.ods Binary files differnew file mode 100644 index 000000000000..e514974cbfbf --- /dev/null +++ b/sc/qa/unit/data/ods/multilineoptimal.ods diff --git a/sc/qa/unit/helper/qahelper.hxx b/sc/qa/unit/helper/qahelper.hxx index 86a9080e70b0..5d730e900bf3 100644 --- a/sc/qa/unit/helper/qahelper.hxx +++ b/sc/qa/unit/helper/qahelper.hxx @@ -62,6 +62,8 @@ struct FileFormat { const char* pName; const char* pFilterName; const char* pTypeName; unsigned int nFormatType; }; +#define CHECK_OPTIMAL 0x1 + // data format for row height tests struct TestParam { @@ -70,11 +72,13 @@ struct TestParam SCROW nStartRow; SCROW nEndRow; SCTAB nTab; - int nExpectedHeight; + int nExpectedHeight; // -1 for default height + int nCheck; // currently only CHECK_OPTIMAL ( we could add CHECK_MANUAL etc.) + bool bOptimal; }; const char* sTestDoc; int nImportType; - int nExportType; + int nExportType; // -1 for import test, otherwise this is an export test int nRowData; RowData* pData; }; @@ -227,7 +231,47 @@ public: return xDocSh; } - + void miscRowHeightsTest( TestParam* aTestValues, unsigned int numElems ) + { + for ( unsigned int index=0; index<numElems; ++index ) + { + OUString sFileName = OUString::createFromAscii( aTestValues[ index ].sTestDoc ); + printf("aTestValues[%d] %s\n", index, OUStringToOString( sFileName, RTL_TEXTENCODING_UTF8 ).getStr() ); + int nImportType = aTestValues[ index ].nImportType; + int nExportType = aTestValues[ index ].nExportType; + ScDocShellRef xShell = loadDoc( sFileName, nImportType ); + CPPUNIT_ASSERT(xShell.Is()); + + if ( nExportType != -1 ) + xShell = saveAndReload(&(*xShell), nExportType ); + + CPPUNIT_ASSERT(xShell.Is()); + + ScDocument* pDoc = xShell->GetDocument(); + + for (int i=0; i<aTestValues[ index ].nRowData; ++i) + { + SCROW nRow = aTestValues[ index ].pData[ i].nStartRow; + SCROW nEndRow = aTestValues[ index ].pData[ i ].nEndRow; + SCTAB nTab = aTestValues[ index ].pData[ i ].nTab; + int nExpectedHeight = aTestValues[ index ].pData[ i ].nExpectedHeight; + if ( nExpectedHeight == -1 ) + nExpectedHeight = sc::TwipsToHMM( ScGlobal::nStdRowHeight ); + bool bCheckOpt = ( ( aTestValues[ index ].pData[ i ].nCheck & CHECK_OPTIMAL ) == CHECK_OPTIMAL ); + for ( ; nRow <= nEndRow; ++nRow ) + { + printf("\t checking row %" SAL_PRIdINT32 " for height %d\n", nRow, nExpectedHeight ); + int nHeight = sc::TwipsToHMM( pDoc->GetRowHeight(nRow, nTab, false) ); + if ( bCheckOpt ) + { + bool bOpt = !(pDoc->GetRowFlags( nRow, nTab ) & CR_MANUALSIZE); + CPPUNIT_ASSERT_EQUAL(aTestValues[ index ].pData[ i ].bOptimal, bOpt); + } + CPPUNIT_ASSERT_EQUAL(nExpectedHeight, nHeight); + } + } + } + } }; void testFile(OUString& aFileName, ScDocument* pDoc, SCTAB nTab, StringType aStringFormat = StringValue) diff --git a/sc/qa/unit/subsequent_export-test.cxx b/sc/qa/unit/subsequent_export-test.cxx index cb451325f323..76d88d0d4e9c 100644 --- a/sc/qa/unit/subsequent_export-test.cxx +++ b/sc/qa/unit/subsequent_export-test.cxx @@ -165,55 +165,40 @@ void ScExportTest::testMiscRowHeightExport() { TestParam::RowData DfltRowData[] = { - { 0, 4, 0, 529 }, - { 5, 10, 0, 1058 }, - { 17, 20, 0, 1767 }, - { 1048573, 1048575, 0, 529 }, + { 0, 4, 0, 529, 0, false }, + { 5, 10, 0, 1058, 0, false }, + { 17, 20, 0, 1767, 0, false }, + // check last couple of row in document to ensure + // they are 5.29mm ( effective default row xlsx height ) + { 1048573, 1048575, 0, 529, 0, false }, }; TestParam::RowData EmptyRepeatRowData[] = { - { 0, 4, 0, 529 }, - { 5, 10, 0, 1058 }, - { 17, 20, 0, 1767 }, + // rows 0-4, 5-10, 17-20 are all set at various + // heights, there is no content in the rows, there + // was a bug where only the first row ( of repeated rows ) + // was set after export + { 0, 4, 0, 529, 0, false }, + { 5, 10, 0, 1058, 0, false }, + { 17, 20, 0, 1767, 0, false }, }; TestParam aTestValues[] = { + // Checks that some distributed ( non-empty ) heights remain set after export (roundtrip) + // additionally there is effectively a default row height ( 5.29 mm ). So we test the + // unset rows at the end of the document to ensure the effective xlsx default height + // is set there too. { "miscrowheights.", XLSX, XLSX, SAL_N_ELEMENTS(DfltRowData), DfltRowData }, + // Checks that some distributed ( non-empty ) heights remain set after export (to xls) { "miscrowheights.", XLSX, XLS, SAL_N_ELEMENTS(DfltRowData), DfltRowData }, + // Checks that repreated rows ( of various heights ) remain set after export ( to xlsx ) { "miscemptyrepeatedrowheights.", ODS, XLSX, SAL_N_ELEMENTS(EmptyRepeatRowData), EmptyRepeatRowData }, + // Checks that repreated rows ( of various heights ) remain set after export ( to xls ) { "miscemptyrepeatedrowheights.", ODS, XLS, SAL_N_ELEMENTS(EmptyRepeatRowData), EmptyRepeatRowData }, }; - - for ( unsigned int index=0; index<SAL_N_ELEMENTS(aTestValues); ++index ) - { - OUString sFileName = OUString::createFromAscii( aTestValues[ index ].sTestDoc ); - printf("aTestValues[%d] %s\n", index, OUStringToOString( sFileName, RTL_TEXTENCODING_UTF8 ).getStr() ); - int nImportType = aTestValues[ index ].nImportType; - int nExportType = aTestValues[ index ].nExportType; - ScDocShellRef xShell = loadDoc( sFileName, nImportType ); - CPPUNIT_ASSERT(xShell.Is()); - - xShell = saveAndReload(&(*xShell), nExportType ); - CPPUNIT_ASSERT(xShell.Is()); - - ScDocument* pDoc = xShell->GetDocument(); - - for (int i=0; i<aTestValues[ index ].nRowData; ++i) - { - SCROW nRow = aTestValues[ index ].pData[ i].nStartRow; - SCROW nEndRow = aTestValues[ index ].pData[ i ].nEndRow; - SCTAB nTab = aTestValues[ index ].pData[ i ].nTab; - int nExpectedHeight = aTestValues[ index ].pData[ i ].nExpectedHeight; - for ( ; nRow <= nEndRow; ++nRow ) - { - printf("\t checking row %" SAL_PRIdINT32 " for height %d\n", nRow, nExpectedHeight ); - int nHeight = sc::TwipsToHMM( pDoc->GetRowHeight(nRow, nTab, false) ); - CPPUNIT_ASSERT_EQUAL(nExpectedHeight, nHeight); - } - } - } + miscRowHeightsTest( aTestValues, SAL_N_ELEMENTS(aTestValues) ); } ScExportTest::ScExportTest() diff --git a/sc/qa/unit/subsequent_filters-test.cxx b/sc/qa/unit/subsequent_filters-test.cxx index c57fbcf56959..74e30860aa77 100644 --- a/sc/qa/unit/subsequent_filters-test.cxx +++ b/sc/qa/unit/subsequent_filters-test.cxx @@ -145,6 +145,7 @@ public: void testRowHeightODS(); void testRichTextContentODS(); + void testMiscRowHeights(); CPPUNIT_TEST_SUITE(ScFiltersTest); CPPUNIT_TEST(testRangeNameXLS); @@ -203,6 +204,7 @@ public: CPPUNIT_TEST(testBugFilesXLS); CPPUNIT_TEST(testBugFilesXLSX); #endif + CPPUNIT_TEST(testMiscRowHeights); CPPUNIT_TEST_SUITE_END(); private: @@ -1860,6 +1862,40 @@ void ScFiltersTest::testFormulaDependency() xDocSh->DoClose(); } +void ScFiltersTest::testMiscRowHeights() +{ + TestParam::RowData DfltRowData[] = + { + // check rows at the begining and end of document + // and make sure they are reported as the default row + // height ( indicated by -1 ) + { 2, 4, 0, -1, 0, false }, + { 1048573, 1048575, 0, -1, 0, false }, + }; + + TestParam::RowData MultiLineOptData[] = + { + // Row 0 is 12.63 mm and optimal flag is set + { 0, 0, 0, 1263, CHECK_OPTIMAL, true }, + // Row 1 is 11.99 mm and optimal flag is NOT set + { 1, 1, 0, 1199, CHECK_OPTIMAL, false }, + }; + + TestParam aTestValues[] = + { + /* Checks that a document saved to ods with default rows does indeed + have default row heights ( there was a problem where the optimal + height was being calcuated after import if no hard height ) + */ + { "alldefaultheights.", ODS, -1, SAL_N_ELEMENTS(DfltRowData), DfltRowData }, + /* Checks the imported height of some multiline input, additionally checks + that the optimal height flag is set ( or not ) + */ + { "multilineoptimal.", ODS, -1, SAL_N_ELEMENTS(MultiLineOptData), MultiLineOptData }, + }; + miscRowHeightsTest( aTestValues, SAL_N_ELEMENTS(aTestValues) ); +} + ScFiltersTest::ScFiltersTest() : ScBootstrapFixture( "/sc/qa/unit/data" ) { |