1 /* 2 * Copyright 2019 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 #include <system/window.h> 21 #include <ui/ANativeObjectBase.h> 22 #include <ui/GraphicTypes.h> 23 #include <ui/PixelFormat.h> 24 25 namespace android::compositionengine::mock { 26 27 /* ------------------------------------------------------------------------ 28 * Mock NativeWindow 29 * 30 * An intentionally simplified Mock which implements a minimal subset of the full 31 * ANativeWindow interface. 32 */ 33 class NativeWindow : public ANativeObjectBase<ANativeWindow, NativeWindow, RefBase> { 34 public: 35 NativeWindow(); 36 ~NativeWindow(); 37 38 MOCK_METHOD1(setSwapInterval, int(int)); 39 MOCK_METHOD2(dequeueBuffer, int(struct ANativeWindowBuffer**, int*)); 40 MOCK_METHOD2(cancelBuffer, int(struct ANativeWindowBuffer*, int)); 41 MOCK_METHOD2(queueBuffer, int(struct ANativeWindowBuffer*, int)); 42 MOCK_CONST_METHOD2(query, int(int, int*)); 43 MOCK_METHOD1(connect, int(int)); 44 MOCK_METHOD1(disconnect, int(int)); 45 MOCK_METHOD1(lockBuffer_DEPRECATED, int(struct ANativeWindowBuffer*)); 46 MOCK_METHOD1(setBuffersFormat, int(PixelFormat)); 47 MOCK_METHOD1(setBuffersDataSpace, int(ui::Dataspace)); 48 MOCK_METHOD1(setUsage, int(uint64_t)); 49 }; 50 51 } // namespace android::compositionengine::mock 52