dev/null                              |binary
 sc/qa/uitest/calc_tests6/tdf107869.py |   84 ----------------------------------
 sc/qa/unit/uicalc/uicalc.cxx          |   84 ++++++++++++++++++++++++++++++++++
 3 files changed, 84 insertions(+), 84 deletions(-)

New commits:
commit f5467ffb31fbd17d0ed57f9453373e36803404b0
Author:     Xisco Fauli <xiscofa...@libreoffice.org>
AuthorDate: Tue Mar 8 16:10:04 2022 +0100
Commit:     Xisco Fauli <xiscofa...@libreoffice.org>
CommitDate: Tue Mar 8 17:27:44 2022 +0100

    tdf#107869: sc: move UItest to CppUnittest
    
    Change-Id: I6b8ab5e7fce23f25cf89ac09caa746787ce209d5
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/131215
    Tested-by: Jenkins
    Reviewed-by: Xisco Fauli <xiscofa...@libreoffice.org>

diff --git a/sc/qa/uitest/calc_tests6/tdf107869.py 
b/sc/qa/uitest/calc_tests6/tdf107869.py
deleted file mode 100644
index 8b85ca978a49..000000000000
--- a/sc/qa/uitest/calc_tests6/tdf107869.py
+++ /dev/null
@@ -1,84 +0,0 @@
-# -*- tab-width: 4; indent-tabs-mode: nil; py-indent-offset: 4 -*-
-#
-# This file is part of the LibreOffice project.
-#
-# This Source Code Form is subject to the terms of the Mozilla Public
-# License, v. 2.0. If a copy of the MPL was not distributed with this
-# file, You can obtain one at http://mozilla.org/MPL/2.0/.
-#
-from uitest.framework import UITestCase
-from uitest.uihelper.common import get_url_for_data_file
-from libreoffice.calc.document import get_cell_by_position
-from libreoffice.uno.propertyvalue import mkPropertyValues
-
-class tdf107869(UITestCase):
-    def test_tdf107869_undo_redo_delete_row_with_comment(self):
-        with self.ui_test.load_file(get_url_for_data_file("comments.ods")) as 
calc_doc:
-            xCalcDoc = self.xUITest.getTopFocusWindow()
-            gridwin = xCalcDoc.getChild("grid_window")
-            #- Delete the row with comment.
-            #select row 1
-            gridwin.executeAction("SELECT", mkPropertyValues({"CELL": "A1"}))
-            self.xUITest.executeCommand(".uno:SelectRow")
-            #delete row 1
-            self.xUITest.executeCommand(".uno:DeleteRows")
-            #A1 should be "B"
-            self.assertEqual(get_cell_by_position(calc_doc, 0, 0, 
0).getString(), "B")
-            #- Undo-redo deletion a few times.
-            self.xUITest.executeCommand(".uno:Undo")
-            self.assertEqual(get_cell_by_position(calc_doc, 0, 0, 
0).getString(), "A")
-            self.xUITest.executeCommand(".uno:Redo")
-            self.assertEqual(get_cell_by_position(calc_doc, 0, 0, 
0).getString(), "B")
-            self.xUITest.executeCommand(".uno:Undo")
-            self.assertEqual(get_cell_by_position(calc_doc, 0, 0, 
0).getString(), "A")
-            self.xUITest.executeCommand(".uno:Redo")
-            self.assertEqual(get_cell_by_position(calc_doc, 0, 0, 
0).getString(), "B")
-            self.xUITest.executeCommand(".uno:Undo")
-            self.assertEqual(get_cell_by_position(calc_doc, 0, 0, 
0).getString(), "A")
-            self.xUITest.executeCommand(".uno:Redo")
-            self.assertEqual(get_cell_by_position(calc_doc, 0, 0, 
0).getString(), "B")
-            self.xUITest.executeCommand(".uno:Undo")
-            self.assertEqual(get_cell_by_position(calc_doc, 0, 0, 
0).getString(), "A")
-            self.xUITest.executeCommand(".uno:Redo")
-            self.assertEqual(get_cell_by_position(calc_doc, 0, 0, 
0).getString(), "B")
-            self.xUITest.executeCommand(".uno:Undo")
-            self.assertEqual(get_cell_by_position(calc_doc, 0, 0, 
0).getString(), "A")
-            self.xUITest.executeCommand(".uno:Redo")
-            self.assertEqual(get_cell_by_position(calc_doc, 0, 0, 
0).getString(), "B")
-            self.xUITest.executeCommand(".uno:Undo")
-            self.assertEqual(get_cell_by_position(calc_doc, 0, 0, 
0).getString(), "A")
-            self.xUITest.executeCommand(".uno:Redo")
-            self.assertEqual(get_cell_by_position(calc_doc, 0, 0, 
0).getString(), "B")
-            self.xUITest.executeCommand(".uno:Undo")
-            self.assertEqual(get_cell_by_position(calc_doc, 0, 0, 
0).getString(), "A")
-
-            #select row 1 and 2
-            gridwin.executeAction("SELECT", mkPropertyValues({"RANGE": 
"A1:A2"}))
-            self.xUITest.executeCommand(".uno:SelectRow")
-            #delete row 1
-            self.xUITest.executeCommand(".uno:DeleteRows")
-            #A1 should be ""
-            self.assertEqual(get_cell_by_position(calc_doc, 0, 0, 
0).getString(), "")
-            #- Undo-redo deletion a few times.
-            self.xUITest.executeCommand(".uno:Undo")
-            self.assertEqual(get_cell_by_position(calc_doc, 0, 0, 
0).getString(), "A")
-            self.xUITest.executeCommand(".uno:Redo")
-            self.assertEqual(get_cell_by_position(calc_doc, 0, 0, 
0).getString(), "")
-            self.xUITest.executeCommand(".uno:Undo")
-            self.assertEqual(get_cell_by_position(calc_doc, 0, 0, 
0).getString(), "A")
-            self.xUITest.executeCommand(".uno:Redo")
-            self.assertEqual(get_cell_by_position(calc_doc, 0, 0, 
0).getString(), "")
-            self.xUITest.executeCommand(".uno:Undo")
-            self.assertEqual(get_cell_by_position(calc_doc, 0, 0, 
0).getString(), "A")
-            self.xUITest.executeCommand(".uno:Redo")
-            self.assertEqual(get_cell_by_position(calc_doc, 0, 0, 
0).getString(), "")
-            self.xUITest.executeCommand(".uno:Undo")
-            self.assertEqual(get_cell_by_position(calc_doc, 0, 0, 
0).getString(), "A")
-            self.xUITest.executeCommand(".uno:Redo")
-            self.assertEqual(get_cell_by_position(calc_doc, 0, 0, 
0).getString(), "")
-            self.xUITest.executeCommand(".uno:Undo")
-            self.assertEqual(get_cell_by_position(calc_doc, 0, 0, 
0).getString(), "A")
-            self.xUITest.executeCommand(".uno:Redo")
-            self.assertEqual(get_cell_by_position(calc_doc, 0, 0, 
0).getString(), "")
-
-# vim: set shiftwidth=4 softtabstop=4 expandtab:
diff --git a/sc/qa/uitest/data/comments.ods b/sc/qa/uitest/data/comments.ods
deleted file mode 100644
index 9f1e13e35673..000000000000
Binary files a/sc/qa/uitest/data/comments.ods and /dev/null differ
diff --git a/sc/qa/unit/uicalc/uicalc.cxx b/sc/qa/unit/uicalc/uicalc.cxx
index 682a2d13ab81..40c469134930 100644
--- a/sc/qa/unit/uicalc/uicalc.cxx
+++ b/sc/qa/unit/uicalc/uicalc.cxx
@@ -213,6 +213,90 @@ CPPUNIT_TEST_FIXTURE(ScUiCalcTest, testTdf126577)
     }
 }
 
+CPPUNIT_TEST_FIXTURE(ScUiCalcTest, testTdf107869)
+{
+    // Without the fix in place, this test would have crashed
+    mxComponent = loadFromDesktop("private:factory/scalc");
+    ScModelObj* pModelObj = dynamic_cast<ScModelObj*>(mxComponent.get());
+    CPPUNIT_ASSERT(pModelObj);
+    ScDocument* pDoc = pModelObj->GetDocument();
+    CPPUNIT_ASSERT(pDoc);
+
+    insertStringToCell(*pModelObj, "A1", "A");
+    insertStringToCell(*pModelObj, "A2", "B");
+
+    // Add a new comment to A1 and A2
+    uno::Sequence<beans::PropertyValue> aArgs
+        = comphelper::InitPropertySequence({ { "Text", 
uno::makeAny(OUString("Comment")) } });
+
+    goToCell("A1");
+    dispatchCommand(mxComponent, ".uno:InsertAnnotation", aArgs);
+    Scheduler::ProcessEventsToIdle();
+
+    goToCell("A2");
+    dispatchCommand(mxComponent, ".uno:InsertAnnotation", aArgs);
+    Scheduler::ProcessEventsToIdle();
+
+    CPPUNIT_ASSERT_MESSAGE("There should be a note on A1", 
pDoc->HasNote(ScAddress(0, 0, 0)));
+    CPPUNIT_ASSERT_MESSAGE("There should be a note on A2", 
pDoc->HasNote(ScAddress(0, 1, 0)));
+
+    goToCell("A1");
+
+    dispatchCommand(mxComponent, ".uno:SelectRow", {});
+    Scheduler::ProcessEventsToIdle();
+
+    dispatchCommand(mxComponent, ".uno:DeleteRows", {});
+    Scheduler::ProcessEventsToIdle();
+
+    for (size_t i = 0; i < 10; ++i)
+    {
+        CPPUNIT_ASSERT_EQUAL(OUString("B"), pDoc->GetString(ScAddress(0, 0, 
0)));
+        CPPUNIT_ASSERT_MESSAGE("There should be a note on A1", 
pDoc->HasNote(ScAddress(0, 0, 0)));
+        CPPUNIT_ASSERT_MESSAGE("There should be no note on A2", 
!pDoc->HasNote(ScAddress(0, 1, 0)));
+
+        dispatchCommand(mxComponent, ".uno:Undo", {});
+        Scheduler::ProcessEventsToIdle();
+
+        CPPUNIT_ASSERT_EQUAL(OUString("A"), pDoc->GetString(ScAddress(0, 0, 
0)));
+        CPPUNIT_ASSERT_EQUAL(OUString("B"), pDoc->GetString(ScAddress(0, 1, 
0)));
+        CPPUNIT_ASSERT_MESSAGE("There should be a note on A1", 
pDoc->HasNote(ScAddress(0, 0, 0)));
+        CPPUNIT_ASSERT_MESSAGE("There should be a note on A2", 
pDoc->HasNote(ScAddress(0, 1, 0)));
+
+        dispatchCommand(mxComponent, ".uno:Redo", {});
+        Scheduler::ProcessEventsToIdle();
+    }
+
+    dispatchCommand(mxComponent, ".uno:Undo", {});
+    Scheduler::ProcessEventsToIdle();
+
+    goToCell("A1:A2");
+
+    dispatchCommand(mxComponent, ".uno:SelectRow", {});
+    Scheduler::ProcessEventsToIdle();
+
+    dispatchCommand(mxComponent, ".uno:DeleteRows", {});
+    Scheduler::ProcessEventsToIdle();
+
+    for (size_t i = 0; i < 10; ++i)
+    {
+        CPPUNIT_ASSERT_EQUAL(OUString(""), pDoc->GetString(ScAddress(0, 0, 
0)));
+        CPPUNIT_ASSERT_EQUAL(OUString(""), pDoc->GetString(ScAddress(0, 1, 
0)));
+        CPPUNIT_ASSERT_MESSAGE("There should be no note on A1", 
!pDoc->HasNote(ScAddress(0, 0, 0)));
+        CPPUNIT_ASSERT_MESSAGE("There should be no note on A2", 
!pDoc->HasNote(ScAddress(0, 1, 0)));
+
+        dispatchCommand(mxComponent, ".uno:Undo", {});
+        Scheduler::ProcessEventsToIdle();
+
+        CPPUNIT_ASSERT_EQUAL(OUString("A"), pDoc->GetString(ScAddress(0, 0, 
0)));
+        CPPUNIT_ASSERT_EQUAL(OUString("B"), pDoc->GetString(ScAddress(0, 1, 
0)));
+        CPPUNIT_ASSERT_MESSAGE("There should be a note on A1", 
pDoc->HasNote(ScAddress(0, 0, 0)));
+        CPPUNIT_ASSERT_MESSAGE("There should be a note on A2", 
pDoc->HasNote(ScAddress(0, 1, 0)));
+
+        dispatchCommand(mxComponent, ".uno:Redo", {});
+        Scheduler::ProcessEventsToIdle();
+    }
+}
+
 CPPUNIT_TEST_FIXTURE(ScUiCalcTest, testTdf63805)
 {
     mxComponent = loadFromDesktop("private:factory/scalc");

Reply via email to