xref: /aosp_15_r20/external/perfetto/src/tracing/test/mock_producer_endpoint.h (revision 6dbdd20afdafa5e3ca9b8809fa73465d530080dc)
1 /*
2  * Copyright (C) 2022 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 #ifndef SRC_TRACING_TEST_MOCK_PRODUCER_ENDPOINT_H_
18 #define SRC_TRACING_TEST_MOCK_PRODUCER_ENDPOINT_H_
19 
20 #include "perfetto/ext/tracing/core/tracing_service.h"
21 #include "protos/perfetto/common/data_source_descriptor.gen.h"
22 #include "test/gtest_and_gmock.h"
23 
24 namespace perfetto {
25 
26 class MockProducerEndpoint : public TracingService::ProducerEndpoint {
27  public:
28   MOCK_METHOD(void, Disconnect, (), (override));
29   MOCK_METHOD(void,
30               RegisterDataSource,
31               (const DataSourceDescriptor&),
32               (override));
33   MOCK_METHOD(void,
34               UpdateDataSource,
35               (const DataSourceDescriptor&),
36               (override));
37   MOCK_METHOD(void, UnregisterDataSource, (const std::string&), (override));
38   MOCK_METHOD(void, RegisterTraceWriter, (uint32_t, uint32_t), (override));
39   MOCK_METHOD(void, UnregisterTraceWriter, (uint32_t), (override));
40   MOCK_METHOD(void,
41               CommitData,
42               (const CommitDataRequest&, CommitDataCallback),
43               (override));
44   MOCK_METHOD(SharedMemory*, shared_memory, (), (const, override));
45   MOCK_METHOD(size_t, shared_buffer_page_size_kb, (), (const, override));
46   MOCK_METHOD(std::unique_ptr<TraceWriter>,
47               CreateTraceWriter,
48               (BufferID, BufferExhaustedPolicy),
49               (override));
50   MOCK_METHOD(SharedMemoryArbiter*, MaybeSharedMemoryArbiter, (), (override));
51   MOCK_METHOD(bool, IsShmemProvidedByProducer, (), (const, override));
52   MOCK_METHOD(void, NotifyFlushComplete, (FlushRequestID), (override));
53   MOCK_METHOD(void,
54               NotifyDataSourceStarted,
55               (DataSourceInstanceID),
56               (override));
57   MOCK_METHOD(void,
58               NotifyDataSourceStopped,
59               (DataSourceInstanceID),
60               (override));
61   MOCK_METHOD(void,
62               ActivateTriggers,
63               (const std::vector<std::string>&),
64               (override));
65   MOCK_METHOD(void, Sync, (std::function<void()>), (override));
66 };
67 
68 }  // namespace perfetto
69 
70 #endif  // SRC_TRACING_TEST_MOCK_PRODUCER_ENDPOINT_H_
71