diff options
author | Henry Castro <hcastro@collabora.com> | 2017-06-27 20:42:11 -0400 |
---|---|---|
committer | Jan Holesovsky <kendy@collabora.com> | 2017-07-26 18:30:08 +0200 |
commit | 0892238c635009a7b078a0778dbd6138e06e0ac0 (patch) | |
tree | 04eb88e1029774e227f487621f5cbb840eed0f3d /sd/qa/unit/tiledrendering/tiledrendering.cxx | |
parent | ea31fa38bfef778428203d1473cafc31659be1b9 (diff) |
sd lok: disable undo state if conflict with other views
Change-Id: I046d118fca32c95f7734d6e29598da56578c9ec0
Reviewed-on: https://gerrit.libreoffice.org/39333
Tested-by: Jenkins <ci@libreoffice.org>
Reviewed-by: Henry Castro <hcastro@collabora.com>
Reviewed-on: https://gerrit.libreoffice.org/39400
Reviewed-by: Jan Holesovsky <kendy@collabora.com>
Tested-by: Jan Holesovsky <kendy@collabora.com>
Diffstat (limited to 'sd/qa/unit/tiledrendering/tiledrendering.cxx')
-rw-r--r-- | sd/qa/unit/tiledrendering/tiledrendering.cxx | 55 |
1 files changed, 55 insertions, 0 deletions
diff --git a/sd/qa/unit/tiledrendering/tiledrendering.cxx b/sd/qa/unit/tiledrendering/tiledrendering.cxx index 6a75280b7f4f..46dc5acf7c7c 100644 --- a/sd/qa/unit/tiledrendering/tiledrendering.cxx +++ b/sd/qa/unit/tiledrendering/tiledrendering.cxx @@ -95,6 +95,7 @@ public: void testTdf105502(); void testCommentCallbacks(); void testMultiViewInsertDeletePage(); + void testDisableUndoRepair(); CPPUNIT_TEST_SUITE(SdTiledRenderingTest); CPPUNIT_TEST(testRegisterCallback); @@ -131,6 +132,7 @@ public: CPPUNIT_TEST(testTdf105502); CPPUNIT_TEST(testCommentCallbacks); CPPUNIT_TEST(testMultiViewInsertDeletePage); + CPPUNIT_TEST(testDisableUndoRepair); CPPUNIT_TEST_SUITE_END(); @@ -1762,6 +1764,59 @@ void SdTiledRenderingTest::testMultiViewInsertDeletePage() comphelper::LibreOfficeKit::setActive(false); } +void SdTiledRenderingTest::testDisableUndoRepair() +{ + // Load the document. + comphelper::LibreOfficeKit::setActive(); + SdXImpressDocument* pXImpressDocument = createDoc("dummy.odp"); + SfxViewShell* pView1 = SfxViewShell::Current(); + int nView1 = SfxLokHelper::getView(); + SfxLokHelper::createView(); + SfxViewShell* pView2 = SfxViewShell::Current(); + int nView2 = SfxLokHelper::getView(); + { + std::unique_ptr<SfxPoolItem> pItem1; + std::unique_ptr<SfxPoolItem> pItem2; + CPPUNIT_ASSERT(SfxItemState::DISABLED == pView1->GetViewFrame()->GetBindings().QueryState(SID_UNDO, pItem1)); + CPPUNIT_ASSERT(SfxItemState::DISABLED == pView2->GetViewFrame()->GetBindings().QueryState(SID_UNDO, pItem2)); + } + + // Insert a character in the first view. + SfxLokHelper::setView(nView1); + pXImpressDocument->postKeyEvent(LOK_KEYEVENT_KEYINPUT, 0, awt::Key::TAB); + pXImpressDocument->postKeyEvent(LOK_KEYEVENT_KEYUP, 0, awt::Key::TAB); + pXImpressDocument->postKeyEvent(LOK_KEYEVENT_KEYINPUT, 'h', 0); + pXImpressDocument->postKeyEvent(LOK_KEYEVENT_KEYUP, 'h', 0); + Scheduler::ProcessEventsToIdle(); + { + std::unique_ptr<SfxPoolItem> pItem1; + std::unique_ptr<SfxPoolItem> pItem2; + pView1->GetViewFrame()->GetBindings().QueryState(SID_UNDO, pItem1); + pView2->GetViewFrame()->GetBindings().QueryState(SID_UNDO, pItem2); + CPPUNIT_ASSERT(!dynamic_cast< const SfxUInt32Item* >(pItem1.get())); + CPPUNIT_ASSERT(dynamic_cast< const SfxUInt32Item* >(pItem2.get())); + CPPUNIT_ASSERT_EQUAL(static_cast<sal_uInt32>(SID_REPAIRPACKAGE), dynamic_cast< const SfxUInt32Item * >(pItem2.get())->GetValue()); + } + + // Insert a character in the second view. + SfxLokHelper::setView(nView2); + pXImpressDocument->setPart(1); + pXImpressDocument->postKeyEvent(LOK_KEYEVENT_KEYINPUT, 0, awt::Key::TAB); + pXImpressDocument->postKeyEvent(LOK_KEYEVENT_KEYUP, 0, awt::Key::TAB); + pXImpressDocument->postKeyEvent(LOK_KEYEVENT_KEYINPUT, 'c', 0); + pXImpressDocument->postKeyEvent(LOK_KEYEVENT_KEYUP, 'c', 0); + Scheduler::ProcessEventsToIdle(); + { + std::unique_ptr<SfxPoolItem> pItem1; + std::unique_ptr<SfxPoolItem> pItem2; + pView1->GetViewFrame()->GetBindings().QueryState(SID_UNDO, pItem1); + pView2->GetViewFrame()->GetBindings().QueryState(SID_UNDO, pItem2); + CPPUNIT_ASSERT(!dynamic_cast< const SfxUInt32Item* >(pItem2.get())); + CPPUNIT_ASSERT(dynamic_cast< const SfxUInt32Item* >(pItem1.get())); + CPPUNIT_ASSERT_EQUAL(static_cast<sal_uInt32>(SID_REPAIRPACKAGE), dynamic_cast< const SfxUInt32Item * >(pItem1.get())->GetValue()); + } +} + CPPUNIT_TEST_SUITE_REGISTRATION(SdTiledRenderingTest); CPPUNIT_PLUGIN_IMPLEMENT(); |