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 | ExternalViewerSettings extView; | ||
62 | qtHelpWriteConfig(QStringList(), QStringList(), QStringList(), QStringList(), QString(), true, extView); | ||||
mwolff: add proper defaults to the struct, so that you don't need to do any default initialization here | |||||
62 | m_plugin->readConfig(); | 63 | m_plugin->readConfig(); | ||
63 | } | 64 | } | ||
64 | 65 | | |||
65 | void TestQtHelpPlugin::cleanup() | 66 | void TestQtHelpPlugin::cleanup() | ||
66 | { | 67 | { | ||
67 | delete m_plugin; | 68 | delete m_plugin; | ||
68 | } | 69 | } | ||
69 | 70 | | |||
70 | void TestQtHelpPlugin::cleanupTestCase() | 71 | void TestQtHelpPlugin::cleanupTestCase() | ||
71 | { | 72 | { | ||
72 | m_testCore->cleanup(); | 73 | m_testCore->cleanup(); | ||
73 | delete m_testCore; | 74 | delete m_testCore; | ||
74 | } | 75 | } | ||
75 | 76 | | |||
76 | void TestQtHelpPlugin::testDefaultValue() | 77 | void TestQtHelpPlugin::testDefaultValue() | ||
77 | { | 78 | { | ||
78 | QCOMPARE(m_plugin->isQtHelpQtDocLoaded(), true); | 79 | QCOMPARE(m_plugin->isQtHelpQtDocLoaded(), true); | ||
79 | QCOMPARE(m_plugin->qtHelpProviderLoaded().size(), 0); | 80 | QCOMPARE(m_plugin->qtHelpProviderLoaded().size(), 0); | ||
80 | QCOMPARE(m_plugin->providers().size(), 1); | 81 | QCOMPARE(m_plugin->providers().size(), 1); | ||
81 | } | 82 | } | ||
82 | 83 | | |||
83 | void TestQtHelpPlugin::testUnsetQtHelpDoc() | 84 | void TestQtHelpPlugin::testUnsetQtHelpDoc() | ||
84 | { | 85 | { | ||
85 | qtHelpWriteConfig(QStringList(), QStringList(), QStringList(), QStringList(), QString(), false); | 86 | ExternalViewerSettings extView; | ||
87 | qtHelpWriteConfig(QStringList(), QStringList(), QStringList(), QStringList(), QString(), false, extView); | ||||
86 | m_plugin->readConfig(); | 88 | m_plugin->readConfig(); | ||
87 | 89 | | |||
88 | QCOMPARE(m_plugin->providers().size(), 0); | 90 | QCOMPARE(m_plugin->providers().size(), 0); | ||
89 | } | 91 | } | ||
90 | 92 | | |||
91 | void TestQtHelpPlugin::testAddOneValidProvider() | 93 | void TestQtHelpPlugin::testAddOneValidProvider() | ||
92 | { | 94 | { | ||
93 | QStringList path, name, icon, ghns; | 95 | QStringList path, name, icon, ghns; | ||
94 | path << VALID1; | 96 | path << VALID1; | ||
95 | name << QStringLiteral("file1"); | 97 | name << QStringLiteral("file1"); | ||
96 | icon << QStringLiteral("myIcon"); | 98 | icon << QStringLiteral("myIcon"); | ||
97 | ghns << QStringLiteral("0"); | 99 | ghns << QStringLiteral("0"); | ||
98 | qtHelpWriteConfig(icon, name, path, ghns, QString(), true); | 100 | ExternalViewerSettings extView; | ||
101 | qtHelpWriteConfig(icon, name, path, ghns, QString(), true, extView); | ||||
99 | m_plugin->readConfig(); | 102 | m_plugin->readConfig(); | ||
100 | 103 | | |||
101 | QCOMPARE(m_plugin->qtHelpProviderLoaded().size(), 1); | 104 | QCOMPARE(m_plugin->qtHelpProviderLoaded().size(), 1); | ||
102 | QCOMPARE(m_plugin->qtHelpProviderLoaded().at(0)->fileName(), path.at(0)); | 105 | QCOMPARE(m_plugin->qtHelpProviderLoaded().at(0)->fileName(), path.at(0)); | ||
103 | QCOMPARE(m_plugin->qtHelpProviderLoaded().at(0)->name(), name.at(0)); | 106 | QCOMPARE(m_plugin->qtHelpProviderLoaded().at(0)->name(), name.at(0)); | ||
104 | QCOMPARE(m_plugin->qtHelpProviderLoaded().at(0)->iconName(), icon.at(0)); | 107 | QCOMPARE(m_plugin->qtHelpProviderLoaded().at(0)->iconName(), icon.at(0)); | ||
105 | } | 108 | } | ||
106 | 109 | | |||
107 | void TestQtHelpPlugin::testAddTwoDifferentValidProvider() | 110 | void TestQtHelpPlugin::testAddTwoDifferentValidProvider() | ||
108 | { | 111 | { | ||
109 | QStringList path, name, icon, ghns; | 112 | QStringList path, name, icon, ghns; | ||
110 | path << VALID1 << VALID2; | 113 | path << VALID1 << VALID2; | ||
111 | name << QStringLiteral("file1") << QStringLiteral("file2"); | 114 | name << QStringLiteral("file1") << QStringLiteral("file2"); | ||
112 | icon << QStringLiteral("myIcon") << QStringLiteral("myIcon"); | 115 | icon << QStringLiteral("myIcon") << QStringLiteral("myIcon"); | ||
113 | ghns << QStringLiteral("0") << QStringLiteral("0"); | 116 | ghns << QStringLiteral("0") << QStringLiteral("0"); | ||
114 | qtHelpWriteConfig(icon, name, path, ghns, QString(), true); | 117 | ExternalViewerSettings extView; | ||
118 | qtHelpWriteConfig(icon, name, path, ghns, QString(), true, extView); | ||||
115 | m_plugin->readConfig(); | 119 | m_plugin->readConfig(); | ||
116 | 120 | | |||
117 | QCOMPARE(m_plugin->qtHelpProviderLoaded().size(), 2); | 121 | QCOMPARE(m_plugin->qtHelpProviderLoaded().size(), 2); | ||
118 | // first provider | 122 | // first provider | ||
119 | QCOMPARE(m_plugin->qtHelpProviderLoaded().at(0)->fileName(), path.at(0)); | 123 | QCOMPARE(m_plugin->qtHelpProviderLoaded().at(0)->fileName(), path.at(0)); | ||
120 | QCOMPARE(m_plugin->qtHelpProviderLoaded().at(0)->name(), name.at(0)); | 124 | QCOMPARE(m_plugin->qtHelpProviderLoaded().at(0)->name(), name.at(0)); | ||
121 | QCOMPARE(m_plugin->qtHelpProviderLoaded().at(0)->iconName(), icon.at(0)); | 125 | QCOMPARE(m_plugin->qtHelpProviderLoaded().at(0)->iconName(), icon.at(0)); | ||
122 | // second provider | 126 | // second provider | ||
123 | QCOMPARE(m_plugin->qtHelpProviderLoaded().at(1)->fileName(), path.at(1)); | 127 | QCOMPARE(m_plugin->qtHelpProviderLoaded().at(1)->fileName(), path.at(1)); | ||
124 | QCOMPARE(m_plugin->qtHelpProviderLoaded().at(1)->name(), name.at(1)); | 128 | QCOMPARE(m_plugin->qtHelpProviderLoaded().at(1)->name(), name.at(1)); | ||
125 | QCOMPARE(m_plugin->qtHelpProviderLoaded().at(1)->iconName(), icon.at(1)); | 129 | QCOMPARE(m_plugin->qtHelpProviderLoaded().at(1)->iconName(), icon.at(1)); | ||
126 | } | 130 | } | ||
127 | 131 | | |||
128 | void TestQtHelpPlugin::testAddInvalidProvider() | 132 | void TestQtHelpPlugin::testAddInvalidProvider() | ||
129 | { | 133 | { | ||
130 | QStringList path, name, icon, ghns; | 134 | QStringList path, name, icon, ghns; | ||
131 | path << INVALID; | 135 | path << INVALID; | ||
132 | name << QStringLiteral("file1"); | 136 | name << QStringLiteral("file1"); | ||
133 | icon << QStringLiteral("myIcon"); | 137 | icon << QStringLiteral("myIcon"); | ||
134 | ghns << QStringLiteral("0"); | 138 | ghns << QStringLiteral("0"); | ||
135 | qtHelpWriteConfig(icon, name, path, ghns, QString(), true); | 139 | ExternalViewerSettings extView; | ||
140 | qtHelpWriteConfig(icon, name, path, ghns, QString(), true, extView); | ||||
136 | m_plugin->readConfig(); | 141 | m_plugin->readConfig(); | ||
137 | 142 | | |||
138 | QCOMPARE(m_plugin->qtHelpProviderLoaded().size(), 0); | 143 | QCOMPARE(m_plugin->qtHelpProviderLoaded().size(), 0); | ||
139 | } | 144 | } | ||
140 | 145 | | |||
141 | void TestQtHelpPlugin::testAddTwiceSameProvider() | 146 | void TestQtHelpPlugin::testAddTwiceSameProvider() | ||
142 | { | 147 | { | ||
143 | QStringList path, name, icon, ghns; | 148 | QStringList path, name, icon, ghns; | ||
144 | path << VALID1 << VALID1; | 149 | path << VALID1 << VALID1; | ||
145 | name << QStringLiteral("file1") << QStringLiteral("file2"); | 150 | name << QStringLiteral("file1") << QStringLiteral("file2"); | ||
146 | icon << QStringLiteral("myIcon") << QStringLiteral("myIcon"); | 151 | icon << QStringLiteral("myIcon") << QStringLiteral("myIcon"); | ||
147 | ghns << QStringLiteral("0") << QStringLiteral("0"); | 152 | ghns << QStringLiteral("0") << QStringLiteral("0"); | ||
148 | qtHelpWriteConfig(icon, name, path, ghns, QString(), true); | 153 | ExternalViewerSettings extView; | ||
154 | qtHelpWriteConfig(icon, name, path, ghns, QString(), true, extView); | ||||
149 | m_plugin->readConfig(); | 155 | m_plugin->readConfig(); | ||
150 | 156 | | |||
151 | QCOMPARE(m_plugin->qtHelpProviderLoaded().size(), 1); | 157 | QCOMPARE(m_plugin->qtHelpProviderLoaded().size(), 1); | ||
152 | } | 158 | } | ||
153 | 159 | | |||
154 | void TestQtHelpPlugin::testRemoveOneProvider() | 160 | void TestQtHelpPlugin::testRemoveOneProvider() | ||
155 | { | 161 | { | ||
156 | QStringList path, name, icon, ghns; | 162 | QStringList path, name, icon, ghns; | ||
157 | path << VALID1 << VALID2; | 163 | path << VALID1 << VALID2; | ||
158 | name << QStringLiteral("file1") << QStringLiteral("file2"); | 164 | name << QStringLiteral("file1") << QStringLiteral("file2"); | ||
159 | icon << QStringLiteral("myIcon") << QStringLiteral("myIcon"); | 165 | icon << QStringLiteral("myIcon") << QStringLiteral("myIcon"); | ||
160 | ghns << QStringLiteral("0") << QStringLiteral("0"); | 166 | ghns << QStringLiteral("0") << QStringLiteral("0"); | ||
161 | qtHelpWriteConfig(icon, name, path, ghns, QString(), true); | 167 | ExternalViewerSettings extView; | ||
168 | qtHelpWriteConfig(icon, name, path, ghns, QString(), true, extView); | ||||
162 | m_plugin->readConfig(); | 169 | m_plugin->readConfig(); | ||
163 | 170 | | |||
164 | QCOMPARE(m_plugin->qtHelpProviderLoaded().size(), 2); | 171 | QCOMPARE(m_plugin->qtHelpProviderLoaded().size(), 2); | ||
165 | // we remove the second provider | 172 | // we remove the second provider | ||
166 | QtHelpProvider *provider = m_plugin->qtHelpProviderLoaded().at(0); | 173 | QtHelpProvider *provider = m_plugin->qtHelpProviderLoaded().at(0); | ||
167 | path.removeAt(1); | 174 | path.removeAt(1); | ||
168 | name.removeAt(1); | 175 | name.removeAt(1); | ||
169 | icon.removeAt(1); | 176 | icon.removeAt(1); | ||
170 | ghns.removeAt(1); | 177 | ghns.removeAt(1); | ||
171 | qtHelpWriteConfig(icon, name, path, ghns, QString(), true); | 178 | qtHelpWriteConfig(icon, name, path, ghns, QString(), true, extView); | ||
172 | m_plugin->readConfig(); | 179 | m_plugin->readConfig(); | ||
173 | 180 | | |||
174 | QCOMPARE(m_plugin->qtHelpProviderLoaded().size(), 1); | 181 | QCOMPARE(m_plugin->qtHelpProviderLoaded().size(), 1); | ||
175 | QCOMPARE(m_plugin->qtHelpProviderLoaded().at(0), provider); | 182 | QCOMPARE(m_plugin->qtHelpProviderLoaded().at(0), provider); | ||
176 | } | 183 | } | ||
177 | 184 | | |||
178 | void TestQtHelpPlugin::testDeclarationLookup_Class() | 185 | void TestQtHelpPlugin::testDeclarationLookup_Class() | ||
179 | { | 186 | { | ||
▲ 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