1 /* 2 * Copyright (c) 2024 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 "gtest/gtest.h" 17 #include "fbdev_driver.h" 18 19 #include <cstdio> 20 #include <cstdlib> 21 #include <cstring> 22 #include <memory> 23 #include <fcntl.h> 24 #include <sys/ioctl.h> 25 #include <sys/mman.h> 26 #include <sys/types.h> 27 #include <unistd.h> 28 #include "securec.h" 29 #include "ui_rotation.h" 30 #include "updater_ui_const.h" 31 32 using namespace testing::ext; 33 using namespace Updater; 34 35 namespace UpdaterUt { 36 class FbdevDriverUnitTest : public testing::Test { 37 public: SetUpTestCase(void)38 static void SetUpTestCase(void) {} TearDownTestCase(void)39 static void TearDownTestCase(void) {} 40 void SetUp() override {} 41 void TearDown() override {} 42 }; 43 HWTEST_F(FbdevDriverUnitTest, test_fbdev_driver_init, TestSize.Level0)44HWTEST_F(FbdevDriverUnitTest, test_fbdev_driver_init, TestSize.Level0) 45 { 46 auto drv = std::make_unique<FbdevDriver>(); 47 drv->SetDevPath(""); 48 EXPECT_FALSE(drv->Init()); 49 drv->SetDevPath("/fakepath/fakefb0"); 50 EXPECT_FALSE(drv->Init()); 51 drv->SetDevPath(FB_DEV_PATH); 52 EXPECT_TRUE(drv->Init()); 53 } 54 }