1 /*
2     SPDX-FileCopyrightText: 2019-2021 Laurent Montel <montel@kde.org>
3 
4     SPDX-License-Identifier: LGPL-2.0-or-later
5 
6 */
7 
8 #include "changedebugmodejobtest.h"
9 #include "changedebugmodejob.h"
10 #include <QTest>
QTEST_GUILESS_MAIN(ChangeDebugModeJobTest)11 QTEST_GUILESS_MAIN(ChangeDebugModeJobTest)
12 
13 ChangeDebugModeJobTest::ChangeDebugModeJobTest(QObject *parent)
14     : QObject(parent)
15 {
16 }
17 
shouldHaveDefaultValue()18 void ChangeDebugModeJobTest::shouldHaveDefaultValue()
19 {
20     ChangeDebugModeJob job;
21     QVERIFY(job.debugMode().isEmpty());
22     QVERIFY(job.loggingCategoriesName().isEmpty());
23     QVERIFY(!job.canStart());
24     QVERIFY(!job.withoutArguments());
25 }
26 
shouldBeAbleToStart()27 void ChangeDebugModeJobTest::shouldBeAbleToStart()
28 {
29     ChangeDebugModeJob job;
30     job.setDebugMode(QStringLiteral("foo"));
31     QVERIFY(!job.debugMode().isEmpty());
32     QVERIFY(job.loggingCategoriesName().isEmpty());
33     QVERIFY(!job.canStart());
34     job.setLoggingCategoriesName({QStringLiteral("foo")});
35     QVERIFY(!job.debugMode().isEmpty());
36     QVERIFY(!job.loggingCategoriesName().isEmpty());
37     QVERIFY(job.canStart());
38 }
39 
shouldBeAbleToStartWithoutArgument()40 void ChangeDebugModeJobTest::shouldBeAbleToStartWithoutArgument()
41 {
42     ChangeDebugModeJob job;
43     QVERIFY(!job.canStart());
44     job.setWithoutArguments(true);
45     QVERIFY(job.canStart());
46     job.setDebugMode(QStringLiteral("foo"));
47     QVERIFY(job.canStart());
48 }
49 
shouldConvertToLoggingType()50 void ChangeDebugModeJobTest::shouldConvertToLoggingType()
51 {
52     ChangeDebugModeJob job;
53     QCOMPARE(job.convertDebugModeToLoggingType(QStringLiteral("bla")), LoggingCategory::LoggingType::Undefined);
54     QCOMPARE(job.convertDebugModeToLoggingType(QString()), LoggingCategory::LoggingType::Undefined);
55 
56     QCOMPARE(job.convertDebugModeToLoggingType(QStringLiteral("Full")), LoggingCategory::LoggingType::All);
57     QCOMPARE(job.convertDebugModeToLoggingType(QStringLiteral("Info")), LoggingCategory::LoggingType::Info);
58     QCOMPARE(job.convertDebugModeToLoggingType(QStringLiteral("Warning")), LoggingCategory::LoggingType::Warning);
59     QCOMPARE(job.convertDebugModeToLoggingType(QStringLiteral("Critical")), LoggingCategory::LoggingType::Critical);
60     QCOMPARE(job.convertDebugModeToLoggingType(QStringLiteral("Off")), LoggingCategory::LoggingType::Off);
61 }
62