Changeset View
Changeset View
Standalone View
Standalone View
plugins/qthelp/tests/test_qthelpplugin.cpp
Show First 20 Lines • Show All 52 Lines • ▼ Show 20 Line(s) | 51 | { | |||
---|---|---|---|---|---|
53 | m_testCore = new TestCore(); | 53 | m_testCore = new TestCore(); | ||
54 | m_testCore->initialize(); | 54 | m_testCore->initialize(); | ||
55 | } | 55 | } | ||
56 | 56 | | |||
57 | void TestQtHelpPlugin::init() | 57 | void TestQtHelpPlugin::init() | ||
58 | { | 58 | { | ||
59 | m_plugin = new QtHelpPlugin(m_testCore, QVariantList()); | 59 | m_plugin = new QtHelpPlugin(m_testCore, QVariantList()); | ||
60 | // write default config and read it | 60 | // write default config and read it | ||
61 | qtHelpWriteConfig(QStringList(), QStringList(), QStringList(), QStringList(), QString(), true); | 61 | qtHelpWriteConfig(QStringList(), QStringList(), QStringList(), QStringList(), QString(), true, false); | ||
mwolff: add proper defaults to the struct, so that you don't need to do any default initialization here | |||||
62 | m_plugin->readConfig(); | 62 | m_plugin->readConfig(); | ||
63 | } | 63 | } | ||
64 | 64 | | |||
65 | void TestQtHelpPlugin::cleanup() | 65 | void TestQtHelpPlugin::cleanup() | ||
66 | { | 66 | { | ||
67 | delete m_plugin; | 67 | delete m_plugin; | ||
68 | } | 68 | } | ||
69 | 69 | | |||
70 | void TestQtHelpPlugin::cleanupTestCase() | 70 | void TestQtHelpPlugin::cleanupTestCase() | ||
71 | { | 71 | { | ||
72 | m_testCore->cleanup(); | 72 | m_testCore->cleanup(); | ||
73 | delete m_testCore; | 73 | delete m_testCore; | ||
74 | } | 74 | } | ||
75 | 75 | | |||
76 | void TestQtHelpPlugin::testDefaultValue() | 76 | void TestQtHelpPlugin::testDefaultValue() | ||
77 | { | 77 | { | ||
78 | QCOMPARE(m_plugin->isQtHelpQtDocLoaded(), true); | 78 | QCOMPARE(m_plugin->isQtHelpQtDocLoaded(), true); | ||
79 | QCOMPARE(m_plugin->qtHelpProviderLoaded().size(), 0); | 79 | QCOMPARE(m_plugin->qtHelpProviderLoaded().size(), 0); | ||
80 | QCOMPARE(m_plugin->providers().size(), 1); | 80 | QCOMPARE(m_plugin->providers().size(), 1); | ||
81 | } | 81 | } | ||
82 | 82 | | |||
83 | void TestQtHelpPlugin::testUnsetQtHelpDoc() | 83 | void TestQtHelpPlugin::testUnsetQtHelpDoc() | ||
84 | { | 84 | { | ||
85 | qtHelpWriteConfig(QStringList(), QStringList(), QStringList(), QStringList(), QString(), false); | 85 | qtHelpWriteConfig(QStringList(), QStringList(), QStringList(), QStringList(), QString(), false, false); | ||
86 | m_plugin->readConfig(); | 86 | m_plugin->readConfig(); | ||
87 | 87 | | |||
88 | QCOMPARE(m_plugin->providers().size(), 0); | 88 | QCOMPARE(m_plugin->providers().size(), 0); | ||
89 | } | 89 | } | ||
90 | 90 | | |||
91 | void TestQtHelpPlugin::testAddOneValidProvider() | 91 | void TestQtHelpPlugin::testAddOneValidProvider() | ||
92 | { | 92 | { | ||
93 | QStringList path, name, icon, ghns; | 93 | QStringList path, name, icon, ghns; | ||
94 | path << VALID1; | 94 | path << VALID1; | ||
95 | name << QStringLiteral("file1"); | 95 | name << QStringLiteral("file1"); | ||
96 | icon << QStringLiteral("myIcon"); | 96 | icon << QStringLiteral("myIcon"); | ||
97 | ghns << QStringLiteral("0"); | 97 | ghns << QStringLiteral("0"); | ||
98 | qtHelpWriteConfig(icon, name, path, ghns, QString(), true); | 98 | qtHelpWriteConfig(icon, name, path, ghns, QString(), true, false); | ||
99 | m_plugin->readConfig(); | 99 | m_plugin->readConfig(); | ||
100 | 100 | | |||
101 | QCOMPARE(m_plugin->qtHelpProviderLoaded().size(), 1); | 101 | QCOMPARE(m_plugin->qtHelpProviderLoaded().size(), 1); | ||
102 | QCOMPARE(m_plugin->qtHelpProviderLoaded().at(0)->fileName(), path.at(0)); | 102 | QCOMPARE(m_plugin->qtHelpProviderLoaded().at(0)->fileName(), path.at(0)); | ||
103 | QCOMPARE(m_plugin->qtHelpProviderLoaded().at(0)->name(), name.at(0)); | 103 | QCOMPARE(m_plugin->qtHelpProviderLoaded().at(0)->name(), name.at(0)); | ||
104 | QCOMPARE(m_plugin->qtHelpProviderLoaded().at(0)->iconName(), icon.at(0)); | 104 | QCOMPARE(m_plugin->qtHelpProviderLoaded().at(0)->iconName(), icon.at(0)); | ||
105 | } | 105 | } | ||
106 | 106 | | |||
107 | void TestQtHelpPlugin::testAddTwoDifferentValidProvider() | 107 | void TestQtHelpPlugin::testAddTwoDifferentValidProvider() | ||
108 | { | 108 | { | ||
109 | QStringList path, name, icon, ghns; | 109 | QStringList path, name, icon, ghns; | ||
110 | path << VALID1 << VALID2; | 110 | path << VALID1 << VALID2; | ||
111 | name << QStringLiteral("file1") << QStringLiteral("file2"); | 111 | name << QStringLiteral("file1") << QStringLiteral("file2"); | ||
112 | icon << QStringLiteral("myIcon") << QStringLiteral("myIcon"); | 112 | icon << QStringLiteral("myIcon") << QStringLiteral("myIcon"); | ||
113 | ghns << QStringLiteral("0") << QStringLiteral("0"); | 113 | ghns << QStringLiteral("0") << QStringLiteral("0"); | ||
114 | qtHelpWriteConfig(icon, name, path, ghns, QString(), true); | 114 | qtHelpWriteConfig(icon, name, path, ghns, QString(), true, false); | ||
115 | m_plugin->readConfig(); | 115 | m_plugin->readConfig(); | ||
116 | 116 | | |||
117 | QCOMPARE(m_plugin->qtHelpProviderLoaded().size(), 2); | 117 | QCOMPARE(m_plugin->qtHelpProviderLoaded().size(), 2); | ||
118 | // first provider | 118 | // first provider | ||
119 | QCOMPARE(m_plugin->qtHelpProviderLoaded().at(0)->fileName(), path.at(0)); | 119 | QCOMPARE(m_plugin->qtHelpProviderLoaded().at(0)->fileName(), path.at(0)); | ||
120 | QCOMPARE(m_plugin->qtHelpProviderLoaded().at(0)->name(), name.at(0)); | 120 | QCOMPARE(m_plugin->qtHelpProviderLoaded().at(0)->name(), name.at(0)); | ||
121 | QCOMPARE(m_plugin->qtHelpProviderLoaded().at(0)->iconName(), icon.at(0)); | 121 | QCOMPARE(m_plugin->qtHelpProviderLoaded().at(0)->iconName(), icon.at(0)); | ||
122 | // second provider | 122 | // second provider | ||
123 | QCOMPARE(m_plugin->qtHelpProviderLoaded().at(1)->fileName(), path.at(1)); | 123 | QCOMPARE(m_plugin->qtHelpProviderLoaded().at(1)->fileName(), path.at(1)); | ||
124 | QCOMPARE(m_plugin->qtHelpProviderLoaded().at(1)->name(), name.at(1)); | 124 | QCOMPARE(m_plugin->qtHelpProviderLoaded().at(1)->name(), name.at(1)); | ||
125 | QCOMPARE(m_plugin->qtHelpProviderLoaded().at(1)->iconName(), icon.at(1)); | 125 | QCOMPARE(m_plugin->qtHelpProviderLoaded().at(1)->iconName(), icon.at(1)); | ||
126 | } | 126 | } | ||
127 | 127 | | |||
128 | void TestQtHelpPlugin::testAddInvalidProvider() | 128 | void TestQtHelpPlugin::testAddInvalidProvider() | ||
129 | { | 129 | { | ||
130 | QStringList path, name, icon, ghns; | 130 | QStringList path, name, icon, ghns; | ||
131 | path << INVALID; | 131 | path << INVALID; | ||
132 | name << QStringLiteral("file1"); | 132 | name << QStringLiteral("file1"); | ||
133 | icon << QStringLiteral("myIcon"); | 133 | icon << QStringLiteral("myIcon"); | ||
134 | ghns << QStringLiteral("0"); | 134 | ghns << QStringLiteral("0"); | ||
135 | qtHelpWriteConfig(icon, name, path, ghns, QString(), true); | 135 | qtHelpWriteConfig(icon, name, path, ghns, QString(), true, false); | ||
136 | m_plugin->readConfig(); | 136 | m_plugin->readConfig(); | ||
137 | 137 | | |||
138 | QCOMPARE(m_plugin->qtHelpProviderLoaded().size(), 0); | 138 | QCOMPARE(m_plugin->qtHelpProviderLoaded().size(), 0); | ||
139 | } | 139 | } | ||
140 | 140 | | |||
141 | void TestQtHelpPlugin::testAddTwiceSameProvider() | 141 | void TestQtHelpPlugin::testAddTwiceSameProvider() | ||
142 | { | 142 | { | ||
143 | QStringList path, name, icon, ghns; | 143 | QStringList path, name, icon, ghns; | ||
144 | path << VALID1 << VALID1; | 144 | path << VALID1 << VALID1; | ||
145 | name << QStringLiteral("file1") << QStringLiteral("file2"); | 145 | name << QStringLiteral("file1") << QStringLiteral("file2"); | ||
146 | icon << QStringLiteral("myIcon") << QStringLiteral("myIcon"); | 146 | icon << QStringLiteral("myIcon") << QStringLiteral("myIcon"); | ||
147 | ghns << QStringLiteral("0") << QStringLiteral("0"); | 147 | ghns << QStringLiteral("0") << QStringLiteral("0"); | ||
148 | qtHelpWriteConfig(icon, name, path, ghns, QString(), true); | 148 | qtHelpWriteConfig(icon, name, path, ghns, QString(), true, false); | ||
149 | m_plugin->readConfig(); | 149 | m_plugin->readConfig(); | ||
150 | 150 | | |||
151 | QCOMPARE(m_plugin->qtHelpProviderLoaded().size(), 1); | 151 | QCOMPARE(m_plugin->qtHelpProviderLoaded().size(), 1); | ||
152 | } | 152 | } | ||
153 | 153 | | |||
154 | void TestQtHelpPlugin::testRemoveOneProvider() | 154 | void TestQtHelpPlugin::testRemoveOneProvider() | ||
155 | { | 155 | { | ||
156 | QStringList path, name, icon, ghns; | 156 | QStringList path, name, icon, ghns; | ||
157 | path << VALID1 << VALID2; | 157 | path << VALID1 << VALID2; | ||
158 | name << QStringLiteral("file1") << QStringLiteral("file2"); | 158 | name << QStringLiteral("file1") << QStringLiteral("file2"); | ||
159 | icon << QStringLiteral("myIcon") << QStringLiteral("myIcon"); | 159 | icon << QStringLiteral("myIcon") << QStringLiteral("myIcon"); | ||
160 | ghns << QStringLiteral("0") << QStringLiteral("0"); | 160 | ghns << QStringLiteral("0") << QStringLiteral("0"); | ||
161 | qtHelpWriteConfig(icon, name, path, ghns, QString(), true); | 161 | qtHelpWriteConfig(icon, name, path, ghns, QString(), true, false); | ||
162 | m_plugin->readConfig(); | 162 | m_plugin->readConfig(); | ||
163 | 163 | | |||
164 | QCOMPARE(m_plugin->qtHelpProviderLoaded().size(), 2); | 164 | QCOMPARE(m_plugin->qtHelpProviderLoaded().size(), 2); | ||
165 | // we remove the second provider | 165 | // we remove the second provider | ||
166 | QtHelpProvider *provider = m_plugin->qtHelpProviderLoaded().at(0); | 166 | QtHelpProvider *provider = m_plugin->qtHelpProviderLoaded().at(0); | ||
167 | path.removeAt(1); | 167 | path.removeAt(1); | ||
168 | name.removeAt(1); | 168 | name.removeAt(1); | ||
169 | icon.removeAt(1); | 169 | icon.removeAt(1); | ||
170 | ghns.removeAt(1); | 170 | ghns.removeAt(1); | ||
171 | qtHelpWriteConfig(icon, name, path, ghns, QString(), true); | 171 | qtHelpWriteConfig(icon, name, path, ghns, QString(), true, false); | ||
172 | m_plugin->readConfig(); | 172 | m_plugin->readConfig(); | ||
173 | 173 | | |||
174 | QCOMPARE(m_plugin->qtHelpProviderLoaded().size(), 1); | 174 | QCOMPARE(m_plugin->qtHelpProviderLoaded().size(), 1); | ||
175 | QCOMPARE(m_plugin->qtHelpProviderLoaded().at(0), provider); | 175 | QCOMPARE(m_plugin->qtHelpProviderLoaded().at(0), provider); | ||
176 | } | 176 | } | ||
177 | 177 | | |||
178 | void TestQtHelpPlugin::testDeclarationLookup_Class() | 178 | void TestQtHelpPlugin::testDeclarationLookup_Class() | ||
179 | { | 179 | { | ||
▲ Show 20 Lines • Show All 76 Lines • Show Last 20 Lines |
add proper defaults to the struct, so that you don't need to do any default initialization here