diff options
author | Henry Castro <hcastro@collabora.com> | 2017-06-17 13:52:15 -0400 |
---|---|---|
committer | Henry Castro <hcastro@collabora.com> | 2017-12-07 19:14:18 +0100 |
commit | 6fd6e3c1d36d67002967f56e47255e360f4b08c1 (patch) | |
tree | 3d733efd3b054513590b211e209972f5328fd292 /sw/qa | |
parent | ed50a0a2ce51584fa3a8fba0094220a4bf25c650 (diff) |
lokit: add .uno:DocumentRepair command
Change-Id: I5b13ea6f4785bc91c29111fa63c4a1b0ea9b2660
Reviewed-on: https://gerrit.libreoffice.org/38908
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 | 48 |
1 files changed, 47 insertions, 1 deletions
diff --git a/sw/qa/extras/tiledrendering/tiledrendering.cxx b/sw/qa/extras/tiledrendering/tiledrendering.cxx index 91f5f2235901..d6f95df456e7 100644 --- a/sw/qa/extras/tiledrendering/tiledrendering.cxx +++ b/sw/qa/extras/tiledrendering/tiledrendering.cxx @@ -32,6 +32,7 @@ #include <sfx2/viewsh.hxx> #include <sfx2/bindings.hxx> #include <sfx2/dispatch.hxx> +#include <sfx2/viewfrm.hxx> #include <sfx2/lokhelper.hxx> #include <redline.hxx> #include <IDocumentRedlineAccess.hxx> @@ -94,7 +95,7 @@ public: void testRedoRepairResult(); void testDisableUndoRepair(); void testAllTrackedChanges(); - + void testDocumentRepair(); CPPUNIT_TEST_SUITE(SwTiledRenderingTest); CPPUNIT_TEST(testRegisterCallback); @@ -141,6 +142,7 @@ public: CPPUNIT_TEST(testRedoRepairResult); CPPUNIT_TEST(testDisableUndoRepair); CPPUNIT_TEST(testAllTrackedChanges); + CPPUNIT_TEST(testDocumentRepair); CPPUNIT_TEST_SUITE_END(); @@ -1887,6 +1889,50 @@ void SwTiledRenderingTest::testAllTrackedChanges() comphelper::LibreOfficeKit::setActive(false); } +void SwTiledRenderingTest::testDocumentRepair() +{ + comphelper::LibreOfficeKit::setActive(); + + // Create two views. + SwXTextDocument* pXTextDocument = createDoc("dummy.fodt"); + // view #1 + SfxViewShell* pView1 = SfxViewShell::Current(); + + // view #2 + SfxLokHelper::createView(); + SfxViewShell* pView2 = SfxViewShell::Current(); + int nView2 = SfxLokHelper::getView(); + CPPUNIT_ASSERT(pView1 != pView2); + { + std::unique_ptr<SfxPoolItem> pItem1; + std::unique_ptr<SfxPoolItem> pItem2; + pView1->GetViewFrame()->GetBindings().QueryState(SID_DOC_REPAIR, pItem1); + pView2->GetViewFrame()->GetBindings().QueryState(SID_DOC_REPAIR, pItem2); + CPPUNIT_ASSERT(dynamic_cast< const SfxBoolItem* >(pItem1.get())); + CPPUNIT_ASSERT(dynamic_cast< const SfxBoolItem* >(pItem2.get())); + CPPUNIT_ASSERT_EQUAL(false, dynamic_cast< const SfxBoolItem* >(pItem1.get())->GetValue()); + CPPUNIT_ASSERT_EQUAL(false, dynamic_cast< const SfxBoolItem* >(pItem2.get())->GetValue()); + } + + // 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(); + { + std::unique_ptr<SfxPoolItem> pItem1; + std::unique_ptr<SfxPoolItem> pItem2; + pView1->GetViewFrame()->GetBindings().QueryState(SID_DOC_REPAIR, pItem1); + pView2->GetViewFrame()->GetBindings().QueryState(SID_DOC_REPAIR, pItem2); + CPPUNIT_ASSERT(dynamic_cast< const SfxBoolItem* >(pItem1.get())); + CPPUNIT_ASSERT(dynamic_cast< const SfxBoolItem* >(pItem2.get())); + CPPUNIT_ASSERT_EQUAL(true, dynamic_cast< const SfxBoolItem* >(pItem1.get())->GetValue()); + CPPUNIT_ASSERT_EQUAL(true, dynamic_cast< const SfxBoolItem* >(pItem2.get())->GetValue()); + } + + comphelper::LibreOfficeKit::setActive(false); +} + CPPUNIT_TEST_SUITE_REGISTRATION(SwTiledRenderingTest); |