diff options
author | Xisco Fauli <xiscofauli@libreoffice.org> | 2022-09-14 13:59:02 +0200 |
---|---|---|
committer | Xisco Fauli <xiscofauli@libreoffice.org> | 2022-09-14 17:08:19 +0200 |
commit | 3592c2e1af98b3fad00c43a4e886c29f3a4bb934 (patch) | |
tree | 5f2da75e52ad9223fcd408c0c99791e807e13cb6 /sd/qa/unit | |
parent | 76342be56ee1ec52a27cf867760c2485ac4fd291 (diff) |
tdf#148620: sd: move UITest to CppUnittest
hopefully this will fix the sporadic failures of
UITest_impress_tests2 in Jenkins
Change-Id: I3df2484b07a0cf7a0efdafb7235c3ff83f187200
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/139928
Tested-by: Xisco Fauli <xiscofauli@libreoffice.org>
Reviewed-by: Xisco Fauli <xiscofauli@libreoffice.org>
Diffstat (limited to 'sd/qa/unit')
-rw-r--r-- | sd/qa/unit/uiimpress.cxx | 128 |
1 files changed, 106 insertions, 22 deletions
diff --git a/sd/qa/unit/uiimpress.cxx b/sd/qa/unit/uiimpress.cxx index b309b4e4754f..3642bef710eb 100644 --- a/sd/qa/unit/uiimpress.cxx +++ b/sd/qa/unit/uiimpress.cxx @@ -67,6 +67,8 @@ public: virtual void tearDown() override; void checkCurrentPageNumber(sal_uInt16 nNum); + void typeString(SdXImpressDocument* rImpressDocument, const std::string& rStr); + void typeKey(SdXImpressDocument* rImpressDocument, const sal_uInt16 nKey); void insertStringToObject(sal_uInt16 nObj, const std::string& rStr, bool bUseEscape); sd::slidesorter::SlideSorterViewShell* getSlideSorterViewShell(); FileFormat* getFormat(sal_Int32 nExportType); @@ -100,6 +102,23 @@ void SdUiImpressTest::checkCurrentPageNumber(sal_uInt16 nNum) CPPUNIT_ASSERT_EQUAL(nNum, nPageNumber); } +void SdUiImpressTest::typeKey(SdXImpressDocument* rImpressDocument, const sal_uInt16 nKey) +{ + rImpressDocument->postKeyEvent(LOK_KEYEVENT_KEYINPUT, 0, nKey); + rImpressDocument->postKeyEvent(LOK_KEYEVENT_KEYUP, 0, nKey); + Scheduler::ProcessEventsToIdle(); +} + +void SdUiImpressTest::typeString(SdXImpressDocument* rImpressDocument, const std::string& rStr) +{ + for (const char c : rStr) + { + rImpressDocument->postKeyEvent(LOK_KEYEVENT_KEYINPUT, c, 0); + rImpressDocument->postKeyEvent(LOK_KEYEVENT_KEYUP, c, 0); + Scheduler::ProcessEventsToIdle(); + } +} + void SdUiImpressTest::insertStringToObject(sal_uInt16 nObj, const std::string& rStr, bool bUseEscape) { @@ -110,24 +129,17 @@ void SdUiImpressTest::insertStringToObject(sal_uInt16 nObj, const std::string& r CPPUNIT_ASSERT_MESSAGE("No Shape", pShape); SdrView* pView = pViewShell->GetView(); pView->MarkObj(pShape, pView->GetSdrPageView()); + Scheduler::ProcessEventsToIdle(); CPPUNIT_ASSERT(!pView->IsTextEdit()); - for (const char c : rStr) - { - pImpressDocument->postKeyEvent(LOK_KEYEVENT_KEYINPUT, c, 0); - pImpressDocument->postKeyEvent(LOK_KEYEVENT_KEYUP, c, 0); - Scheduler::ProcessEventsToIdle(); - } + typeString(pImpressDocument, rStr); CPPUNIT_ASSERT(pView->IsTextEdit()); if (bUseEscape) { - pImpressDocument->postKeyEvent(LOK_KEYEVENT_KEYINPUT, 0, awt::Key::ESCAPE); - pImpressDocument->postKeyEvent(LOK_KEYEVENT_KEYUP, 0, awt::Key::ESCAPE); - Scheduler::ProcessEventsToIdle(); - + typeKey(pImpressDocument, KEY_ESCAPE); CPPUNIT_ASSERT(!pView->IsTextEdit()); } } @@ -586,6 +598,86 @@ CPPUNIT_TEST_FIXTURE(SdUiImpressTest, testmoveSlides) CPPUNIT_ASSERT_EQUAL(OUString("Test 2"), pViewShell->GetActualPage()->GetName()); } +CPPUNIT_TEST_FIXTURE(SdUiImpressTest, testTdf148620) +{ + mxComponent = loadFromDesktop("private:factory/simpress", + "com.sun.star.presentation.PresentationDocument"); + + auto pXImpressDocument = dynamic_cast<SdXImpressDocument*>(mxComponent.get()); + + uno::Reference<drawing::XDrawPagesSupplier> xDrawPagesSupplier(mxComponent, uno::UNO_QUERY); + uno::Reference<drawing::XDrawPage> xDrawPage(xDrawPagesSupplier->getDrawPages()->getByIndex(0), + uno::UNO_QUERY); + uno::Reference<text::XTextRange> xShape(xDrawPage->getByIndex(1), uno::UNO_QUERY); + CPPUNIT_ASSERT_EQUAL(OUString(u""), xShape->getString()); + + insertStringToObject(1, "one", /*bUseEscape*/ false); + typeKey(pXImpressDocument, KEY_RETURN); + typeString(pXImpressDocument, "two"); + typeKey(pXImpressDocument, KEY_RETURN); + typeString(pXImpressDocument, "three"); + typeKey(pXImpressDocument, KEY_RETURN); + typeString(pXImpressDocument, "four"); + typeKey(pXImpressDocument, KEY_RETURN); + typeString(pXImpressDocument, "five"); + typeKey(pXImpressDocument, KEY_RETURN); + typeString(pXImpressDocument, "six"); + + CPPUNIT_ASSERT_EQUAL(OUString(u"One\nTwo\nThree\nFour\nFive\nsix"), xShape->getString()); + + uno::Sequence<beans::PropertyValue> aArgs( + comphelper::InitPropertySequence({ { "KeyModifier", uno::Any(sal_Int32(0)) } })); + dispatchCommand(mxComponent, ".uno:OutlineUp", aArgs); + Scheduler::ProcessEventsToIdle(); + + CPPUNIT_ASSERT_EQUAL(OUString(u"One\nTwo\nThree\nFour\nsix\nFive"), xShape->getString()); + + dispatchCommand(mxComponent, ".uno:OutlineUp", aArgs); + Scheduler::ProcessEventsToIdle(); + + CPPUNIT_ASSERT_EQUAL(OUString(u"One\nTwo\nThree\nsix\nFour\nFive"), xShape->getString()); + + dispatchCommand(mxComponent, ".uno:OutlineUp", aArgs); + Scheduler::ProcessEventsToIdle(); + + CPPUNIT_ASSERT_EQUAL(OUString(u"One\nTwo\nsix\nThree\nFour\nFive"), xShape->getString()); + + dispatchCommand(mxComponent, ".uno:OutlineUp", aArgs); + Scheduler::ProcessEventsToIdle(); + + CPPUNIT_ASSERT_EQUAL(OUString(u"One\nsix\nTwo\nThree\nFour\nFive"), xShape->getString()); + + dispatchCommand(mxComponent, ".uno:OutlineUp", aArgs); + Scheduler::ProcessEventsToIdle(); + + CPPUNIT_ASSERT_EQUAL(OUString(u"six\nOne\nTwo\nThree\nFour\nFive"), xShape->getString()); + + dispatchCommand(mxComponent, ".uno:OutlineDown", aArgs); + Scheduler::ProcessEventsToIdle(); + + CPPUNIT_ASSERT_EQUAL(OUString(u"One\nsix\nTwo\nThree\nFour\nFive"), xShape->getString()); + + dispatchCommand(mxComponent, ".uno:OutlineDown", aArgs); + Scheduler::ProcessEventsToIdle(); + + CPPUNIT_ASSERT_EQUAL(OUString(u"One\nTwo\nsix\nThree\nFour\nFive"), xShape->getString()); + + dispatchCommand(mxComponent, ".uno:OutlineDown", aArgs); + Scheduler::ProcessEventsToIdle(); + + CPPUNIT_ASSERT_EQUAL(OUString(u"One\nTwo\nThree\nsix\nFour\nFive"), xShape->getString()); + + dispatchCommand(mxComponent, ".uno:OutlineDown", aArgs); + Scheduler::ProcessEventsToIdle(); + + CPPUNIT_ASSERT_EQUAL(OUString(u"One\nTwo\nThree\nFour\nsix\nFive"), xShape->getString()); + + dispatchCommand(mxComponent, ".uno:OutlineDown", aArgs); + Scheduler::ProcessEventsToIdle(); + + CPPUNIT_ASSERT_EQUAL(OUString(u"One\nTwo\nThree\nFour\nFive\nsix"), xShape->getString()); +} + CPPUNIT_TEST_FIXTURE(SdUiImpressTest, testTdf141703) { mxComponent = loadFromDesktop("private:factory/simpress", @@ -607,22 +699,14 @@ CPPUNIT_TEST_FIXTURE(SdUiImpressTest, testTdf141703) Scheduler::ProcessEventsToIdle(); } - pXImpressDocument->postKeyEvent(LOK_KEYEVENT_KEYINPUT, 'A', 0); - pXImpressDocument->postKeyEvent(LOK_KEYEVENT_KEYUP, 'A', 0); - Scheduler::ProcessEventsToIdle(); + typeString(pXImpressDocument, "A"); // Move to A2 with Tab and write 'B' - pXImpressDocument->postKeyEvent(LOK_KEYEVENT_KEYINPUT, 0, KEY_TAB); - pXImpressDocument->postKeyEvent(LOK_KEYEVENT_KEYUP, 0, KEY_TAB); - Scheduler::ProcessEventsToIdle(); + typeKey(pXImpressDocument, KEY_TAB); - pXImpressDocument->postKeyEvent(LOK_KEYEVENT_KEYINPUT, 'B', 0); - pXImpressDocument->postKeyEvent(LOK_KEYEVENT_KEYUP, 'B', 0); - Scheduler::ProcessEventsToIdle(); + typeString(pXImpressDocument, "B"); - pXImpressDocument->postKeyEvent(LOK_KEYEVENT_KEYINPUT, 0, awt::Key::ESCAPE); - pXImpressDocument->postKeyEvent(LOK_KEYEVENT_KEYUP, 0, awt::Key::ESCAPE); - Scheduler::ProcessEventsToIdle(); + typeKey(pXImpressDocument, KEY_ESCAPE); sd::ViewShell* pViewShell = pXImpressDocument->GetDocShell()->GetViewShell(); SdPage* pActualPage = pViewShell->GetActualPage(); |