summaryrefslogtreecommitdiff
path: root/sd/qa/unit/tiledrendering
diff options
context:
space:
mode:
authorPranav Kant <pranavk@collabora.co.uk>2017-04-23 14:54:42 +0530
committerpranavk <pranavk@collabora.co.uk>2017-05-01 06:46:19 +0200
commitc454fbb9b62164d5f047990ae63522c9fb932086 (patch)
tree682c263be6e283fd4ad04e509548abd520595f16 /sd/qa/unit/tiledrendering
parent862b6c0a32dfce924bfafa84acaed47c5380fc46 (diff)
sd: Use unique Page ids for better multi-view support + unit test
... instead of using simple IDs which are assumed to be one greater than the slide position everywhere in the codebase. Use a 16 bit static counter and uniquely assign page ids to SdPage objects. This helps in identifying which slide was already selected in second view before any slide is deleted in the first view. Otherwise, using simple positions to keep track of it leads the second view to end up selecting the wrong slide after any slide is added or removed in the first view. Change-Id: I465cf7ea86899f0e52549062a9e5fa5cd459f978 Reviewed-on: https://gerrit.libreoffice.org/36863 Tested-by: Jenkins <ci@libreoffice.org> Reviewed-by: pranavk <pranavk@collabora.co.uk>
Diffstat (limited to 'sd/qa/unit/tiledrendering')
-rw-r--r--sd/qa/unit/tiledrendering/data/dummy.odpbin10727 -> 10763 bytes
-rw-r--r--sd/qa/unit/tiledrendering/tiledrendering.cxx52
2 files changed, 52 insertions, 0 deletions
diff --git a/sd/qa/unit/tiledrendering/data/dummy.odp b/sd/qa/unit/tiledrendering/data/dummy.odp
index 12cd67947df5..83dee413c5ed 100644
--- a/sd/qa/unit/tiledrendering/data/dummy.odp
+++ b/sd/qa/unit/tiledrendering/data/dummy.odp
Binary files differ
diff --git a/sd/qa/unit/tiledrendering/tiledrendering.cxx b/sd/qa/unit/tiledrendering/tiledrendering.cxx
index d1aeb4b4360a..08e1bc197dd6 100644
--- a/sd/qa/unit/tiledrendering/tiledrendering.cxx
+++ b/sd/qa/unit/tiledrendering/tiledrendering.cxx
@@ -44,6 +44,8 @@
#include <undo/undomanager.hxx>
#include <sfx2/request.hxx>
#include <svx/svxids.hrc>
+#include <DrawViewShell.hxx>
+#include <pres.hxx>
#include <chrono>
@@ -97,6 +99,7 @@ public:
void testTdf81754();
void testTdf105502();
void testCommentCallbacks();
+ void testMultiViewInsertDeletePage();
CPPUNIT_TEST_SUITE(SdTiledRenderingTest);
CPPUNIT_TEST(testRegisterCallback);
@@ -132,6 +135,7 @@ public:
CPPUNIT_TEST(testTdf81754);
CPPUNIT_TEST(testTdf105502);
CPPUNIT_TEST(testCommentCallbacks);
+ CPPUNIT_TEST(testMultiViewInsertDeletePage);
CPPUNIT_TEST_SUITE_END();
@@ -1708,6 +1712,54 @@ void SdTiledRenderingTest::testCommentCallbacks()
comphelper::LibreOfficeKit::setActive(false);
}
+void SdTiledRenderingTest::testMultiViewInsertDeletePage()
+{
+ // Load the document.
+ comphelper::LibreOfficeKit::setActive();
+ SdXImpressDocument* pXImpressDocument = createDoc("dummy.odp");
+ ViewCallback aView1;
+ int nView1 = SfxLokHelper::getView();
+ SfxViewShell::Current()->registerLibreOfficeKitViewCallback(&ViewCallback::callback, &aView1);
+ uno::Sequence<beans::PropertyValue> aArgs;
+ SdDrawDocument* pDoc = pXImpressDocument->GetDocShell()->GetDoc();
+
+ // Create second view
+ SfxLokHelper::createView();
+ pXImpressDocument->initializeForTiledRendering(aArgs);
+ ViewCallback aView2;
+ SfxViewShell::Current()->registerLibreOfficeKitViewCallback(&ViewCallback::callback, &aView2);
+ int nView2 = SfxLokHelper::getView();
+
+ // the document has 8 slides
+ CPPUNIT_ASSERT_EQUAL(static_cast<sal_uInt16>(8), pDoc->GetSdPageCount(PageKind::Standard));
+
+ // Switch to 5th page in 2nd view
+ pXImpressDocument->setPart(4);
+
+ // Insert slide in 1st view
+ SfxLokHelper::setView(nView1);
+ comphelper::dispatchCommand(".uno:InsertPage", aArgs);
+ Scheduler::ProcessEventsToIdle();
+
+ // See if the current slide number changed in 2nd view too
+ SfxLokHelper::setView(nView2);
+ CPPUNIT_ASSERT_EQUAL(5, pXImpressDocument->getPart());
+
+ // Delete the page in 1st view now
+ SfxLokHelper::setView(nView1);
+ comphelper::dispatchCommand(".uno:DeletePage", aArgs);
+ Scheduler::ProcessEventsToIdle();
+
+ // See if current slide number changed in 2nd view too
+ SfxLokHelper::setView(nView2);
+ CPPUNIT_ASSERT_EQUAL(4, pXImpressDocument->getPart());
+
+ mxComponent->dispose();
+ mxComponent.clear();
+
+ comphelper::LibreOfficeKit::setActive(false);
+}
+
CPPUNIT_TEST_SUITE_REGISTRATION(SdTiledRenderingTest);
CPPUNIT_PLUGIN_IMPLEMENT();