Squish: Adapt to recent aspect development

Change-Id: Ied7406af9c39d8b57b5b9064500e589e33fb86da
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
This commit is contained in:
hjk
2023-05-23 15:36:29 +02:00
parent 080c5e82d2
commit 0d37a66b51
8 changed files with 39 additions and 66 deletions

View File

@@ -195,7 +195,7 @@ Core::IDocument::OpenResult ObjectsMapDocument::openImpl(QString *error,
text = reader.data();
} else {
const Utils::FilePath base = SquishPlugin::squishSettings()->squishPath.filePath();
const Utils::FilePath base = SquishPlugin::squishSettings()->squishPath();
if (base.isEmpty()) {
if (error)
error->append(Tr::tr("Incomplete Squish settings. "
@@ -233,7 +233,7 @@ bool ObjectsMapDocument::writeFile(const Utils::FilePath &fileName) const
}
// otherwise we need the objectmaptool to write the scripted object map again
const Utils::FilePath base = SquishPlugin::squishSettings()->squishPath.filePath();
const Utils::FilePath base = SquishPlugin::squishSettings()->squishPath();
if (base.isEmpty())
return false;
const Utils::FilePath exe = base.pathAppended("lib/exec/objectmaptool").withExecutableSuffix();

View File

@@ -314,7 +314,7 @@ void SquishNavigationWidget::onNewTestCaseTriggered(const QModelIndex &index)
auto settings = SquishPlugin::squishSettings();
QTC_ASSERT(settings, return);
if (!settings->squishPath.filePath().pathAppended("scriptmodules").exists()) {
if (!settings->squishPath().pathAppended("scriptmodules").exists()) {
SquishMessages::criticalMessage(Tr::tr("Set up a valid Squish path to be able to create "
"a new test case.\n(Edit > Preferences > Squish)"));
return;

View File

@@ -109,7 +109,7 @@ bool SquishPluginPrivate::initializeGlobalScripts()
QTC_ASSERT(dd->m_squishTools, return false);
SquishFileHandler::instance()->setSharedFolders({});
const Utils::FilePath squishserver = dd->m_squishSettings.squishPath.filePath().pathAppended(
const Utils::FilePath squishserver = dd->m_squishSettings.squishPath().pathAppended(
Utils::HostOsInfo::withExecutableSuffix("bin/squishserver"));
if (!squishserver.isExecutableFile())
return false;
@@ -134,8 +134,7 @@ void SquishPlugin::initialize()
bool SquishPlugin::delayedInitialize()
{
connect(&dd->m_squishSettings, &SquishSettings::squishPathChanged,
connect(&dd->m_squishSettings.squishPath, &Utils::BaseAspect::changed,
dd, &SquishPluginPrivate::initializeGlobalScripts);
return dd->initializeGlobalScripts();

View File

@@ -36,10 +36,8 @@ SquishSettings::SquishSettings()
setSettingsGroup("Squish");
setAutoApply(false);
registerAspect(&squishPath);
squishPath.setSettingsKey("SquishPath");
squishPath.setLabelText(Tr::tr("Squish path:"));
squishPath.setDisplayStyle(StringAspect::PathChooserDisplay);
squishPath.setExpectedKind(PathChooser::ExistingDirectory);
squishPath.setPlaceHolderText(Tr::tr("Path to Squish installation"));
squishPath.setValidationFunction([this](FancyLineEdit *edit, QString *error) {
@@ -54,37 +52,30 @@ SquishSettings::SquishSettings()
return valid;
});
registerAspect(&licensePath);
licensePath.setSettingsKey("LicensePath");
licensePath.setLabelText(Tr::tr("License path:"));
licensePath.setDisplayStyle(StringAspect::PathChooserDisplay);
licensePath.setExpectedKind(PathChooser::ExistingDirectory);
registerAspect(&local);
local.setSettingsKey("Local");
local.setLabel(Tr::tr("Local Server"));
local.setDefaultValue(true);
registerAspect(&serverHost);
serverHost.setSettingsKey("ServerHost");
serverHost.setLabelText(Tr::tr("Server host:"));
serverHost.setDisplayStyle(StringAspect::LineEditDisplay);
serverHost.setDefaultValue("localhost");
serverHost.setEnabled(false);
registerAspect(&serverPort);
serverPort.setSettingsKey("ServerPort");
serverPort.setLabel(Tr::tr("Server Port"));
serverPort.setRange(1, 65535);
serverPort.setDefaultValue(9999);
serverPort.setEnabled(false);
registerAspect(&verbose);
verbose.setSettingsKey("Verbose");
verbose.setLabel(Tr::tr("Verbose log"));
verbose.setDefaultValue(false);
registerAspect(&minimizeIDE);
minimizeIDE.setSettingsKey("MinimizeIDE");
minimizeIDE.setLabel(Tr::tr("Minimize IDE"));
minimizeIDE.setToolTip(Tr::tr("Minimize IDE automatically while running or recording test cases."));
@@ -94,13 +85,11 @@ SquishSettings::SquishSettings()
serverHost.setEnabled(!checked);
serverPort.setEnabled(!checked);
});
connect(&squishPath, &Utils::StringAspect::valueChanged,
this, &SquishSettings::squishPathChanged);
}
Utils::FilePath SquishSettings::scriptsPath(Language language) const
{
Utils::FilePath scripts = squishPath.filePath().pathAppended("scriptmodules");
Utils::FilePath scripts = squishPath().pathAppended("scriptmodules");
switch (language) {
case Language::Python: scripts = scripts.pathAppended("python"); break;
case Language::Perl: scripts = scripts.pathAppended("perl"); break;
@@ -139,7 +128,6 @@ SquishSettingsPage::SquishSettingsPage(SquishSettings *settings)
SquishServerSettings::SquishServerSettings()
{
registerAspect(&autTimeout);
autTimeout.setLabel(Tr::tr("Maximum startup time:"));
autTimeout.setToolTip(Tr::tr("Specifies how many seconds Squish should wait for a reply from the "
"AUT directly after starting it."));
@@ -147,7 +135,6 @@ SquishServerSettings::SquishServerSettings()
autTimeout.setSuffix("s");
autTimeout.setDefaultValue(20);
registerAspect(&responseTimeout);
responseTimeout.setLabel(Tr::tr("Maximum response time:"));
responseTimeout.setToolTip(Tr::tr("Specifies how many seconds Squish should wait for a reply from "
"the hooked up AUT before raising a timeout error."));
@@ -155,7 +142,6 @@ SquishServerSettings::SquishServerSettings()
responseTimeout.setDefaultValue(300);
responseTimeout.setSuffix("s");
registerAspect(&postMortemWaitTime);
postMortemWaitTime.setLabel(Tr::tr("Maximum post-mortem wait time:"));
postMortemWaitTime.setToolTip(Tr::tr("Specifies how many seconds Squish should wait after the the "
"first AUT process has exited."));
@@ -163,7 +149,6 @@ SquishServerSettings::SquishServerSettings()
postMortemWaitTime.setDefaultValue(1500);
postMortemWaitTime.setSuffix("ms");
registerAspect(&animatedCursor);
animatedCursor.setLabel(Tr::tr("Animate mouse cursor:"));
animatedCursor.setDefaultValue(true);
}
@@ -250,10 +235,10 @@ void SquishServerSettings::setFromXmlOutput(const QString &output)
autPaths = newSettings.autPaths;
attachableAuts = newSettings.attachableAuts;
licensedToolkits = newSettings.licensedToolkits;
autTimeout.setValue(newSettings.autTimeout.value());
postMortemWaitTime.setValue(newSettings.postMortemWaitTime.value());
responseTimeout.setValue(newSettings.responseTimeout.value());
animatedCursor.setValue(newSettings.animatedCursor.value());
autTimeout.setValue(newSettings.autTimeout());
postMortemWaitTime.setValue(newSettings.postMortemWaitTime());
responseTimeout.setValue(newSettings.responseTimeout());
animatedCursor.setValue(newSettings.animatedCursor());
}
class SquishServerItem : public TreeItem
@@ -625,14 +610,14 @@ QList<QStringList> SquishServerSettingsWidget::toConfigChangeArguments() const
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")});
if (m_originalSettings.autTimeout() != m_serverSettings.autTimeout())
result.append({"setAUTTimeout", QString::number(m_serverSettings.autTimeout())});
if (m_originalSettings.responseTimeout() != m_serverSettings.responseTimeout())
result.append({"setResponseTimeout", QString::number(m_serverSettings.responseTimeout())});
if (m_originalSettings.postMortemWaitTime() != m_serverSettings.postMortemWaitTime())
result.append({"setAUTPostMortemTimeout", QString::number(m_serverSettings.postMortemWaitTime())});
if (m_originalSettings.animatedCursor() != m_serverSettings.animatedCursor())
result.append({"setCursorAnimation", m_serverSettings.animatedCursor() ? QString("on") : QString("off")});
return result;
}

View File

@@ -10,12 +10,7 @@
#include <QDialog>
#include <QProcess>
QT_BEGIN_NAMESPACE
class QSettings;
QT_END_NAMESPACE
namespace Squish {
namespace Internal {
namespace Squish::Internal {
enum class Language;
@@ -30,30 +25,26 @@ public:
QMap<QString, QString> attachableAuts; // name, host:port
QStringList autPaths; // absolute path
QStringList licensedToolkits;
Utils::IntegerAspect autTimeout;
Utils::IntegerAspect responseTimeout;
Utils::IntegerAspect postMortemWaitTime;
Utils::BoolAspect animatedCursor;
Utils::IntegerAspect autTimeout{this};
Utils::IntegerAspect responseTimeout{this};
Utils::IntegerAspect postMortemWaitTime{this};
Utils::BoolAspect animatedCursor{this};
};
class SquishSettings : public Utils::AspectContainer
{
Q_OBJECT
public:
SquishSettings();
Utils::FilePath scriptsPath(Language language) const;
Utils::StringAspect squishPath;
Utils::StringAspect licensePath;
Utils::StringAspect serverHost;
Utils::IntegerAspect serverPort;
Utils::BoolAspect local;
Utils::BoolAspect verbose;
Utils::BoolAspect minimizeIDE;
signals:
void squishPathChanged();
Utils::FilePathAspect squishPath{this};
Utils::FilePathAspect licensePath{this};
Utils::StringAspect serverHost{this};
Utils::IntegerAspect serverPort{this};
Utils::BoolAspect local{this};
Utils::BoolAspect verbose{this};
Utils::BoolAspect minimizeIDE{this};
};
class SquishSettingsPage final : public Core::IOptionsPage
@@ -71,5 +62,4 @@ private:
void configWriteFailed(QProcess::ProcessError error);
};
} // namespace Internal
} // namespace Squish
} // Squish::Internal

View File

@@ -166,7 +166,6 @@ static bool copyScriptTemplates(const SuiteConf &suiteConf, const Utils::FilePat
const SquishSettings *s = SquishPlugin::squishSettings();
QTC_ASSERT(s, return false);
// copy template files
const Utils::FilePath squishPath = s->squishPath.filePath();
bool ok = destination.ensureWritableDir();
QTC_ASSERT(ok, return false);

View File

@@ -169,7 +169,7 @@ struct SquishToolsSettings
{
const SquishSettings *squishSettings = SquishPlugin::squishSettings();
QTC_ASSERT(squishSettings, return);
squishPath = squishSettings->squishPath.filePath();
squishPath = squishSettings->squishPath();
if (!squishPath.isEmpty()) {
const FilePath squishBin(squishPath.pathAppended("bin"));
@@ -181,12 +181,12 @@ struct SquishToolsSettings
HostOsInfo::withExecutableSuffix("processcomm")).absoluteFilePath();
}
isLocalServer = squishSettings->local.value();
serverHost = squishSettings->serverHost.value();
serverPort = squishSettings->serverPort.value();
verboseLog = squishSettings->verbose.value();
licenseKeyPath = squishSettings->licensePath.filePath();
minimizeIDE = squishSettings->minimizeIDE.value();
isLocalServer = squishSettings->local();
serverHost = squishSettings->serverHost();
serverPort = squishSettings->serverPort();
verboseLog = squishSettings->verbose();
licenseKeyPath = squishSettings->licensePath();
minimizeIDE = squishSettings->minimizeIDE();
}
};

View File

@@ -112,7 +112,7 @@ bool SquishToolkitsPage::handleReject()
void SquishToolkitsPage::delayedInitialize()
{
const auto s = SquishPlugin::squishSettings();
const Utils::FilePath server = s->squishPath.filePath().pathAppended(
const Utils::FilePath server = s->squishPath().pathAppended(
Utils::HostOsInfo::withExecutableSuffix("bin/squishserver"));
if (server.isExecutableFile())
fetchServerSettings();