summaryrefslogtreecommitdiff
path: root/sc
diff options
context:
space:
mode:
authorMarkus Mohrhard <markus.mohrhard@googlemail.com>2013-03-22 08:11:55 +0100
committerMarkus Mohrhard <markus.mohrhard@googlemail.com>2013-03-22 08:56:11 +0100
commitf40803fea0bec4d3b8f9446ca01b9623ebf95c21 (patch)
tree5824c5055c78da43ea9afb5a67fd9ba01a224eb9 /sc
parentedf57013463eff6d3b40d8d5d933577f0e6cf8e3 (diff)
add import test for color scales
Change-Id: Ie85f8efd520aaf4e10b560c637a74fbd9e25530b
Diffstat (limited to 'sc')
-rw-r--r--sc/qa/unit/data/ods/colorscale.odsbin0 -> 8902 bytes
-rw-r--r--sc/qa/unit/data/xlsx/colorscale.xlsxbin0 -> 5888 bytes
-rw-r--r--sc/qa/unit/subsequent_filters-test.cxx110
3 files changed, 110 insertions, 0 deletions
diff --git a/sc/qa/unit/data/ods/colorscale.ods b/sc/qa/unit/data/ods/colorscale.ods
new file mode 100644
index 000000000000..6ea5b83f54f7
--- /dev/null
+++ b/sc/qa/unit/data/ods/colorscale.ods
Binary files differ
diff --git a/sc/qa/unit/data/xlsx/colorscale.xlsx b/sc/qa/unit/data/xlsx/colorscale.xlsx
new file mode 100644
index 000000000000..c70a2079e7a7
--- /dev/null
+++ b/sc/qa/unit/data/xlsx/colorscale.xlsx
Binary files differ
diff --git a/sc/qa/unit/subsequent_filters-test.cxx b/sc/qa/unit/subsequent_filters-test.cxx
index 2206f42a087c..dea8c8528c61 100644
--- a/sc/qa/unit/subsequent_filters-test.cxx
+++ b/sc/qa/unit/subsequent_filters-test.cxx
@@ -124,6 +124,8 @@ public:
void testDataBarODS();
void testDataBarXLSX();
+ void testColorScaleODS();
+ void testColorScaleXLSX();
void testNewCondFormatXLSX();
//change this test file only in excel and not in calc
@@ -184,6 +186,8 @@ public:
CPPUNIT_TEST(testDataBarODS);
CPPUNIT_TEST(testDataBarXLSX);
+ CPPUNIT_TEST(testColorScaleODS);
+ CPPUNIT_TEST(testColorScaleXLSX);
CPPUNIT_TEST(testNewCondFormatXLSX);
CPPUNIT_TEST(testNumberFormatHTML);
@@ -1808,6 +1812,112 @@ void ScFiltersTest::testDataBarXLSX()
testDataBar_Impl(pDoc);
}
+namespace {
+
+struct ColorScale2EntryData
+{
+ ScRange aRange;
+ ScColorScaleEntryType eLowerType;
+ ScColorScaleEntryType eUpperType;
+};
+
+ColorScale2EntryData aData2Entry[] = {
+ { ScRange(1,2,0,1,5,0), COLORSCALE_MIN, COLORSCALE_MAX },
+ { ScRange(3,2,0,3,5,0), COLORSCALE_PERCENTILE, COLORSCALE_PERCENT },
+ { ScRange(5,2,0,5,5,0), COLORSCALE_VALUE, COLORSCALE_FORMULA }
+};
+
+void testColorScale2Entry_Impl(ScDocument* pDoc)
+{
+ const ScConditionalFormatList* pList = pDoc->GetCondFormList(0);
+ CPPUNIT_ASSERT(pList);
+
+ for(size_t i = 0; i < SAL_N_ELEMENTS(aData2Entry); ++i)
+ {
+ ScConditionalFormatList::const_iterator itr = std::find_if(pList->begin(),
+ pList->end(), FindCondFormatByEnclosingRange(aData2Entry[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::COLORSCALE);
+ const ScColorScaleFormat* pColFormat = static_cast<const ScColorScaleFormat*>(pFormatEntry);
+ CPPUNIT_ASSERT_EQUAL(size_t(2), pColFormat->size());
+
+ ScColorScaleFormat::const_iterator format_itr = pColFormat->begin();
+ CPPUNIT_ASSERT_EQUAL(aData2Entry[i].eLowerType, format_itr->GetType());
+ ++format_itr;
+ CPPUNIT_ASSERT(format_itr != pColFormat->end());
+ CPPUNIT_ASSERT_EQUAL(aData2Entry[i].eUpperType, format_itr->GetType());
+ }
+}
+
+struct ColorScale3EntryData
+{
+ ScRange aRange;
+ ScColorScaleEntryType eLowerType;
+ ScColorScaleEntryType eMiddleType;
+ ScColorScaleEntryType eUpperType;
+};
+
+ColorScale3EntryData aData3Entry[] = {
+ { ScRange(1,1,1,1,6,1), COLORSCALE_MIN, COLORSCALE_PERCENTILE, COLORSCALE_MAX },
+ { ScRange(3,1,1,3,6,1), COLORSCALE_PERCENTILE, COLORSCALE_VALUE, COLORSCALE_PERCENT },
+ { ScRange(5,1,1,5,6,1), COLORSCALE_VALUE, COLORSCALE_VALUE, COLORSCALE_FORMULA }
+};
+
+void testColorScale3Entry_Impl(ScDocument* pDoc)
+{
+ ScConditionalFormatList* pList = pDoc->GetCondFormList(1);
+ CPPUNIT_ASSERT(pList);
+
+ for(size_t i = 0; i < SAL_N_ELEMENTS(aData3Entry); ++i)
+ {
+ ScConditionalFormatList::const_iterator itr = std::find_if(pList->begin(),
+ pList->end(), FindCondFormatByEnclosingRange(aData3Entry[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::COLORSCALE);
+ const ScColorScaleFormat* pColFormat = static_cast<const ScColorScaleFormat*>(pFormatEntry);
+ CPPUNIT_ASSERT_EQUAL(size_t(3), pColFormat->size());
+
+ ScColorScaleFormat::const_iterator format_itr = pColFormat->begin();
+ CPPUNIT_ASSERT_EQUAL(aData3Entry[i].eLowerType, format_itr->GetType());
+ ++format_itr;
+ CPPUNIT_ASSERT(format_itr != pColFormat->end());
+ CPPUNIT_ASSERT_EQUAL(aData3Entry[i].eMiddleType, format_itr->GetType());
+ ++format_itr;
+ CPPUNIT_ASSERT(format_itr != pColFormat->end());
+ CPPUNIT_ASSERT_EQUAL(aData3Entry[i].eUpperType, format_itr->GetType());
+ }
+}
+
+}
+
+void ScFiltersTest::testColorScaleODS()
+{
+ ScDocShellRef xDocSh = loadDoc("colorscale.", ODS);
+ CPPUNIT_ASSERT(xDocSh.Is());
+ ScDocument* pDoc = xDocSh->GetDocument();
+ CPPUNIT_ASSERT(pDoc);
+
+ testColorScale2Entry_Impl(pDoc);
+ testColorScale3Entry_Impl(pDoc);
+}
+
+void ScFiltersTest::testColorScaleXLSX()
+{
+ ScDocShellRef xDocSh = loadDoc("colorscale.", XLSX);
+ CPPUNIT_ASSERT(xDocSh.Is());
+ ScDocument* pDoc = xDocSh->GetDocument();
+ CPPUNIT_ASSERT(pDoc);
+
+ testColorScale2Entry_Impl(pDoc);
+ testColorScale3Entry_Impl(pDoc);
+}
+
void ScFiltersTest::testNewCondFormatXLSX()
{
ScDocShellRef xDocSh = ScBootstrapFixture::loadDoc( "new_cond_format_test.", XLSX );