Add SetUp/TearDown in libinput haltests
authordyamy-lee <dyamy.lee@samsung.com>
Wed, 21 Apr 2021 06:44:40 +0000 (15:44 +0900)
committerduna.oh <duna.oh@samsung.com>
Fri, 27 Jan 2023 05:46:18 +0000 (14:46 +0900)
Every test creates libinput and udev, and removes them. So, executing common logic as using SetUp/TearDown.

Change-Id: I445db460c282a6f929ac8db5a70c0aa67302f32a

haltests/test_hal_libinput.cpp
haltests/test_hal_libinput.h

index 487ef87..bfbc237 100644 (file)
@@ -21,24 +21,26 @@ static const struct libinput_interface simple_interface = {
        .close_restricted = close_restricted,
 };
 
-TEST_F(LibInputHalTest, UdevCreateTest)
+void LibInputHalTest::SetUp(void)
 {
-       struct libinput *li;
-       struct udev *udev_context;
-
        udev_context = udev_new();
-       EXPECT_TRUE(udev_context != NULL);
-
        li = libinput_udev_create_context(&simple_interface, NULL, udev_context);
-       EXPECT_TRUE(li != NULL);
-
        libinput_udev_assign_seat(li, "seat0");
-       EXPECT_TRUE(li != NULL);
+}
 
+void LibInputHalTest::TearDown(void)
+{
        libinput_unref(li);
        udev_unref(udev_context);
 }
 
+TEST_F(LibInputHalTest, UdevCreateTest)
+{
+       EXPECT_TRUE(udev_context != NULL);
+       EXPECT_TRUE(li != NULL);
+       EXPECT_TRUE(true);
+}
+
 TEST_F(LibInputHalTest, GetDeviceListsTest)
 {
        EXPECT_TRUE(true);
index 3f424b7..7f00984 100644 (file)
@@ -16,6 +16,12 @@ class LibInputHalTest : public ::testing::Test
        public:
                LibInputHalTest() {};
                virtual ~LibInputHalTest();
+
+               void SetUp(void);
+               void TearDown(void);
+
+               struct libinput *li;
+               struct udev *udev_context;
 };
 
 #endif // __LIBINPUT_TESTS_H__