Home | History | Annotate | Download | only in mock
      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_METHOD2(addResyncSample, bool(nsecs_t, bool*));
     35     MOCK_METHOD0(endResync, void());
     36     MOCK_METHOD1(setPeriod, void(nsecs_t));
     37     MOCK_METHOD0(getPeriod, nsecs_t());
     38     MOCK_METHOD1(setRefreshSkipCount, void(int));
     39     MOCK_CONST_METHOD1(computeNextRefresh, nsecs_t(int));
     40     MOCK_METHOD1(setIgnorePresentFences, void(bool));
     41     MOCK_METHOD0(expectedPresentTime, nsecs_t());
     42 
     43     MOCK_CONST_METHOD1(dump, void(std::string&));
     44 
     45     status_t addEventListener(const char* name, nsecs_t phase, Callback* callback,
     46                               nsecs_t lastCallbackTime) override;
     47     status_t removeEventListener(Callback* callback, nsecs_t* outLastCallback) override;
     48     status_t changePhaseOffset(Callback* callback, nsecs_t phase) override;
     49 
     50     nsecs_t getCallbackPhase() { return mCallback.phase; }
     51 
     52     void triggerCallback();
     53 
     54 private:
     55     struct CallbackType {
     56         Callback* callback = nullptr;
     57         nsecs_t phase;
     58     };
     59     CallbackType mCallback;
     60 };
     61 
     62 } // namespace mock
     63 } // namespace android
     64