summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMiklos Vajna <vmiklos@collabora.co.uk>2016-07-01 15:04:55 +0200
committerMiklos Vajna <vmiklos@collabora.co.uk>2016-07-20 18:06:41 +0200
commitaac2c25b2396e8df3fd6ae072c22dbe57d1cd33d (patch)
treee8fb55c9218e1a1f764770b9c230c655b56ebfaa
parentebdab327c911e84ca4325d3216cd3a0cd204dff6 (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. Reviewed-on: https://gerrit.libreoffice.org/26856 Reviewed-by: Miklos Vajna <vmiklos@collabora.co.uk> Tested-by: Jenkins <ci@libreoffice.org> (cherry picked from commit e3c36c789f481b855c0fb556a09f4b81401ed3db) Conflicts: sc/qa/unit/tiledrendering/tiledrendering.cxx Change-Id: I4a1a7d97b744dd089fe15bd58af6cca5e0b79e8f
-rw-r--r--sc/qa/unit/tiledrendering/tiledrendering.cxx66
1 files changed, 64 insertions, 2 deletions
diff --git a/sc/qa/unit/tiledrendering/tiledrendering.cxx b/sc/qa/unit/tiledrendering/tiledrendering.cxx
index a5fe1ab63845..46b85e6801d7 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
{
@@ -49,12 +52,14 @@ public:
void testSortAscendingDescending();
void testPartHash();
void testDocumentSize();
+ void testViewCursors();
CPPUNIT_TEST_SUITE(ScTiledRenderingTest);
CPPUNIT_TEST(testRowColumnSelections);
CPPUNIT_TEST(testSortAscendingDescending);
CPPUNIT_TEST(testPartHash);
CPPUNIT_TEST(testDocumentSize);
+ CPPUNIT_TEST(testViewCursors);
CPPUNIT_TEST_SUITE_END();
private:
@@ -325,6 +330,63 @@ void ScTiledRenderingTest::testDocumentSize()
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();