1 # -*- tab-width: 4; indent-tabs-mode: nil; py-indent-offset: 4 -*-
3 # This file is part of the LibreOffice project.
5 # This Source Code Form is subject to the terms of the Mozilla Public
6 # License, v. 2.0. If a copy of the MPL was not distributed with this
7 # file, You can obtain one at http://mozilla.org/MPL/2.0/.
10 from uitest
.framework
import UITestCase
11 from uitest
.uihelper
.common
import get_state_as_dict
12 from libreoffice
.uno
.propertyvalue
import mkPropertyValues
14 class tdf135938(UITestCase
):
16 def test_tdf135938_cross_reference_update(self
):
17 with self
.ui_test
.create_doc_in_start_center("writer"):
18 with self
.ui_test
.execute_modeless_dialog_through_command(".uno:InsertReferenceField", close_button
="cancel") as xDialog
:
19 # Select set reference type
20 xTreelistType
= xDialog
.getChild("type-ref")
21 xTreeEntry
= xTreelistType
.getChild('0')
22 self
.assertEqual(get_state_as_dict(xTreeEntry
)["Text"], "Set Reference")
23 xTreeEntry
.executeAction("SELECT", tuple())
25 # Insert cross references
26 xName
= xDialog
.getChild("name-ref")
27 xName
.executeAction("TYPE", mkPropertyValues({"TEXT": "ABC"}))
28 xInsert
= xDialog
.getChild("ok")
29 xInsert
.executeAction("CLICK", tuple())
31 xSelect
= xDialog
.getChild("select-ref")
32 self
.assertEqual("1", get_state_as_dict(xSelect
)["Children"])
33 self
.assertEqual("ABC", get_state_as_dict(xSelect
.getChild(0))["Text"])
35 xName
.executeAction("TYPE", mkPropertyValues({"KEYCODE":"CTRL+A"}))
36 xName
.executeAction("TYPE", mkPropertyValues({"TEXT": "DEF"}))
37 xInsert
.executeAction("CLICK", tuple())
39 self
.assertEqual("2", get_state_as_dict(xSelect
)["Children"])
40 self
.assertEqual("ABC", get_state_as_dict(xSelect
.getChild(0))["Text"])
41 self
.assertEqual("DEF", get_state_as_dict(xSelect
.getChild(1))["Text"])
43 # Search for insert reference type
45 for childIx
in range(len(xTreelistType
.getChildren())):
46 xTreeEntry
= xTreelistType
.getChild(childIx
)
47 if get_state_as_dict(xTreeEntry
)["Text"] == "Insert Reference":
48 xTreeEntry
.executeAction("SELECT", tuple())
49 # Filter the cross references
50 xFilter
= xDialog
.getChild("filter")
51 xFilter
.executeAction("TYPE", mkPropertyValues({"TEXT": "A"}))
52 # Without the fix in place, this test would have failed with
53 # AssertionError: 'ABC' != 'DEF', i.e., the text of the name field did not change
54 self
.assertEqual(get_state_as_dict(xName
)["Text"], "ABC")
56 self
.assertEqual("1", get_state_as_dict(xSelect
)["Children"])
59 # Check if insert reference entry was found
60 self
.assertFalse(xFilter
is None)
62 # vim: set shiftwidth=4 softtabstop=4 expandtab: