1885b47fbSopenharmony_ci/* 2885b47fbSopenharmony_ci * Copyright (c) 2021 Huawei Device Co., Ltd. 3885b47fbSopenharmony_ci * Licensed under the Apache License, Version 2.0 (the "License"); 4885b47fbSopenharmony_ci * you may not use this file except in compliance with the License. 5885b47fbSopenharmony_ci * You may obtain a copy of the License at 6885b47fbSopenharmony_ci * 7885b47fbSopenharmony_ci * http://www.apache.org/licenses/LICENSE-2.0 8885b47fbSopenharmony_ci * 9885b47fbSopenharmony_ci * Unless required by applicable law or agreed to in writing, software 10885b47fbSopenharmony_ci * distributed under the License is distributed on an "AS IS" BASIS, 11885b47fbSopenharmony_ci * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12885b47fbSopenharmony_ci * See the License for the specific language governing permissions and 13885b47fbSopenharmony_ci * limitations under the License. 14885b47fbSopenharmony_ci */ 15885b47fbSopenharmony_ci 16885b47fbSopenharmony_ci#include <gtest/gtest.h> 17885b47fbSopenharmony_ci#include "display.h" 18885b47fbSopenharmony_ci#include "window/window_manager/utils/include/display_info.h" 19885b47fbSopenharmony_ci 20885b47fbSopenharmony_cinamespace OHOS::Rosen { 21885b47fbSopenharmony_cinamespace { 22885b47fbSopenharmony_ci const int32_t HEIGHT_VALUE = 1000; 23885b47fbSopenharmony_ci const int32_t WEIGHT_VALUE = 600; 24885b47fbSopenharmony_ci} // namespace 25885b47fbSopenharmony_ci 26885b47fbSopenharmony_ciclass Display::Impl : public RefBase { 27885b47fbSopenharmony_cipublic: 28885b47fbSopenharmony_ci Impl(const std::string& name, sptr<DisplayInfo> displayInfo) 29885b47fbSopenharmony_ci { 30885b47fbSopenharmony_ci name_ = name; 31885b47fbSopenharmony_ci displayInfo_ = displayInfo; 32885b47fbSopenharmony_ci } 33885b47fbSopenharmony_ci ~Impl() = default; 34885b47fbSopenharmony_ci DEFINE_VAR_FUNC_GET_SET(std::string, Name, name); 35885b47fbSopenharmony_ci DEFINE_VAR_FUNC_GET_SET(sptr<DisplayInfo>, DisplayInfo, displayInfo); 36885b47fbSopenharmony_ci}; 37885b47fbSopenharmony_ci 38885b47fbSopenharmony_ciDisplay::Display(const std::string& name, sptr<DisplayInfo> info) : pImpl_(new Impl(name, info)) 39885b47fbSopenharmony_ci{ 40885b47fbSopenharmony_ci GTEST_LOG_(INFO) << "MOCK Display Display"; 41885b47fbSopenharmony_ci} 42885b47fbSopenharmony_ci 43885b47fbSopenharmony_ciDisplay::~Display() 44885b47fbSopenharmony_ci{ 45885b47fbSopenharmony_ci GTEST_LOG_(INFO) << "MOCK Display ~Display"; 46885b47fbSopenharmony_ci} 47885b47fbSopenharmony_ci 48885b47fbSopenharmony_ciDisplayId Display::GetId() const 49885b47fbSopenharmony_ci{ 50885b47fbSopenharmony_ci GTEST_LOG_(INFO) << "MOCK Display ~Display"; 51885b47fbSopenharmony_ci DisplayId displayId {0}; 52885b47fbSopenharmony_ci return displayId; 53885b47fbSopenharmony_ci} 54885b47fbSopenharmony_ci 55885b47fbSopenharmony_ciint32_t Display::GetWidth() const 56885b47fbSopenharmony_ci{ 57885b47fbSopenharmony_ci GTEST_LOG_(INFO) << "MOCK Display GetWidth"; 58885b47fbSopenharmony_ci return WEIGHT_VALUE; 59885b47fbSopenharmony_ci} 60885b47fbSopenharmony_ci 61885b47fbSopenharmony_ciint32_t Display::GetHeight() const 62885b47fbSopenharmony_ci{ 63885b47fbSopenharmony_ci GTEST_LOG_(INFO) << "MOCK Display GetHeight"; 64885b47fbSopenharmony_ci return HEIGHT_VALUE; 65885b47fbSopenharmony_ci} 66885b47fbSopenharmony_ci 67885b47fbSopenharmony_ciuint32_t Display::GetRefreshRate() const 68885b47fbSopenharmony_ci{ 69885b47fbSopenharmony_ci GTEST_LOG_(INFO) << "MOCK Display GetRefreshRate"; 70885b47fbSopenharmony_ci return 0; 71885b47fbSopenharmony_ci} 72885b47fbSopenharmony_ci 73885b47fbSopenharmony_ciScreenId Display::GetScreenId() const 74885b47fbSopenharmony_ci{ 75885b47fbSopenharmony_ci GTEST_LOG_(INFO) << "MOCK Display GetScreenId"; 76885b47fbSopenharmony_ci ScreenId screenId {0}; 77885b47fbSopenharmony_ci return screenId; 78885b47fbSopenharmony_ci} 79885b47fbSopenharmony_ci 80885b47fbSopenharmony_civoid Display::UpdateDisplayInfo(sptr<DisplayInfo> displayInfo) const 81885b47fbSopenharmony_ci{ 82885b47fbSopenharmony_ci GTEST_LOG_(INFO) << "MOCK Display UpdateDisplayInfo"; 83885b47fbSopenharmony_ci if (!displayInfo) { 84885b47fbSopenharmony_ci return; 85885b47fbSopenharmony_ci } 86885b47fbSopenharmony_ci pImpl_->SetDisplayInfo(displayInfo); 87885b47fbSopenharmony_ci} 88885b47fbSopenharmony_ci 89885b47fbSopenharmony_cifloat Display::GetVirtualPixelRatio() const 90885b47fbSopenharmony_ci{ 91885b47fbSopenharmony_ci#ifdef PRODUCT_RK 92885b47fbSopenharmony_ci return 1.0f; 93885b47fbSopenharmony_ci#else 94885b47fbSopenharmony_ci return 2.0f; 95885b47fbSopenharmony_ci#endif 96885b47fbSopenharmony_ci} 97885b47fbSopenharmony_ci} // namespace OHOS::Rosen