File indexing completed on 2025-02-23 05:24:00
0001 /* 0002 SPDX-FileCopyrightText: 2019-2024 Laurent Montel <montel@kde.org> 0003 0004 SPDX-License-Identifier: LGPL-2.0-or-later 0005 0006 */ 0007 0008 #include "changedebugmodejobtest.h" 0009 #include "jobs/changedebugmodejob.h" 0010 #include <QTest> 0011 QTEST_GUILESS_MAIN(ChangeDebugModeJobTest) 0012 0013 ChangeDebugModeJobTest::ChangeDebugModeJobTest(QObject *parent) 0014 : QObject(parent) 0015 { 0016 } 0017 0018 void ChangeDebugModeJobTest::shouldHaveDefaultValue() 0019 { 0020 ChangeDebugModeJob job; 0021 QVERIFY(job.debugMode().isEmpty()); 0022 QVERIFY(job.loggingCategoriesName().isEmpty()); 0023 QVERIFY(!job.canStart()); 0024 QVERIFY(!job.withoutArguments()); 0025 } 0026 0027 void ChangeDebugModeJobTest::shouldBeAbleToStart() 0028 { 0029 ChangeDebugModeJob job; 0030 job.setDebugMode(QStringLiteral("foo")); 0031 QVERIFY(!job.debugMode().isEmpty()); 0032 QVERIFY(job.loggingCategoriesName().isEmpty()); 0033 QVERIFY(!job.canStart()); 0034 job.setLoggingCategoriesName({QStringLiteral("foo")}); 0035 QVERIFY(!job.debugMode().isEmpty()); 0036 QVERIFY(!job.loggingCategoriesName().isEmpty()); 0037 QVERIFY(job.canStart()); 0038 } 0039 0040 void ChangeDebugModeJobTest::shouldBeAbleToStartWithoutArgument() 0041 { 0042 ChangeDebugModeJob job; 0043 QVERIFY(!job.canStart()); 0044 job.setWithoutArguments(true); 0045 QVERIFY(job.canStart()); 0046 job.setDebugMode(QStringLiteral("foo")); 0047 QVERIFY(job.canStart()); 0048 } 0049 0050 void ChangeDebugModeJobTest::shouldConvertToLoggingType() 0051 { 0052 ChangeDebugModeJob job; 0053 QCOMPARE(job.convertDebugModeToLoggingType(QStringLiteral("bla")), LoggingCategory::LoggingType::Undefined); 0054 QCOMPARE(job.convertDebugModeToLoggingType(QString()), LoggingCategory::LoggingType::Undefined); 0055 0056 QCOMPARE(job.convertDebugModeToLoggingType(QStringLiteral("Full")), LoggingCategory::LoggingType::All); 0057 QCOMPARE(job.convertDebugModeToLoggingType(QStringLiteral("Info")), LoggingCategory::LoggingType::Info); 0058 QCOMPARE(job.convertDebugModeToLoggingType(QStringLiteral("Warning")), LoggingCategory::LoggingType::Warning); 0059 QCOMPARE(job.convertDebugModeToLoggingType(QStringLiteral("Critical")), LoggingCategory::LoggingType::Critical); 0060 QCOMPARE(job.convertDebugModeToLoggingType(QStringLiteral("Off")), LoggingCategory::LoggingType::Off); 0061 } 0062 0063 #include "moc_changedebugmodejobtest.cpp"