Kaydet (Commit) 06c17598 authored tarafından Kohei Yoshida's avatar Kohei Yoshida

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
üst 6377907a
...@@ -4763,59 +4763,67 @@ void Test::testNoteBasic() ...@@ -4763,59 +4763,67 @@ void Test::testNoteBasic()
OUString aTabName2("Table2"); OUString aTabName2("Table2");
m_pDoc->InsertTab(0, aTabName); m_pDoc->InsertTab(0, aTabName);
ScAddress rAddr(2, 2, 0); // cell C3 ScAddress aAddr(2, 2, 0); // cell C3
ScPostIt *pNote = m_pDoc->GetOrCreateNote(rAddr); ScPostIt *pNote = m_pDoc->GetOrCreateNote(aAddr);
pNote->SetText(rAddr, aHello); pNote->SetText(aAddr, aHello);
pNote->SetAuthor(aJimBob); pNote->SetAuthor(aJimBob);
ScPostIt *pGetNote = m_pDoc->GetNote(rAddr); ScPostIt *pGetNote = m_pDoc->GetNote(aAddr);
CPPUNIT_ASSERT_MESSAGE("note should be itself", pGetNote == pNote ); CPPUNIT_ASSERT_MESSAGE("note should be itself", pGetNote == pNote);
// Insert one row at row 1. // Insert one row at row 1.
bool bInsertRow = m_pDoc->InsertRow(0, 0, MAXCOL, 0, 1, 1); bool bInsertRow = m_pDoc->InsertRow(0, 0, MAXCOL, 0, 1, 1);
CPPUNIT_ASSERT_MESSAGE("failed to insert row", bInsertRow ); CPPUNIT_ASSERT_MESSAGE("failed to insert row", bInsertRow );
CPPUNIT_ASSERT_MESSAGE("note hasn't moved", m_pDoc->GetNote(rAddr) == NULL); CPPUNIT_ASSERT_MESSAGE("note hasn't moved", m_pDoc->GetNote(aAddr) == NULL);
rAddr.IncRow(); // cell C4 aAddr.IncRow(); // cell C4
CPPUNIT_ASSERT_MESSAGE("note not there", m_pDoc->GetNote(rAddr) == pNote); CPPUNIT_ASSERT_MESSAGE("note not there", m_pDoc->GetNote(aAddr) == pNote);
// Insert column at column A. // Insert column at column A.
bool bInsertCol = m_pDoc->InsertCol(0, 0, MAXROW, 0, 1, 1); bool bInsertCol = m_pDoc->InsertCol(0, 0, MAXROW, 0, 1, 1);
CPPUNIT_ASSERT_MESSAGE("failed to insert column", bInsertCol ); CPPUNIT_ASSERT_MESSAGE("failed to insert column", bInsertCol );
CPPUNIT_ASSERT_MESSAGE("note hasn't moved", m_pDoc->GetNote(rAddr) == NULL); CPPUNIT_ASSERT_MESSAGE("note hasn't moved", m_pDoc->GetNote(aAddr) == NULL);
rAddr.IncCol(); // cell D4 aAddr.IncCol(); // cell D4
CPPUNIT_ASSERT_MESSAGE("note not there", m_pDoc->GetNote(rAddr) == pNote); CPPUNIT_ASSERT_MESSAGE("note not there", m_pDoc->GetNote(aAddr) == pNote);
// Insert a new sheet to shift the current sheet to the right. // Insert a new sheet to shift the current sheet to the right.
m_pDoc->InsertTab(0, aTabName2); m_pDoc->InsertTab(0, aTabName2);
CPPUNIT_ASSERT_MESSAGE("note hasn't moved", m_pDoc->GetNote(rAddr) == NULL); CPPUNIT_ASSERT_MESSAGE("note hasn't moved", m_pDoc->GetNote(aAddr) == NULL);
rAddr.IncTab(); // Move to the next sheet. aAddr.IncTab(); // Move to the next sheet.
CPPUNIT_ASSERT_MESSAGE("note not there", m_pDoc->GetNote(rAddr) == pNote); CPPUNIT_ASSERT_MESSAGE("note not there", m_pDoc->GetNote(aAddr) == pNote);
m_pDoc->DeleteTab(0); m_pDoc->DeleteTab(0);
rAddr.IncTab(-1); aAddr.IncTab(-1);
CPPUNIT_ASSERT_MESSAGE("note not there", m_pDoc->GetNote(rAddr) == pNote); CPPUNIT_ASSERT_MESSAGE("note not there", m_pDoc->GetNote(aAddr) == pNote);
// Insert cell at C4. This should NOT shift the note position. // Insert cell at C4. This should NOT shift the note position.
bInsertRow = m_pDoc->InsertRow(2, 0, 2, 0, 3, 1); bInsertRow = m_pDoc->InsertRow(2, 0, 2, 0, 3, 1);
CPPUNIT_ASSERT_MESSAGE("Failed to insert cell at C4.", bInsertRow); 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. // Delete cell at C4. Again, this should NOT shift the note position.
m_pDoc->DeleteRow(2, 0, 2, 0, 3, 1); 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. // 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); m_pDoc->DeleteRow(3, 0, 3, 0, 2, 1);
rAddr.IncRow(-1); // cell D3 aAddr.IncRow(-1); // cell D3
CPPUNIT_ASSERT_MESSAGE("Note at D4 should have shifted up to D3.", m_pDoc->GetNote(rAddr) == pNote); 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. // Delete column C. This should shift the note one cell left.
m_pDoc->DeleteCol(0, 0, MAXROW, 0, 2, 1); m_pDoc->DeleteCol(0, 0, MAXROW, 0, 2, 1);
rAddr.IncCol(-1); // cell C3 aAddr.IncCol(-1); // cell C3
CPPUNIT_ASSERT_MESSAGE("Note at D3 should have shifted left to C3.", m_pDoc->GetNote(rAddr) == pNote); 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); m_pDoc->DeleteTab(0);
} }
......
...@@ -395,7 +395,6 @@ public: ...@@ -395,7 +395,6 @@ public:
CPPUNIT_TEST(testDataArea); CPPUNIT_TEST(testDataArea);
CPPUNIT_TEST(testGraphicsInGroup); CPPUNIT_TEST(testGraphicsInGroup);
CPPUNIT_TEST(testGraphicsOnSheetMove); CPPUNIT_TEST(testGraphicsOnSheetMove);
CPPUNIT_TEST(testNoteBasic);
CPPUNIT_TEST(testStreamValid); CPPUNIT_TEST(testStreamValid);
CPPUNIT_TEST(testFunctionLists); CPPUNIT_TEST(testFunctionLists);
CPPUNIT_TEST(testToggleRefFlag); CPPUNIT_TEST(testToggleRefFlag);
...@@ -431,6 +430,7 @@ public: ...@@ -431,6 +430,7 @@ public:
CPPUNIT_TEST(testSortWithFormulaRefs); CPPUNIT_TEST(testSortWithFormulaRefs);
CPPUNIT_TEST(testSortWithStrings); CPPUNIT_TEST(testSortWithStrings);
CPPUNIT_TEST(testShiftCells); CPPUNIT_TEST(testShiftCells);
CPPUNIT_TEST(testNoteBasic);
CPPUNIT_TEST(testNoteDeleteRow); CPPUNIT_TEST(testNoteDeleteRow);
CPPUNIT_TEST(testNoteDeleteCol); CPPUNIT_TEST(testNoteDeleteCol);
CPPUNIT_TEST(testNoteLifeCycle); CPPUNIT_TEST(testNoteLifeCycle);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment