diff options
author | Markus Mohrhard <markus.mohrhard@googlemail.com> | 2016-03-26 16:34:48 +0100 |
---|---|---|
committer | Markus Mohrhard <markus.mohrhard@googlemail.com> | 2016-03-26 16:59:20 +0100 |
commit | ba64def7776e592a37fbb1833edacb397ba373a2 (patch) | |
tree | 4361ec51bfb8b8e279cc24c9a0f901bc90c394a9 | |
parent | 988a49426f42c1445bc26677cf8041b7a233015c (diff) |
add a few unit tests for conditional format reference listening
Change-Id: I0609bf9033a7a2dd40afaae9effbfa06de5e4c83
-rw-r--r-- | sc/qa/unit/ucalc.hxx | 11 | ||||
-rw-r--r-- | sc/qa/unit/ucalc_condformat.cxx | 121 |
2 files changed, 132 insertions, 0 deletions
diff --git a/sc/qa/unit/ucalc.hxx b/sc/qa/unit/ucalc.hxx index 59a445b5e233..d2845976c6ad 100644 --- a/sc/qa/unit/ucalc.hxx +++ b/sc/qa/unit/ucalc.hxx @@ -432,6 +432,8 @@ public: void testCellTextWidth(); void testEditTextIterator(); + // conditional format tests + // mostly in ucalc_condformat.cxx void testCondFormatINSDEL(); void testCondFormatInsertRow(); void testCondFormatInsertCol(); @@ -444,11 +446,20 @@ public: void testIconSet(); void testDataBarLengthAutomaticAxis(); void testDataBarLengthMiddleAxis(); + + // Tests for the ScFormulaListener class void testFormulaListenerSingleCellToSingleCell(); void testFormulaListenerMultipleCellsToSingleCell(); void testFormulaListenerSingleCellToMultipleCells(); void testFormulaListenerMultipleCellsToMultipleCells(); + // Check that the Listeners are correctly updated when we + // call a operation + void testCondFormatUpdateMoveTab(); + void testCondFormatUpdateDeleteTab(); + void testCondFormatUpdateInsertTab(); + void testCondFormatUpdateReference(); + void testCondFormatEndsWithStr(); void testCondFormatEndsWithVal(); diff --git a/sc/qa/unit/ucalc_condformat.cxx b/sc/qa/unit/ucalc_condformat.cxx index aa21471cf511..6d75c02caafb 100644 --- a/sc/qa/unit/ucalc_condformat.cxx +++ b/sc/qa/unit/ucalc_condformat.cxx @@ -743,4 +743,125 @@ void Test::testFormulaListenerMultipleCellsToMultipleCells() m_pDoc->DeleteTab(0); } +void Test::testCondFormatUpdateMoveTab() +{ + m_pDoc->InsertTab(0, "test"); + m_pDoc->InsertTab(1, "Test2"); + + ScConditionEntry* pEntry = new ScConditionEntry(SC_COND_EQUAL, "A1", "", m_pDoc, ScAddress(10, 10, 0), "", "", formula::FormulaGrammar::GRAM_DEFAULT, formula::FormulaGrammar::GRAM_DEFAULT); + + ScConditionalFormat* pFormat = new ScConditionalFormat(0, m_pDoc); + pFormat->SetRange(ScRange(10, 10, 0, 10, 12, 0)); + m_pDoc->AddCondFormat(pFormat, 0); + + pFormat->AddEntry(pEntry); + + // the conditional format should listen to A1:A3 + for (SCROW nRow = 0; nRow < 3; ++nRow) + { + m_pDoc->SetValue(ScAddress(0, nRow, 0), 1.0); + CPPUNIT_ASSERT(pEntry->NeedsRepaint()); + } + + m_pDoc->MoveTab(0, 1); + + // the conditional format should listen to A1:A3 on the second sheet + for (SCROW nRow = 0; nRow < 3; ++nRow) + { + m_pDoc->SetValue(ScAddress(0, nRow, 1), 1.0); + CPPUNIT_ASSERT(pEntry->NeedsRepaint()); + } + + m_pDoc->DeleteTab(1); + m_pDoc->DeleteTab(0); +} + +void Test::testCondFormatUpdateInsertTab() +{ + m_pDoc->InsertTab(0, "test"); + + ScConditionEntry* pEntry = new ScConditionEntry(SC_COND_EQUAL, "A1", "", m_pDoc, ScAddress(10, 10, 0), "", "", formula::FormulaGrammar::GRAM_DEFAULT, formula::FormulaGrammar::GRAM_DEFAULT); + + ScConditionalFormat* pFormat = new ScConditionalFormat(0, m_pDoc); + pFormat->SetRange(ScRange(10, 10, 0, 10, 12, 0)); + m_pDoc->AddCondFormat(pFormat, 0); + + pFormat->AddEntry(pEntry); + + // the conditional format should listen to A1:A3 + for (SCROW nRow = 0; nRow < 3; ++nRow) + { + m_pDoc->SetValue(ScAddress(0, nRow, 0), 1.0); + CPPUNIT_ASSERT(pEntry->NeedsRepaint()); + } + + m_pDoc->InsertTab(0, "test2"); + + // the conditional format should listen to A1:A3 on the second sheet + for (SCROW nRow = 0; nRow < 3; ++nRow) + { + m_pDoc->SetValue(ScAddress(0, nRow, 1), 1.0); + CPPUNIT_ASSERT(pEntry->NeedsRepaint()); + } + + m_pDoc->DeleteTab(1); + m_pDoc->DeleteTab(0); +} + +void Test::testCondFormatUpdateDeleteTab() +{ + m_pDoc->InsertTab(0, "test"); + m_pDoc->InsertTab(1, "Test2"); + + ScConditionEntry* pEntry = new ScConditionEntry(SC_COND_EQUAL, "A1", "", m_pDoc, ScAddress(10, 10, 1), "", "", formula::FormulaGrammar::GRAM_DEFAULT, formula::FormulaGrammar::GRAM_DEFAULT); + + ScConditionalFormat* pFormat = new ScConditionalFormat(0, m_pDoc); + pFormat->SetRange(ScRange(10, 10, 1, 10, 12, 1)); + m_pDoc->AddCondFormat(pFormat, 1); + + pFormat->AddEntry(pEntry); + + // the conditional format should listen to A1:A3 on the second sheet + for (SCROW nRow = 0; nRow < 3; ++nRow) + { + m_pDoc->SetValue(ScAddress(0, nRow, 1), 1.0); + CPPUNIT_ASSERT(pEntry->NeedsRepaint()); + } + + m_pDoc->DeleteTab(0); + + // the conditional format should listen to A1:A3 on the second sheet + for (SCROW nRow = 0; nRow < 3; ++nRow) + { + m_pDoc->SetValue(ScAddress(0, nRow, 0), 1.0); + CPPUNIT_ASSERT(pEntry->NeedsRepaint()); + } + + m_pDoc->DeleteTab(0); +} + +void Test::testCondFormatUpdateReference() +{ + m_pDoc->InsertTab(0, "test"); + m_pDoc->InsertTab(1, "Test2"); + + ScConditionEntry* pEntry = new ScConditionEntry(SC_COND_EQUAL, "A1", "", m_pDoc, ScAddress(10, 10, 0), "", "", formula::FormulaGrammar::GRAM_DEFAULT, formula::FormulaGrammar::GRAM_DEFAULT); + + ScConditionalFormat* pFormat = new ScConditionalFormat(0, m_pDoc); + pFormat->SetRange(ScRange(10, 10, 0, 10, 12, 0)); + m_pDoc->AddCondFormat(pFormat, 0); + + pFormat->AddEntry(pEntry); + + // the conditional format should listen to A1:A3 + for (SCROW nRow = 0; nRow < 3; ++nRow) + { + m_pDoc->SetValue(ScAddress(0, nRow, 0), 1.0); + CPPUNIT_ASSERT(pEntry->NeedsRepaint()); + } + + m_pDoc->DeleteTab(1); + m_pDoc->DeleteTab(0); +} + /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ |