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"; 22 23// This file contains comprehensive set of supported message structures and 24// data types. Unit tests depends on the plugin-processed version of this file. 25 26// Tests importing message definition from another proto file. 27message TransgalacticParcel { 28 optional TransgalacticMessage message = 1; 29 optional string tracking_code = 2; 30 optional TransgalacticMessage.MessageType message_type = 3; 31} 32 33enum SmallEnum { 34 TO_BE = 1; 35 NOT_TO_BE = 0; 36} 37 38enum SignedEnum { 39 POSITIVE = 1; 40 NEUTRAL = 0; 41 NEGATIVE = -1; 42} 43 44enum BigEnum { 45 BEGIN = 10; 46 END = 100500; 47} 48 49message EveryField { 50 optional int32 field_int32 = 1; 51 optional int64 field_int64 = 2; 52 optional uint32 field_uint32 = 3; 53 optional uint64 field_uint64 = 4; 54 optional sint32 field_sint32 = 5; 55 optional sint64 field_sint64 = 6; 56 optional fixed32 field_fixed32 = 7; 57 optional fixed64 field_fixed64 = 8; 58 optional sfixed32 field_sfixed32 = 9; 59 optional sfixed64 field_sfixed64 = 10; 60 optional float field_float = 11; 61 optional double field_double = 12; 62 optional bool field_bool = 13; 63 repeated EveryField field_nested = 14; 64 65 optional SmallEnum small_enum = 51; 66 optional SignedEnum signed_enum = 52; 67 optional BigEnum big_enum = 53; 68 69 optional string field_string = 500; 70 optional bytes field_bytes = 505; 71 72 enum NestedEnum { 73 PING = 1; 74 PONG = 2; 75 } 76 optional NestedEnum nested_enum = 600; 77 78 repeated int32 repeated_int32 = 999; 79} 80 81message NestedA { 82 message NestedB { 83 message NestedC { optional int32 value_c = 1; } 84 optional NestedC value_b = 1; 85 } 86 repeated NestedB repeated_a = 2; 87 optional NestedB.NestedC super_nested = 3; 88} 89 90message CamelCaseFields { 91 // To check that any reasonable name converts to camel case correctly. 92 optional bool foo_bar_baz = 1; 93 optional bool barBaz = 2; 94 optional bool MooMoo = 3; 95 optional bool URLEncoder = 4; 96 optional bool XMap = 5; 97 optional bool UrLE_nco__der = 6; 98 optional bool __bigBang = 7; 99 optional bool U2 = 8; 100 optional bool bangBig__ = 9; 101} 102 103message PackedRepeatedFields { 104 repeated int32 field_int32 = 1 [packed = true]; 105 repeated int64 field_int64 = 4 [packed = true]; 106 repeated uint32 field_uint32 = 5 [packed = true]; 107 repeated uint64 field_uint64 = 6 [packed = true]; 108 // Repeated packed Zig-zag fields are currently unsupported by our protoc 109 // plugin. 110 // repeated sint32 field_sint32 = 7 [packed = true]; 111 // repeated sint64 field_sint64 = 8 [packed = true]; 112 repeated fixed32 field_fixed32 = 2 [packed = true]; 113 repeated fixed64 field_fixed64 = 9 [packed = true]; 114 repeated sfixed32 field_sfixed32 = 10 [packed = true]; 115 repeated sfixed64 field_sfixed64 = 3 [packed = true]; 116 repeated float field_float = 11 [packed = true]; 117 repeated double field_double = 12 [packed = true]; 118 // Repeated (even non-packed) bool fields are currently unsupported by our 119 // protoc plugin. 120 // repeated bool field_bool = 13 [packed = true]; 121 repeated SmallEnum small_enum = 51 [packed = true]; 122 repeated SignedEnum signed_enum = 52 [packed = true]; 123 repeated BigEnum big_enum = 53 [packed = true]; 124} 125 126// The following two messages are for testing that unknown fields being 127// preserved in the decode->reencode path. 128 129message TestVersioning_V1 { 130 enum Enumz_V1 { 131 ONE = 1; 132 TWO = 2; 133 } 134 message Sub1_V1 { 135 optional int32 sub1_int = 1; 136 optional string sub1_string = 2; 137 } 138 optional int32 root_int = 1; 139 repeated Enumz_V1 enumz = 2; 140 optional string root_string = 3; 141 repeated string rep_string = 4; 142 optional Sub1_V1 sub1 = 5; 143 repeated Sub1_V1 sub1_rep = 6; 144 optional Sub1_V1 sub1_lazy = 7 [lazy = true]; 145} 146 147message TestVersioning_V2 { 148 enum Enumz_V2 { 149 ONE = 1; 150 TWO = 2; 151 THREE_V2 = 3; 152 } 153 message Sub1_V2 { 154 optional int32 sub1_int = 1; 155 optional string sub1_string = 2; 156 optional int32 sub1_int_v2 = 3; // New in v2. 157 optional string sub1_string_v2 = 4; // New in v2. 158 } 159 message Sub2_V2 { // New in v2. 160 optional int32 sub2_int = 1; 161 optional string sub2_string = 2; 162 } 163 164 optional int32 root_int = 1; 165 repeated Enumz_V2 enumz = 2; 166 optional string root_string = 3; 167 repeated string rep_string = 4; 168 optional Sub1_V2 sub1 = 5; 169 repeated Sub1_V2 sub1_rep = 6; 170 optional Sub1_V2 sub1_lazy = 7 [lazy = true]; 171 172 // New fields introduced in V2. 173 optional int32 root_int_v2 = 10; 174 optional Sub2_V2 sub2 = 11; 175 repeated Sub2_V2 sub2_rep = 12; 176 optional Sub2_V2 sub2_lazy = 13 [lazy = true]; 177} 178