MCPcopy Create free account
hub / github.com/KDE/kdevelop / testPathGrouping

Method testPathGrouping

kdevplatform/shell/tests/test_problemmodel.cpp:161–262  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

159}
160
161void TestProblemModel::testPathGrouping()
162{
163 m_model->setGrouping(PathGrouping);
164 m_model->setSeverity(IProblem::Hint);
165 QCOMPARE(m_model->rowCount(), 0);
166
167 // Check if setting problems works
168 m_model->setProblems(m_problems);
169 QCOMPARE(m_model->rowCount(), 3);
170
171 for (int i = 0; i < m_model->rowCount(); i++) {
172 QVERIFY(checkLabel(i, QModelIndex(), m_problems[i]->finalLocation().document.str()));
173
174 QModelIndex idx = m_model->index(i, 0);
175 QVERIFY(idx.isValid());
176 QVERIFY(checkIsSame(0, idx, m_problems[i]));
177 }
178
179 // Check if displaying various data parts works
180 {
181 QModelIndex idx = m_model->index(0, 0);
182 QVERIFY(idx.isValid());
183 QVERIFY(checkDisplay(0, idx, m_problems[0]));
184 }
185
186 // Check if clearing works
187 m_model->clearProblems();
188 QCOMPARE(m_model->rowCount(), 0);
189
190 // Check if add problems works
191 int c = 0;
192 for (const IProblem::Ptr& p : std::as_const(m_problems)) {
193 m_model->addProblem(p);
194 c++;
195
196 QCOMPARE(m_model->rowCount(), c);
197 }
198
199 for (int i = 0; i < m_model->rowCount(); i++) {
200 QVERIFY(checkLabel(i, QModelIndex(), m_problems[i]->finalLocation().document.str()));
201
202 QModelIndex idx = m_model->index(i, 0);
203 QVERIFY(idx.isValid());
204 QVERIFY(checkIsSame(0, idx, m_problems[i]));
205 }
206
207 // Check if filtering works
208 // old-style setSeverity
209 // Error filtering
210 m_model->setSeverity(IProblem::Error);
211 QCOMPARE(m_model->rowCount(), 1);
212 QVERIFY(checkPathGroup(0, m_problems[0]));
213
214 // Warning filtering
215 m_model->setSeverity(IProblem::Warning);
216 QCOMPARE(m_model->rowCount(), 2);
217 QVERIFY(checkPathGroup(0, m_problems[0]));
218 QVERIFY(checkPathGroup(1, m_problems[1]));

Callers

nothing calls this directly

Calls 12

strMethod · 0.80
QModelIndexClass · 0.50
setGroupingMethod · 0.45
setSeverityMethod · 0.45
rowCountMethod · 0.45
setProblemsMethod · 0.45
finalLocationMethod · 0.45
indexMethod · 0.45
isValidMethod · 0.45
clearProblemsMethod · 0.45
addProblemMethod · 0.45
setSeveritiesMethod · 0.45

Tested by

no test coverage detected