xref: /aosp_15_r20/external/grpc-grpc/test/cpp/interop/http2_client.h (revision cc02d7e222339f7a4f6ba5f422e6413f4bd931f2)
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 
27 #include "src/proto/grpc/testing/messages.pb.h"
28 #include "src/proto/grpc/testing/test.grpc.pb.h"
29 
30 namespace grpc {
31 namespace testing {
32 
33 class Http2Client {
34  public:
35   explicit Http2Client(const std::shared_ptr<Channel>& channel);
~Http2Client()36   ~Http2Client() {}
37 
38   bool DoRstAfterHeader();
39   bool DoRstAfterData();
40   bool DoRstDuringData();
41   bool DoGoaway();
42   bool DoPing();
43   bool DoMaxStreams();
44 
45  private:
46   class ServiceStub {
47    public:
48     explicit ServiceStub(const std::shared_ptr<Channel>& channel);
49 
50     TestService::Stub* Get();
51 
52    private:
53     std::unique_ptr<TestService::Stub> stub_;
54     std::shared_ptr<Channel> channel_;
55   };
56 
57   void MaxStreamsWorker(const std::shared_ptr<grpc::Channel>& channel);
58   bool AssertStatusCode(const Status& s, StatusCode expected_code);
59   Status SendUnaryCall(SimpleResponse* response);
60   SimpleRequest BuildDefaultRequest();
61   ServiceStub serviceStub_;
62   std::shared_ptr<Channel> channel_;
63   SimpleRequest defaultRequest_;
64 };
65 
66 }  // namespace testing
67 }  // namespace grpc
68 
69 #endif  // GRPC_TEST_CPP_INTEROP_HTTP2_CLIENT_H
70