diff options
author | Miklos Vajna <vmiklos@collabora.co.uk> | 2015-05-29 12:05:32 +0200 |
---|---|---|
committer | Miklos Vajna <vmiklos@collabora.co.uk> | 2015-05-29 12:34:07 +0200 |
commit | 560c3fdca41843c29ea33c1e9c14429537f4e4b6 (patch) | |
tree | 4677db8a01377200cb1f33219d54b4dd71e9f7cb | |
parent | 70b598ac14bf5b8e9af4188dbccef332a40a6562 (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
-rw-r--r-- | sw/qa/extras/tiledrendering/data/2-pages.odt | bin | 0 -> 8596 bytes | |||
-rw-r--r-- | sw/qa/extras/tiledrendering/tiledrendering.cxx | 33 |
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 Binary files differnew file mode 100644 index 000000000000..04953e5edf4e --- /dev/null +++ b/sw/qa/extras/tiledrendering/data/2-pages.odt 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(); |