forked from qt-creator/qt-creator
Squish: Add Create New Squish Suite
Change-Id: I9246f22bb5f4cbccb2fd4d39218e4d6594f88a89 Reviewed-by: David Schulz <david.schulz@qt.io>
This commit is contained in:
107
share/qtcreator/templates/wizards/projects/squish/wizard.json
Normal file
107
share/qtcreator/templates/wizards/projects/squish/wizard.json
Normal file
@@ -0,0 +1,107 @@
|
|||||||
|
{
|
||||||
|
"version": 1,
|
||||||
|
"supportedProjectTypes": [ "Squish" ],
|
||||||
|
"id": "S.SquishTestSuite",
|
||||||
|
"category": "T.Squish",
|
||||||
|
"trDescription": "Creates a new Squish test suite.",
|
||||||
|
"trDisplayName": "Squish Test Suite",
|
||||||
|
"trDisplayCategory": "Squish",
|
||||||
|
"iconText": "STS",
|
||||||
|
"enabled": "%{JS: value('Plugins').indexOf('Squish') >= 0}",
|
||||||
|
|
||||||
|
"options":
|
||||||
|
[
|
||||||
|
{
|
||||||
|
"key": "SquishSuiteName",
|
||||||
|
"value": "%{JS: '%{SuiteName}'.startsWith('suite_') ? '%{SuiteName}' : 'suite_%{SuiteName}'}"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"key": "TargetPath",
|
||||||
|
"value": "%{Path}/%{SquishSuiteName}"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"key": "AUT",
|
||||||
|
"value": "%{ChosenAUT}"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"key": "Language",
|
||||||
|
"value": "%{ChosenLanguage}"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"key": "Toolkit",
|
||||||
|
"value": "%{ChosenToolkit}"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
|
||||||
|
"pages":
|
||||||
|
[
|
||||||
|
{
|
||||||
|
"trDisplayName": "Location",
|
||||||
|
"trShortTitle": "Location",
|
||||||
|
"trSubTitle": "Specify name of the Test suite and directory where to create the Squish test suite.",
|
||||||
|
"typeId": "Fields",
|
||||||
|
"data" :
|
||||||
|
[
|
||||||
|
{
|
||||||
|
"name": "SuiteName",
|
||||||
|
"trDisplayName": "Test Suite Name:",
|
||||||
|
"type": "LineEdit"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "Path",
|
||||||
|
"trDisplayName": "Test Suite folder's parent folder:",
|
||||||
|
"type": "PathChooser",
|
||||||
|
"data":
|
||||||
|
{
|
||||||
|
"kind": "existingDirectory",
|
||||||
|
"basePath": "%{InitialPath}",
|
||||||
|
"path": "%{InitialPath}"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"trDisplayName": "Setup",
|
||||||
|
"trShortTitle": "Setup",
|
||||||
|
"trSubTitle": "Choose the GUI toolkit used by the application you want to create Squish Test Suite for.",
|
||||||
|
"typeId": "SquishToolkits",
|
||||||
|
"data": {}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"trDisplayName": "Script Language",
|
||||||
|
"trShortTitle": "Language",
|
||||||
|
"trSubTitle": "Choose the scripting language to be used for the Test Suite's test scripts.",
|
||||||
|
"typeId": "SquishScriptLanguage",
|
||||||
|
"data": {}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"trDisplayName": "Application Under Test",
|
||||||
|
"trShortTitle": "AUT",
|
||||||
|
"trSubTitle": "Choose the application (AUT) that you want this Test Suite to test.",
|
||||||
|
"typeId": "SquishAUT",
|
||||||
|
"data": {}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"trDisplayName": "Summary",
|
||||||
|
"trShortTitle": "Summary",
|
||||||
|
"typeId": "Summary",
|
||||||
|
"data":
|
||||||
|
{
|
||||||
|
"hideProjectUi": true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
],
|
||||||
|
|
||||||
|
"generators":
|
||||||
|
[
|
||||||
|
{
|
||||||
|
"typeId": "SquishSuiteGenerator",
|
||||||
|
"data": {
|
||||||
|
"mode": "TestSuite",
|
||||||
|
"aut": "%{AUT}",
|
||||||
|
"language": "%{Language}",
|
||||||
|
"toolkit": "%{Toolkit}"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
@@ -1,6 +1,6 @@
|
|||||||
add_qtc_plugin(Squish
|
add_qtc_plugin(Squish
|
||||||
PLUGIN_DEPENDS
|
PLUGIN_DEPENDS
|
||||||
Core Debugger TextEditor
|
Core Debugger ProjectExplorer TextEditor
|
||||||
DEPENDS ExtensionSystem Utils
|
DEPENDS ExtensionSystem Utils
|
||||||
SOURCES
|
SOURCES
|
||||||
deletesymbolicnamedialog.cpp deletesymbolicnamedialog.h
|
deletesymbolicnamedialog.cpp deletesymbolicnamedialog.h
|
||||||
@@ -24,6 +24,7 @@ add_qtc_plugin(Squish
|
|||||||
squishtesttreeview.cpp squishtesttreeview.h
|
squishtesttreeview.cpp squishtesttreeview.h
|
||||||
squishtools.cpp squishtools.h
|
squishtools.cpp squishtools.h
|
||||||
squishtr.h
|
squishtr.h
|
||||||
|
squishwizardpages.cpp squishwizardpages.h
|
||||||
squishxmloutputhandler.cpp squishxmloutputhandler.h
|
squishxmloutputhandler.cpp squishxmloutputhandler.h
|
||||||
suiteconf.cpp suiteconf.h
|
suiteconf.cpp suiteconf.h
|
||||||
symbolnameitemdelegate.cpp symbolnameitemdelegate.h
|
symbolnameitemdelegate.cpp symbolnameitemdelegate.h
|
||||||
|
|||||||
@@ -5,6 +5,7 @@ QtcPlugin {
|
|||||||
|
|
||||||
Depends { name: "Core" }
|
Depends { name: "Core" }
|
||||||
Depends { name: "Debugger" }
|
Depends { name: "Debugger" }
|
||||||
|
Depends { name: "ProjectExplorer" }
|
||||||
Depends { name: "TextEditor" }
|
Depends { name: "TextEditor" }
|
||||||
Depends { name: "Utils" }
|
Depends { name: "Utils" }
|
||||||
|
|
||||||
@@ -53,6 +54,8 @@ QtcPlugin {
|
|||||||
"squishtools.cpp",
|
"squishtools.cpp",
|
||||||
"squishtools.h",
|
"squishtools.h",
|
||||||
"squishtr.h",
|
"squishtr.h",
|
||||||
|
"squishwizardpages.cpp",
|
||||||
|
"squishwizardpages.h",
|
||||||
"squishxmloutputhandler.cpp",
|
"squishxmloutputhandler.cpp",
|
||||||
"squishxmloutputhandler.h",
|
"squishxmloutputhandler.h",
|
||||||
"suiteconf.cpp",
|
"suiteconf.cpp",
|
||||||
|
|||||||
@@ -163,6 +163,7 @@ void SquishFileHandler::openTestSuites()
|
|||||||
const QString suiteName = suiteDir.dirName();
|
const QString suiteName = suiteDir.dirName();
|
||||||
const QStringList cases = SuiteConf::validTestCases(suite);
|
const QStringList cases = SuiteConf::validTestCases(suite);
|
||||||
const QFileInfo suiteConf(suiteDir, "suite.conf");
|
const QFileInfo suiteConf(suiteDir, "suite.conf");
|
||||||
|
|
||||||
if (m_suites.contains(suiteName)) {
|
if (m_suites.contains(suiteName)) {
|
||||||
if (replaceSuite == QMessageBox::YesToAll) {
|
if (replaceSuite == QMessageBox::YesToAll) {
|
||||||
modifySuiteItem(suiteName, suiteConf.absoluteFilePath(), cases);
|
modifySuiteItem(suiteName, suiteConf.absoluteFilePath(), cases);
|
||||||
@@ -192,6 +193,32 @@ void SquishFileHandler::openTestSuites()
|
|||||||
emit suitesOpened();
|
emit suitesOpened();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void SquishFileHandler::openTestSuite(const Utils::FilePath &suitePath)
|
||||||
|
{
|
||||||
|
const QString suiteName = suitePath.parentDir().fileName();
|
||||||
|
const QString suitePathStr = suitePath.toString();
|
||||||
|
const QStringList cases = SuiteConf::validTestCases(suitePath.parentDir().toString());
|
||||||
|
|
||||||
|
if (m_suites.contains(suiteName)) {
|
||||||
|
QMessageBox::Button replaceSuite
|
||||||
|
= QMessageBox::question(Core::ICore::dialogParent(),
|
||||||
|
Tr::tr("Suite Already Open"),
|
||||||
|
Tr::tr("A test suite with the name \"%1\" is already open."
|
||||||
|
"\nClose the opened test suite and replace it "
|
||||||
|
"with the new one?")
|
||||||
|
.arg(suiteName),
|
||||||
|
QMessageBox::Yes | QMessageBox::No,
|
||||||
|
QMessageBox::No);
|
||||||
|
if (replaceSuite == QMessageBox::Yes)
|
||||||
|
modifySuiteItem(suiteName, suitePathStr, cases);
|
||||||
|
} else {
|
||||||
|
SquishTestTreeItem *item = createSuiteTreeItem(suiteName, suitePathStr, cases);
|
||||||
|
// TODO add file watcher
|
||||||
|
m_suites.insert(suiteName, suitePathStr);
|
||||||
|
emit testTreeItemCreated(item);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void SquishFileHandler::closeTestSuite(const QString &suiteName)
|
void SquishFileHandler::closeTestSuite(const QString &suiteName)
|
||||||
{
|
{
|
||||||
if (!m_suites.contains(suiteName))
|
if (!m_suites.contains(suiteName))
|
||||||
|
|||||||
@@ -9,6 +9,8 @@
|
|||||||
#include <QObject>
|
#include <QObject>
|
||||||
#include <QString>
|
#include <QString>
|
||||||
|
|
||||||
|
namespace Utils { class FilePath; }
|
||||||
|
|
||||||
namespace Squish {
|
namespace Squish {
|
||||||
namespace Internal {
|
namespace Internal {
|
||||||
|
|
||||||
@@ -20,6 +22,7 @@ public:
|
|||||||
~SquishFileHandler() override = default;
|
~SquishFileHandler() override = default;
|
||||||
static SquishFileHandler *instance();
|
static SquishFileHandler *instance();
|
||||||
void openTestSuites();
|
void openTestSuites();
|
||||||
|
void openTestSuite(const Utils::FilePath &suitePath);
|
||||||
void closeTestSuite(const QString &suiteName);
|
void closeTestSuite(const QString &suiteName);
|
||||||
void closeAllTestSuites();
|
void closeAllTestSuites();
|
||||||
void runTestCase(const QString &suiteName, const QString &testCaseName);
|
void runTestCase(const QString &suiteName, const QString &testCaseName);
|
||||||
|
|||||||
@@ -12,6 +12,9 @@
|
|||||||
#include <coreplugin/editormanager/editormanager.h>
|
#include <coreplugin/editormanager/editormanager.h>
|
||||||
#include <coreplugin/find/itemviewfind.h>
|
#include <coreplugin/find/itemviewfind.h>
|
||||||
#include <coreplugin/icore.h>
|
#include <coreplugin/icore.h>
|
||||||
|
#include <coreplugin/iwizardfactory.h>
|
||||||
|
|
||||||
|
#include <utils/algorithm.h>
|
||||||
#include <utils/checkablemessagebox.h>
|
#include <utils/checkablemessagebox.h>
|
||||||
#include <utils/qtcassert.h>
|
#include <utils/qtcassert.h>
|
||||||
|
|
||||||
@@ -168,6 +171,21 @@ void SquishNavigationWidget::contextMenuEvent(QContextMenuEvent *event)
|
|||||||
QAction *createNewTestSuite = new QAction(Tr::tr("Create New Test Suite..."), &menu);
|
QAction *createNewTestSuite = new QAction(Tr::tr("Create New Test Suite..."), &menu);
|
||||||
menu.addAction(createNewTestSuite);
|
menu.addAction(createNewTestSuite);
|
||||||
|
|
||||||
|
connect(createNewTestSuite,
|
||||||
|
&QAction::triggered,
|
||||||
|
this, [this]() {
|
||||||
|
if (!Core::ICore::isNewItemDialogRunning()) {
|
||||||
|
Core::ICore::showNewItemDialog(
|
||||||
|
Tr::tr("New Project", "Title of dialog"),
|
||||||
|
Utils::filtered(Core::IWizardFactory::allWizardFactories(),
|
||||||
|
[](Core::IWizardFactory *f) {
|
||||||
|
return f->supportedProjectTypes().contains("Squish");
|
||||||
|
}));
|
||||||
|
} else {
|
||||||
|
Core::ICore::raiseWindow(Core::ICore::newItemDialog());
|
||||||
|
}
|
||||||
|
|
||||||
|
});
|
||||||
connect(openSquishSuites,
|
connect(openSquishSuites,
|
||||||
&QAction::triggered,
|
&QAction::triggered,
|
||||||
SquishFileHandler::instance(),
|
SquishFileHandler::instance(),
|
||||||
|
|||||||
@@ -4,6 +4,7 @@
|
|||||||
#include "squishplugin.h"
|
#include "squishplugin.h"
|
||||||
|
|
||||||
#include "objectsmapeditor.h"
|
#include "objectsmapeditor.h"
|
||||||
|
#include "squish/squishwizardpages.h"
|
||||||
#include "squishnavigationwidget.h"
|
#include "squishnavigationwidget.h"
|
||||||
#include "squishoutputpane.h"
|
#include "squishoutputpane.h"
|
||||||
#include "squishresultmodel.h"
|
#include "squishresultmodel.h"
|
||||||
@@ -18,6 +19,8 @@
|
|||||||
|
|
||||||
#include <extensionsystem/pluginmanager.h>
|
#include <extensionsystem/pluginmanager.h>
|
||||||
|
|
||||||
|
#include <projectexplorer/jsonwizard/jsonwizardfactory.h>
|
||||||
|
|
||||||
#include <utils/mimetypes/mimedatabase.h>
|
#include <utils/mimetypes/mimedatabase.h>
|
||||||
#include <utils/qtcassert.h>
|
#include <utils/qtcassert.h>
|
||||||
|
|
||||||
@@ -56,6 +59,11 @@ SquishPluginPrivate::SquishPluginPrivate()
|
|||||||
m_outputPane = SquishOutputPane::instance();
|
m_outputPane = SquishOutputPane::instance();
|
||||||
m_squishTools = new SquishTools;
|
m_squishTools = new SquishTools;
|
||||||
initializeMenuEntries();
|
initializeMenuEntries();
|
||||||
|
|
||||||
|
ProjectExplorer::JsonWizardFactory::registerPageFactory(new SquishToolkitsPageFactory);
|
||||||
|
ProjectExplorer::JsonWizardFactory::registerPageFactory(new SquishScriptLanguagePageFactory);
|
||||||
|
ProjectExplorer::JsonWizardFactory::registerPageFactory(new SquishAUTPageFactory);
|
||||||
|
ProjectExplorer::JsonWizardFactory::registerGeneratorFactory(new SquishGeneratorFactory);
|
||||||
}
|
}
|
||||||
|
|
||||||
SquishPluginPrivate::~SquishPluginPrivate()
|
SquishPluginPrivate::~SquishPluginPrivate()
|
||||||
|
|||||||
349
src/plugins/squish/squishwizardpages.cpp
Normal file
349
src/plugins/squish/squishwizardpages.cpp
Normal file
@@ -0,0 +1,349 @@
|
|||||||
|
// Copyright (C) 2022 The Qt Company Ltd.
|
||||||
|
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0 WITH Qt-GPL-exception-1.0
|
||||||
|
|
||||||
|
#include "squishwizardpages.h"
|
||||||
|
|
||||||
|
#include "squishfilehandler.h"
|
||||||
|
#include "squishsettings.h"
|
||||||
|
#include "squishtools.h"
|
||||||
|
#include "squishtr.h"
|
||||||
|
|
||||||
|
#include <utils/qtcassert.h>
|
||||||
|
|
||||||
|
#include <QApplication>
|
||||||
|
#include <QButtonGroup>
|
||||||
|
#include <QComboBox>
|
||||||
|
#include <QGroupBox>
|
||||||
|
#include <QLineEdit>
|
||||||
|
#include <QRadioButton>
|
||||||
|
#include <QTimer>
|
||||||
|
#include <QVBoxLayout>
|
||||||
|
|
||||||
|
namespace Squish {
|
||||||
|
namespace Internal {
|
||||||
|
|
||||||
|
/************************************ ToolkitsPage ***********************************************/
|
||||||
|
|
||||||
|
SquishToolkitsPageFactory::SquishToolkitsPageFactory()
|
||||||
|
{
|
||||||
|
setTypeIdsSuffix("SquishToolkits");
|
||||||
|
}
|
||||||
|
|
||||||
|
Utils::WizardPage *SquishToolkitsPageFactory::create(ProjectExplorer::JsonWizard *,
|
||||||
|
Utils::Id typeId, const QVariant &)
|
||||||
|
{
|
||||||
|
QTC_ASSERT(canCreate(typeId), return nullptr);
|
||||||
|
return new SquishToolkitsPage;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool SquishToolkitsPageFactory::validateData(Utils::Id typeId, const QVariant &, QString *)
|
||||||
|
{
|
||||||
|
QTC_ASSERT(canCreate(typeId), return false);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
SquishToolkitsPage::SquishToolkitsPage()
|
||||||
|
{
|
||||||
|
resize(400, 300);
|
||||||
|
setTitle(Tr::tr("Create New Squish Test Suite"));
|
||||||
|
|
||||||
|
auto layout = new QHBoxLayout(this);
|
||||||
|
auto groupBox = new QGroupBox(Tr::tr("Available GUI toolkits:"), this);
|
||||||
|
auto buttonLayout = new QVBoxLayout(groupBox);
|
||||||
|
|
||||||
|
m_buttonGroup = new QButtonGroup(this);
|
||||||
|
m_buttonGroup->setExclusive(true);
|
||||||
|
const QStringList toolkits = { "Android", "iOS", "Java", "Mac", "Qt", "Tk", "VNC", "Windows",
|
||||||
|
"Web", "XView"};
|
||||||
|
for (const QString &toolkit : toolkits) {
|
||||||
|
auto button = new QRadioButton(toolkit, this);
|
||||||
|
button->setEnabled(false);
|
||||||
|
m_buttonGroup->addButton(button);
|
||||||
|
buttonLayout->addWidget(button);
|
||||||
|
}
|
||||||
|
groupBox->setLayout(buttonLayout);
|
||||||
|
layout->addWidget(groupBox);
|
||||||
|
auto hiddenLineEdit = new QLineEdit(this);
|
||||||
|
hiddenLineEdit->setVisible(false);
|
||||||
|
layout->addWidget(hiddenLineEdit);
|
||||||
|
registerFieldWithName("ChosenToolkit", hiddenLineEdit);
|
||||||
|
|
||||||
|
m_hiddenLineEdit = new QLineEdit(this);
|
||||||
|
m_hiddenLineEdit->setVisible(false);
|
||||||
|
layout->addWidget(m_hiddenLineEdit);
|
||||||
|
registerField("RegisteredAUTs", m_hiddenLineEdit);
|
||||||
|
|
||||||
|
connect(m_buttonGroup, &QButtonGroup::buttonToggled,
|
||||||
|
this, [this, hiddenLineEdit](QAbstractButton *button, bool checked) {
|
||||||
|
if (checked) {
|
||||||
|
hiddenLineEdit->setText(button->text());
|
||||||
|
emit completeChanged();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
void SquishToolkitsPage::initializePage()
|
||||||
|
{
|
||||||
|
QTimer::singleShot(0, this, &SquishToolkitsPage::delayedInitialize);
|
||||||
|
}
|
||||||
|
|
||||||
|
bool SquishToolkitsPage::isComplete() const
|
||||||
|
{
|
||||||
|
return m_buttonGroup->checkedButton() != nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool SquishToolkitsPage::handleReject()
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
void SquishToolkitsPage::delayedInitialize()
|
||||||
|
{
|
||||||
|
fetchServerSettings();
|
||||||
|
}
|
||||||
|
|
||||||
|
void SquishToolkitsPage::fetchServerSettings()
|
||||||
|
{
|
||||||
|
auto squishTools = SquishTools::instance();
|
||||||
|
QTC_ASSERT(squishTools, return);
|
||||||
|
|
||||||
|
connect(squishTools, &SquishTools::queryFinished, this,
|
||||||
|
[this] (const QString &out) {
|
||||||
|
SquishServerSettings s;
|
||||||
|
s.setFromXmlOutput(out);
|
||||||
|
QApplication::restoreOverrideCursor();
|
||||||
|
// FIXME current impl limited to Desktop to avoid confusion and bugreports
|
||||||
|
const QStringList ignored = { "Android", "iOS", "VNC", "XView" };
|
||||||
|
auto buttons = m_buttonGroup->buttons();
|
||||||
|
for (auto button : buttons) {
|
||||||
|
const QString text = button->text();
|
||||||
|
if (!ignored.contains(text) && s.licensedToolkits.contains(text)) {
|
||||||
|
button->setEnabled(true);
|
||||||
|
if (s.licensedToolkits.size() == 1)
|
||||||
|
button->setChecked(true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
m_hiddenLineEdit->setText(s.mappedAuts.keys().join('\n'));
|
||||||
|
});
|
||||||
|
QApplication::setOverrideCursor(Qt::WaitCursor);
|
||||||
|
squishTools->queryServerSettings();
|
||||||
|
}
|
||||||
|
|
||||||
|
/********************************* ScriptLanguagePage ********************************************/
|
||||||
|
|
||||||
|
SquishScriptLanguagePageFactory::SquishScriptLanguagePageFactory()
|
||||||
|
{
|
||||||
|
setTypeIdsSuffix("SquishScriptLanguage");
|
||||||
|
}
|
||||||
|
|
||||||
|
Utils::WizardPage *SquishScriptLanguagePageFactory::create(ProjectExplorer::JsonWizard *,
|
||||||
|
Utils::Id typeId, const QVariant &)
|
||||||
|
{
|
||||||
|
QTC_ASSERT(canCreate(typeId), return nullptr);
|
||||||
|
return new SquishScriptLanguagePage;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool SquishScriptLanguagePageFactory::validateData(Utils::Id typeId, const QVariant &, QString *)
|
||||||
|
{
|
||||||
|
QTC_ASSERT(canCreate(typeId), return false);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
SquishScriptLanguagePage::SquishScriptLanguagePage()
|
||||||
|
{
|
||||||
|
resize(400, 300);
|
||||||
|
setTitle(Tr::tr("Create New Squish Test Suite"));
|
||||||
|
|
||||||
|
auto layout = new QHBoxLayout(this);
|
||||||
|
auto groupBox = new QGroupBox(Tr::tr("Available languages:"), this);
|
||||||
|
auto buttonLayout = new QVBoxLayout(groupBox);
|
||||||
|
|
||||||
|
auto buttonGroup = new QButtonGroup(this);
|
||||||
|
buttonGroup->setExclusive(true);
|
||||||
|
const QStringList languages = { "JavaScript", "Perl", "Python", "Ruby", "Tcl" };
|
||||||
|
for (const QString &language : languages) {
|
||||||
|
auto button = new QRadioButton(language, this);
|
||||||
|
button->setChecked(language.startsWith('J'));
|
||||||
|
buttonGroup->addButton(button);
|
||||||
|
buttonLayout->addWidget(button);
|
||||||
|
}
|
||||||
|
groupBox->setLayout(buttonLayout);
|
||||||
|
|
||||||
|
layout->addWidget(groupBox);
|
||||||
|
auto hiddenLineEdit = new QLineEdit(this);
|
||||||
|
hiddenLineEdit->setVisible(false);
|
||||||
|
layout->addWidget(hiddenLineEdit);
|
||||||
|
|
||||||
|
connect(buttonGroup, &QButtonGroup::buttonToggled,
|
||||||
|
this, [this, hiddenLineEdit](QAbstractButton *button, bool checked) {
|
||||||
|
if (checked) {
|
||||||
|
hiddenLineEdit->setText(button->text());
|
||||||
|
emit completeChanged();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
registerFieldWithName("ChosenLanguage", hiddenLineEdit);
|
||||||
|
hiddenLineEdit->setText(buttonGroup->checkedButton()->text());
|
||||||
|
}
|
||||||
|
|
||||||
|
/************************************* AUTPage ***************************************************/
|
||||||
|
|
||||||
|
SquishAUTPageFactory::SquishAUTPageFactory()
|
||||||
|
{
|
||||||
|
setTypeIdsSuffix("SquishAUT");
|
||||||
|
}
|
||||||
|
|
||||||
|
Utils::WizardPage *SquishAUTPageFactory::create(ProjectExplorer::JsonWizard *, Utils::Id typeId,
|
||||||
|
const QVariant &)
|
||||||
|
{
|
||||||
|
QTC_ASSERT(canCreate(typeId), return nullptr);
|
||||||
|
return new SquishAUTPage;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool SquishAUTPageFactory::validateData(Utils::Id typeId, const QVariant &, QString *)
|
||||||
|
{
|
||||||
|
QTC_ASSERT(canCreate(typeId), return false);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
SquishAUTPage::SquishAUTPage()
|
||||||
|
{
|
||||||
|
resize(400, 300);
|
||||||
|
auto layout = new QVBoxLayout(this);
|
||||||
|
m_autCombo = new QComboBox(this);
|
||||||
|
layout->addWidget(m_autCombo);
|
||||||
|
registerFieldWithName("ChosenAUT", m_autCombo, "currentText");
|
||||||
|
}
|
||||||
|
|
||||||
|
void SquishAUTPage::initializePage()
|
||||||
|
{
|
||||||
|
m_autCombo->clear();
|
||||||
|
m_autCombo->addItem(Tr::tr("<None>"));
|
||||||
|
m_autCombo->addItems(field("RegisteredAUTs").toString().split('\n'));
|
||||||
|
m_autCombo->setCurrentIndex(0);
|
||||||
|
}
|
||||||
|
|
||||||
|
/********************************* SquishSuiteGenerator ******************************************/
|
||||||
|
|
||||||
|
SquishGeneratorFactory::SquishGeneratorFactory()
|
||||||
|
{
|
||||||
|
setTypeIdsSuffix("SquishSuiteGenerator");
|
||||||
|
}
|
||||||
|
|
||||||
|
ProjectExplorer::JsonWizardGenerator *SquishGeneratorFactory::create(Utils::Id typeId,
|
||||||
|
const QVariant &data,
|
||||||
|
const QString &,
|
||||||
|
Utils::Id,
|
||||||
|
const QVariantMap &)
|
||||||
|
{
|
||||||
|
QTC_ASSERT(canCreate(typeId), return nullptr);
|
||||||
|
|
||||||
|
auto generator = new SquishFileGenerator;
|
||||||
|
QString errorMessage;
|
||||||
|
generator->setup(data, &errorMessage);
|
||||||
|
|
||||||
|
if (!errorMessage.isEmpty()) {
|
||||||
|
qWarning() << "SquishSuiteGenerator setup error:" << errorMessage;
|
||||||
|
delete generator;
|
||||||
|
return nullptr;
|
||||||
|
}
|
||||||
|
return generator;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool SquishGeneratorFactory::validateData(Utils::Id typeId, const QVariant &data,
|
||||||
|
QString *errorMessage)
|
||||||
|
{
|
||||||
|
QTC_ASSERT(canCreate(typeId), return false);
|
||||||
|
|
||||||
|
QScopedPointer<SquishFileGenerator> generator(new SquishFileGenerator);
|
||||||
|
return generator->setup(data, errorMessage);
|
||||||
|
}
|
||||||
|
|
||||||
|
bool SquishFileGenerator::setup(const QVariant &data, QString *errorMessage)
|
||||||
|
{
|
||||||
|
if (data.isNull())
|
||||||
|
return false;
|
||||||
|
|
||||||
|
if (data.type() != QVariant::Map) {
|
||||||
|
*errorMessage = Tr::tr("Key is not an object.");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
const QVariantMap map = data.toMap();
|
||||||
|
auto modeVariant = map.value("mode");
|
||||||
|
if (!modeVariant.isValid()) {
|
||||||
|
*errorMessage = Tr::tr("Key 'mode' is not set.");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
m_mode = modeVariant.toString();
|
||||||
|
if (m_mode != "TestSuite") {
|
||||||
|
*errorMessage = Tr::tr("Unsupported mode:") + ' ' + m_mode;
|
||||||
|
m_mode.clear();
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
static QString generateSuiteConf(const QString &aut, const QString &language,
|
||||||
|
const QString &toolkit) {
|
||||||
|
QString content;
|
||||||
|
content.append("AUT=").append(aut).append('\n');
|
||||||
|
content.append("LANGUAGE=").append(language).append('\n');
|
||||||
|
|
||||||
|
// FIXME old format
|
||||||
|
content.append("OBJECTMAPSTYLE=script\n");
|
||||||
|
// FIXME use what is configured
|
||||||
|
content.append("VERSION=3\n");
|
||||||
|
content.append("WRAPPERS=").append(toolkit).append('\n');
|
||||||
|
return content;
|
||||||
|
}
|
||||||
|
|
||||||
|
Core::GeneratedFiles SquishFileGenerator::fileList(Utils::MacroExpander *expander,
|
||||||
|
const Utils::FilePath &wizardDir,
|
||||||
|
const Utils::FilePath &projectDir,
|
||||||
|
QString *errorMessage)
|
||||||
|
{
|
||||||
|
errorMessage->clear();
|
||||||
|
// later on differentiate based on m_mode
|
||||||
|
QString aut = expander->expand(QString{"%{AUT}"});
|
||||||
|
if (aut == Tr::tr("<None>"))
|
||||||
|
aut.clear();
|
||||||
|
const QString lang = expander->expand(QString{"%{Language}"});
|
||||||
|
const QString toolkit = expander->expand(QString{"%{Toolkit}"});;
|
||||||
|
const Utils::FilePath suiteConf = projectDir.pathAppended("suite.conf");
|
||||||
|
|
||||||
|
Core::GeneratedFile file(suiteConf);
|
||||||
|
file.setAttributes(Core::GeneratedFile::OpenEditorAttribute);
|
||||||
|
file.setContents(generateSuiteConf(aut, lang, toolkit));
|
||||||
|
Core::GeneratedFile base(projectDir);
|
||||||
|
base.setAttributes(Core::GeneratedFile::CustomGeneratorAttribute);
|
||||||
|
return {base, file};
|
||||||
|
}
|
||||||
|
|
||||||
|
bool SquishFileGenerator::writeFile(const ProjectExplorer::JsonWizard *,
|
||||||
|
Core::GeneratedFile *file,
|
||||||
|
QString *errorMessage)
|
||||||
|
{
|
||||||
|
if (!(file->attributes() & Core::GeneratedFile::CustomGeneratorAttribute)) {
|
||||||
|
if (!file->write(errorMessage))
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool SquishFileGenerator::allDone(const ProjectExplorer::JsonWizard *wizard, Core::GeneratedFile *file,
|
||||||
|
QString *errorMessage)
|
||||||
|
{
|
||||||
|
if (m_mode == "TestSuite") {
|
||||||
|
if (file->filePath().fileName() == "suite.conf")
|
||||||
|
QTimer::singleShot(0, [filePath = file->filePath()] {
|
||||||
|
SquishFileHandler::instance()->openTestSuite(filePath);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
} // namespace Internal
|
||||||
|
} // namespace Squish
|
||||||
117
src/plugins/squish/squishwizardpages.h
Normal file
117
src/plugins/squish/squishwizardpages.h
Normal file
@@ -0,0 +1,117 @@
|
|||||||
|
// Copyright (C) 2022 The Qt Company Ltd.
|
||||||
|
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0 WITH Qt-GPL-exception-1.0
|
||||||
|
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include <projectexplorer/jsonwizard/jsonwizardgeneratorfactory.h>
|
||||||
|
#include <projectexplorer/jsonwizard/jsonwizardpagefactory.h>
|
||||||
|
#include <utils/wizardpage.h>
|
||||||
|
|
||||||
|
QT_BEGIN_NAMESPACE
|
||||||
|
class QButtonGroup;
|
||||||
|
class QComboBox;
|
||||||
|
class QLineEdit;
|
||||||
|
QT_END_NAMESPACE
|
||||||
|
|
||||||
|
namespace Squish {
|
||||||
|
namespace Internal {
|
||||||
|
|
||||||
|
class SquishToolkitsPageFactory : public ProjectExplorer::JsonWizardPageFactory
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
SquishToolkitsPageFactory();
|
||||||
|
|
||||||
|
Utils::WizardPage *create(ProjectExplorer::JsonWizard *wizard, Utils::Id typeId,
|
||||||
|
const QVariant &data) override;
|
||||||
|
bool validateData(Utils::Id typeId, const QVariant &data, QString *errorMessage) override;
|
||||||
|
};
|
||||||
|
|
||||||
|
class SquishToolkitsPage : public Utils::WizardPage
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
public:
|
||||||
|
SquishToolkitsPage();
|
||||||
|
~SquishToolkitsPage() = default;
|
||||||
|
|
||||||
|
void initializePage() override;
|
||||||
|
bool isComplete() const override;
|
||||||
|
bool handleReject() override;
|
||||||
|
|
||||||
|
private:
|
||||||
|
void delayedInitialize();
|
||||||
|
void fetchServerSettings();
|
||||||
|
|
||||||
|
QButtonGroup *m_buttonGroup = nullptr;
|
||||||
|
QLineEdit *m_hiddenLineEdit = nullptr;
|
||||||
|
};
|
||||||
|
|
||||||
|
class SquishScriptLanguagePageFactory : public ProjectExplorer::JsonWizardPageFactory
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
SquishScriptLanguagePageFactory();
|
||||||
|
|
||||||
|
Utils::WizardPage *create(ProjectExplorer::JsonWizard *wizard, Utils::Id typeId,
|
||||||
|
const QVariant &data) override;
|
||||||
|
bool validateData(Utils::Id typeId, const QVariant &data, QString *errorMessage) override;
|
||||||
|
};
|
||||||
|
|
||||||
|
class SquishScriptLanguagePage : public Utils::WizardPage
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
public:
|
||||||
|
SquishScriptLanguagePage();
|
||||||
|
~SquishScriptLanguagePage() = default;
|
||||||
|
};
|
||||||
|
|
||||||
|
class SquishAUTPageFactory : public ProjectExplorer::JsonWizardPageFactory
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
SquishAUTPageFactory();
|
||||||
|
|
||||||
|
Utils::WizardPage *create(ProjectExplorer::JsonWizard *wizard, Utils::Id typeId,
|
||||||
|
const QVariant &data) override;
|
||||||
|
bool validateData(Utils::Id typeId, const QVariant &data, QString *errorMessage) override;
|
||||||
|
};
|
||||||
|
|
||||||
|
class SquishAUTPage : public Utils::WizardPage
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
public:
|
||||||
|
SquishAUTPage();
|
||||||
|
~SquishAUTPage() = default;
|
||||||
|
|
||||||
|
void initializePage() override;
|
||||||
|
private:
|
||||||
|
QComboBox *m_autCombo = nullptr;
|
||||||
|
};
|
||||||
|
|
||||||
|
class SquishGeneratorFactory : public ProjectExplorer::JsonWizardGeneratorFactory
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
SquishGeneratorFactory();
|
||||||
|
|
||||||
|
ProjectExplorer::JsonWizardGenerator *create(Utils::Id typeId, const QVariant &data,
|
||||||
|
const QString &path, Utils::Id platform,
|
||||||
|
const QVariantMap &variables) override;
|
||||||
|
bool validateData(Utils::Id typeId, const QVariant &data, QString *errorMessage) override;
|
||||||
|
};
|
||||||
|
|
||||||
|
class SquishFileGenerator : public ProjectExplorer::JsonWizardGenerator
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
bool setup(const QVariant &data, QString *errorMessage);
|
||||||
|
Core::GeneratedFiles fileList(Utils::MacroExpander *expander,
|
||||||
|
const Utils::FilePath &wizardDir,
|
||||||
|
const Utils::FilePath &projectDir,
|
||||||
|
QString *errorMessage) override;
|
||||||
|
bool writeFile(const ProjectExplorer::JsonWizard *wizard, Core::GeneratedFile *file,
|
||||||
|
QString *errorMessage) override;
|
||||||
|
bool allDone(const ProjectExplorer::JsonWizard *wizard, Core::GeneratedFile *file,
|
||||||
|
QString *errorMessage) override;
|
||||||
|
|
||||||
|
private:
|
||||||
|
QString m_mode;
|
||||||
|
};
|
||||||
|
|
||||||
|
} // namespace Internal
|
||||||
|
} // namespace Squish
|
||||||
Reference in New Issue
Block a user