| 201 | } |
| 202 | |
| 203 | void testTreeRemoteModel() |
| 204 | { |
| 205 | QScopedPointer<QStandardItemModel> treeModel(new QStandardItemModel(this)); |
| 206 | auto e0 = new QStandardItem(QStringLiteral("entry0")); |
| 207 | e0->appendRow(new QStandardItem(QStringLiteral("entry00"))); |
| 208 | e0->appendRow(new QStandardItem(QStringLiteral("entry01"))); |
| 209 | treeModel->appendRow(e0); |
| 210 | auto e1 = new QStandardItem(QStringLiteral("entry1")); |
| 211 | e1->appendRow(new QStandardItem(QStringLiteral("entry10"))); |
| 212 | e1->appendRow(new QStandardItem(QStringLiteral("entry12"))); |
| 213 | treeModel->appendRow(e1); |
| 214 | |
| 215 | FakeRemoteModelServer server(QStringLiteral("com.kdab.GammaRay.UnitTest.TreeModel"), this); |
| 216 | server.setModel(treeModel.data()); |
| 217 | server.modelMonitored(true); |
| 218 | |
| 219 | FakeRemoteModel client(QStringLiteral("com.kdab.GammaRay.UnitTest.TreeModel"), this); |
| 220 | connect(&server, &FakeRemoteModelServer::message, &client, |
| 221 | &RemoteModel::newMessage); |
| 222 | connect(&client, &FakeRemoteModel::message, &server, |
| 223 | &RemoteModelServer::newRequest); |
| 224 | |
| 225 | QAbstractItemModelTester modelTest(&client); |
| 226 | QTRY_VERIFY(client.rowCount() == 2); |
| 227 | |
| 228 | QCOMPARE(client.rowCount(), 2); |
| 229 | QCOMPARE(client.hasChildren(), true); |
| 230 | |
| 231 | auto i1 = client.index(1, 0); |
| 232 | QVERIFY(waitForData(i1)); |
| 233 | QCOMPARE(i1.data().toString(), QStringLiteral("entry1")); |
| 234 | QCOMPARE(client.rowCount(i1), 2); |
| 235 | |
| 236 | auto i12 = client.index(1, 0, i1); |
| 237 | QVERIFY(waitForData(i12)); |
| 238 | QCOMPARE(i12.data().toString(), QStringLiteral("entry12")); |
| 239 | QCOMPARE(client.rowCount(i12), 0); |
| 240 | |
| 241 | e1->insertRow(1, new QStandardItem(QStringLiteral("entry11"))); |
| 242 | QTRY_VERIFY(client.rowCount(i1) == 3); |
| 243 | |
| 244 | QCOMPARE(client.rowCount(i1), 3); |
| 245 | auto i11 = client.index(1, 0, i1); |
| 246 | QVERIFY(waitForData(i11)); |
| 247 | QCOMPARE(i11.data().toString(), QStringLiteral("entry11")); |
| 248 | QCOMPARE(client.rowCount(i11), 0); |
| 249 | |
| 250 | const auto deleteMe = e1->takeRow(0); |
| 251 | qDeleteAll(deleteMe); |
| 252 | QTRY_VERIFY(client.rowCount(i1) == 2); |
| 253 | |
| 254 | QCOMPARE(client.rowCount(i1), 2); |
| 255 | i11 = client.index(0, 0, i1); |
| 256 | QVERIFY(waitForData(i11)); |
| 257 | QCOMPARE(i11.data().toString(), QStringLiteral("entry11")); |
| 258 | } |
| 259 | |
| 260 | // this should not make a difference if the above works, however it broke massively with Qt 5.4... |
nothing calls this directly
no test coverage detected