[Libreoffice-commits] .: sc/qa
Markus Mohrhard
mmohrhard at kemper.freedesktop.org
Thu May 26 10:21:21 PDT 2011
sc/qa/unit/ucalc.cxx | 52 +++++++++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 52 insertions(+)
New commits:
commit e8c376c207e89f0b6155e4bbcd0f46421db116ea
Author: Markus Mohrhard <markus.mohrhard at googlemail.com>
Date: Thu May 26 19:12:43 2011 +0200
add unit test for ScDocument::MoveTab
this unit test is disabled for now because there is a problem with ScProgress in ScDocument::MoveTab during unit tests
diff --git a/sc/qa/unit/ucalc.cxx b/sc/qa/unit/ucalc.cxx
index a55fbbf..c43eb01 100644
--- a/sc/qa/unit/ucalc.cxx
+++ b/sc/qa/unit/ucalc.cxx
@@ -236,6 +236,7 @@ public:
void testDataPilot();
void testDataPilotFilters();
void testSheetCopy();
+ void testSheetMove();
void testExternalRef();
void testDataArea();
@@ -276,6 +277,9 @@ public:
CPPUNIT_TEST(testDataPilot);
CPPUNIT_TEST(testDataPilotFilters);
CPPUNIT_TEST(testSheetCopy);
+#if 0 // Disabled, first problem with ScProgress in ScDocument::MoveTab must be solved
+ CPPUNIT_TEST(testSheetMove);
+#endif
CPPUNIT_TEST(testExternalRef);
CPPUNIT_TEST(testDataArea);
CPPUNIT_TEST(testGraphicsInGroup);
@@ -1238,6 +1242,54 @@ void Test::testSheetCopy()
CPPUNIT_ASSERT_MESSAGE("rows 5 - 10 should be hidden", bHidden && nRow1 == 5 && nRow2 == 10);
bHidden = m_pDoc->RowHidden(11, 1, &nRow1, &nRow2);
CPPUNIT_ASSERT_MESSAGE("rows 11 - maxrow should be visible", !bHidden && nRow1 == 11 && nRow2 == MAXROW);
+ m_pDoc->DeleteTab(1);
+ m_pDoc->DeleteTab(0);
+}
+
+void Test::testSheetMove()
+{
+ OUString aTabName(RTL_CONSTASCII_USTRINGPARAM("TestTab1"));
+ m_pDoc->InsertTab(0, aTabName);
+ CPPUNIT_ASSERT_MESSAGE("document should have one sheet to begin with.", m_pDoc->GetTableCount() == 1);
+ SCROW nRow1, nRow2;
+ bool bHidden = m_pDoc->RowHidden(0, 0, &nRow1, &nRow2);
+ CPPUNIT_ASSERT_MESSAGE("new sheet should have all rows visible", !bHidden && nRow1 == 0 && nRow2 == MAXROW);
+
+ //test if inserting before another sheet works
+ m_pDoc->InsertTab(0, OUString(RTL_CONSTASCII_USTRINGPARAM("TestTab2")));
+ CPPUNIT_ASSERT_MESSAGE("document should have two sheets", m_pDoc->GetTableCount() == 2);
+ bHidden = m_pDoc->RowHidden(0, 0, &nRow1, &nRow2);
+ CPPUNIT_ASSERT_MESSAGE("new sheet should have all rows visible", !bHidden && nRow1 == 0 && nRow2 == MAXROW);
+
+ // Move and test the result.
+ m_pDoc->MoveTab(0, 1);
+ CPPUNIT_ASSERT_MESSAGE("document now should have two sheets.", m_pDoc->GetTableCount() == 2);
+ bHidden = m_pDoc->RowHidden(0, 1, &nRow1, &nRow2);
+ CPPUNIT_ASSERT_MESSAGE("copied sheet should also have all rows visible as the original.", !bHidden && nRow1 == 0 && nRow2 == MAXROW);
+ String aName;
+ m_pDoc->GetName(0, aName);
+ CPPUNIT_ASSERT_MESSAGE("sheets should have changed places", aName.EqualsAscii("TestTab1"));
+
+ m_pDoc->SetRowHidden(5, 10, 0, true);
+ bHidden = m_pDoc->RowHidden(0, 0, &nRow1, &nRow2);
+ CPPUNIT_ASSERT_MESSAGE("rows 0 - 4 should be visible", !bHidden && nRow1 == 0 && nRow2 == 4);
+ bHidden = m_pDoc->RowHidden(5, 0, &nRow1, &nRow2);
+ CPPUNIT_ASSERT_MESSAGE("rows 5 - 10 should be hidden", bHidden && nRow1 == 5 && nRow2 == 10);
+ bHidden = m_pDoc->RowHidden(11, 0, &nRow1, &nRow2);
+ CPPUNIT_ASSERT_MESSAGE("rows 11 - maxrow should be visible", !bHidden && nRow1 == 11 && nRow2 == MAXROW);
+
+ // Move the sheet once again.
+ m_pDoc->MoveTab(1, 0);
+ CPPUNIT_ASSERT_MESSAGE("document now should have two sheets.", m_pDoc->GetTableCount() == 2);
+ bHidden = m_pDoc->RowHidden(0, 1, &nRow1, &nRow2);
+ CPPUNIT_ASSERT_MESSAGE("rows 0 - 4 should be visible", !bHidden && nRow1 == 0 && nRow2 == 4);
+ bHidden = m_pDoc->RowHidden(5, 1, &nRow1, &nRow2);
+ CPPUNIT_ASSERT_MESSAGE("rows 5 - 10 should be hidden", bHidden && nRow1 == 5 && nRow2 == 10);
+ bHidden = m_pDoc->RowHidden(11, 1, &nRow1, &nRow2);
+ CPPUNIT_ASSERT_MESSAGE("rows 11 - maxrow should be visible", !bHidden && nRow1 == 11 && nRow2 == MAXROW);
+ m_pDoc->GetName(0, aName);
+ CPPUNIT_ASSERT_MESSAGE("sheets should have changed places", aName.EqualsAscii("TestTab2"));
+ m_pDoc->DeleteTab(1);
m_pDoc->DeleteTab(0);
}
More information about the Libreoffice-commits
mailing list