Kaydet (Commit) 368903ee authored tarafından Miklos Vajna's avatar Miklos Vajna Kaydeden (comit) Jan Holesovsky

LOK: add DOCUMENT_SIZE_CHANGED testcase

This failed without the SwViewShell::SizeChgNotify() hunk of commit
63a40c45 (LOK: change PAGE_COUNT to a
more generic DOCUMENT_SIZE, 2015-05-27).

Change-Id: Id230420f60d1a6f3caf822f7e23ffca010919196
(cherry picked from commit 560c3fdc)
üst 692b77f7
......@@ -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();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment