MCPcopy Create free account
hub / github.com/KDAB/GammaRay / testProblemModel

Method testProblemModel

tests/problemreportertest.cpp:245–279  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

243 }
244
245 void testProblemModel()
246 {
247 auto model = ObjectBroker::model(QStringLiteral("com.kdab.GammaRay.ProblemModel"));
248 auto rowCount = model->rowCount();
249
250 Problem p1;
251 p1.problemId = QStringLiteral("9skjlksdjb");
252 p1.description = QStringLiteral("Lorem ipsum dolor sit amet.");
253 p1.severity = Problem::Warning;
254 SourceLocation l1 = SourceLocation::fromOneBased(QUrl("../main.qml"), 101, 42);
255 SourceLocation l2 = SourceLocation::fromOneBased(QUrl("A.qml"), 43, 21);
256 p1.object = ObjectId(this);
257 p1.locations << l1 << l2;
258 ProblemCollector::addProblem(p1);
259
260 Problem p2;
261 p2.problemId = QStringLiteral("asdf");
262 ProblemCollector::addProblem(p2);
263
264 QCOMPARE(model->rowCount(), rowCount + 2);
265
266 auto index = model->index(rowCount, 0, QModelIndex());
267 QCOMPARE(index.data(Qt::DisplayRole).toString(), QStringLiteral("Lorem ipsum dolor sit amet."));
268 QCOMPARE(index.sibling(rowCount, 1).data(Qt::DisplayRole).toString(), l1.displayString());
269 QCOMPARE(index.data(ObjectModel::ObjectIdRole).value<ObjectId>(), ObjectId(this));
270 QCOMPARE(index.data(ProblemModelRoles::SourceLocationRole).value<QVector<SourceLocation>>(), p1.locations);
271 QCOMPARE(index.data(ProblemModelRoles::SeverityRole).value<int>(), static_cast<int>(Problem::Warning));
272 QCOMPARE(index.data(ProblemModelRoles::ProblemIdRole).toString(), QStringLiteral("9skjlksdjb"));
273
274
275 ProblemCollector::removeProblem(QStringLiteral("9skjlksdjb"));
276 QCOMPARE(model->rowCount(), rowCount + 1);
277 ProblemCollector::removeProblem(QStringLiteral("asdf"));
278 QCOMPARE(model->rowCount(), rowCount);
279 }
280
281#ifdef QT_QML_LIB
282 static void testBindingLoopChecker()

Callers

nothing calls this directly

Calls 7

QUrlClass · 0.50
ObjectIdClass · 0.50
QModelIndexClass · 0.50
rowCountMethod · 0.45
indexMethod · 0.45
dataMethod · 0.45
displayStringMethod · 0.45

Tested by

no test coverage detected