[Libreoffice-commits] core.git: Branch 'distro/collabora/cp-5.3' - sc/qa

Jan Holesovsky kendy at collabora.com
Tue May 2 21:04:12 UTC 2017


 sc/qa/unit/tiledrendering/data/cursor-away.ods |binary
 sc/qa/unit/tiledrendering/tiledrendering.cxx   |   45 +++++++++++++++++++++++++
 2 files changed, 45 insertions(+)

New commits:
commit 9c2daa30dc8743515e78665bcb02a4a0dc13c469
Author: Jan Holesovsky <kendy at collabora.com>
Date:   Tue May 2 16:32:28 2017 +0200

    sc lok: Unit test that pgdown grows the document size for the new view.
    
    Test based on the online.git test by Ashod Nakashian, thanks for the repro
    steps there!
    
    Change-Id: I225127e953b0dade0b1bd4e12c131dc984b7e3fc
    Reviewed-on: https://gerrit.libreoffice.org/37169
    Reviewed-by: Andras Timar <andras.timar at collabora.com>
    Tested-by: Andras Timar <andras.timar at collabora.com>

diff --git a/sc/qa/unit/tiledrendering/data/cursor-away.ods b/sc/qa/unit/tiledrendering/data/cursor-away.ods
new file mode 100644
index 000000000000..c593fc7db033
Binary files /dev/null and b/sc/qa/unit/tiledrendering/data/cursor-away.ods differ
diff --git a/sc/qa/unit/tiledrendering/tiledrendering.cxx b/sc/qa/unit/tiledrendering/tiledrendering.cxx
index cb0f5aea7b9b..577e79aeb41c 100644
--- a/sc/qa/unit/tiledrendering/tiledrendering.cxx
+++ b/sc/qa/unit/tiledrendering/tiledrendering.cxx
@@ -75,6 +75,7 @@ public:
     void testUndoLimiting();
     void testUndoRepairDispatch();
     void testInsertGraphicInvalidations();
+    void testDocumentSizeWithTwoViews();
 
     CPPUNIT_TEST_SUITE(ScTiledRenderingTest);
     CPPUNIT_TEST(testRowColumnSelections);
@@ -100,6 +101,7 @@ public:
     CPPUNIT_TEST(testUndoLimiting);
     CPPUNIT_TEST(testUndoRepairDispatch);
     CPPUNIT_TEST(testInsertGraphicInvalidations);
+    CPPUNIT_TEST(testDocumentSizeWithTwoViews);
     CPPUNIT_TEST_SUITE_END();
 
 private:
@@ -1307,6 +1309,49 @@ void ScTiledRenderingTest::testInsertGraphicInvalidations()
     comphelper::LibreOfficeKit::setActive(false);
 }
 
+void ScTiledRenderingTest::testDocumentSizeWithTwoViews()
+{
+    comphelper::LibreOfficeKit::setActive();
+
+    // Open a document that has the cursor far away & paint a tile
+    ScModelObj* pModelObj = createDoc("cursor-away.ods");
+
+    // Set the visible area, and press page down
+    pModelObj->setClientVisibleArea(Rectangle(750, 1861, 20583, 6997));
+    pModelObj->postKeyEvent(LOK_KEYEVENT_KEYINPUT, 0, awt::Key::PAGEDOWN);
+    pModelObj->postKeyEvent(LOK_KEYEVENT_KEYUP, 0, awt::Key::PAGEDOWN);
+    Scheduler::ProcessEventsToIdle();
+
+    Size aDocSize = pModelObj->getDocumentSize();
+
+    int nCanvasWidth = 256;
+    int nCanvasHeight = 256;
+    std::vector<unsigned char> aBuffer1(nCanvasWidth * nCanvasHeight * 4);
+    ScopedVclPtrInstance<VirtualDevice> pDevice1(nullptr, Size(1, 1), DeviceFormat::DEFAULT);
+    pDevice1->SetOutputSizePixelScaleOffsetAndBuffer(Size(nCanvasWidth, nCanvasHeight), Fraction(1.0), Point(), aBuffer1.data());
+    pModelObj->paintTile(*pDevice1.get(), nCanvasWidth, nCanvasHeight, /*nTilePosX=*/0, /*nTilePosY=*/291840, /*nTileWidth=*/3840, /*nTileHeight=*/3840);
+    Scheduler::ProcessEventsToIdle();
+
+    // Create a new view
+    SfxLokHelper::createView();
+    Size aViewSize = pModelObj->getDocumentSize();
+
+    std::vector<unsigned char> aBuffer2(nCanvasWidth * nCanvasHeight * 4);
+    ScopedVclPtrInstance<VirtualDevice> pDevice2(nullptr, Size(1, 1), DeviceFormat::DEFAULT);
+    pDevice2->SetOutputSizePixelScaleOffsetAndBuffer(Size(nCanvasWidth, nCanvasHeight), Fraction(1.0), Point(), aBuffer2.data());
+    pModelObj->paintTile(*pDevice2.get(), nCanvasWidth, nCanvasHeight, /*nTilePosX=*/0, /*nTilePosY=*/291840, /*nTileWidth=*/3840, /*nTileHeight=*/3840);
+    Scheduler::ProcessEventsToIdle();
+
+    // Make sure the newly created view has the same size as the original one
+    CPPUNIT_ASSERT_EQUAL(aDocSize, aViewSize);
+
+    // and that the tiles actually have the same content
+    for (size_t i = 0; i < aBuffer1.size(); ++i)
+        CPPUNIT_ASSERT_EQUAL(aBuffer1[i], aBuffer2[i]);
+
+    comphelper::LibreOfficeKit::setActive(false);
+}
+
 }
 
 CPPUNIT_TEST_SUITE_REGISTRATION(ScTiledRenderingTest);


More information about the Libreoffice-commits mailing list