From ae7cfa6a9bef89bbe0f7d827925b606a3f59adef Mon Sep 17 00:00:00 2001 From: Markus Mohrhard Date: Thu, 2 Apr 2015 15:58:51 +0200 Subject: add a test for databar entries Change-Id: I38c025481d3135a708668cad00816f22cdd66cc8 --- sc/qa/extras/new_cond_format.cxx | 43 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 43 insertions(+) (limited to 'sc/qa/extras/new_cond_format.cxx') diff --git a/sc/qa/extras/new_cond_format.cxx b/sc/qa/extras/new_cond_format.cxx index edefc1f0f0a5..e067080b4ef9 100644 --- a/sc/qa/extras/new_cond_format.cxx +++ b/sc/qa/extras/new_cond_format.cxx @@ -15,6 +15,8 @@ #include #include #include +#include +#include #include using namespace css; @@ -227,6 +229,45 @@ void testAxisColor(uno::Reference xPropSet, Color aColor) CPPUNIT_ASSERT_EQUAL(aColor.GetColor(), sal_uInt32(nColor)); } +void testDataBarEntryValue(uno::Reference xEntry, + const OUString& rExpectedValue, sal_Int32 nType) +{ + switch (nType) + { + case sheet::DataBarEntryType::DATABAR_VALUE: + case sheet::DataBarEntryType::DATABAR_PERCENT: + case sheet::DataBarEntryType::DATABAR_PERCENTILE: + case sheet::DataBarEntryType::DATABAR_FORMULA: + { + OUString aString = xEntry->getFormula(); + CPPUNIT_ASSERT_EQUAL(rExpectedValue, aString); + } + break; + default: + break; + } +} + +void testDataBarEntries(uno::Reference xPropSet, + const OUString& rExpectedMinString, sal_Int32 nExpectedMinType, + const OUString& rExpectedMaxString, sal_Int32 nExpectedMaxType) +{ + uno::Any aAny = xPropSet->getPropertyValue("DataBarEntries"); + uno::Sequence > aEntries; + CPPUNIT_ASSERT(aAny >>= aEntries); + + CPPUNIT_ASSERT_EQUAL(sal_Int32(2), aEntries.getLength()); + + sal_Int32 nMinType = aEntries[0]->getType(); + CPPUNIT_ASSERT_EQUAL(nExpectedMinType, nMinType); + + sal_Int32 nMaxType = aEntries[1]->getType(); + CPPUNIT_ASSERT_EQUAL(nExpectedMaxType, nMaxType); + + testDataBarEntryValue(aEntries[0], rExpectedMinString, nMinType); + testDataBarEntryValue(aEntries[1], rExpectedMaxString, nMaxType); +} + } void ScConditionalFormatTest::testDataBarProperties() @@ -258,6 +299,8 @@ void ScConditionalFormatTest::testDataBarProperties() testPositiveColor(xPropSet, COL_LIGHTBLUE); testNegativeColor(xPropSet, COL_LIGHTRED); testAxisColor(xPropSet, COL_BLACK); + testDataBarEntries(xPropSet, "", sheet::DataBarEntryType::DATABAR_AUTO, + "", sheet::DataBarEntryType::DATABAR_MAX); } } -- cgit