Changeset View
Changeset View
Standalone View
Standalone View
tests/kded/configtest.cpp
Show All 10 Lines | |||||
11 | but WITHOUT ANY WARRANTY; without even the implied warranty of | 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
13 | GNU General Public License for more details. | 13 | GNU General Public License for more details. | ||
14 | 14 | | |||
15 | You should have received a copy of the GNU General Public License | 15 | You should have received a copy of the GNU General Public License | ||
16 | along with this program. If not, see <http://www.gnu.org/licenses/>. | 16 | along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
17 | *********************************************************************/ | 17 | *********************************************************************/ | ||
18 | #include "../../kded/config.h" | 18 | #include "../../kded/config.h" | ||
19 | #include "../../common/globals.h" | ||||
19 | 20 | | |||
20 | #include <QtTest> | 21 | #include <QtTest> | ||
21 | #include <QObject> | 22 | #include <QObject> | ||
22 | 23 | | |||
23 | #include <KScreen/Config> | 24 | #include <KScreen/Config> | ||
24 | #include <KScreen/EDID> | 25 | #include <KScreen/EDID> | ||
25 | #include <KScreen/Screen> | 26 | #include <KScreen/Screen> | ||
26 | #include <KScreen/Mode> | 27 | #include <KScreen/Mode> | ||
▲ Show 20 Lines • Show All 71 Lines • ▼ Show 20 Line(s) | 57 | { | |||
98 | auto configWrapper = std::unique_ptr<Config>(new Config(config)); | 99 | auto configWrapper = std::unique_ptr<Config>(new Config(config)); | ||
99 | 100 | | |||
100 | return configWrapper; | 101 | return configWrapper; | ||
101 | } | 102 | } | ||
102 | 103 | | |||
103 | void TestConfig::initTestCase() | 104 | void TestConfig::initTestCase() | ||
104 | { | 105 | { | ||
105 | qputenv("KSCREEN_LOGGING", "false"); | 106 | qputenv("KSCREEN_LOGGING", "false"); | ||
106 | Config::setDirPath(QStringLiteral(TEST_DATA "serializerdata/")); | 107 | Globals::setDirPath(QStringLiteral(TEST_DATA "serializerdata/")); | ||
107 | } | 108 | } | ||
108 | 109 | | |||
109 | void TestConfig::testSimpleConfig() | 110 | void TestConfig::testSimpleConfig() | ||
110 | { | 111 | { | ||
111 | auto configWrapper = createConfig(true, false); | 112 | auto configWrapper = createConfig(true, false); | ||
112 | configWrapper = std::move(configWrapper->readFile(QStringLiteral("simpleConfig.json"))); | 113 | configWrapper = std::move(configWrapper->readFile(QStringLiteral("simpleConfig.json"))); | ||
113 | 114 | | |||
114 | auto config = configWrapper->data(); | 115 | auto config = configWrapper->data(); | ||
▲ Show 20 Lines • Show All 246 Lines • ▼ Show 20 Line(s) | 281 | { | |||
361 | config->addOutput(output6); | 362 | config->addOutput(output6); | ||
362 | config->addOutput(output2); | 363 | config->addOutput(output2); | ||
363 | config->addOutput(output5); | 364 | config->addOutput(output5); | ||
364 | config->addOutput(output4); | 365 | config->addOutput(output4); | ||
365 | config->addOutput(output3); | 366 | config->addOutput(output3); | ||
366 | config->addOutput(output1); | 367 | config->addOutput(output1); | ||
367 | 368 | | |||
368 | Config configWrapper(config); | 369 | Config configWrapper(config); | ||
369 | configWrapper.setDirPath(QStringLiteral(TEST_DATA "serializerdata/")); | | |||
370 | 370 | | |||
371 | QHash<QString, QPoint> positions; | 371 | QHash<QString, QPoint> positions; | ||
372 | positions[QStringLiteral("DisplayPort-0")] = QPoint(0, 1080); | 372 | positions[QStringLiteral("DisplayPort-0")] = QPoint(0, 1080); | ||
373 | positions[QStringLiteral("DisplayPort-1")] = QPoint(2100, 30); | 373 | positions[QStringLiteral("DisplayPort-1")] = QPoint(2100, 30); | ||
374 | positions[QStringLiteral("DisplayPort-2")] = QPoint(2100, 1080); | 374 | positions[QStringLiteral("DisplayPort-2")] = QPoint(2100, 1080); | ||
375 | positions[QStringLiteral("DisplayPort-3")] = QPoint(4020, 0); | 375 | positions[QStringLiteral("DisplayPort-3")] = QPoint(4020, 0); | ||
376 | positions[QStringLiteral("DVI-0")] = QPoint(4020, 1080); | 376 | positions[QStringLiteral("DVI-0")] = QPoint(4020, 1080); | ||
377 | positions[QStringLiteral("DVI-1")] = QPoint(0, 0); | 377 | positions[QStringLiteral("DVI-1")] = QPoint(0, 0); | ||
Show All 24 Lines | 397 | { | |||
402 | auto configWrapper = createConfig(true, true); | 402 | auto configWrapper = createConfig(true, true); | ||
403 | configWrapper = std::move(configWrapper->readFile(QStringLiteral("twoScreenConfig.json"))); | 403 | configWrapper = std::move(configWrapper->readFile(QStringLiteral("twoScreenConfig.json"))); | ||
404 | 404 | | |||
405 | auto config = configWrapper->data(); | 405 | auto config = configWrapper->data(); | ||
406 | QVERIFY(config); | 406 | QVERIFY(config); | ||
407 | 407 | | |||
408 | // Make sure we don't write into TEST_DATA | 408 | // Make sure we don't write into TEST_DATA | ||
409 | QStandardPaths::setTestModeEnabled(true); | 409 | QStandardPaths::setTestModeEnabled(true); | ||
410 | configWrapper->setDirPath(QStandardPaths::writableLocation(QStandardPaths::GenericDataLocation) % QStringLiteral("/kscreen/")); | 410 | Globals::setDirPath(QStandardPaths::writableLocation(QStandardPaths::GenericDataLocation) % QStringLiteral("/kscreen/")); | ||
411 | // TODO: this needs setup of the control directory | 411 | // TODO: this needs setup of the control directory | ||
412 | 412 | | |||
413 | // Basic assumptions for the remainder of our tests, this is the situation where the lid is opened | 413 | // Basic assumptions for the remainder of our tests, this is the situation where the lid is opened | ||
414 | QCOMPARE(config->connectedOutputs().count(), 2); | 414 | QCOMPARE(config->connectedOutputs().count(), 2); | ||
415 | 415 | | |||
416 | auto output = config->connectedOutputs().first(); | 416 | auto output = config->connectedOutputs().first(); | ||
417 | QCOMPARE(output->name(), QLatin1String("OUTPUT-1")); | 417 | QCOMPARE(output->name(), QLatin1String("OUTPUT-1")); | ||
418 | QCOMPARE(output->isEnabled(), true); | 418 | QCOMPARE(output->isEnabled(), true); | ||
▲ Show 20 Lines • Show All 58 Lines • ▼ Show 20 Line(s) | |||||
477 | QCOMPARE(output->isEnabled(), true); | 477 | QCOMPARE(output->isEnabled(), true); | ||
478 | QCOMPARE(output->isPrimary(), true); | 478 | QCOMPARE(output->isPrimary(), true); | ||
479 | 479 | | |||
480 | output2 = config->connectedOutputs().last(); | 480 | output2 = config->connectedOutputs().last(); | ||
481 | QCOMPARE(output2->name(), QLatin1String("OUTPUT-2")); | 481 | QCOMPARE(output2->name(), QLatin1String("OUTPUT-2")); | ||
482 | QCOMPARE(output2->isEnabled(), true); | 482 | QCOMPARE(output2->isEnabled(), true); | ||
483 | QCOMPARE(output2->isPrimary(), false); | 483 | QCOMPARE(output2->isPrimary(), false); | ||
484 | 484 | | |||
485 | Config::setDirPath(QStringLiteral(TEST_DATA "/serializerdata/")); | 485 | Globals::setDirPath(QStringLiteral(TEST_DATA "/serializerdata/")); | ||
486 | } | 486 | } | ||
487 | 487 | | |||
488 | void TestConfig::testFixedConfig() | 488 | void TestConfig::testFixedConfig() | ||
489 | { | 489 | { | ||
490 | // Load a dualhead config | 490 | // Load a dualhead config | ||
491 | auto configWrapper = createConfig(true, true); | 491 | auto configWrapper = createConfig(true, true); | ||
492 | configWrapper = std::move(configWrapper->readFile(QStringLiteral("twoScreenConfig.json"))); | 492 | configWrapper = std::move(configWrapper->readFile(QStringLiteral("twoScreenConfig.json"))); | ||
493 | auto config = configWrapper->data(); | 493 | auto config = configWrapper->data(); | ||
494 | QVERIFY(config); | 494 | QVERIFY(config); | ||
495 | 495 | | |||
496 | // Make sure we don't write into TEST_DATA | 496 | // Make sure we don't write into TEST_DATA | ||
497 | QStandardPaths::setTestModeEnabled(true); | 497 | QStandardPaths::setTestModeEnabled(true); | ||
498 | Config::setDirPath(QStandardPaths::writableLocation(QStandardPaths::GenericDataLocation) % QStringLiteral("/kscreen/")); | 498 | Globals::setDirPath(QStandardPaths::writableLocation(QStandardPaths::GenericDataLocation) % QStringLiteral("/kscreen/")); | ||
499 | // TODO: this needs setup of the control directory | 499 | // TODO: this needs setup of the control directory | ||
500 | 500 | | |||
501 | const QString fixedCfgPath = Config::configsDirPath() % Config::s_fixedConfigFileName; | 501 | 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 | 502 | // save config as the current one, this is the config we don't want restored, and which we'll overwrite | ||
503 | configWrapper->writeFile(fixedCfgPath); | 503 | configWrapper->writeFile(fixedCfgPath); | ||
504 | 504 | | |||
505 | // Check if both files exist | 505 | // Check if both files exist | ||
506 | QFile fixedCfg(fixedCfgPath); | 506 | QFile fixedCfg(fixedCfgPath); | ||
507 | QVERIFY(fixedCfg.exists()); | 507 | QVERIFY(fixedCfg.exists()); | ||
508 | 508 | | |||
509 | Config::setDirPath(QStringLiteral(TEST_DATA "/serializerdata/")); | 509 | Globals::setDirPath(QStringLiteral(TEST_DATA "/serializerdata/")); | ||
510 | } | 510 | } | ||
511 | 511 | | |||
512 | 512 | | |||
513 | QTEST_MAIN(TestConfig) | 513 | QTEST_MAIN(TestConfig) | ||
514 | 514 | | |||
515 | #include "configtest.moc" | 515 | #include "configtest.moc" |