• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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/EventThread.h"
22 
23 namespace android::mock {
24 
25 class EventThread : public android::EventThread {
26 public:
27     static constexpr auto kCallingUid = static_cast<uid_t>(0);
28 
29     EventThread();
30     ~EventThread() override;
31 
32     // TODO(b/302035909): workaround otherwise gtest complains about
33     //  error: no viable conversion from
34     //  'tuple<android::ftl::Flags<android::gui::ISurfaceComposer::EventRegistration> &&>' to 'const
35     //  tuple<android::ftl::Flags<android::gui::ISurfaceComposer::EventRegistration>>'
createEventConnection(EventRegistrationFlags flags)36     sp<EventThreadConnection> createEventConnection(EventRegistrationFlags flags) const override {
37         return createEventConnection(false, flags);
38     }
39     MOCK_METHOD(sp<EventThreadConnection>, createEventConnection, (bool, EventRegistrationFlags),
40                 (const));
41 
42     MOCK_METHOD(void, enableSyntheticVsync, (bool), (override));
43     MOCK_METHOD(void, onHotplugReceived, (PhysicalDisplayId, bool), (override));
44     MOCK_METHOD(void, onHotplugConnectionError, (int32_t), (override));
45     MOCK_METHOD(void, onModeChanged, (const scheduler::FrameRateMode&), (override));
46     MOCK_METHOD(void, onFrameRateOverridesChanged,
47                 (PhysicalDisplayId, std::vector<FrameRateOverride>), (override));
48     MOCK_METHOD(void, dump, (std::string&), (const, override));
49     MOCK_METHOD(void, setDuration,
50                 (std::chrono::nanoseconds workDuration, std::chrono::nanoseconds readyDuration),
51                 (override));
52     MOCK_METHOD(status_t, registerDisplayEventConnection,
53                 (const sp<android::EventThreadConnection>&), (override));
54     MOCK_METHOD(void, setVsyncRate, (uint32_t, const sp<android::EventThreadConnection>&),
55                 (override));
56     MOCK_METHOD(void, requestNextVsync, (const sp<android::EventThreadConnection>&), (override));
57     MOCK_METHOD(VsyncEventData, getLatestVsyncEventData,
58                 (const sp<android::EventThreadConnection>&, nsecs_t), (const, override));
59     MOCK_METHOD(void, requestLatestConfig, (const sp<android::EventThreadConnection>&));
60     MOCK_METHOD(void, pauseVsyncCallback, (bool));
61     MOCK_METHOD(void, onNewVsyncSchedule, (std::shared_ptr<scheduler::VsyncSchedule>), (override));
62     MOCK_METHOD(void, onHdcpLevelsChanged,
63                 (PhysicalDisplayId displayId, int32_t connectedLevel, int32_t maxLevel),
64                 (override));
65 };
66 
67 } // namespace android::mock
68