diff options
author | Jan Holesovsky <kendy@collabora.com> | 2017-05-02 16:32:28 +0200 |
---|---|---|
committer | Andras Timar <andras.timar@collabora.com> | 2017-05-02 23:03:42 +0200 |
commit | 9c2daa30dc8743515e78665bcb02a4a0dc13c469 (patch) | |
tree | c88e5f40b706db8bfb872c0f01399c31948f1585 | |
parent | 61d5a42cf4c65a9da38b91d33a98ea46d4b4d1ea (diff) |
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@collabora.com>
Tested-by: Andras Timar <andras.timar@collabora.com>
-rw-r--r-- | sc/qa/unit/tiledrendering/data/cursor-away.ods | bin | 0 -> 9230 bytes | |||
-rw-r--r-- | sc/qa/unit/tiledrendering/tiledrendering.cxx | 45 |
2 files changed, 45 insertions, 0 deletions
diff --git a/sc/qa/unit/tiledrendering/data/cursor-away.ods b/sc/qa/unit/tiledrendering/data/cursor-away.ods Binary files differnew file mode 100644 index 000000000000..c593fc7db033 --- /dev/null +++ b/sc/qa/unit/tiledrendering/data/cursor-away.ods 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); |