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

Method testIntegration

tests/bindinginspectortest.cpp:917–1059  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

915}
916
917void BindingInspectorTest::testIntegration()
918{
919 createProbe();
920 QByteArray code =
921 "import QtQuick 2.0\n"
922 "Rectangle {\n"
923 " id: a\n"
924 " objectName: 'a'\n"
925 " property string labelText: \"Hello world!\"\n"
926 " implicitWidth: childrenRect.width\n"
927 " height: 200\n"
928 " Text {\n"
929 " id: t\n"
930 " objectName: 'text'\n"
931 " text: labelText\n"
932 " property int foo: width\n"
933 " anchors { left: parent.left; right: parent.right; bottom: parent.bottom; verticalCenter: parent.verticalCenter }\n"
934 " }\n"
935 "}";
936
937 QQmlEngine engine;
938 QQmlComponent c(&engine);
939 c.setData(code, QUrl());
940 QObject *rect = c.create();
941 QTest::qWait(30);
942 QVERIFY(rect);
943 QObject *text = rect->findChildren<QQuickText *>().at(0);
944
945 QAbstractItemModel *bindingModel = ObjectBroker::model(QStringLiteral("com.kdab.GammaRay.ObjectInspector.bindingModel"));
946 QVERIFY(bindingModel);
947 QAbstractItemModelTester modelTest(bindingModel);
948
949 Probe::instance()->selectObject(text);
950 QCOMPARE(bindingModel->rowCount(), 6);
951 auto topLevelIndices = getSortedChildren(QModelIndex(), bindingModel);
952 QModelIndex textBindingIndex = topLevelIndices[5];
953 QVERIFY(textBindingIndex.isValid());
954 QCOMPARE(textBindingIndex.data().toString(), QStringLiteral("t.text"));
955 QCOMPARE(textBindingIndex.sibling(textBindingIndex.row(), BindingModel::ValueColumn).data().toString(), QStringLiteral("Hello world!"));
956 QCOMPARE(textBindingIndex.sibling(textBindingIndex.row(), BindingModel::DepthColumn).data().toString(), QStringLiteral("1"));
957 QCOMPARE(bindingModel->rowCount(textBindingIndex), 1);
958
959 QModelIndex labelTextIndex = bindingModel->index(0, 0, textBindingIndex);
960 QVERIFY(labelTextIndex.isValid());
961 QCOMPARE(labelTextIndex.data().toString(), QStringLiteral("a.labelText"));
962 QCOMPARE(labelTextIndex.sibling(labelTextIndex.row(), BindingModel::ValueColumn).data().toString(), QStringLiteral("Hello world!"));
963 QCOMPARE(labelTextIndex.sibling(labelTextIndex.row(), BindingModel::DepthColumn).data().toString(), QStringLiteral("0"));
964 QCOMPARE(bindingModel->rowCount(labelTextIndex), 0);
965
966 QModelIndex fooIndex = topLevelIndices[4];
967 QVERIFY(fooIndex.isValid());
968 QCOMPARE(fooIndex.data().toString(), QStringLiteral("t.foo"));
969 QCOMPARE(fooIndex.sibling(fooIndex.row(), BindingModel::DepthColumn).data().toString(), QString(QChar(0x221e)));
970 QCOMPARE(bindingModel->rowCount(fooIndex), 1);
971
972 QModelIndex tWidthIndex = bindingModel->index(0, 0, fooIndex);
973 QVERIFY(tWidthIndex.isValid());
974 QCOMPARE(tWidthIndex.data().toString(), QStringLiteral("t.width"));

Callers

nothing calls this directly

Calls 12

getSortedChildrenFunction · 0.85
rowMethod · 0.80
QUrlClass · 0.50
QModelIndexClass · 0.50
QStringClass · 0.50
setDataMethod · 0.45
createMethod · 0.45
selectObjectMethod · 0.45
rowCountMethod · 0.45
isValidMethod · 0.45
dataMethod · 0.45
indexMethod · 0.45

Tested by

no test coverage detected