Add board for hal test
[platform/core/system/libdevice-node.git] / unittest / device_haltests.cpp
index ee84de6..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)
@@ -1096,14 +1174,10 @@ TEST_F(USBCLIENTHalTest, InitP)
 TEST_F(USBCLIENTHalTest, EnableP)
 {
        int ret;
-       char str[256];
 
        if (!supported)
                return;
 
-       //dummy code to prevent error for not used function
-       snprintf(str, 255, "%s,", _available_funcs[2]->name);
-
        if (!client_dev || !client_dev->enable) {
                cout << "There is no function for enable" << endl;
                return;
@@ -1142,51 +1216,6 @@ TEST_F(USBCLIENTHalTest, ReConfigureGadgetP)
        EXPECT_EQ(ret, 0) << "Fail to reconfigure_gadget (" << ret << ")";
 }
 
-TEST_F(USBCLIENTHalTest, IsGadgetSupportedP)
-{
-       bool flag;
-
-       if (!supported)
-               return;
-
-       if (!client_dev || !client_dev->is_gadget_supported) {
-               cout << "There is no function for is_gadget_supported" << endl;
-               return;
-       }
-       flag = client_dev->is_gadget_supported(client_dev, gadget_dev);
-       EXPECT_EQ(flag, true) << "Fail to is_gadget_supported (" << flag << ")";
-}
-
-TEST_F(USBCLIENTHalTest, IsFunctionSupportedP)
-{
-       bool flag;
-
-       if (!supported)
-               return;
-
-       if (!client_dev || !client_dev->is_function_supported) {
-               cout << "There is no function for is_function_supported" << endl;
-               return;
-       }
-       flag = client_dev->is_function_supported(client_dev, *gadget_dev->funcs);
-       EXPECT_EQ(flag, true) << "Fail to is_function_supported (" << flag << ")";
-}
-
-TEST_F(USBCLIENTHalTest, GetCurrentGadgetP)
-{
-       int ret;
-
-       if (!supported)
-               return;
-
-       if (!client_dev || !client_dev->get_current_gadget) {
-               cout << "There is no function for get_current_gadget" << endl;
-               return;
-       }
-       ret = client_dev->get_current_gadget(client_dev, &gadget_dev);
-       EXPECT_EQ(ret, 0) << "Fail to get_current_gadget (" << ret << ")";
-}
-
 TEST_F(USBCLIENTHalTest, DisableP)
 {
        int ret;
@@ -1202,18 +1231,6 @@ TEST_F(USBCLIENTHalTest, DisableP)
        EXPECT_EQ(ret, 0) << "Fail to disable (" << ret << ")";
 }
 
-TEST_F(USBCLIENTHalTest, FreeGadgetP)
-{
-       if (!supported)
-               return;
-
-       if (!client_dev || !client_dev->free_gadget) {
-               cout << "There is no function for free_gadget" << endl;
-               return;
-       }
-       client_dev->free_gadget(gadget_dev);
-}
-
 TEST_F(USBCLIENTHalTest, DeinitP)
 {
        int ret;
@@ -1258,14 +1275,12 @@ TEST_F(USBGADGETHalTest, IdToGadget)
 {
        struct usb_gadget_id gadget_id;
        int ret;
-       char str[256];
 
        if (!gadget_translator || !gadget_translator->id_to_gadget) {
                cout << "There is no function for id_to_gadget" << endl;
                return;
        }
-       //dummy code to prevent error for not used function
-       snprintf(str, 255, "%s,", _available_funcs[2]->name);
+
        gadget_id.function_mask = 7;
        ret = gadget_translator->id_to_gadget(&gadget_id, &gadget_dev);
        EXPECT_EQ(ret, 0) << "Fail to id_to_gadget (" << ret << ")";