[Libreoffice-commits] .: sc/qa

Markus Mohrhard mmohrhard at kemper.freedesktop.org
Tue Apr 3 22:51:02 PDT 2012


 sc/qa/unit/ucalc.cxx |   49 +++++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 49 insertions(+)

New commits:
commit 62d745ddde6b60aaaa796123f45b3df8c10e9869
Author: Karthik A Padmanabhan <treadstone90 at gmail.com>
Date:   Tue Apr 3 01:21:16 2012 +0530

    Test cases for ScDocFunc::RenameTable()
    
    Rename twice and also check if upon renaming two tables have the same name or not

diff --git a/sc/qa/unit/ucalc.cxx b/sc/qa/unit/ucalc.cxx
index 245215c..c8bd00c 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


More information about the Libreoffice-commits mailing list