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

Method testJSValue

tests/qmlsupporttest.cpp:126–159  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

124 }
125
126 void testJSValue()
127 {
128 QQmlEngine engine;
129 QQmlComponent component(&engine);
130 component.setData(
131 "import QtQuick 2.0\nRectangle { property var a1: []; property var a2: [\"hello\", \"world\"] }",
132 QUrl());
133 auto obj = component.create();
134 QVERIFY2(obj, qPrintable(component.errorString()));
135
136 auto adaptor = PropertyAdaptorFactory::create(obj, this);
137 QVERIFY(adaptor);
138
139 auto idx = indexOfProperty(adaptor, "a1");
140 QVERIFY(idx >= 0);
141
142 auto data = adaptor->propertyData(idx);
143 auto jsValueAdaptor = PropertyAdaptorFactory::create(data.value(), this);
144 QVERIFY(jsValueAdaptor);
145 QCOMPARE(jsValueAdaptor->count(), 0);
146
147 idx = indexOfProperty(adaptor, "a2");
148 QVERIFY(idx >= 0);
149
150 data = adaptor->propertyData(idx);
151 jsValueAdaptor = PropertyAdaptorFactory::create(data.value(), this);
152 QVERIFY(jsValueAdaptor);
153 QCOMPARE(jsValueAdaptor->count(), 2);
154 data = jsValueAdaptor->propertyData(1);
155 QCOMPARE(data.name(), QStringLiteral("1"));
156 QCOMPARE(data.value(), QVariant("world"));
157
158 delete obj;
159 }
160
161 void testContextProperty()
162 {

Callers

nothing calls this directly

Calls 9

QUrlClass · 0.50
QVariantClass · 0.50
setDataMethod · 0.45
createMethod · 0.45
errorStringMethod · 0.45
propertyDataMethod · 0.45
valueMethod · 0.45
countMethod · 0.45
nameMethod · 0.45

Tested by

no test coverage detected