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 # Id is a random number now, not 0.
48 # xId = xDialog.getChild("idspinbutton")
49 # self.assertEqual(get_state_as_dict(xId)['Text'], "0")
50 # type_text(xId, "429496729") # added in front, making it 4294967290
52 xTabIndex
= xDialog
.getChild("tabindexspinbutton")
53 self
.assertEqual(get_state_as_dict(xTabIndex
)['Text'], "1")
54 type_text(xTabIndex
, "-") # add a minus in front, making it -1
56 with self
.ui_test
.execute_blocking_action(xAdd
.executeAction
, args
=('CLICK', ())) as xSubDialog
:
57 xDisplayName
= xSubDialog
.getChild("displayname")
58 type_text(xDisplayName
, "Foo Bar")
59 xValue
= xSubDialog
.getChild("value")
60 type_text(xValue
, "foo-bar")
62 # Verify that the UI appended the list item.
63 listItems
= contentControl
.ListItems
64 self
.assertEqual(len(listItems
), 2)
65 self
.assertEqual(listItems
[1][0].Name
, "DisplayText")
66 self
.assertEqual(listItems
[1][0].Value
, "Foo Bar")
67 self
.assertEqual(listItems
[1][1].Name
, "Value")
68 self
.assertEqual(listItems
[1][1].Value
, "foo-bar")
69 self
.assertEqual(contentControl
.Alias
, "new alias my alias")
70 self
.assertEqual(contentControl
.Tag
, "new tag my tag")
71 # self.assertEqual(contentControl.Id, -6) # stored as signed, displays as unsigned
72 self
.assertEqual(contentControl
.TabIndex
, 4294967295) # stored as unsigned, displays as signed
75 # vim: set shiftwidth=4 softtabstop=4 expandtab: