Jelajahi Sumber

Enable Qt types for windows

Fixes: #136
Alexey Edelev 4 tahun lalu
induk
melakukan
ce0a3ff387

+ 1 - 1
CMakeLists.txt

@@ -94,8 +94,8 @@ add_subdirectory("src/grpc")
 add_subdirectory("src/generator")
 if(NOT WIN32)#TODO: There are linking issues with windows build of well-known types...
     add_subdirectory("src/wellknowntypes")
-    add_subdirectory("src/qttypes")
 endif()
+add_subdirectory("src/qttypes")
 
 # add a target to generate API documentation with Doxygen
 find_package(Doxygen)

+ 4 - 4
cmake/QtProtobufGen.cmake

@@ -150,11 +150,11 @@ function(qtprotobuf_generate)
             target_include_directories(${GENERATED_TARGET_NAME} PRIVATE
                 $<TARGET_PROPERTY:${QT_PROTOBUF_PROJECT}::QtProtobufWellKnownTypes,INTERFACE_INCLUDE_DIRECTORIES>)
         endif()
+    endif()
 
-        if(TARGET ${QT_PROTOBUF_PROJECT}::QtProtobufQtTypes)
-            target_include_directories(${GENERATED_TARGET_NAME} PRIVATE
-                $<TARGET_PROPERTY:${QT_PROTOBUF_PROJECT}::QtProtobufQtTypes,INTERFACE_INCLUDE_DIRECTORIES>)
-        endif()
+    if(TARGET ${QT_PROTOBUF_PROJECT}::QtProtobufQtTypes)
+        target_include_directories(${GENERATED_TARGET_NAME} PRIVATE
+            $<TARGET_PROPERTY:${QT_PROTOBUF_PROJECT}::QtProtobufQtTypes,INTERFACE_INCLUDE_DIRECTORIES>)
     endif()
 
     #Automatically link whole static library to specified in parameters target

+ 1 - 1
tests/CMakeLists.txt

@@ -6,5 +6,5 @@ add_subdirectory("test_protobuf_multifile")
 add_subdirectory("test_qprotobuf_serializer_plugin")
 if(NOT WIN32)#TODO: There are linking issues with windows build of well-known types...
     add_subdirectory("test_wellknowntypes")
-    add_subdirectory("test_qttypes")
 endif()
+add_subdirectory("test_qttypes")

+ 4 - 3
tests/test_qttypes/qtcoretest.cpp

@@ -318,12 +318,13 @@ TEST_F(QtTypesQtCoreTest, QPolygonFTest)
     qtprotobufnamespace::qttypes::tests::QPolygonFMessage msg;
     msg.setTestField(QPolygonF({QPointF(10, 0), QPointF(20, 20), QPointF(0, 20)}));
     QByteArray result = msg.serialize(serializer.get());
-    EXPECT_TRUE(QByteArray::fromHex("0a3c0a121100000000000000000900000000000024400a121100000000000034400900000000000034400a12110000000000003440090000000000000000") ==
-                result || QByteArray::fromHex("0a3c0a090900000000000024400a120900000000000034401100000000000034400a09110000000000003440") == result);
+    std::cerr << result.toHex().toStdString() << std::endl;
+    EXPECT_TRUE(QByteArray::fromHex("0a3c0a121100000000000000000900000000000024400a121100000000000034400900000000000034400a12110000000000003440090000000000000000") == result
+                || QByteArray::fromHex("0a2a0a090900000000000024400a120900000000000034401100000000000034400a09110000000000003440") == result
+                || QByteArray::fromHex("0a3c0a120900000000000024401100000000000000000a120900000000000034401100000000000034400a12090000000000000000110000000000003440") == result);
 
     msg.setTestField({});
     msg.deserialize(serializer.get(), QByteArray::fromHex("0a2a0a090900000000000024400a120900000000000034401100000000000034400a09110000000000003440"));
-
     EXPECT_EQ(msg.testField().size(), 3);
     EXPECT_EQ(msg.testField()[0], QPointF(10, 0));
     EXPECT_EQ(msg.testField()[1], QPointF(20, 20));

+ 18 - 10
tests/test_qttypes/qtguitest.cpp

@@ -82,8 +82,10 @@ TEST_F(QtTypesQtGuiTest, QMatrix4x4Test)
     qtprotobufnamespace::qttypes::tests::QMatrix4x4Message msg;
     msg.setTestField({0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15});
     auto result = msg.serialize(serializer.get());
-    EXPECT_TRUE(QByteArray::fromHex("0a518501000070417d0000604175000050416d0000404165000030415d0000204155000010414d00000041450000e0403d0000c040350000a0402d0000804025000040401d00000040150000803f0d00000000") ==
-               result || QByteArray::fromHex("0a4c150000803f1d0000004025000040402d00008040350000a0403d0000c040450000e0404d0000004155000010415d0000204165000030416d0000404175000050417d00006041850100007041") == result);
+
+    EXPECT_TRUE(QByteArray::fromHex("0a518501000070417d0000604175000050416d0000404165000030415d0000204155000010414d00000041450000e0403d0000c040350000a0402d0000804025000040401d00000040150000803f0d00000000") == result
+                || QByteArray::fromHex("0a4c150000803f1d0000004025000040402d00008040350000a0403d0000c040450000e0404d0000004155000010415d0000204165000030416d0000404175000050417d00006041850100007041") == result
+                || QByteArray::fromHex("0a514d000000410d00000000150000803f1d0000004025000040402d00008040350000a0403d0000c040450000e04055000010415d0000204165000030416d0000404175000050417d00006041850100007041") == result);
 
     msg.setTestField({});
     msg.deserialize(serializer.get(), QByteArray::fromHex("0a4c150000803f1d0000004025000040402d00008040350000a0403d0000c040450000e0404d0000004155000010415d0000204165000030416d0000404175000050417d00006041850100007041"));
@@ -98,8 +100,9 @@ TEST_F(QtTypesQtGuiTest, QVector2DTest)
     qtprotobufnamespace::qttypes::tests::QVector2DMessage msg;
     msg.setTestField(QVector2D(42, 24));
     auto result = msg.serialize(serializer.get());
-    EXPECT_TRUE(QByteArray::fromHex("0a0a150000c0410d00002842") ==
-               result);
+
+    EXPECT_TRUE(QByteArray::fromHex("0a0a150000c0410d00002842") == result
+                || QByteArray::fromHex("0a0a0d00002842150000c041") == result);
 
     msg.setTestField({});
     msg.deserialize(serializer.get(), QByteArray::fromHex("0a0a0d0000c0411500002842"));
@@ -114,8 +117,9 @@ TEST_F(QtTypesQtGuiTest, QVector3DTest)
     qtprotobufnamespace::qttypes::tests::QVector3DMessage msg;
     msg.setTestField(QVector3D(42, 24, 11));
     auto result = msg.serialize(serializer.get());
-    EXPECT_TRUE(QByteArray::fromHex("0a0f1d00003041150000c0410d00002842") ==
-               result);
+
+    EXPECT_TRUE(QByteArray::fromHex("0a0f1d00003041150000c0410d00002842") == result
+                || QByteArray::fromHex("0a0f0d00002842150000c0411d00003041") == result);
 
     msg.setTestField({});
     msg.deserialize(serializer.get(), QByteArray::fromHex("0a0f0d0000c04115000030411d00002842"));
@@ -130,8 +134,10 @@ TEST_F(QtTypesQtGuiTest, QVector4DTest)
     qtprotobufnamespace::qttypes::tests::QVector4DMessage msg;
     msg.setTestField({24, 11, 42, 0});
     auto result = msg.serialize(serializer.get());
-    EXPECT_TRUE(QByteArray::fromHex("0a1425000000001d0000284215000030410d0000c041") ==
-               result || QByteArray::fromHex("0a0f0d0000c04115000030411d00002842") == result);
+
+    EXPECT_TRUE(QByteArray::fromHex("0a1425000000001d0000284215000030410d0000c041") == result
+                || QByteArray::fromHex("0a0f0d0000c04115000030411d00002842") == result
+                || QByteArray::fromHex("0a140d0000c04115000030411d000028422500000000") == result);
 
     msg.setTestField({});
     msg.deserialize(serializer.get(), QByteArray::fromHex("0a0f0d0000c04115000030411d00002842"));
@@ -146,8 +152,10 @@ TEST_F(QtTypesQtGuiTest, QTransformTest)
     qtprotobufnamespace::qttypes::tests::QTransformMessage msg;
     msg.setTestField(QTransform(0, 1, 2, 3, 4, 5, 6, 7, 8));
     auto result = msg.serialize(serializer.get());
-    EXPECT_TRUE(QByteArray::fromHex("0a51490000000000002040410000000000001c4039000000000000184031000000000000144029000000000000104021000000000000084019000000000000004011000000000000f03f090000000000000000") ==
-               result || QByteArray::fromHex("0a4811000000000000f03f190000000000000040210000000000000840290000000000001040310000000000001440390000000000001840410000000000001c40490000000000002040") == result);
+
+    EXPECT_TRUE(QByteArray::fromHex("0a51490000000000002040410000000000001c4039000000000000184031000000000000144029000000000000104021000000000000084019000000000000004011000000000000f03f090000000000000000") == result
+                || QByteArray::fromHex("0a4811000000000000f03f190000000000000040210000000000000840290000000000001040310000000000001440390000000000001840410000000000001c40490000000000002040") == result
+                || QByteArray::fromHex("0a5149000000000000204009000000000000000011000000000000f03f190000000000000040210000000000000840290000000000001040310000000000001440390000000000001840410000000000001c40") == result);
 
     msg.setTestField({});
     msg.deserialize(serializer.get(), QByteArray::fromHex("0a48090000000000002040110000000000001c4019000000000000184021000000000000144029000000000000104031000000000000084039000000000000004041000000000000f03f"));