Propogate onChange() event when getFooBuilder() is on an oneof message

field.

Change-Id: Idb5b53da5accd24038a895aba49b684eeee95814
changes/14/217114/1
Jisi Liu 10 years ago
parent 20042b72da
commit e70329c6c0
  1. 14
      java/src/test/java/com/google/protobuf/GeneratedMessageTest.java
  2. 1
      src/google/protobuf/compiler/java/java_message_field.cc

@ -56,9 +56,10 @@ import protobuf_unittest.UnittestProto;
import protobuf_unittest.UnittestProto.ForeignEnum;
import protobuf_unittest.UnittestProto.ForeignMessage;
import protobuf_unittest.UnittestProto.ForeignMessageOrBuilder;
import protobuf_unittest.UnittestProto.NestedTestAllTypes;
import protobuf_unittest.UnittestProto.TestAllExtensions;
import protobuf_unittest.UnittestProto.TestAllTypes;
import protobuf_unittest.UnittestProto.TestAllTypes.NestedMessage;
import protobuf_unittest.UnittestProto.TestAllTypes;
import protobuf_unittest.UnittestProto.TestAllTypesOrBuilder;
import protobuf_unittest.UnittestProto.TestExtremeDefaultValues;
import protobuf_unittest.UnittestProto.TestOneof2;
@ -1510,6 +1511,17 @@ public class GeneratedMessageTest extends TestCase {
}
}
public void testOneofNestedBuilderOnChangePropagation() {
NestedTestAllTypes.Builder parentBuilder = NestedTestAllTypes.newBuilder();
TestAllTypes.Builder builder = parentBuilder.getPayloadBuilder();
builder.getOneofNestedMessageBuilder();
assertTrue(builder.hasOneofNestedMessage());
assertTrue(parentBuilder.hasPayload());
NestedTestAllTypes message = parentBuilder.build();
assertTrue(message.hasPayload());
assertTrue(message.getPayload().hasOneofNestedMessage());
}
public void testGetRepeatedFieldBuilder() {
Descriptor descriptor = TestAllTypes.getDescriptor();

@ -718,6 +718,7 @@ GenerateBuilderMembers(io::Printer* printer) const {
" $oneof_name$_ = null;\n"
" }\n"
" $set_oneof_case_message$;\n"
" $on_changed$;\n"
" return $name$Builder_;\n"
"}\n");
}

Loading…
Cancel
Save