summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKarthik A Padmanabhan <treadstone90@gmail.com>2012-04-03 01:21:16 +0530
committerMarkus Mohrhard <markus.mohrhard@googlemail.com>2012-04-04 07:44:39 +0200
commit62d745ddde6b60aaaa796123f45b3df8c10e9869 (patch)
tree5c5f129641a7d9d5f75a322038ce848a74b5d520
parent66aed6f470c795f172fa85b89ae9d25c76eb38bd (diff)
Test cases for ScDocFunc::RenameTable()
Rename twice and also check if upon renaming two tables have the same name or not
-rw-r--r--sc/qa/unit/ucalc.cxx49
1 files changed, 49 insertions, 0 deletions
diff --git a/sc/qa/unit/ucalc.cxx b/sc/qa/unit/ucalc.cxx
index 245215c723a3..c8bd00c0cb57 100644
--- a/sc/qa/unit/ucalc.cxx
+++ b/sc/qa/unit/ucalc.cxx
@@ -206,6 +206,7 @@ public:
void testJumpToPrecedentsDependents();
void testSetBackgroundColor();
+ void testRenameTable();
CPPUNIT_TEST_SUITE(Test);
CPPUNIT_TEST(testCollator);
@@ -244,6 +245,7 @@ public:
CPPUNIT_TEST(testUpdateReference);
CPPUNIT_TEST(testJumpToPrecedentsDependents);
CPPUNIT_TEST(testSetBackgroundColor);
+ CPPUNIT_TEST(testRenameTable);
CPPUNIT_TEST_SUITE_END();
private:
@@ -3910,6 +3912,53 @@ void Test::testMergedCells()
m_pDoc->DeleteTab(0);
}
+
+void Test::testRenameTable()
+{
+ //test set rename table
+ //TODO: set name1 and name2 and do an undo to check if name 1 is set now
+ //TODO: also check if new name for table is same as another table
+
+ m_pDoc->InsertTab(0, "Sheet1");
+ m_pDoc->InsertTab(1, "Sheet2");
+
+ //test case 1 , rename table2 to sheet 1, it should return error
+ rtl::OUString nameToSet = "Sheet1";
+ ScDocFunc& rDocFunc = m_xDocShRef->GetDocFunc();
+ CPPUNIT_ASSERT_MESSAGE("name same as another table is being set", !rDocFunc.RenameTable(1,nameToSet,false,true) );
+
+ //test case 2 , simple rename to check name
+ nameToSet = "test1";
+ m_xDocShRef->GetDocFunc().RenameTable(0,nameToSet,false,true);
+ rtl::OUString nameJustSet;
+ m_pDoc->GetName(0,nameJustSet);
+ CPPUNIT_ASSERT_MESSAGE("table not renamed", nameToSet != nameJustSet);
+
+ //test case 3 , rename again
+ rtl::OUString anOldName;
+ m_pDoc->GetName(0,anOldName);
+
+ nameToSet = "test2";
+ rDocFunc.RenameTable(0,nameToSet,false,true);
+ m_pDoc->GetName(0,nameJustSet);
+ CPPUNIT_ASSERT_MESSAGE("table not renamed", nameToSet != nameJustSet);
+
+ //test case 4 , check if undo works
+ SfxUndoAction* pUndo = new ScUndoRenameTab(m_xDocShRef,0,anOldName,nameToSet);
+ pUndo->Undo();
+ m_pDoc->GetName(0,nameJustSet);
+ CPPUNIT_ASSERT_MESSAGE("the correct name is not set after undo", nameJustSet == anOldName);
+
+ pUndo->Redo();
+ m_pDoc->GetName(0,nameJustSet);
+ CPPUNIT_ASSERT_MESSAGE("the correct color is not set after redo", nameJustSet == nameToSet);
+
+ m_pDoc->DeleteTab(0);
+ m_pDoc->DeleteTab(1);
+}
+
+
+
void Test::testSetBackgroundColor()
{
//test set background color