Commit 8585fef8 authored by Laurent Montel's avatar Laurent Montel 😁

Add isValid

parent f3c31942
......@@ -38,6 +38,22 @@ void ViewerPluginExternalScriptInfoTest::shouldHaveDefaultValue()
QVERIFY(info.commandLine().isEmpty());
QVERIFY(info.executable().isEmpty());
QVERIFY(info.description().isEmpty());
QVERIFY(!info.isValid());
}
void ViewerPluginExternalScriptInfoTest::shouldHaveValid()
{
ViewerPluginExternalScriptInfo info;
info.setName(QString());
QVERIFY(!info.isValid());
info.setName(QStringLiteral("foo"));
info.setExecutable(QStringLiteral("bla"));
QVERIFY(info.isValid());
info.setName(QStringLiteral(" "));
QVERIFY(!info.isValid());
info.setName(QStringLiteral("foo"));
info.setExecutable(QStringLiteral(" "));
QVERIFY(!info.isValid());
}
QTEST_MAIN(ViewerPluginExternalScriptInfoTest)
......@@ -29,6 +29,7 @@ public:
private Q_SLOTS:
void shouldHaveDefaultValue();
void shouldHaveValid();
};
#endif // VIEWERPLUGINEXTERNALSCRIPTINFOTEST_H
......@@ -61,3 +61,9 @@ void ViewerPluginExternalScriptInfo::setDescription(const QString &description)
{
mDescription = description;
}
bool ViewerPluginExternalScriptInfo::isValid() const
{
return !mName.trimmed().isEmpty() &&
!mExecutable.trimmed().isEmpty();
}
......@@ -36,6 +36,7 @@ public:
QString description() const;
void setDescription(const QString &description);
bool isValid() const;
private:
QString mCommandLine;
QString mName;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment