| 57 | } |
| 58 | |
| 59 | void testProbeSide() |
| 60 | { |
| 61 | auto *toolManager = ObjectBroker::object<ToolManagerInterface *>(); |
| 62 | QVERIFY(toolManager); |
| 63 | |
| 64 | QSignalSpy availableToolsSpy(toolManager, &ToolManagerInterface::availableToolsResponse); |
| 65 | QSignalSpy toolEnabledSpy(toolManager, &ToolManagerInterface::toolEnabled); |
| 66 | QSignalSpy toolSelectedSpy(toolManager, &ToolManagerInterface::toolSelected); |
| 67 | QSignalSpy toolsForObjectSpy(toolManager, &ToolManagerInterface::toolsForObjectResponse); |
| 68 | |
| 69 | toolManager->requestAvailableTools(); |
| 70 | availableToolsSpy.wait(500); |
| 71 | QCOMPARE(availableToolsSpy.size(), 1); |
| 72 | const auto &list = availableToolsSpy[0][0].value<QVector<ToolData>>(); |
| 73 | QVERIFY(!list.isEmpty()); |
| 74 | |
| 75 | bool hasBasicTools = false; |
| 76 | const ToolData *actionInspector = nullptr; |
| 77 | const ToolData *guiSupport = nullptr; |
| 78 | for (const auto &tool : list) { |
| 79 | if (tool.id == "GammaRay::ObjectInspector") |
| 80 | hasBasicTools = true; |
| 81 | else if (tool.id == "gammaray_actioninspector") |
| 82 | actionInspector = &tool; |
| 83 | else if (tool.id == "gammaray_guisupport") |
| 84 | guiSupport = &tool; |
| 85 | } |
| 86 | QVERIFY(hasBasicTools); |
| 87 | QVERIFY(actionInspector); |
| 88 | QCOMPARE(actionInspector->enabled, false); /* coverity[UNINIT_CTOR] */ |
| 89 | QCOMPARE(actionInspector->hasUi, true); /* coverity[UNINIT_CTOR] */ |
| 90 | QVERIFY(guiSupport); |
| 91 | QCOMPARE(guiSupport->enabled, true); /* coverity[UNINIT_CTOR] */ |
| 92 | QCOMPARE(guiSupport->hasUi, false); /* coverity[UNINIT_CTOR] */ |
| 93 | // Create QAction to enable action inspector |
| 94 | QAction action("Test Action", this); |
| 95 | toolEnabledSpy.wait(1000); |
| 96 | QVERIFY(!toolEnabledSpy.isEmpty()); |
| 97 | QStringList enabledTools; |
| 98 | for (auto i = toolEnabledSpy.constBegin(); i != toolEnabledSpy.constEnd(); ++i) |
| 99 | enabledTools << i->first().toString(); |
| 100 | QVERIFY(enabledTools.contains("gammaray_actioninspector")); |
| 101 | |
| 102 | toolManager->selectObject(ObjectId(&action), QStringLiteral("gammaray_actioninspector")); |
| 103 | toolSelectedSpy.wait(50); |
| 104 | QCOMPARE(toolSelectedSpy.size(), 1); |
| 105 | QString selectedTool = toolSelectedSpy.constFirst().constFirst().toString(); |
| 106 | QCOMPARE(selectedTool, QStringLiteral("gammaray_actioninspector")); |
| 107 | |
| 108 | toolManager->requestToolsForObject(ObjectId(&action)); |
| 109 | toolsForObjectSpy.wait(50); |
| 110 | QCOMPARE(toolsForObjectSpy.size(), 1); |
| 111 | const ObjectId &actionId = toolsForObjectSpy.constFirst().constFirst().value<ObjectId>(); |
| 112 | QCOMPARE(actionId.asQObject(), &action); |
| 113 | const auto &actionTools = toolsForObjectSpy.constFirst().constLast().value<QVector<QString>>(); |
| 114 | QStringList supportedToolIds; |
| 115 | supportedToolIds.reserve(actionTools.size()); |
| 116 | for (const auto &tool : actionTools) |
nothing calls this directly
no test coverage detected