sc/qa/uitest/calc_tests3/tdf81351.py |   77 -----------------------------------
 sc/qa/unit/uicalc/uicalc.cxx         |   76 ++++++++++++++++++++++++++++++++++
 2 files changed, 76 insertions(+), 77 deletions(-)

New commits:
commit 4e6f0f39854e2a0e6c3ea6e9f5d80b2c9dcab3c6
Author:     diwanshu885 <dmittal...@gmail.com>
AuthorDate: Sat Jan 9 01:14:44 2021 +0530
Commit:     Xisco Fauli <xiscofa...@libreoffice.org>
CommitDate: Thu Jan 21 09:31:18 2021 +0100

    tdf#131407: Move UITest to Cppunit
    
    Change-Id: Ib3afe3ac26a348f47aa566e7b2e7986c42112a0f
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/108991
    Tested-by: Jenkins
    Reviewed-by: Xisco Fauli <xiscofa...@libreoffice.org>

diff --git a/sc/qa/uitest/calc_tests3/tdf81351.py 
b/sc/qa/uitest/calc_tests3/tdf81351.py
deleted file mode 100644
index afe320559871..000000000000
--- a/sc/qa/uitest/calc_tests3/tdf81351.py
+++ /dev/null
@@ -1,77 +0,0 @@
-# -*- tab-width: 4; indent-tabs-mode: nil; py-indent-offset: 4 -*-
-#
-# 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 libreoffice.uno.propertyvalue import mkPropertyValues
-
-from uitest.framework import UITestCase
-from libreoffice.calc.document import get_column
-from libreoffice.calc.document import get_cell_by_position
-from uitest.uihelper.common import get_url_for_data_file
-
-class tdf81351(UITestCase):
-
-    def test_tdf81351(self):
-        calc_doc = 
self.ui_test.load_file(get_url_for_data_file("tdf81351.ods"))
-        xTopWindow = self.xUITest.getTopFocusWindow()
-        document = self.ui_test.get_component()
-        gridwin = xTopWindow.getChild("grid_window")
-
-        self.assertEqual(get_cell_by_position(document, 0, 0, 1).getString(), 
".uno:Paste")
-
-        gridwin.executeAction("SELECT", mkPropertyValues({"RANGE": "A1:F5"}))
-
-        self.xUITest.executeCommand(".uno:SortAscending")
-
-        gridwin.executeAction("SELECT", mkPropertyValues({"CELL": "B7"}))
-        self.assertEqual(get_cell_by_position(document, 0, 0, 1).getString(), 
".uno:Bold")
-
-        self.xUITest.executeCommand(".uno:Undo")
-        self.assertEqual(get_cell_by_position(document, 0, 0, 1).getString(), 
".uno:Paste")
-
-        gridwin.executeAction("SELECT", mkPropertyValues({"CELL": "B7"}))
-
-    def test_tdf81351_comment4(self):
-        calc_doc = 
self.ui_test.load_file(get_url_for_data_file("tdf81351.ods"))
-        xTopWindow = self.xUITest.getTopFocusWindow()
-        document = self.ui_test.get_component()
-
-        gridwin = xTopWindow.getChild("grid_window")
-        gridwin.executeAction("SELECT", mkPropertyValues({"RANGE": "A1:F5"}))
-
-
-        self.xUITest.executeCommand(".uno:SortAscending")
-        self.assertEqual(get_cell_by_position(document, 0, 0, 1).getString(), 
".uno:Bold")
-
-        gridwin.executeAction("SELECT", mkPropertyValues({"CELL": "B7"}))
-
-        self.xUITest.executeCommand(".uno:Undo")
-        self.assertEqual(get_cell_by_position(document, 0, 0, 1).getString(), 
".uno:Paste")
-
-        self.xUITest.executeCommand(".uno:Redo")
-        self.assertEqual(get_cell_by_position(document, 0, 0, 1).getString(), 
".uno:Bold")
-
-    def test_sort_descending(self):
-        calc_doc = 
self.ui_test.load_file(get_url_for_data_file("tdf81351.ods"))
-        xTopWindow = self.xUITest.getTopFocusWindow()
-        document = self.ui_test.get_component()
-
-        gridwin = xTopWindow.getChild("grid_window")
-        gridwin.executeAction("SELECT", mkPropertyValues({"RANGE": "A1:F5"}))
-
-        self.xUITest.executeCommand(".uno:SortDescending")
-        self.assertEqual(get_cell_by_position(document, 0, 0, 1).getString(), 
".uno:Undo")
-
-        gridwin.executeAction("SELECT", mkPropertyValues({"CELL": "B7"}))
-
-        self.xUITest.executeCommand(".uno:Undo")
-        self.assertEqual(get_cell_by_position(document, 0, 0, 1).getString(), 
".uno:Paste")
-
-        self.xUITest.executeCommand(".uno:Redo")
-        self.assertEqual(get_cell_by_position(document, 0, 0, 1).getString(), 
".uno:Undo")
-
-        self.ui_test.close_doc()
-# vim: set shiftwidth=4 softtabstop=4 expandtab:
diff --git a/sc/qa/uitest/data/tdf81351.ods 
b/sc/qa/unit/uicalc/data/tdf81351.ods
similarity index 100%
rename from sc/qa/uitest/data/tdf81351.ods
rename to sc/qa/unit/uicalc/data/tdf81351.ods
diff --git a/sc/qa/unit/uicalc/uicalc.cxx b/sc/qa/unit/uicalc/uicalc.cxx
index 94881e92b72f..b99c1496087d 100644
--- a/sc/qa/unit/uicalc/uicalc.cxx
+++ b/sc/qa/unit/uicalc/uicalc.cxx
@@ -553,6 +553,82 @@ CPPUNIT_TEST_FIXTURE(ScUiCalcTest, testTdf71339)
     CPPUNIT_ASSERT_EQUAL(OUString("=SUM(A1:A3)"), aFormula);
 }
 
+CPPUNIT_TEST_FIXTURE(ScUiCalcTest, testTdf81351)
+{
+    ScModelObj* pModelObj = createDoc("tdf81351.ods");
+    CPPUNIT_ASSERT(pModelObj);
+    ScDocument* pDoc = pModelObj->GetDocument();
+    CPPUNIT_ASSERT(pDoc);
+
+    CPPUNIT_ASSERT_EQUAL(OUString(".uno:Paste"), pDoc->GetString(ScAddress(0, 
1, 0)));
+    CPPUNIT_ASSERT_EQUAL(OUString(".uno:Bold"), pDoc->GetString(ScAddress(0, 
2, 0)));
+    CPPUNIT_ASSERT_EQUAL(OUString(".uno:Save"), pDoc->GetString(ScAddress(0, 
3, 0)));
+    CPPUNIT_ASSERT_EQUAL(OUString(".uno:Undo"), pDoc->GetString(ScAddress(0, 
4, 0)));
+
+    // Go to A1 before selecting A1:F5
+    ScDocShell::GetViewData()->SetCurX(0);
+    ScDocShell::GetViewData()->SetCurY(0);
+    checkCurrentCell(0, 0);
+
+    ScRange aMatRange(0, 0, 0, 5, 4, 0);
+    ScDocShell::GetViewData()->GetMarkData().SetMarkArea(aMatRange);
+
+    dispatchCommand(mxComponent, ".uno:SortAscending", {});
+    dispatchCommand(mxComponent, ".uno:GoDown", {});
+
+    // Without the fix in place, this test would have crashed
+    CPPUNIT_ASSERT_EQUAL(OUString(".uno:Bold"), pDoc->GetString(ScAddress(0, 
1, 0)));
+    CPPUNIT_ASSERT_EQUAL(OUString(".uno:Paste"), pDoc->GetString(ScAddress(0, 
2, 0)));
+    CPPUNIT_ASSERT_EQUAL(OUString(".uno:Save"), pDoc->GetString(ScAddress(0, 
3, 0)));
+    CPPUNIT_ASSERT_EQUAL(OUString(".uno:Undo"), pDoc->GetString(ScAddress(0, 
4, 0)));
+
+    dispatchCommand(mxComponent, ".uno:Undo", {});
+
+    CPPUNIT_ASSERT_EQUAL(OUString(".uno:Paste"), pDoc->GetString(ScAddress(0, 
1, 0)));
+    CPPUNIT_ASSERT_EQUAL(OUString(".uno:Bold"), pDoc->GetString(ScAddress(0, 
2, 0)));
+    CPPUNIT_ASSERT_EQUAL(OUString(".uno:Save"), pDoc->GetString(ScAddress(0, 
3, 0)));
+    CPPUNIT_ASSERT_EQUAL(OUString(".uno:Undo"), pDoc->GetString(ScAddress(0, 
4, 0)));
+
+    dispatchCommand(mxComponent, ".uno:Redo", {});
+
+    CPPUNIT_ASSERT_EQUAL(OUString(".uno:Bold"), pDoc->GetString(ScAddress(0, 
1, 0)));
+    CPPUNIT_ASSERT_EQUAL(OUString(".uno:Paste"), pDoc->GetString(ScAddress(0, 
2, 0)));
+    CPPUNIT_ASSERT_EQUAL(OUString(".uno:Save"), pDoc->GetString(ScAddress(0, 
3, 0)));
+    CPPUNIT_ASSERT_EQUAL(OUString(".uno:Undo"), pDoc->GetString(ScAddress(0, 
4, 0)));
+
+    dispatchCommand(mxComponent, ".uno:Undo", {});
+
+    CPPUNIT_ASSERT_EQUAL(OUString(".uno:Paste"), pDoc->GetString(ScAddress(0, 
1, 0)));
+    CPPUNIT_ASSERT_EQUAL(OUString(".uno:Bold"), pDoc->GetString(ScAddress(0, 
2, 0)));
+    CPPUNIT_ASSERT_EQUAL(OUString(".uno:Save"), pDoc->GetString(ScAddress(0, 
3, 0)));
+    CPPUNIT_ASSERT_EQUAL(OUString(".uno:Undo"), pDoc->GetString(ScAddress(0, 
4, 0)));
+
+    ScDocShell::GetViewData()->GetMarkData().SetMarkArea(aMatRange);
+
+    dispatchCommand(mxComponent, ".uno:SortDescending", {});
+    dispatchCommand(mxComponent, ".uno:GoDown", {});
+
+    // Without the fix in place, this test would have crashed
+    CPPUNIT_ASSERT_EQUAL(OUString(".uno:Undo"), pDoc->GetString(ScAddress(0, 
1, 0)));
+    CPPUNIT_ASSERT_EQUAL(OUString(".uno:Save"), pDoc->GetString(ScAddress(0, 
2, 0)));
+    CPPUNIT_ASSERT_EQUAL(OUString(".uno:Paste"), pDoc->GetString(ScAddress(0, 
3, 0)));
+    CPPUNIT_ASSERT_EQUAL(OUString(".uno:Bold"), pDoc->GetString(ScAddress(0, 
4, 0)));
+
+    dispatchCommand(mxComponent, ".uno:Undo", {});
+
+    CPPUNIT_ASSERT_EQUAL(OUString(".uno:Paste"), pDoc->GetString(ScAddress(0, 
1, 0)));
+    CPPUNIT_ASSERT_EQUAL(OUString(".uno:Bold"), pDoc->GetString(ScAddress(0, 
2, 0)));
+    CPPUNIT_ASSERT_EQUAL(OUString(".uno:Save"), pDoc->GetString(ScAddress(0, 
3, 0)));
+    CPPUNIT_ASSERT_EQUAL(OUString(".uno:Undo"), pDoc->GetString(ScAddress(0, 
4, 0)));
+
+    dispatchCommand(mxComponent, ".uno:Redo", {});
+
+    CPPUNIT_ASSERT_EQUAL(OUString(".uno:Undo"), pDoc->GetString(ScAddress(0, 
1, 0)));
+    CPPUNIT_ASSERT_EQUAL(OUString(".uno:Save"), pDoc->GetString(ScAddress(0, 
2, 0)));
+    CPPUNIT_ASSERT_EQUAL(OUString(".uno:Paste"), pDoc->GetString(ScAddress(0, 
3, 0)));
+    CPPUNIT_ASSERT_EQUAL(OUString(".uno:Bold"), pDoc->GetString(ScAddress(0, 
4, 0)));
+}
+
 CPPUNIT_PLUGIN_IMPLEMENT();
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
_______________________________________________
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits

Reply via email to