forked from qt-creator/qt-creator
Squish: Write server config changes
Change-Id: I74242e88b9a7ba7b2c6f815efc1dd4e8cdca9df1 Reviewed-by: David Schulz <david.schulz@qt.io>
This commit is contained in:
@@ -29,6 +29,8 @@
|
||||
#include "squishtools.h"
|
||||
#include "squishtr.h"
|
||||
|
||||
#include <coreplugin/icore.h>
|
||||
|
||||
#include <utils/basetreeview.h>
|
||||
#include <utils/fileutils.h>
|
||||
#include <utils/icon.h>
|
||||
@@ -40,6 +42,7 @@
|
||||
#include <QDialogButtonBox>
|
||||
#include <QFrame>
|
||||
#include <QHeaderView>
|
||||
#include <QMessageBox>
|
||||
#include <QPushButton>
|
||||
#include <QSettings>
|
||||
#include <QVBoxLayout>
|
||||
@@ -335,6 +338,7 @@ class SquishServerSettingsWidget : public QWidget
|
||||
{
|
||||
public:
|
||||
explicit SquishServerSettingsWidget(QWidget *parent = nullptr);
|
||||
QList<QStringList> toConfigChangeArguments() const;
|
||||
|
||||
private:
|
||||
void repopulateApplicationView();
|
||||
@@ -344,6 +348,8 @@ private:
|
||||
void addAttachableAut(TreeItem *categoryItem, SquishServerItem *original);
|
||||
void editApplicationOrPath();
|
||||
void removeApplicationOrPath();
|
||||
|
||||
SquishServerSettings m_originalSettings;
|
||||
SquishServerSettings m_serverSettings;
|
||||
BaseTreeView m_applicationsView;
|
||||
TreeModel<SquishServerItem> m_model;
|
||||
@@ -414,6 +420,7 @@ SquishServerSettingsWidget::SquishServerSettingsWidget(QWidget *parent)
|
||||
connect(squishTools, &SquishTools::queryFinished, this,
|
||||
[this, progress] (const QByteArray &out) {
|
||||
m_serverSettings.setFromXmlOutput(out);
|
||||
m_originalSettings.setFromXmlOutput(out);
|
||||
repopulateApplicationView();
|
||||
progress->hide();
|
||||
setEnabled(true);
|
||||
@@ -576,6 +583,61 @@ void SquishServerSettingsWidget::removeApplicationOrPath()
|
||||
m_model.destroyItem(item);
|
||||
}
|
||||
|
||||
QList<QStringList> SquishServerSettingsWidget::toConfigChangeArguments() const
|
||||
{
|
||||
QList<QStringList> result;
|
||||
for (auto it = m_originalSettings.mappedAuts.begin(),
|
||||
end = m_originalSettings.mappedAuts.end(); it != end; ++it) {
|
||||
const QString value = m_serverSettings.mappedAuts.value(it.key());
|
||||
if (value == it.value())
|
||||
continue;
|
||||
if (value.isEmpty())
|
||||
result.append({"removeAUT", it.key(), it.value()});
|
||||
else
|
||||
result.append({"addAUT", it.key(), value});
|
||||
}
|
||||
for (auto it = m_serverSettings.mappedAuts.begin(),
|
||||
end = m_serverSettings.mappedAuts.end(); it != end; ++it) {
|
||||
if (!m_originalSettings.mappedAuts.contains(it.key()))
|
||||
result.append({"addAUT", it.key(), it.value()});
|
||||
}
|
||||
|
||||
for (auto it = m_originalSettings.attachableAuts.begin(),
|
||||
end = m_originalSettings.attachableAuts.end(); it != end; ++it) {
|
||||
const QString value = m_serverSettings.attachableAuts.value(it.key());
|
||||
if (value == it.value())
|
||||
continue;
|
||||
if (value.isEmpty())
|
||||
result.append({"removeAttachableAUT", it.key(), it.value()});
|
||||
else
|
||||
result.append({"addAttachableAUT", it.key(), value});
|
||||
}
|
||||
for (auto it = m_serverSettings.attachableAuts.begin(),
|
||||
end = m_serverSettings.attachableAuts.end(); it != end; ++it) {
|
||||
if (!m_originalSettings.attachableAuts.contains(it.key()))
|
||||
result.append({"addAttachableAUT", it.key(), it.value()});
|
||||
}
|
||||
|
||||
for (auto &path : qAsConst(m_originalSettings.autPaths)) {
|
||||
if (!m_serverSettings.autPaths.contains(path))
|
||||
result.append({"removeAppPath", path});
|
||||
}
|
||||
for (auto &path : qAsConst(m_serverSettings.autPaths)) {
|
||||
if (!m_originalSettings.autPaths.contains(path))
|
||||
result.append({"addAppPath", path});
|
||||
}
|
||||
|
||||
if (m_originalSettings.autTimeout.value() != m_serverSettings.autTimeout.value())
|
||||
result.append({"setAUTTimeout", QString::number(m_serverSettings.autTimeout.value())});
|
||||
if (m_originalSettings.responseTimeout.value() != m_serverSettings.responseTimeout.value())
|
||||
result.append({"setResponseTimeout", QString::number(m_serverSettings.responseTimeout.value())});
|
||||
if (m_originalSettings.postMortemWaitTime.value() != m_serverSettings.postMortemWaitTime.value())
|
||||
result.append({"setAUTPostMortemTimeout", QString::number(m_serverSettings.postMortemWaitTime.value())});
|
||||
if (m_originalSettings.animatedCursor.value() != m_serverSettings.animatedCursor.value())
|
||||
result.append({"setCursorAnimation", m_serverSettings.animatedCursor.value() ? QString("on") : QString("off")});
|
||||
return result;
|
||||
}
|
||||
|
||||
void SquishServerSettingsWidget::editApplicationOrPath()
|
||||
{
|
||||
const QModelIndex &idx = m_applicationsView.currentIndex();
|
||||
@@ -603,21 +665,37 @@ SquishServerSettingsDialog::SquishServerSettingsDialog(QWidget *parent)
|
||||
{
|
||||
setWindowTitle(Tr::tr("Squish Server Settings"));
|
||||
|
||||
QVBoxLayout *mainLayout = new QVBoxLayout;
|
||||
mainLayout->addWidget(new SquishServerSettingsWidget);
|
||||
auto buttonBox = new QDialogButtonBox(/*QDialogButtonBox::Apply|*/QDialogButtonBox::Cancel, this);
|
||||
QVBoxLayout *mainLayout = new QVBoxLayout(this);
|
||||
auto settingsWidget = new SquishServerSettingsWidget(this);
|
||||
mainLayout->addWidget(settingsWidget);
|
||||
auto buttonBox = new QDialogButtonBox(QDialogButtonBox::Ok|QDialogButtonBox::Cancel, this);
|
||||
mainLayout->addWidget(buttonBox);
|
||||
setLayout(mainLayout);
|
||||
// connect(buttonBox->button(QDialogButtonBox::Apply), &QPushButton::clicked,
|
||||
// this, &SquishServerSettingsDialog::onApply);
|
||||
connect(buttonBox->button(QDialogButtonBox::Ok), &QPushButton::clicked,
|
||||
this, [this, settingsWidget, buttonBox] {
|
||||
const QList<QStringList> configChanges = settingsWidget->toConfigChangeArguments();
|
||||
if (configChanges.isEmpty()) {
|
||||
accept();
|
||||
return;
|
||||
}
|
||||
|
||||
connect(SquishTools::instance(), &SquishTools::configChangesFailed,
|
||||
this, &SquishServerSettingsDialog::configWriteFailed);
|
||||
connect(SquishTools::instance(), &SquishTools::configChangesWritten,
|
||||
this, &QDialog::accept);
|
||||
buttonBox->button(QDialogButtonBox::Ok)->setEnabled(false);
|
||||
SquishTools::instance()->writeServerSettingsChanges(configChanges);
|
||||
});
|
||||
connect(buttonBox->button(QDialogButtonBox::Cancel), &QPushButton::clicked,
|
||||
this, &QDialog::reject);
|
||||
}
|
||||
|
||||
void SquishServerSettingsDialog::onApply()
|
||||
void SquishServerSettingsDialog::configWriteFailed(QProcess::ProcessError error)
|
||||
{
|
||||
// TODO write settings to server
|
||||
accept();
|
||||
QMessageBox::critical(Core::ICore::dialogParent(),
|
||||
Tr::tr("Error"),
|
||||
Tr::tr("Failed to write configuration changes.\n"
|
||||
"Squish server finished with process error %1.").arg(error));
|
||||
}
|
||||
|
||||
} // namespace Internal
|
||||
|
||||
@@ -30,6 +30,7 @@
|
||||
#include <utils/aspects.h>
|
||||
|
||||
#include <QDialog>
|
||||
#include <QProcess>
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
class QSettings;
|
||||
@@ -63,7 +64,7 @@ public:
|
||||
explicit SquishServerSettingsDialog(QWidget *parent = nullptr);
|
||||
|
||||
private:
|
||||
void onApply();
|
||||
void configWriteFailed(QProcess::ProcessError error);
|
||||
};
|
||||
|
||||
} // namespace Internal
|
||||
|
||||
@@ -184,6 +184,20 @@ void SquishTools::queryServerSettings()
|
||||
startSquishServer(RunnerQueryRequested);
|
||||
}
|
||||
|
||||
void SquishTools::writeServerSettingsChanges(const QList<QStringList> &changes)
|
||||
{
|
||||
if (m_state != Idle) {
|
||||
QMessageBox::critical(Core::ICore::dialogParent(),
|
||||
Tr::tr("Error"),
|
||||
Tr::tr("Squish Tools in unexpected state (%1).\n"
|
||||
"Refusing to write configuration changes.").arg(m_state));
|
||||
return;
|
||||
}
|
||||
m_serverConfigChanges = changes;
|
||||
startSquishServer(ServerConfigChangeRequested);
|
||||
}
|
||||
|
||||
|
||||
void SquishTools::setState(SquishTools::State state)
|
||||
{
|
||||
// TODO check whether state transition is legal
|
||||
@@ -207,6 +221,7 @@ void SquishTools::setState(SquishTools::State state)
|
||||
} else if (m_request == RecordTestRequested) {
|
||||
} else if (m_request == RunnerQueryRequested) {
|
||||
executeRunnerQuery();
|
||||
} else if (m_request == ServerConfigChangeRequested) { // nothing to do here
|
||||
} else {
|
||||
QTC_ASSERT(false, qDebug() << m_state << m_request);
|
||||
}
|
||||
@@ -222,7 +237,18 @@ void SquishTools::setState(SquishTools::State state)
|
||||
break;
|
||||
case ServerStopped:
|
||||
m_state = Idle;
|
||||
if (m_request == ServerStopRequested) {
|
||||
if (m_request == ServerConfigChangeRequested) {
|
||||
if (m_serverProcess.result() == ProcessResult::FinishedWithError) {
|
||||
emit configChangesFailed(m_serverProcess.error());
|
||||
break;
|
||||
}
|
||||
|
||||
m_serverConfigChanges.removeFirst();
|
||||
if (!m_serverConfigChanges.isEmpty())
|
||||
startSquishServer(ServerConfigChangeRequested);
|
||||
else
|
||||
emit configChangesWritten();
|
||||
} else if (m_request == ServerStopRequested) {
|
||||
m_request = None;
|
||||
if (m_squishRunnerMode == TestingMode) {
|
||||
emit squishTestRunFinished();
|
||||
@@ -331,13 +357,20 @@ void SquishTools::startSquishServer(Request request)
|
||||
|
||||
QStringList arguments;
|
||||
// TODO if isLocalServer is false we should start a squishserver on remote device
|
||||
if (toolsSettings.isLocalServer)
|
||||
if (toolsSettings.isLocalServer) {
|
||||
if (m_request != ServerConfigChangeRequested)
|
||||
arguments << "--local"; // for now - although Squish Docs say "don't use it"
|
||||
else
|
||||
} else {
|
||||
arguments << "--port" << QString::number(toolsSettings.serverPort);
|
||||
}
|
||||
if (toolsSettings.verboseLog)
|
||||
arguments << "--verbose";
|
||||
|
||||
if (m_request == ServerConfigChangeRequested && QTC_GUARD(!m_serverConfigChanges.isEmpty())) {
|
||||
arguments.append("--config");
|
||||
arguments.append(m_serverConfigChanges.first());
|
||||
}
|
||||
|
||||
m_serverProcess.setCommand({toolsSettings.serverPath, arguments});
|
||||
m_serverProcess.setEnvironment(squishEnvironment());
|
||||
|
||||
|
||||
@@ -72,6 +72,7 @@ public:
|
||||
const QStringList &additionalServerArgs = QStringList(),
|
||||
const QStringList &additionalRunnerArgs = QStringList());
|
||||
void queryServerSettings();
|
||||
void writeServerSettingsChanges(const QList<QStringList> &changes);
|
||||
|
||||
signals:
|
||||
void logOutputReceived(const QString &output);
|
||||
@@ -79,12 +80,14 @@ signals:
|
||||
void squishTestRunFinished();
|
||||
void resultOutputCreated(const QByteArray &output);
|
||||
void queryFinished(const QByteArray &output);
|
||||
void configChangesFailed(QProcess::ProcessError error);
|
||||
void configChangesWritten();
|
||||
|
||||
private:
|
||||
enum Request {
|
||||
None,
|
||||
ServerStopRequested,
|
||||
ServerQueryRequested,
|
||||
ServerConfigChangeRequested,
|
||||
RunnerQueryRequested,
|
||||
RunTestRequested,
|
||||
RecordTestRequested,
|
||||
@@ -129,6 +132,7 @@ private:
|
||||
QFileSystemWatcher *m_resultsFileWatcher = nullptr;
|
||||
QStringList m_additionalServerArguments;
|
||||
QStringList m_additionalRunnerArguments;
|
||||
QList<QStringList> m_serverConfigChanges;
|
||||
QWindowList m_lastTopLevelWindows;
|
||||
enum RunnerMode { NoMode, TestingMode, QueryMode} m_squishRunnerMode = NoMode;
|
||||
qint64 m_readResultsCount;
|
||||
|
||||
Reference in New Issue
Block a user