Debian Codegraph @

test/core/event_engine/mock_event_engine.h

raw
1 // Copyright 2022 gRPC authors.
2 //
3 // Licensed under the Apache License, Version 2.0 (the "License");
4 // you may not use this file except in compliance with the License.
5 // You may obtain a copy of the License at
6 //
7 // http://www.apache.org/licenses/LICENSE-2.0
8 //
9 // Unless required by applicable law or agreed to in writing, software
10 // distributed under the License is distributed on an "AS IS" BASIS,
11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 // See the License for the specific language governing permissions and
13 // limitations under the License.
14
15 #ifndef GRPC_TEST_EVENT_ENGINE_MOCK_EVENT_ENGINE_H
16 #define GRPC_TEST_EVENT_ENGINE_MOCK_EVENT_ENGINE_H
17
18 #include <chrono>
19 #include <memory>
20
21 #include "absl/functional/any_invocable.h"
22 #include "absl/status/status.h"
23 #include "absl/status/statusor.h"
24 #include "gmock/gmock.h"
25
26 #include <grpc/event_engine/endpoint_config.h>
27 #include <grpc/event_engine/event_engine.h>
28 #include <grpc/event_engine/memory_allocator.h>
29
30 namespace grpc_event_engine {
31 namespace experimental {
32
33 class MockEventEngine : public EventEngine {
34 public:
35 MOCK_METHOD(
36 absl::StatusOr<std::unique_ptr<Listener>>, CreateListener,
37 (Listener::AcceptCallback on_accept,
38 absl::AnyInvocable<void(absl::Status)> on_shutdown,
39 const EndpointConfig& config,
40 std::unique_ptr<MemoryAllocatorFactory> memory_allocator_factory));
41 MOCK_METHOD(ConnectionHandle, Connect,
42 (OnConnectCallback on_connect, const ResolvedAddress& addr,
43 const EndpointConfig& args, MemoryAllocator memory_allocator,
44 Duration timeout));
45 MOCK_METHOD(bool, CancelConnect, (ConnectionHandle handle));
46 MOCK_METHOD(bool, IsWorkerThread, ());
47 MOCK_METHOD(std::unique_ptr<DNSResolver>, GetDNSResolver,
48 (const DNSResolver::ResolverOptions& options));
49 MOCK_METHOD(void, Run, (Closure * closure));
50 MOCK_METHOD(void, Run, (absl::AnyInvocable<void()> closure));
51 MOCK_METHOD(TaskHandle, RunAfter, (Duration when, Closure* closure));
52 MOCK_METHOD(TaskHandle, RunAfter,
53 (Duration when, absl::AnyInvocable<void()> closure));
54 MOCK_METHOD(bool, Cancel, (TaskHandle handle));
55 };
56
57 } // namespace experimental
58 } // namespace grpc_event_engine
59
60 #endif