[Libreoffice-commits] core.git: sw/qa

Miklos Vajna vmiklos at collabora.co.uk
Fri May 29 03:36:17 PDT 2015


 sw/qa/extras/tiledrendering/data/2-pages.odt   |binary
 sw/qa/extras/tiledrendering/tiledrendering.cxx |   33 +++++++++++++++++++++++++
 2 files changed, 33 insertions(+)

New commits:
commit 560c3fdca41843c29ea33c1e9c14429537f4e4b6
Author: Miklos Vajna <vmiklos at collabora.co.uk>
Date:   Fri May 29 12:05:32 2015 +0200

    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

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 0000000..04953e5
Binary files /dev/null and b/sw/qa/extras/tiledrendering/data/2-pages.odt differ
diff --git a/sw/qa/extras/tiledrendering/tiledrendering.cxx b/sw/qa/extras/tiledrendering/tiledrendering.cxx
index 4d6cc99..a6dbe60 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();


More information about the Libreoffice-commits mailing list