diff options
author | Ivan Komissarov <ABBAPOH@gmail.com> | 2019-05-16 23:44:02 +0200 |
---|---|---|
committer | Ivan Komissarov <ABBAPOH@gmail.com> | 2019-06-27 10:18:09 +0000 |
commit | 0e5050b7f75c90d406c5292ddf8d43b6a5b555c8 (patch) | |
tree | ef6fa7afb3c6293ccf2919d0653d407df3afe3dd /tests | |
parent | bb4622ac70ab43bb1e8f1930fc8430a3ec00eafb (diff) |
Add support for gRPC to the protobuf.cpp module
This implements support for the gRPC framework: https://www.grpc.io
Change-Id: Ia85461b9618e73827114c137fce8615e5a8139e3
Reviewed-by: Qbs CI Bot <travis-bot@weickelt.de>
Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
Diffstat (limited to 'tests')
-rw-r--r-- | tests/auto/blackbox/testdata/grpc/grpc.cpp | 49 | ||||
-rw-r--r-- | tests/auto/blackbox/testdata/grpc/grpc.proto | 15 | ||||
-rw-r--r-- | tests/auto/blackbox/testdata/grpc/grpc_cpp.qbs | 26 | ||||
-rw-r--r-- | tests/auto/blackbox/tst_blackbox.cpp | 23 | ||||
-rw-r--r-- | tests/auto/blackbox/tst_blackbox.h | 2 |
5 files changed, 115 insertions, 0 deletions
diff --git a/tests/auto/blackbox/testdata/grpc/grpc.cpp b/tests/auto/blackbox/testdata/grpc/grpc.cpp new file mode 100644 index 000000000..81995601d --- /dev/null +++ b/tests/auto/blackbox/testdata/grpc/grpc.cpp @@ -0,0 +1,49 @@ +/**************************************************************************** +** +** Copyright (C) 2019 Ivan Komissarov +** Contact: abbapoh@gmail.com +** +** This file is part of Qbs. +** +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms and +** conditions see http://www.qt.io/terms-conditions. For further information +** use the contact form at http://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 or version 3 as published by the Free +** Software Foundation and appearing in the file LICENSE.LGPLv21 and +** LICENSE.LGPLv3 included in the packaging of this file. Please review the +** following information to ensure the GNU Lesser General Public License +** requirements will be met: https://www.gnu.org/licenses/lgpl.html and +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, The Qt Company gives you certain additional +** rights. These rights are described in The Qt Company LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +****************************************************************************/ + +#include <grpc.grpc.pb.h> + +class ServiceImpl final : public Qbs::Grpc::Service +{ + grpc::Status doWork( + grpc::ServerContext* context, + const Qbs::Request* request, + Qbs::Response* reply) override + { + (void)context; + reply->set_name(request->name()); + return grpc::Status::OK; + } +}; + +int main(int, char**) +{ + return 0; +} diff --git a/tests/auto/blackbox/testdata/grpc/grpc.proto b/tests/auto/blackbox/testdata/grpc/grpc.proto new file mode 100644 index 000000000..631006bad --- /dev/null +++ b/tests/auto/blackbox/testdata/grpc/grpc.proto @@ -0,0 +1,15 @@ +syntax = "proto3"; + +package Qbs; + +message Request { + string name = 1; +} + +message Response { + string name = 1; +} + +service Grpc { + rpc doWork(Request) returns (Response) {} +} diff --git a/tests/auto/blackbox/testdata/grpc/grpc_cpp.qbs b/tests/auto/blackbox/testdata/grpc/grpc_cpp.qbs new file mode 100644 index 000000000..8ee3dd9c9 --- /dev/null +++ b/tests/auto/blackbox/testdata/grpc/grpc_cpp.qbs @@ -0,0 +1,26 @@ +import qbs + +CppApplication { + name: "grpc_cpp" + consoleApplication: true + condition: hasDependencies + + Depends { name: "cpp" } + cpp.cxxLanguageVersion: "c++11" + cpp.warningLevel: "none" + + Depends { name: "protobuf.cpp"; required: false } + protobuf.cpp.useGrpc: true + + property bool hasDependencies: { + console.info("has grpc: " + protobuf.cpp.present); + return protobuf.cpp.present; + } + + files: "grpc.cpp" + + Group { + files: "grpc.proto" + fileTags: "protobuf.grpc" + } +} diff --git a/tests/auto/blackbox/tst_blackbox.cpp b/tests/auto/blackbox/tst_blackbox.cpp index 534922112..f87889155 100644 --- a/tests/auto/blackbox/tst_blackbox.cpp +++ b/tests/auto/blackbox/tst_blackbox.cpp @@ -6823,6 +6823,29 @@ void TestBlackbox::groupsInModules() QCOMPARE(output.readAll().trimmed(), QByteArray("diamond")); } +void TestBlackbox::grpc_data() +{ + QTest::addColumn<QString>("projectFile"); + QTest::newRow("cpp") << QString("grpc_cpp.qbs"); +} + +void TestBlackbox::grpc() +{ + QDir::setCurrent(testDataDir + "/grpc"); + QFETCH(QString, projectFile); + rmDirR(relativeBuildDir()); + QbsRunParameters resolveParams("resolve", QStringList{"-f", projectFile}); + QCOMPARE(runQbs(resolveParams), 0); + const bool withGrpc = m_qbsStdout.contains("has grpc: true"); + const bool withoutGrpc = m_qbsStdout.contains("has grpc: false"); + QVERIFY2(withGrpc || withoutGrpc, m_qbsStdout.constData()); + if (withoutGrpc) + QSKIP("grpc module not present"); + + QbsRunParameters runParams; + QCOMPARE(runQbs(runParams), 0); +} + void TestBlackbox::ico() { QDir::setCurrent(testDataDir + "/ico"); diff --git a/tests/auto/blackbox/tst_blackbox.h b/tests/auto/blackbox/tst_blackbox.h index e8c456b1e..0a14c418c 100644 --- a/tests/auto/blackbox/tst_blackbox.h +++ b/tests/auto/blackbox/tst_blackbox.h @@ -119,6 +119,8 @@ private slots: void generator(); void generator_data(); void groupsInModules(); + void grpc_data(); + void grpc(); void ico(); void importAssignment(); void importChangeTracking(); |