1 /* 2 * Copyright (c) 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 #include <thread> 17 #include "gtest/gtest.h" 18 #include "ui_test_graphic_engine.h" 19 #include "view_api.h" 20 #include "graphic_engine.h" 21 #include "common/graphic_startup.h" 22 #include "common/image_decode_ability.h" 23 #include "common/screen.h" 24 #include "font/ui_font_header.h" 25 #include "log/log.h" 26 #include "updater_ui_const.h" 27 #include "ui_rotation.h" 28 #include "utils.h" 29 30 using namespace testing::ext; 31 using namespace Updater; 32 33 namespace { 34 constexpr uint32_t WHITE_BGCOLOR = 0x000000ff; 35 constexpr const char* FONT_PATH = "/system/etc/charger/resources/"; 36 class UpdaterUiGraphicEngineUnitTest : public testing::Test { 37 public: SetUpTestCase(void)38 static void SetUpTestCase(void) 39 { 40 TestGraphicEngine::GetInstance(); 41 } TearDownTestCase(void)42 static void TearDownTestCase(void) {} SetUp()43 void SetUp() override {} TearDown()44 void TearDown() override {} 45 }; 46 47 HWTEST_F(UpdaterUiGraphicEngineUnitTest, test_ui_graphic_engine_test01, TestSize.Level0) 48 { 49 GraphicEngine::GetInstance().Init(WHITE_BGCOLOR, OHOS::ColorMode::ARGB8888, FONT_PATH); 50 uint16_t height = OHOS::Screen::GetInstance().GetHeight(); 51 uint16_t width = OHOS::Screen::GetInstance().GetWidth(); 52 EXPECT_EQ(height, GraphicEngine::GetInstance().GetScreenHeight()); 53 EXPECT_EQ(width, GraphicEngine::GetInstance().GetScreenWidth()); 54 OHOS::BufferInfo *bufferInfo = GraphicEngine::GetInstance().GetFBBufferInfo(); 55 EXPECT_EQ(bufferInfo->color, WHITE_BGCOLOR); 56 EXPECT_EQ(bufferInfo->mode, OHOS::ColorMode::ARGB8888); 57 } 58 } 59