diff options
author | lokilee73 <changjoo.lee@samsung.com> | 2018-08-17 20:35:40 +0900 |
---|---|---|
committer | lokilee73 <changjoo.lee@samsung.com> | 2018-08-17 20:35:52 +0900 |
commit | b04ef88c51682d26e141d7d48d40f86b55cfa92c (patch) | |
tree | 58443c709f2b88bfe6ee8b2f11fd384f35cf12d4 | |
parent | 9cb65663a40bed2067f88e1ca832a0737fe87ef1 (diff) | |
download | libdevice-node-b04ef88c51682d26e141d7d48d40f86b55cfa92c.tar.gz libdevice-node-b04ef88c51682d26e141d7d48d40f86b55cfa92c.tar.bz2 libdevice-node-b04ef88c51682d26e141d7d48d40f86b55cfa92c.zip |
Unify cpp files to one
Merge below cpp files to device_haltests.cpp
gtest_hal_battery.cpp
gtest_hal_cpu.cpp
gtest_hal_display.cpp
gtest_hal_extcon.cpp
gtest_hal_ir.cpp
gtest_hal_rgb.cpp
gtest_hal_thermal.cpp
gtest_hal_touchscreen.cpp
gtest_hal_usb_client.cpp
gtest_hal_gadget.cpp
Change-Id: I20a155136b21e6b2a4a86daeb24f2592dc281b22
Signed-off-by: lokilee73 <changjoo.lee@samsung.com>
-rwxr-xr-x | packaging/libdevice-node.spec | 2 | ||||
-rwxr-xr-x | unittest/device_haltests.cpp | 1100 | ||||
-rwxr-xr-x | unittest/gtest_hal_battery.cpp | 126 | ||||
-rwxr-xr-x | unittest/gtest_hal_cpu.cpp | 100 | ||||
-rwxr-xr-x | unittest/gtest_hal_display.cpp | 215 | ||||
-rwxr-xr-x | unittest/gtest_hal_extcon.cpp | 107 | ||||
-rwxr-xr-x | unittest/gtest_hal_ir.cpp | 111 | ||||
-rwxr-xr-x | unittest/gtest_hal_rgb.cpp | 100 | ||||
-rwxr-xr-x | unittest/gtest_hal_thermal.cpp | 110 | ||||
-rwxr-xr-x | unittest/gtest_hal_touchscreen.cpp | 83 | ||||
-rwxr-xr-x | unittest/gtest_hal_usb_client.cpp | 236 | ||||
-rwxr-xr-x | unittest/gtest_hal_usb_gadget.cpp | 98 |
12 files changed, 1101 insertions, 1287 deletions
diff --git a/packaging/libdevice-node.spec b/packaging/libdevice-node.spec index e97c5ec..d97946f 100755 --- a/packaging/libdevice-node.spec +++ b/packaging/libdevice-node.spec @@ -61,4 +61,4 @@ make %{?jobs:-j%jobs} %{_libdir}/pkgconfig/*.pc %files -n device-haltests -%{_bindir}/gtest* +%{_bindir}/device_haltests diff --git a/unittest/device_haltests.cpp b/unittest/device_haltests.cpp new file mode 100755 index 0000000..175049f --- /dev/null +++ b/unittest/device_haltests.cpp @@ -0,0 +1,1100 @@ + +#include <iostream> +#include <gtest/gtest.h> +#include <system_info.h> +#include "unittest.h" +#include "hw/battery.h" +#include "hw/cpu.h" +#include "hw/display.h" +#include "hw/external_connection.h" +#include "hw/ir.h" +#include "hw/led.h" +#include "hw/thermal.h" +#include "hw/touchscreen.h" +#include "hw/usb_client.h" +#include "hw/usb_gadget.h" + +using namespace std; + +/* + * main class + */ +#define MODEL_NAME "http://tizen.org/system/model_name" +#define LOWBATTERY "LowBattery" + +struct hw_info *info; +struct battery_device *battery_dev; +struct cpu_device *cpu_dev; +struct display_device *display_dev; +struct external_connection_device *ext_dev; +struct ir_device *ir_dev; +struct led_device *rgb_dev; +struct thermal_device *thermal_dev; +struct touchscreen_device *touchscreen_dev; +struct usb_client *client_dev; +struct usb_gadget *gadget_dev; +struct usb_gadget_id gadget_id; +struct usb_gadget_translator *gadget_translator; + +/* Define Classes */ +class BATTERYHalTest : public testing::Test +{ + public: + virtual void SetUp() + { + int ret; + + ret = system_info_get_platform_bool(FEATURE_BATTERY, &supported); + EXPECT_EQ(SYSTEM_INFO_ERROR_NONE, ret) << "system_info_get_platform_bool failed"; + + } + + virtual void TearDown() + { + + } +}; + +class CPUHalTest : public testing::Test +{ + public: + virtual void SetUp() + { + + } + + virtual void TearDown() + { + + } +}; + +class DISPLAYHalTest : public testing::Test +{ + public: + virtual void SetUp() + { + + } + + virtual void TearDown() + { + + } +}; + +class EXTCONHalTest : public testing::Test +{ + public: + virtual void SetUp() + { + + } + + virtual void TearDown() + { + + } +}; + +class IRHalTest : public testing::Test +{ + public: + virtual void SetUp() + { + int ret; + + ret = system_info_get_platform_bool(FEATURE_IR, &supported); + EXPECT_EQ(SYSTEM_INFO_ERROR_NONE, ret) << "system_info_get_platform_bool failed"; + } + + virtual void TearDown() + { + + } +}; + +class RGBHalTest : public testing::Test +{ + public: + virtual void SetUp() + { + int ret; + + ret = system_info_get_platform_bool(FEATURE_LED, &supported); + EXPECT_EQ(SYSTEM_INFO_ERROR_NONE, ret) << "system_info_get_platform_bool failed"; + } + + virtual void TearDown() + { + + } +}; + +class THERMALHalTest : public testing::Test +{ + public: + virtual void SetUp() + { + + } + + virtual void TearDown() + { + + } +}; + +class TOUCHSCREENHalTest : public testing::Test +{ + public: + virtual void SetUp() + { + + } + + virtual void TearDown() + { + + } +}; + +class USBCLIENTHalTest : public testing::Test +{ + public: + virtual void SetUp() + { + int ret; + char *model_name = NULL; + + ret = system_info_get_platform_string(MODEL_NAME, &model_name); + EXPECT_EQ(SYSTEM_INFO_ERROR_NONE, ret) << "system_info_get_platform_bool failed"; + + if (!strncmp(model_name, "artik", 5)) { + supported = true; + } else { + supported = false; + } + cout << "supported " << supported << endl; + free(model_name); + } + + virtual void TearDown() + { + + } +}; + +class USBGADGETHalTest : public testing::Test +{ + public: + virtual void SetUp() + { + + } + + virtual void TearDown() + { + + } +}; + +/* + * Testcase for Battery + */ +TEST_F(BATTERYHalTest, InitP) +{ + int ret; + + if (!supported) + return; + + ret = hw_get_info(BATTERY_HARDWARE_DEVICE_ID, + (const struct hw_info **)&info); + EXPECT_EQ(ret, 0) << "Fail to load battery hal (" << ret << ")"; + + if (!info->open) { + cout << "There is no function for info open" << endl; + return; + } + ret = info->open(info, NULL, (struct hw_common**)&battery_dev); + EXPECT_EQ(ret, 0) << "Fail to open battery device(" << ret << ")"; +} + +static void updated_cb(struct battery_info *info, void *data) +{ + +} + +TEST_F(BATTERYHalTest, RegisterChangedEventP) +{ + int ret; + + if (!supported) + return; + + if (!battery_dev->register_changed_event) { + cout << "There is no function for register_changed_event" << endl; + return; + } + ret = battery_dev->register_changed_event(updated_cb, NULL); + EXPECT_EQ(ret, 0) << "Fail to register_changed_event (" << ret << ")"; +} + +TEST_F(BATTERYHalTest, UnregisterChangedEventP) +{ + if (!supported) + return; + + if (!battery_dev->unregister_changed_event) { + cout << "There is no function for unregister_changed_event" << endl; + return; + } + battery_dev->unregister_changed_event(updated_cb); +} + +TEST_F(BATTERYHalTest, GetCurrentStateP) +{ + int ret; + + if (!supported) + return; + + if (!battery_dev->get_current_state) { + cout << "There is no function for get_current_state" << endl; + return; + } + ret = battery_dev->get_current_state(updated_cb, NULL); + EXPECT_EQ(ret, 0) << "Fail to get_current_state (" << ret << ")"; +} + +TEST_F(BATTERYHalTest, DeinitP) +{ + int ret; + + if (!supported) + return; + + if (!info->close) { + cout << "There is no function for info close" << endl; + return; + } + ret = info->close((struct hw_common *)battery_dev); + EXPECT_EQ(ret, 0) << "Fail to close battery device(" << ret << ")"; +} + +/* + * Testcase for Cpu + */ +TEST_F(CPUHalTest, InitP) +{ + int ret; + + ret = hw_get_info(CPU_HARDWARE_DEVICE_ID, + (const struct hw_info **)&info); + if (ret < 0) { + cout << "There is no device for cpu " << ret << endl; + return; + } else { + EXPECT_EQ(ret, 0) << "Fail to load cpu hal (" << ret << ")"; + } + if (!info || !info->open) { + cout << "There is no function for info open" << endl; + return; + } + ret = info->open(info, NULL, (struct hw_common**)&cpu_dev); + EXPECT_EQ(ret, 0) << "Fail to open cpu device (" << ret << ")"; +} + +TEST_F(CPUHalTest, StartBoostP) +{ + int ret; + + if (!cpu_dev || !cpu_dev->start_boost) { + cout << "There is no function for start_boost" << endl; + return; + } + + // prprpr TODO + ret = cpu_dev->start_boost((void *)LOWBATTERY); + EXPECT_EQ(ret, 0) << "Fail to start_boost (" << ret << ")"; +} + +TEST_F(CPUHalTest, StopBoostP) +{ + int ret; + + if (!cpu_dev || !cpu_dev->stop_boost) { + cout << "There is no function for stop_boost" << endl; + return; + } + + // prprpr TODO + ret = cpu_dev->stop_boost((void *)LOWBATTERY); + EXPECT_EQ(ret, 0) << "Fail to stop_boost (" << ret << ")"; +} + +TEST_F(CPUHalTest, DeinitP) +{ + int ret; + + if (!info || !info->close) { + cout << "There is no function for info close" << endl; + return; + } + + ret = info->close((struct hw_common *)cpu_dev); + EXPECT_EQ(ret, 0) << "Fail to open cpu device (" << ret << ")"; +} + +/* + * Testcase for Display + */ +TEST_F(DISPLAYHalTest, InitP) +{ + int ret; + + ret = hw_get_info(DISPLAY_HARDWARE_DEVICE_ID, + (const struct hw_info **)&info); + if (ret < 0) { + cout << "There is no device for display" << ret << endl; + return; + } else { + EXPECT_EQ(ret, 0) << "Fail to load display hal (" << ret << ")"; + } + + if (!info || !info->open) { + cout << "There is no function for info open" << endl; + return; + } + ret = info->open(info, NULL, (struct hw_common**)&display_dev); + EXPECT_EQ(ret, 0) << "Fail to open display device (" << ret << ")"; +} + +TEST_F(DISPLAYHalTest, GetMaxBrightnessP) +{ + int ret; + int max; + + if (!display_dev || !display_dev->get_max_brightness) { + cout << "There is no function for get_max_brightness" << endl; + return; + } + ret = display_dev->get_max_brightness(&max); + EXPECT_EQ(ret, 0) << "Fail to get_max_brightness (" << ret << ")"; +} + +TEST_F(DISPLAYHalTest, GetBrightnessP) +{ + int ret; + int brt; + + if (!display_dev || !display_dev->get_brightness) { + cout << "There is no function for get_brightness" << endl; + return; + } + ret = display_dev->get_brightness(&brt); + EXPECT_EQ(ret, 0) << "Fail to get_brightness (" << ret << ")"; +} + +TEST_F(DISPLAYHalTest, SetBrightnessP) +{ + int ret; + int max; + + if (!display_dev || !display_dev->get_max_brightness) { + cout << "There is no function for get_max_brightness" << endl; + return; + } + ret = display_dev->get_max_brightness(&max); + EXPECT_EQ(ret, 0) << "Fail to get_max_brightness (" << ret << ")"; + + if (!display_dev || !display_dev->set_brightness) { + cout << "There is no function for set_brightness" << endl; + return; + } + ret = display_dev->set_brightness(max); + EXPECT_EQ(ret, 0) << "Fail to set_brightness (" << ret << ")"; +} + +TEST_F(DISPLAYHalTest, GetAutoBrightnessP) +{ + int ret; + int brt; + float lmax = 0, lmin = 0, light = 0; + + if (!display_dev || !display_dev->get_auto_brightness) { + cout << "There is no function for get_auto_brightness" << endl; + return; + } + ret = display_dev->get_auto_brightness(lmax, lmin, light, &brt); + EXPECT_GE(ret, 0) << "Fail to set_brightness (" << ret << ")"; +} + +TEST_F(DISPLAYHalTest, GetStateP) +{ + int ret; + enum display_state state; + + if (!display_dev || !display_dev->get_state) { + cout << "There is no function for get_state" << endl; + return; + } + ret = display_dev->get_state(&state); + EXPECT_GE(ret, 0) << "Fail to get_state (" << ret << ")"; +} + +TEST_F(DISPLAYHalTest, SetStateP) +{ + int ret; + + if (!display_dev || !display_dev->set_state) { + cout << "There is no function for set_state" << endl; + return; + } + ret = display_dev->set_state(DISPLAY_ON); + EXPECT_GE(ret, 0) << "Fail to set_state (" << ret << ")"; +} + +TEST_F(DISPLAYHalTest, GetMaxFrameRateP) +{ + int ret; + int max; + + if (!display_dev || !display_dev->get_max_frame_rate) { + cout << "There is no function for get_max_frame_rate" << endl; + return; + } + ret = display_dev->get_max_frame_rate(&max); + EXPECT_GE(ret, 0) << "Fail to get_max_frame_rate (" << ret << ")"; +} + +TEST_F(DISPLAYHalTest, GetMinFrameRateP) +{ + int ret; + int min; + + if (!display_dev || !display_dev->get_min_frame_rate) { + cout << "There is no function for get_min_frame_rate" << endl; + return; + } + ret = display_dev->get_min_frame_rate(&min); + EXPECT_GE(ret, 0) << "Fail to get_min_frame_rate (" << ret << ")"; +} + +TEST_F(DISPLAYHalTest, GetFrameRateP) +{ + int ret, rate; + + if (!display_dev || !display_dev->get_frame_rate) { + cout << "There is no function for get_frame_rate" << endl; + return; + } + ret = display_dev->get_frame_rate(&rate); + EXPECT_GE(ret, 0) << "Fail to get frame rate (" << ret << ")"; +} + +TEST_F(DISPLAYHalTest, SetFrameRateP) +{ + int ret; + int max; + + if (!display_dev || !display_dev->get_max_frame_rate) { + cout << "There is no function for get_max_frame_rate" << endl; + return; + } + ret = display_dev->get_max_frame_rate(&max); + EXPECT_GE(ret, 0) << "Fail to get_max_frame_rate (" << ret << ")"; + + if (!display_dev->set_frame_rate) { + cout << "There is no function for set_frame_rate" << endl; + return; + } + ret = display_dev->set_frame_rate(max); + EXPECT_GE(ret, 0) << "Fail to set_frame_rate (" << ret << ")"; +} + +TEST_F(DISPLAYHalTest, DeinitP) +{ + int ret; + + if (!info || !info->close) { + cout << "There is no function for info close" << endl; + return; + } + ret = info->close((struct hw_common *)display_dev); + EXPECT_GE(ret, 0) << "Fail to close display device (" << ret << ")"; +} + +/* + * Testcase for Extcon + */ +TEST_F(EXTCONHalTest, InitP) +{ + int ret; + + ret = hw_get_info(EXTERNAL_CONNECTION_HARDWARE_DEVICE_ID, + (const struct hw_info **)&info); + if (ret < 0) { + cout << "There is no device for extcon" << ret << endl; + return; + } else { + EXPECT_EQ(ret, 0) << "Fail to load extcon hal (" << ret << ")"; + } + + if (!info || !info->open) { + cout << "There is no function for info open" << endl; + return; + } + ret = info->open(info, NULL, (struct hw_common**)&ext_dev); + EXPECT_EQ(ret, 0) << "Fail to open extcon device(" << ret << ")"; +} + +static void updated_cb(struct connection_info *info, void *data) +{ + +} + +TEST_F(EXTCONHalTest, RegisterChangedEventP) +{ + int ret; + + if (!ext_dev || !ext_dev->register_changed_event) { + cout << "There is no function for register_changed_event" << endl; + return; + } + ret = ext_dev->register_changed_event(updated_cb, NULL); + EXPECT_EQ(ret, 0) << "Fail to register_changed_event (" << ret << ")"; +} + +TEST_F(EXTCONHalTest, UnregisterChangedEventP) +{ + if (!ext_dev || !ext_dev->unregister_changed_event) { + cout << "There is no function for unregister_changed_event" << endl; + return; + } + ext_dev->unregister_changed_event(updated_cb); +} + +TEST_F(EXTCONHalTest, GetCurrentStateP) +{ + int ret; + + if (!ext_dev || !ext_dev->get_current_state) { + cout << "There is no function for unregister_changed_event" << endl; + return; + } + ret = ext_dev->get_current_state(updated_cb, NULL); + EXPECT_EQ(ret, 0) << "Fail to unregister_changed_event (" << ret << ")"; +} + +TEST_F(EXTCONHalTest, DeinitP) +{ + int ret; + + if (!info || !info->close) { + cout << "There is no function for info close" << endl; + return; + } + ret = info->close((struct hw_common *)ext_dev); + EXPECT_EQ(ret, 0) << "Fail to close extcon device(" << ret << ")"; +} + +/* + * Testcase for Ir + */ +TEST_F(IRHalTest, InitP) +{ + int ret; + + if (!supported) + return; + + ret = hw_get_info(IR_HARDWARE_DEVICE_ID, + (const struct hw_info **)&info); + EXPECT_EQ(ret, 0) << "Fail to get hal for ir (" << ret << ")"; + + if (!info->open) { + cout << "There is no function for info open" << endl; + return; + } + ret = info->open(info, NULL, (struct hw_common**)&ir_dev); + EXPECT_EQ(ret, 0) << "Fail to open ir device (" << ret << ")"; +} + +TEST_F(IRHalTest, IsAvailableP) +{ + int ret; + bool val; + + if (!supported) + return; + + if (!ir_dev->is_available) { + cout << "There is no function for is_available" << endl; + return; + } + ret = ir_dev->is_available(&val); + EXPECT_EQ(ret, 0) << "Fail to is_available (" << ret << ")"; +} + +TEST_F(IRHalTest, TransmitP) +{ + int ret; + int pattern[5] = {100, 200, 300, 400, 500}; + + if (!supported) + return; + + if (!ir_dev->transmit) { + cout << "There is no function for transmit" << endl; + return; + } + ret = ir_dev->transmit(pattern, 5); + EXPECT_EQ(ret, 0) << "Fail to transmit (" << ret << ")"; +} + +TEST_F(IRHalTest, DeinitP) +{ + int ret; + + if (!supported) + return; + + if (!info->close) { + cout << "There is no function for info close" << endl; + return; + } + ret = info->close((struct hw_common *)ir_dev); + EXPECT_EQ(ret, 0) << "Fail to close ir device (" << ret << ")"; +} + +/* + * Testcase for Rgb + */ +TEST_F(RGBHalTest, InitP) +{ + int ret; + + if (!supported) + return; + + ret = hw_get_info(LED_HARDWARE_DEVICE_ID, + (const struct hw_info **)&info); + EXPECT_EQ(ret, 0) << "Fail to get hal for rgb (" << ret << ")"; + + if (!info->open) { + cout << "There is no function for info open" << endl; + return; + } + ret = info->open(info, LED_ID_NOTIFICATION, (struct hw_common**)&rgb_dev); + EXPECT_EQ(ret, 0) << "Fail to open rgb device (" << ret << ")"; +} + +TEST_F(RGBHalTest, SetStateP) +{ + struct led_state state; + int ret; + + if (!supported) + return; + + if (!rgb_dev->set_state) { + cout << "There is no function for set_state" << endl; + return; + } + + state.type = LED_TYPE_BLINK; + state.color = 0xFFFFFF; + state.duty_on = 500; + state.duty_off = 500; + ret = rgb_dev->set_state(&state); + EXPECT_GE(ret, 0) << "Fail to set_state (" << ret << ")"; +} + +TEST_F(RGBHalTest, DeinitP) +{ + int ret; + + if (!supported) + return; + + if (!info->close) { + cout << "There is no function for info close" << endl; + return; + } + ret = info->close((struct hw_common *)rgb_dev); + EXPECT_GE(ret, 0) << "Fail to close rgb device (" << ret << ")"; +} + +/* + * Testcase for Thermal + */ +TEST_F(THERMALHalTest, InitP) +{ + int ret; + + ret = hw_get_info(THERMAL_HARDWARE_DEVICE_ID, + (const struct hw_info **)&info); + if (ret < 0) { + cout << "There is no device for thermal" << ret << endl; + return; + } else { + EXPECT_EQ(ret, 0) << "Fail to get hal for thermal (" << ret << ")"; + } + + if (!info || !info->open) { + cout << "There is no function for info open" << endl; + return; + } + ret = info->open(info, NULL, (struct hw_common**)&thermal_dev); + EXPECT_EQ(ret, 0) << "Fail to open thermal device (" << ret << ")"; +} + +TEST_F(THERMALHalTest, GetStateP) +{ + struct thermal_info thermal; + int ret; + + if (!thermal_dev || !thermal_dev->get_state) { + cout << "There is no function for get_state" << endl; + return; + } + ret = thermal_dev->get_state(&thermal); + EXPECT_EQ(ret, 0) << "Fail to get_state (" << ret << ")"; +} + +static void updated_cb(struct thermal_info *info, void *data) +{ + +} + +TEST_F(THERMALHalTest, RegisterChangedEventP) +{ + int ret; + + if (!thermal_dev || !thermal_dev->register_changed_event) { + cout << "There is no function for register_changed_event" << endl; + return; + } + ret = thermal_dev->register_changed_event(updated_cb, NULL); + EXPECT_EQ(ret, 0) << "Fail to register_changed_event (" << ret << ")"; +} + +TEST_F(THERMALHalTest, UnregisterChangedEventP) +{ + if (!thermal_dev || !thermal_dev->unregister_changed_event) { + cout << "There is no function for unregister_changed_event" << endl; + return; + } + thermal_dev->unregister_changed_event(updated_cb); +} + +TEST_F(THERMALHalTest, DeinitP) +{ + int ret; + + if (!info || !info->close) { + cout << "There is no function for info close" << endl; + return; + } + ret = info->close((struct hw_common *)thermal_dev); + EXPECT_EQ(ret, 0) << "Fail to close thermal device (" << ret << ")"; +} + +/* + * Testcase for Touchscreen + */ +TEST_F(TOUCHSCREENHalTest, InitP) +{ + int ret; + + ret = hw_get_info(TOUCHSCREEN_HARDWARE_DEVICE_ID, + (const struct hw_info **)&info); + if (ret < 0) { + cout << "There is no device for touchscreen " << ret << endl; + return; + } else { + EXPECT_EQ(ret, 0) << "Fail to get hal for touchscreen (" << ret << ")"; + } + + if (!info || !info->open) { + cout << "There is no function for info open" << endl; + return; + } + ret = info->open(info, NULL, (struct hw_common**)&touchscreen_dev); + EXPECT_EQ(ret, 0) << "Fail to open touchscreen device (" << ret << ")"; +} + +TEST_F(TOUCHSCREENHalTest, SetstateP) +{ + enum touchscreen_state state = TOUCHSCREEN_ON; + int ret; + + if (!touchscreen_dev || !touchscreen_dev->set_state) { + cout << "There is no function for set_state" << endl; + return; + } + ret = touchscreen_dev->set_state(state); + EXPECT_EQ(ret, 0) << "Fail to set_state (" << ret << ")"; +} + +TEST_F(TOUCHSCREENHalTest, DeinitP) +{ + int ret; + + if (!info || !info->close) { + cout << "There is no function for info close" << endl; + return; + } + ret = info->close((struct hw_common *)touchscreen_dev); + EXPECT_EQ(ret, 0) << "Fail to close touchscreen device (" << ret << ")"; +} + +/* + * Testcase for Client + */ +TEST_F(USBCLIENTHalTest, InitP) +{ + int ret; + + if (!supported) + return; + + ret = hw_get_info(USB_CLIENT_HARDWARE_DEVICE_ID, + (const struct hw_info **)&info); + if (ret < 0) { + cout << "There is no device for usb client" << ret << endl; + return; + } else { + EXPECT_EQ(ret, 0) << "Fail to get hal for usb client (" << ret << ")"; + } + if (!info || !info->open) { + cout << "There is no function for info open" << endl; + return; + } + ret = info->open(info, NULL, (struct hw_common**)&client_dev); + EXPECT_EQ(ret, 0) << "Fail to open usb client device (" << ret << ")"; + EXPECT_NE(client_dev, nullptr) << "Fail to get usb client device structure"; + + ret = hw_get_info(USB_GADGET_DEVICE_ID, + (const struct hw_info **)&info); + if (ret < 0) { + cout << "There is no device for usb gadget" << ret << endl; + return; + } else { + EXPECT_EQ(ret, 0) << "Fail to get hal for usb gadget (" << ret << ")"; + } + + if (!info || !info->open) { + cout << "There is no function for info open" << endl; + return; + } + ret = info->open(info, NULL, (struct hw_common**)&gadget_translator); + EXPECT_EQ(ret, 0) << "Fail to open usb gadget device (" << ret << ")"; +} + +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; + } + ret = client_dev->enable(client_dev); + EXPECT_EQ(ret, 0) << "Fail to enable (" << ret << ")"; +} + +TEST_F(USBCLIENTHalTest, ReConfigureGadgetP) +{ + int ret; + + if (!supported) + return; + + if (!gadget_translator || !gadget_translator->id_to_gadget) { + cout << "There is no function for id_to_gadget" << endl; + return; + } + 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 << ")"; + + if (!client_dev || !client_dev->disable) { + cout << "There is no function for disable" << endl; + return; + } + ret = client_dev->disable(client_dev); + EXPECT_EQ(ret, 0) << "Fail to disable (" << ret << ")"; + + if (!client_dev || !client_dev->reconfigure_gadget) { + cout << "There is no function for reconfigure_gadget" << endl; + return; + } + ret = client_dev->reconfigure_gadget(client_dev, gadget_dev); + 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; + + if (!supported) + return; + + if (!client_dev || !client_dev->disable) { + cout << "There is no function for disable" << endl; + return; + } + ret = client_dev->disable(client_dev); + 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; + + if (!supported) + return; + + if (!info || !info->close) { + cout << "There is no function for info close" << endl; + return; + } + ret = info->close((struct hw_common *)client_dev); + EXPECT_EQ(ret, 0) << "Fail to close usb client device (" << ret << ")"; +} + +/* + * Testcase for Gadget + */ +TEST_F(USBGADGETHalTest, InitP) +{ + int ret; + + ret = hw_get_info(USB_GADGET_DEVICE_ID, + (const struct hw_info **)&info); + if (ret < 0) { + cout << "There is no device for usb gadget" << ret << endl; + return; + } else { + EXPECT_EQ(ret, 0) << "Fail to get hal for usb gadget (" << ret << ")"; + } + + if (!info || !info->open) { + cout << "There is no function for info open" << endl; + return; + } + ret = info->open(info, NULL, (struct hw_common**)&gadget_translator); + EXPECT_EQ(ret, 0) << "Fail to open usb gadget device (" << ret << ")"; +} + +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 << ")"; +} + +TEST_F(USBGADGETHalTest, CleanUpGadget) +{ + if (!gadget_translator || !gadget_translator->cleanup_gadget) { + cout << "There is no function for cleanup_gadget" << endl; + return; + } + gadget_translator->cleanup_gadget(gadget_dev); +} + +TEST_F(USBGADGETHalTest, DeinitP) +{ + int ret; + + if (!info || !info->close) { + cout << "There is no function for info close" << endl; + return; + } + ret = info->close((struct hw_common *)gadget_translator); + EXPECT_EQ(ret, 0) << "Fail to close usb gadget device (" << ret << ")"; +} + +int main(int argc, char **argv) +{ + testing::InitGoogleTest(&argc, argv); + + return RUN_ALL_TESTS(); +} diff --git a/unittest/gtest_hal_battery.cpp b/unittest/gtest_hal_battery.cpp deleted file mode 100755 index b7a5946..0000000 --- a/unittest/gtest_hal_battery.cpp +++ /dev/null @@ -1,126 +0,0 @@ - -#include <iostream> -#include <gtest/gtest.h> -#include <system_info.h> -#include "hw/battery.h" -#include "unittest.h" - -using namespace std; - -/* - * main class - */ -struct hw_info *info; -struct battery_device *battery_dev; -static bool need_featurecheck = true; - -class BATTERYHalTest : public testing::Test -{ - public: - virtual void SetUp() - { - int ret; - - if (need_featurecheck) { - ret = system_info_get_platform_bool(FEATURE_BATTERY, &supported); - EXPECT_EQ(SYSTEM_INFO_ERROR_NONE, ret) << "system_info_get_platform_bool failed"; - need_featurecheck = false; - } - } - - virtual void TearDown() - { - - } -}; - -/* - * testcase - */ -TEST_F(BATTERYHalTest, InitP) -{ - int ret; - - if (!supported) - return; - - ret = hw_get_info(BATTERY_HARDWARE_DEVICE_ID, - (const struct hw_info **)&info); - EXPECT_EQ(ret, 0) << "Fail to load battery hal (" << ret << ")"; - - if (!info->open) { - cout << "There is no function for info open" << endl; - return; - } - ret = info->open(info, NULL, (struct hw_common**)&battery_dev); - EXPECT_EQ(ret, 0) << "Fail to open battery device(" << ret << ")"; -} - -static void updated_cb(struct battery_info *info, void *data) -{ - -} - -TEST_F(BATTERYHalTest, RegisterChangedEventP) -{ - int ret; - - if (!supported) - return; - - if (!battery_dev->register_changed_event) { - cout << "There is no function for register_changed_event" << endl; - return; - } - ret = battery_dev->register_changed_event(updated_cb, NULL); - EXPECT_EQ(ret, 0) << "Fail to register_changed_event (" << ret << ")"; -} - -TEST_F(BATTERYHalTest, UnregisterChangedEventP) -{ - if (!supported) - return; - - if (!battery_dev->unregister_changed_event) { - cout << "There is no function for unregister_changed_event" << endl; - return; - } - battery_dev->unregister_changed_event(updated_cb); -} - -TEST_F(BATTERYHalTest, GetCurrentStateP) -{ - int ret; - - if (!supported) - return; - - if (!battery_dev->get_current_state) { - cout << "There is no function for get_current_state" << endl; - return; - } - ret = battery_dev->get_current_state(updated_cb, NULL); - EXPECT_EQ(ret, 0) << "Fail to get_current_state (" << ret << ")"; -} - -TEST_F(BATTERYHalTest, DeinitP) -{ - int ret; - - if (!supported) - return; - - if (!info->close) { - cout << "There is no function for info close" << endl; - return; - } - ret = info->close((struct hw_common *)battery_dev); - EXPECT_EQ(ret, 0) << "Fail to close battery device(" << ret << ")"; -} - -int main(int argc, char **argv) -{ - testing::InitGoogleTest(&argc, argv); - - return RUN_ALL_TESTS(); -} diff --git a/unittest/gtest_hal_cpu.cpp b/unittest/gtest_hal_cpu.cpp deleted file mode 100755 index e1541fa..0000000 --- a/unittest/gtest_hal_cpu.cpp +++ /dev/null @@ -1,100 +0,0 @@ - -#include <iostream> -#include <gtest/gtest.h> -#include "hw/cpu.h" - -using namespace std; - -/* - * main class - */ - -#define LOWBATTERY "LowBattery" - -struct hw_info *info; -struct cpu_device *cpu_dev; - -class CPUHalTest : public testing::Test -{ - public: - virtual void SetUp() - { - - } - - virtual void TearDown() - { - - } -}; - -/* - * testcase - */ -TEST_F(CPUHalTest, InitP) -{ - int ret; - - ret = hw_get_info(CPU_HARDWARE_DEVICE_ID, - (const struct hw_info **)&info); - if (ret < 0) { - cout << "There is no device for cpu " << ret << endl; - return; - } else { - EXPECT_EQ(ret, 0) << "Fail to load cpu hal (" << ret << ")"; - } - if (!info || !info->open) { - cout << "There is no function for info open" << endl; - return; - } - ret = info->open(info, NULL, (struct hw_common**)&cpu_dev); - EXPECT_EQ(ret, 0) << "Fail to open cpu device (" << ret << ")"; -} - -TEST_F(CPUHalTest, StartBoostP) -{ - int ret; - - if (!cpu_dev || !cpu_dev->start_boost) { - cout << "There is no function for start_boost" << endl; - return; - } - - // prprpr TODO - ret = cpu_dev->start_boost((void *)LOWBATTERY); - EXPECT_EQ(ret, 0) << "Fail to start_boost (" << ret << ")"; -} - -TEST_F(CPUHalTest, StopBoostP) -{ - int ret; - - if (!cpu_dev || !cpu_dev->stop_boost) { - cout << "There is no function for stop_boost" << endl; - return; - } - - // prprpr TODO - ret = cpu_dev->stop_boost((void *)LOWBATTERY); - EXPECT_EQ(ret, 0) << "Fail to stop_boost (" << ret << ")"; -} - -TEST_F(CPUHalTest, DeinitP) -{ - int ret; - - if (!info || !info->close) { - cout << "There is no function for info close" << endl; - return; - } - - ret = info->close((struct hw_common *)cpu_dev); - EXPECT_EQ(ret, 0) << "Fail to open cpu device (" << ret << ")"; -} - -int main(int argc, char **argv) -{ - testing::InitGoogleTest(&argc, argv); - - return RUN_ALL_TESTS(); -} diff --git a/unittest/gtest_hal_display.cpp b/unittest/gtest_hal_display.cpp deleted file mode 100755 index bb21cb2..0000000 --- a/unittest/gtest_hal_display.cpp +++ /dev/null @@ -1,215 +0,0 @@ - -#include <iostream> -#include <gtest/gtest.h> -#include "hw/display.h" - -using namespace std; - -/* - * main class - */ - -#define LOWBATTERY "LowBattery" - -struct hw_info *info; -struct display_device *display_dev; - -class DISPLAYHalTest : public testing::Test -{ - public: - virtual void SetUp() - { - - } - - virtual void TearDown() - { - - } -}; - -/* - * testcase - */ -TEST_F(DISPLAYHalTest, InitP) -{ - int ret; - - ret = hw_get_info(DISPLAY_HARDWARE_DEVICE_ID, - (const struct hw_info **)&info); - if (ret < 0) { - cout << "There is no device for display" << ret << endl; - return; - } else { - EXPECT_EQ(ret, 0) << "Fail to load display hal (" << ret << ")"; - } - - if (!info || !info->open) { - cout << "There is no function for info open" << endl; - return; - } - ret = info->open(info, NULL, (struct hw_common**)&display_dev); - EXPECT_EQ(ret, 0) << "Fail to open display device (" << ret << ")"; -} - -TEST_F(DISPLAYHalTest, GetMaxBrightnessP) -{ - int ret; - int max; - - if (!display_dev || !display_dev->get_max_brightness) { - cout << "There is no function for get_max_brightness" << endl; - return; - } - ret = display_dev->get_max_brightness(&max); - EXPECT_EQ(ret, 0) << "Fail to get_max_brightness (" << ret << ")"; -} - -TEST_F(DISPLAYHalTest, GetBrightnessP) -{ - int ret; - int brt; - - if (!display_dev || !display_dev->get_brightness) { - cout << "There is no function for get_brightness" << endl; - return; - } - ret = display_dev->get_brightness(&brt); - EXPECT_EQ(ret, 0) << "Fail to get_brightness (" << ret << ")"; -} - -TEST_F(DISPLAYHalTest, SetBrightnessP) -{ - int ret; - int max; - - if (!display_dev || !display_dev->get_max_brightness) { - cout << "There is no function for get_max_brightness" << endl; - return; - } - ret = display_dev->get_max_brightness(&max); - EXPECT_EQ(ret, 0) << "Fail to get_max_brightness (" << ret << ")"; - - if (!display_dev || !display_dev->set_brightness) { - cout << "There is no function for set_brightness" << endl; - return; - } - ret = display_dev->set_brightness(max); - EXPECT_EQ(ret, 0) << "Fail to set_brightness (" << ret << ")"; -} - -TEST_F(DISPLAYHalTest, GetAutoBrightnessP) -{ - int ret; - int brt; - float lmax = 0, lmin = 0, light = 0; - - if (!display_dev || !display_dev->get_auto_brightness) { - cout << "There is no function for get_auto_brightness" << endl; - return; - } - ret = display_dev->get_auto_brightness(lmax, lmin, light, &brt); - EXPECT_GE(ret, 0) << "Fail to set_brightness (" << ret << ")"; -} - -TEST_F(DISPLAYHalTest, GetStateP) -{ - int ret; - enum display_state state; - - if (!display_dev || !display_dev->get_state) { - cout << "There is no function for get_state" << endl; - return; - } - ret = display_dev->get_state(&state); - EXPECT_GE(ret, 0) << "Fail to get_state (" << ret << ")"; -} - -TEST_F(DISPLAYHalTest, SetStateP) -{ - int ret; - - if (!display_dev || !display_dev->set_state) { - cout << "There is no function for set_state" << endl; - return; - } - ret = display_dev->set_state(DISPLAY_ON); - EXPECT_GE(ret, 0) << "Fail to set_state (" << ret << ")"; -} - -TEST_F(DISPLAYHalTest, GetMaxFrameRateP) -{ - int ret; - int max; - - if (!display_dev || !display_dev->get_max_frame_rate) { - cout << "There is no function for get_max_frame_rate" << endl; - return; - } - ret = display_dev->get_max_frame_rate(&max); - EXPECT_GE(ret, 0) << "Fail to get_max_frame_rate (" << ret << ")"; -} - -TEST_F(DISPLAYHalTest, GetMinFrameRateP) -{ - int ret; - int min; - - if (!display_dev || !display_dev->get_min_frame_rate) { - cout << "There is no function for get_min_frame_rate" << endl; - return; - } - ret = display_dev->get_min_frame_rate(&min); - EXPECT_GE(ret, 0) << "Fail to get_min_frame_rate (" << ret << ")"; -} - -TEST_F(DISPLAYHalTest, GetFrameRateP) -{ - int ret, rate; - - if (!display_dev || !display_dev->get_frame_rate) { - cout << "There is no function for get_frame_rate" << endl; - return; - } - ret = display_dev->get_frame_rate(&rate); - EXPECT_GE(ret, 0) << "Fail to get frame rate (" << ret << ")"; -} - -TEST_F(DISPLAYHalTest, SetFrameRateP) -{ - int ret; - int max; - - if (!display_dev || !display_dev->get_max_frame_rate) { - cout << "There is no function for get_max_frame_rate" << endl; - return; - } - ret = display_dev->get_max_frame_rate(&max); - EXPECT_GE(ret, 0) << "Fail to get_max_frame_rate (" << ret << ")"; - - if (!display_dev->set_frame_rate) { - cout << "There is no function for set_frame_rate" << endl; - return; - } - ret = display_dev->set_frame_rate(max); - EXPECT_GE(ret, 0) << "Fail to set_frame_rate (" << ret << ")"; -} - -TEST_F(DISPLAYHalTest, DeinitP) -{ - int ret; - - if (!info || !info->close) { - cout << "There is no function for info close" << endl; - return; - } - ret = info->close((struct hw_common *)display_dev); - EXPECT_GE(ret, 0) << "Fail to close display device (" << ret << ")"; -} - -int main(int argc, char **argv) -{ - testing::InitGoogleTest(&argc, argv); - - return RUN_ALL_TESTS(); -} diff --git a/unittest/gtest_hal_extcon.cpp b/unittest/gtest_hal_extcon.cpp deleted file mode 100755 index cfb8c0f..0000000 --- a/unittest/gtest_hal_extcon.cpp +++ /dev/null @@ -1,107 +0,0 @@ - -#include <iostream> -#include <gtest/gtest.h> -#include "hw/external_connection.h" - -using namespace std; - -/* - * main class - */ -struct hw_info *info; -struct external_connection_device *ext_dev; - -class EXTCONHalTest : public testing::Test -{ - public: - virtual void SetUp() - { - - } - - virtual void TearDown() - { - - } -}; - -/* - * testcase - */ -TEST_F(EXTCONHalTest, InitP) -{ - int ret; - - ret = hw_get_info(EXTERNAL_CONNECTION_HARDWARE_DEVICE_ID, - (const struct hw_info **)&info); - if (ret < 0) { - cout << "There is no device for extcon" << ret << endl; - return; - } else { - EXPECT_EQ(ret, 0) << "Fail to load extcon hal (" << ret << ")"; - } - - if (!info || !info->open) { - cout << "There is no function for info open" << endl; - return; - } - ret = info->open(info, NULL, (struct hw_common**)&ext_dev); - EXPECT_EQ(ret, 0) << "Fail to open extcon device(" << ret << ")"; -} - -static void updated_cb(struct connection_info *info, void *data) -{ - -} - -TEST_F(EXTCONHalTest, RegisterChangedEventP) -{ - int ret; - - if (!ext_dev || !ext_dev->register_changed_event) { - cout << "There is no function for register_changed_event" << endl; - return; - } - ret = ext_dev->register_changed_event(updated_cb, NULL); - EXPECT_EQ(ret, 0) << "Fail to register_changed_event (" << ret << ")"; -} - -TEST_F(EXTCONHalTest, UnregisterChangedEventP) -{ - if (!ext_dev || !ext_dev->unregister_changed_event) { - cout << "There is no function for unregister_changed_event" << endl; - return; - } - ext_dev->unregister_changed_event(updated_cb); -} - -TEST_F(EXTCONHalTest, GetCurrentStateP) -{ - int ret; - - if (!ext_dev || !ext_dev->get_current_state) { - cout << "There is no function for unregister_changed_event" << endl; - return; - } - ret = ext_dev->get_current_state(updated_cb, NULL); - EXPECT_EQ(ret, 0) << "Fail to unregister_changed_event (" << ret << ")"; -} - -TEST_F(EXTCONHalTest, DeinitP) -{ - int ret; - - if (!info || !info->close) { - cout << "There is no function for info close" << endl; - return; - } - ret = info->close((struct hw_common *)ext_dev); - EXPECT_EQ(ret, 0) << "Fail to close extcon device(" << ret << ")"; -} - -int main(int argc, char **argv) -{ - testing::InitGoogleTest(&argc, argv); - - return RUN_ALL_TESTS(); -} diff --git a/unittest/gtest_hal_ir.cpp b/unittest/gtest_hal_ir.cpp deleted file mode 100755 index 4b77f20..0000000 --- a/unittest/gtest_hal_ir.cpp +++ /dev/null @@ -1,111 +0,0 @@ - -#include <iostream> -#include <gtest/gtest.h> -#include <system_info.h> -#include "hw/ir.h" -#include "unittest.h" - -using namespace std; - -/* - * main class - */ -struct hw_info *info; -struct ir_device *ir_dev; -static bool need_featurecheck = true; - -class IRHalTest : public testing::Test -{ - public: - virtual void SetUp() - { - int ret; - - if (need_featurecheck) { - ret = system_info_get_platform_bool(FEATURE_IR, &supported); - EXPECT_EQ(SYSTEM_INFO_ERROR_NONE, ret) << "system_info_get_platform_bool failed"; - need_featurecheck = false; - } - } - - virtual void TearDown() - { - - } -}; - -/* - * testcase - */ -TEST_F(IRHalTest, InitP) -{ - int ret; - - if (!supported) - return; - - ret = hw_get_info(IR_HARDWARE_DEVICE_ID, - (const struct hw_info **)&info); - EXPECT_EQ(ret, 0) << "Fail to get hal for ir (" << ret << ")"; - - if (!info->open) { - cout << "There is no function for info open" << endl; - return; - } - ret = info->open(info, NULL, (struct hw_common**)&ir_dev); - EXPECT_EQ(ret, 0) << "Fail to open ir device (" << ret << ")"; -} - -TEST_F(IRHalTest, IsAvailableP) -{ - int ret; - bool val; - - if (!supported) - return; - - if (!ir_dev->is_available) { - cout << "There is no function for is_available" << endl; - return; - } - ret = ir_dev->is_available(&val); - EXPECT_EQ(ret, 0) << "Fail to is_available (" << ret << ")"; -} - -TEST_F(IRHalTest, TransmitP) -{ - int ret; - int pattern[5] = {100, 200, 300, 400, 500}; - - if (!supported) - return; - - if (!ir_dev->transmit) { - cout << "There is no function for transmit" << endl; - return; - } - ret = ir_dev->transmit(pattern, 5); - EXPECT_EQ(ret, 0) << "Fail to transmit (" << ret << ")"; -} - -TEST_F(IRHalTest, DeinitP) -{ - int ret; - - if (!supported) - return; - - if (!info->close) { - cout << "There is no function for info close" << endl; - return; - } - ret = info->close((struct hw_common *)ir_dev); - EXPECT_EQ(ret, 0) << "Fail to close ir device (" << ret << ")"; -} - -int main(int argc, char **argv) -{ - testing::InitGoogleTest(&argc, argv); - - return RUN_ALL_TESTS(); -} diff --git a/unittest/gtest_hal_rgb.cpp b/unittest/gtest_hal_rgb.cpp deleted file mode 100755 index d3325be..0000000 --- a/unittest/gtest_hal_rgb.cpp +++ /dev/null @@ -1,100 +0,0 @@ - -#include <iostream> -#include <gtest/gtest.h> -#include <system_info.h> -#include "hw/led.h" -#include "unittest.h" - -using namespace std; - -/* - * main class - */ -struct hw_info *info; -struct led_device *rgb_dev; -static bool need_featurecheck = true; - -class RGBHalTest : public testing::Test -{ - public: - virtual void SetUp() - { - int ret; - - if (need_featurecheck) { - ret = system_info_get_platform_bool(FEATURE_LED, &supported); - EXPECT_EQ(SYSTEM_INFO_ERROR_NONE, ret) << "system_info_get_platform_bool failed"; - need_featurecheck = false; - } - } - - virtual void TearDown() - { - - } -}; - -/* - * testcase - */ -TEST_F(RGBHalTest, InitP) -{ - int ret; - - if (!supported) - return; - - ret = hw_get_info(LED_HARDWARE_DEVICE_ID, - (const struct hw_info **)&info); - EXPECT_EQ(ret, 0) << "Fail to get hal for rgb (" << ret << ")"; - - if (!info->open) { - cout << "There is no function for info open" << endl; - return; - } - ret = info->open(info, LED_ID_NOTIFICATION, (struct hw_common**)&rgb_dev); - EXPECT_EQ(ret, 0) << "Fail to open rgb device (" << ret << ")"; -} - -TEST_F(RGBHalTest, SetStateP) -{ - struct led_state state; - int ret; - - if (!supported) - return; - - if (!rgb_dev->set_state) { - cout << "There is no function for set_state" << endl; - return; - } - - state.type = LED_TYPE_BLINK; - state.color = 0xFFFFFF; - state.duty_on = 500; - state.duty_off = 500; - ret = rgb_dev->set_state(&state); - EXPECT_GE(ret, 0) << "Fail to set_state (" << ret << ")"; -} - -TEST_F(RGBHalTest, DeinitP) -{ - int ret; - - if (!supported) - return; - - if (!info->close) { - cout << "There is no function for info close" << endl; - return; - } - ret = info->close((struct hw_common *)rgb_dev); - EXPECT_GE(ret, 0) << "Fail to close rgb device (" << ret << ")"; -} - -int main(int argc, char **argv) -{ - testing::InitGoogleTest(&argc, argv); - - return RUN_ALL_TESTS(); -} diff --git a/unittest/gtest_hal_thermal.cpp b/unittest/gtest_hal_thermal.cpp deleted file mode 100755 index 9d0838b..0000000 --- a/unittest/gtest_hal_thermal.cpp +++ /dev/null @@ -1,110 +0,0 @@ - -#include <iostream> -#include <gtest/gtest.h> -#include <system_info.h> -#include "hw/thermal.h" -#include "unittest.h" - -using namespace std; - -/* - * main class - */ -struct hw_info *info; -struct thermal_device *thermal_dev; - -class THERMALHalTest : public testing::Test -{ - public: - virtual void SetUp() - { - - } - - virtual void TearDown() - { - - } -}; - -/* - * testcase - */ -TEST_F(THERMALHalTest, InitP) -{ - int ret; - - ret = hw_get_info(THERMAL_HARDWARE_DEVICE_ID, - (const struct hw_info **)&info); - if (ret < 0) { - cout << "There is no device for thermal" << ret << endl; - return; - } else { - EXPECT_EQ(ret, 0) << "Fail to get hal for thermal (" << ret << ")"; - } - - if (!info || !info->open) { - cout << "There is no function for info open" << endl; - return; - } - ret = info->open(info, NULL, (struct hw_common**)&thermal_dev); - EXPECT_EQ(ret, 0) << "Fail to open thermal device (" << ret << ")"; -} - -TEST_F(THERMALHalTest, GetStateP) -{ - struct thermal_info thermal; - int ret; - - if (!thermal_dev || !thermal_dev->get_state) { - cout << "There is no function for get_state" << endl; - return; - } - ret = thermal_dev->get_state(&thermal); - EXPECT_EQ(ret, 0) << "Fail to get_state (" << ret << ")"; -} - -static void updated_cb(struct thermal_info *info, void *data) -{ - -} - -TEST_F(THERMALHalTest, RegisterChangedEventP) -{ - int ret; - - if (!thermal_dev || !thermal_dev->register_changed_event) { - cout << "There is no function for register_changed_event" << endl; - return; - } - ret = thermal_dev->register_changed_event(updated_cb, NULL); - EXPECT_EQ(ret, 0) << "Fail to register_changed_event (" << ret << ")"; -} - -TEST_F(THERMALHalTest, UnregisterChangedEventP) -{ - if (!thermal_dev || !thermal_dev->unregister_changed_event) { - cout << "There is no function for unregister_changed_event" << endl; - return; - } - thermal_dev->unregister_changed_event(updated_cb); -} - -TEST_F(THERMALHalTest, DeinitP) -{ - int ret; - - if (!info || !info->close) { - cout << "There is no function for info close" << endl; - return; - } - ret = info->close((struct hw_common *)thermal_dev); - EXPECT_EQ(ret, 0) << "Fail to close thermal device (" << ret << ")"; -} - -int main(int argc, char **argv) -{ - testing::InitGoogleTest(&argc, argv); - - return RUN_ALL_TESTS(); -} diff --git a/unittest/gtest_hal_touchscreen.cpp b/unittest/gtest_hal_touchscreen.cpp deleted file mode 100755 index 046cef8..0000000 --- a/unittest/gtest_hal_touchscreen.cpp +++ /dev/null @@ -1,83 +0,0 @@ - -#include <iostream> -#include <gtest/gtest.h> -#include "hw/common.h" -#include "hw/touchscreen.h" - -using namespace std; - -/* - * main class - */ -struct hw_info *info; -struct touchscreen_device *touchscreen_dev; - -class TOUCHSCREENHalTest : public testing::Test -{ - public: - virtual void SetUp() - { - - } - - virtual void TearDown() - { - - } -}; - -/* - * testcase - */ -TEST_F(TOUCHSCREENHalTest, InitP) -{ - int ret; - - ret = hw_get_info(TOUCHSCREEN_HARDWARE_DEVICE_ID, - (const struct hw_info **)&info); - if (ret < 0) { - cout << "There is no device for touchscreen" << ret << endl; - return; - } else { - EXPECT_EQ(ret, 0) << "Fail to get hal for touchscreen (" << ret << ")"; - } - - if (!info || !info->open) { - cout << "There is no function for info open" << endl; - return; - } - ret = info->open(info, NULL, (struct hw_common**)&touchscreen_dev); - EXPECT_EQ(ret, 0) << "Fail to open touchscreen device (" << ret << ")"; -} - -TEST_F(TOUCHSCREENHalTest, SetstateP) -{ - enum touchscreen_state state = TOUCHSCREEN_ON; - int ret; - - if (!touchscreen_dev || !touchscreen_dev->set_state) { - cout << "There is no function for set_state" << endl; - return; - } - ret = touchscreen_dev->set_state(state); - EXPECT_EQ(ret, 0) << "Fail to set_state (" << ret << ")"; -} - -TEST_F(TOUCHSCREENHalTest, DeinitP) -{ - int ret; - - if (!info || !info->close) { - cout << "There is no function for info close" << endl; - return; - } - ret = info->close((struct hw_common *)touchscreen_dev); - EXPECT_EQ(ret, 0) << "Fail to close touchscreen device (" << ret << ")"; -} - -int main(int argc, char **argv) -{ - testing::InitGoogleTest(&argc, argv); - - return RUN_ALL_TESTS(); -} diff --git a/unittest/gtest_hal_usb_client.cpp b/unittest/gtest_hal_usb_client.cpp deleted file mode 100755 index 597823c..0000000 --- a/unittest/gtest_hal_usb_client.cpp +++ /dev/null @@ -1,236 +0,0 @@ - -#include <iostream> -#include <gtest/gtest.h> -#include <system_info.h> -#include "hw/usb_client.h" -#include "unittest.h" - -using namespace std; - -/* - * main class - */ -struct hw_info *info; -struct usb_client *client_dev; -struct usb_gadget *gadget_dev; -struct usb_gadget_id gadget_id; -struct usb_gadget_translator *gadget_translator; -static bool need_modelcheck = true; - -#define MODEL_NAME "http://tizen.org/system/model_name" - -class USBCLIENTHalTest : public testing::Test -{ - public: - virtual void SetUp() - { - int ret; - char *model_name = NULL; - - if (need_modelcheck) { - ret = system_info_get_platform_string(MODEL_NAME, &model_name); - EXPECT_EQ(SYSTEM_INFO_ERROR_NONE, ret) << "system_info_get_platform_bool failed"; - - if (!strncmp(model_name, "artik", 5)) { - supported = true; - } else { - supported = false; - } - cout << "supported " << supported << endl; - need_modelcheck = false; - free(model_name); - } - } - - virtual void TearDown() - { - - } -}; - -/* - * testcase - */ -TEST_F(USBCLIENTHalTest, InitP) -{ - int ret; - - if (!supported) - return; - - ret = hw_get_info(USB_CLIENT_HARDWARE_DEVICE_ID, - (const struct hw_info **)&info); - if (ret < 0) { - cout << "There is no device for usb client" << ret << endl; - return; - } else { - EXPECT_EQ(ret, 0) << "Fail to get hal for usb client (" << ret << ")"; - } - if (!info || !info->open) { - cout << "There is no function for info open" << endl; - return; - } - ret = info->open(info, NULL, (struct hw_common**)&client_dev); - EXPECT_EQ(ret, 0) << "Fail to open usb client device (" << ret << ")"; - EXPECT_NE(client_dev, nullptr) << "Fail to get usb client device structure"; - - ret = hw_get_info(USB_GADGET_DEVICE_ID, - (const struct hw_info **)&info); - if (ret < 0) { - cout << "There is no device for usb gadget" << ret << endl; - return; - } else { - EXPECT_EQ(ret, 0) << "Fail to get hal for usb gadget (" << ret << ")"; - } - - if (!info || !info->open) { - cout << "There is no function for info open" << endl; - return; - } - ret = info->open(info, NULL, (struct hw_common**)&gadget_translator); - EXPECT_EQ(ret, 0) << "Fail to open usb gadget device (" << ret << ")"; -} - -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; - } - ret = client_dev->enable(client_dev); - EXPECT_EQ(ret, 0) << "Fail to enable (" << ret << ")"; -} - -TEST_F(USBCLIENTHalTest, ReConfigureGadgetP) -{ - int ret; - - if (!supported) - return; - - if (!gadget_translator || !gadget_translator->id_to_gadget) { - cout << "There is no function for id_to_gadget" << endl; - return; - } - 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 << ")"; - - if (!client_dev || !client_dev->disable) { - cout << "There is no function for disable" << endl; - return; - } - ret = client_dev->disable(client_dev); - EXPECT_EQ(ret, 0) << "Fail to disable (" << ret << ")"; - - if (!client_dev || !client_dev->reconfigure_gadget) { - cout << "There is no function for reconfigure_gadget" << endl; - return; - } - ret = client_dev->reconfigure_gadget(client_dev, gadget_dev); - 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; - - if (!supported) - return; - - if (!client_dev || !client_dev->disable) { - cout << "There is no function for disable" << endl; - return; - } - ret = client_dev->disable(client_dev); - 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; - - if (!supported) - return; - - if (!info || !info->close) { - cout << "There is no function for info close" << endl; - return; - } - ret = info->close((struct hw_common *)client_dev); - EXPECT_EQ(ret, 0) << "Fail to close usb client device (" << ret << ")"; -} - -int main(int argc, char **argv) -{ - testing::InitGoogleTest(&argc, argv); - - return RUN_ALL_TESTS(); -} - diff --git a/unittest/gtest_hal_usb_gadget.cpp b/unittest/gtest_hal_usb_gadget.cpp deleted file mode 100755 index 4b567c2..0000000 --- a/unittest/gtest_hal_usb_gadget.cpp +++ /dev/null @@ -1,98 +0,0 @@ - -#include <iostream> -#include <gtest/gtest.h> -#include <system_info.h> -#include "hw/usb_gadget.h" -#include "unittest.h" - -using namespace std; - -/* - * main class - */ -struct hw_info *info; -struct usb_gadget *gadget_dev; -struct usb_gadget_translator *gadget_translator; - -class USBGADGETHalTest : public testing::Test -{ - public: - virtual void SetUp() - { - - } - - virtual void TearDown() - { - - } -}; - -/* - * testcase - */ -TEST_F(USBGADGETHalTest, InitP) -{ - int ret; - - ret = hw_get_info(USB_GADGET_DEVICE_ID, - (const struct hw_info **)&info); - if (ret < 0) { - cout << "There is no device for usb gadget" << ret << endl; - return; - } else { - EXPECT_EQ(ret, 0) << "Fail to get hal for usb gadget (" << ret << ")"; - } - - if (!info || !info->open) { - cout << "There is no function for info open" << endl; - return; - } - ret = info->open(info, NULL, (struct hw_common**)&gadget_translator); - EXPECT_EQ(ret, 0) << "Fail to open usb gadget device (" << ret << ")"; -} - -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 << ")"; -} - -TEST_F(USBGADGETHalTest, CleanUpGadget) -{ - if (!gadget_translator || !gadget_translator->cleanup_gadget) { - cout << "There is no function for cleanup_gadget" << endl; - return; - } - gadget_translator->cleanup_gadget(gadget_dev); -} - -TEST_F(USBGADGETHalTest, DeinitP) -{ - int ret; - - if (!info || !info->close) { - cout << "There is no function for info close" << endl; - return; - } - ret = info->close((struct hw_common *)gadget_translator); - EXPECT_EQ(ret, 0) << "Fail to close usb gadget device (" << ret << ")"; -} - -int main(int argc, char **argv) -{ - testing::InitGoogleTest(&argc, argv); - - return RUN_ALL_TESTS(); -} |