1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
|
#############################################################################
##
## Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
## Contact: http://www.qt-project.org/legal
##
## This file is part of Qt Creator.
##
## Commercial License Usage
## Licensees holding valid commercial Qt licenses may use this file in
## accordance with the commercial license agreement provided with the
## Software or, alternatively, in accordance with the terms contained in
## a written agreement between you and Digia. For licensing terms and
## conditions see http://www.qt.io/licensing. For further information
## use the contact form at http://www.qt.io/contact-us.
##
## GNU Lesser General Public License Usage
## Alternatively, this file may be used under the terms of the GNU Lesser
## General Public License version 2.1 or version 3 as published by the Free
## Software Foundation and appearing in the file LICENSE.LGPLv21 and
## LICENSE.LGPLv3 included in the packaging of this file. Please review the
## following information to ensure the GNU Lesser General Public License
## requirements will be met: https://www.gnu.org/licenses/lgpl.html and
# http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
##
## In addition, as a special exception, Digia gives you certain additional
## rights. These rights are described in the Digia Qt LGPL Exception
## version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
##
#############################################################################
source("../../shared/qtcreator.py")
def performEditMenu():
test.log("Editing menu")
previewMenuBar = waitForObject(":FormEditorStack.menuBar_QDesignerMenuBar")
# add File menu
doubleClick(previewMenuBar, 30, 7, 0, Qt.LeftButton)
passiveLineEdit = waitForObject(":FormEditorStack.__qt__passive_editor_QLineEdit")
replaceEditorContent(passiveLineEdit, "SquishTestFile")
type(passiveLineEdit, "<Return>")
menu = waitForObject("{name='menuSquishTestFile' title='SquishTestFile' type='QDesignerMenu' "
"visible='1' window=':Qt Creator_Core::Internal::MainWindow'}")
menuHeight = menu.height
itemHeight = menuHeight / 2 # actually only 'Type Here' and 'Add Separator' are shown
itemHalf = itemHeight / 2
# add Open menu item
doubleClick(menu, 15, itemHalf, 0, Qt.LeftButton)
passiveLineEdit = waitForObject(":FormEditorStack.__qt__passive_editor_QLineEdit")
replaceEditorContent(passiveLineEdit, "Open")
type(passiveLineEdit, "<Return>")
waitFor("menu.height > menuHeight", 2000)
menuHeight = menu.height
# add a separator
doubleClick(menu, 15, menu.height - itemHalf, 0, Qt.LeftButton)
waitFor("menu.height > menuHeight", 2000)
separatorHeight = menu.height - menuHeight
menuHeight = menu.height
# add Shutdown menu item (Quit/Exit do not work because Squish/Qt5 problems with menus)
doubleClick(menu, 30, itemHeight + separatorHeight + itemHalf, 0, Qt.LeftButton)
passiveLineEdit = waitForObject(":FormEditorStack.__qt__passive_editor_QLineEdit")
replaceEditorContent(passiveLineEdit, "Shutdown")
type(passiveLineEdit, "<Return>")
waitFor("menu.height > menuHeight", 2000)
# close menu in case it overlaps the combo box
mouseClick(waitForObject(":FormEditorStack_qdesigner_internal::FormWindow"),
100, 100, 0, Qt.LeftButton)
# verify Action Editor and Object Inspector
actionTV = waitForObject("{container={name='ActionEditorDockWidget' type='QDockWidget' "
"visible='1' window=':Qt Creator_Core::Internal::MainWindow'} "
"type='qdesigner_internal::ActionTreeView' unnamed='1' visible='1'}")
test.compare(dumpItems(actionTV.model()), ["actionOpen", "actionShutdown"],
"Verify whether respective actions have been added to Action Editor.")
objInspTV = waitForObject("{container={name='ObjectInspectorDockWidget' type='QDockWidget' "
"visible='1' window=':Qt Creator_Core::Internal::MainWindow'} "
"type='QTreeView' unnamed='1' visible='1'}")
tree = __iterateChildren__(objInspTV.model(), None)
expectedMenuSequence = [["menuSquishTestFile", 2], ["actionOpen", 3], ["separator", 3],
["actionShutdown", 3]]
seqStart = tree.index(expectedMenuSequence[0])
test.verify(seqStart != -1 and tree[seqStart:seqStart + 4] == expectedMenuSequence,
"Verify Object Inspector contains expected menu inclusive children.")
return [["Open", False], ["", True], ["Shutdown", False]]
def performEditCombo():
edComboWin = "{type='qdesigner_internal::ListWidgetEditor' unnamed='1' visible='1'}"
test.log("Editing combo box")
comboBox = waitForObject(":FormEditorStack.comboBox_QComboBox")
doubleClick(comboBox, 5, 5, 0, Qt.LeftButton)
# make sure properties of items are shown
propertyEdView = "{type='QtPropertyEditorView' unnamed='1' visible='1' window=%s}" % edComboWin
if test.verify(not object.exists(propertyEdView), "Verifying property editor is not visible."):
clickButton(waitForObject("{name='showPropertiesButton' type='QPushButton' visible='1' "
"window=%s}" % edComboWin))
for i in range(5):
clickButton(waitForObject("{name='newListItemButton' type='QToolButton' visible='1' "
"window=%s}" % edComboWin))
doubleClick(waitForObject("{column='1' container=%s text='New Item' type='QModelIndex'}"
% propertyEdView))
lineEd = waitForObject("{container=%s type='qdesigner_internal::PropertyLineEdit' "
"unnamed='1' visible='1'}" % propertyEdView)
type(lineEd, "Combo Item %d" % i)
type(lineEd, "<Return>")
itemListWidget = waitForObject("{name='listWidget' type='QListWidget' visible='1' window=%s}"
% edComboWin)
expectedItems = ["Combo Item %d" % i for i in range(5)]
test.compare(dumpItems(itemListWidget.model()), expectedItems,
"Verifying all items have been added.")
# move last item to top (assume last item is still selected)
upButton = waitForObject("{name='moveListItemUpButton' type='QToolButton' visible='1' "
"window=%s}" % edComboWin)
downButton = findObject("{name='moveListItemDownButton' type='QToolButton' visible='1' "
"window=%s}" % edComboWin)
test.verify(upButton.enabled, "Verifying whether Up button is enabled")
test.verify(not downButton.enabled, "Verifying whether Down button is disabled")
for _ in range(4):
clickButton(upButton)
test.verify(waitFor("not upButton.enabled", 1000), "Verifying whether Up button is disabled")
test.verify(downButton.enabled, "Verifying whether Down button is enabled")
expectedItems.insert(0, expectedItems.pop())
test.compare(dumpItems(itemListWidget.model()), expectedItems,
"Verifying last item has moved to top of the list.")
# remove the "Combo Item 1" item from the list
clickItem(itemListWidget, "Combo Item 1", 5, 5, 0, Qt.LeftButton)
clickButton("{name='deleteListItemButton' type='QToolButton' visible='1' window=%s}"
% edComboWin)
waitFor("itemListWidget.model().rowCount() == len(expectedItems) - 1", 2000)
expectedItems.remove("Combo Item 1")
test.compare(dumpItems(itemListWidget.model()), expectedItems,
"Verifying 'Combo Item 1' has been removed.")
clickButton("{text='OK' type='QPushButton' unnamed='1' visible='1' window=%s}" % edComboWin)
test.compare(dumpItems(comboBox.model()), expectedItems,
"Verifying combo box inside Designer has been updated")
return expectedItems
def verifyPreview(menuItems, comboItems):
test.log("Verifying preview")
prev = "{name='MainWindow' type='QMainWindow' visible='1' windowTitle='MainWindow - [Preview]'}"
invokeMenuItem("Tools", "Form Editor", "Preview...")
# verify menu
menuBar = waitForObject("{name='menuBar' type='QMenuBar' visible='1' window=%s}" % prev)
menu = None
activateItem(menuBar, "SquishTestFile")
# known issue for Squish using Qt5 on Mac
if platform.system() == 'Darwin':
for obj in object.topLevelObjects():
try:
if className(obj) == 'QMenu' and str(obj.objectName) == 'menuSquishTestFile':
menu = obj
break
except:
pass
else:
try:
menu = waitForObject("{name='menuSquishTestFile' title='SquishTestFile' "
"type='QMenu' visible='1' window=%s}" % prev)
except:
pass
if menu:
actions = menu.actions()
for position, (text, isSep) in enumerate(menuItems):
action = actions.at(position)
test.verify(action.isSeparator() == isSep and str(action.text) == text,
"Verifying menu item '%s' (separator: %s)" % (text, str(isSep)))
else:
test.warning("Failed to get menu...")
activateItem(menuBar, "SquishTestFile")
# verify combo
combo = waitForObject("{name='comboBox' type='QComboBox' visible='1' window=%s}" % prev)
test.compare(dumpItems(combo.model()), comboItems,
"Verifying combo box contains expected items.")
sendEvent("QCloseEvent", waitForObject(prev))
def main():
startApplication("qtcreator" + SettingsPath)
if not startedWithoutPluginError():
return
createProject_Qt_GUI(tempDir(), "DesignerTestApp", False)
selectFromLocator("mainwindow.ui")
replaceEditorContent(waitForObject("{container=':*Qt Creator.Widget Box_QDockWidget' "
"type='QLineEdit' visible='1'}"), "combo")
categoryView = ("{container=':Widget Box_qdesigner_internal::WidgetBoxTreeWidget' "
"type='qdesigner_internal::WidgetBoxCategoryListView' unnamed='1' visible='1'}")
dragAndDrop(waitForObject("{container=%s text='Combo Box' type='QModelIndex'}" % categoryView),
5, 5, ":FormEditorStack_qdesigner_internal::FormWindow", 20, 50, Qt.CopyAction)
menuItems = performEditMenu()
comboItems = performEditCombo()
verifyPreview(menuItems, comboItems)
invokeMenuItem("File", "Save All")
invokeMenuItem("Build", "Build All")
waitForCompile()
checkCompile()
invokeMenuItem("File", "Exit")
|