Changeset View
Changeset View
Standalone View
Standalone View
tests/kded/configtest.cpp
Show All 28 Lines | |||||
29 | 29 | | |||
30 | #include <memory> | 30 | #include <memory> | ||
31 | 31 | | |||
32 | class TestConfig : public QObject | 32 | class TestConfig : public QObject | ||
33 | { | 33 | { | ||
34 | Q_OBJECT | 34 | Q_OBJECT | ||
35 | 35 | | |||
36 | private Q_SLOTS: | 36 | private Q_SLOTS: | ||
37 | void init(); | ||||
37 | void initTestCase(); | 38 | void initTestCase(); | ||
38 | 39 | | |||
39 | void testSimpleConfig(); | 40 | void testSimpleConfig(); | ||
40 | void testTwoScreenConfig(); | 41 | void testTwoScreenConfig(); | ||
41 | void testRotatedScreenConfig(); | 42 | void testRotatedScreenConfig(); | ||
42 | void testDisabledScreenConfig(); | 43 | void testDisabledScreenConfig(); | ||
43 | void testConfig404(); | 44 | void testConfig404(); | ||
44 | void testCorruptConfig(); | 45 | void testCorruptConfig(); | ||
▲ Show 20 Lines • Show All 51 Lines • ▼ Show 20 Line(s) | 58 | { | |||
96 | config->addOutput(output1); | 97 | config->addOutput(output1); | ||
97 | config->addOutput(output2); | 98 | config->addOutput(output2); | ||
98 | 99 | | |||
99 | auto configWrapper = std::unique_ptr<Config>(new Config(config)); | 100 | auto configWrapper = std::unique_ptr<Config>(new Config(config)); | ||
100 | 101 | | |||
101 | return configWrapper; | 102 | return configWrapper; | ||
102 | } | 103 | } | ||
103 | 104 | | |||
105 | void TestConfig::init() | ||||
106 | { | ||||
107 | Globals::setDirPath(QStringLiteral(TEST_DATA "serializerdata/")); | ||||
108 | } | ||||
109 | | ||||
104 | void TestConfig::initTestCase() | 110 | void TestConfig::initTestCase() | ||
105 | { | 111 | { | ||
106 | qputenv("KSCREEN_LOGGING", "false"); | 112 | qputenv("KSCREEN_LOGGING", "false"); | ||
107 | Globals::setDirPath(QStringLiteral(TEST_DATA "serializerdata/")); | | |||
108 | } | 113 | } | ||
109 | 114 | | |||
110 | void TestConfig::testSimpleConfig() | 115 | void TestConfig::testSimpleConfig() | ||
111 | { | 116 | { | ||
112 | auto configWrapper = createConfig(true, false); | 117 | auto configWrapper = createConfig(true, false); | ||
113 | configWrapper = std::move(configWrapper->readFile(QStringLiteral("simpleConfig.json"))); | 118 | configWrapper = std::move(configWrapper->readFile(QStringLiteral("simpleConfig.json"))); | ||
114 | 119 | | |||
115 | auto config = configWrapper->data(); | 120 | auto config = configWrapper->data(); | ||
▲ Show 20 Lines • Show All 360 Lines • ▼ Show 20 Line(s) | 402 | { | |||
476 | QCOMPARE(output->name(), QLatin1String("OUTPUT-1")); | 481 | QCOMPARE(output->name(), QLatin1String("OUTPUT-1")); | ||
477 | QCOMPARE(output->isEnabled(), true); | 482 | QCOMPARE(output->isEnabled(), true); | ||
478 | QCOMPARE(output->isPrimary(), true); | 483 | QCOMPARE(output->isPrimary(), true); | ||
479 | 484 | | |||
480 | output2 = config->connectedOutputs().last(); | 485 | output2 = config->connectedOutputs().last(); | ||
481 | QCOMPARE(output2->name(), QLatin1String("OUTPUT-2")); | 486 | QCOMPARE(output2->name(), QLatin1String("OUTPUT-2")); | ||
482 | QCOMPARE(output2->isEnabled(), true); | 487 | QCOMPARE(output2->isEnabled(), true); | ||
483 | QCOMPARE(output2->isPrimary(), false); | 488 | QCOMPARE(output2->isPrimary(), false); | ||
484 | | ||||
485 | Globals::setDirPath(QStringLiteral(TEST_DATA "/serializerdata/")); | | |||
486 | } | 489 | } | ||
487 | 490 | | |||
488 | void TestConfig::testFixedConfig() | 491 | void TestConfig::testFixedConfig() | ||
489 | { | 492 | { | ||
490 | // Load a dualhead config | 493 | // Load a dualhead config | ||
491 | auto configWrapper = createConfig(true, true); | 494 | auto configWrapper = createConfig(true, true); | ||
492 | configWrapper = std::move(configWrapper->readFile(QStringLiteral("twoScreenConfig.json"))); | 495 | configWrapper = std::move(configWrapper->readFile(QStringLiteral("twoScreenConfig.json"))); | ||
493 | auto config = configWrapper->data(); | 496 | auto config = configWrapper->data(); | ||
494 | QVERIFY(config); | 497 | QVERIFY(config); | ||
495 | 498 | | |||
496 | // Make sure we don't write into TEST_DATA | 499 | // Make sure we don't write into TEST_DATA | ||
497 | QStandardPaths::setTestModeEnabled(true); | 500 | QStandardPaths::setTestModeEnabled(true); | ||
498 | Globals::setDirPath(QStandardPaths::writableLocation(QStandardPaths::GenericDataLocation) % QStringLiteral("/kscreen/")); | 501 | Globals::setDirPath(QStandardPaths::writableLocation(QStandardPaths::GenericDataLocation) % QStringLiteral("/kscreen/")); | ||
499 | // TODO: this needs setup of the control directory | 502 | // TODO: this needs setup of the control directory | ||
500 | 503 | | |||
501 | const QString fixedCfgPath = Config::configsDirPath() % Config::s_fixedConfigFileName; | 504 | const QString fixedCfgPath = Config::configsDirPath() % Config::s_fixedConfigFileName; | ||
502 | // save config as the current one, this is the config we don't want restored, and which we'll overwrite | 505 | // save config as the current one, this is the config we don't want restored, and which we'll overwrite | ||
503 | configWrapper->writeFile(fixedCfgPath); | 506 | configWrapper->writeFile(fixedCfgPath); | ||
504 | 507 | | |||
505 | // Check if both files exist | 508 | // Check if both files exist | ||
506 | QFile fixedCfg(fixedCfgPath); | 509 | QFile fixedCfg(fixedCfgPath); | ||
507 | QVERIFY(fixedCfg.exists()); | 510 | QVERIFY(fixedCfg.exists()); | ||
508 | | ||||
509 | Globals::setDirPath(QStringLiteral(TEST_DATA "/serializerdata/")); | | |||
510 | } | 511 | } | ||
511 | 512 | | |||
512 | 513 | | |||
513 | QTEST_MAIN(TestConfig) | 514 | QTEST_MAIN(TestConfig) | ||
514 | 515 | | |||
515 | #include "configtest.moc" | 516 | #include "configtest.moc" |