1/* 2 * Copyright (c) 2021-2022 Huawei Device Co., Ltd. 3 * Licensed under the Apache License, Version 2.0 (the "License"); 4 * you may not use this file except in compliance with the License. 5 * You may obtain a copy of the License at 6 * 7 * http://www.apache.org/licenses/LICENSE-2.0 8 * 9 * Unless required by applicable law or agreed to in writing, software 10 * distributed under the License is distributed on an "AS IS" BASIS, 11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 * See the License for the specific language governing permissions and 13 * limitations under the License. 14 */ 15 16#ifndef FRAMEWORKS_DM_TEST_ST_DISPLAY_TEST_UTILS_H 17#define FRAMEWORKS_DM_TEST_ST_DISPLAY_TEST_UTILS_H 18 19#include <securec.h> 20 21#include "display_manager.h" 22#include "screen_manager.h" 23#include "display_property.h" 24#include "display.h" 25#include "screen.h" 26#include "display_info.h" 27#include "wm_common.h" 28#include "dm_common.h" 29#include "iconsumer_surface.h" 30#include "window_manager_hilog.h" 31#include "unique_fd.h" 32#include "ui/rs_surface_node.h" 33#include "ui/rs_display_node.h" 34 35namespace OHOS { 36namespace Rosen { 37class DisplayTestUtils { 38public: 39 ~DisplayTestUtils(); 40 static bool SizeEqualToDisplay(const sptr<Display>& display, const Media::Size cur); 41 static bool SizeEqual(const Media::Size dst, const Media::Size cur); 42 void init(); 43 bool CreateSurface(); 44 void SetDefaultWH(const sptr<Display>& display); 45 class BufferListener : public IBufferConsumerListener { 46 public: 47 explicit BufferListener(DisplayTestUtils &displayTestUtils): utils_(displayTestUtils) 48 { 49 } 50 ~BufferListener() noexcept override = default; 51 void OnBufferAvailable() override 52 { 53 utils_.OnVsync(); 54 } 55 56 private: 57 DisplayTestUtils &utils_; 58 }; 59 friend class BufferListener; 60 61 void OnVsync(); 62 uint32_t successCount_ = 0; 63 uint32_t failCount_ = 0; 64 uint32_t defaultWidth_ = 0; 65 uint32_t defaultHeight_ = 0; 66 sptr<IBufferConsumerListener> listener_ = nullptr; 67 sptr<IConsumerSurface> csurface_ = nullptr; // cosumer surface 68 sptr<Surface> psurface_ = nullptr; // producer surface 69 sptr<SurfaceBuffer> prevBuffer_ = nullptr; 70 BufferHandle *bufferHandle_ = nullptr; 71 72private: 73 std::mutex mutex_; 74}; 75} // namespace ROSEN 76} // namespace OHOS 77#endif // FRAMEWORKS_DM_TEST_ST_DISPLAY_TEST_UTILS_H 78