| 45 | } |
| 46 | |
| 47 | void testRun() |
| 48 | { |
| 49 | CMakeServer server(nullptr); |
| 50 | QSignalSpy spyConnected(&server, &CMakeServer::connected); |
| 51 | QVERIFY(server.isServerAvailable() || spyConnected.wait()); |
| 52 | |
| 53 | QSignalSpy spy(&server, &CMakeServer::response); |
| 54 | QJsonObject codeModel; |
| 55 | int errors = 0; |
| 56 | connect(&server, &CMakeServer::response, this, [&errors, &codeModel, &server](const QJsonObject &response) { |
| 57 | if (response.value(QStringLiteral("type")) == QLatin1String("reply")) { |
| 58 | if (response.value(QStringLiteral("inReplyTo")) == QLatin1String("configure")) |
| 59 | server.compute(); |
| 60 | else if (response.value(QStringLiteral("inReplyTo")) == QLatin1String("compute")) |
| 61 | server.codemodel(); |
| 62 | else if(response.value(QStringLiteral("inReplyTo")) == QLatin1String("codemodel")) |
| 63 | codeModel = response; |
| 64 | } else if(response.value(QStringLiteral("type")) == QLatin1String("error")) { |
| 65 | ++errors; |
| 66 | } |
| 67 | }); |
| 68 | |
| 69 | const QString name = QStringLiteral("single_subdirectory"); |
| 70 | const auto paths = projectPaths(name); |
| 71 | const QString builddir = QStringLiteral(CMAKE_TESTS_BINARY_DIR "/cmake-server-test-builddir/") + name; |
| 72 | QVERIFY(QDir(builddir).removeRecursively()); |
| 73 | QVERIFY(QDir(builddir).mkpath(builddir)); |
| 74 | |
| 75 | QVERIFY(spy.wait()); |
| 76 | server.handshake(paths.sourceDir, Path(builddir)); |
| 77 | QVERIFY(spy.wait()); |
| 78 | server.configure({}); |
| 79 | while(codeModel.isEmpty()) |
| 80 | QVERIFY(spy.wait()); |
| 81 | QCOMPARE(errors, 0); |
| 82 | QVERIFY(!codeModel.isEmpty()); |
| 83 | qDebug() << "codemodel" << codeModel; |
| 84 | } |
| 85 | }; |
| 86 | |
| 87 | QTEST_MAIN( CMakeServerTest ) |
nothing calls this directly
no test coverage detected