blob: 07044bb5b8a374e7a23ea962c0ca8aedf53f840c (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
|
/*
SPDX-FileCopyrightText: 2021 Alexander Lohnau <alexander.lohnau@gmx.de>
SPDX-License-Identifier: MIT
*/
#include "test_state_config.h"
#include <QTest>
class TestStateConfig : public QObject
{
Q_OBJECT
private Q_SLOTS:
void testStateConfig()
{
auto stateConfig = KSharedConfig::openStateConfig(QStringLiteral("test_statedatarc"));
// Clean the group at every start
stateConfig->deleteGroup("General");
stateConfig->sync();
// It should have the default value
QCOMPARE(MyStateConfig().someStateData(), 0);
// the updated value should be read from the generated config class
stateConfig->group("General").writeEntry("SomeStateData", 1);
QCOMPARE(MyStateConfig().someStateData(), 1);
// Make sure writing the value works as expected
MyStateConfig cfg;
cfg.setSomeStateData(2);
QVERIFY(cfg.isSaveNeeded());
cfg.save();
stateConfig->reparseConfiguration();
QCOMPARE(stateConfig->group("General").readEntry("SomeStateData", -1), 2);
}
};
QTEST_MAIN(TestStateConfig)
#include "test_state_config_main.moc"
|