diff options
author | Henry Castro <hcastro@collabora.com> | 2017-05-25 21:07:25 -0400 |
---|---|---|
committer | Henry Castro <hcastro@collabora.com> | 2017-05-27 06:20:51 +0200 |
commit | 0582bd49b385ebcebf93fe87d0161ed4846c8805 (patch) | |
tree | 2fbad7faf409b16e6dac21a96405711c9288be8b /sw/qa | |
parent | 95b9b46cca1da5f452af5e322af447fd27f82ea5 (diff) |
sw lok: disable undo state if conflict with other views
Change-Id: I5497c9b1f236bc803529825ba8b423d55fffa93e
Reviewed-on: https://gerrit.libreoffice.org/38049
Tested-by: Jenkins <ci@libreoffice.org>
Reviewed-by: Henry Castro <hcastro@collabora.com>
Diffstat (limited to 'sw/qa')
-rw-r--r-- | sw/qa/extras/tiledrendering/tiledrendering.cxx | 78 |
1 files changed, 78 insertions, 0 deletions
diff --git a/sw/qa/extras/tiledrendering/tiledrendering.cxx b/sw/qa/extras/tiledrendering/tiledrendering.cxx index cd67c8b28fcb..d876736f8076 100644 --- a/sw/qa/extras/tiledrendering/tiledrendering.cxx +++ b/sw/qa/extras/tiledrendering/tiledrendering.cxx @@ -89,6 +89,7 @@ public: void testPaintCallbacks(); void testUndoRepairResult(); void testRedoRepairResult(); + void testDisableUndoRepair(); CPPUNIT_TEST_SUITE(SwTiledRenderingTest); @@ -134,6 +135,7 @@ public: CPPUNIT_TEST(testPaintCallbacks); CPPUNIT_TEST(testUndoRepairResult); CPPUNIT_TEST(testRedoRepairResult); + CPPUNIT_TEST(testDisableUndoRepair); CPPUNIT_TEST_SUITE_END(); @@ -1724,6 +1726,82 @@ void SwTiledRenderingTest::testRedoRepairResult() comphelper::LibreOfficeKit::setActive(false); } +void SwTiledRenderingTest::testDisableUndoRepair() +{ + comphelper::LibreOfficeKit::setActive(); + + // Create two views. + SwXTextDocument* pXTextDocument = createDoc("dummy.fodt"); + ViewCallback aView1; + SwView* pView1 = dynamic_cast<SwView*>(SfxViewShell::Current()); + int nView1 = SfxLokHelper::getView(); + SfxLokHelper::createView(); + ViewCallback aView2; + SwView* pView2 = dynamic_cast<SwView*>(SfxViewShell::Current()); + int nView2 = SfxLokHelper::getView(); + + { + SfxItemSet aItemSet1(pXTextDocument->GetDocShell()->GetDoc()->GetAttrPool(), SID_UNDO, SID_UNDO); + SfxItemSet aItemSet2(pXTextDocument->GetDocShell()->GetDoc()->GetAttrPool(), SID_UNDO, SID_UNDO); + pView1->GetState(aItemSet1); + CPPUNIT_ASSERT_EQUAL(SfxItemState::DISABLED, aItemSet1.GetItemState(SID_UNDO)); + pView2->GetState(aItemSet2); + CPPUNIT_ASSERT_EQUAL(SfxItemState::DISABLED, aItemSet2.GetItemState(SID_UNDO)); + } + + auto fnCheckStates = [pXTextDocument, pView1, pView2]() + { + SfxItemSet aItemSet1(pXTextDocument->GetDocShell()->GetDoc()->GetAttrPool(), SID_UNDO, SID_UNDO); + SfxItemSet aItemSet2(pXTextDocument->GetDocShell()->GetDoc()->GetAttrPool(), SID_UNDO, SID_UNDO); + // first view, undo enabled + pView1->GetState(aItemSet1); + CPPUNIT_ASSERT_EQUAL(SfxItemState::SET, aItemSet1.GetItemState(SID_UNDO)); + CPPUNIT_ASSERT(!dynamic_cast< const SfxUInt32Item * >(aItemSet1.GetItem(SID_UNDO))); + // second view, undo conflict + pView2->GetState(aItemSet2); + CPPUNIT_ASSERT_EQUAL(SfxItemState::SET, aItemSet2.GetItemState(SID_UNDO)); + CPPUNIT_ASSERT(dynamic_cast< const SfxUInt32Item * >(aItemSet2.GetItem(SID_UNDO))); + CPPUNIT_ASSERT_EQUAL(static_cast<sal_uInt32>(SwUndoId::CONFLICT), dynamic_cast< const SfxUInt32Item * >(aItemSet2.GetItem(SID_UNDO))->GetValue()); + }; + + // Insert a character in the first view. + SfxLokHelper::setView(nView1); + pXTextDocument->postKeyEvent(LOK_KEYEVENT_KEYINPUT, 'k', 0); + pXTextDocument->postKeyEvent(LOK_KEYEVENT_KEYUP, 'k', 0); + Scheduler::ProcessEventsToIdle(); + fnCheckStates(); + + // Insert a character in the second view. + SfxLokHelper::setView(nView2); + pXTextDocument->postKeyEvent(LOK_KEYEVENT_KEYINPUT, 'u', 0); + pXTextDocument->postKeyEvent(LOK_KEYEVENT_KEYUP, 'u', 0); + Scheduler::ProcessEventsToIdle(); + { + SfxItemSet aItemSet1(pXTextDocument->GetDocShell()->GetDoc()->GetAttrPool(), SID_UNDO, SID_UNDO); + SfxItemSet aItemSet2(pXTextDocument->GetDocShell()->GetDoc()->GetAttrPool(), SID_UNDO, SID_UNDO); + // second view, undo enabled + pView2->GetState(aItemSet2); + CPPUNIT_ASSERT_EQUAL(SfxItemState::SET, aItemSet2.GetItemState(SID_UNDO)); + CPPUNIT_ASSERT(!dynamic_cast< const SfxUInt32Item * >(aItemSet2.GetItem(SID_UNDO))); + // first view, undo conflict + pView1->GetState(aItemSet1); + CPPUNIT_ASSERT_EQUAL(SfxItemState::SET, aItemSet1.GetItemState(SID_UNDO)); + CPPUNIT_ASSERT(dynamic_cast< const SfxUInt32Item * >(aItemSet1.GetItem(SID_UNDO))); + CPPUNIT_ASSERT_EQUAL(static_cast<sal_uInt32>(SwUndoId::CONFLICT), dynamic_cast< const SfxUInt32Item * >(aItemSet1.GetItem(SID_UNDO))->GetValue()); + } + + // Insert a character in the first view. + SfxLokHelper::setView(nView1); + pXTextDocument->postKeyEvent(LOK_KEYEVENT_KEYINPUT, 'l', 0); + pXTextDocument->postKeyEvent(LOK_KEYEVENT_KEYUP, 'l', 0); + Scheduler::ProcessEventsToIdle(); + fnCheckStates(); + + mxComponent->dispose(); + mxComponent.clear(); + comphelper::LibreOfficeKit::setActive(false); +} + CPPUNIT_TEST_SUITE_REGISTRATION(SwTiledRenderingTest); CPPUNIT_PLUGIN_IMPLEMENT(); |