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 """Covers sw/source/ui/misc/ fixes."""
12 from uitest
.framework
import UITestCase
13 from uitest
.uihelper
.common
import get_state_as_dict
14 from uitest
.uihelper
.common
import type_text
17 class TestTmpdlg(UITestCase
):
18 def test_content_control_dialog(self
):
19 with self
.ui_test
.create_doc_in_start_center("writer") as xComponent
:
20 # Insert a dropdown content control, verify that a placeholder item is provided.
21 self
.xUITest
.executeCommand(".uno:InsertDropdownContentControl")
22 paragraphs
= xComponent
.Text
.createEnumeration()
23 paragraph
= paragraphs
.nextElement()
24 portions
= paragraph
.createEnumeration()
25 portion
= portions
.nextElement()
26 contentControl
= portion
.ContentControl
27 contentControl
.Alias
= "my alias"
28 contentControl
.Tag
= "my tag"
29 contentControl
.TabIndex
= "1"
30 listItems
= contentControl
.ListItems
31 self
.assertEqual(len(listItems
), 1)
32 self
.assertEqual(listItems
[0][0].Name
, "DisplayText")
33 self
.assertEqual(listItems
[0][0].Value
, "")
34 self
.assertEqual(listItems
[0][1].Name
, "Value")
35 self
.assertEqual(listItems
[0][1].Value
, "Choose an item")
37 # Append a new list item.
38 with self
.ui_test
.execute_dialog_through_command(".uno:ContentControlProperties") as xDialog
:
39 xAlias
= xDialog
.getChild("aliasentry")
40 self
.assertEqual(get_state_as_dict(xAlias
)['Text'], "my alias")
41 type_text(xAlias
, "new alias ")
42 xTag
= xDialog
.getChild("tagentry")
43 self
.assertEqual(get_state_as_dict(xTag
)['Text'], "my tag")
44 type_text(xTag
, "new tag ")
45 xAdd
= xDialog
.getChild("add")
47 xId
= xDialog
.getChild("idspinbutton")
48 self
.assertEqual(get_state_as_dict(xId
)['Text'], "0")
49 type_text(xId
, "429496729") # added in front, making it 4294967290
51 xTabIndex
= xDialog
.getChild("tabindexspinbutton")
52 self
.assertEqual(get_state_as_dict(xTabIndex
)['Text'], "1")
53 type_text(xTabIndex
, "-") # add a minus in front, making it -1
55 with self
.ui_test
.execute_blocking_action(xAdd
.executeAction
, args
=('CLICK', ())) as xSubDialog
:
56 xDisplayName
= xSubDialog
.getChild("displayname")
57 type_text(xDisplayName
, "Foo Bar")
58 xValue
= xSubDialog
.getChild("value")
59 type_text(xValue
, "foo-bar")
61 # Verify that the UI appended the list item.
62 listItems
= contentControl
.ListItems
63 self
.assertEqual(len(listItems
), 2)
64 self
.assertEqual(listItems
[1][0].Name
, "DisplayText")
65 self
.assertEqual(listItems
[1][0].Value
, "Foo Bar")
66 self
.assertEqual(listItems
[1][1].Name
, "Value")
67 self
.assertEqual(listItems
[1][1].Value
, "foo-bar")
68 self
.assertEqual(contentControl
.Alias
, "new alias my alias")
69 self
.assertEqual(contentControl
.Tag
, "new tag my tag")
70 self
.assertEqual(contentControl
.Id
, -6) # stored as signed, displays as unsigned
71 self
.assertEqual(contentControl
.TabIndex
, 4294967295) # stored as unsigned, displays as signed
74 # vim: set shiftwidth=4 softtabstop=4 expandtab: