1 /*
2  * Copyright (C) 2018 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 <gui/IGraphicBufferProducer.h>
22 
23 #include <utils/RefBase.h>
24 
25 namespace android {
26 namespace mock {
27 
28 class GraphicBufferProducer : public BnGraphicBufferProducer, public virtual android::RefBase {
29 public:
30     GraphicBufferProducer();
31     ~GraphicBufferProducer() override;
32 
33     MOCK_METHOD2(requestBuffer, status_t(int, sp<GraphicBuffer>*));
34     MOCK_METHOD1(setMaxDequeuedBufferCount, status_t(int));
35     MOCK_METHOD1(setAsyncMode, status_t(bool));
36     MOCK_METHOD8(dequeueBuffer,
37                  status_t(int*, sp<Fence>*, uint32_t, uint32_t, PixelFormat, uint64_t, uint64_t*,
38                           FrameEventHistoryDelta*));
39     MOCK_METHOD1(detachBuffer, status_t(int));
40     MOCK_METHOD2(detachNextBuffer, status_t(sp<GraphicBuffer>*, sp<Fence>*));
41     MOCK_METHOD2(attachBuffer, status_t(int*, const sp<GraphicBuffer>&));
42     MOCK_METHOD3(queueBuffer, status_t(int, const QueueBufferInput&, QueueBufferOutput*));
43     MOCK_METHOD2(cancelBuffer, status_t(int, const sp<Fence>&));
44     MOCK_METHOD2(query, int(int, int*));
45     MOCK_METHOD4(connect, status_t(const sp<IProducerListener>&, int, bool, QueueBufferOutput*));
46     MOCK_METHOD2(disconnect, status_t(int, DisconnectMode));
47     MOCK_METHOD1(setSidebandStream, status_t(const sp<NativeHandle>&));
48     MOCK_METHOD4(allocateBuffers, void(uint32_t, uint32_t, PixelFormat, uint64_t));
49     MOCK_METHOD1(allowAllocation, status_t(bool));
50     MOCK_METHOD1(setGenerationNumber, status_t(uint32_t));
51     MOCK_CONST_METHOD0(getConsumerName, String8());
52     MOCK_METHOD1(setSharedBufferMode, status_t(bool));
53     MOCK_METHOD1(setAutoRefresh, status_t(bool));
54     MOCK_METHOD1(setDequeueTimeout, status_t(nsecs_t));
55     MOCK_METHOD3(getLastQueuedBuffer, status_t(sp<GraphicBuffer>*, sp<Fence>*, float[16]));
56     MOCK_METHOD1(getFrameTimestamps, void(FrameEventHistoryDelta*));
57     MOCK_CONST_METHOD1(getUniqueId, status_t(uint64_t*));
58     MOCK_CONST_METHOD1(getConsumerUsage, status_t(uint64_t*));
59 };
60 
61 } // namespace mock
62 } // namespace android
63