From a40ea3f1d603d6f43c73346f87ed0e5038c32538 Mon Sep 17 00:00:00 2001 From: Mitch Curtis Date: Thu, 8 Mar 2018 09:46:57 +0100 Subject: [PATCH] Remove duplicated "Qt Unit Test" wizard There are currently two types of wizards for creating auto tests: - Qt Unit Test - Auto Test Project Both produce almost identical code in the case of a Qt GUI-based test, and the descriptions are very similar. This is really confusing. The Auto Test Project wizard has support for Qt Test, Google Test and Qt Quick Test. In addition, the documentation only mentions Auto Test Projects when it discusses the creation of auto tests: http://doc.qt.io/qtcreator/creator-autotest.html#creating-tests So let's just use that and make everything simpler. Change-Id: Ia16c88c462744baa8df3f9e8082cbcad6ad9eb15 Reviewed-by: Christian Stenger Reviewed-by: Tobias Hunger --- .../projects/creator-projects-creating.qdoc | 4 - .../qmakeprojectmanager.pro | 9 +- .../qmakeprojectmanager.qbs | 4 - .../qmakeprojectmanagerplugin.cpp | 2 - .../wizards/testwizard.cpp | 183 ------------------ .../qmakeprojectmanager/wizards/testwizard.h | 47 ----- .../wizards/testwizarddialog.cpp | 93 --------- .../wizards/testwizarddialog.h | 75 ------- .../wizards/testwizardpage.cpp | 137 ------------- .../wizards/testwizardpage.h | 67 ------- .../wizards/testwizardpage.ui | 141 -------------- 11 files changed, 1 insertion(+), 761 deletions(-) delete mode 100644 src/plugins/qmakeprojectmanager/wizards/testwizard.cpp delete mode 100644 src/plugins/qmakeprojectmanager/wizards/testwizard.h delete mode 100644 src/plugins/qmakeprojectmanager/wizards/testwizarddialog.cpp delete mode 100644 src/plugins/qmakeprojectmanager/wizards/testwizarddialog.h delete mode 100644 src/plugins/qmakeprojectmanager/wizards/testwizardpage.cpp delete mode 100644 src/plugins/qmakeprojectmanager/wizards/testwizardpage.h delete mode 100644 src/plugins/qmakeprojectmanager/wizards/testwizardpage.ui diff --git a/doc/src/projects/creator-projects-creating.qdoc b/doc/src/projects/creator-projects-creating.qdoc index 26209b6c04e..019ac432f33 100644 --- a/doc/src/projects/creator-projects-creating.qdoc +++ b/doc/src/projects/creator-projects-creating.qdoc @@ -157,10 +157,6 @@ \list - \li Qt Unit Test - - Qt unit tests for features or classes - \li Auto Test Project Projects with boilerplate code for a Qt or Google test. For more diff --git a/src/plugins/qmakeprojectmanager/qmakeprojectmanager.pro b/src/plugins/qmakeprojectmanager/qmakeprojectmanager.pro index 850febd4d11..765b12b515a 100644 --- a/src/plugins/qmakeprojectmanager/qmakeprojectmanager.pro +++ b/src/plugins/qmakeprojectmanager/qmakeprojectmanager.pro @@ -25,9 +25,6 @@ HEADERS += \ wizards/librarywizard.h \ wizards/librarywizarddialog.h \ wizards/guiappwizarddialog.h \ - wizards/testwizard.h \ - wizards/testwizarddialog.h \ - wizards/testwizardpage.h \ wizards/modulespage.h \ wizards/filespage.h \ wizards/qtwizard.h \ @@ -69,9 +66,6 @@ SOURCES += \ wizards/librarywizard.cpp \ wizards/librarywizarddialog.cpp \ wizards/guiappwizarddialog.cpp \ - wizards/testwizard.cpp \ - wizards/testwizarddialog.cpp \ - wizards/testwizardpage.cpp \ wizards/modulespage.cpp \ wizards/filespage.cpp \ wizards/qtwizard.cpp \ @@ -94,8 +88,7 @@ SOURCES += \ FORMS += makestep.ui \ qmakestep.ui \ qmakeprojectconfigwidget.ui \ - librarydetailswidget.ui \ - wizards/testwizardpage.ui + librarydetailswidget.ui RESOURCES += qmakeprojectmanager.qrc \ wizards/wizards.qrc diff --git a/src/plugins/qmakeprojectmanager/qmakeprojectmanager.qbs b/src/plugins/qmakeprojectmanager/qmakeprojectmanager.qbs index 027173ce519..829d1eb4934 100644 --- a/src/plugins/qmakeprojectmanager/qmakeprojectmanager.qbs +++ b/src/plugins/qmakeprojectmanager/qmakeprojectmanager.qbs @@ -90,10 +90,6 @@ Project { "subdirsprojectwizard.cpp", "subdirsprojectwizard.h", "subdirsprojectwizarddialog.cpp", "subdirsprojectwizarddialog.h", "simpleprojectwizard.cpp", "simpleprojectwizard.h", - "testwizard.cpp", "testwizard.h", - "testwizarddialog.cpp", "testwizarddialog.h", - "testwizardpage.cpp", "testwizardpage.h", - "testwizardpage.ui", "wizards.qrc" ] } diff --git a/src/plugins/qmakeprojectmanager/qmakeprojectmanagerplugin.cpp b/src/plugins/qmakeprojectmanager/qmakeprojectmanagerplugin.cpp index 8c60a5333c7..f52917ab202 100644 --- a/src/plugins/qmakeprojectmanager/qmakeprojectmanagerplugin.cpp +++ b/src/plugins/qmakeprojectmanager/qmakeprojectmanagerplugin.cpp @@ -34,7 +34,6 @@ #include "desktopqmakerunconfiguration.h" #include "wizards/guiappwizard.h" #include "wizards/librarywizard.h" -#include "wizards/testwizard.h" #include "wizards/simpleprojectwizard.h" #include "wizards/subdirsprojectwizard.h" #include "customwidgetwizard/customwidgetwizard.h" @@ -148,7 +147,6 @@ bool QmakeProjectManagerPlugin::initialize(const QStringList &arguments, QString new SubdirsProjectWizard, new GuiAppWizard, new LibraryWizard, - new TestWizard, new CustomWidgetWizard, new SimpleProjectWizard }; diff --git a/src/plugins/qmakeprojectmanager/wizards/testwizard.cpp b/src/plugins/qmakeprojectmanager/wizards/testwizard.cpp deleted file mode 100644 index 3f2ebfc6191..00000000000 --- a/src/plugins/qmakeprojectmanager/wizards/testwizard.cpp +++ /dev/null @@ -1,183 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** 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 The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3 as published by the Free Software -** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-3.0.html. -** -****************************************************************************/ - -#include "testwizard.h" -#include "testwizarddialog.h" - -#include -#include -#include - -#include -#include - -#include -#include -#include - -namespace QmakeProjectManager { -namespace Internal { - -TestWizard::TestWizard() -{ - setId("L.Qt4Test"); - setCategory(QLatin1String(ProjectExplorer::Constants::QT_PROJECT_WIZARD_CATEGORY)); - setDisplayCategory(QCoreApplication::translate("ProjectExplorer", - ProjectExplorer::Constants::QT_PROJECT_WIZARD_CATEGORY_DISPLAY)); - setDisplayName(tr("Qt Unit Test")); - setDescription(tr("Creates a QTestLib-based unit test for a feature or a class. " - "Unit tests allow you to verify that the code is fit for use " - "and that there are no regressions.")); - setIcon(QIcon(QLatin1String(":/wizards/images/console.png"))); - setRequiredFeatures({QtSupport::Constants::FEATURE_QT_CONSOLE, QtSupport::Constants::FEATURE_QT_PREFIX}); -} - -Core::BaseFileWizard *TestWizard::create(QWidget *parent, const Core::WizardDialogParameters ¶meters) const -{ - TestWizardDialog *dialog = new TestWizardDialog(this, displayName(), icon(), parent, parameters); - dialog->setProjectName(TestWizardDialog::uniqueProjectName(parameters.defaultPath())); - return dialog; -} - -// ---------------- code generation helpers -static const char initTestCaseC[] = "initTestCase"; -static const char cleanupTestCaseC[] = "cleanupTestCase"; -static const char closeFunctionC[] = "}\n\n"; -static const char testDataTypeC[] = "QString"; - -static inline void writeVoidMemberDeclaration(QTextStream &str, - const QString &indent, - const QString &methodName) -{ - str << indent << "void " << methodName << "();\n"; -} - -static inline void writeVoidMemberBody(QTextStream &str, - const QString &className, - const QString &methodName, - bool close = true) -{ - str << "void " << className << "::" << methodName << "()\n{\n"; - if (close) - str << closeFunctionC; -} - -static QString generateTestCode(const TestWizardParameters &testParams, - const QString &sourceBaseName) -{ - QString rc; - const QString indent = QString(4, QLatin1Char(' ')); - QTextStream str(&rc); - // Includes - str << CppTools::AbstractEditorSupport::licenseTemplate(testParams.fileName, testParams.className) - << "#include \n#include \n"; - if (testParams.requiresQApplication) - str << "#include \n"; - // Class declaration - str << "\nclass " << testParams.className << " : public QObject\n" - "{\n" << indent << "Q_OBJECT\n\npublic:\n" - << indent << testParams.className << "();\n\nprivate Q_SLOTS:\n"; - if (testParams.initializationCode) { - writeVoidMemberDeclaration(str, indent, QLatin1String(initTestCaseC)); - writeVoidMemberDeclaration(str, indent, QLatin1String(cleanupTestCaseC)); - } - const QString dataSlot = testParams.testSlot + QLatin1String("_data"); - if (testParams.useDataSet) - writeVoidMemberDeclaration(str, indent, dataSlot); - writeVoidMemberDeclaration(str, indent, testParams.testSlot); - str << "};\n\n"; - // Code: Constructor - str << testParams.className << "::" << testParams.className << "()\n{\n}\n\n"; - // Code: Initialization slots - if (testParams.initializationCode) { - writeVoidMemberBody(str, testParams.className, QLatin1String(initTestCaseC)); - writeVoidMemberBody(str, testParams.className, QLatin1String(cleanupTestCaseC)); - } - // test data generation slot - if (testParams.useDataSet) { - writeVoidMemberBody(str, testParams.className, dataSlot, false); - str << indent << "QTest::addColumn<" << testDataTypeC << ">(\"data\");\n" - << indent << "QTest::newRow(\"0\") << " << testDataTypeC << "();\n" - << closeFunctionC; - } - // Test slot with data or dummy - writeVoidMemberBody(str, testParams.className, testParams.testSlot, false); - if (testParams.useDataSet) - str << indent << "QFETCH(" << testDataTypeC << ", data);\n"; - switch (testParams.type) { - case TestWizardParameters::Test: - str << indent << "QVERIFY2(true, \"Failure\");\n"; - break; - case TestWizardParameters::Benchmark: - str << indent << "QBENCHMARK {\n" << indent << "}\n"; - break; - } - str << closeFunctionC; - // Main & moc include - str << (testParams.requiresQApplication ? "QTEST_MAIN" : "QTEST_APPLESS_MAIN") - << '(' << testParams.className << ")\n\n" - << "#include \"" << sourceBaseName << ".moc\"\n"; - return rc; -} - -Core::GeneratedFiles TestWizard::generateFiles(const QWizard *w, QString *errorMessage) const -{ - Q_UNUSED(errorMessage) - - const TestWizardDialog *wizardDialog = qobject_cast(w); - QTC_ASSERT(wizardDialog, return Core::GeneratedFiles()); - - const QtProjectParameters projectParams = wizardDialog->projectParameters(); - const TestWizardParameters testParams = wizardDialog->testParameters(); - const QString projectPath = projectParams.projectPath(); - - // Create files: Source - const QString sourceFilePath = Core::BaseFileWizardFactory::buildFileName(projectPath, testParams.fileName, sourceSuffix()); - const QFileInfo sourceFileInfo(sourceFilePath); - - Core::GeneratedFile source(sourceFilePath); - source.setAttributes(Core::GeneratedFile::OpenEditorAttribute); - source.setContents(generateTestCode(testParams, sourceFileInfo.baseName())); - - // Create profile with define for base dir to find test data - const QString profileName = Core::BaseFileWizardFactory::buildFileName(projectPath, projectParams.fileName, profileSuffix()); - Core::GeneratedFile profile(profileName); - profile.setAttributes(Core::GeneratedFile::OpenProjectAttribute); - QString contents; - { - QTextStream proStr(&contents); - QtProjectParameters::writeProFileHeader(proStr); - projectParams.writeProFile(proStr); - proStr << "\n\nSOURCES +=" - << " \\\n " << Utils::FileName::fromString(sourceFilePath).fileName() - << " \n\nDEFINES += SRCDIR=\\\\\\\"$$PWD/\\\\\\\"\n"; - } - profile.setContents(contents); - - return Core::GeneratedFiles() << source << profile; -} - -} // namespace Internal -} // namespace QmakeProjectManager diff --git a/src/plugins/qmakeprojectmanager/wizards/testwizard.h b/src/plugins/qmakeprojectmanager/wizards/testwizard.h deleted file mode 100644 index 421cf957438..00000000000 --- a/src/plugins/qmakeprojectmanager/wizards/testwizard.h +++ /dev/null @@ -1,47 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** 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 The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3 as published by the Free Software -** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-3.0.html. -** -****************************************************************************/ - -#pragma once - -#include "qtwizard.h" - -namespace QmakeProjectManager { -namespace Internal { - -class TestWizard : public QtWizard -{ - Q_OBJECT - -public: - TestWizard(); - -protected: - Core::BaseFileWizard *create(QWidget *parent, const Core::WizardDialogParameters ¶meters) const; - - Core::GeneratedFiles generateFiles(const QWizard *w, QString *errorMessage) const; -}; - -} // namespace Internal -} // namespace QmakeProjectManager diff --git a/src/plugins/qmakeprojectmanager/wizards/testwizarddialog.cpp b/src/plugins/qmakeprojectmanager/wizards/testwizarddialog.cpp deleted file mode 100644 index dd867958fc6..00000000000 --- a/src/plugins/qmakeprojectmanager/wizards/testwizarddialog.cpp +++ /dev/null @@ -1,93 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** 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 The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3 as published by the Free Software -** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-3.0.html. -** -****************************************************************************/ - -#include "testwizarddialog.h" -#include "testwizardpage.h" -#include - -#include - -enum PageIds { StartPageId = 0 }; - -namespace QmakeProjectManager { -namespace Internal { - -const char *TestWizardParameters::filePrefix = "tst_"; - -TestWizardParameters::TestWizardParameters() : - type(Test), - initializationCode(false), - useDataSet(false), - requiresQApplication(requiresQApplicationDefault) -{ -} - -TestWizardDialog::TestWizardDialog(const Core::BaseFileWizardFactory *factory, - const QString &templateName, - const QIcon &icon, - QWidget *parent, - const Core::WizardDialogParameters ¶meters) : - BaseQmakeProjectWizardDialog(factory, true, parent, parameters), - m_testPage(new TestWizardPage) -{ - setIntroDescription(tr("This wizard generates a Qt Unit Test " - "consisting of a single source file with a test class.")); - setWindowIcon(icon); - setWindowTitle(templateName); - setSelectedModules(QLatin1String("core testlib"), true); - if (!parameters.extraValues().contains(QLatin1String(ProjectExplorer::Constants::PROJECT_KIT_IDS))) - addTargetSetupPage(); - addModulesPage(); - m_testPageId = addPage(m_testPage); - addExtensionPages(extensionPages()); - connect(this, &QWizard::currentIdChanged, this, &TestWizardDialog::slotCurrentIdChanged); -} - -void TestWizardDialog::slotCurrentIdChanged(int id) -{ - if (id == m_testPageId) - m_testPage->setProjectName(projectName()); -} - -TestWizardParameters TestWizardDialog::testParameters() const -{ - return m_testPage->parameters(); -} - -QtProjectParameters TestWizardDialog::projectParameters() const -{ - QtProjectParameters rc; - rc.type = QtProjectParameters::ConsoleApp; - rc.fileName = projectName(); - rc.path = path(); - // Name binary "tst_xx" after the main source - rc.target = QFileInfo(m_testPage->sourcefileName()).baseName(); - rc.selectedModules = selectedModulesList(); - rc.deselectedModules = deselectedModulesList(); - return rc; -} - -} // namespace Internal -} // namespace QmakeProjectManager diff --git a/src/plugins/qmakeprojectmanager/wizards/testwizarddialog.h b/src/plugins/qmakeprojectmanager/wizards/testwizarddialog.h deleted file mode 100644 index 8efcf0bb477..00000000000 --- a/src/plugins/qmakeprojectmanager/wizards/testwizarddialog.h +++ /dev/null @@ -1,75 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** 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 The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3 as published by the Free Software -** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-3.0.html. -** -****************************************************************************/ - -#pragma once - -#include "qtwizard.h" - -namespace QmakeProjectManager { -namespace Internal { - -class TestWizardPage; - -// Parameters of the test wizard. -struct TestWizardParameters { - enum { requiresQApplicationDefault = 0 }; - - static const char *filePrefix; - - TestWizardParameters(); - - - enum Type { Test, Benchmark }; - - Type type; - bool initializationCode; - bool useDataSet; - bool requiresQApplication; - - QString className; - QString testSlot; - QString fileName; -}; - -class TestWizardDialog : public BaseQmakeProjectWizardDialog -{ - Q_OBJECT -public: - explicit TestWizardDialog(const Core::BaseFileWizardFactory *factory, const QString &templateName, - const QIcon &icon, - QWidget *parent, - const Core::WizardDialogParameters ¶meters); - - TestWizardParameters testParameters() const; - QtProjectParameters projectParameters() const; - -private: - void slotCurrentIdChanged(int id); - TestWizardPage *m_testPage; - int m_testPageId; -}; - -} // namespace Internal -} // namespace QmakeProjectManager diff --git a/src/plugins/qmakeprojectmanager/wizards/testwizardpage.cpp b/src/plugins/qmakeprojectmanager/wizards/testwizardpage.cpp deleted file mode 100644 index b936353c4b3..00000000000 --- a/src/plugins/qmakeprojectmanager/wizards/testwizardpage.cpp +++ /dev/null @@ -1,137 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** 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 The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3 as published by the Free Software -** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-3.0.html. -** -****************************************************************************/ - -#include "testwizardpage.h" -#include "testwizarddialog.h" -#include "qtwizard.h" -#include "ui_testwizardpage.h" - -#include - -namespace QmakeProjectManager { -namespace Internal { - -TestWizardPage::TestWizardPage(QWidget *parent) : - QWizardPage(parent), - m_sourceSuffix(QtWizard::sourceSuffix()), - m_lowerCaseFileNames(QtWizard::lowerCaseFiles()), - ui(new Ui::TestWizardPage), - m_fileNameEdited(false), - m_valid(false) -{ - setTitle(tr("Test Class Information")); - ui->setupUi(this); - ui->testSlotLineEdit->setText(QLatin1String("testCase1")); - ui->testClassLineEdit->setLowerCaseFileName(m_lowerCaseFileNames); - ui->qApplicationCheckBox->setChecked(TestWizardParameters::requiresQApplicationDefault); - connect(ui->testClassLineEdit, &Utils::ClassNameValidatingLineEdit::updateFileName, - this, &TestWizardPage::slotClassNameEdited); - connect(ui->fileLineEdit, &QLineEdit::textEdited, \ - this, &TestWizardPage::slotFileNameEdited); - connect(ui->testClassLineEdit, &Utils::FancyLineEdit::validChanged, - this, &TestWizardPage::slotUpdateValid); - connect(ui->testSlotLineEdit, &Utils::FancyLineEdit::validChanged, - this, &TestWizardPage::slotUpdateValid); - connect(ui->fileLineEdit, &Utils::FancyLineEdit::validChanged, - this, &TestWizardPage::slotUpdateValid); - - setProperty(Utils::SHORT_TITLE_PROPERTY, tr("Details")); -} - -TestWizardPage::~TestWizardPage() -{ - delete ui; -} - -bool TestWizardPage::isComplete() const -{ - return m_valid; -} - -QString TestWizardPage::sourcefileName() const -{ - return ui->fileLineEdit->text(); -} - -TestWizardParameters TestWizardPage::parameters() const -{ - TestWizardParameters rc; - rc.type = static_cast(ui->typeComboBox->currentIndex()); - rc.initializationCode = ui->initCheckBox->isChecked(); - rc.useDataSet = ui->dataCheckBox->isChecked(); - rc.requiresQApplication = ui->qApplicationCheckBox->isChecked(); - rc.className = ui->testClassLineEdit->text(); - rc.testSlot = ui->testSlotLineEdit->text(); - rc.fileName = sourcefileName(); - return rc; -} - -static QString fileNameFromClass(const QString &className, - bool lowerCase, - const QString &suffix) -{ - QString rc = QLatin1String(TestWizardParameters::filePrefix); - rc += lowerCase ? className.toLower() : className; - rc += QLatin1Char('.'); - rc += suffix; - return rc; -} - -void TestWizardPage::setProjectName(const QString &t) -{ - if (t.isEmpty()) - return; - // initially populate - QString className = t; - className[0] = className.at(0).toUpper(); - className += QLatin1String("Test"); - ui->testClassLineEdit->setText(className); - ui->fileLineEdit->setText(fileNameFromClass(className, m_lowerCaseFileNames, m_sourceSuffix)); -} - -void TestWizardPage::slotClassNameEdited(const QString &className) -{ - if (!m_fileNameEdited) - ui->fileLineEdit->setText(fileNameFromClass(className, m_lowerCaseFileNames, m_sourceSuffix)); -} - -void TestWizardPage::slotFileNameEdited() -{ - m_fileNameEdited = true; -} - -void TestWizardPage::slotUpdateValid() -{ - const bool newValid = ui->fileLineEdit->isValid() - && ui->testClassLineEdit->isValid() - && ui->testSlotLineEdit->isValid(); - if (newValid != m_valid) { - m_valid = newValid; - emit completeChanged(); - } -} - -} // namespace Internal -} // namespace QmakeProjectManager diff --git a/src/plugins/qmakeprojectmanager/wizards/testwizardpage.h b/src/plugins/qmakeprojectmanager/wizards/testwizardpage.h deleted file mode 100644 index e414ba26b98..00000000000 --- a/src/plugins/qmakeprojectmanager/wizards/testwizardpage.h +++ /dev/null @@ -1,67 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** 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 The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3 as published by the Free Software -** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-3.0.html. -** -****************************************************************************/ - -#pragma once - -#include - -namespace QmakeProjectManager { -namespace Internal { - -namespace Ui { class TestWizardPage; } - -struct TestWizardParameters; - -/* TestWizardPage: Let's the user input test class name, slot - * (for which a CLassNameValidatingLineEdit is abused) and file name. */ - -class TestWizardPage : public QWizardPage -{ - Q_OBJECT - -public: - explicit TestWizardPage(QWidget *parent = 0); - ~TestWizardPage(); - virtual bool isComplete() const; - - TestWizardParameters parameters() const; - QString sourcefileName() const; - - void setProjectName(const QString &); - -private: - void slotClassNameEdited(const QString&); - void slotFileNameEdited(); - void slotUpdateValid(); - - const QString m_sourceSuffix; - const bool m_lowerCaseFileNames; - Ui::TestWizardPage *ui; - bool m_fileNameEdited; - bool m_valid; -}; - -} // namespace Internal -} // namespace QmakeProjectManager diff --git a/src/plugins/qmakeprojectmanager/wizards/testwizardpage.ui b/src/plugins/qmakeprojectmanager/wizards/testwizardpage.ui deleted file mode 100644 index 6b964d88778..00000000000 --- a/src/plugins/qmakeprojectmanager/wizards/testwizardpage.ui +++ /dev/null @@ -1,141 +0,0 @@ - - - QmakeProjectManager::Internal::TestWizardPage - - - WizardPage - - - - - - Specify basic information about the test class for which you want to generate skeleton source code file. - - - true - - - - - - - Qt::Vertical - - - QSizePolicy::Fixed - - - - 0 - 20 - - - - - - - - QFormLayout::ExpandingFieldsGrow - - - - - Class name: - - - - - - - - - - Test slot: - - - - - - - - - - Type: - - - - - - - - Test - - - - - Benchmark - - - - - - - - Use a test data set - - - - - - - Requires QApplication - - - - - - - Generate initialization and cleanup code - - - - - - - File: - - - - - - - true - - - - - - - - - Qt::Vertical - - - - - - - - Utils::ClassNameValidatingLineEdit - QLineEdit -
utils/classnamevalidatinglineedit.h
-
- - Utils::FileNameValidatingLineEdit - QLineEdit -
utils/filenamevalidatinglineedit.h
-
-
- - -