33
const static QByteArray BOOLEAN_DEFINITION = R"(
36
"id": "enabledSetting",
37
"displayName": "Enabled",
46
const static QByteArray LIST_DEFINITION = R"(
49
"id": "unitTempSetting",
50
"displayName": "Temperature Units",
54
"values": ["Celcius", "Fahrenheit"]
60
const static QByteArray NUMBER_DEFINITION = R"(
73
const static QByteArray STRING_DEFINITION = R"(
76
"id": "locationSetting",
77
"displayName": "Location",
80
"defaultValue": "London"
33
const static QByteArray BOOLEAN_DEFINITION =
37
"id": "enabledSetting",
38
"displayName": "Enabled",
47
const static QByteArray LIST_DEFINITION =
51
"id": "unitTempSetting",
52
"displayName": "Temperature Units",
56
"values": ["Celcius", "Fahrenheit"]
62
const static QByteArray NUMBER_DEFINITION =
76
const static QByteArray STRING_DEFINITION =
80
"id": "locationSetting",
81
"displayName": "Location",
84
"defaultValue": "London"
90
const static QByteArray MIXED_DEFINITION =
94
"id": "locationSetting",
95
"displayName": "Location",
98
"defaultValue": "London"
102
"id": "unitTempSetting",
103
"displayName": "Temperature Units",
107
"values": ["Celcius", "Fahrenheit"]
112
"displayName": "Age",
119
"id": "enabledSetting",
120
"displayName": "Enabled",
90
133
QScopedPointer<QTemporaryDir> tempDir;
92
QSharedPointer<SettingsModelInterface> newSettingsModel(const QString& id, const QByteArray& json)
135
QSharedPointer<SettingsModelInterface> settings;
137
void newSettingsModel(const QString& id, const QByteArray& json)
94
139
QJsonDocument doc = QJsonDocument::fromJson(json);
95
140
QVariant definitions = doc.toVariant();
96
return QSharedPointer<SettingsModelInterface>(
97
new SettingsModel(tempDir->path(), id, definitions));
141
settings.reset(new SettingsModel(tempDir->path(), id, definitions));
110
154
void testBooleanDefinition()
112
156
newSettingsModel("boolean", BOOLEAN_DEFINITION);
157
QVERIFY(settings->rowCount() == 1);
115
160
void testListDefinition()
117
162
newSettingsModel("list", LIST_DEFINITION);
163
QVERIFY(settings->rowCount() == 1);
120
166
void testNumberDefinition()
122
168
newSettingsModel("number", NUMBER_DEFINITION);
169
QVERIFY(settings->rowCount() == 1);
125
172
void testStringDefinition()
127
174
newSettingsModel("string", STRING_DEFINITION);
175
QVERIFY(settings->rowCount() == 1);
178
void testMixedDefinition()
180
newSettingsModel("mixed", MIXED_DEFINITION);
181
QVERIFY(settings->rowCount() == 4);