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 "Scheduler/DispSync.h" 22 23 namespace android { 24 namespace mock { 25 26 class DispSync : public android::DispSync { 27 public: 28 DispSync(); 29 ~DispSync() override; 30 31 MOCK_METHOD0(reset, void()); 32 MOCK_METHOD1(addPresentFence, bool(const std::shared_ptr<FenceTime>&)); 33 MOCK_METHOD0(beginResync, void()); 34 MOCK_METHOD3(addResyncSample, bool(nsecs_t, std::optional<nsecs_t>, bool*)); 35 MOCK_METHOD0(endResync, void()); 36 MOCK_METHOD1(setPeriod, void(nsecs_t)); 37 MOCK_METHOD0(getPeriod, nsecs_t()); 38 MOCK_METHOD0(getIntendedPeriod, nsecs_t()); 39 MOCK_METHOD1(setRefreshSkipCount, void(int)); 40 MOCK_CONST_METHOD2(computeNextRefresh, nsecs_t(int, nsecs_t)); 41 MOCK_METHOD1(setIgnorePresentFences, void(bool)); 42 MOCK_METHOD1(expectedPresentTime, nsecs_t(nsecs_t)); 43 44 MOCK_CONST_METHOD1(dump, void(std::string&)); 45 46 status_t addEventListener(const char* name, nsecs_t phase, Callback* callback, 47 nsecs_t lastCallbackTime) override; 48 status_t removeEventListener(Callback* callback, nsecs_t* outLastCallback) override; 49 status_t changePhaseOffset(Callback* callback, nsecs_t phase) override; 50 getCallbackPhase()51 nsecs_t getCallbackPhase() { return mCallback.phase; } 52 53 void triggerCallback(); 54 55 private: 56 struct CallbackType { 57 Callback* callback = nullptr; 58 nsecs_t phase; 59 }; 60 CallbackType mCallback; 61 }; 62 63 } // namespace mock 64 } // namespace android 65