diff options
author | Xisco Fauli <xiscofauli@libreoffice.org> | 2020-03-09 18:14:54 +0100 |
---|---|---|
committer | Xisco Faulí <xiscofauli@libreoffice.org> | 2020-03-10 10:40:20 +0100 |
commit | bfee21b6c87c420e0c5d3447b13e013592a30c22 (patch) | |
tree | 241f0790ea0631b81f7fb4a13bb01f91d0098104 /sc/qa/unit | |
parent | bd7f647b16ca2c5f9ef7d4b0945201c4f2ecebad (diff) |
tdf#122232: move UItest to CppunitTest
Change-Id: I6cb9019fea4b1be5af94dcc8811a4f96fc1b6d37
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/90238
Tested-by: Jenkins
Reviewed-by: Xisco Faulí <xiscofauli@libreoffice.org>
Diffstat (limited to 'sc/qa/unit')
-rw-r--r-- | sc/qa/unit/uicalc/data/tdf122232.ods | bin | 0 -> 10437 bytes | |||
-rw-r--r-- | sc/qa/unit/uicalc/uicalc.cxx | 92 |
2 files changed, 92 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 000000000000..23dc98f61308 --- /dev/null +++ b/sc/qa/unit/uicalc/data/tdf122232.ods diff --git a/sc/qa/unit/uicalc/uicalc.cxx b/sc/qa/unit/uicalc/uicalc.cxx new file mode 100644 index 000000000000..3dfcade9de98 --- /dev/null +++ b/sc/qa/unit/uicalc/uicalc.cxx @@ -0,0 +1,92 @@ +/* -*- 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); + +private: + 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(); +} + +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. + CPPUNIT_ASSERT_EQUAL(sal_Int16(2), ScDocShell::GetViewData()->GetCurX()); + CPPUNIT_ASSERT_EQUAL(sal_Int32(5), ScDocShell::GetViewData()->GetCurY()); + + pModelObj->postKeyEvent(LOK_KEYEVENT_KEYINPUT, 0, KEY_TAB); + pModelObj->postKeyEvent(LOK_KEYEVENT_KEYINPUT, 0, KEY_TAB); + Scheduler::ProcessEventsToIdle(); + + CPPUNIT_ASSERT_EQUAL(sal_Int16(6), ScDocShell::GetViewData()->GetCurX()); + CPPUNIT_ASSERT_EQUAL(sal_Int32(5), ScDocShell::GetViewData()->GetCurY()); + + //without the fix, cursor would jump to C29 instead of C7. + pModelObj->postKeyEvent(LOK_KEYEVENT_KEYINPUT, 0, awt::Key::RETURN); + Scheduler::ProcessEventsToIdle(); + + CPPUNIT_ASSERT_EQUAL(sal_Int16(2), ScDocShell::GetViewData()->GetCurX()); + CPPUNIT_ASSERT_EQUAL(sal_Int32(6), ScDocShell::GetViewData()->GetCurY()); +} + +CPPUNIT_PLUGIN_IMPLEMENT(); + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ |