Browse Source

Add tests for nexsted external fields

Fixes: #125
Alexey Edelev 4 years ago
parent
commit
b944f7ff54

+ 14 - 0
tests/test_protobuf/nestedtest.cpp.inc

@@ -171,5 +171,19 @@ TEST_F(NestedTest, NeighborTest)
     ASSERT_TRUE(test.neighborNested2() == NestedFieldMessage2::NestedMessageLevel1::NestedMessageLevel2{75});
     ASSERT_TRUE(test.neighborNested2() == NestedFieldMessage2::NestedMessageLevel1::NestedMessageLevel2{75});
 }
 }
 
 
+TEST_F(NestedTest, ExternalTest)
+{
+    assertMessagePropertyRegistered<NestedExternal, qtprotobufnamespace1::externaltests::NestedFieldMessage::NestedMessage*>(1, "qtprotobufnamespace1::externaltests::NestedFieldMessage::NestedMessage*", "externalNested");
+
+    NestedExternal test{{15}};
+    EXPECT_EQ(test.externalNested().field(), 15);
+
+    const char *propertyName = "externalNested";
+
+    ASSERT_TRUE(test.setProperty(propertyName, QVariant::fromValue<qtprotobufnamespace1::externaltests::NestedFieldMessage::NestedMessage*>(new qtprotobufnamespace1::externaltests::NestedFieldMessage::NestedMessage{55})));
+    ASSERT_TRUE(*(test.property(propertyName).value<qtprotobufnamespace1::externaltests::NestedFieldMessage::NestedMessage*>()) == qtprotobufnamespace1::externaltests::NestedFieldMessage::NestedMessage{55});
+    ASSERT_TRUE(test.externalNested() == qtprotobufnamespace1::externaltests::NestedFieldMessage::NestedMessage{55});
+}
+
 }
 }
 }
 }

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

@@ -17,3 +17,10 @@ enum ExternalTestEnum {
     EXTERNAL_TEST_ENUM_VALUE3 = 3;
     EXTERNAL_TEST_ENUM_VALUE3 = 3;
     EXTERNAL_TEST_ENUM_VALUE4 = 4;
     EXTERNAL_TEST_ENUM_VALUE4 = 4;
 }
 }
+
+message NestedFieldMessage {
+    message NestedMessage {
+        sint32 field = 1;
+    }
+    NestedMessage nested = 1;   
+}

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

@@ -1,6 +1,7 @@
 syntax = "proto3";
 syntax = "proto3";
 
 
 package qtprotobufnamespace.tests.nested;
 package qtprotobufnamespace.tests.nested;
+import "externalpackagetest.proto";
 
 
 message NestedFieldMessage {
 message NestedFieldMessage {
     sint32 testFieldInt = 1;
     sint32 testFieldInt = 1;
@@ -25,3 +26,7 @@ message NeighborNested {
     NestedFieldMessage.NestedMessage neighborNested = 1;
     NestedFieldMessage.NestedMessage neighborNested = 1;
     NestedFieldMessage2.NestedMessageLevel1.NestedMessageLevel2 neighborNested2 = 2;
     NestedFieldMessage2.NestedMessageLevel1.NestedMessageLevel2 neighborNested2 = 2;
 }
 }
+
+message NestedExternal {
+    qtprotobufnamespace1.externaltests.NestedFieldMessage.NestedMessage externalNested = 1;
+}

+ 1 - 0
tests/test_protobuf_multifile/nestedtest.cpp

@@ -26,5 +26,6 @@
 #include "qtprotobufnamespace/tests/nested/neighbornested.h"
 #include "qtprotobufnamespace/tests/nested/neighbornested.h"
 #include "qtprotobufnamespace/tests/nested/nestedfieldmessage.h"
 #include "qtprotobufnamespace/tests/nested/nestedfieldmessage.h"
 #include "qtprotobufnamespace/tests/nested/nestedfieldmessage2.h"
 #include "qtprotobufnamespace/tests/nested/nestedfieldmessage2.h"
+#include "qtprotobufnamespace/tests/nested/nestedexternal.h"
 
 
 #include "../test_protobuf/nestedtest.cpp.inc"
 #include "../test_protobuf/nestedtest.cpp.inc"