| 593 | } |
| 594 | |
| 595 | void BindingInspectorTest::testModelDataChanged() |
| 596 | { |
| 597 | MockObject obj1 { 53, true, 'x', 5.3, "Hello World" }; |
| 598 | |
| 599 | provider->data = { { |
| 600 | { &obj1, "a", &obj1, "b" }, |
| 601 | { &obj1, "a", &obj1, "c" }, |
| 602 | { &obj1, "a", &obj1, "d" }, |
| 603 | { &obj1, "b", &obj1, "e" }, |
| 604 | } }; |
| 605 | |
| 606 | bindingExtension->setQObject(&obj1); |
| 607 | QCOMPARE(bindingModel->rowCount(QModelIndex()), 2); |
| 608 | auto topLevelIndices = getSortedChildren(QModelIndex(), bindingModel); |
| 609 | QModelIndex obj1aIndex = topLevelIndices[0]; |
| 610 | QVERIFY(obj1aIndex.isValid()); |
| 611 | QCOMPARE(obj1aIndex.data().toString(), QStringLiteral("a")); |
| 612 | QCOMPARE(obj1aIndex.sibling(obj1aIndex.row(), BindingModel::ValueColumn).data().toInt(), 53); |
| 613 | QCOMPARE(obj1aIndex.sibling(obj1aIndex.row(), BindingModel::DepthColumn).data().toString(), QStringLiteral("2")); |
| 614 | QCOMPARE(bindingModel->rowCount(obj1aIndex), 3); |
| 615 | |
| 616 | auto obj1aChildren = getSortedChildren(obj1aIndex); |
| 617 | QModelIndex obj1dIndex = obj1aChildren[2]; |
| 618 | QVERIFY(obj1dIndex.isValid()); |
| 619 | QCOMPARE(obj1dIndex.data().toString(), QStringLiteral("d")); |
| 620 | QCOMPARE(obj1dIndex.sibling(obj1dIndex.row(), BindingModel::ValueColumn).data().toDouble(), 5.3); |
| 621 | QCOMPARE(obj1dIndex.sibling(obj1dIndex.row(), BindingModel::DepthColumn).data().toString(), QStringLiteral("0")); |
| 622 | QCOMPARE(bindingModel->rowCount(obj1dIndex), 0); |
| 623 | |
| 624 | QSignalSpy dataChangedSpy(bindingModel, &QAbstractItemModel::dataChanged); |
| 625 | QVERIFY(dataChangedSpy.isValid()); |
| 626 | |
| 627 | obj1.setD(3.1415926535897932); |
| 628 | obj1.setA(12); |
| 629 | |
| 630 | dataChangedSpy.wait(500); |
| 631 | QCOMPARE(dataChangedSpy.size(), 2); |
| 632 | QCOMPARE(dataChangedSpy.at(0).at(0).toModelIndex(), obj1aIndex.sibling(obj1aIndex.row(), BindingModel::ValueColumn)); |
| 633 | QCOMPARE(dataChangedSpy.at(0).at(1).toModelIndex(), obj1aIndex.sibling(obj1aIndex.row(), BindingModel::ValueColumn)); |
| 634 | QCOMPARE(dataChangedSpy.at(1).at(0).toModelIndex(), obj1dIndex.sibling(obj1dIndex.row(), BindingModel::ValueColumn)); |
| 635 | QCOMPARE(dataChangedSpy.at(1).at(1).toModelIndex(), obj1dIndex.sibling(obj1dIndex.row(), BindingModel::ValueColumn)); |
| 636 | |
| 637 | QCOMPARE(bindingModel->rowCount(obj1aIndex), 3); |
| 638 | QCOMPARE(obj1aIndex.sibling(obj1aIndex.row(), BindingModel::DepthColumn).data().toString(), QStringLiteral("2")); |
| 639 | QCOMPARE(obj1aIndex.sibling(obj1aIndex.row(), BindingModel::ValueColumn).data().toInt(), 12); |
| 640 | |
| 641 | QCOMPARE(obj1dIndex.sibling(obj1dIndex.row(), BindingModel::ValueColumn).data().toDouble(), 3.1415926535897932); |
| 642 | QCOMPARE(obj1dIndex.sibling(obj1dIndex.row(), BindingModel::DepthColumn).data().toString(), QStringLiteral("0")); |
| 643 | } |
| 644 | |
| 645 | void BindingInspectorTest::testModelAdditions() |
| 646 | { |
nothing calls this directly
no test coverage detected