From f7c67d5521d64c7927a921031b334e14bc1ede40 Mon Sep 17 00:00:00 2001 From: Robert Loehning Date: Thu, 5 Sep 2013 13:37:05 +0200 Subject: [PATCH] Squish: Add test case for git clone wizard Change-Id: I4b4415d8a9b40b16be609286f0f07a63c4dd88bc Reviewed-by: Christian Stenger --- tests/system/objects.map | 15 +++ tests/system/suite_tools/suite.conf | 2 +- .../system/suite_tools/tst_git_clone/test.py | 114 ++++++++++++++++++ 3 files changed, 130 insertions(+), 1 deletion(-) create mode 100644 tests/system/suite_tools/tst_git_clone/test.py diff --git a/tests/system/objects.map b/tests/system/objects.map index c014ad910fe..5f6e2f8e47d 100644 --- a/tests/system/objects.map +++ b/tests/system/objects.map @@ -1,4 +1,5 @@ :*Qt Creator.Build Project_Core::Internal::FancyToolButton {text='Build Project' type='Core::Internal::FancyToolButton' unnamed='1' visible='1' window=':Qt Creator_Core::Internal::MainWindow'} +:*Qt Creator.Cancel_QPushButton {text='Cancel' type='QPushButton' unnamed='1' visible='1' window=':Qt Creator_Core::Internal::MainWindow'} :*Qt Creator.Clear_QToolButton {text='Clear' type='QToolButton' unnamed='1' visible='1' window=':Qt Creator_Core::Internal::MainWindow'} :*Qt Creator.Continue_Core::Internal::FancyToolButton {text='Continue' type='Core::Internal::FancyToolButton' unnamed='1' visible='1' window=':Qt Creator_Core::Internal::MainWindow'} :*Qt Creator.DoubleTabWidget_ProjectExplorer::Internal::DoubleTabWidget {name='ProjectExplorer__Internal__DoubleTabWidget' type='ProjectExplorer::Internal::DoubleTabWidget' visible='1' window=':Qt Creator_Core::Internal::MainWindow' windowTitle='DoubleTabWidget'} @@ -38,6 +39,10 @@ :CMake Wizard.Next_QPushButton {name='__qt__passive_wizardbutton1' text~='(Next.*|Continue)' type='QPushButton' visible='1' window=':CMake Wizard_CMakeProjectManager::Internal::CMakeOpenProjectWizard'} :CMake Wizard.Run CMake_QPushButton {text='Run CMake' type='QPushButton' unnamed='1' visible='1' window=':CMake Wizard_CMakeProjectManager::Internal::CMakeOpenProjectWizard'} :CMake Wizard_CMakeProjectManager::Internal::CMakeOpenProjectWizard {type='CMakeProjectManager::Internal::CMakeOpenProjectWizard' unnamed='1' visible='1' windowTitle='CMake Wizard'} +:Cannot Open Project.OK_QPushButton {text='OK' type='QPushButton' unnamed='1' visible='1' window=':Cannot Open Project_QMessageBox'} +:Cannot Open Project.Show Details..._QPushButton {text='Show Details...' type='QPushButton' unnamed='1' visible='1' window=':Cannot Open Project_QMessageBox'} +:Cannot Open Project_QMessageBox {text?='Failed to open project in *' type='QMessageBox' unnamed='1' visible='1'} +:Cannot Open Project_QTextEdit {type='QTextEdit' unnamed='1' visible='1' window=':Cannot Open Project_QMessageBox'} :CodePaster__Internal__PasteSelectDialog.Cancel_QPushButton {text='Cancel' type='QPushButton' unnamed='1' visible='1' window=':CodePaster__Internal__PasteSelectDialog_CodePaster::PasteSelectDialog'} :CodePaster__Internal__PasteSelectDialog.OK_QPushButton {text='OK' type='QPushButton' unnamed='1' visible='1' window=':CodePaster__Internal__PasteSelectDialog_CodePaster::PasteSelectDialog'} :CodePaster__Internal__PasteSelectDialog.listWidget_QListWidget {name='listWidget' type='QListWidget' visible='1' window=':CodePaster__Internal__PasteSelectDialog_CodePaster::PasteSelectDialog'} @@ -74,6 +79,13 @@ :FormEditorStack_qdesigner_internal::FormWindow {container=':*Qt Creator.FormEditorStack_Designer::Internal::FormEditorStack' type='qdesigner_internal::FormWindow' unnamed='1' visible='1'} :FormEditorStack_qdesigner_internal::PropertyLineEdit {container=':*Qt Creator.FormEditorStack_Designer::Internal::FormEditorStack' type='qdesigner_internal::PropertyLineEdit' unnamed='1' visible='1'} :Generator:_QComboBox {buddy=':CMake Wizard.Generator:_QLabel' type='QComboBox' unnamed='1' visible='1'} +:Git Repository Clone.Cancel_QPushButton {text='Cancel' type='QPushButton' unnamed='1' visible='1' window=':Git Repository Clone_VcsBase::Internal::CheckoutWizardDialog'} +:Git Repository Clone.Finish_QPushButton {text~='(Finish|Done)' type='QPushButton' unnamed='1' visible='1' window=':Git Repository Clone_VcsBase::Internal::CheckoutWizardDialog'} +:Git Repository Clone.Repository_QGroupBox {name='repositoryGroupBox' title='Repository' type='QGroupBox' visible='1' window=':Git Repository Clone_VcsBase::Internal::CheckoutWizardDialog'} +:Git Repository Clone.Result._QLabel {name='statusLabel' type='QLabel' visible='1' window=':Git Repository Clone_VcsBase::Internal::CheckoutWizardDialog'} +:Git Repository Clone.Working Copy_QGroupBox {name='localGroupBox' title='Working Copy' type='QGroupBox' visible='1' window=':Git Repository Clone_VcsBase::Internal::CheckoutWizardDialog'} +:Git Repository Clone.logPlainTextEdit_QPlainTextEdit {name='logPlainTextEdit' type='QPlainTextEdit' visible='1' window=':Git Repository Clone_VcsBase::Internal::CheckoutWizardDialog'} +:Git Repository Clone_VcsBase::Internal::CheckoutWizardDialog {type='VcsBase::Internal::CheckoutWizardDialog' unnamed='1' visible='1' windowTitle='Git Repository Clone'} :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'} @@ -155,6 +167,7 @@ :QtSupport__Internal__QtVersionManager.errorLabel.QLabel {container=':qt_tabwidget_stackedwidget.QtSupport__Internal__QtVersionManager_QtSupport::Internal::QtOptionsPageWidget' name='errorLabel' type='QLabel' visible='1'} :QtSupport__Internal__QtVersionManager.qmake_QLabel {container=':qt_tabwidget_stackedwidget.QtSupport__Internal__QtVersionManager_QtSupport::Internal::QtOptionsPageWidget' name='qmakePath' type='QLabel' visible='1'} :QtSupport__Internal__QtVersionManager.qtdirList_QTreeWidget {container=':qt_tabwidget_stackedwidget.QtSupport__Internal__QtVersionManager_QtSupport::Internal::QtOptionsPageWidget' name='qtdirList' type='QTreeWidget' visible='1'} +:Repository.repositoryLineEdit_QLineEdit {container=':Git Repository Clone.Repository_QGroupBox' name='repositoryLineEdit' type='QLineEdit' visible='1'} :Restart required.OK_QPushButton {text='OK' type='QPushButton' unnamed='1' visible='1' window=':Restart required_QMessageBox'} :Restart required_QMessageBox {text='The language change will take effect after a restart of Qt Creator.' type='QMessageBox' unnamed='1' visible='1'} :Revert to Saved.Proceed_QPushButton {text='Proceed' type='QPushButton' unnamed='1' visible='1' window=':Revert to Saved_QMessageBox'} @@ -171,6 +184,8 @@ :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'} +:Working Copy.checkoutDirectoryLineEdit_QLineEdit {container=':Git Repository Clone.Working Copy_QGroupBox' name='checkoutDirectoryLineEdit' type='QLineEdit' visible='1'} +:Working Copy_Utils::BaseValidatingLineEdit {container=':Git Repository Clone.Working Copy_QGroupBox' type='Utils::BaseValidatingLineEdit' 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'} diff --git a/tests/system/suite_tools/suite.conf b/tests/system/suite_tools/suite.conf index 2f872714c52..d031934fc3c 100644 --- a/tests/system/suite_tools/suite.conf +++ b/tests/system/suite_tools/suite.conf @@ -7,6 +7,6 @@ HOOK_SUB_PROCESSES=false IMPLICITAUTSTART=0 LANGUAGE=Python OBJECTMAP=../objects.map -TEST_CASES=tst_codepasting tst_designer_autocomplete tst_designer_goto_slot tst_external_sort +TEST_CASES=tst_codepasting tst_designer_autocomplete tst_designer_goto_slot tst_external_sort tst_git_clone VERSION=2 WRAPPERS=Qt diff --git a/tests/system/suite_tools/tst_git_clone/test.py b/tests/system/suite_tools/tst_git_clone/test.py new file mode 100644 index 00000000000..3f010ec8ea4 --- /dev/null +++ b/tests/system/suite_tools/tst_git_clone/test.py @@ -0,0 +1,114 @@ +############################################################################# +## +## 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") + +cloneUrl = "https://codereview.qt-project.org/p/qt-labs/jom" +cloneDir = "myCloneOfJom" + +def verifyCloneLog(targetDir, canceled): + cloneLog = waitForObject(":Git Repository Clone.logPlainTextEdit_QPlainTextEdit") + waitFor('"The process terminated " in str(cloneLog.plainText)', 30000) + test.verify(("Executing in " + targetDir + ":" in str(cloneLog.plainText)), + "Searching for target directory in clone log") + test.verify((" ".join(["clone", cloneUrl, cloneDir]) in str(cloneLog.plainText)), + "Searching for git parameters in clone log") + test.verify(("Stopping..." in str(cloneLog.plainText)) ^ (not canceled), + "Searching for 'Stopping...' in clone log") + test.verify(("'" + cloneDir + "'..." in str(cloneLog.plainText)), + "Searching for clone directory in clone log") + if canceled: + result = "The process terminated in an abnormal way." + summary = "Failed." + else: + result = "The process terminated with exit code 0." + summary = "Succeeded." + test.verify((result in str(cloneLog.plainText)), + "Searching for result (%s) in clone log:\n%s" + % (result, str(cloneLog.plainText))) + test.compare(waitForObject(":Git Repository Clone.Result._QLabel").text, summary) + +def verifyFiles(targetDir): + for file in [".gitignore", "CMakeLists.txt", "jom.pro", + os.path.join("bin", "ibjom.cmd"), + os.path.join("src", "app", "main.cpp")]: + test.verify(os.path.exists(os.path.join(targetDir, cloneDir, file)), + "Verify the existence of %s" % file) + +def main(): + startApplication("qtcreator" + SettingsPath) + if not startedWithoutPluginError(): + return + for button in ["Cancel immediately", + ":Git Repository Clone.Cancel_QPushButton", + ":Git Repository Clone.Finish_QPushButton"]: + __createProjectOrFileSelectType__(" Import Project", "Git Repository Clone") + replaceEditorContent(waitForObject(":Repository.repositoryLineEdit_QLineEdit"), + cloneUrl) + targetDir = tempDir() + replaceEditorContent(waitForObject(":Working Copy_Utils::BaseValidatingLineEdit"), + targetDir) + cloneDirEdit = waitForObject(":Working Copy.checkoutDirectoryLineEdit_QLineEdit") + test.compare(cloneDirEdit.text, "p-qt-labs-jom") + replaceEditorContent(cloneDirEdit, cloneDir) + clickButton(waitForObject(":Next_QPushButton")) + test.compare(waitForObject(":Git Repository Clone.Result._QLabel").text, + "Checkout started...") + if button == "Cancel immediately": + clickButton(":Git Repository Clone.Cancel_QPushButton") + verifyCloneLog(targetDir, True) + clickButton(":Git Repository Clone.Cancel_QPushButton") + else: + verifyCloneLog(targetDir, False) + verifyFiles(targetDir) + try: + clickButton(waitForObject(button)) + except: + cloneLog = waitForObject(":Git Repository Clone.logPlainTextEdit_QPlainTextEdit") + test.fatal("Cloning failed", + str(cloneLog.plainText)) + clickButton(":Git Repository Clone.Cancel_QPushButton") + continue + if button == ":Git Repository Clone.Finish_QPushButton": + try: + # CMake wizard shown + clickButton(waitForObject(":CMake Wizard.Cancel_QPushButton", 5000)) + clickButton(waitForObject(":Cannot Open Project.OK_QPushButton")) + test.passes("The checked out project was being opened with CMake.") + except: + try: + # QMake Project mode shown + clickButton(waitForObject(":*Qt Creator.Cancel_QPushButton", 5000)) + test.passes("The checked out project was being opened with QMake.") + except: + clickButton(waitForObject(":Cannot Open Project.Show Details..._QPushButton")) + test.fail("The checked out project was not being opened.", + waitForObject(":Cannot Open Project_QTextEdit").plainText) + clickButton(waitForObject(":Cannot Open Project.OK_QPushButton")) + invokeMenuItem("File", "Exit")