1 /*
2  *
3  * Copyright 2016 gRPC authors.
4  *
5  * Licensed under the Apache License, Version 2.0 (the "License");
6  * you may not use this file except in compliance with the License.
7  * You may obtain a copy of the License at
8  *
9  *     http://www.apache.org/licenses/LICENSE-2.0
10  *
11  * Unless required by applicable law or agreed to in writing, software
12  * distributed under the License is distributed on an "AS IS" BASIS,
13  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  * See the License for the specific language governing permissions and
15  * limitations under the License.
16  *
17  */
18 
19 #ifndef GRPC_TEST_CPP_INTEROP_HTTP2_CLIENT_H
20 #define GRPC_TEST_CPP_INTEROP_HTTP2_CLIENT_H
21 
22 #include <memory>
23 
24 #include <grpc/grpc.h>
25 #include <grpcpp/channel.h>
26 #include "src/proto/grpc/testing/messages.pb.h"
27 #include "src/proto/grpc/testing/test.grpc.pb.h"
28 
29 namespace grpc {
30 namespace testing {
31 
32 class Http2Client {
33  public:
34   explicit Http2Client(const std::shared_ptr<Channel>& channel);
~Http2Client()35   ~Http2Client() {}
36 
37   bool DoRstAfterHeader();
38   bool DoRstAfterData();
39   bool DoRstDuringData();
40   bool DoGoaway();
41   bool DoPing();
42   bool DoMaxStreams();
43 
44  private:
45   class ServiceStub {
46    public:
47     ServiceStub(const std::shared_ptr<Channel>& channel);
48 
49     TestService::Stub* Get();
50 
51    private:
52     std::unique_ptr<TestService::Stub> stub_;
53     std::shared_ptr<Channel> channel_;
54   };
55 
56   void MaxStreamsWorker(const std::shared_ptr<grpc::Channel>& channel);
57   bool AssertStatusCode(const Status& s, StatusCode expected_code);
58   Status SendUnaryCall(SimpleResponse* response);
59   SimpleRequest BuildDefaultRequest();
60   ServiceStub serviceStub_;
61   std::shared_ptr<Channel> channel_;
62   SimpleRequest defaultRequest_;
63 };
64 
65 }  // namespace testing
66 }  // namespace grpc
67 
68 #endif  // GRPC_TEST_CPP_INTEROP_HTTP2_CLIENT_H
69