sc/qa/uitest/calc_tests4/tdf94208.py |   47 -----------------------------------
 sc/qa/unit/uicalc/uicalc.cxx         |   46 ++++++++++++++++++++++++++++++++++
 2 files changed, 46 insertions(+), 47 deletions(-)

New commits:
commit 1f5f94d153fbade9cd96f841f1084fe16815f4f3
Author:     Xisco Fauli <xiscofa...@libreoffice.org>
AuthorDate: Fri Mar 11 12:31:03 2022 +0100
Commit:     Xisco Fauli <xiscofa...@libreoffice.org>
CommitDate: Fri Mar 11 13:46:07 2022 +0100

    tdf#94208: sc: move UItest to CppUnittest
    
    The original test was incomplete and didn't fail without
    the fix in place
    
    Change-Id: I0ddec239b9cb06d90aed21be8b916f39d51a3a38
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/131367
    Tested-by: Jenkins
    Reviewed-by: Xisco Fauli <xiscofa...@libreoffice.org>

diff --git a/sc/qa/uitest/calc_tests4/tdf94208.py 
b/sc/qa/uitest/calc_tests4/tdf94208.py
deleted file mode 100644
index 7301f4664a76..000000000000
--- a/sc/qa/uitest/calc_tests4/tdf94208.py
+++ /dev/null
@@ -1,47 +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.calc import enter_text_to_cell
-from libreoffice.calc.document import get_cell_by_position
-from libreoffice.uno.propertyvalue import mkPropertyValues
-#Bug 94208 - Undo after Control-D Fill doesn't broadcast deleted 
(undo-inserted) cells for calculation
-
-class tdf94208(UITestCase):
-
-    def test_tdf94208_Undo_fill_down_rows_selected(self):
-        with self.ui_test.create_doc_in_start_center("calc") as document:
-            xCalcDoc = self.xUITest.getTopFocusWindow()
-            gridwin = xCalcDoc.getChild("grid_window")
-
-            #1 - Fill data
-            enter_text_to_cell(gridwin, "A3", "Range")
-            enter_text_to_cell(gridwin, "A4", "Range")
-            enter_text_to_cell(gridwin, "A5", "Range")
-            enter_text_to_cell(gridwin, "A6", "Range")
-            enter_text_to_cell(gridwin, "A7", "Range")
-            enter_text_to_cell(gridwin, "A8", "Range")
-            enter_text_to_cell(gridwin, "B6", "test")
-            #2 - Select rows three though eight.
-            gridwin.executeAction("SELECT", mkPropertyValues({"RANGE": 
"A3:A8"}))
-            self.xUITest.executeCommand(".uno:SelectRow")
-            #3 - type Control-D/Fill Down
-            self.xUITest.executeCommand(".uno:FillDown")
-            #4 - undo.
-            self.xUITest.executeCommand(".uno:Undo")
-            #5 -  Ouch! The data isn't right.
-            self.assertEqual(get_cell_by_position(document, 0, 0, 
2).getString(), "Range")
-            self.assertEqual(get_cell_by_position(document, 0, 0, 
3).getString(), "Range")
-            self.assertEqual(get_cell_by_position(document, 0, 0, 
4).getString(), "Range")
-            self.assertEqual(get_cell_by_position(document, 0, 0, 
5).getString(), "Range")
-            self.assertEqual(get_cell_by_position(document, 0, 0, 
6).getString(), "Range")
-            self.assertEqual(get_cell_by_position(document, 0, 0, 
6).getString(), "Range")
-            self.assertEqual(get_cell_by_position(document, 0, 1, 
5).getString(), "test")
-
-
-# vim: set shiftwidth=4 softtabstop=4 expandtab:
diff --git a/sc/qa/unit/uicalc/uicalc.cxx b/sc/qa/unit/uicalc/uicalc.cxx
index 40c469134930..56f70c19bc48 100644
--- a/sc/qa/unit/uicalc/uicalc.cxx
+++ b/sc/qa/unit/uicalc/uicalc.cxx
@@ -349,6 +349,52 @@ CPPUNIT_TEST_FIXTURE(ScUiCalcTest, testTdf63805)
     CPPUNIT_ASSERT_EQUAL(OUString(""), pDoc->GetString(ScAddress(0, 1, 0)));
 }
 
+CPPUNIT_TEST_FIXTURE(ScUiCalcTest, testTdf94208)
+{
+    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", "=COUNTA(B:B)");
+    insertStringToCell(*pModelObj, "A3", "Range");
+    insertStringToCell(*pModelObj, "A4", "Range");
+    insertStringToCell(*pModelObj, "A5", "Range");
+    insertStringToCell(*pModelObj, "A6", "Range");
+    insertStringToCell(*pModelObj, "A7", "Range");
+    insertStringToCell(*pModelObj, "A8", "Range");
+    insertStringToCell(*pModelObj, "B6", "Test");
+
+    CPPUNIT_ASSERT_EQUAL(1.0, pDoc->GetValue(ScAddress(0, 0, 0)));
+
+    goToCell("A3:A8");
+
+    dispatchCommand(mxComponent, ".uno:SelectRow", {});
+    Scheduler::ProcessEventsToIdle();
+
+    //type Control-D/Fill Down
+    dispatchCommand(mxComponent, ".uno:FillDown", {});
+    Scheduler::ProcessEventsToIdle();
+
+    CPPUNIT_ASSERT_EQUAL(0.0, pDoc->GetValue(ScAddress(0, 0, 0)));
+
+    dispatchCommand(mxComponent, ".uno:Undo", {});
+    Scheduler::ProcessEventsToIdle();
+
+    // Without the fix in place, this test would have failed with
+    // - Expected: 1
+    // - Actual  : 0
+    CPPUNIT_ASSERT_EQUAL(1.0, pDoc->GetValue(ScAddress(0, 0, 0)));
+
+    for (SCROW i = 2; i < 8; ++i)
+    {
+        CPPUNIT_ASSERT_EQUAL(OUString("Range"), pDoc->GetString(ScAddress(0, 
i, 0)));
+    }
+
+    CPPUNIT_ASSERT_EQUAL(OUString("Test"), pDoc->GetString(ScAddress(1, 5, 
0)));
+}
+
 CPPUNIT_TEST_FIXTURE(ScUiCalcTest, testTdf37623)
 {
     mxComponent = loadFromDesktop("private:factory/scalc");

Reply via email to