Browse Source

Split test into protobuf and grpc parts

- Remove unused main files in tests
- Remove unecessary test headers
Viktor Kopp 6 years ago
parent
commit
8cc633cb96
47 changed files with 322 additions and 350 deletions
  1. 2 224
      tests/CMakeLists.txt
  2. 0 40
      tests/clienttest.h
  3. 0 32
      tests/main.cpp
  4. 0 40
      tests/servertest.h
  5. 80 0
      tests/test_grpc/CMakeLists.txt
  6. 11 8
      tests/test_grpc/clienttest.cpp
  7. 0 0
      tests/test_grpc/echoserver/CMakeLists.txt
  8. 0 0
      tests/test_grpc/echoserver/main.cpp
  9. 0 0
      tests/test_grpc/echoserver/testserver/.gitignore
  10. 0 0
      tests/test_grpc/echoserver/testserver/globalenums.grpc.pb.cc
  11. 0 0
      tests/test_grpc/echoserver/testserver/globalenums.grpc.pb.h
  12. 0 0
      tests/test_grpc/echoserver/testserver/globalenums.pb.cc
  13. 0 0
      tests/test_grpc/echoserver/testserver/globalenums.pb.h
  14. 0 0
      tests/test_grpc/echoserver/testserver/globalenums.proto
  15. 0 0
      tests/test_grpc/echoserver/testserver/globalenumssamenamespace.grpc.pb.cc
  16. 0 0
      tests/test_grpc/echoserver/testserver/globalenumssamenamespace.grpc.pb.h
  17. 0 0
      tests/test_grpc/echoserver/testserver/globalenumssamenamespace.pb.cc
  18. 0 0
      tests/test_grpc/echoserver/testserver/globalenumssamenamespace.pb.h
  19. 0 0
      tests/test_grpc/echoserver/testserver/globalenumssamenamespace.proto
  20. 0 0
      tests/test_grpc/echoserver/testserver/main.cpp
  21. 0 0
      tests/test_grpc/echoserver/testserver/simpletest.grpc.pb.cc
  22. 0 0
      tests/test_grpc/echoserver/testserver/simpletest.grpc.pb.h
  23. 0 0
      tests/test_grpc/echoserver/testserver/simpletest.pb.cc
  24. 0 0
      tests/test_grpc/echoserver/testserver/simpletest.pb.h
  25. 0 0
      tests/test_grpc/echoserver/testserver/simpletest.proto
  26. 0 0
      tests/test_grpc/echoserver/testserver/testserver.pro
  27. 0 0
      tests/test_grpc/echoserver/testserver/testservice.grpc.pb.cc
  28. 0 0
      tests/test_grpc/echoserver/testserver/testservice.grpc.pb.h
  29. 0 0
      tests/test_grpc/echoserver/testserver/testservice.pb.cc
  30. 0 0
      tests/test_grpc/echoserver/testserver/testservice.pb.h
  31. 0 0
      tests/test_grpc/echoserver/testserver/testservice.proto
  32. 8 0
      tests/test_grpc/proto/simpletest.proto
  33. 0 0
      tests/test_grpc/proto/testservice.proto
  34. 4 6
      tests/test_grpc/servertest.cpp
  35. 217 0
      tests/test_protobuf/CMakeLists.txt
  36. 0 0
      tests/test_protobuf/deserializationtest.cpp
  37. 0 0
      tests/test_protobuf/deserializationtest.h
  38. 0 0
      tests/test_protobuf/proto/externalpackagetest.proto
  39. 0 0
      tests/test_protobuf/proto/globalenums.proto
  40. 0 0
      tests/test_protobuf/proto/globalenumssamenamespace.proto
  41. 0 0
      tests/test_protobuf/proto/nestedmessages.proto
  42. 0 0
      tests/test_protobuf/proto/simpletest.proto
  43. 0 0
      tests/test_protobuf/serializationcomplexmessagemap.cpp
  44. 0 0
      tests/test_protobuf/serializationtest.cpp
  45. 0 0
      tests/test_protobuf/serializationtest.h
  46. 0 0
      tests/test_protobuf/simpletest.cpp
  47. 0 0
      tests/test_protobuf/simpletest.h

+ 2 - 224
tests/CMakeLists.txt

@@ -1,224 +1,2 @@
-set(PROTO_FILES_DIR ${CMAKE_CURRENT_SOURCE_DIR}/proto/)
-set(GENERATED_SOURCES_DIR ${CMAKE_CURRENT_BINARY_DIR}/generated)
-
-file(MAKE_DIRECTORY ${GENERATED_SOURCES_DIR})
-file(GLOB PROTO_FILES ABSOLUTE ${CMAKE_CURRENT_SOURCE_DIR}/proto/*.proto)
-## test sources generation
-if(WIN32)
-    #Needs to set path to protobuf libraries
-    set(PROTOBUF_INSTALATION_PATH "")
-    set(Protobuf_PROTOC_EXECUTABLE ${PROTOBUF_INSTALATION_PATH}/bin/protoc.exe)
-endif()
-
-set(test_sources_generation "test_generation")
-add_custom_target(${test_sources_generation})
-add_custom_command(TARGET ${test_sources_generation}
-        COMMAND ${Protobuf_PROTOC_EXECUTABLE} --${PROJECT_NAME}_opt=out=${GENERATED_SOURCES_DIR} --plugin=protoc-gen-${PROJECT_NAME}=$<TARGET_FILE:${PROJECT_NAME}> --qtprotobuf_out=${GENERATED_SOURCES_DIR} -I=${PROTO_FILES_DIR} ${PROTO_FILES}
-        WORKING_DIRECTORY ${PROTO_FILES_DIR}
-        DEPENDS ${PROTO_FILES}
-        COMMENT "Generating test headers"
-)
-add_dependencies(${test_sources_generation} ${PROJECT_NAME})
-
-## test sources build
-# policy enables automoc for generated files
-if(${CMAKE_VERSION} VERSION_GREATER "3.10.0")
-    cmake_policy(SET CMP0071 NEW)
-endif()
-
-set(CMAKE_INCLUDE_CURRENT_DIR ON)
-set(CMAKE_AUTOMOC ON)
-set(CMAKE_AUTORCC ON)
-
-if(Qt5_POSITION_INDEPENDENT_CODE)
-    set(CMAKE_POSITION_INDEPENDENT_CODE ON)
-endif()
-
-set(EXPECTED_GENERATED_HEADERS
-    complexmessage.h
-    externalcomplexmessage.h
-    globalenums.h
-    repeatedbytesmessage.h
-    repeatedcomplexmessage.h
-    repeateddoublemessage.h
-    repeatedexternalcomplexmessage.h
-    repeatedfixedint64message.h
-    repeatedfixedintmessage.h
-    repeatedfloatmessage.h
-    repeatedint64message.h
-    repeatedintmessage.h
-    repeatedsfixedint64message.h
-    repeatedsfixedintmessage.h
-    repeatedsint64message.h
-    repeatedsintmessage.h
-    repeatedstringmessage.h
-    repeateduint64message.h
-    repeateduintmessage.h
-    simpleboolmessage.h
-    simplebytesmessage.h
-    simpledoublemessage.h
-    simpleenumlistmessage.h
-    simpleenummessage.h
-    simpleexternalenummessage.h
-    simpleexternalmessage.h
-    simplefileenummessage.h
-    simplefixed32complexmessagemapmessage.h
-    simplefixed32int32mapmessage.h
-    simplefixed32int64mapmessage.h
-    simplefixed32sint32mapmessage.h
-    simplefixed32sint64mapmessage.h
-    simplefixed32stringmapmessage.h
-    simplefixed32uint32mapmessage.h
-    simplefixed32uint64mapmessage.h
-    simplefixed64complexmessagemapmessage.h
-    simplefixed64int32mapmessage.h
-    simplefixed64int64mapmessage.h
-    simplefixed64sint32mapmessage.h
-    simplefixed64sint64mapmessage.h
-    simplefixed64stringmapmessage.h
-    simplefixed64uint32mapmessage.h
-    simplefixed64uint64mapmessage.h
-    simplefixedint32message.h
-    simplefixedint64message.h
-    simplefloatmessage.h
-    simpleint32complexmessagemapmessage.h
-    simpleint32int32mapmessage.h
-    simpleint32int64mapmessage.h
-    simpleint32sint32mapmessage.h
-    simpleint32sint64mapmessage.h
-    simpleint32stringmapmessage.h
-    simpleint32uint32mapmessage.h
-    simpleint32uint64mapmessage.h
-    simpleint64complexmessagemapmessage.h
-    simpleint64int32mapmessage.h
-    simpleint64int64mapmessage.h
-    simpleint64message.h
-    simpleint64sint32mapmessage.h
-    simpleint64sint64mapmessage.h
-    simpleint64stringmapmessage.h
-    simpleint64uint32mapmessage.h
-    simpleint64uint64mapmessage.h
-    simpleintmessage.h
-    simplesfixed32complexmessagemapmessage.h
-    simplesfixed32int32mapmessage.h
-    simplesfixed32int64mapmessage.h
-    simplesfixed32sint32mapmessage.h
-    simplesfixed32sint64mapmessage.h
-    simplesfixed32stringmapmessage.h
-    simplesfixed32uint32mapmessage.h
-    simplesfixed32uint64mapmessage.h
-    simplesfixed64complexmessagemapmessage.h
-    simplesfixed64int32mapmessage.h
-    simplesfixed64int64mapmessage.h
-    simplesfixed64sint32mapmessage.h
-    simplesfixed64sint64mapmessage.h
-    simplesfixed64stringmapmessage.h
-    simplesfixed64uint32mapmessage.h
-    simplesfixed64uint64mapmessage.h
-    simplesfixedint32message.h
-    simplesfixedint64message.h
-    simplesint32complexmessagemapmessage.h
-    simplesint32int32mapmessage.h
-    simplesint32int64mapmessage.h
-    simplesint32sint32mapmessage.h
-    simplesint32sint64mapmessage.h
-    simplesint32stringmapmessage.h
-    simplesint32uint32mapmessage.h
-    simplesint32uint64mapmessage.h
-    simplesint64complexmessagemapmessage.h
-    simplesint64int32mapmessage.h
-    simplesint64int64mapmessage.h
-    simplesint64message.h
-    simplesint64sint32mapmessage.h
-    simplesint64sint64mapmessage.h
-    simplesint64stringmapmessage.h
-    simplesint64uint32mapmessage.h
-    simplesint64uint64mapmessage.h
-    simplesintmessage.h
-    simplestringcomplexmessagemapmessage.h
-    simplestringint32mapmessage.h
-    simplestringint64mapmessage.h
-    simplestringmessage.h
-    simplestringsint32mapmessage.h
-    simplestringsint64mapmessage.h
-    simplestringstringmapmessage.h
-    simplestringuint32mapmessage.h
-    simplestringuint64mapmessage.h
-    simpleuint32complexmessagemapmessage.h
-    simpleuint32int32mapmessage.h
-    simpleuint32int64mapmessage.h
-    simpleuint32sint32mapmessage.h
-    simpleuint32sint64mapmessage.h
-    simpleuint32stringmapmessage.h
-    simpleuint32uint32mapmessage.h
-    simpleuint32uint64mapmessage.h
-    simpleuint64complexmessagemapmessage.h
-    simpleuint64int32mapmessage.h
-    simpleuint64int64mapmessage.h
-    simpleuint64message.h
-    simpleuint64sint32mapmessage.h
-    simpleuint64sint64mapmessage.h
-    simpleuint64stringmapmessage.h
-    simpleuint64uint32mapmessage.h
-    simpleuint64uint64mapmessage.h
-    simpleuintmessage.h
-    stepchildenummessage.h
-    testserviceclient.h
-    testserviceserver.h
-)
-
-foreach(EXPECTED_GENERATED_HEADER ${EXPECTED_GENERATED_HEADERS})
-    get_filename_component(GENERATED_HEADER_BASENAME ${EXPECTED_GENERATED_HEADER} NAME_WE)
-
-    list(APPEND GENERATED_SOURCES ${GENERATED_SOURCES_DIR}/${GENERATED_HEADER_BASENAME}.cpp)
-    list(APPEND GENERATED_HEADERS ${GENERATED_SOURCES_DIR}/${GENERATED_HEADER_BASENAME}.h)
-
-    set_property(SOURCE ${GENERATED_SOURCES_DIR}/${GENERATED_HEADER_BASENAME}.cpp PROPERTY SKIP_AUTOMOC ON)
-endforeach(EXPECTED_GENERATED_HEADER)
-
-qt5_wrap_cpp(MOC_SOURCES ${GENERATED_HEADERS})
-list(APPEND GENERATED_SOURCES ${MOC_SOURCES})
-
-# TODO: so far the following cpp files are not generated 
-list(REMOVE_ITEM GENERATED_SOURCES
-    ${GENERATED_SOURCES_DIR}/testserviceserver.cpp
-    ${GENERATED_SOURCES_DIR}/globalenums.cpp
-)
-set_source_files_properties(${GENERATED_SOURCES} PROPERTIES GENERATED TRUE)
-
-# TODO: but their headers should be included in sources for executable to be processed by moc
-list(APPEND GENERATED_SOURCES
-    ${GENERATED_SOURCES_DIR}/testserviceserver.h
-    ${GENERATED_SOURCES_DIR}/globalenums.h
-)
-
-set_source_files_properties(${GENERATED_SOURCES_DIR}/globalenums.h PROPERTIES GENERATED TRUE)
-set_source_files_properties(${GENERATED_SOURCES_DIR}/testserviceserver.h PROPERTIES GENERATED TRUE)
-
-if(WIN32)
-    #Set  path to GTest build libraries
-    set(GTEST_BOTH_LIBRARIES "")
-
-    #Set  path to GTest include directory
-    include_directories(${GTEST_INCLUDE_PATHS} "/")
-endif()
-
-file(GLOB SOURCES main.cpp
-    simpletest.cpp
-    serializationtest.cpp
-    deserializationtest.cpp
-    servertest.cpp
-    clienttest.cpp
-    serializationcomplexmessagemap.cpp)
-
-set(testtarget "qtprotobuf_test")
-add_executable(${testtarget} ${SOURCES} ${GENERATED_SOURCES})
-
-if(WIN32)
-    target_link_libraries(${testtarget} qtgrpc qtprotobufsupport "${GTEST_BOTH_LIBRARIES}/gmock_main.lib" "${GTEST_BOTH_LIBRARIES}/gmock.lib" Qt5::Core Qt5::Qml Qt5::Network)
-elseif(UNIX)
-    target_link_libraries(${testtarget} gtest qtgrpc qtprotobufsupport)
-endif()
-
-target_include_directories(${testtarget} PRIVATE ${GENERATED_SOURCES_DIR})
-add_dependencies(${testtarget} ${test_sources_generation})
+add_subdirectory("test_protobuf")
+add_subdirectory("test_grpc")

+ 0 - 40
tests/clienttest.h

@@ -1,40 +0,0 @@
-/*
- * MIT License
- *
- * Copyright (c) 2019 Alexey Edelev <semlanik@gmail.com>
- *
- * This file is part of qtprotobuf project https://git.semlanik.org/semlanik/qtprotobuf
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy of this
- * software and associated documentation files (the "Software"), to deal in the Software
- * without restriction, including without limitation the rights to use, copy, modify,
- * merge, publish, distribute, sublicense, and/or sell copies of the Software, and
- * to permit persons to whom the Software is furnished to do so, subject to the following
- * conditions:
- *
- * The above copyright notice and this permission notice shall be included in all copies
- * or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
- * INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
- * PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE
- * FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
- * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
- * DEALINGS IN THE SOFTWARE.
- */
-
-#pragma once
-
-#include <gtest/gtest.h>
-
-namespace qtprotobuf {
-namespace tests {
-
-class ClientTest : public ::testing::Test
-{
-public:
-    ClientTest();
-};
-
-} //namespace tests
-} //namespace qtprotobuf

+ 0 - 32
tests/main.cpp

@@ -1,32 +0,0 @@
-/*
- * MIT License
- *
- * Copyright (c) 2019 Alexey Edelev <semlanik@gmail.com>
- *
- * This file is part of qtprotobuf project https://git.semlanik.org/semlanik/qtprotobuf
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy of this
- * software and associated documentation files (the "Software"), to deal in the Software
- * without restriction, including without limitation the rights to use, copy, modify,
- * merge, publish, distribute, sublicense, and/or sell copies of the Software, and
- * to permit persons to whom the Software is furnished to do so, subject to the following
- * conditions:
- *
- * The above copyright notice and this permission notice shall be included in all copies
- * or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
- * INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
- * PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE
- * FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
- * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
- * DEALINGS IN THE SOFTWARE.
- */
-
-#include <gtest/gtest.h>
-
-int main(int argc, char *argv[])
-{
-    ::testing::InitGoogleTest(&argc, argv);
-    return RUN_ALL_TESTS();
-}

+ 0 - 40
tests/servertest.h

@@ -1,40 +0,0 @@
-/*
- * MIT License
- *
- * Copyright (c) 2019 Alexey Edelev <semlanik@gmail.com>
- *
- * This file is part of qtprotobuf project https://git.semlanik.org/semlanik/qtprotobuf
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy of this
- * software and associated documentation files (the "Software"), to deal in the Software
- * without restriction, including without limitation the rights to use, copy, modify,
- * merge, publish, distribute, sublicense, and/or sell copies of the Software, and
- * to permit persons to whom the Software is furnished to do so, subject to the following
- * conditions:
- *
- * The above copyright notice and this permission notice shall be included in all copies
- * or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
- * INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
- * PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE
- * FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
- * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
- * DEALINGS IN THE SOFTWARE.
- */
-
-#pragma once
-
-#include <gtest/gtest.h>
-
-namespace qtprotobuf {
-namespace tests {
-
-class ServerTest : public ::testing::Test
-{
-public:
-    ServerTest();
-};
-
-} //namespace tests
-} //namespace qtprotobuf

+ 80 - 0
tests/test_grpc/CMakeLists.txt

@@ -0,0 +1,80 @@
+set(PROTO_FILES_DIR ${CMAKE_CURRENT_SOURCE_DIR}/proto/)
+set(GENERATED_SOURCES_DIR ${CMAKE_CURRENT_BINARY_DIR}/generated)
+
+file(MAKE_DIRECTORY ${GENERATED_SOURCES_DIR})
+file(GLOB PROTO_FILES ABSOLUTE ${CMAKE_CURRENT_SOURCE_DIR}/proto/*.proto)
+## test sources generation
+if(WIN32)
+    #Needs to set path to protobuf libraries
+    set(PROTOBUF_INSTALATION_PATH "")
+    set(Protobuf_PROTOC_EXECUTABLE ${PROTOBUF_INSTALATION_PATH}/bin/protoc.exe)
+endif()
+
+set(test_sources_generation "test_grpc_sources_generation")
+add_custom_target(${test_sources_generation})
+add_custom_command(TARGET ${test_sources_generation}
+        COMMAND ${Protobuf_PROTOC_EXECUTABLE} --${PROJECT_NAME}_opt=out=${GENERATED_SOURCES_DIR} --plugin=protoc-gen-${PROJECT_NAME}=$<TARGET_FILE:${PROJECT_NAME}> --qtprotobuf_out=${GENERATED_SOURCES_DIR} -I=${PROTO_FILES_DIR} ${PROTO_FILES}
+        WORKING_DIRECTORY ${PROTO_FILES_DIR}
+        DEPENDS ${PROTO_FILES}
+        COMMENT "Generating test headers"
+)
+add_dependencies(${test_sources_generation} ${PROJECT_NAME})
+
+set(EXPECTED_GENERATED_HEADERS
+    simplestringmessage.h
+    testserviceclient.h
+    testserviceserver.h
+)
+
+foreach(EXPECTED_GENERATED_HEADER ${EXPECTED_GENERATED_HEADERS})
+    get_filename_component(GENERATED_HEADER_BASENAME ${EXPECTED_GENERATED_HEADER} NAME_WE)
+
+    list(APPEND GENERATED_SOURCES ${GENERATED_SOURCES_DIR}/${GENERATED_HEADER_BASENAME}.cpp)
+    list(APPEND GENERATED_HEADERS ${GENERATED_SOURCES_DIR}/${GENERATED_HEADER_BASENAME}.h)
+
+    set_property(SOURCE ${GENERATED_SOURCES_DIR}/${GENERATED_HEADER_BASENAME}.cpp PROPERTY SKIP_AUTOMOC ON)
+endforeach(EXPECTED_GENERATED_HEADER)
+
+qt5_wrap_cpp(MOC_SOURCES ${GENERATED_HEADERS})
+list(APPEND GENERATED_SOURCES ${MOC_SOURCES})
+
+# TODO: so far the following cpp files are not generated 
+list(REMOVE_ITEM GENERATED_SOURCES
+    ${GENERATED_SOURCES_DIR}/globalenums.cpp
+    ${GENERATED_SOURCES_DIR}/testserviceserver.cpp
+)
+set_source_files_properties(${GENERATED_SOURCES} PROPERTIES GENERATED TRUE)
+
+# TODO: but their headers should be included in sources for executable to be processed by moc
+list(APPEND GENERATED_SOURCES
+    ${GENERATED_SOURCES_DIR}/globalenums.h
+    ${GENERATED_SOURCES_DIR}/testserviceserver.h
+)
+
+set_source_files_properties(${GENERATED_SOURCES_DIR}/globalenums.h PROPERTIES GENERATED TRUE)
+set_source_files_properties(${GENERATED_SOURCES_DIR}/testserviceserver.h PROPERTIES GENERATED TRUE)
+
+if(WIN32)
+    #Set  path to GTest build libraries
+    set(GTEST_BOTH_LIBRARIES "")
+
+    #Set  path to GTest include directory
+    include_directories(${GTEST_INCLUDE_PATHS} "/")
+endif()
+
+file(GLOB SOURCES main.cpp
+    servertest.cpp
+    clienttest.cpp)
+
+set(testtarget "qtgrpc_test")
+add_executable(${testtarget} ${SOURCES} ${GENERATED_SOURCES})
+
+if(WIN32)
+    target_link_libraries(${testtarget} qtgrpc qtprotobufsupport "${GTEST_BOTH_LIBRARIES}/gmock_main.lib" "${GTEST_BOTH_LIBRARIES}/gmock.lib" Qt5::Core Qt5::Qml Qt5::Network)
+elseif(UNIX)
+    target_link_libraries(${testtarget} gtest_main qtgrpc qtprotobufsupport)
+endif()
+
+target_include_directories(${testtarget} PRIVATE ${GENERATED_SOURCES_DIR})
+add_dependencies(${testtarget} ${test_sources_generation})
+

+ 11 - 8
tests/clienttest.cpp → tests/test_grpc/clienttest.cpp

@@ -23,21 +23,24 @@
  * DEALINGS IN THE SOFTWARE.
  */
 
-#include "clienttest.h"
-#include <QCoreApplication>
-
 #include "testserviceclient.h"
 #include "http2channel.h"
+#include "qtprotobuf.h"
 
-using namespace qtprotobufnamespace::tests;
-using namespace qtprotobuf::tests;
+#include <QCoreApplication>
+#include <gtest/gtest.h>
 
+using namespace qtprotobufnamespace::tests;
 using namespace qtprotobuf;
 
-ClientTest::ClientTest()
+class ClientTest : public ::testing::Test
 {
-
-}
+protected:
+    static void SetUpTestCase() {
+        QtProtobuf::init();
+        SimpleStringMessage::registerTypes();   
+    }
+};
 
 TEST_F(ClientTest, CheckMethodsGeneration)
 {

+ 0 - 0
tests/echoserver/CMakeLists.txt → tests/test_grpc/echoserver/CMakeLists.txt


+ 0 - 0
tests/echoserver/main.cpp → tests/test_grpc/echoserver/main.cpp


+ 0 - 0
tests/echoserver/testserver/.gitignore → tests/test_grpc/echoserver/testserver/.gitignore


+ 0 - 0
tests/echoserver/testserver/globalenums.grpc.pb.cc → tests/test_grpc/echoserver/testserver/globalenums.grpc.pb.cc


+ 0 - 0
tests/echoserver/testserver/globalenums.grpc.pb.h → tests/test_grpc/echoserver/testserver/globalenums.grpc.pb.h


+ 0 - 0
tests/echoserver/testserver/globalenums.pb.cc → tests/test_grpc/echoserver/testserver/globalenums.pb.cc


+ 0 - 0
tests/echoserver/testserver/globalenums.pb.h → tests/test_grpc/echoserver/testserver/globalenums.pb.h


+ 0 - 0
tests/echoserver/testserver/globalenums.proto → tests/test_grpc/echoserver/testserver/globalenums.proto


+ 0 - 0
tests/echoserver/testserver/globalenumssamenamespace.grpc.pb.cc → tests/test_grpc/echoserver/testserver/globalenumssamenamespace.grpc.pb.cc


+ 0 - 0
tests/echoserver/testserver/globalenumssamenamespace.grpc.pb.h → tests/test_grpc/echoserver/testserver/globalenumssamenamespace.grpc.pb.h


+ 0 - 0
tests/echoserver/testserver/globalenumssamenamespace.pb.cc → tests/test_grpc/echoserver/testserver/globalenumssamenamespace.pb.cc


+ 0 - 0
tests/echoserver/testserver/globalenumssamenamespace.pb.h → tests/test_grpc/echoserver/testserver/globalenumssamenamespace.pb.h


+ 0 - 0
tests/echoserver/testserver/globalenumssamenamespace.proto → tests/test_grpc/echoserver/testserver/globalenumssamenamespace.proto


+ 0 - 0
tests/echoserver/testserver/main.cpp → tests/test_grpc/echoserver/testserver/main.cpp


+ 0 - 0
tests/echoserver/testserver/simpletest.grpc.pb.cc → tests/test_grpc/echoserver/testserver/simpletest.grpc.pb.cc


+ 0 - 0
tests/echoserver/testserver/simpletest.grpc.pb.h → tests/test_grpc/echoserver/testserver/simpletest.grpc.pb.h


+ 0 - 0
tests/echoserver/testserver/simpletest.pb.cc → tests/test_grpc/echoserver/testserver/simpletest.pb.cc


+ 0 - 0
tests/echoserver/testserver/simpletest.pb.h → tests/test_grpc/echoserver/testserver/simpletest.pb.h


+ 0 - 0
tests/echoserver/testserver/simpletest.proto → tests/test_grpc/echoserver/testserver/simpletest.proto


+ 0 - 0
tests/echoserver/testserver/testserver.pro → tests/test_grpc/echoserver/testserver/testserver.pro


+ 0 - 0
tests/echoserver/testserver/testservice.grpc.pb.cc → tests/test_grpc/echoserver/testserver/testservice.grpc.pb.cc


+ 0 - 0
tests/echoserver/testserver/testservice.grpc.pb.h → tests/test_grpc/echoserver/testserver/testservice.grpc.pb.h


+ 0 - 0
tests/echoserver/testserver/testservice.pb.cc → tests/test_grpc/echoserver/testserver/testservice.pb.cc


+ 0 - 0
tests/echoserver/testserver/testservice.pb.h → tests/test_grpc/echoserver/testserver/testservice.pb.h


+ 0 - 0
tests/echoserver/testserver/testservice.proto → tests/test_grpc/echoserver/testserver/testservice.proto


+ 8 - 0
tests/test_grpc/proto/simpletest.proto

@@ -0,0 +1,8 @@
+syntax = "proto3";
+
+package qtprotobufnamespace.tests;
+
+message SimpleStringMessage {
+    string testFieldString = 6;
+}
+

+ 0 - 0
tests/proto/testservice.proto → tests/test_grpc/proto/testservice.proto


+ 4 - 6
tests/servertest.cpp → tests/test_grpc/servertest.cpp

@@ -23,22 +23,20 @@
  * DEALINGS IN THE SOFTWARE.
  */
 
-#include "servertest.h"
-
 #include "testserviceserver.h"
 
-using namespace qtprotobufnamespace::tests;
-using namespace qtprotobuf::tests;
+#include <gtest/gtest.h>
 
+using namespace qtprotobufnamespace::tests;
 using namespace qtprotobuf;
 
 class TestServiceServerImpl : public TestServiceServer {
     SimpleStringMessage testMethod(const SimpleStringMessage &) override { return SimpleStringMessage(); }
 };
 
-ServerTest::ServerTest()
+class ServerTest : public ::testing::Test
 {
-}
+};
 
 TEST_F(ServerTest, CheckMethodsGeneration)
 {

+ 217 - 0
tests/test_protobuf/CMakeLists.txt

@@ -0,0 +1,217 @@
+set(PROTO_FILES_DIR ${CMAKE_CURRENT_SOURCE_DIR}/proto/)
+set(GENERATED_SOURCES_DIR ${CMAKE_CURRENT_BINARY_DIR}/generated)
+
+file(MAKE_DIRECTORY ${GENERATED_SOURCES_DIR})
+file(GLOB PROTO_FILES ABSOLUTE ${CMAKE_CURRENT_SOURCE_DIR}/proto/*.proto)
+## test sources generation
+if(WIN32)
+    #Needs to set path to protobuf libraries
+    set(PROTOBUF_INSTALATION_PATH "")
+    set(Protobuf_PROTOC_EXECUTABLE ${PROTOBUF_INSTALATION_PATH}/bin/protoc.exe)
+endif()
+
+set(test_sources_generation "test_generation")
+add_custom_target(${test_sources_generation})
+add_custom_command(TARGET ${test_sources_generation}
+        COMMAND ${Protobuf_PROTOC_EXECUTABLE} --${PROJECT_NAME}_opt=out=${GENERATED_SOURCES_DIR} --plugin=protoc-gen-${PROJECT_NAME}=$<TARGET_FILE:${PROJECT_NAME}> --qtprotobuf_out=${GENERATED_SOURCES_DIR} -I=${PROTO_FILES_DIR} ${PROTO_FILES}
+        WORKING_DIRECTORY ${PROTO_FILES_DIR}
+        DEPENDS ${PROTO_FILES}
+        COMMENT "Generating test headers"
+)
+add_dependencies(${test_sources_generation} ${PROJECT_NAME})
+
+## test sources build
+# policy enables automoc for generated files
+if(${CMAKE_VERSION} VERSION_GREATER "3.10.0")
+    cmake_policy(SET CMP0071 NEW)
+endif()
+
+set(CMAKE_INCLUDE_CURRENT_DIR ON)
+set(CMAKE_AUTOMOC ON)
+set(CMAKE_AUTORCC ON)
+
+if(Qt5_POSITION_INDEPENDENT_CODE)
+    set(CMAKE_POSITION_INDEPENDENT_CODE ON)
+endif()
+
+set(EXPECTED_GENERATED_HEADERS
+    complexmessage.h
+    externalcomplexmessage.h
+    globalenums.h
+    repeatedbytesmessage.h
+    repeatedcomplexmessage.h
+    repeateddoublemessage.h
+    repeatedexternalcomplexmessage.h
+    repeatedfixedint64message.h
+    repeatedfixedintmessage.h
+    repeatedfloatmessage.h
+    repeatedint64message.h
+    repeatedintmessage.h
+    repeatedsfixedint64message.h
+    repeatedsfixedintmessage.h
+    repeatedsint64message.h
+    repeatedsintmessage.h
+    repeatedstringmessage.h
+    repeateduint64message.h
+    repeateduintmessage.h
+    simpleboolmessage.h
+    simplebytesmessage.h
+    simpledoublemessage.h
+    simpleenumlistmessage.h
+    simpleenummessage.h
+    simpleexternalenummessage.h
+    simpleexternalmessage.h
+    simplefileenummessage.h
+    simplefixed32complexmessagemapmessage.h
+    simplefixed32int32mapmessage.h
+    simplefixed32int64mapmessage.h
+    simplefixed32sint32mapmessage.h
+    simplefixed32sint64mapmessage.h
+    simplefixed32stringmapmessage.h
+    simplefixed32uint32mapmessage.h
+    simplefixed32uint64mapmessage.h
+    simplefixed64complexmessagemapmessage.h
+    simplefixed64int32mapmessage.h
+    simplefixed64int64mapmessage.h
+    simplefixed64sint32mapmessage.h
+    simplefixed64sint64mapmessage.h
+    simplefixed64stringmapmessage.h
+    simplefixed64uint32mapmessage.h
+    simplefixed64uint64mapmessage.h
+    simplefixedint32message.h
+    simplefixedint64message.h
+    simplefloatmessage.h
+    simpleint32complexmessagemapmessage.h
+    simpleint32int32mapmessage.h
+    simpleint32int64mapmessage.h
+    simpleint32sint32mapmessage.h
+    simpleint32sint64mapmessage.h
+    simpleint32stringmapmessage.h
+    simpleint32uint32mapmessage.h
+    simpleint32uint64mapmessage.h
+    simpleint64complexmessagemapmessage.h
+    simpleint64int32mapmessage.h
+    simpleint64int64mapmessage.h
+    simpleint64message.h
+    simpleint64sint32mapmessage.h
+    simpleint64sint64mapmessage.h
+    simpleint64stringmapmessage.h
+    simpleint64uint32mapmessage.h
+    simpleint64uint64mapmessage.h
+    simpleintmessage.h
+    simplesfixed32complexmessagemapmessage.h
+    simplesfixed32int32mapmessage.h
+    simplesfixed32int64mapmessage.h
+    simplesfixed32sint32mapmessage.h
+    simplesfixed32sint64mapmessage.h
+    simplesfixed32stringmapmessage.h
+    simplesfixed32uint32mapmessage.h
+    simplesfixed32uint64mapmessage.h
+    simplesfixed64complexmessagemapmessage.h
+    simplesfixed64int32mapmessage.h
+    simplesfixed64int64mapmessage.h
+    simplesfixed64sint32mapmessage.h
+    simplesfixed64sint64mapmessage.h
+    simplesfixed64stringmapmessage.h
+    simplesfixed64uint32mapmessage.h
+    simplesfixed64uint64mapmessage.h
+    simplesfixedint32message.h
+    simplesfixedint64message.h
+    simplesint32complexmessagemapmessage.h
+    simplesint32int32mapmessage.h
+    simplesint32int64mapmessage.h
+    simplesint32sint32mapmessage.h
+    simplesint32sint64mapmessage.h
+    simplesint32stringmapmessage.h
+    simplesint32uint32mapmessage.h
+    simplesint32uint64mapmessage.h
+    simplesint64complexmessagemapmessage.h
+    simplesint64int32mapmessage.h
+    simplesint64int64mapmessage.h
+    simplesint64message.h
+    simplesint64sint32mapmessage.h
+    simplesint64sint64mapmessage.h
+    simplesint64stringmapmessage.h
+    simplesint64uint32mapmessage.h
+    simplesint64uint64mapmessage.h
+    simplesintmessage.h
+    simplestringcomplexmessagemapmessage.h
+    simplestringint32mapmessage.h
+    simplestringint64mapmessage.h
+    simplestringmessage.h
+    simplestringsint32mapmessage.h
+    simplestringsint64mapmessage.h
+    simplestringstringmapmessage.h
+    simplestringuint32mapmessage.h
+    simplestringuint64mapmessage.h
+    simpleuint32complexmessagemapmessage.h
+    simpleuint32int32mapmessage.h
+    simpleuint32int64mapmessage.h
+    simpleuint32sint32mapmessage.h
+    simpleuint32sint64mapmessage.h
+    simpleuint32stringmapmessage.h
+    simpleuint32uint32mapmessage.h
+    simpleuint32uint64mapmessage.h
+    simpleuint64complexmessagemapmessage.h
+    simpleuint64int32mapmessage.h
+    simpleuint64int64mapmessage.h
+    simpleuint64message.h
+    simpleuint64sint32mapmessage.h
+    simpleuint64sint64mapmessage.h
+    simpleuint64stringmapmessage.h
+    simpleuint64uint32mapmessage.h
+    simpleuint64uint64mapmessage.h
+    simpleuintmessage.h
+    stepchildenummessage.h
+)
+
+foreach(EXPECTED_GENERATED_HEADER ${EXPECTED_GENERATED_HEADERS})
+    get_filename_component(GENERATED_HEADER_BASENAME ${EXPECTED_GENERATED_HEADER} NAME_WE)
+
+    list(APPEND GENERATED_SOURCES ${GENERATED_SOURCES_DIR}/${GENERATED_HEADER_BASENAME}.cpp)
+    list(APPEND GENERATED_HEADERS ${GENERATED_SOURCES_DIR}/${GENERATED_HEADER_BASENAME}.h)
+
+    set_property(SOURCE ${GENERATED_SOURCES_DIR}/${GENERATED_HEADER_BASENAME}.cpp PROPERTY SKIP_AUTOMOC ON)
+endforeach(EXPECTED_GENERATED_HEADER)
+
+qt5_wrap_cpp(MOC_SOURCES ${GENERATED_HEADERS})
+list(APPEND GENERATED_SOURCES ${MOC_SOURCES})
+
+# TODO: so far the following cpp files are not generated 
+list(REMOVE_ITEM GENERATED_SOURCES
+    ${GENERATED_SOURCES_DIR}/globalenums.cpp
+)
+set_source_files_properties(${GENERATED_SOURCES} PROPERTIES GENERATED TRUE)
+
+# TODO: but their headers should be included in sources for executable to be processed by moc
+list(APPEND GENERATED_SOURCES
+    ${GENERATED_SOURCES_DIR}/globalenums.h
+)
+
+set_source_files_properties(${GENERATED_SOURCES_DIR}/globalenums.h PROPERTIES GENERATED TRUE)
+
+if(WIN32)
+    #Set  path to GTest build libraries
+    set(GTEST_BOTH_LIBRARIES "")
+
+    #Set  path to GTest include directory
+    include_directories(${GTEST_INCLUDE_PATHS} "/")
+endif()
+
+file(GLOB SOURCES
+    simpletest.cpp
+    serializationtest.cpp
+    deserializationtest.cpp
+    serializationcomplexmessagemap.cpp)
+
+set(testtarget "qtprotobuf_test")
+add_executable(${testtarget} ${SOURCES} ${GENERATED_SOURCES})
+
+if(WIN32)
+    target_link_libraries(${testtarget} qtgrpc qtprotobufsupport "${GTEST_BOTH_LIBRARIES}/gmock_main.lib" "${GTEST_BOTH_LIBRARIES}/gmock.lib" Qt5::Core Qt5::Qml Qt5::Network)
+elseif(UNIX)
+    target_link_libraries(${testtarget} gtest_main qtgrpc qtprotobufsupport)
+endif()
+
+target_include_directories(${testtarget} PRIVATE ${GENERATED_SOURCES_DIR})
+add_dependencies(${testtarget} ${test_sources_generation})

+ 0 - 0
tests/deserializationtest.cpp → tests/test_protobuf/deserializationtest.cpp


+ 0 - 0
tests/deserializationtest.h → tests/test_protobuf/deserializationtest.h


+ 0 - 0
tests/proto/externalpackagetest.proto → tests/test_protobuf/proto/externalpackagetest.proto


+ 0 - 0
tests/proto/globalenums.proto → tests/test_protobuf/proto/globalenums.proto


+ 0 - 0
tests/proto/globalenumssamenamespace.proto → tests/test_protobuf/proto/globalenumssamenamespace.proto


+ 0 - 0
tests/proto/nestedmessages.proto → tests/test_protobuf/proto/nestedmessages.proto


+ 0 - 0
tests/proto/simpletest.proto → tests/test_protobuf/proto/simpletest.proto


+ 0 - 0
tests/serializationcomplexmessagemap.cpp → tests/test_protobuf/serializationcomplexmessagemap.cpp


+ 0 - 0
tests/serializationtest.cpp → tests/test_protobuf/serializationtest.cpp


+ 0 - 0
tests/serializationtest.h → tests/test_protobuf/serializationtest.h


+ 0 - 0
tests/simpletest.cpp → tests/test_protobuf/simpletest.cpp


+ 0 - 0
tests/simpletest.h → tests/test_protobuf/simpletest.h