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 51enum VeryNegativeEnum { 52 DEF = 0; 53 VAL = -2147483648; 54} 55 56message EveryField { 57 optional int32 field_int32 = 1; 58 optional int64 field_int64 = 2; 59 optional uint32 field_uint32 = 3; 60 optional uint64 field_uint64 = 4; 61 optional sint32 field_sint32 = 5; 62 optional sint64 field_sint64 = 6; 63 optional fixed32 field_fixed32 = 7; 64 optional fixed64 field_fixed64 = 8; 65 optional sfixed32 field_sfixed32 = 9; 66 optional sfixed64 field_sfixed64 = 10; 67 optional float field_float = 11; 68 optional double field_double = 12; 69 optional bool field_bool = 13; 70 repeated EveryField field_nested = 14; 71 72 optional SmallEnum small_enum = 51; 73 optional SignedEnum signed_enum = 52; 74 optional BigEnum big_enum = 53; 75 optional VeryNegativeEnum very_negative_enum = 54; 76 77 optional string field_string = 500; 78 optional bytes field_bytes = 505; 79 80 enum NestedEnum { 81 PING = 1; 82 PONG = 2; 83 } 84 optional NestedEnum nested_enum = 600; 85 86 repeated string repeated_string = 700; 87 repeated fixed64 repeated_fixed64 = 701; 88 repeated sfixed32 repeated_sfixed32 = 702; 89 90 repeated int32 repeated_int32 = 999; 91} 92 93message NestedA { 94 message NestedB { 95 message NestedC { 96 optional int32 value_c = 1; 97 } 98 optional NestedC value_b = 1; 99 } 100 repeated NestedB repeated_a = 2; 101 optional NestedB.NestedC super_nested = 3; 102} 103 104message CamelCaseFields { 105 // To check that any reasonable name converts to camel case correctly. 106 optional bool foo_bar_baz = 1; 107 optional bool barBaz = 2; 108 optional bool MooMoo = 3; 109 optional bool URLEncoder = 4; 110 optional bool XMap = 5; 111 optional bool UrLE_nco__der = 6; 112 optional bool __bigBang = 7; 113 optional bool U2 = 8; 114 optional bool bangBig__ = 9; 115} 116 117message PackedRepeatedFields { 118 repeated int32 field_int32 = 1 [packed = true]; 119 repeated int64 field_int64 = 4 [packed = true]; 120 repeated uint32 field_uint32 = 5 [packed = true]; 121 repeated uint64 field_uint64 = 6 [packed = true]; 122 // Repeated packed Zig-zag fields are currently unsupported by our protoc 123 // plugin. 124 // repeated sint32 field_sint32 = 7 [packed = true]; 125 // repeated sint64 field_sint64 = 8 [packed = true]; 126 repeated fixed32 field_fixed32 = 2 [packed = true]; 127 repeated fixed64 field_fixed64 = 9 [packed = true]; 128 repeated sfixed32 field_sfixed32 = 10 [packed = true]; 129 repeated sfixed64 field_sfixed64 = 3 [packed = true]; 130 repeated float field_float = 11 [packed = true]; 131 repeated double field_double = 12 [packed = true]; 132 // Repeated (even non-packed) bool fields are currently unsupported by our 133 // protoc plugin. 134 // repeated bool field_bool = 13 [packed = true]; 135 repeated SmallEnum small_enum = 51 [packed = true]; 136 repeated SignedEnum signed_enum = 52 [packed = true]; 137 repeated BigEnum big_enum = 53 [packed = true]; 138} 139 140// The following two messages are for testing that unknown fields being 141// preserved in the decode->reencode path. 142 143message TestVersioning_V1 { 144 enum Enumz_V1 { 145 ONE = 1; 146 TWO = 2; 147 } 148 message Sub1_V1 { 149 optional int32 sub1_int = 1; 150 optional string sub1_string = 2; 151 } 152 optional int32 root_int = 1; 153 repeated Enumz_V1 enumz = 2; 154 optional string root_string = 3; 155 repeated string rep_string = 4; 156 optional Sub1_V1 sub1 = 5; 157 repeated Sub1_V1 sub1_rep = 6; 158 optional Sub1_V1 sub1_lazy = 7 [lazy = true]; 159} 160 161message TestVersioning_V2 { 162 enum Enumz_V2 { 163 ONE = 1; 164 TWO = 2; 165 THREE_V2 = 3; 166 } 167 message Sub1_V2 { 168 optional int32 sub1_int = 1; 169 optional string sub1_string = 2; 170 optional int32 sub1_int_v2 = 3; // New in v2. 171 optional string sub1_string_v2 = 4; // New in v2. 172 } 173 message Sub2_V2 { // New in v2. 174 optional int32 sub2_int = 1; 175 optional string sub2_string = 2; 176 } 177 178 optional int32 root_int = 1; 179 repeated Enumz_V2 enumz = 2; 180 optional string root_string = 3; 181 repeated string rep_string = 4; 182 optional Sub1_V2 sub1 = 5; 183 repeated Sub1_V2 sub1_rep = 6; 184 optional Sub1_V2 sub1_lazy = 7 [lazy = true]; 185 186 // New fields introduced in V2. 187 optional int32 root_int_v2 = 10; 188 optional Sub2_V2 sub2 = 11; 189 repeated Sub2_V2 sub2_rep = 12; 190 optional Sub2_V2 sub2_lazy = 13 [lazy = true]; 191} 192 193message DifferentPackages { 194 optional subpackage.Message subpackage_message = 1; 195 optional subpackage.Message.NestedMessage subpackage_nested_message = 2; 196 optional subpackage.Enum subpackage_enum = 3; 197 optional subpackage.Message.NestedEnum subpackage_nested_enum = 4; 198 199 optional .other_package.Message otherpackage_message = 5; 200 optional .other_package.Message.NestedMessage otherpackage_nested_message = 6; 201 optional .other_package.Enum otherpackage_enum = 7; 202 optional .other_package.Message.NestedEnum otherpackage_nested_enum = 8; 203} 204