diff options
author | Markus Mohrhard <markus.mohrhard@googlemail.com> | 2013-03-22 08:52:11 +0100 |
---|---|---|
committer | Markus Mohrhard <markus.mohrhard@googlemail.com> | 2013-03-22 08:56:12 +0100 |
commit | 317a9b2e9463635b87f1c00fc11755dc9a4129f6 (patch) | |
tree | 1aa0854e34f917a0e85ae6149410615c6bbe71f6 /sc | |
parent | e05cbcccbaafd42410f347ebc8b4222f59bf88a3 (diff) |
add databar export test
Change-Id: I0770d20911307ddd9426417314bebbe569660b14
Diffstat (limited to 'sc')
-rw-r--r-- | sc/qa/unit/helper/shared_test_impl.hxx | 40 | ||||
-rw-r--r-- | sc/qa/unit/subsequent_export-test.cxx | 30 | ||||
-rw-r--r-- | sc/qa/unit/subsequent_filters-test.cxx | 44 |
3 files changed, 70 insertions, 44 deletions
diff --git a/sc/qa/unit/helper/shared_test_impl.hxx b/sc/qa/unit/helper/shared_test_impl.hxx index 6874a48abf40..04f054735b36 100644 --- a/sc/qa/unit/helper/shared_test_impl.hxx +++ b/sc/qa/unit/helper/shared_test_impl.hxx @@ -30,6 +30,46 @@ private: const ScRange& mrRange; }; +struct DataBarData +{ + ScRange aRange; + ScColorScaleEntryType eLowerLimitType; + ScColorScaleEntryType eUpperLimitType; + databar::ScAxisPostion eAxisPosition; +}; + +DataBarData aData[] = { + { ScRange(1,2,0,1,5,0), COLORSCALE_AUTO, COLORSCALE_AUTO, databar::AUTOMATIC }, + { ScRange(3,2,0,3,5,0), COLORSCALE_MIN, COLORSCALE_MAX, databar::AUTOMATIC }, + { ScRange(5,2,0,5,5,0), COLORSCALE_PERCENTILE, COLORSCALE_PERCENT, databar::AUTOMATIC }, + { ScRange(7,2,0,7,5,0), COLORSCALE_VALUE, COLORSCALE_FORMULA, databar::AUTOMATIC }, + { ScRange(1,9,0,1,12,0), COLORSCALE_AUTO, COLORSCALE_AUTO, databar::MIDDLE } +}; + +void testDataBar_Impl(ScDocument* pDoc) +{ + ScConditionalFormatList* pList = pDoc->GetCondFormList(0); + CPPUNIT_ASSERT(pList); + + for(size_t i = 0; i < SAL_N_ELEMENTS(aData); ++i) + { + ScConditionalFormatList::const_iterator itr = std::find_if(pList->begin(), + pList->end(), FindCondFormatByEnclosingRange(aData[i].aRange)); + CPPUNIT_ASSERT(itr != pList->end()); + CPPUNIT_ASSERT_EQUAL(size_t(1), itr->size()); + + const ScFormatEntry* pFormatEntry = itr->GetEntry(0); + CPPUNIT_ASSERT_EQUAL(pFormatEntry->GetType(), condformat::DATABAR); + const ScDataBarFormat* pDataBar = static_cast<const ScDataBarFormat*>(pFormatEntry); + CPPUNIT_ASSERT(pDataBar); + const ScDataBarFormatData* pDataBarData = pDataBar->GetDataBarData(); + CPPUNIT_ASSERT_EQUAL(aData[i].eLowerLimitType, pDataBarData->mpLowerLimit->GetType()); + CPPUNIT_ASSERT_EQUAL(aData[i].eUpperLimitType, pDataBarData->mpUpperLimit->GetType()); + + CPPUNIT_ASSERT_EQUAL(aData[i].eAxisPosition, pDataBarData->meAxisPosition); + } +} + struct ColorScale2EntryData { ScRange aRange; diff --git a/sc/qa/unit/subsequent_export-test.cxx b/sc/qa/unit/subsequent_export-test.cxx index aa0c1ed8c5ce..c73ba31f36e2 100644 --- a/sc/qa/unit/subsequent_export-test.cxx +++ b/sc/qa/unit/subsequent_export-test.cxx @@ -48,6 +48,8 @@ public: void testConditionalFormatExportXLSX(); void testColorScaleExportODS(); void testColorScaleExportXLSX(); + void testDataBarExportODS(); + void testDataBarExportXLSX(); void testMiscRowHeightExport(); CPPUNIT_TEST_SUITE(ScExportTest); @@ -192,6 +194,34 @@ void ScExportTest::testColorScaleExportXLSX() testColorScale3Entry_Impl(pDoc); } +void ScExportTest::testDataBarExportODS() +{ + ScDocShellRef xShell = loadDoc("databar.", ODS); + CPPUNIT_ASSERT(xShell.Is()); + + ScDocShellRef xDocSh = saveAndReload(xShell, ODS); + CPPUNIT_ASSERT(xDocSh.Is()); + + ScDocument* pDoc = xDocSh->GetDocument(); + CPPUNIT_ASSERT(pDoc); + + testDataBar_Impl(pDoc); +} + +void ScExportTest::testDataBarExportXLSX() +{ + ScDocShellRef xShell = loadDoc("databar.", XLSX); + CPPUNIT_ASSERT(xShell.Is()); + + ScDocShellRef xDocSh = saveAndReload(xShell, XLSX); + CPPUNIT_ASSERT(xDocSh.Is()); + + ScDocument* pDoc = xDocSh->GetDocument(); + CPPUNIT_ASSERT(pDoc); + + testDataBar_Impl(pDoc); +} + void ScExportTest::testMiscRowHeightExport() { TestParam::RowData DfltRowData[] = diff --git a/sc/qa/unit/subsequent_filters-test.cxx b/sc/qa/unit/subsequent_filters-test.cxx index 5a417f8bb218..bdb09fdbd19b 100644 --- a/sc/qa/unit/subsequent_filters-test.cxx +++ b/sc/qa/unit/subsequent_filters-test.cxx @@ -1732,50 +1732,6 @@ void ScFiltersTest::testRichTextContentODS() xDocSh->DoClose(); } -namespace { - -struct DataBarData -{ - ScRange aRange; - ScColorScaleEntryType eLowerLimitType; - ScColorScaleEntryType eUpperLimitType; - databar::ScAxisPostion eAxisPosition; -}; - -DataBarData aData[] = { - { ScRange(1,2,0,1,5,0), COLORSCALE_AUTO, COLORSCALE_AUTO, databar::AUTOMATIC }, - { ScRange(3,2,0,3,5,0), COLORSCALE_MIN, COLORSCALE_MAX, databar::AUTOMATIC }, - { ScRange(5,2,0,5,5,0), COLORSCALE_PERCENTILE, COLORSCALE_PERCENT, databar::AUTOMATIC }, - { ScRange(7,2,0,7,5,0), COLORSCALE_VALUE, COLORSCALE_FORMULA, databar::AUTOMATIC }, - { ScRange(1,9,0,1,12,0), COLORSCALE_AUTO, COLORSCALE_AUTO, databar::MIDDLE } -}; - -void testDataBar_Impl(ScDocument* pDoc) -{ - ScConditionalFormatList* pList = pDoc->GetCondFormList(0); - CPPUNIT_ASSERT(pList); - - for(size_t i = 0; i < SAL_N_ELEMENTS(aData); ++i) - { - ScConditionalFormatList::const_iterator itr = std::find_if(pList->begin(), - pList->end(), FindCondFormatByEnclosingRange(aData[i].aRange)); - CPPUNIT_ASSERT(itr != pList->end()); - CPPUNIT_ASSERT_EQUAL(size_t(1), itr->size()); - - const ScFormatEntry* pFormatEntry = itr->GetEntry(0); - CPPUNIT_ASSERT_EQUAL(pFormatEntry->GetType(), condformat::DATABAR); - const ScDataBarFormat* pDataBar = static_cast<const ScDataBarFormat*>(pFormatEntry); - CPPUNIT_ASSERT(pDataBar); - const ScDataBarFormatData* pDataBarData = pDataBar->GetDataBarData(); - CPPUNIT_ASSERT_EQUAL(aData[i].eLowerLimitType, pDataBarData->mpLowerLimit->GetType()); - CPPUNIT_ASSERT_EQUAL(aData[i].eUpperLimitType, pDataBarData->mpUpperLimit->GetType()); - - CPPUNIT_ASSERT_EQUAL(aData[i].eAxisPosition, pDataBarData->meAxisPosition); - } -} - -} - void ScFiltersTest::testDataBarODS() { ScDocShellRef xDocSh = loadDoc("databar.", ODS); |