| 22 | using namespace GammaRay; |
| 23 | |
| 24 | class QuickTextureTest : public BaseQuickTest |
| 25 | { |
| 26 | Q_OBJECT |
| 27 | private slots: |
| 28 | void testTextureGrab() |
| 29 | { |
| 30 | if (!showSource("qrc:/manual/textures.qml")) |
| 31 | return; |
| 32 | |
| 33 | auto remoteView = ObjectBroker::object<RemoteViewInterface *>("com.kdab.GammaRay.ObjectInspector.texture.remoteView"); |
| 34 | QVERIFY(remoteView); |
| 35 | QSignalSpy frameSpy(remoteView, &RemoteViewInterface::frameUpdated); |
| 36 | QVERIFY(frameSpy.isValid()); |
| 37 | remoteView->setViewActive(true); |
| 38 | |
| 39 | auto imageItem = view()->rootObject(); |
| 40 | QVERIFY(imageItem); |
| 41 | QCOMPARE(imageItem->metaObject()->className(), "QQuickImage"); |
| 42 | Probe::instance()->selectObject(imageItem, QPoint()); |
| 43 | |
| 44 | QVERIFY(frameSpy.wait() || frameSpy.size() >= 1); |
| 45 | const auto last = frameSpy.size() - 1; |
| 46 | const auto frame = frameSpy.at(last).at(0).value<RemoteViewFrame>(); |
| 47 | QCOMPARE(frame.viewRect(), QRectF(0, 0, 360, 360)); |
| 48 | QCOMPARE(frame.image().pixel(358, 0), QColor(Qt::red).rgb()); |
| 49 | QCOMPARE(frame.image().pixel(119, 0), QColor(Qt::green).rgb()); |
| 50 | QCOMPARE(frame.image().pixel(239, 0), QColor(Qt::blue).rgb()); |
| 51 | } |
| 52 | |
| 53 | void testDFGrab() |
| 54 | { |
| 55 | if (!showSource("qrc:/manual/textures.qml")) |
| 56 | return; |
| 57 | |
| 58 | auto remoteView = ObjectBroker::object<RemoteViewInterface *>("com.kdab.GammaRay.ObjectInspector.texture.remoteView"); |
| 59 | QVERIFY(remoteView); |
| 60 | QSignalSpy frameSpy(remoteView, &RemoteViewInterface::frameUpdated); |
| 61 | QVERIFY(frameSpy.isValid()); |
| 62 | remoteView->setViewActive(true); |
| 63 | |
| 64 | QQuickItem *textItem = nullptr; |
| 65 | foreach (auto item, view()->rootObject()->findChildren<QQuickItem *>()) { |
| 66 | if (strcmp(item->metaObject()->className(), "QQuickText") == 0) |
| 67 | textItem = item; |
| 68 | } |
| 69 | QVERIFY(textItem); |
| 70 | Probe::instance()->selectObject(textItem, QPoint()); |
| 71 | |
| 72 | QVERIFY(frameSpy.wait() || frameSpy.size() >= 1); |
| 73 | const auto last = frameSpy.size() - 1; |
| 74 | const auto frame = frameSpy.at(last).at(0).value<RemoteViewFrame>(); |
| 75 | QVERIFY(frame.viewRect().height() > 0); |
| 76 | QVERIFY(frame.viewRect().width() > 0); |
| 77 | } |
| 78 | |
| 79 | void testShaderEffectSourceGrab() |
| 80 | { |
| 81 | if (!showSource("qrc:/manual/shadereffect6.qml")) { |
nothing calls this directly
no test coverage detected