sc/qa/uitest/calc_tests7/tdf124818.py |   28 ----------------------------
 sc/qa/unit/uicalc/uicalc.cxx          |   30 ++++++++++++++++++++++++++++++
 2 files changed, 30 insertions(+), 28 deletions(-)

New commits:
commit bebf2433ba1b7797bddddb06bdeec7975250181c
Author:     Xisco Fauli <xiscofa...@libreoffice.org>
AuthorDate: Fri Feb 18 18:48:31 2022 +0100
Commit:     Xisco Fauli <xiscofa...@libreoffice.org>
CommitDate: Fri Feb 18 20:20:29 2022 +0100

    tdf#124818: sc: move UItest to CppUnittest
    
    The original UItest is just wrong. The report talks about
    Select all - Cut - Undo and no cut and not undo is done there
    
    Change-Id: I53b925f86aa01fd4f161ec3180b2d7471baff09f
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/130172
    Tested-by: Jenkins
    Reviewed-by: Xisco Fauli <xiscofa...@libreoffice.org>

diff --git a/sc/qa/uitest/calc_tests7/tdf124818.py 
b/sc/qa/uitest/calc_tests7/tdf124818.py
deleted file mode 100644
index 1b131288313c..000000000000
--- a/sc/qa/uitest/calc_tests7/tdf124818.py
+++ /dev/null
@@ -1,28 +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
-
-#Bug 124818 - CRASH: selecting all and switching spreadsheet
-
-class tdf124818(UITestCase):
-   def test_tdf124818_crash_select_all_and_switch_spreadsheet(self):
-    with self.ui_test.load_file(get_url_for_data_file("tdf124818.xls")) as 
calc_doc:
-        xCalcDoc = self.xUITest.getTopFocusWindow()
-        gridwin = xCalcDoc.getChild("grid_window")
-
-        #Select all ( Ctrl + A );Go to sheet Graph2;Select all;Crash
-        self.xUITest.executeCommand(".uno:SelectAll")
-        self.xUITest.executeCommand(".uno:JumpToPrevTable")
-        self.xUITest.executeCommand(".uno:SelectAll")
-
-        #verify; no crashes
-        self.assertEqual(calc_doc.Sheets.getCount(), 3)
-
-# vim: set shiftwidth=4 softtabstop=4 expandtab:
diff --git a/sc/qa/uitest/data/tdf124818.xls 
b/sc/qa/unit/uicalc/data/tdf124818.xls
similarity index 100%
rename from sc/qa/uitest/data/tdf124818.xls
rename to sc/qa/unit/uicalc/data/tdf124818.xls
diff --git a/sc/qa/unit/uicalc/uicalc.cxx b/sc/qa/unit/uicalc/uicalc.cxx
index 15d34995c4b2..0861d04fc4a6 100644
--- a/sc/qa/unit/uicalc/uicalc.cxx
+++ b/sc/qa/unit/uicalc/uicalc.cxx
@@ -1478,6 +1478,36 @@ CPPUNIT_TEST_FIXTURE(ScUiCalcTest, testTdf126904)
     }
 }
 
+CPPUNIT_TEST_FIXTURE(ScUiCalcTest, testTdf124818)
+{
+    ScModelObj* pModelObj = createDoc("tdf124818.xls");
+    ScDocument* pDoc = pModelObj->GetDocument();
+    CPPUNIT_ASSERT(pDoc);
+
+    CPPUNIT_ASSERT_EQUAL(sal_Int16(2), ScDocShell::GetViewData()->GetTabNo());
+
+    dispatchCommand(mxComponent, ".uno:JumpToPrevTable", {});
+
+    CPPUNIT_ASSERT_EQUAL(sal_Int16(1), ScDocShell::GetViewData()->GetTabNo());
+
+    ScDrawLayer* pDrawLayer = pDoc->GetDrawLayer();
+    SdrPage* pPage = pDrawLayer->GetPage(1);
+    CPPUNIT_ASSERT_EQUAL(static_cast<size_t>(1), pPage->GetObjCount());
+
+    dispatchCommand(mxComponent, ".uno:SelectAll", {});
+    Scheduler::ProcessEventsToIdle();
+
+    dispatchCommand(mxComponent, ".uno:Cut", {});
+    Scheduler::ProcessEventsToIdle();
+
+    CPPUNIT_ASSERT_EQUAL(static_cast<size_t>(0), pPage->GetObjCount());
+
+    dispatchCommand(mxComponent, ".uno:Undo", {});
+    Scheduler::ProcessEventsToIdle();
+
+    CPPUNIT_ASSERT_EQUAL(static_cast<size_t>(1), pPage->GetObjCount());
+}
+
 CPPUNIT_TEST_FIXTURE(ScUiCalcTest, testTdf124816)
 {
     ScModelObj* pModelObj = createDoc("tdf124816.xlsx");

Reply via email to