cmd/protoc-gen-go-grpc: change test files to exercise name rewriting

Change the service and method names in grpc.proto to not use camel-case,
to make it explicit where rewriting occurs in the generated code.

Change-Id: I9e4a851097b0ee14817a589f5f959adcc5a14fe3
Reviewed-on: https://go-review.googlesource.com/c/153657
Reviewed-by: Joe Tsai <thebrokentoaster@gmail.com>
diff --git a/cmd/protoc-gen-go-grpc/testdata/grpc/grpc.pb.go b/cmd/protoc-gen-go-grpc/testdata/grpc/grpc.pb.go
index 7edc978..ea2e7a7 100644
--- a/cmd/protoc-gen-go-grpc/testdata/grpc/grpc.pb.go
+++ b/cmd/protoc-gen-go-grpc/testdata/grpc/grpc.pb.go
@@ -121,21 +121,21 @@
 }
 
 var fileDescriptor_81ea47a3f88c2082 = []byte{
-	// 211 bytes of a gzipped FileDescriptorProto
-	0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0xe2, 0x4f, 0x2f, 0x2a, 0x48,
-	0xd6, 0x07, 0x11, 0x7a, 0x05, 0x45, 0xf9, 0x25, 0xf9, 0x42, 0xc2, 0xe9, 0xf9, 0x60, 0x06, 0x84,
-	0x9b, 0xac, 0x07, 0x92, 0x52, 0xe2, 0xe4, 0x62, 0x0f, 0x4a, 0x2d, 0x2c, 0x4d, 0x2d, 0x2e, 0x51,
-	0xe2, 0xe2, 0xe2, 0x08, 0x4a, 0x2d, 0x2e, 0xc8, 0xcf, 0x2b, 0x4e, 0x35, 0xda, 0xc8, 0xc4, 0xc5,
-	0x12, 0x92, 0x5a, 0x5c, 0x22, 0xe4, 0xc1, 0xc5, 0x19, 0x9a, 0x97, 0x58, 0x54, 0xe9, 0x9c, 0x98,
-	0x93, 0x23, 0x24, 0xa3, 0x87, 0xc5, 0x08, 0x3d, 0xa8, 0x7e, 0x29, 0x59, 0x1c, 0xb2, 0x10, 0x23,
-	0x85, 0xbc, 0xb9, 0xb8, 0x5c, 0xf2, 0xcb, 0xf3, 0x8a, 0x4b, 0x8a, 0x52, 0x13, 0x73, 0x29, 0x32,
-	0xca, 0x80, 0x51, 0xc8, 0x93, 0x8b, 0x23, 0xb4, 0x80, 0x0a, 0x46, 0x69, 0x30, 0x0a, 0xb9, 0x73,
-	0xb1, 0x38, 0x65, 0xa6, 0x64, 0x52, 0x68, 0x8c, 0x01, 0xa3, 0x93, 0x7d, 0x94, 0x6d, 0x7a, 0x66,
-	0x49, 0x46, 0x69, 0x92, 0x5e, 0x72, 0x7e, 0xae, 0x7e, 0x7a, 0x7e, 0x4e, 0x62, 0x5e, 0xba, 0x3e,
-	0x58, 0x75, 0x52, 0x69, 0x9a, 0x7e, 0x99, 0x91, 0x7e, 0x72, 0x6e, 0x0a, 0x84, 0x9f, 0xac, 0x9b,
-	0x9e, 0x9a, 0xa7, 0x9b, 0x9e, 0xaf, 0x5f, 0x92, 0x5a, 0x5c, 0x92, 0x92, 0x58, 0x92, 0x08, 0x8e,
-	0xa6, 0x24, 0x36, 0xb0, 0xa4, 0x31, 0x20, 0x00, 0x00, 0xff, 0xff, 0x29, 0xd5, 0xc4, 0xd0, 0xba,
-	0x01, 0x00, 0x00,
+	// 218 bytes of a gzipped FileDescriptorProto
+	0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xac, 0xd1, 0x3d, 0x4b, 0x04, 0x31,
+	0x10, 0x06, 0x60, 0xd6, 0x42, 0xbd, 0x41, 0x39, 0x88, 0x9d, 0x68, 0x73, 0x95, 0xcd, 0x25, 0xc7,
+	0x59, 0x8b, 0x60, 0x27, 0x88, 0xc8, 0x96, 0x36, 0x4b, 0x3e, 0xc6, 0x18, 0xd8, 0xcd, 0xc4, 0x7c,
+	0xac, 0xf8, 0x13, 0xfd, 0x57, 0xb2, 0x59, 0x4b, 0xad, 0x6e, 0x9b, 0x90, 0x97, 0x77, 0x78, 0x8a,
+	0x19, 0x58, 0xdb, 0x18, 0xb4, 0x98, 0x1e, 0x1e, 0x22, 0x65, 0x62, 0x17, 0x96, 0xea, 0x67, 0x8e,
+	0x9a, 0x4f, 0xd5, 0x66, 0x05, 0x27, 0x2d, 0x7e, 0x14, 0x4c, 0x79, 0x03, 0x70, 0xda, 0x62, 0x0a,
+	0xe4, 0x13, 0xee, 0xbf, 0x8f, 0xe0, 0x2c, 0x63, 0xca, 0x5d, 0xc2, 0x38, 0x3a, 0x8d, 0xec, 0x11,
+	0xa0, 0x78, 0x19, 0xbf, 0x3a, 0x2d, 0xfb, 0x9e, 0x5d, 0xf1, 0x3f, 0x2c, 0xfe, 0x0b, 0x5d, 0x5e,
+	0xff, 0xd3, 0xce, 0x36, 0x7b, 0x81, 0xb5, 0xa1, 0x4f, 0x9f, 0x72, 0x44, 0x39, 0x1c, 0xee, 0xed,
+	0x1a, 0xf6, 0x0c, 0xe7, 0x25, 0x2c, 0xe5, 0xdd, 0x34, 0xec, 0x09, 0x56, 0xca, 0x19, 0xb7, 0x84,
+	0xb5, 0x6b, 0x1e, 0xee, 0x5f, 0xef, 0xac, 0xcb, 0xef, 0x45, 0x71, 0x4d, 0x83, 0xb0, 0xd4, 0x4b,
+	0x6f, 0x45, 0x9d, 0x56, 0xe5, 0x4d, 0x8c, 0x7b, 0xa1, 0x07, 0x33, 0x67, 0xbd, 0xb5, 0xe8, 0xb7,
+	0x96, 0xc4, 0xb4, 0x7a, 0x23, 0xb3, 0xac, 0xe7, 0x53, 0xc7, 0xb5, 0xbc, 0xfd, 0x09, 0x00, 0x00,
+	0xff, 0xff, 0x74, 0x8e, 0x77, 0x1d, 0xd2, 0x01, 0x00, 0x00,
 }
 
 func init() {
diff --git a/cmd/protoc-gen-go-grpc/testdata/grpc/grpc.proto b/cmd/protoc-gen-go-grpc/testdata/grpc/grpc.proto
index c484ebe..36d61ce 100644
--- a/cmd/protoc-gen-go-grpc/testdata/grpc/grpc.proto
+++ b/cmd/protoc-gen-go-grpc/testdata/grpc/grpc.proto
@@ -11,15 +11,17 @@
 message Request {}
 message Response {}
 
-service Test {
-  rpc UnaryCall(Request) returns (Response);
+// Service and method names chosen to exercise the distinction between the
+// proto definition names and the CamelCased Go names.
+service test_service {
+  rpc unary_call(Request) returns (Response);
 
   // This RPC streams from the server only.
-  rpc Downstream(Request) returns (stream Response);
+  rpc downstream_call(Request) returns (stream Response);
 
   // This RPC streams from the client.
-  rpc Upstream(stream Request) returns (Response);
+  rpc upstream_call(stream Request) returns (Response);
 
   // This one streams in both directions.
-  rpc Bidi(stream Request) returns (stream Response);
+  rpc bidi_call(stream Request) returns (stream Response);
 }
diff --git a/cmd/protoc-gen-go-grpc/testdata/grpc/grpc_grpc.pb.go b/cmd/protoc-gen-go-grpc/testdata/grpc/grpc_grpc.pb.go
index 189397a..48c4abd 100644
--- a/cmd/protoc-gen-go-grpc/testdata/grpc/grpc_grpc.pb.go
+++ b/cmd/protoc-gen-go-grpc/testdata/grpc/grpc_grpc.pb.go
@@ -15,42 +15,42 @@
 // is compatible with the grpc package it is being compiled against.
 const _ = grpc.SupportPackageIsVersion4
 
-// TestClient is the client API for Test service.
+// TestServiceClient is the client API for TestService service.
 //
 // For semantics around ctx use and closing/ending streaming RPCs, please refer to https://godoc.org/google.golang.org/grpc#ClientConn.NewStream.
-type TestClient interface {
+type TestServiceClient interface {
 	UnaryCall(ctx context.Context, in *Request, opts ...grpc.CallOption) (*Response, error)
 	// This RPC streams from the server only.
-	Downstream(ctx context.Context, in *Request, opts ...grpc.CallOption) (Test_DownstreamClient, error)
+	DownstreamCall(ctx context.Context, in *Request, opts ...grpc.CallOption) (TestService_DownstreamCallClient, error)
 	// This RPC streams from the client.
-	Upstream(ctx context.Context, opts ...grpc.CallOption) (Test_UpstreamClient, error)
+	UpstreamCall(ctx context.Context, opts ...grpc.CallOption) (TestService_UpstreamCallClient, error)
 	// This one streams in both directions.
-	Bidi(ctx context.Context, opts ...grpc.CallOption) (Test_BidiClient, error)
+	BidiCall(ctx context.Context, opts ...grpc.CallOption) (TestService_BidiCallClient, error)
 }
 
-type testClient struct {
+type testServiceClient struct {
 	cc *grpc.ClientConn
 }
 
-func NewTestClient(cc *grpc.ClientConn) TestClient {
-	return &testClient{cc}
+func NewTestServiceClient(cc *grpc.ClientConn) TestServiceClient {
+	return &testServiceClient{cc}
 }
 
-func (c *testClient) UnaryCall(ctx context.Context, in *Request, opts ...grpc.CallOption) (*Response, error) {
+func (c *testServiceClient) UnaryCall(ctx context.Context, in *Request, opts ...grpc.CallOption) (*Response, error) {
 	out := new(Response)
-	err := c.cc.Invoke(ctx, "/goproto.protoc.grpc.Test/UnaryCall", in, out, opts...)
+	err := c.cc.Invoke(ctx, "/goproto.protoc.grpc.test_service/unary_call", in, out, opts...)
 	if err != nil {
 		return nil, err
 	}
 	return out, nil
 }
 
-func (c *testClient) Downstream(ctx context.Context, in *Request, opts ...grpc.CallOption) (Test_DownstreamClient, error) {
-	stream, err := c.cc.NewStream(ctx, &_Test_serviceDesc.Streams[0], "/goproto.protoc.grpc.Test/Downstream", opts...)
+func (c *testServiceClient) DownstreamCall(ctx context.Context, in *Request, opts ...grpc.CallOption) (TestService_DownstreamCallClient, error) {
+	stream, err := c.cc.NewStream(ctx, &_TestService_serviceDesc.Streams[0], "/goproto.protoc.grpc.test_service/downstream_call", opts...)
 	if err != nil {
 		return nil, err
 	}
-	x := &testDownstreamClient{stream}
+	x := &testServiceDownstreamCallClient{stream}
 	if err := x.ClientStream.SendMsg(in); err != nil {
 		return nil, err
 	}
@@ -60,16 +60,16 @@
 	return x, nil
 }
 
-type Test_DownstreamClient interface {
+type TestService_DownstreamCallClient interface {
 	Recv() (*Response, error)
 	grpc.ClientStream
 }
 
-type testDownstreamClient struct {
+type testServiceDownstreamCallClient struct {
 	grpc.ClientStream
 }
 
-func (x *testDownstreamClient) Recv() (*Response, error) {
+func (x *testServiceDownstreamCallClient) Recv() (*Response, error) {
 	m := new(Response)
 	if err := x.ClientStream.RecvMsg(m); err != nil {
 		return nil, err
@@ -77,30 +77,30 @@
 	return m, nil
 }
 
-func (c *testClient) Upstream(ctx context.Context, opts ...grpc.CallOption) (Test_UpstreamClient, error) {
-	stream, err := c.cc.NewStream(ctx, &_Test_serviceDesc.Streams[1], "/goproto.protoc.grpc.Test/Upstream", opts...)
+func (c *testServiceClient) UpstreamCall(ctx context.Context, opts ...grpc.CallOption) (TestService_UpstreamCallClient, error) {
+	stream, err := c.cc.NewStream(ctx, &_TestService_serviceDesc.Streams[1], "/goproto.protoc.grpc.test_service/upstream_call", opts...)
 	if err != nil {
 		return nil, err
 	}
-	x := &testUpstreamClient{stream}
+	x := &testServiceUpstreamCallClient{stream}
 	return x, nil
 }
 
-type Test_UpstreamClient interface {
+type TestService_UpstreamCallClient interface {
 	Send(*Request) error
 	CloseAndRecv() (*Response, error)
 	grpc.ClientStream
 }
 
-type testUpstreamClient struct {
+type testServiceUpstreamCallClient struct {
 	grpc.ClientStream
 }
 
-func (x *testUpstreamClient) Send(m *Request) error {
+func (x *testServiceUpstreamCallClient) Send(m *Request) error {
 	return x.ClientStream.SendMsg(m)
 }
 
-func (x *testUpstreamClient) CloseAndRecv() (*Response, error) {
+func (x *testServiceUpstreamCallClient) CloseAndRecv() (*Response, error) {
 	if err := x.ClientStream.CloseSend(); err != nil {
 		return nil, err
 	}
@@ -111,30 +111,30 @@
 	return m, nil
 }
 
-func (c *testClient) Bidi(ctx context.Context, opts ...grpc.CallOption) (Test_BidiClient, error) {
-	stream, err := c.cc.NewStream(ctx, &_Test_serviceDesc.Streams[2], "/goproto.protoc.grpc.Test/Bidi", opts...)
+func (c *testServiceClient) BidiCall(ctx context.Context, opts ...grpc.CallOption) (TestService_BidiCallClient, error) {
+	stream, err := c.cc.NewStream(ctx, &_TestService_serviceDesc.Streams[2], "/goproto.protoc.grpc.test_service/bidi_call", opts...)
 	if err != nil {
 		return nil, err
 	}
-	x := &testBidiClient{stream}
+	x := &testServiceBidiCallClient{stream}
 	return x, nil
 }
 
-type Test_BidiClient interface {
+type TestService_BidiCallClient interface {
 	Send(*Request) error
 	Recv() (*Response, error)
 	grpc.ClientStream
 }
 
-type testBidiClient struct {
+type testServiceBidiCallClient struct {
 	grpc.ClientStream
 }
 
-func (x *testBidiClient) Send(m *Request) error {
+func (x *testServiceBidiCallClient) Send(m *Request) error {
 	return x.ClientStream.SendMsg(m)
 }
 
-func (x *testBidiClient) Recv() (*Response, error) {
+func (x *testServiceBidiCallClient) Recv() (*Response, error) {
 	m := new(Response)
 	if err := x.ClientStream.RecvMsg(m); err != nil {
 		return nil, err
@@ -142,79 +142,79 @@
 	return m, nil
 }
 
-// TestServer is the server API for Test service.
-type TestServer interface {
+// TestServiceServer is the server API for TestService service.
+type TestServiceServer interface {
 	UnaryCall(context.Context, *Request) (*Response, error)
 	// This RPC streams from the server only.
-	Downstream(*Request, Test_DownstreamServer) error
+	DownstreamCall(*Request, TestService_DownstreamCallServer) error
 	// This RPC streams from the client.
-	Upstream(Test_UpstreamServer) error
+	UpstreamCall(TestService_UpstreamCallServer) error
 	// This one streams in both directions.
-	Bidi(Test_BidiServer) error
+	BidiCall(TestService_BidiCallServer) error
 }
 
-func RegisterTestServer(s *grpc.Server, srv TestServer) {
-	s.RegisterService(&_Test_serviceDesc, srv)
+func RegisterTestServiceServer(s *grpc.Server, srv TestServiceServer) {
+	s.RegisterService(&_TestService_serviceDesc, srv)
 }
 
-func _Test_UnaryCall_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
+func _TestService_UnaryCall_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
 	in := new(Request)
 	if err := dec(in); err != nil {
 		return nil, err
 	}
 	if interceptor == nil {
-		return srv.(TestServer).UnaryCall(ctx, in)
+		return srv.(TestServiceServer).UnaryCall(ctx, in)
 	}
 	info := &grpc.UnaryServerInfo{
 		Server:     srv,
-		FullMethod: "/goproto.protoc.grpc.Test/UnaryCall",
+		FullMethod: "/goproto.protoc.grpc.test_service/unary_call",
 	}
 	handler := func(ctx context.Context, req interface{}) (interface{}, error) {
-		return srv.(TestServer).UnaryCall(ctx, req.(*Request))
+		return srv.(TestServiceServer).UnaryCall(ctx, req.(*Request))
 	}
 	return interceptor(ctx, in, info, handler)
 }
 
-func _Test_Downstream_Handler(srv interface{}, stream grpc.ServerStream) error {
+func _TestService_DownstreamCall_Handler(srv interface{}, stream grpc.ServerStream) error {
 	m := new(Request)
 	if err := stream.RecvMsg(m); err != nil {
 		return err
 	}
-	return srv.(TestServer).Downstream(m, &testDownstreamServer{stream})
+	return srv.(TestServiceServer).DownstreamCall(m, &testServiceDownstreamCallServer{stream})
 }
 
-type Test_DownstreamServer interface {
+type TestService_DownstreamCallServer interface {
 	Send(*Response) error
 	grpc.ServerStream
 }
 
-type testDownstreamServer struct {
+type testServiceDownstreamCallServer struct {
 	grpc.ServerStream
 }
 
-func (x *testDownstreamServer) Send(m *Response) error {
+func (x *testServiceDownstreamCallServer) Send(m *Response) error {
 	return x.ServerStream.SendMsg(m)
 }
 
-func _Test_Upstream_Handler(srv interface{}, stream grpc.ServerStream) error {
-	return srv.(TestServer).Upstream(&testUpstreamServer{stream})
+func _TestService_UpstreamCall_Handler(srv interface{}, stream grpc.ServerStream) error {
+	return srv.(TestServiceServer).UpstreamCall(&testServiceUpstreamCallServer{stream})
 }
 
-type Test_UpstreamServer interface {
+type TestService_UpstreamCallServer interface {
 	SendAndClose(*Response) error
 	Recv() (*Request, error)
 	grpc.ServerStream
 }
 
-type testUpstreamServer struct {
+type testServiceUpstreamCallServer struct {
 	grpc.ServerStream
 }
 
-func (x *testUpstreamServer) SendAndClose(m *Response) error {
+func (x *testServiceUpstreamCallServer) SendAndClose(m *Response) error {
 	return x.ServerStream.SendMsg(m)
 }
 
-func (x *testUpstreamServer) Recv() (*Request, error) {
+func (x *testServiceUpstreamCallServer) Recv() (*Request, error) {
 	m := new(Request)
 	if err := x.ServerStream.RecvMsg(m); err != nil {
 		return nil, err
@@ -222,25 +222,25 @@
 	return m, nil
 }
 
-func _Test_Bidi_Handler(srv interface{}, stream grpc.ServerStream) error {
-	return srv.(TestServer).Bidi(&testBidiServer{stream})
+func _TestService_BidiCall_Handler(srv interface{}, stream grpc.ServerStream) error {
+	return srv.(TestServiceServer).BidiCall(&testServiceBidiCallServer{stream})
 }
 
-type Test_BidiServer interface {
+type TestService_BidiCallServer interface {
 	Send(*Response) error
 	Recv() (*Request, error)
 	grpc.ServerStream
 }
 
-type testBidiServer struct {
+type testServiceBidiCallServer struct {
 	grpc.ServerStream
 }
 
-func (x *testBidiServer) Send(m *Response) error {
+func (x *testServiceBidiCallServer) Send(m *Response) error {
 	return x.ServerStream.SendMsg(m)
 }
 
-func (x *testBidiServer) Recv() (*Request, error) {
+func (x *testServiceBidiCallServer) Recv() (*Request, error) {
 	m := new(Request)
 	if err := x.ServerStream.RecvMsg(m); err != nil {
 		return nil, err
@@ -248,29 +248,29 @@
 	return m, nil
 }
 
-var _Test_serviceDesc = grpc.ServiceDesc{
-	ServiceName: "goproto.protoc.grpc.Test",
-	HandlerType: (*TestServer)(nil),
+var _TestService_serviceDesc = grpc.ServiceDesc{
+	ServiceName: "goproto.protoc.grpc.test_service",
+	HandlerType: (*TestServiceServer)(nil),
 	Methods: []grpc.MethodDesc{
 		{
 			MethodName: "UnaryCall",
-			Handler:    _Test_UnaryCall_Handler,
+			Handler:    _TestService_UnaryCall_Handler,
 		},
 	},
 	Streams: []grpc.StreamDesc{
 		{
-			StreamName:    "Downstream",
-			Handler:       _Test_Downstream_Handler,
+			StreamName:    "DownstreamCall",
+			Handler:       _TestService_DownstreamCall_Handler,
 			ServerStreams: true,
 		},
 		{
-			StreamName:    "Upstream",
-			Handler:       _Test_Upstream_Handler,
+			StreamName:    "UpstreamCall",
+			Handler:       _TestService_UpstreamCall_Handler,
 			ClientStreams: true,
 		},
 		{
-			StreamName:    "Bidi",
-			Handler:       _Test_Bidi_Handler,
+			StreamName:    "BidiCall",
+			Handler:       _TestService_BidiCall_Handler,
 			ServerStreams: true,
 			ClientStreams: true,
 		},