summaryrefslogtreecommitdiff
path: root/sd/qa/unit
diff options
context:
space:
mode:
authorMiklos Vajna <vmiklos@collabora.co.uk>2016-07-01 18:05:43 +0200
committerMiklos Vajna <vmiklos@collabora.co.uk>2016-07-21 10:21:34 +0200
commit2ca45663bf74e82fe508c2577613627741cf14f6 (patch)
tree5fb6fdaa4d21db1c4958ded2897701965b1c7850 /sd/qa/unit
parent606ad3c7961ced06a9c4278d64a7913090f03abe (diff)
svx lok: add LOK_CALLBACK_GRAPHIC_VIEW_SELECTION
So a view can be aware where the graphic selections of other views are. Change-Id: I0cc420cfe4bf3824fbfa1a58da889cac5e9a7b60 Reviewed-on: https://gerrit.libreoffice.org/26863 Reviewed-by: Miklos Vajna <vmiklos@collabora.co.uk> Tested-by: Jenkins <ci@libreoffice.org> (cherry picked from commit 3ebfc5b95559a9bcb2fc0508b51fd00e8eb20260)
Diffstat (limited to 'sd/qa/unit')
-rw-r--r--sd/qa/unit/tiledrendering/tiledrendering.cxx68
1 files changed, 68 insertions, 0 deletions
diff --git a/sd/qa/unit/tiledrendering/tiledrendering.cxx b/sd/qa/unit/tiledrendering/tiledrendering.cxx
index ab9196c0b865..316936f44d47 100644
--- a/sd/qa/unit/tiledrendering/tiledrendering.cxx
+++ b/sd/qa/unit/tiledrendering/tiledrendering.cxx
@@ -12,6 +12,7 @@
#include <test/xmltesttools.hxx>
#include <boost/property_tree/json_parser.hpp>
#include <LibreOfficeKit/LibreOfficeKitEnums.h>
+#include <sfx2/lokhelper.hxx>
#include <com/sun/star/frame/Desktop.hpp>
#include <comphelper/dispatchcommand.hxx>
#include <comphelper/processfactory.hxx>
@@ -62,6 +63,7 @@ public:
void testPartHash();
void testResizeTable();
void testResizeTableColumn();
+ void testViewCursors();
CPPUNIT_TEST_SUITE(SdTiledRenderingTest);
CPPUNIT_TEST(testRegisterCallback);
@@ -81,6 +83,7 @@ public:
CPPUNIT_TEST(testPartHash);
CPPUNIT_TEST(testResizeTable);
CPPUNIT_TEST(testResizeTableColumn);
+ CPPUNIT_TEST(testViewCursors);
CPPUNIT_TEST_SUITE_END();
private:
@@ -806,6 +809,71 @@ void SdTiledRenderingTest::testResizeTableColumn()
comphelper::LibreOfficeKit::setActive(false);
}
+class ViewCallback
+{
+public:
+ bool m_bGraphicSelectionInvalidated;
+ bool m_bGraphicViewSelectionInvalidated;
+
+ ViewCallback()
+ : m_bGraphicSelectionInvalidated(false),
+ m_bGraphicViewSelectionInvalidated(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_GRAPHIC_SELECTION:
+ {
+ m_bGraphicSelectionInvalidated = true;
+ }
+ break;
+ case LOK_CALLBACK_GRAPHIC_VIEW_SELECTION:
+ {
+ m_bGraphicViewSelectionInvalidated = true;
+ }
+ break;
+ }
+ }
+};
+
+void SdTiledRenderingTest::testViewCursors()
+{
+ comphelper::LibreOfficeKit::setActive();
+
+ // Create two views.
+ SdXImpressDocument* pXImpressDocument = createDoc("shape.odp");
+ ViewCallback aView1;
+ SfxViewShell::Current()->registerLibreOfficeKitViewCallback(&ViewCallback::callback, &aView1);
+ SfxLokHelper::createView();
+ ViewCallback aView2;
+ SfxViewShell::Current()->registerLibreOfficeKitViewCallback(&ViewCallback::callback, &aView2);
+
+ // Select the shape in the second view.
+ sd::ViewShell* pViewShell = pXImpressDocument->GetDocShell()->GetViewShell();
+ SdPage* pActualPage = pViewShell->GetActualPage();
+ SdrObject* pObject = pActualPage->GetObj(0);
+ SdrView* pView = pViewShell->GetView();
+ pView->MarkObj(pObject, pView->GetSdrPageView());
+ Scheduler::ProcessEventsToIdle();
+
+ // First view notices that there was a selection change in the other view.
+ CPPUNIT_ASSERT(aView1.m_bGraphicViewSelectionInvalidated);
+ // Second view notices that there was a selection change in its own view.
+ CPPUNIT_ASSERT(aView2.m_bGraphicSelectionInvalidated);
+ mxComponent->dispose();
+ mxComponent.clear();
+
+ comphelper::LibreOfficeKit::setActive(false);
+}
+
CPPUNIT_TEST_SUITE_REGISTRATION(SdTiledRenderingTest);
CPPUNIT_PLUGIN_IMPLEMENT();