• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2025 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 
17 #pragma once
18 
19 #include "gmock/gmock.h"
20 
21 #include "chre/util/system/message_common.h"
22 #include "chre/util/system/message_router.h"
23 
24 #include "pw_allocator/unique_ptr.h"
25 #include "pw_function/function.h"
26 
27 namespace chre::message {
28 
29 class MockMessageHubCallback : public MessageRouter::MessageHubCallback {
30  public:
31   MOCK_METHOD(bool, onMessageReceived,
32               (pw::UniquePtr<std::byte[]> && data, uint32_t messageType,
33                uint32_t messagePermissions, const Session &session,
34                bool sentBySessionInitiator),
35               (override));
36   MOCK_METHOD(void, onSessionOpenRequest, (const Session &session), (override));
37   MOCK_METHOD(void, onSessionOpened, (const Session &session), (override));
38   MOCK_METHOD(void, onSessionClosed, (const Session &session, Reason reason),
39               (override));
40   MOCK_METHOD(void, forEachEndpoint,
41               (const pw::Function<bool(const EndpointInfo &)> &function),
42               (override));
43   MOCK_METHOD(std::optional<EndpointInfo>, getEndpointInfo,
44               (EndpointId endpointId), (override));
45   MOCK_METHOD(std::optional<EndpointId>, getEndpointForService,
46               (const char *serviceDescriptor), (override));
47   MOCK_METHOD(bool, doesEndpointHaveService,
48               (EndpointId endpointId, const char *serviceDescriptor),
49               (override));
50   MOCK_METHOD(
51       void, forEachService,
52       (const pw::Function<bool(const EndpointInfo &,
53                                const message::ServiceInfo &)> &function),
54       (override));
55   MOCK_METHOD(void, onHubRegistered, (const MessageHubInfo &), (override));
56   MOCK_METHOD(void, onHubUnregistered, (MessageHubId), (override));
57   MOCK_METHOD(void, onEndpointRegistered,
58               (MessageHubId messageHubId, EndpointId endpointId), (override));
59   MOCK_METHOD(void, onEndpointUnregistered,
60               (MessageHubId messageHubId, EndpointId endpointId), (override));
61 
pw_recycle()62   void pw_recycle() override {
63     delete this;
64   }
65 };
66 
67 }  // namespace chre::message
68