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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
|
#include "testpreferences.h"
#include "core/subsurface-qt/SettingsObjectWrapper.h"
#include <QtTest>
#define TEST(METHOD, VALUE) \
QCOMPARE(METHOD, VALUE); \
pref->sync(); \
pref->load(); \
QCOMPARE(METHOD, VALUE);
void TestPreferences::testPreferences()
{
auto pref = SettingsObjectWrapper::instance();
pref->load();
pref->animation_settings->setAnimationSpeed(20);
TEST(pref->animation_settings->animationSpeed(), 20);
pref->animation_settings->setAnimationSpeed(30);
TEST(pref->animation_settings->animationSpeed(), 30);
auto cloud = pref->cloud_storage;
cloud->setBackgroundSync(true);
TEST(cloud->backgroundSync(), true);
cloud->setBackgroundSync(false);
TEST(cloud->backgroundSync(), false);
cloud->setBaseUrl("test_one");
TEST(cloud->baseUrl(), QStringLiteral("test_one"));
cloud->setBaseUrl("test_two");
TEST(cloud->baseUrl(), QStringLiteral("test_two"));
cloud->setEmail("tomaz@subsurface.com");
TEST(cloud->email(), QStringLiteral("tomaz@subsurface.com"));
cloud->setEmail("tomaz@gmail.com");
TEST(cloud->email(), QStringLiteral("tomaz@gmail.com"));
cloud->setGitLocalOnly(true);
TEST(cloud->gitLocalOnly(), true);
cloud->setGitLocalOnly(false);
TEST(cloud->gitLocalOnly(), false);
// Why there's new password and password on the prefs?
cloud->setNewPassword("ABCD");
TEST(cloud->newPassword(), QStringLiteral("ABCD"));
cloud->setNewPassword("ABCDE");
TEST(cloud->newPassword(), QStringLiteral("ABCDE"));
cloud->setPassword("ABCDE");
TEST(cloud->password(), QStringLiteral("ABCDE"));
cloud->setPassword("ABCABC");
TEST(cloud->password(), QStringLiteral("ABCABC"));
cloud->setSavePasswordLocal(true);
TEST(cloud->savePasswordLocal(), true);
cloud->setSavePasswordLocal(false);
TEST(cloud->savePasswordLocal(), false);
// Why this is short and not bool?
cloud->setSaveUserIdLocal(1);
TEST(cloud->saveUserIdLocal(), (short)1);
cloud->setSaveUserIdLocal(0);
TEST(cloud->saveUserIdLocal(), (short)0);
cloud->setUserId("Tomaz");
TEST(cloud->userId(), QStringLiteral("Tomaz"));
cloud->setUserId("Zamot");
TEST(cloud->userId(), QStringLiteral("Zamot"));
cloud->setVerificationStatus(0);
TEST(cloud->verificationStatus(), (short)0);
cloud->setVerificationStatus(1);
TEST(cloud->verificationStatus(), (short)1);
}
QTEST_MAIN(TestPreferences)
|