diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-27 16:51:28 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-27 16:51:28 +0000 |
commit | 940b4d1848e8c70ab7642901a68594e8016caffc (patch) | |
tree | eb72f344ee6c3d9b80a7ecc079ea79e9fba8676d /sc/qa/unit/uicalc | |
parent | Initial commit. (diff) | |
download | libreoffice-940b4d1848e8c70ab7642901a68594e8016caffc.tar.xz libreoffice-940b4d1848e8c70ab7642901a68594e8016caffc.zip |
Adding upstream version 1:7.0.4.upstream/1%7.0.4upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'sc/qa/unit/uicalc')
-rw-r--r-- | sc/qa/unit/uicalc/data/tdf122232.ods | bin | 0 -> 10437 bytes | |||
-rw-r--r-- | sc/qa/unit/uicalc/data/tdf124815.ods | bin | 0 -> 281687 bytes | |||
-rw-r--r-- | sc/qa/unit/uicalc/data/tdf124816.xlsx | bin | 0 -> 10247 bytes | |||
-rw-r--r-- | sc/qa/unit/uicalc/data/tdf126904.ods | bin | 0 -> 23144 bytes | |||
-rw-r--r-- | sc/qa/unit/uicalc/uicalc.cxx | 183 |
5 files changed, 183 insertions, 0 deletions
diff --git a/sc/qa/unit/uicalc/data/tdf122232.ods b/sc/qa/unit/uicalc/data/tdf122232.ods Binary files differnew file mode 100644 index 000000000..23dc98f61 --- /dev/null +++ b/sc/qa/unit/uicalc/data/tdf122232.ods diff --git a/sc/qa/unit/uicalc/data/tdf124815.ods b/sc/qa/unit/uicalc/data/tdf124815.ods Binary files differnew file mode 100644 index 000000000..8ad01f4a8 --- /dev/null +++ b/sc/qa/unit/uicalc/data/tdf124815.ods diff --git a/sc/qa/unit/uicalc/data/tdf124816.xlsx b/sc/qa/unit/uicalc/data/tdf124816.xlsx Binary files differnew file mode 100644 index 000000000..890c9de8e --- /dev/null +++ b/sc/qa/unit/uicalc/data/tdf124816.xlsx diff --git a/sc/qa/unit/uicalc/data/tdf126904.ods b/sc/qa/unit/uicalc/data/tdf126904.ods Binary files differnew file mode 100644 index 000000000..0f2cf0513 --- /dev/null +++ b/sc/qa/unit/uicalc/data/tdf126904.ods diff --git a/sc/qa/unit/uicalc/uicalc.cxx b/sc/qa/unit/uicalc/uicalc.cxx new file mode 100644 index 000000000..b68c5e6cd --- /dev/null +++ b/sc/qa/unit/uicalc/uicalc.cxx @@ -0,0 +1,183 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-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/. + */ + +#include <test/bootstrapfixture.hxx> +#include <unotest/macros_test.hxx> +#include <LibreOfficeKit/LibreOfficeKitEnums.h> +#include <vcl/scheduler.hxx> + +#include <comphelper/processfactory.hxx> +#include <com/sun/star/frame/Desktop.hpp> +#include <document.hxx> +#include <docuno.hxx> +#include <tabvwsh.hxx> + +using namespace ::com::sun::star; + +class ScUiCalcTest : public test::BootstrapFixture, public unotest::MacrosTest +{ +public: + virtual void setUp() override; + + virtual void tearDown() override; + + ScModelObj* createDoc(const char* pName); + void checkCurrentCell(SCCOL nCol, SCROW nRow); + +protected: + uno::Reference<lang::XComponent> mxComponent; +}; + +void ScUiCalcTest::setUp() +{ + test::BootstrapFixture::setUp(); + + mxDesktop.set(frame::Desktop::create(mxComponentContext)); +} + +void ScUiCalcTest::tearDown() +{ + if (mxComponent.is()) + mxComponent->dispose(); + + test::BootstrapFixture::tearDown(); +} + +void ScUiCalcTest::checkCurrentCell(SCCOL nCol, SCROW nRow) +{ + CPPUNIT_ASSERT_EQUAL(sal_Int16(nCol), ScDocShell::GetViewData()->GetCurX()); + CPPUNIT_ASSERT_EQUAL(sal_Int32(nRow), ScDocShell::GetViewData()->GetCurY()); +} + +char const DATA_DIRECTORY[] = "/sc/qa/unit/uicalc/data/"; + +ScModelObj* ScUiCalcTest::createDoc(const char* pName) +{ + if (mxComponent.is()) + mxComponent->dispose(); + mxComponent = loadFromDesktop(m_directories.getURLFromSrc(DATA_DIRECTORY) + + OUString::createFromAscii(pName), + "com.sun.star.sheet.SpreadsheetDocument"); + ScModelObj* pModelObj = dynamic_cast<ScModelObj*>(mxComponent.get()); + CPPUNIT_ASSERT(pModelObj); + return pModelObj; +} + +CPPUNIT_TEST_FIXTURE(ScUiCalcTest, testTdf122232) +{ + ScModelObj* pModelObj = createDoc("tdf122232.ods"); + ScDocument* pDoc = pModelObj->GetDocument(); + CPPUNIT_ASSERT(pDoc); + + //Start with from C6. Press tabulator to reach G6. + checkCurrentCell(2, 5); + + pModelObj->postKeyEvent(LOK_KEYEVENT_KEYINPUT, 0, KEY_TAB); + pModelObj->postKeyEvent(LOK_KEYEVENT_KEYINPUT, 0, KEY_TAB); + Scheduler::ProcessEventsToIdle(); + checkCurrentCell(6, 5); + + //without the fix, cursor would jump to C29 instead of C7. + pModelObj->postKeyEvent(LOK_KEYEVENT_KEYINPUT, 0, awt::Key::RETURN); + Scheduler::ProcessEventsToIdle(); + checkCurrentCell(2, 6); +} + +CPPUNIT_TEST_FIXTURE(ScUiCalcTest, testTdf126904) +{ + ScModelObj* pModelObj = createDoc("tdf126904.ods"); + ScDocument* pDoc = pModelObj->GetDocument(); + CPPUNIT_ASSERT(pDoc); + + checkCurrentCell(0, 4); + dispatchCommand(mxComponent, ".uno:GoRight", {}); + checkCurrentCell(1, 4); + dispatchCommand(mxComponent, ".uno:GoRight", {}); + checkCurrentCell(4, 4); + dispatchCommand(mxComponent, ".uno:GoRight", {}); + checkCurrentCell(5, 4); + dispatchCommand(mxComponent, ".uno:GoRight", {}); + checkCurrentCell(8, 4); + dispatchCommand(mxComponent, ".uno:GoRight", {}); + checkCurrentCell(9, 4); + dispatchCommand(mxComponent, ".uno:GoRight", {}); + checkCurrentCell(12, 4); + + //Cursor can't move forward to the right + for (size_t i = 0; i < 5; ++i) + { + dispatchCommand(mxComponent, ".uno:GoRight", {}); + checkCurrentCell(13, 4); + } +} + +CPPUNIT_TEST_FIXTURE(ScUiCalcTest, testTdf124816) +{ + ScModelObj* pModelObj = createDoc("tdf124816.xlsx"); + ScDocument* pDoc = pModelObj->GetDocument(); + CPPUNIT_ASSERT(pDoc); + + // The actual result is completely unrelated to this test and behaviour of + // OFFSET() was changed as of tdf#85551 and here result of that test + // document is now Err:502 instead of 0. + const OUString aExpectedResult("Err:502"); + checkCurrentCell(3, 9); + CPPUNIT_ASSERT_EQUAL(aExpectedResult, pDoc->GetString(ScAddress(3, 9, 0))); + + //Without the fix, it would crash + dispatchCommand(mxComponent, ".uno:InsertRowsBefore", {}); + CPPUNIT_ASSERT_EQUAL(OUString(""), pDoc->GetString(ScAddress(3, 9, 0))); + dispatchCommand(mxComponent, ".uno:Undo", {}); + CPPUNIT_ASSERT_EQUAL(aExpectedResult, pDoc->GetString(ScAddress(3, 9, 0))); +} + +CPPUNIT_TEST_FIXTURE(ScUiCalcTest, testTdf124815) +{ + ScModelObj* pModelObj = createDoc("tdf124815.ods"); + ScDocument* pDoc = pModelObj->GetDocument(); + CPPUNIT_ASSERT(pDoc); + + checkCurrentCell(0, 0); + CPPUNIT_ASSERT_EQUAL(OUString("Rakennukset"), pDoc->GetString(ScAddress(2, 0, 0))); + + //Without the fix, it would crash + dispatchCommand(mxComponent, ".uno:InsertColumnsBefore", {}); + CPPUNIT_ASSERT_EQUAL(OUString("Rakennukset"), pDoc->GetString(ScAddress(3, 0, 0))); + dispatchCommand(mxComponent, ".uno:Undo", {}); + CPPUNIT_ASSERT_EQUAL(OUString("Rakennukset"), pDoc->GetString(ScAddress(2, 0, 0))); +} + +CPPUNIT_TEST_FIXTURE(ScUiCalcTest, testTdf83901) +{ + mxComponent = loadFromDesktop("private:factory/scalc"); + ScModelObj* pModelObj = dynamic_cast<ScModelObj*>(mxComponent.get()); + CPPUNIT_ASSERT(pModelObj); + ScDocument* pDoc = pModelObj->GetDocument(); + CPPUNIT_ASSERT(pDoc); + + checkCurrentCell(0, 0); + pDoc->SetString(ScAddress(0, 1, 0), "=ROW(A3)"); + CPPUNIT_ASSERT_EQUAL(3.0, pDoc->GetValue(ScAddress(0, 1, 0))); + + dispatchCommand(mxComponent, ".uno:GoDown", {}); + dispatchCommand(mxComponent, ".uno:GoDown", {}); + checkCurrentCell(0, 2); + dispatchCommand(mxComponent, ".uno:SelectRow", {}); + dispatchCommand(mxComponent, ".uno:InsertRowsBefore", {}); + + //Without the fix, it would be 3.0 + CPPUNIT_ASSERT_EQUAL(4.0, pDoc->GetValue(ScAddress(0, 1, 0))); + + dispatchCommand(mxComponent, ".uno:Undo", {}); + CPPUNIT_ASSERT_EQUAL(3.0, pDoc->GetValue(ScAddress(0, 1, 0))); +} + +CPPUNIT_PLUGIN_IMPLEMENT(); + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ |