Commit 686aa01a authored by David Faure's avatar David Faure

Provide 4-args ctor for LoggingCategory so that the unittest can be much shorter and maintainable.

Requires more typing for fully converting the unittest though
parent 138389db
......@@ -59,13 +59,9 @@ void LoadCategoriesJobTest::shouldReadRules_data()
QTest::newRow("rulesbeforesection") << QStringLiteral("rulebeforerulessectionfiles.ini") << QString() << false << LoggingCategory::List() << LoggingCategory::List();
LoggingCategory::List qtKdeCategories;
LoggingCategory tmp;
tmp.description = QStringLiteral("KPasswdServer (KIO)");
tmp.logName = QStringLiteral("org.kde.kio.kpasswdserver");
tmp.loggingType = LoggingCategory::Info;
tmp.enabled = true;
qtKdeCategories.append(tmp);
qtKdeCategories.append(LoggingCategory(QStringLiteral("KPasswdServer (KIO)"), QStringLiteral("org.kde.kio.kpasswdserver"), LoggingCategory::Info, true));
LoggingCategory tmp;
tmp.description = QStringLiteral("KUriFilter IKWS (KIO)");
tmp.logName = QStringLiteral("org.kde.kurifilter-ikws");
tmp.loggingType = LoggingCategory::Info;
......@@ -134,11 +130,7 @@ void LoadCategoriesJobTest::shouldReadRules_data()
<< qtKdeCategories;
qtKdeCategories.clear();
tmp.description = QStringLiteral("KPasswdServer (KIO)");
tmp.logName = QStringLiteral("org.kde.kio.kpasswdserver");
tmp.loggingType = LoggingCategory::All;
tmp.enabled = true;
qtKdeCategories.append(tmp);
qtKdeCategories.append(LoggingCategory(QStringLiteral("KPasswdServer (KIO)"), QStringLiteral("org.kde.kio.kpasswdserver"), LoggingCategory::All, true));
tmp.description = QStringLiteral("KUriFilter IKWS (KIO)");
tmp.logName = QStringLiteral("org.kde.kurifilter-ikws");
......@@ -173,11 +165,7 @@ void LoadCategoriesJobTest::shouldReadRules_data()
<< qtKdeCategories;
qtKdeCategories.clear();
tmp.description = QStringLiteral("KPasswdServer (KIO)");
tmp.logName = QStringLiteral("org.kde.kio.kpasswdserver");
tmp.loggingType = LoggingCategory::Info;
tmp.enabled = true;
qtKdeCategories.append(tmp);
qtKdeCategories.append(LoggingCategory(QStringLiteral("KPasswdServer (KIO)"), QStringLiteral("org.kde.kio.kpasswdserver"), LoggingCategory::Info, true));
tmp.description = QStringLiteral("KUriFilter IKWS (KIO)");
tmp.logName = QStringLiteral("org.kde.kurifilter-ikws");
......@@ -212,11 +200,7 @@ void LoadCategoriesJobTest::shouldReadRules_data()
<< qtKdeCategories;
qtKdeCategories.clear();
tmp.description = QStringLiteral("KPasswdServer (KIO)");
tmp.logName = QStringLiteral("org.kde.kio.kpasswdserver");
tmp.loggingType = LoggingCategory::Warning;
tmp.enabled = true;
qtKdeCategories.append(tmp);
qtKdeCategories.append(LoggingCategory(QStringLiteral("KPasswdServer (KIO)"), QStringLiteral("org.kde.kio.kpasswdserver"), LoggingCategory::Warning, true));
tmp.description = QStringLiteral("KUriFilter IKWS (KIO)");
tmp.logName = QStringLiteral("org.kde.kurifilter-ikws");
......@@ -247,11 +231,7 @@ void LoadCategoriesJobTest::shouldReadRules_data()
<< qtKdeCategories;
qtKdeCategories.clear();
tmp.description = QStringLiteral("KPasswdServer (KIO)");
tmp.logName = QStringLiteral("org.kde.kio.kpasswdserver");
tmp.loggingType = LoggingCategory::Critical;
tmp.enabled = true;
qtKdeCategories.append(tmp);
qtKdeCategories.append(LoggingCategory(QStringLiteral("KPasswdServer (KIO)"), QStringLiteral("org.kde.kio.kpasswdserver"), LoggingCategory::Critical, true));
tmp.description = QStringLiteral("KUriFilter IKWS (KIO)");
tmp.logName = QStringLiteral("org.kde.kurifilter-ikws");
......@@ -289,11 +269,7 @@ void LoadCategoriesJobTest::shouldReadRules_data()
<< qtKdeCategories;
qtKdeCategories.clear();
tmp.description = QStringLiteral("KPasswdServer (KIO)");
tmp.logName = QStringLiteral("org.kde.kio.kpasswdserver");
tmp.loggingType = LoggingCategory::Debug;
tmp.enabled = true;
qtKdeCategories.append(tmp);
qtKdeCategories.append(LoggingCategory(QStringLiteral("KPasswdServer (KIO)"), QStringLiteral("org.kde.kio.kpasswdserver"), LoggingCategory::Debug, true));
tmp.description = QStringLiteral("KUriFilter IKWS (KIO)");
tmp.logName = QStringLiteral("org.kde.kurifilter-ikws");
......
......@@ -40,7 +40,7 @@ bool LoggingCategory::isValid() const
return !logName.isEmpty();
}
QString LoggingCategory::createCustomRule()
QString LoggingCategory::createCustomRule() const
{
QString str;
switch (loggingType) {
......@@ -74,7 +74,7 @@ QString LoggingCategory::createCustomRule()
}
QString LoggingCategory::createRule()
QString LoggingCategory::createRule() const
{
QString str;
switch (loggingType) {
......
......@@ -25,8 +25,6 @@
#include <QString>
struct LoggingCategory {
LoggingCategory();
enum LoggingType {
All = 0,
Info,
......@@ -37,12 +35,19 @@ struct LoggingCategory {
Undefined
};
LoggingCategory();
explicit LoggingCategory(const QString &description, const QString &logName, LoggingType loggingType, bool enabled)
: description(description), logName(logName), loggingType(loggingType), enabled(enabled) {}
typedef QVector<LoggingCategory> List;
bool operator ==(const LoggingCategory &other) const;
bool isValid() const;
QString createRule();
QString createCustomRule();
QString createRule() const;
QString createCustomRule() const;
QString description;
QString logName;
LoggingType loggingType;
......
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