From de623b59a981e3d6a43b410a9216ec0acadc9ed1 Mon Sep 17 00:00:00 2001 From: Xisco Fauli Date: Sun, 24 May 2020 17:33:46 +0200 Subject: tdf#131715: uitest: add wrapper for roadmapwizard MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Change-Id: I8e8999b7862ad13cb6d3328e05abe120da3ed5c0 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/94759 Tested-by: Jenkins Reviewed-by: Xisco FaulĂ­ --- vcl/inc/uiobject-internal.hxx | 34 ++++++++++++++++++++++++++ vcl/inc/wizdlg.hxx | 2 ++ vcl/source/control/roadmapwizard.cxx | 6 +++++ vcl/source/uitest/uiobject.cxx | 46 ++++++++++++++++++++++++++++++++++++ 4 files changed, 88 insertions(+) create mode 100644 vcl/inc/uiobject-internal.hxx (limited to 'vcl') diff --git a/vcl/inc/uiobject-internal.hxx b/vcl/inc/uiobject-internal.hxx new file mode 100644 index 000000000000..accecb2e8f08 --- /dev/null +++ b/vcl/inc/uiobject-internal.hxx @@ -0,0 +1,34 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + */ + +#include +#include +#include "wizdlg.hxx" + +class RoadmapWizard; + +class RoadmapWizardUIObject final : public WindowUIObject +{ + VclPtr mxRoadmapWizard; + +public: + RoadmapWizardUIObject(const VclPtr& xRoadmapWizard); + virtual ~RoadmapWizardUIObject() override; + + virtual StringMap get_state() override; + + virtual void execute(const OUString& rAction, const StringMap& rParameters) override; + + static std::unique_ptr create(vcl::Window* pWindow); + +private: + virtual OUString get_name() const override; +}; + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/vcl/inc/wizdlg.hxx b/vcl/inc/wizdlg.hxx index 946af0530866..2c82b3ab8dd3 100644 --- a/vcl/inc/wizdlg.hxx +++ b/vcl/inc/wizdlg.hxx @@ -149,6 +149,8 @@ namespace vcl void SetItemSelectHdl( const Link& _rHdl ); void ShowRoadmap(bool bShow); + FactoryFunction GetUITestFactory() const override; + protected: /// to override to create new pages diff --git a/vcl/source/control/roadmapwizard.cxx b/vcl/source/control/roadmapwizard.cxx index bd3078e52c8a..3e887ad922b7 100644 --- a/vcl/source/control/roadmapwizard.cxx +++ b/vcl/source/control/roadmapwizard.cxx @@ -31,6 +31,7 @@ #include #include "wizimpldata.hxx" +#include namespace vcl { @@ -842,6 +843,11 @@ namespace vcl return m_xRoadmapImpl->pRoadmap->GetCurrentRoadmapItemID(); } + FactoryFunction RoadmapWizard::GetUITestFactory() const + { + return RoadmapWizardUIObject::create; + } + } // namespace vcl /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/vcl/source/uitest/uiobject.cxx b/vcl/source/uitest/uiobject.cxx index 22496e2375a0..5fb0a5c0174e 100644 --- a/vcl/source/uitest/uiobject.cxx +++ b/vcl/source/uitest/uiobject.cxx @@ -27,6 +27,7 @@ #include #include #include +#include #include #include @@ -1455,6 +1456,51 @@ std::unique_ptr TabControlUIObject::create(vcl::Window* pWindow) return std::unique_ptr(new TabControlUIObject(pTabControl)); } +RoadmapWizardUIObject::RoadmapWizardUIObject(const VclPtr& xRoadmapWizard): + WindowUIObject(xRoadmapWizard), + mxRoadmapWizard(xRoadmapWizard) +{ +} + +RoadmapWizardUIObject::~RoadmapWizardUIObject() +{ +} +void RoadmapWizardUIObject::execute(const OUString& rAction, + const StringMap& rParameters) +{ + if (rAction == "SELECT") + { + if (rParameters.find("POS") != rParameters.end()) + { + auto itr = rParameters.find("POS"); + sal_uInt32 nPos = itr->second.toUInt32(); + mxRoadmapWizard->SelectRoadmapItemByID(nPos); + } + } + else + WindowUIObject::execute(rAction, rParameters); +} + +StringMap RoadmapWizardUIObject::get_state() +{ + StringMap aMap = WindowUIObject::get_state(); + + aMap["CurrentStep"] = OUString::number(mxRoadmapWizard->GetCurrentRoadmapItemID()); + + return aMap; +} + +OUString RoadmapWizardUIObject::get_name() const +{ + return "RoadmapWizardUIObject"; +} + +std::unique_ptr RoadmapWizardUIObject::create(vcl::Window* pWindow) +{ + vcl::RoadmapWizard* pRoadmapWizard = dynamic_cast(pWindow); + assert(pRoadmapWizard); + return std::unique_ptr(new RoadmapWizardUIObject(pRoadmapWizard)); +} /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ -- cgit