diff options
author | Henry Castro <hcastro@collabora.com> | 2016-11-24 07:09:38 -0400 |
---|---|---|
committer | Henry Castro <hcastro@collabora.com> | 2016-11-28 02:26:23 +0000 |
commit | 2db42ab241d0852d89a470b18727c22d0fc06745 (patch) | |
tree | 40af961c0846fdd68a657938d5d1fd61f3c69024 /sw/qa/extras/tiledrendering | |
parent | e2d5f1ba3fd0db00276cf48b0d9be9b16dcbf7a0 (diff) |
sw lok: notify repair when exist a conflict of multiple users undo/redo
Change-Id: I026f4df6239fa87ee191f92127f9fa98ac2993eb
Reviewed-on: https://gerrit.libreoffice.org/31161
Tested-by: Jenkins <ci@libreoffice.org>
Reviewed-by: Henry Castro <hcastro@collabora.com>
Diffstat (limited to 'sw/qa/extras/tiledrendering')
-rw-r--r-- | sw/qa/extras/tiledrendering/tiledrendering.cxx | 99 |
1 files changed, 99 insertions, 0 deletions
diff --git a/sw/qa/extras/tiledrendering/tiledrendering.cxx b/sw/qa/extras/tiledrendering/tiledrendering.cxx index 19a40665d2df..c9829f2a84a6 100644 --- a/sw/qa/extras/tiledrendering/tiledrendering.cxx +++ b/sw/qa/extras/tiledrendering/tiledrendering.cxx @@ -10,6 +10,7 @@ #include <string> #include <boost/property_tree/json_parser.hpp> +#include <com/sun/star/frame/DispatchResultState.hpp> #include <swmodeltestbase.hxx> #include <LibreOfficeKit/LibreOfficeKitEnums.h> #include <comphelper/dispatchcommand.hxx> @@ -78,6 +79,9 @@ public: void testCommentEndTextEdit(); void testCursorPosition(); void testPaintCallbacks(); + void testUndoRepairResult(); + void testRedoRepairResult(); + CPPUNIT_TEST_SUITE(SwTiledRenderingTest); CPPUNIT_TEST(testRegisterCallback); @@ -120,6 +124,9 @@ public: CPPUNIT_TEST(testCommentEndTextEdit); CPPUNIT_TEST(testCursorPosition); CPPUNIT_TEST(testPaintCallbacks); + CPPUNIT_TEST(testUndoRepairResult); + CPPUNIT_TEST(testRedoRepairResult); + CPPUNIT_TEST_SUITE_END(); private: @@ -754,6 +761,30 @@ public: } }; +class TestResultListener : public cppu::WeakImplHelper<css::frame::XDispatchResultListener> +{ +public: + sal_uInt32 m_nDocRepair; + + TestResultListener() : m_nDocRepair(0) + { + } + + virtual void SAL_CALL dispatchFinished(const css::frame::DispatchResultEvent& rEvent) + throw(css::uno::RuntimeException, std::exception) override + { + if (rEvent.State == frame::DispatchResultState::SUCCESS) + { + rEvent.Result >>= m_nDocRepair; + } + } + + virtual void SAL_CALL disposing(const css::lang::EventObject&) + throw (css::uno::RuntimeException, std::exception) override + { + } +}; + void SwTiledRenderingTest::testMissingInvalidation() { comphelper::LibreOfficeKit::setActive(); @@ -1572,6 +1603,74 @@ void SwTiledRenderingTest::testPaintCallbacks() comphelper::LibreOfficeKit::setActive(false); } +void SwTiledRenderingTest::testUndoRepairResult() +{ + // Load a document and create two views. + comphelper::LibreOfficeKit::setActive(); + SwXTextDocument* pXTextDocument = createDoc("dummy.fodt"); + int nView1 = SfxLokHelper::getView(); + SfxLokHelper::createView(); + TestResultListener* pResult2 = new TestResultListener(); + css::uno::Reference< css::frame::XDispatchResultListener > xListener(static_cast< css::frame::XDispatchResultListener* >(pResult2), css::uno::UNO_QUERY); + pXTextDocument->initializeForTiledRendering(uno::Sequence<beans::PropertyValue>()); + int nView2 = SfxLokHelper::getView(); + + // Insert a character in the second view. + SfxLokHelper::setView(nView2); + pXTextDocument->postKeyEvent(LOK_KEYEVENT_KEYINPUT, 'b', 0); + pXTextDocument->postKeyEvent(LOK_KEYEVENT_KEYUP, 'b', 0); + + // Insert a character in the first view. + SfxLokHelper::setView(nView1); + pXTextDocument->postKeyEvent(LOK_KEYEVENT_KEYINPUT, 'a', 0); + pXTextDocument->postKeyEvent(LOK_KEYEVENT_KEYUP, 'a', 0); + + // Assert that by default the second view can't undo the action. + SfxLokHelper::setView(nView2); + comphelper::dispatchCommand(".uno:Undo", {}, xListener); + Scheduler::ProcessEventsToIdle(); + CPPUNIT_ASSERT_EQUAL(static_cast<sal_uInt32>(UNDO_CONFLICT), pResult2->m_nDocRepair); + + mxComponent->dispose(); + mxComponent.clear(); + comphelper::LibreOfficeKit::setActive(false); +} + +void SwTiledRenderingTest::testRedoRepairResult() +{ + // Load a document and create two views. + comphelper::LibreOfficeKit::setActive(); + SwXTextDocument* pXTextDocument = createDoc("dummy.fodt"); + int nView1 = SfxLokHelper::getView(); + SfxLokHelper::createView(); + TestResultListener* pResult2 = new TestResultListener(); + css::uno::Reference< css::frame::XDispatchResultListener > xListener(static_cast< css::frame::XDispatchResultListener* >(pResult2), css::uno::UNO_QUERY); + pXTextDocument->initializeForTiledRendering(uno::Sequence<beans::PropertyValue>()); + int nView2 = SfxLokHelper::getView(); + + // Insert a character in the second view. + SfxLokHelper::setView(nView2); + pXTextDocument->postKeyEvent(LOK_KEYEVENT_KEYINPUT, 'b', 0); + pXTextDocument->postKeyEvent(LOK_KEYEVENT_KEYUP, 'b', 0); + + // Insert a character in the first view. + SfxLokHelper::setView(nView1); + pXTextDocument->postKeyEvent(LOK_KEYEVENT_KEYINPUT, 'a', 0); + pXTextDocument->postKeyEvent(LOK_KEYEVENT_KEYUP, 'a', 0); + comphelper::dispatchCommand(".uno:Undo", {}, xListener); + CPPUNIT_ASSERT_EQUAL(static_cast<sal_uInt32>(0), pResult2->m_nDocRepair); + + // Assert that by default the second view can't redo the action. + SfxLokHelper::setView(nView2); + comphelper::dispatchCommand(".uno:Redo", {}, xListener); + Scheduler::ProcessEventsToIdle(); + CPPUNIT_ASSERT_EQUAL(static_cast<sal_uInt32>(UNDO_CONFLICT), pResult2->m_nDocRepair); + + mxComponent->dispose(); + mxComponent.clear(); + comphelper::LibreOfficeKit::setActive(false); +} + CPPUNIT_TEST_SUITE_REGISTRATION(SwTiledRenderingTest); CPPUNIT_PLUGIN_IMPLEMENT(); |