diff options
author | Kohei Yoshida <kohei.yoshida@collabora.com> | 2014-02-07 16:00:08 -0500 |
---|---|---|
committer | Kohei Yoshida <kohei.yoshida@collabora.com> | 2014-02-07 16:05:13 -0500 |
commit | 06c17598fb944aebcd0ef0783d2d4a81662208bb (patch) | |
tree | 328f6525ae1b37d7822a1df13a18532dcf5111db /sc/qa | |
parent | 6377907addf266d783ba741a7d4f425f86fb7b20 (diff) |
fdo#74273: Adopt existing test to catch this.
Apparently having a non-empty cell where the note is makes the note take
a slightly different code path.
Change-Id: I23decb83eeb34ee9e16b4f56816648815f102db8
Diffstat (limited to 'sc/qa')
-rw-r--r-- | sc/qa/unit/ucalc.cxx | 52 | ||||
-rw-r--r-- | sc/qa/unit/ucalc.hxx | 2 |
2 files changed, 31 insertions, 23 deletions
diff --git a/sc/qa/unit/ucalc.cxx b/sc/qa/unit/ucalc.cxx index 275e4a04eadf..b91255e243bf 100644 --- a/sc/qa/unit/ucalc.cxx +++ b/sc/qa/unit/ucalc.cxx @@ -4763,59 +4763,67 @@ void Test::testNoteBasic() OUString aTabName2("Table2"); m_pDoc->InsertTab(0, aTabName); - ScAddress rAddr(2, 2, 0); // cell C3 - ScPostIt *pNote = m_pDoc->GetOrCreateNote(rAddr); + ScAddress aAddr(2, 2, 0); // cell C3 + ScPostIt *pNote = m_pDoc->GetOrCreateNote(aAddr); - pNote->SetText(rAddr, aHello); + pNote->SetText(aAddr, aHello); pNote->SetAuthor(aJimBob); - ScPostIt *pGetNote = m_pDoc->GetNote(rAddr); - CPPUNIT_ASSERT_MESSAGE("note should be itself", pGetNote == pNote ); + ScPostIt *pGetNote = m_pDoc->GetNote(aAddr); + CPPUNIT_ASSERT_MESSAGE("note should be itself", pGetNote == pNote); // Insert one row at row 1. bool bInsertRow = m_pDoc->InsertRow(0, 0, MAXCOL, 0, 1, 1); CPPUNIT_ASSERT_MESSAGE("failed to insert row", bInsertRow ); - CPPUNIT_ASSERT_MESSAGE("note hasn't moved", m_pDoc->GetNote(rAddr) == NULL); - rAddr.IncRow(); // cell C4 - CPPUNIT_ASSERT_MESSAGE("note not there", m_pDoc->GetNote(rAddr) == pNote); + CPPUNIT_ASSERT_MESSAGE("note hasn't moved", m_pDoc->GetNote(aAddr) == NULL); + aAddr.IncRow(); // cell C4 + CPPUNIT_ASSERT_MESSAGE("note not there", m_pDoc->GetNote(aAddr) == pNote); // Insert column at column A. bool bInsertCol = m_pDoc->InsertCol(0, 0, MAXROW, 0, 1, 1); CPPUNIT_ASSERT_MESSAGE("failed to insert column", bInsertCol ); - CPPUNIT_ASSERT_MESSAGE("note hasn't moved", m_pDoc->GetNote(rAddr) == NULL); - rAddr.IncCol(); // cell D4 - CPPUNIT_ASSERT_MESSAGE("note not there", m_pDoc->GetNote(rAddr) == pNote); + CPPUNIT_ASSERT_MESSAGE("note hasn't moved", m_pDoc->GetNote(aAddr) == NULL); + aAddr.IncCol(); // cell D4 + CPPUNIT_ASSERT_MESSAGE("note not there", m_pDoc->GetNote(aAddr) == pNote); // Insert a new sheet to shift the current sheet to the right. m_pDoc->InsertTab(0, aTabName2); - CPPUNIT_ASSERT_MESSAGE("note hasn't moved", m_pDoc->GetNote(rAddr) == NULL); - rAddr.IncTab(); // Move to the next sheet. - CPPUNIT_ASSERT_MESSAGE("note not there", m_pDoc->GetNote(rAddr) == pNote); + CPPUNIT_ASSERT_MESSAGE("note hasn't moved", m_pDoc->GetNote(aAddr) == NULL); + aAddr.IncTab(); // Move to the next sheet. + CPPUNIT_ASSERT_MESSAGE("note not there", m_pDoc->GetNote(aAddr) == pNote); m_pDoc->DeleteTab(0); - rAddr.IncTab(-1); - CPPUNIT_ASSERT_MESSAGE("note not there", m_pDoc->GetNote(rAddr) == pNote); + aAddr.IncTab(-1); + CPPUNIT_ASSERT_MESSAGE("note not there", m_pDoc->GetNote(aAddr) == pNote); // Insert cell at C4. This should NOT shift the note position. bInsertRow = m_pDoc->InsertRow(2, 0, 2, 0, 3, 1); CPPUNIT_ASSERT_MESSAGE("Failed to insert cell at C4.", bInsertRow); - CPPUNIT_ASSERT_MESSAGE("Note shouldn't have moved but it has.", m_pDoc->GetNote(rAddr) == pNote); + CPPUNIT_ASSERT_MESSAGE("Note shouldn't have moved but it has.", m_pDoc->GetNote(aAddr) == pNote); // Delete cell at C4. Again, this should NOT shift the note position. m_pDoc->DeleteRow(2, 0, 2, 0, 3, 1); - CPPUNIT_ASSERT_MESSAGE("Note shouldn't have moved but it has.", m_pDoc->GetNote(rAddr) == pNote); + CPPUNIT_ASSERT_MESSAGE("Note shouldn't have moved but it has.", m_pDoc->GetNote(aAddr) == pNote); // Now, with the note at D4, delete cell D3. This should shift the note one cell up. m_pDoc->DeleteRow(3, 0, 3, 0, 2, 1); - rAddr.IncRow(-1); // cell D3 - CPPUNIT_ASSERT_MESSAGE("Note at D4 should have shifted up to D3.", m_pDoc->GetNote(rAddr) == pNote); + aAddr.IncRow(-1); // cell D3 + CPPUNIT_ASSERT_MESSAGE("Note at D4 should have shifted up to D3.", m_pDoc->GetNote(aAddr) == pNote); // Delete column C. This should shift the note one cell left. m_pDoc->DeleteCol(0, 0, MAXROW, 0, 2, 1); - rAddr.IncCol(-1); // cell C3 - CPPUNIT_ASSERT_MESSAGE("Note at D3 should have shifted left to C3.", m_pDoc->GetNote(rAddr) == pNote); + aAddr.IncCol(-1); // cell C3 + CPPUNIT_ASSERT_MESSAGE("Note at D3 should have shifted left to C3.", m_pDoc->GetNote(aAddr) == pNote); + + // Insert a text where the note is. + m_pDoc->SetString(aAddr, "Note is here."); + + // Delete row 1. This should shift the note from C3 to C2. + m_pDoc->DeleteRow(0, 0, MAXCOL, 0, 0, 1); + aAddr.IncRow(-1); // C2 + CPPUNIT_ASSERT_MESSAGE("Note at C3 should have shifted up to C2.", m_pDoc->GetNote(aAddr) == pNote); m_pDoc->DeleteTab(0); } diff --git a/sc/qa/unit/ucalc.hxx b/sc/qa/unit/ucalc.hxx index 74b79a399486..f59546798bec 100644 --- a/sc/qa/unit/ucalc.hxx +++ b/sc/qa/unit/ucalc.hxx @@ -395,7 +395,6 @@ public: CPPUNIT_TEST(testDataArea); CPPUNIT_TEST(testGraphicsInGroup); CPPUNIT_TEST(testGraphicsOnSheetMove); - CPPUNIT_TEST(testNoteBasic); CPPUNIT_TEST(testStreamValid); CPPUNIT_TEST(testFunctionLists); CPPUNIT_TEST(testToggleRefFlag); @@ -431,6 +430,7 @@ public: CPPUNIT_TEST(testSortWithFormulaRefs); CPPUNIT_TEST(testSortWithStrings); CPPUNIT_TEST(testShiftCells); + CPPUNIT_TEST(testNoteBasic); CPPUNIT_TEST(testNoteDeleteRow); CPPUNIT_TEST(testNoteDeleteCol); CPPUNIT_TEST(testNoteLifeCycle); |