[Libreoffice-commits] core.git: Branch 'private/moggi/ui-test' - 3 commits - include/vcl uitest/calc_tests vcl/inc vcl/source

Markus Mohrhard markus.mohrhard at googlemail.com
Mon Mar 28 18:59:05 UTC 2016


 include/vcl/uitest/uiobject.hxx        |    1 
 uitest/calc_tests/create_range_name.py |   26 +++++++++++++++
 vcl/inc/uitest/uiobject_impl.hxx       |   21 ++++++++++++
 vcl/source/uitest/factory.cxx          |   14 ++++++++
 vcl/source/uitest/uiobject.cxx         |   57 ++++++++++++++++++++++++++++-----
 5 files changed, 111 insertions(+), 8 deletions(-)

New commits:
commit 98cd72a05cc9e6cdd5f4c9c9d76111a266294776
Author: Markus Mohrhard <markus.mohrhard at googlemail.com>
Date:   Mon Mar 28 20:58:13 2016 +0200

    add spinfield uitest support
    
    Change-Id: Id2dae42396beaa4818c60a57ac8aa76e4eddf24d

diff --git a/include/vcl/uitest/uiobject.hxx b/include/vcl/uitest/uiobject.hxx
index 55f5088..855cac3 100644
--- a/include/vcl/uitest/uiobject.hxx
+++ b/include/vcl/uitest/uiobject.hxx
@@ -25,6 +25,7 @@ enum class UIObjectType
     COMBOBOX,
     SPINBUTTON,
     TABPAGE,
+    SPINFIELD,
     UNKNOWN
 };
 
diff --git a/vcl/inc/uitest/uiobject_impl.hxx b/vcl/inc/uitest/uiobject_impl.hxx
index a23d57fc..4e86e34 100644
--- a/vcl/inc/uitest/uiobject_impl.hxx
+++ b/vcl/inc/uitest/uiobject_impl.hxx
@@ -16,6 +16,7 @@
 class TabPage;
 class ComboBox;
 class SpinButton;
+class SpinField;
 
 class WindowUIObject : public UIObject
 {
@@ -206,4 +207,24 @@ protected:
     virtual OUString get_name() const override;
 };
 
+class SpinFieldUIObject : public EditUIObject
+{
+    VclPtr<SpinField> mxSpinField;
+
+public:
+
+    SpinFieldUIObject(VclPtr<SpinField> xEdit);
+
+    virtual void execute(const OUString& rAction,
+            const StringMap& rParameters) override;
+
+    virtual StringMap get_state() override;
+
+    virtual UIObjectType get_type() const override;
+
+protected:
+
+    virtual OUString get_name() const override;
+};
+
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/vcl/source/uitest/factory.cxx b/vcl/source/uitest/factory.cxx
index 6cf1516..beec042 100644
--- a/vcl/source/uitest/factory.cxx
+++ b/vcl/source/uitest/factory.cxx
@@ -14,6 +14,7 @@
 #include <vcl/lstbox.hxx>
 #include <vcl/combobox.hxx>
 #include <vcl/spin.hxx>
+#include <vcl/spinfld.hxx>
 
 std::unique_ptr<UIObject> UITestWrapperFactory::createObject(vcl::Window* pWindow)
 {
@@ -98,6 +99,19 @@ std::unique_ptr<UIObject> UITestWrapperFactory::createObject(vcl::Window* pWindo
             return std::unique_ptr<UIObject>(new SpinUIObject(pSpinButton));
         }
         break;
+        case WINDOW_SPINFIELD:
+        case WINDOW_PATTERNFIELD:
+        case WINDOW_NUMERICFIELD:
+        case WINDOW_METRICFIELD:
+        case WINDOW_CURRENCYFIELD:
+        case WINDOW_DATEFIELD:
+        case WINDOW_TIMEFIELD:
+        {
+            SpinField* pSpinField = dynamic_cast<SpinField*>(pWindow);
+            assert(pSpinField);
+            return std::unique_ptr<UIObject>(new SpinFieldUIObject(pSpinField));
+        }
+        break;
         default:
         break;
     }
diff --git a/vcl/source/uitest/uiobject.cxx b/vcl/source/uitest/uiobject.cxx
index 209fb20..0d9c97a 100644
--- a/vcl/source/uitest/uiobject.cxx
+++ b/vcl/source/uitest/uiobject.cxx
@@ -15,6 +15,7 @@
 #include <vcl/lstbox.hxx>
 #include <vcl/combobox.hxx>
 #include <vcl/spin.hxx>
+#include <vcl/spinfld.hxx>
 
 #include <rtl/ustrbuf.hxx>
 
@@ -602,4 +603,41 @@ OUString SpinUIObject::get_name() const
 {
     return OUString("SpinUIObject");
 }
+
+SpinFieldUIObject::SpinFieldUIObject(VclPtr<SpinField> xSpinField):
+    EditUIObject(xSpinField),
+    mxSpinField(xSpinField)
+{
+}
+
+void SpinFieldUIObject::execute(const OUString& rAction,
+        const StringMap& /*rParameters*/)
+{
+    if (rAction == "UP")
+    {
+        mxSpinField->Up();
+    }
+    else if (rAction == "DOWN")
+    {
+        mxSpinField->Down();
+    }
+}
+
+StringMap SpinFieldUIObject::get_state()
+{
+    StringMap aMap = EditUIObject::get_state();
+
+    return aMap;
+}
+
+UIObjectType SpinFieldUIObject::get_type() const
+{
+    return UIObjectType::SPINFIELD;
+}
+
+OUString SpinFieldUIObject::get_name() const
+{
+    return OUString("SpinFieldUIObject");
+}
+
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
commit 3b431495bcf8a2b9ea73571e342afb409ec605d5
Author: Markus Mohrhard <markus.mohrhard at googlemail.com>
Date:   Mon Mar 28 20:57:36 2016 +0200

    add demo creating a local range name
    
    Change-Id: Ieb908e58b9ab4daed7d03279fbc66ddea2435cb3

diff --git a/uitest/calc_tests/create_range_name.py b/uitest/calc_tests/create_range_name.py
index 9019753..5900788 100644
--- a/uitest/calc_tests/create_range_name.py
+++ b/uitest/calc_tests/create_range_name.py
@@ -39,4 +39,30 @@ def create_range_name(xContext):
     xAddBtn = xAddNameDlg.getChild("add")
     xAddBtn.executeAction("CLICK", tuple())
 
+def create_local_range_name(xContext):
+    xUITest = xContext.ServiceManager.createInstanceWithContext(
+            "org.libreoffice.uitest.UITest", xContext)
+
+    ui_test = UITest(xUITest, xContext)
+
+    ui_test.create_doc_in_start_center("calc")
+
+    ui_test.execute_modeless_dialog_through_command(".uno:AddName")
+
+    xAddNameDlg = xUITest.getTopFocusWindow()
+
+    props = {"TEXT": "simpleRangeName"}
+    actionProps = mkPropertyValues(props)
+
+    xEdit = xAddNameDlg.getChild("edit")
+    xEdit.executeAction("TYPE", actionProps)
+
+    xScope = xAddNameDlg.getChild("scope")
+    props = {"POS": "1"}
+    scopeProps = mkPropertyValues(props)
+    xScope.executeAction("SELECT", scopeProps)
+
+    xAddBtn = xAddNameDlg.getChild("add")
+    xAddBtn.executeAction("CLICK", tuple())
+
 # vim:set shiftwidth=4 softtabstop=4 expandtab: */
commit 24a80872b4c6eec5b1f24b4d0b04f8a5212c61aa
Author: Markus Mohrhard <markus.mohrhard at googlemail.com>
Date:   Mon Mar 28 19:07:07 2016 +0200

    fix warnings
    
    Change-Id: I490b40ef80408ee393cb0664fb4eceeb8e48bf1b

diff --git a/vcl/source/uitest/uiobject.cxx b/vcl/source/uitest/uiobject.cxx
index 737fa92..209fb20 100644
--- a/vcl/source/uitest/uiobject.cxx
+++ b/vcl/source/uitest/uiobject.cxx
@@ -183,14 +183,14 @@ void WindowUIObject::execute(const OUString& rAction,
     }
     else if (rAction == "TYPE")
     {
-        auto itr = rParameters.find("TEXT");
-        if (itr == rParameters.end())
+        auto it = rParameters.find("TEXT");
+        if (it == rParameters.end())
         {
             SAL_WARN("vcl.uitest", "missing parameter TEXT to action TYPE");
             return;
         }
 
-        const OUString& rText = itr->second;
+        const OUString& rText = it->second;
         auto aKeyEvents = generate_key_events_from_text(rText);
         for (auto itr = aKeyEvents.begin(), itrEnd = aKeyEvents.end();
                 itr != itrEnd; ++itr)
@@ -353,14 +353,14 @@ void EditUIObject::execute(const OUString& rAction,
     {
         if (rParameters.find("TEXT") != rParameters.end())
         {
-            auto itr = rParameters.find("TEXT");
-            if (itr == rParameters.end())
+            auto it = rParameters.find("TEXT");
+            if (it == rParameters.end())
             {
                 SAL_WARN("vcl.uitest", "missing parameter TEXT to action SET");
                 return;
             }
 
-            const OUString& rText = rParameters.find("TEXT")->second;
+            const OUString& rText = it->second;
             auto aKeyEvents = generate_key_events_from_text(rText);
             for (auto itr = aKeyEvents.begin(), itrEnd = aKeyEvents.end();
                     itr != itrEnd; ++itr)
@@ -447,9 +447,12 @@ TabPageUIObject::TabPageUIObject(VclPtr<TabPage> xTabPage):
 }
 
 void TabPageUIObject::execute(const OUString& rAction,
-        const StringMap& rParameters)
+        const StringMap& /*rParameters*/)
 {
+    if (rAction == "SELECT")
+    {
 
+    }
 }
 
 StringMap TabPageUIObject::get_state()
@@ -568,7 +571,7 @@ SpinUIObject::SpinUIObject(VclPtr<SpinButton> xSpinButton):
 }
 
 void SpinUIObject::execute(const OUString& rAction,
-        const StringMap& rParameters)
+        const StringMap& /*rParameters*/)
 {
     if (rAction == "UP")
     {


More information about the Libreoffice-commits mailing list