summaryrefslogtreecommitdiff
path: root/sc
diff options
context:
space:
mode:
authorMarkus Mohrhard <markus.mohrhard@googlemail.com>2015-05-17 03:07:45 +0200
committerMarkus Mohrhard <markus.mohrhard@googlemail.com>2015-05-17 06:48:24 +0200
commit31719b052740766c43df508999b691af9075aa3d (patch)
treec70eecec0de629bbf2ec5560e8a408a6a65e483a /sc
parenta8fc28682da6223520706f990598f58362fad9d5 (diff)
initial test for databar length calculation
Change-Id: I6fb47b7987733e4047008430a62f77d58cc592ad
Diffstat (limited to 'sc')
-rw-r--r--sc/qa/unit/ucalc.cxx47
-rw-r--r--sc/qa/unit/ucalc.hxx2
2 files changed, 49 insertions, 0 deletions
diff --git a/sc/qa/unit/ucalc.cxx b/sc/qa/unit/ucalc.cxx
index 6503ddced60f..c9a46f83a9c4 100644
--- a/sc/qa/unit/ucalc.cxx
+++ b/sc/qa/unit/ucalc.cxx
@@ -5879,6 +5879,53 @@ void Test::testIconSet()
m_pDoc->DeleteTab(0);
}
+void Test::testDataBarLength()
+{
+ m_pDoc->InsertTab(0, "Test");
+
+ ScConditionalFormat* pFormat = new ScConditionalFormat(1, m_pDoc);
+ ScRangeList aRangeList(ScRange(0,0,0,0,7,0));
+ pFormat->SetRange(aRangeList);
+
+ ScDataBarFormat* pDatabar = new ScDataBarFormat(m_pDoc);
+ pFormat->AddEntry(pDatabar);
+
+ ScDataBarFormatData* pFormatData = new ScDataBarFormatData();
+ pFormatData->mpLowerLimit.reset(new ScColorScaleEntry());
+ pFormatData->mpLowerLimit->SetValue(3);
+ pFormatData->mpLowerLimit->SetType(COLORSCALE_VALUE);
+ pFormatData->mpUpperLimit.reset(new ScColorScaleEntry());
+ pFormatData->mpUpperLimit->SetValue(7);
+ pFormatData->mpUpperLimit->SetType(COLORSCALE_VALUE);
+ pDatabar->SetDataBarData(pFormatData);
+
+ struct {
+ double nVal; double nLength;
+ } aValues[] = {
+ { 2, 0 },
+ { 3, 0 },
+ { 4, 25.0 },
+ { 5, 50.0 },
+ { 6, 75.0 },
+ { 7, 100.0 },
+ { 8, 100.0 }
+ };
+
+ for (size_t i = 0; i < SAL_N_ELEMENTS(aValues); ++i)
+ {
+ m_pDoc->SetValue(0, i, 0, aValues[i].nVal);
+ }
+
+ for (size_t i = 0; i < SAL_N_ELEMENTS(aValues); ++i)
+ {
+ ScDataBarInfo* pInfo = pDatabar->GetDataBarInfo(ScAddress(0, i, 0));
+ CPPUNIT_ASSERT(pInfo);
+ ASSERT_DOUBLES_EQUAL(aValues[i].nLength, pInfo->mnLength);
+ }
+ delete pFormat;
+ m_pDoc->DeleteTab(0);
+}
+
void Test::testImportStream()
{
sc::AutoCalcSwitch aAC(*m_pDoc, true); // turn on auto calc.
diff --git a/sc/qa/unit/ucalc.hxx b/sc/qa/unit/ucalc.hxx
index 1cec088af157..ff8356ed1491 100644
--- a/sc/qa/unit/ucalc.hxx
+++ b/sc/qa/unit/ucalc.hxx
@@ -419,6 +419,7 @@ public:
void testCondCopyPasteSheetBetweenDoc();
void testCondCopyPasteSheet();
void testIconSet();
+ void testDataBarLength();
void testImportStream();
void testDeleteContents();
@@ -631,6 +632,7 @@ public:
CPPUNIT_TEST(testCondCopyPasteSheetBetweenDoc);
CPPUNIT_TEST(testCondCopyPasteSheet);
CPPUNIT_TEST(testIconSet);
+ CPPUNIT_TEST(testDataBarLength);
CPPUNIT_TEST(testImportStream);
CPPUNIT_TEST(testDeleteContents);
CPPUNIT_TEST(testTransliterateText);