tdf#131715: uitest: add wrapper for roadmapwizard

Change-Id: I8e8999b7862ad13cb6d3328e05abe120da3ed5c0
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/94759
Tested-by: Jenkins
Reviewed-by: Xisco Faulí <xiscofauli@libreoffice.org>
This commit is contained in:
Xisco Fauli 2020-05-24 17:33:46 +02:00 committed by Xisco Faulí
parent 2d1f1a1c84
commit de623b59a9
5 changed files with 116 additions and 0 deletions

View file

@ -0,0 +1,28 @@
#
# 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/.
from uitest.framework import UITestCase
from uitest.uihelper.common import get_state_as_dict
from uitest.uihelper.common import select_pos
class tdf131715(UITestCase):
def test_tdf131715(self):
self.ui_test.create_doc_in_start_center("calc")
self.ui_test.execute_dialog_through_command(".uno:InsertObjectChart")
xChartDlg = self.xUITest.getTopFocusWindow()
xWizard = xChartDlg.getChild('Wizard')
for i in range(10):
#without the fix in place, it would crash here
select_pos(xWizard, "2")
self.assertEqual(get_state_as_dict(xWizard)['CurrentStep'], "2")
xOkBtn = xChartDlg.getChild("finish")
self.ui_test.close_dialog_through_button(xOkBtn)
self.ui_test.close_doc()

View file

@ -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 <memory>
#include <vcl/uitest/uiobject.hxx>
#include "wizdlg.hxx"
class RoadmapWizard;
class RoadmapWizardUIObject final : public WindowUIObject
{
VclPtr<vcl::RoadmapWizard> mxRoadmapWizard;
public:
RoadmapWizardUIObject(const VclPtr<vcl::RoadmapWizard>& xRoadmapWizard);
virtual ~RoadmapWizardUIObject() override;
virtual StringMap get_state() override;
virtual void execute(const OUString& rAction, const StringMap& rParameters) override;
static std::unique_ptr<UIObject> create(vcl::Window* pWindow);
private:
virtual OUString get_name() const override;
};
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */

View file

@ -149,6 +149,8 @@ namespace vcl
void SetItemSelectHdl( const Link<LinkParamNone*,void>& _rHdl );
void ShowRoadmap(bool bShow);
FactoryFunction GetUITestFactory() const override;
protected:
/// to override to create new pages

View file

@ -31,6 +31,7 @@
#include <set>
#include "wizimpldata.hxx"
#include <uiobject-internal.hxx>
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: */

View file

@ -27,6 +27,7 @@
#include <vcl/edit.hxx>
#include <vcl/vclmedit.hxx>
#include <vcl/uitest/logger.hxx>
#include <uiobject-internal.hxx>
#include <comphelper/string.hxx>
#include <comphelper/lok.hxx>
@ -1455,6 +1456,51 @@ std::unique_ptr<UIObject> TabControlUIObject::create(vcl::Window* pWindow)
return std::unique_ptr<UIObject>(new TabControlUIObject(pTabControl));
}
RoadmapWizardUIObject::RoadmapWizardUIObject(const VclPtr<vcl::RoadmapWizard>& 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<UIObject> RoadmapWizardUIObject::create(vcl::Window* pWindow)
{
vcl::RoadmapWizard* pRoadmapWizard = dynamic_cast<vcl::RoadmapWizard*>(pWindow);
assert(pRoadmapWizard);
return std::unique_ptr<UIObject>(new RoadmapWizardUIObject(pRoadmapWizard));
}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */