[Libreoffice-commits] core.git: sd/qa sd/source
Xisco Fauli (via logerrit)
logerrit at kemper.freedesktop.org
Mon Feb 1 19:18:23 UTC 2021
sd/qa/unit/uiimpress.cxx | 84 ++++++++++++
sd/source/ui/slidesorter/inc/controller/SlsPageSelector.hxx | 2
2 files changed, 85 insertions(+), 1 deletion(-)
New commits:
commit bc04a3c85afaf290958ae63ff374ff1d3f07bb66
Author: Xisco Fauli <xiscofauli at libreoffice.org>
AuthorDate: Mon Feb 1 16:19:45 2021 +0100
Commit: Xisco Fauli <xiscofauli at libreoffice.org>
CommitDate: Mon Feb 1 20:17:39 2021 +0100
tdf#100950: sd_uiimpress: Add unittest
Change-Id: Ia2ecdc6d2836f51d7c47f1dc7208f52d4ab12a02
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/110258
Tested-by: Jenkins
Reviewed-by: Xisco Fauli <xiscofauli at libreoffice.org>
diff --git a/sd/qa/unit/uiimpress.cxx b/sd/qa/unit/uiimpress.cxx
index 7bfe6e42ac87..83eb2a39cd13 100644
--- a/sd/qa/unit/uiimpress.cxx
+++ b/sd/qa/unit/uiimpress.cxx
@@ -9,6 +9,7 @@
#include <test/bootstrapfixture.hxx>
#include <unotest/macros_test.hxx>
+#include <LibreOfficeKit/LibreOfficeKitEnums.h>
#include <com/sun/star/beans/XPropertySet.hpp>
#include <com/sun/star/frame/Desktop.hpp>
@@ -29,6 +30,11 @@
#include <svx/xfillit0.hxx>
#include <svx/xflclit.hxx>
#include <svx/xflgrit.hxx>
+#include <SlideSorterViewShell.hxx>
+#include <SlideSorter.hxx>
+#include <controller/SlideSorterController.hxx>
+#include <controller/SlsClipboard.hxx>
+#include <controller/SlsPageSelector.hxx>
#include <svl/stritem.hxx>
#include <undo/undomanager.hxx>
#include <vcl/scheduler.hxx>
@@ -39,6 +45,7 @@
#include <drawdoc.hxx>
#include <sdpage.hxx>
#include <unomodel.hxx>
+#include <osl/thread.hxx>
using namespace ::com::sun::star;
@@ -53,6 +60,8 @@ public:
virtual void tearDown() override;
void checkCurrentPageNumber(sal_uInt16 nNum);
+ void insertStringToObject(sal_uInt16 nObj, const std::string& rStr);
+ sd::slidesorter::SlideSorterViewShell* getSlideSorterViewShell();
};
void SdUiImpressTest::setUp()
@@ -82,6 +91,55 @@ void SdUiImpressTest::checkCurrentPageNumber(sal_uInt16 nNum)
CPPUNIT_ASSERT_EQUAL(nNum, nPageNumber);
}
+void SdUiImpressTest::insertStringToObject(sal_uInt16 nObj, const std::string& rStr)
+{
+ auto pImpressDocument = dynamic_cast<SdXImpressDocument*>(mxComponent.get());
+ sd::ViewShell* pViewShell = pImpressDocument->GetDocShell()->GetViewShell();
+ SdPage* pPage = pViewShell->GetActualPage();
+ SdrObject* pShape = pPage->GetObj(nObj);
+ CPPUNIT_ASSERT_MESSAGE("No Shape", pShape);
+ SdrView* pView = pViewShell->GetView();
+ pView->MarkObj(pShape, pView->GetSdrPageView());
+
+ 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();
+ }
+
+ CPPUNIT_ASSERT(pView->IsTextEdit());
+
+ pImpressDocument->postKeyEvent(LOK_KEYEVENT_KEYINPUT, 0, awt::Key::ESCAPE);
+ pImpressDocument->postKeyEvent(LOK_KEYEVENT_KEYUP, 0, awt::Key::ESCAPE);
+ Scheduler::ProcessEventsToIdle();
+
+ CPPUNIT_ASSERT(!pView->IsTextEdit());
+}
+
+sd::slidesorter::SlideSorterViewShell* SdUiImpressTest::getSlideSorterViewShell()
+{
+ auto pXImpressDocument = dynamic_cast<SdXImpressDocument*>(mxComponent.get());
+ sd::ViewShell* pViewShell = pXImpressDocument->GetDocShell()->GetViewShell();
+ sd::slidesorter::SlideSorterViewShell* pSSVS = nullptr;
+ // Same as in sd/qa/unit/misc-tests.cxx
+ for (int i = 0; i < 1000; i++)
+ {
+ // Process all Tasks - slide sorter is created here
+ while (Scheduler::ProcessTaskScheduling())
+ ;
+ if ((pSSVS = sd::slidesorter::SlideSorterViewShell::GetSlideSorter(
+ pViewShell->GetViewShellBase()))
+ != nullptr)
+ break;
+ osl::Thread::wait(std::chrono::milliseconds(100));
+ }
+ CPPUNIT_ASSERT(pSSVS);
+ return pSSVS;
+}
+
CPPUNIT_TEST_FIXTURE(SdUiImpressTest, testTdf111522)
{
// Load the document and create two new windows.
@@ -213,6 +271,32 @@ CPPUNIT_TEST_FIXTURE(SdUiImpressTest, testTdf128651)
CPPUNIT_ASSERT_EQUAL_MESSAGE("Redo changes width", nUndoWidth, nRedoWidth);
}
+CPPUNIT_TEST_FIXTURE(SdUiImpressTest, testTdf100950)
+{
+ mxComponent = loadFromDesktop("private:factory/simpress",
+ "com.sun.star.presentation.PresentationDocument");
+
+ CPPUNIT_ASSERT(mxComponent.is());
+
+ dispatchCommand(mxComponent, ".uno:InsertPage", {});
+ Scheduler::ProcessEventsToIdle();
+
+ dispatchCommand(mxComponent, ".uno:InsertPage", {});
+ Scheduler::ProcessEventsToIdle();
+
+ insertStringToObject(0, "Test");
+
+ dispatchCommand(mxComponent, ".uno:Undo", {});
+ Scheduler::ProcessEventsToIdle();
+
+ sd::slidesorter::SlideSorterViewShell* pSSVS = getSlideSorterViewShell();
+ auto& rSSController = pSSVS->GetSlideSorter().GetController();
+ auto& rPageSelector = rSSController.GetPageSelector();
+
+ // Without the fix in place, this test would have failed here
+ CPPUNIT_ASSERT(rPageSelector.IsPageSelected(2));
+}
+
CPPUNIT_TEST_FIXTURE(SdUiImpressTest, testTdf129346)
{
mxComponent = loadFromDesktop("private:factory/simpress",
diff --git a/sd/source/ui/slidesorter/inc/controller/SlsPageSelector.hxx b/sd/source/ui/slidesorter/inc/controller/SlsPageSelector.hxx
index c61578954dae..5993618db157 100644
--- a/sd/source/ui/slidesorter/inc/controller/SlsPageSelector.hxx
+++ b/sd/source/ui/slidesorter/inc/controller/SlsPageSelector.hxx
@@ -91,7 +91,7 @@ public:
SlideSorterModel::GetPageDescriptor(i)->HasState(ST_Selected) is
included here to make this class more self contained.
*/
- bool IsPageSelected(int nPageIndex);
+ SD_DLLPUBLIC bool IsPageSelected(int nPageIndex);
/** Return whether the specified page is visible. This convenience
method is a substitute for
More information about the Libreoffice-commits
mailing list