Add board for hal test 90/249190/2
authorlokilee73 <changjoo.lee@samsung.com>
Tue, 8 Dec 2020 11:10:30 +0000 (20:10 +0900)
committerlokilee73 <changjoo.lee@samsung.com>
Wed, 9 Dec 2020 03:33:50 +0000 (12:33 +0900)
Change-Id: Ic874f8b4e00aac5bc3935b344736715e6f536889
Signed-off-by: lokilee73 <changjoo.lee@samsung.com>
unittest/device_haltests.cpp

index 3fad8b9..70de98d 100644 (file)
@@ -15,6 +15,7 @@
 #include "hw/usb_gadget.h"
 #include "hw/bezel.h"
 #include "hw/touchsensitivity.h"
+#include "hw/board.h"
 
 using namespace std;
 
@@ -25,6 +26,7 @@ using namespace std;
 #define LOWBATTERY "LowBattery"
 
 struct hw_info *info;
+struct hw_board *board_dev;
 struct battery_device *battery_dev;
 struct cpu_device *cpu_dev;
 struct display_device *display_dev;
@@ -181,6 +183,20 @@ class TOUCHSENSITIVITYHalTest : public testing::Test
                }
 };
 
+class BOARDHalTest : public testing::Test
+{
+       public:
+               virtual void SetUp()
+               {
+
+               }
+
+               virtual void TearDown()
+               {
+
+               }
+};
+
 class BEZELHalTest : public testing::Test
 {
        public:
@@ -975,6 +991,68 @@ TEST_F(TOUCHSENSITIVITYHalTest, DeinitP)
 }
 
 /*
+ * Testcase for Board
+ */
+TEST_F(BOARDHalTest, InitP)
+{
+       int ret;
+
+       info = NULL;
+       ret = hw_get_info(BOARD_HARDWARE_DEVICE_ID,
+                       (const struct hw_info **)&info);
+       if (ret < 0) {
+               cout << "There is no device for board " << ret << endl;
+               return;
+       } else {
+               EXPECT_EQ(ret, 0) << "Fail to get hal for board (" << ret << ")";
+       }
+
+       if (!info || !info->open) {
+               cout << "There is no function for info open" << endl;
+               return;
+       }
+       ret = info->open(info, NULL, (struct hw_common**)&board_dev);
+       EXPECT_EQ(ret, 0) << "Fail to open board device (" << ret << ")";
+}
+
+TEST_F(BOARDHalTest, GetDeviceSerialP)
+{
+       int ret;
+       char *serial;
+
+       if (!board_dev || !board_dev->get_device_serial) {
+               cout << "There is no function for get_device_serial" << endl;
+               return;
+       }
+       ret = board_dev->get_device_serial(&serial);
+       EXPECT_EQ(ret, 0) << "Fail to get device serial (" << ret << ")";
+}
+
+TEST_F(BOARDHalTest, GetDeviceRevisionP)
+{
+       int ret, revision;
+
+       if (!board_dev || !board_dev->get_device_revision) {
+               cout << "There is no function for get_device_revision" << endl;
+               return;
+       }
+       ret = board_dev->get_device_revision(&revision);
+       EXPECT_EQ(ret, 0) << "Fail to get device revision (" << ret << ")";
+}
+
+TEST_F(BOARDHalTest, DeinitP)
+{
+       int ret;
+
+       if (!info || !info->close) {
+               cout << "There is no function for info close" << endl;
+               return;
+       }
+       ret = info->close((struct hw_common *)board_dev);
+       EXPECT_EQ(ret, 0) << "Fail to close board device (" << ret << ")";
+}
+
+/*
  * Testcase for Bezel
  */
 TEST_F(BEZELHalTest, InitP)