sw/qa/uitest/writer_tests/tdf129796.py |   76 +++++++++++++++++++++++++++++++++
 sw/source/ui/fldui/flddb.cxx           |    1 
 sw/source/ui/fldui/flddinf.cxx         |    1 
 sw/source/ui/fldui/flddok.cxx          |    3 +
 sw/source/ui/fldui/fldfunc.cxx         |    2 
 sw/source/ui/fldui/fldref.cxx          |    3 +
 sw/source/ui/fldui/fldvar.cxx          |    4 +
 sw/source/uibase/inc/condedit.hxx      |    3 +
 sw/source/uibase/inc/numfmtlb.hxx      |    4 +
 9 files changed, 97 insertions(+)

New commits:
commit 045665d7760f14b36f9971f8b736d5dee6189b0a
Author:     Xisco Fauli <[email protected]>
AuthorDate: Thu Dec 16 19:33:44 2021 +0100
Commit:     Xisco Fauli <[email protected]>
CommitDate: Thu Dec 16 22:27:11 2021 +0100

    tdf#129796: sw: Add UItest
    
    Change-Id: I0eb3aa6a5550b1c49e88b0aa3195d3aae5d6396b
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/126960
    Tested-by: Jenkins
    Reviewed-by: Xisco Fauli <[email protected]>

diff --git a/sw/qa/uitest/writer_tests/tdf129796.py 
b/sw/qa/uitest/writer_tests/tdf129796.py
new file mode 100644
index 000000000000..fb764f7aec79
--- /dev/null
+++ b/sw/qa/uitest/writer_tests/tdf129796.py
@@ -0,0 +1,76 @@
+# -*- tab-width: 4; indent-tabs-mode: nil; py-indent-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/.
+#
+
+from uitest.framework import UITestCase
+from libreoffice.uno.propertyvalue import mkPropertyValues
+from uitest.uihelper.common import get_state_as_dict
+from uitest.uihelper.common import select_pos
+
+class Tdf129796(UITestCase):
+
+    def test_tdf129796(self):
+
+        with self.ui_test.create_doc_in_start_center("writer") as writer_doc:
+
+            with 
self.ui_test.execute_modeless_dialog_through_command(".uno:InsertField", 
close_button="cancel") as xDialog:
+                xTab = xDialog.getChild("tabcontrol")
+                select_pos(xTab, "4")
+
+                xType = xDialog.getChild("type-var")
+                xType.getChild('8').executeAction("SELECT", tuple())
+                self.assertEqual("User Field", 
get_state_as_dict(xType)['SelectEntryText'])
+
+                xNumFormat = xDialog.getChild("numformat-var")
+                xNumFormat.getChild('0').executeAction("SELECT", tuple())
+                self.assertEqual("Text", 
get_state_as_dict(xNumFormat)['SelectEntryText'])
+
+                xName = xDialog.getChild("name-var")
+                xName.executeAction("TYPE", mkPropertyValues({"TEXT": 
"MyField"}))
+
+                xValue = xDialog.getChild("value-var")
+                xValue.executeAction("TYPE", mkPropertyValues({"TEXT": "abc"}))
+
+                xApplyBtn = xDialog.getChild("apply")
+                xApplyBtn.executeAction("CLICK", ())
+
+                xType.getChild('4').executeAction("SELECT", tuple())
+                self.assertEqual("Input field", 
get_state_as_dict(xType)['SelectEntryText'])
+
+                self.assertEqual("MyField", 
get_state_as_dict(xDialog.getChild("select-var"))["SelectEntryText"])
+
+                xValue.executeAction("TYPE", mkPropertyValues({"TEXT": "ref"}))
+
+                xOkBtn = xDialog.getChild("ok")
+                with 
self.ui_test.execute_blocking_action(xOkBtn.executeAction, args=('CLICK', ())) 
as xFieldDialog:
+                    xName = xFieldDialog.getChild("name")
+                    self.assertEqual("ref", get_state_as_dict(xName)['Text'])
+                    xText = xFieldDialog.getChild("text")
+                    self.assertEqual("abc", get_state_as_dict(xText)['Text'])
+
+            textfields = writer_doc.getTextFields()
+            textfield = textfields.createEnumeration().nextElement()
+            self.assertEqual('MyField', textfield.Content)
+            
self.assertTrue(textfield.supportsService("com.sun.star.text.TextField.InputUser"))
+
+            # Move the cursor to the field
+            self.xUITest.executeCommand(".uno:GoLeft")
+
+            with 
self.ui_test.execute_dialog_through_command(".uno:FieldDialog") as xDialog:
+                xType = xDialog.getChild("type-var")
+                xNumFormat = xDialog.getChild("numformat-var")
+                xValue = xDialog.getChild("value-var")
+                xName = xDialog.getChild("name-var")
+
+                # Without the fix in place, this test would have crashed here
+                self.assertEqual("ref", get_state_as_dict(xValue)['Text'])
+                self.assertEqual("Input field", 
get_state_as_dict(xType)['SelectEntryText'])
+                self.assertEqual("General", 
get_state_as_dict(xNumFormat)['SelectEntryText'])
+                self.assertEqual("MyField", get_state_as_dict(xName)['Text'])
+
+# vim: set shiftwidth=4 softtabstop=4 expandtab:
diff --git a/sw/source/ui/fldui/flddb.cxx b/sw/source/ui/fldui/flddb.cxx
index 5bc1c8d77645..f65abe0bdf7a 100644
--- a/sw/source/ui/fldui/flddb.cxx
+++ b/sw/source/ui/fldui/flddb.cxx
@@ -65,6 +65,7 @@ SwFieldDBPage::SwFieldDBPage(weld::Container* pPage, 
weld::DialogController* pCo
 
     // uitests
     m_xTypeLB->set_buildable_name(m_xTypeLB->get_buildable_name() + "-db");
+    m_xNumFormatLB->set_buildable_name(m_xNumFormatLB->get_buildable_name() + 
"-db");
 }
 
 SwFieldDBPage::~SwFieldDBPage()
diff --git a/sw/source/ui/fldui/flddinf.cxx b/sw/source/ui/fldui/flddinf.cxx
index aa5536d3eff8..b35a12b77516 100644
--- a/sw/source/ui/fldui/flddinf.cxx
+++ b/sw/source/ui/fldui/flddinf.cxx
@@ -80,6 +80,7 @@ SwFieldDokInfPage::SwFieldDokInfPage(weld::Container* pPage, 
weld::DialogControl
 
     // uitests
     m_xTypeTLB->set_buildable_name(m_xTypeTLB->get_buildable_name() + 
"-docinf");
+    m_xSelectionLB->set_buildable_name(m_xSelectionLB->get_buildable_name() + 
"-docinf");
 }
 
 SwFieldDokInfPage::~SwFieldDokInfPage()
diff --git a/sw/source/ui/fldui/flddok.cxx b/sw/source/ui/fldui/flddok.cxx
index b977568c71cd..3a4288fdcfcb 100644
--- a/sw/source/ui/fldui/flddok.cxx
+++ b/sw/source/ui/fldui/flddok.cxx
@@ -71,6 +71,9 @@ SwFieldDokPage::SwFieldDokPage(weld::Container* pPage, 
weld::DialogController* p
 
     // uitests
     m_xTypeLB->set_buildable_name(m_xTypeLB->get_buildable_name() + "-doc");
+    m_xValueED->set_buildable_name(m_xValueED->get_buildable_name() + "-doc");
+    m_xNumFormatLB->set_buildable_name(m_xNumFormatLB->get_buildable_name() + 
"-doc");
+    m_xSelectionLB->set_buildable_name(m_xSelectionLB->get_buildable_name() + 
"-doc");
 }
 
 SwFieldDokPage::~SwFieldDokPage()
diff --git a/sw/source/ui/fldui/fldfunc.cxx b/sw/source/ui/fldui/fldfunc.cxx
index 346327d1e026..9571d60ac5de 100644
--- a/sw/source/ui/fldui/fldfunc.cxx
+++ b/sw/source/ui/fldui/fldfunc.cxx
@@ -82,6 +82,8 @@ SwFieldFuncPage::SwFieldFuncPage(weld::Container* pPage, 
weld::DialogController*
 
     // uitests
     m_xTypeLB->set_buildable_name(m_xTypeLB->get_buildable_name() + "-func");
+    m_xValueED->set_buildable_name(m_xValueED->get_buildable_name() + "-func");
+    m_xSelectionLB->set_buildable_name(m_xSelectionLB->get_buildable_name() + 
"-func");
 }
 
 SwFieldFuncPage::~SwFieldFuncPage()
diff --git a/sw/source/ui/fldui/fldref.cxx b/sw/source/ui/fldui/fldref.cxx
index 0c9b10eae16b..0b18e0d41e89 100644
--- a/sw/source/ui/fldui/fldref.cxx
+++ b/sw/source/ui/fldui/fldref.cxx
@@ -105,6 +105,9 @@ SwFieldRefPage::SwFieldRefPage(weld::Container* pPage, 
weld::DialogController* p
 
     // uitests
     m_xTypeLB->set_buildable_name(m_xTypeLB->get_buildable_name() + "-ref");
+    m_xNameED->set_buildable_name(m_xNameED->get_buildable_name() + "-ref");
+    m_xValueED->set_buildable_name(m_xValueED->get_buildable_name() + "-ref");
+    m_xSelectionLB->set_buildable_name(m_xSelectionLB->get_buildable_name() + 
"-ref");
 }
 
 SwFieldRefPage::~SwFieldRefPage()
diff --git a/sw/source/ui/fldui/fldvar.cxx b/sw/source/ui/fldui/fldvar.cxx
index b07f3d117837..22f0f5e596a5 100644
--- a/sw/source/ui/fldui/fldvar.cxx
+++ b/sw/source/ui/fldui/fldvar.cxx
@@ -82,6 +82,10 @@ SwFieldVarPage::SwFieldVarPage(weld::Container* pPage, 
weld::DialogController* p
 
     // uitests
     m_xTypeLB->set_buildable_name(m_xTypeLB->get_buildable_name() + "-var");
+    m_xNameED->set_buildable_name(m_xNameED->get_buildable_name() + "-var");
+    m_xValueED->set_buildable_name(m_xValueED->get_buildable_name() + "-var");
+    m_xNumFormatLB->set_buildable_name(m_xNumFormatLB->get_buildable_name() + 
"-var");
+    m_xSelectionLB->set_buildable_name(m_xSelectionLB->get_buildable_name() + 
"-var");
 }
 
 SwFieldVarPage::~SwFieldVarPage()
diff --git a/sw/source/uibase/inc/condedit.hxx 
b/sw/source/uibase/inc/condedit.hxx
index a4599508c000..0b8e31473a43 100644
--- a/sw/source/uibase/inc/condedit.hxx
+++ b/sw/source/uibase/inc/condedit.hxx
@@ -61,6 +61,9 @@ public:
     void hide() { m_xControl->hide(); }
     weld::Entry& get_widget() { return *m_xControl; }
 
+    OString get_buildable_name() const { return 
m_xControl->get_buildable_name(); }
+    void set_buildable_name(const OString& rId) { 
m_xControl->set_buildable_name(rId); }
+
     void ShowBrackets(bool bShow) { bBrackets = bShow; }
     bool GetBrackets() const { return bBrackets; }
     void SetDropEnable(bool bFlag) { bEnableDrop = bFlag; }
diff --git a/sw/source/uibase/inc/numfmtlb.hxx 
b/sw/source/uibase/inc/numfmtlb.hxx
index 437537307d7d..a56d5fb8fe3e 100644
--- a/sw/source/uibase/inc/numfmtlb.hxx
+++ b/sw/source/uibase/inc/numfmtlb.hxx
@@ -99,6 +99,8 @@ public:
 
     void            set_sensitive(bool bSensitive) { 
mxControl->set_sensitive(bSensitive); }
     void            connect_changed(const Link<weld::ComboBox&, void>& rLink) 
{ mxControl->connect_changed(rLink); }
+    OString         get_buildable_name() const { return 
mxControl->get_buildable_name(); }
+    void            set_buildable_name(const OString& rId){ 
mxControl->set_buildable_name(rId); }
 };
 
 class SW_DLLPUBLIC SwNumFormatTreeView final : public SwNumFormatBase
@@ -131,6 +133,8 @@ public:
     void            set_visible(bool bVisible) { 
mxControl->set_visible(bVisible); }
     void            select(int nPos) { mxControl->select(nPos); }
     void            connect_row_activated(const Link<weld::TreeView&, bool>& 
rLink) { mxControl->connect_row_activated(rLink); }
+    OString         get_buildable_name() const { return 
mxControl->get_buildable_name(); }
+    void            set_buildable_name(const OString& rId){ 
mxControl->set_buildable_name(rId); }
 };
 
 #endif

Reply via email to