1/* 2 * Copyright (C) 2017 The Android Open Source Project 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 17syntax = "proto2"; 18 19package protozero.test.protos; 20 21import "src/protozero/test/example_proto/library.proto"; 22import "src/protozero/test/example_proto/other_package/test_messages.proto"; 23import "src/protozero/test/example_proto/subpackage/test_messages.proto"; 24 25// This file contains comprehensive set of supported message structures and 26// data types. Unit tests depends on the plugin-processed version of this file. 27 28// Tests importing message definition from another proto file. 29message TransgalacticParcel { 30 optional TransgalacticMessage message = 1; 31 optional string tracking_code = 2; 32 optional TransgalacticMessage.MessageType message_type = 3; 33} 34 35enum SmallEnum { 36 TO_BE = 1; 37 NOT_TO_BE = 0; 38} 39 40enum SignedEnum { 41 POSITIVE = 1; 42 NEUTRAL = 0; 43 NEGATIVE = -1; 44} 45 46enum BigEnum { 47 BEGIN = 10; 48 END = 100500; 49} 50 51message EveryField { 52 optional int32 field_int32 = 1; 53 optional int64 field_int64 = 2; 54 optional uint32 field_uint32 = 3; 55 optional uint64 field_uint64 = 4; 56 optional sint32 field_sint32 = 5; 57 optional sint64 field_sint64 = 6; 58 optional fixed32 field_fixed32 = 7; 59 optional fixed64 field_fixed64 = 8; 60 optional sfixed32 field_sfixed32 = 9; 61 optional sfixed64 field_sfixed64 = 10; 62 optional float field_float = 11; 63 optional double field_double = 12; 64 optional bool field_bool = 13; 65 repeated EveryField field_nested = 14; 66 67 optional SmallEnum small_enum = 51; 68 optional SignedEnum signed_enum = 52; 69 optional BigEnum big_enum = 53; 70 71 optional string field_string = 500; 72 optional bytes field_bytes = 505; 73 74 enum NestedEnum { 75 PING = 1; 76 PONG = 2; 77 } 78 optional NestedEnum nested_enum = 600; 79 80 repeated string repeated_string = 700; 81 repeated fixed64 repeated_fixed64 = 701; 82 repeated sfixed32 repeated_sfixed32 = 702; 83 84 repeated int32 repeated_int32 = 999; 85} 86 87message NestedA { 88 message NestedB { 89 message NestedC { 90 optional int32 value_c = 1; 91 } 92 optional NestedC value_b = 1; 93 } 94 repeated NestedB repeated_a = 2; 95 optional NestedB.NestedC super_nested = 3; 96} 97 98message CamelCaseFields { 99 // To check that any reasonable name converts to camel case correctly. 100 optional bool foo_bar_baz = 1; 101 optional bool barBaz = 2; 102 optional bool MooMoo = 3; 103 optional bool URLEncoder = 4; 104 optional bool XMap = 5; 105 optional bool UrLE_nco__der = 6; 106 optional bool __bigBang = 7; 107 optional bool U2 = 8; 108 optional bool bangBig__ = 9; 109} 110 111message PackedRepeatedFields { 112 repeated int32 field_int32 = 1 [packed = true]; 113 repeated int64 field_int64 = 4 [packed = true]; 114 repeated uint32 field_uint32 = 5 [packed = true]; 115 repeated uint64 field_uint64 = 6 [packed = true]; 116 // Repeated packed Zig-zag fields are currently unsupported by our protoc 117 // plugin. 118 // repeated sint32 field_sint32 = 7 [packed = true]; 119 // repeated sint64 field_sint64 = 8 [packed = true]; 120 repeated fixed32 field_fixed32 = 2 [packed = true]; 121 repeated fixed64 field_fixed64 = 9 [packed = true]; 122 repeated sfixed32 field_sfixed32 = 10 [packed = true]; 123 repeated sfixed64 field_sfixed64 = 3 [packed = true]; 124 repeated float field_float = 11 [packed = true]; 125 repeated double field_double = 12 [packed = true]; 126 // Repeated (even non-packed) bool fields are currently unsupported by our 127 // protoc plugin. 128 // repeated bool field_bool = 13 [packed = true]; 129 repeated SmallEnum small_enum = 51 [packed = true]; 130 repeated SignedEnum signed_enum = 52 [packed = true]; 131 repeated BigEnum big_enum = 53 [packed = true]; 132} 133 134// The following two messages are for testing that unknown fields being 135// preserved in the decode->reencode path. 136 137message TestVersioning_V1 { 138 enum Enumz_V1 { 139 ONE = 1; 140 TWO = 2; 141 } 142 message Sub1_V1 { 143 optional int32 sub1_int = 1; 144 optional string sub1_string = 2; 145 } 146 optional int32 root_int = 1; 147 repeated Enumz_V1 enumz = 2; 148 optional string root_string = 3; 149 repeated string rep_string = 4; 150 optional Sub1_V1 sub1 = 5; 151 repeated Sub1_V1 sub1_rep = 6; 152 optional Sub1_V1 sub1_lazy = 7 [lazy = true]; 153} 154 155message TestVersioning_V2 { 156 enum Enumz_V2 { 157 ONE = 1; 158 TWO = 2; 159 THREE_V2 = 3; 160 } 161 message Sub1_V2 { 162 optional int32 sub1_int = 1; 163 optional string sub1_string = 2; 164 optional int32 sub1_int_v2 = 3; // New in v2. 165 optional string sub1_string_v2 = 4; // New in v2. 166 } 167 message Sub2_V2 { // New in v2. 168 optional int32 sub2_int = 1; 169 optional string sub2_string = 2; 170 } 171 172 optional int32 root_int = 1; 173 repeated Enumz_V2 enumz = 2; 174 optional string root_string = 3; 175 repeated string rep_string = 4; 176 optional Sub1_V2 sub1 = 5; 177 repeated Sub1_V2 sub1_rep = 6; 178 optional Sub1_V2 sub1_lazy = 7 [lazy = true]; 179 180 // New fields introduced in V2. 181 optional int32 root_int_v2 = 10; 182 optional Sub2_V2 sub2 = 11; 183 repeated Sub2_V2 sub2_rep = 12; 184 optional Sub2_V2 sub2_lazy = 13 [lazy = true]; 185} 186 187message DifferentPackages { 188 optional subpackage.Message subpackage_message = 1; 189 optional subpackage.Message.NestedMessage subpackage_nested_message = 2; 190 optional subpackage.Enum subpackage_enum = 3; 191 optional subpackage.Message.NestedEnum subpackage_nested_enum = 4; 192 193 optional .other_package.Message otherpackage_message = 5; 194 optional .other_package.Message.NestedMessage otherpackage_nested_message = 6; 195 optional .other_package.Enum otherpackage_enum = 7; 196 optional .other_package.Message.NestedEnum otherpackage_nested_enum = 8; 197} 198