diff options
author | Miklos Vajna <vmiklos@collabora.co.uk> | 2016-07-01 15:04:55 +0200 |
---|---|---|
committer | Miklos Vajna <vmiklos@collabora.co.uk> | 2016-07-01 14:18:27 +0000 |
commit | e3c36c789f481b855c0fb556a09f4b81401ed3db (patch) | |
tree | 23e8067dbed8bc679537ad57d2786bd938a1a8a6 | |
parent | 4961274c5b13017bc4e6904c8bdeb9c2a49566de (diff) |
sc: add LOK_CALLBACK_CELL_VIEW_CURSOR testcase
Fails with the sc/source part of commit (sc lok: add
LOK_CALLBACK_CELL_VIEW_CURSOR, 2016-07-01) reverted.
Change-Id: I4a1a7d97b744dd089fe15bd58af6cca5e0b79e8f
Reviewed-on: https://gerrit.libreoffice.org/26856
Reviewed-by: Miklos Vajna <vmiklos@collabora.co.uk>
Tested-by: Jenkins <ci@libreoffice.org>
-rw-r--r-- | sc/qa/unit/tiledrendering/tiledrendering.cxx | 66 |
1 files changed, 64 insertions, 2 deletions
diff --git a/sc/qa/unit/tiledrendering/tiledrendering.cxx b/sc/qa/unit/tiledrendering/tiledrendering.cxx index 24bbbcee8d65..ed85cd2af6bd 100644 --- a/sc/qa/unit/tiledrendering/tiledrendering.cxx +++ b/sc/qa/unit/tiledrendering/tiledrendering.cxx @@ -12,7 +12,6 @@ #include <test/xmltesttools.hxx> #include <boost/property_tree/json_parser.hpp> -#define LOK_USE_UNSTABLE_API #include <LibreOfficeKit/LibreOfficeKitEnums.h> #include <com/sun/star/frame/Desktop.hpp> #include <comphelper/dispatchcommand.hxx> @@ -28,6 +27,7 @@ #include <svl/srchitem.hxx> #include <comphelper/lok.hxx> +#include <sfx2/lokhelper.hxx> #include <tabvwsh.hxx> #include <docsh.hxx> @@ -36,7 +36,10 @@ using namespace css; -static const char* DATA_DIRECTORY = "/sc/qa/unit/tiledrendering/data/"; +namespace +{ + +const char* DATA_DIRECTORY = "/sc/qa/unit/tiledrendering/data/"; class ScTiledRenderingTest : public test::BootstrapFixture, public unotest::MacrosTest, public XmlTestTools { @@ -50,6 +53,7 @@ public: void testPartHash(); void testDocumentSize(); void testEmptyColumnSelection(); + void testViewCursors(); CPPUNIT_TEST_SUITE(ScTiledRenderingTest); CPPUNIT_TEST(testRowColumnSelections); @@ -57,6 +61,7 @@ public: CPPUNIT_TEST(testPartHash); CPPUNIT_TEST(testDocumentSize); CPPUNIT_TEST(testEmptyColumnSelection); + CPPUNIT_TEST(testViewCursors); CPPUNIT_TEST_SUITE_END(); private: @@ -347,6 +352,63 @@ void ScTiledRenderingTest::testEmptyColumnSelection() comphelper::LibreOfficeKit::setActive(false); } +class ViewCallback +{ +public: + bool m_bOwnCursorInvalidated; + bool m_bViewCursorInvalidated; + + ViewCallback() + : m_bOwnCursorInvalidated(false), + m_bViewCursorInvalidated(false) + { + } + + static void callback(int nType, const char* pPayload, void* pData) + { + static_cast<ViewCallback*>(pData)->callbackImpl(nType, pPayload); + } + + void callbackImpl(int nType, const char* /*pPayload*/) + { + switch (nType) + { + case LOK_CALLBACK_CELL_CURSOR: + { + m_bOwnCursorInvalidated = true; + } + break; + case LOK_CALLBACK_CELL_VIEW_CURSOR: + { + m_bViewCursorInvalidated = true; + } + break; + } + } +}; + + +void ScTiledRenderingTest::testViewCursors() +{ + comphelper::LibreOfficeKit::setActive(); + + ScModelObj* pModelObj = createDoc("select-row-cols.ods"); + ViewCallback aView1; + SfxViewShell::Current()->registerLibreOfficeKitViewCallback(&ViewCallback::callback, &aView1); + SfxLokHelper::createView(); + ViewCallback aView2; + SfxViewShell::Current()->registerLibreOfficeKitViewCallback(&ViewCallback::callback, &aView2); + pModelObj->postKeyEvent(LOK_KEYEVENT_KEYINPUT, 0, awt::Key::DOWN); + pModelObj->postKeyEvent(LOK_KEYEVENT_KEYUP, 0, awt::Key::DOWN); + Scheduler::ProcessEventsToIdle(); + SfxLokHelper::destroyView(SfxLokHelper::getView()); + CPPUNIT_ASSERT(aView1.m_bViewCursorInvalidated); + + comphelper::LibreOfficeKit::setActive(false); +} + +} + CPPUNIT_TEST_SUITE_REGISTRATION(ScTiledRenderingTest); CPPUNIT_PLUGIN_IMPLEMENT(); |