summaryrefslogtreecommitdiff
path: root/svtools
diff options
context:
space:
mode:
authorHenry Castro <hcastro@collabora.com>2019-10-19 14:58:56 -0400
committerHenry Castro <hcastro@collabora.com>2019-10-23 02:38:33 +0200
commit7c6226bee72805db7f0e567ca9f06c786a7d0da2 (patch)
treee1c7a996d2527f136f87e8e9033133ef53df0f0f /svtools
parentd2b5ab3498a78c6d164a15b3bf2b947553ea2743 (diff)
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@gmail.com> Reviewed-by: Henry Castro <hcastro@collabora.com> Reviewed-on: https://gerrit.libreoffice.org/81354 Tested-by: Jenkins
Diffstat (limited to 'svtools')
-rw-r--r--svtools/CppunitTest_svtools_dialogs_test.mk2
-rw-r--r--svtools/Library_svt.mk1
-rw-r--r--svtools/inc/uitest/uiobject.hxx36
-rw-r--r--svtools/qa/unit/svtools-dialogs-test.cxx35
-rw-r--r--svtools/source/control/valueset.cxx6
-rw-r--r--svtools/source/uitest/uiobject.cxx66
6 files changed, 145 insertions, 1 deletions
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/Library_svt.mk b/svtools/Library_svt.mk
index 95486e42b328..c631190904b2 100644
--- a/svtools/Library_svt.mk
+++ b/svtools/Library_svt.mk
@@ -166,6 +166,7 @@ $(eval $(call gb_Library_add_exception_objects,svt,\
svtools/source/table/mousefunction \
svtools/source/table/cellvalueconversion \
svtools/source/table/tablegeometry \
+ svtools/source/uitest/uiobject \
svtools/source/uno/addrtempuno \
svtools/source/uno/fpicker \
svtools/source/uno/framestatuslistener \
diff --git a/svtools/inc/uitest/uiobject.hxx b/svtools/inc/uitest/uiobject.hxx
new file mode 100644
index 000000000000..c1a2ecf1f9f5
--- /dev/null
+++ b/svtools/inc/uitest/uiobject.hxx
@@ -0,0 +1,36 @@
+/* -*- 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>
+
+class ValueSet;
+
+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 3c4efa419426..897455b2ff23 100644
--- a/svtools/qa/unit/svtools-dialogs-test.cxx
+++ b/svtools/qa/unit/svtools-dialogs-test.cxx
@@ -10,6 +10,10 @@
#include <sal/config.h>
#include <test/screenshot_test.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;
@@ -30,9 +34,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();
};
@@ -56,6 +62,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 494583799287..462cd55e99d1 100644
--- a/svtools/source/control/valueset.cxx
+++ b/svtools/source/control/valueset.cxx
@@ -27,6 +27,7 @@
#include <vcl/settings.hxx>
#include <vcl/commandevent.hxx>
#include <vcl/virdev.hxx>
+#include <uitest/uiobject.hxx>
#include <com/sun/star/accessibility/AccessibleEventId.hpp>
#include <com/sun/star/lang/XComponent.hpp>
@@ -1455,6 +1456,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
new file mode 100644
index 000000000000..2b1933a19e21
--- /dev/null
+++ b/svtools/source/uitest/uiobject.cxx
@@ -0,0 +1,66 @@
+/* -*- 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 <uitest/uiobject.hxx>
+
+#include <svtools/valueset.hxx>
+
+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 "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: */