1 /* 2 * Copyright (C) 2025 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 <ComposerClientWrapper.h> 20 21 #include <aidl/android/hardware/graphics/common/DisplayHotplugEvent.h> 22 #include <memory> 23 #include <unistd.h> 24 #include <unordered_map> 25 #include <vector> 26 27 namespace hcct { 28 29 namespace libhwc_aidl_test = 30 ::aidl::android::hardware::graphics::composer3::libhwc_aidl_test; 31 namespace common = ::aidl::android::hardware::graphics::common; 32 33 /* 34 * HwcTester is a class that provides an interface to interact with the 35 * HWC AIDL through libhwc_aidl_test. It's not just an interface to the HWC 36 * AIDL, but also provides some helper functions to make it easier to write 37 * tests. 38 */ 39 40 class HwcTester { 41 public: 42 HwcTester(); 43 ~HwcTester(); 44 45 std::vector<int64_t> GetAllDisplayIds() const; 46 std::vector<std::pair<int64_t, common::DisplayHotplugEvent>> 47 getAndClearLatestHotplugs(); 48 bool DrawSolidColorToScreen(int64_t display_id, Color color); 49 50 private: 51 std::vector<DisplayConfiguration> GetDisplayConfigs(int64_t display_id); 52 DisplayConfiguration GetDisplayActiveConfigs(int64_t display_id); 53 ComposerClientWriter &GetWriter(int64_t display_id); 54 55 std::unique_ptr<libhwc_aidl_test::ComposerClientWrapper> mComposerClient; 56 std::unordered_map<int64_t, libhwc_aidl_test::DisplayWrapper> mDisplays; 57 std::unordered_map<int64_t, ComposerClientWriter> mWriters; 58 }; 59 60 } // namespace hcct 61