tdf#138271: sw: Add UItest

Change-Id: I9bfa7e83fcafe9b809daf93e5a41bc74c9d5e3f8
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/111501
Tested-by: Jenkins
Reviewed-by: Xisco Fauli <xiscofauli@libreoffice.org>
diff --git a/sw/qa/uitest/data/tdf138271.odt b/sw/qa/uitest/data/tdf138271.odt
new file mode 100644
index 0000000..ea09b55
--- /dev/null
+++ b/sw/qa/uitest/data/tdf138271.odt
Binary files differ
diff --git a/sw/qa/uitest/writer_tests7/forms.py b/sw/qa/uitest/writer_tests7/forms.py
index 8c77560..bd6b8ef 100644
--- a/sw/qa/uitest/writer_tests7/forms.py
+++ b/sw/qa/uitest/writer_tests7/forms.py
@@ -139,4 +139,39 @@ class Forms(UITestCase):

        self.ui_test.close_doc()

    def test_tdf138271(self):

        self.ui_test.load_file(get_url_for_data_file("tdf138271.odt"))

        self.xUITest.executeCommand(".uno:JumpToNextFrame")

        aOldValue = ["-1000000.00", "1000000.00"]
        aNewValue = ["-100.00", "100.00"]

        for i, name in enumerate(['formattedcontrol-Value min.', 'formattedcontrol-Value max.']):

            self.ui_test.execute_modeless_dialog_through_command(".uno:ControlProperties")
            xChild = self.ui_test.wait_until_child_is_available(name)

            self.assertEqual(aOldValue[i], get_state_as_dict(xChild)['Text'])

            xChild.executeAction("FOCUS", tuple())
            xChild.executeAction("TYPE", mkPropertyValues({"KEYCODE":"CTRL+A"}))
            xChild.executeAction("TYPE", mkPropertyValues({"KEYCODE":"BACKSPACE"}))
            xChild.executeAction("TYPE", mkPropertyValues({"TEXT": aNewValue[i]}))

            #Close the dialog and open it again
            self.xUITest.executeCommand(".uno:ControlProperties")

            self.ui_test.execute_modeless_dialog_through_command(".uno:ControlProperties")
            xChild = self.ui_test.wait_until_child_is_available(name)

            # Without the fix in place, this test would have failed here because
            # the values wouldn't have changed
            self.assertEqual(aNewValue[i], get_state_as_dict(xChild)['Text'])

            self.xUITest.executeCommand(".uno:ControlProperties")

        self.ui_test.close_doc()

# vim: set shiftwidth=4 softtabstop=4 expandtab: