From ec6be6640a5b2012e74ed5602df93e8656e35fc4 Mon Sep 17 00:00:00 2001
From: Robert Loehning <robert.loehning@digia.com>
Date: Wed, 17 Jul 2013 13:36:10 +0200
Subject: [PATCH] Squish: Test "Go to slot" in Widget Designer

Change-Id: Idc4517f86035aa5faa1265f275b0ed5f97526d2f
Reviewed-by: Christian Stenger <christian.stenger@digia.com>
---
 tests/system/objects.map                      | 12 ++++
 tests/system/suite_tools/envvars              |  1 +
 tests/system/suite_tools/suite.conf           | 12 ++++
 .../tst_designer_goto_slot/test.py            | 60 +++++++++++++++++++
 .../testdata/connections.tsv                  |  4 ++
 5 files changed, 89 insertions(+)
 create mode 100644 tests/system/suite_tools/envvars
 create mode 100644 tests/system/suite_tools/suite.conf
 create mode 100644 tests/system/suite_tools/tst_designer_goto_slot/test.py
 create mode 100644 tests/system/suite_tools/tst_designer_goto_slot/testdata/connections.tsv

diff --git a/tests/system/objects.map b/tests/system/objects.map
index 93019bf52ae..a257d8ca041 100644
--- a/tests/system/objects.map
+++ b/tests/system/objects.map
@@ -5,11 +5,13 @@
 :*Qt Creator.Events_QDockWidget	{name='QmlProfilerEventsViewDockWidget' type='QDockWidget' visible='1' window=':Qt Creator_Core::Internal::MainWindow' windowTitle='Events'}
 :*Qt Creator.Events_QTabBar	{aboveWidget=':*Qt Creator.Events_QDockWidget' type='QTabBar' unnamed='1' visible='1' window=':Qt Creator_Core::Internal::MainWindow'}
 :*Qt Creator.Find_Find::Internal::FindToolBar	{name='Find__Internal__FindWidget' type='Find::Internal::FindToolBar' visible='1' window=':Qt Creator_Core::Internal::MainWindow' windowTitle='Find'}
+:*Qt Creator.FormEditorStack_Designer::Internal::FormEditorStack	{name='FormEditorStack' type='Designer::Internal::FormEditorStack' visible='1' window=':Qt Creator_Core::Internal::MainWindow'}
 :*Qt Creator.Interrupt_Core::Internal::FancyToolButton	{text='Interrupt' type='Core::Internal::FancyToolButton' unnamed='1' visible='1' window=':Qt Creator_Core::Internal::MainWindow'}
 :*Qt Creator.JavaScript_QDockWidget	{name='QmlProfilerV8ProfileViewDockWidget' type='QDockWidget' visible='1' window=':Qt Creator_Core::Internal::MainWindow' windowTitle='JavaScript'}
 :*Qt Creator.JavaScript_QTabBar	{aboveWidget=':*Qt Creator.JavaScript_QDockWidget' type='QTabBar' unnamed='1' visible='1' window=':Qt Creator_Core::Internal::MainWindow'}
 :*Qt Creator.Run_Core::Internal::FancyToolButton	{text='Run' type='Core::Internal::FancyToolButton' unnamed='1' visible='1' window=':Qt Creator_Core::Internal::MainWindow'}
 :*Qt Creator.Start Debugging_Core::Internal::FancyToolButton	{text='Start Debugging' type='Core::Internal::FancyToolButton' unnamed='1' visible='1' window=':Qt Creator_Core::Internal::MainWindow'}
+:*Qt Creator.Widget Box_QDockWidget	{name='WidgetBoxDockWidget' type='QDockWidget' visible='1' window=':Qt Creator_Core::Internal::MainWindow' windowTitle='Widget Box'}
 :*Qt Creator.findEdit_Utils::FilterLineEdit	{name='findEdit' type='Utils::FilterLineEdit' visible='1' window=':Qt Creator_Core::Internal::MainWindow'}
 :*Qt Creator_Core::Internal::FancyToolButton	{occurrence='3' type='Core::Internal::FancyToolButton' unnamed='1' visible='1' window=':Qt Creator_Core::Internal::MainWindow'}
 :*Qt Creator_Help::Internal::HelpViewer	{type='Help::Internal::HelpViewer' unnamed='1' visible='1' window=':Qt Creator_Core::Internal::MainWindow'}
@@ -61,7 +63,14 @@
 :File has been removed.Save_QPushButton	{text='Save' type='QPushButton' unnamed='1' visible='1' window=':File has been removed_QMessageBox'}
 :File has been removed_QMessageBox	{text?='The file * removed*. Do you want to save it under a different name, or close the editor?' type='QMessageBox' unnamed='1' visible='1'}
 :Form.Startup_QGroupBox	{container=':qt_tabwidget_stackedwidget.Form_QWidget' name='startupGroupBox' title='Startup' type='QGroupBox' visible='1'}
+:FormEditorStack.CheckBox_QCheckBox	{container=':*Qt Creator.FormEditorStack_Designer::Internal::FormEditorStack' name='checkBox' text='CheckBox' type='QCheckBox' visible='1'}
+:FormEditorStack.PushButton_QPushButton	{container=':*Qt Creator.FormEditorStack_Designer::Internal::FormEditorStack' name='pushButton' text='PushButton' type='QPushButton' visible='1'}
+:FormEditorStack.centralWidget_QDesignerWidget	{container=':*Qt Creator.FormEditorStack_Designer::Internal::FormEditorStack' name='centralWidget' type='QDesignerWidget' visible='1'}
+:FormEditorStack_qdesigner_internal::FormWindow	{container=':*Qt Creator.FormEditorStack_Designer::Internal::FormEditorStack' type='qdesigner_internal::FormWindow' unnamed='1' visible='1'}
 :Generator:_QComboBox	{buddy=':CMake Wizard.Generator:_QLabel' type='QComboBox' unnamed='1' visible='1'}
+:Go to slot.OK_QPushButton	{text='OK' type='QPushButton' unnamed='1' visible='1' window=':Go to slot_QDialog'}
+:Go to slot.Select signal_QGroupBox	{name='groupBox' title='Select signal' type='QGroupBox' visible='1' window=':Go to slot_QDialog'}
+:Go to slot_QDialog	{name='SelectSignalDialog' type='QDialog' visible='1' windowTitle='Go to slot'}
 :Hits_QCLuceneResultWidget	{aboveWidget=':Hits_QLabel' type='QCLuceneResultWidget' unnamed='1' visible='1' window=':Qt Creator_Core::Internal::MainWindow'}
 :Hits_QLabel	{text~='\\\\d+ - \\\\d+ of \\\\d+ Hits' type='QLabel' unnamed='1' visible='1' window=':Qt Creator_Core::Internal::MainWindow'}
 :Installed Plugins.Close_QPushButton	{text='Close' type='QPushButton' unnamed='1' visible='1' window=':Installed Plugins_Core::Internal::PluginDialog'}
@@ -145,9 +154,11 @@
 :Revert to Saved_QMessageBox	{text?='You will lose your current changes if you proceed reverting*' type='QMessageBox' unnamed='1' visible='1'}
 :RunSettingsEnvironmentDetails_Utils::DetailsButton	{leftWidget=':RunSettingsUseBuildEnvironment_QLabel' text='Details' type='Utils::DetailsButton' unnamed='1' visible='1' window=':Qt Creator_Core::Internal::MainWindow'}
 :RunSettingsUseBuildEnvironment_QLabel	{text~='Us(e|ing) <b>Build Environment</b>' type='QLabel' unnamed='1' visible='1'}
+:Select signal.signalList_QTreeWidget	{container=':Go to slot.Select signal_QGroupBox' name='signalList' type='QTreeWidget' visible='1'}
 :Session Manager_ProjectExplorer::Internal::SessionDialog	{name='ProjectExplorer__Internal__SessionDialog' type='ProjectExplorer::Internal::SessionDialog' visible='1' windowTitle='Session Manager'}
 :Startup.contextHelpComboBox_QComboBox	{container=':Form.Startup_QGroupBox' name='contextHelpComboBox' type='QComboBox' visible='1'}
 :User Interface.languageBox_QComboBox	{container=':Core__Internal__GeneralSettings.User Interface_QGroupBox' name='languageBox' type='QComboBox' visible='1'}
+:Widget Box_qdesigner_internal::WidgetBoxTreeWidget	{container=':*Qt Creator.Widget Box_QDockWidget' type='qdesigner_internal::WidgetBoxTreeWidget' unnamed='1' visible='1'}
 :WritePermissions_Core::Internal::ReadOnlyFilesDialog	{name='Core__Internal__ReadOnlyFilesDialog' type='Core::Internal::ReadOnlyFilesDialog' visible='1' windowTitle='Files Without Write Permissions'}
 :addToVersionControlComboBox_QComboBox	{name='addToVersionControlComboBox' type='QComboBox' visible='1'}
 :fileNameEdit_QLineEdit	{buddy=':Open File.File name:_QLabel' name='fileNameEdit' type='QLineEdit' visible='1'}
@@ -156,6 +167,7 @@
 :headerFileLineEdit_Utils::FileNameValidatingLineEdit	{buddy=':Qt Gui Application.Header file:_QLabel' name='headerFileLineEdit' type='Utils::FileNameValidatingLineEdit' visible='1'}
 :popupFrame_Proposal_QListView	{container=':popupFrame_TextEditor::GenericProposalWidget' type='QListView' unnamed='1' visible='1'}
 :popupFrame_TextEditor::GenericProposalWidget	{name='m_popupFrame' type='TextEditor::GenericProposalWidget' visible='1'}
+:qdesigner_internal::WidgetBoxCategoryListView	{container=':Widget Box_qdesigner_internal::WidgetBoxTreeWidget' occurrence='3' type='qdesigner_internal::WidgetBoxCategoryListView' unnamed='1' visible='1'}
 :qmakeCallEdit	{container=':Qt Creator.scrollArea_QScrollArea' text?='<b>qmake:</b> qmake*' type='QLabel' unnamed='1' visible='1'}
 :qt_tabwidget_stackedwidget.Core__Internal__GeneralSettings_QWidget	{container=':Options.qt_tabwidget_stackedwidget_QStackedWidget' name='Core__Internal__GeneralSettings' type='QWidget' visible='1'}
 :qt_tabwidget_stackedwidget.CppTools__Internal__CompletionSettingsPage_QWidget	{container=':Options.qt_tabwidget_stackedwidget_QStackedWidget' name='CppTools__Internal__CompletionSettingsPage' type='QWidget' visible='1'}
diff --git a/tests/system/suite_tools/envvars b/tests/system/suite_tools/envvars
new file mode 100644
index 00000000000..00aad3eab7d
--- /dev/null
+++ b/tests/system/suite_tools/envvars
@@ -0,0 +1 @@
+QT_PLATFORM_PLUGIN=nonesuch
diff --git a/tests/system/suite_tools/suite.conf b/tests/system/suite_tools/suite.conf
new file mode 100644
index 00000000000..8a0230c0e3d
--- /dev/null
+++ b/tests/system/suite_tools/suite.conf
@@ -0,0 +1,12 @@
+AUT=qtcreator
+CLASS=
+CLASSPATH=
+CWD=
+ENVVARS=envvars
+HOOK_SUB_PROCESSES=false
+IMPLICITAUTSTART=0
+LANGUAGE=Python
+OBJECTMAP=../objects.map
+TEST_CASES=tst_designer_goto_slot
+VERSION=2
+WRAPPERS=Qt
diff --git a/tests/system/suite_tools/tst_designer_goto_slot/test.py b/tests/system/suite_tools/tst_designer_goto_slot/test.py
new file mode 100644
index 00000000000..bb82aeba853
--- /dev/null
+++ b/tests/system/suite_tools/tst_designer_goto_slot/test.py
@@ -0,0 +1,60 @@
+#############################################################################
+##
+## Copyright (C) 2013 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://qt.digia.com/licensing.  For further information
+## use the contact form at http://qt.digia.com/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 as published by the Free Software
+## Foundation and appearing in the file LICENSE.LGPL included in the
+## packaging of this file.  Please review the following information to
+## ensure the GNU Lesser General Public License version 2.1 requirements
+## will be met: 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 main():
+    startApplication("qtcreator" + SettingsPath)
+    if not startedWithoutPluginError():
+        return
+    createProject_Qt_GUI(tempDir(), "DesignerTestApp")
+    selectFromLocator("mainwindow.ui")
+    widgetIndex = "{container=':qdesigner_internal::WidgetBoxCategoryListView' text='%s' type='QModelIndex'}"
+    widgets = {"Push Button": 50,
+               "Check Box": 100}
+    for current in widgets.keys():
+        dragAndDrop(waitForObject(widgetIndex % current), 5, 5,
+                    ":FormEditorStack_qdesigner_internal::FormWindow", 20, widgets[current], Qt.CopyAction)
+    connections = []
+    for record in testData.dataset("connections.tsv"):
+        connections.append([testData.field(record, col) for col in ["widget", "signal", "slot"]])
+    for con in connections:
+        selectFromLocator("mainwindow.ui")
+        openContextMenu(waitForObject(con[0]), 5, 5, 0)
+        activateItem(waitForObjectItem("{type='QMenu' unnamed='1' visible='1'}", "Go to slot..."))
+        waitForObjectItem(":Select signal.signalList_QTreeWidget", con[1])
+        clickItem(":Select signal.signalList_QTreeWidget", con[1], 5, 5, 0, Qt.LeftButton)
+        clickButton(waitForObject(":Go to slot.OK_QPushButton"))
+        editor = waitForObject(":Qt Creator_CppEditor::Internal::CPPEditorWidget")
+        type(editor, "<Up>")
+        type(editor, "<Up>")
+        test.verify(waitFor('str(lineUnderCursor(editor)).strip() == con[2]', 1000),
+                    'Comparing line "%s" to expected "%s"' % (lineUnderCursor(editor), con[2]))
+    invokeMenuItem("File", "Save All")
+    invokeMenuItem("File", "Exit")
diff --git a/tests/system/suite_tools/tst_designer_goto_slot/testdata/connections.tsv b/tests/system/suite_tools/tst_designer_goto_slot/testdata/connections.tsv
new file mode 100644
index 00000000000..e222ef4544c
--- /dev/null
+++ b/tests/system/suite_tools/tst_designer_goto_slot/testdata/connections.tsv
@@ -0,0 +1,4 @@
+"widget"	"signal"	"slot"
+":FormEditorStack.PushButton_QPushButton"	"clicked()"	"void MainWindow::on_pushButton_clicked()"
+":FormEditorStack.CheckBox_QCheckBox"	"toggled(bool)"	"void MainWindow::on_checkBox_toggled(bool checked)"
+":FormEditorStack.centralWidget_QDesignerWidget"	"destroyed()"	"void MainWindow::on_MainWindow_destroyed()"
-- 
GitLab