[Libreoffice-commits] core.git: Branch 'distro/collabora/cp-6.2' - include/svtools svtools/CppunitTest_svtools_dialogs_test.mk svtools/inc svtools/qa svtools/source
Henry Castro (via logerrit)
logerrit at kemper.freedesktop.org
Tue Oct 22 16:31:33 UTC 2019
include/svtools/valueset.hxx | 1
svtools/CppunitTest_svtools_dialogs_test.mk | 2
svtools/inc/uitest/uiobject.hxx | 25 ++++++++++++
svtools/qa/unit/svtools-dialogs-test.cxx | 35 ++++++++++++++++
svtools/source/control/valueset.cxx | 6 ++
svtools/source/uitest/uiobject.cxx | 58 ++++++++++++++++++++++++++++
6 files changed, 126 insertions(+), 1 deletion(-)
New commits:
commit 76b4615a44bcbf1fe3d6dc4c70d2abbe687e3e81
Author: Henry Castro <hcastro at collabora.com>
AuthorDate: Sat Oct 19 14:58:56 2019 -0400
Commit: Henry Castro <hcastro at collabora.com>
CommitDate: Tue Oct 22 18:30:50 2019 +0200
lok: svtools: create ValueSetUIObject class
The ValueSet control is used in Layouts panel inside Sidebar of the
impress document. Once the LO server sends the UI data to the client side
that is transformed to mobile view using Mobile Wizard framework.
The loleaflet client side has to send commands for the user interactions
like to touch an item.
e.g. Send "WindowId SELECT ID=300"
The unit test simulates the scenario, so the ValueSet control executes
the action.
Change-Id: Ib6ec5db6ce2777e819f81a9dae74c4641bb7053b
Reviewed-on: https://gerrit.libreoffice.org/81141
Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoffice at gmail.com>
Reviewed-by: Henry Castro <hcastro at collabora.com>
diff --git a/include/svtools/valueset.hxx b/include/svtools/valueset.hxx
index 7e05633314b2..ec7b3ba79eda 100644
--- a/include/svtools/valueset.hxx
+++ b/include/svtools/valueset.hxx
@@ -297,6 +297,7 @@ public:
virtual void StateChanged( StateChangedType nStateChange ) override;
virtual void DataChanged( const DataChangedEvent& rDCEvt ) override;
virtual boost::property_tree::ptree DumpAsPropertyTree() override;
+ virtual FactoryFunction GetUITestFactory() const override;
virtual void Select();
virtual void UserDraw( const UserDrawEvent& rUDEvt );
diff --git a/svtools/CppunitTest_svtools_dialogs_test.mk b/svtools/CppunitTest_svtools_dialogs_test.mk
index 28c4db4742ea..70f8a00e4bf7 100644
--- a/svtools/CppunitTest_svtools_dialogs_test.mk
+++ b/svtools/CppunitTest_svtools_dialogs_test.mk
@@ -17,7 +17,7 @@ $(eval $(call gb_CppunitTest_add_exception_objects,svtools_dialogs_test, \
$(eval $(call gb_CppunitTest_use_sdk_api,svtools_dialogs_test))
-$(eval $(call gb_CppunitTest_set_include,desktop_dialogs_test,\
+$(eval $(call gb_CppunitTest_set_include,svtools_dialogs_test,\
-I$(SRCDIR)/svtools/source/inc \
-I$(SRCDIR)/svtools/inc \
$$(INCLUDE) \
diff --git a/svtools/inc/uitest/uiobject.hxx b/svtools/inc/uitest/uiobject.hxx
index 16a137da7c7c..2bb82dabd5f1 100644
--- a/svtools/inc/uitest/uiobject.hxx
+++ b/svtools/inc/uitest/uiobject.hxx
@@ -11,6 +11,7 @@
#include <vcl/uitest/uiobject.hxx>
class SvSimpleTable;
+class ValueSet;
class SimpleTableUIObject : public TreeListUIObject
{
@@ -28,4 +29,28 @@ private:
VclPtr<SvSimpleTable> mxTable;
};
+class ValueSetUIObject : public WindowUIObject
+{
+ private:
+ VclPtr<ValueSet> mxValueSet;
+
+ public:
+
+ ValueSetUIObject(const VclPtr<ValueSet>& xValueSet);
+ virtual ~ValueSetUIObject() override;
+
+ virtual void execute(const OUString& rAction,
+ const StringMap& rParameters) override;
+
+ virtual StringMap get_state() override;
+
+ static std::unique_ptr<UIObject> create(vcl::Window* pWindow);
+
+ virtual OUString get_action(VclEventId nEvent) const override;
+
+ protected:
+
+ virtual OUString get_name() const override;
+};
+
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/svtools/qa/unit/svtools-dialogs-test.cxx b/svtools/qa/unit/svtools-dialogs-test.cxx
index 35d04bc0c379..692453335794 100644
--- a/svtools/qa/unit/svtools-dialogs-test.cxx
+++ b/svtools/qa/unit/svtools-dialogs-test.cxx
@@ -13,6 +13,10 @@
#include <osl/file.hxx>
#include <sfx2/app.hxx>
#include <vcl/abstdlg.hxx>
+#include <vcl/scheduler.hxx>
+#include <vcl/wrkwin.hxx>
+#include <uitest/uiobject.hxx>
+#include <svtools/valueset.hxx>
using namespace ::com::sun::star;
@@ -33,9 +37,11 @@ public:
// try to open a dialog
void openAnyDialog();
+ void testValueSetControl();
CPPUNIT_TEST_SUITE(SvtoolsDialogsTest);
CPPUNIT_TEST(openAnyDialog);
+ CPPUNIT_TEST(testValueSetControl);
CPPUNIT_TEST_SUITE_END();
};
@@ -59,6 +65,35 @@ void SvtoolsDialogsTest::openAnyDialog()
processDialogBatchFile("svtools/qa/unit/data/svtools-dialogs-test.txt");
}
+void SvtoolsDialogsTest::testValueSetControl()
+{
+ VclPtr<WorkWindow> pWorkWindow = VclPtr<WorkWindow>::Create(nullptr, WB_APP | WB_STDWORK);
+ VclPtr<ValueSet> pValueSet = VclPtr<ValueSet>::Create(pWorkWindow, WB_ITEMBORDER);
+ pValueSet->InsertItem(100, 0);
+ pValueSet->InsertItem(200, 1);
+ pValueSet->InsertItem(300, 2);
+ pValueSet->Show();
+ pWorkWindow->Show();
+ Scheduler::ProcessEventsToIdle();
+
+ CPPUNIT_ASSERT(pValueSet->IsEnabled());
+ CPPUNIT_ASSERT(pValueSet->IsReallyVisible());
+ CPPUNIT_ASSERT_EQUAL(false, pValueSet->IsItemSelected(300));
+ {
+ std::unique_ptr<UIObject> pUIObject = pValueSet->GetUITestFactory()(pValueSet.get());
+ CPPUNIT_ASSERT(pUIObject);
+
+ StringMap aMap;
+ aMap["ID"] = "300";
+
+ pUIObject->execute("SELECT", aMap);
+ }
+ CPPUNIT_ASSERT_EQUAL(true, pValueSet->IsItemSelected(300));
+
+ pValueSet->disposeOnce();
+ pWorkWindow->disposeOnce();
+}
+
CPPUNIT_TEST_SUITE_REGISTRATION(SvtoolsDialogsTest);
CPPUNIT_PLUGIN_IMPLEMENT();
diff --git a/svtools/source/control/valueset.cxx b/svtools/source/control/valueset.cxx
index 73a91e130b11..d58decd8f177 100644
--- a/svtools/source/control/valueset.cxx
+++ b/svtools/source/control/valueset.cxx
@@ -25,6 +25,7 @@
#include <vcl/help.hxx>
#include <vcl/settings.hxx>
#include <vcl/commandevent.hxx>
+#include <uitest/uiobject.hxx>
#include <com/sun/star/accessibility/AccessibleEventObject.hpp>
#include <com/sun/star/accessibility/AccessibleEventId.hpp>
@@ -1459,6 +1460,11 @@ boost::property_tree::ptree ValueSet::DumpAsPropertyTree()
return aTree;
}
+FactoryFunction ValueSet::GetUITestFactory() const
+{
+ return ValueSetUIObject::create;
+}
+
void ValueSet::Select()
{
maSelectHdl.Call( this );
diff --git a/svtools/source/uitest/uiobject.cxx b/svtools/source/uitest/uiobject.cxx
index 3c0a34b26a8d..4d78e618dad2 100644
--- a/svtools/source/uitest/uiobject.cxx
+++ b/svtools/source/uitest/uiobject.cxx
@@ -12,6 +12,7 @@
#include <vcl/treelistbox.hxx>
#include <svtools/simptabl.hxx>
+#include <svtools/valueset.hxx>
namespace {
@@ -48,4 +49,61 @@ std::unique_ptr<UIObject> SimpleTableUIObject::createFromContainer(vcl::Window*
return std::unique_ptr<UIObject>(new SimpleTableUIObject(pTableContainer->GetTable()));
}
+ValueSetUIObject::ValueSetUIObject(const VclPtr<ValueSet>& xValueSet):
+ WindowUIObject(xValueSet),
+ mxValueSet(xValueSet)
+{
+}
+
+ValueSetUIObject::~ValueSetUIObject()
+{
+}
+
+void ValueSetUIObject::execute(const OUString& rAction,
+ const StringMap& rParameters)
+{
+ if (!mxValueSet->IsEnabled() || !mxValueSet->IsReallyVisible())
+ return;
+
+ if (rAction == "SELECT")
+ {
+ if (rParameters.find("ID") != rParameters.end())
+ {
+ auto aPos = rParameters.find("ID");
+ OUString aVal = aPos->second;
+ sal_Int32 nPos = aVal.toInt32();
+ mxValueSet->SelectItem(nPos);
+ mxValueSet->Select();
+ }
+ }
+ else
+ WindowUIObject::execute(rAction, rParameters);
+}
+
+StringMap ValueSetUIObject::get_state()
+{
+ StringMap aMap = WindowUIObject::get_state();
+ aMap["EntryCount"] = OUString::number(mxValueSet->GetItemCount());
+
+ return aMap;
+}
+
+OUString ValueSetUIObject::get_name() const
+{
+ return OUString("ValueSetUIObject");
+}
+
+OUString ValueSetUIObject::get_action(VclEventId /*nEvent*/) const
+{
+ // No action for this control that trigger item selection after mouse tracking end
+ return OUString();
+}
+
+std::unique_ptr<UIObject> ValueSetUIObject::create(vcl::Window* pWindow)
+{
+ ValueSet* pValueSet = dynamic_cast<ValueSet*>(pWindow);
+ assert(pValueSet);
+ return std::unique_ptr<UIObject>(new ValueSetUIObject(pValueSet));
+}
+
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
More information about the Libreoffice-commits
mailing list