summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMiklos Vajna <vmiklos@collabora.co.uk>2015-05-29 12:05:32 +0200
committerMiklos Vajna <vmiklos@collabora.co.uk>2015-06-03 09:41:09 +0200
commitadcbe2fea4799764f467b75b455015698d2aac55 (patch)
tree8e608648ed140f1fee7650005891484b7a4ee2bc
parentf25e4aff17aa88b0620b9067f3f4f490f36ca9f6 (diff)
LOK: add DOCUMENT_SIZE_CHANGED testcase
This failed without the SwViewShell::SizeChgNotify() hunk of commit 63a40c45018ad2e6f4a660a520a5907beb1d7801 (LOK: change PAGE_COUNT to a more generic DOCUMENT_SIZE, 2015-05-27). Change-Id: Id230420f60d1a6f3caf822f7e23ffca010919196 (cherry picked from commit 560c3fdca41843c29ea33c1e9c14429537f4e4b6)
-rw-r--r--sw/qa/extras/tiledrendering/data/2-pages.odtbin0 -> 8596 bytes
-rw-r--r--sw/qa/extras/tiledrendering/tiledrendering.cxx33
2 files changed, 33 insertions, 0 deletions
diff --git a/sw/qa/extras/tiledrendering/data/2-pages.odt b/sw/qa/extras/tiledrendering/data/2-pages.odt
new file mode 100644
index 000000000000..04953e5edf4e
--- /dev/null
+++ b/sw/qa/extras/tiledrendering/data/2-pages.odt
Binary files differ
diff --git a/sw/qa/extras/tiledrendering/tiledrendering.cxx b/sw/qa/extras/tiledrendering/tiledrendering.cxx
index 4d6cc99c0baf..a6dbe6011da0 100644
--- a/sw/qa/extras/tiledrendering/tiledrendering.cxx
+++ b/sw/qa/extras/tiledrendering/tiledrendering.cxx
@@ -33,6 +33,7 @@ public:
void testSetGraphicSelection();
void testResetSelection();
void testSearch();
+ void testDocumentSizeChanged();
CPPUNIT_TEST_SUITE(SwTiledRenderingTest);
CPPUNIT_TEST(testRegisterCallback);
@@ -42,6 +43,7 @@ public:
CPPUNIT_TEST(testSetGraphicSelection);
CPPUNIT_TEST(testResetSelection);
CPPUNIT_TEST(testSearch);
+ CPPUNIT_TEST(testDocumentSizeChanged);
CPPUNIT_TEST_SUITE_END();
private:
@@ -49,6 +51,7 @@ private:
static void callback(int nType, const char* pPayload, void* pData);
void callbackImpl(int nType, const char* pPayload);
Rectangle m_aInvalidation;
+ Size m_aDocumentSize;
};
SwXTextDocument* SwTiledRenderingTest::createDoc(const char* pName)
@@ -75,6 +78,8 @@ void SwTiledRenderingTest::callbackImpl(int nType, const char* pPayload)
if (m_aInvalidation.IsEmpty())
{
uno::Sequence<OUString> aSeq = comphelper::string::convertCommaSeparated(OUString::createFromAscii(pPayload));
+ if (OString("EMPTY") == pPayload)
+ return;
CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32>(4), aSeq.getLength());
m_aInvalidation.setX(aSeq[0].toInt32());
m_aInvalidation.setY(aSeq[1].toInt32());
@@ -83,6 +88,14 @@ void SwTiledRenderingTest::callbackImpl(int nType, const char* pPayload)
}
}
break;
+ case LOK_CALLBACK_DOCUMENT_SIZE_CHANGED:
+ {
+ uno::Sequence<OUString> aSeq = comphelper::string::convertCommaSeparated(OUString::createFromAscii(pPayload));
+ CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32>(2), aSeq.getLength());
+ m_aDocumentSize.setWidth(aSeq[0].toInt32());
+ m_aDocumentSize.setHeight(aSeq[1].toInt32());
+ }
+ break;
}
}
@@ -276,6 +289,26 @@ void SwTiledRenderingTest::testSearch()
#endif
}
+void SwTiledRenderingTest::testDocumentSizeChanged()
+{
+#if !defined(WNT) && !defined(MACOSX)
+ // Get the current document size.
+ SwXTextDocument* pXTextDocument = createDoc("2-pages.odt");
+ pXTextDocument->registerCallback(&SwTiledRenderingTest::callback, this);
+ SwWrtShell* pWrtShell = pXTextDocument->GetDocShell()->GetWrtShell();
+ pXTextDocument->initializeForTiledRendering();
+ Size aSize = pXTextDocument->getDocumentSize();
+
+ // Delete the second page and see how the size changes.
+ pWrtShell->Down(false);
+ pWrtShell->DelLeft();
+ // Document width should not change, this was 0.
+ CPPUNIT_ASSERT_EQUAL(aSize.getWidth(), m_aDocumentSize.getWidth());
+ // Document height should be smaller now.
+ CPPUNIT_ASSERT(aSize.getHeight() > m_aDocumentSize.getHeight());
+#endif
+}
+
CPPUNIT_TEST_SUITE_REGISTRATION(SwTiledRenderingTest);
CPPUNIT_PLUGIN_IMPLEMENT();