3 #include <gtest/gtest.h>
4 #include <system_info.h>
6 #include "hw/battery.h"
8 #include "hw/display.h"
9 #include "hw/external_connection.h"
12 #include "hw/thermal.h"
13 #include "hw/touchscreen.h"
14 #include "hw/usb_client.h"
15 #include "hw/usb_gadget.h"
17 #include "hw/touchsensitivity.h"
24 #define MODEL_NAME "http://tizen.org/system/model_name"
25 #define LOWBATTERY "LowBattery"
28 struct battery_device *battery_dev;
29 struct cpu_device *cpu_dev;
30 struct display_device *display_dev;
31 struct external_connection_device *ext_dev;
32 struct ir_device *ir_dev;
33 struct led_device *rgb_dev;
34 struct thermal_device *thermal_dev;
35 struct touchscreen_device *touchscreen_dev;
36 struct usb_client *client_dev;
37 struct usb_gadget *gadget_dev;
38 struct usb_gadget_id gadget_id;
39 struct usb_gadget_translator *gadget_translator;
40 struct bezel_device *bezel_dev;
41 struct touchsensitivity_device *touchsensitivity_dev;
45 class BATTERYHalTest : public testing::Test
52 ret = system_info_get_platform_bool(FEATURE_BATTERY, &supported);
53 EXPECT_EQ(SYSTEM_INFO_ERROR_NONE, ret) << "system_info_get_platform_bool failed";
57 virtual void TearDown()
63 class CPUHalTest : public testing::Test
71 virtual void TearDown()
77 class DISPLAYHalTest : public testing::Test
85 virtual void TearDown()
91 class EXTCONHalTest : public testing::Test
99 virtual void TearDown()
105 class IRHalTest : public testing::Test
112 ret = system_info_get_platform_bool(FEATURE_IR, &supported);
113 EXPECT_EQ(SYSTEM_INFO_ERROR_NONE, ret) << "system_info_get_platform_bool failed";
116 virtual void TearDown()
122 class RGBHalTest : public testing::Test
129 ret = system_info_get_platform_bool(FEATURE_LED, &supported);
130 EXPECT_EQ(SYSTEM_INFO_ERROR_NONE, ret) << "system_info_get_platform_bool failed";
133 virtual void TearDown()
139 class THERMALHalTest : public testing::Test
146 ret = system_info_get_platform_bool(FEATURE_THERMISTOR, &supported);
147 EXPECT_EQ(SYSTEM_INFO_ERROR_NONE, ret) << "system_info_get_platform_bool failed";
150 virtual void TearDown()
156 class TOUCHSCREENHalTest : public testing::Test
164 virtual void TearDown()
170 class TOUCHSENSITIVITYHalTest : public testing::Test
178 virtual void TearDown()
184 class BEZELHalTest : public testing::Test
191 ret = system_info_get_platform_bool(FEATURE_BEZEL, &supported);
192 EXPECT_EQ(SYSTEM_INFO_ERROR_NONE, ret) << "system_info_get_platform_bool failed";
195 virtual void TearDown()
201 class USBCLIENTHalTest : public testing::Test
207 char *model_name = NULL;
209 ret = system_info_get_platform_string(MODEL_NAME, &model_name);
210 EXPECT_EQ(SYSTEM_INFO_ERROR_NONE, ret) << "system_info_get_platform_bool failed";
212 if (!strncmp(model_name, "artik", 5)) {
217 cout << "supported " << supported << endl;
221 virtual void TearDown()
227 class USBGADGETHalTest : public testing::Test
235 virtual void TearDown()
242 * Testcase for Battery
244 TEST_F(BATTERYHalTest, InitP)
252 ret = hw_get_info(BATTERY_HARDWARE_DEVICE_ID,
253 (const struct hw_info **)&info);
254 EXPECT_EQ(ret, 0) << "Fail to load battery hal (" << ret << ")";
257 cout << "There is no function for info open" << endl;
260 ret = info->open(info, NULL, (struct hw_common**)&battery_dev);
261 EXPECT_EQ(ret, 0) << "Fail to open battery device(" << ret << ")";
264 static void battery_updated_cb(struct battery_info *info, void *data)
269 TEST_F(BATTERYHalTest, RegisterChangedEventP)
276 if (!battery_dev->register_changed_event) {
277 cout << "There is no function for register_changed_event" << endl;
280 ret = battery_dev->register_changed_event(battery_updated_cb, NULL);
281 EXPECT_EQ(ret, 0) << "Fail to register_changed_event (" << ret << ")";
284 TEST_F(BATTERYHalTest, UnregisterChangedEventP)
289 if (!battery_dev->unregister_changed_event) {
290 cout << "There is no function for unregister_changed_event" << endl;
293 battery_dev->unregister_changed_event(battery_updated_cb);
296 TEST_F(BATTERYHalTest, GetCurrentStateP)
303 if (!battery_dev->get_current_state) {
304 cout << "There is no function for get_current_state" << endl;
307 ret = battery_dev->get_current_state(battery_updated_cb, NULL);
308 EXPECT_EQ(ret, 0) << "Fail to get_current_state (" << ret << ")";
311 TEST_F(BATTERYHalTest, DeinitP)
319 cout << "There is no function for info close" << endl;
322 ret = info->close((struct hw_common *)battery_dev);
323 EXPECT_EQ(ret, 0) << "Fail to close battery device(" << ret << ")";
329 TEST_F(CPUHalTest, InitP)
334 ret = hw_get_info(CPU_HARDWARE_DEVICE_ID,
335 (const struct hw_info **)&info);
337 cout << "There is no device for cpu " << ret << endl;
340 EXPECT_EQ(ret, 0) << "Fail to load cpu hal (" << ret << ")";
342 if (!info || !info->open) {
343 cout << "There is no function for info open" << endl;
346 ret = info->open(info, NULL, (struct hw_common**)&cpu_dev);
347 EXPECT_EQ(ret, 0) << "Fail to open cpu device (" << ret << ")";
350 TEST_F(CPUHalTest, StartBoostP)
354 if (!cpu_dev || !cpu_dev->start_boost) {
355 cout << "There is no function for start_boost" << endl;
360 ret = cpu_dev->start_boost((void *)LOWBATTERY);
361 EXPECT_EQ(ret, 0) << "Fail to start_boost (" << ret << ")";
364 TEST_F(CPUHalTest, StopBoostP)
368 if (!cpu_dev || !cpu_dev->stop_boost) {
369 cout << "There is no function for stop_boost" << endl;
374 ret = cpu_dev->stop_boost((void *)LOWBATTERY);
375 EXPECT_EQ(ret, 0) << "Fail to stop_boost (" << ret << ")";
378 TEST_F(CPUHalTest, DeinitP)
382 if (!info || !info->close) {
383 cout << "There is no function for info close" << endl;
387 ret = info->close((struct hw_common *)cpu_dev);
388 EXPECT_EQ(ret, 0) << "Fail to open cpu device (" << ret << ")";
392 * Testcase for Display
394 TEST_F(DISPLAYHalTest, InitP)
399 ret = hw_get_info(DISPLAY_HARDWARE_DEVICE_ID,
400 (const struct hw_info **)&info);
402 cout << "There is no device for display" << ret << endl;
405 EXPECT_EQ(ret, 0) << "Fail to load display hal (" << ret << ")";
408 if (!info || !info->open) {
409 cout << "There is no function for info open" << endl;
412 ret = info->open(info, NULL, (struct hw_common**)&display_dev);
413 EXPECT_EQ(ret, 0) << "Fail to open display device (" << ret << ")";
416 TEST_F(DISPLAYHalTest, GetMaxBrightnessP)
421 if (!display_dev || !display_dev->get_max_brightness) {
422 cout << "There is no function for get_max_brightness" << endl;
425 ret = display_dev->get_max_brightness(&max);
426 EXPECT_EQ(ret, 0) << "Fail to get_max_brightness (" << ret << ")";
429 TEST_F(DISPLAYHalTest, GetBrightnessP)
434 if (!display_dev || !display_dev->get_brightness) {
435 cout << "There is no function for get_brightness" << endl;
438 ret = display_dev->get_brightness(&brt);
439 EXPECT_EQ(ret, 0) << "Fail to get_brightness (" << ret << ")";
442 TEST_F(DISPLAYHalTest, SetBrightnessP)
447 if (!display_dev || !display_dev->get_max_brightness) {
448 cout << "There is no function for get_max_brightness" << endl;
451 ret = display_dev->get_max_brightness(&max);
452 EXPECT_EQ(ret, 0) << "Fail to get_max_brightness (" << ret << ")";
454 if (!display_dev || !display_dev->set_brightness) {
455 cout << "There is no function for set_brightness" << endl;
458 ret = display_dev->set_brightness(max);
459 EXPECT_EQ(ret, 0) << "Fail to set_brightness (" << ret << ")";
462 TEST_F(DISPLAYHalTest, GetAutoBrightnessP)
466 float lmax = 0, lmin = 0, light = 0;
468 if (!display_dev || !display_dev->get_auto_brightness) {
469 cout << "There is no function for get_auto_brightness" << endl;
472 ret = display_dev->get_auto_brightness(lmax, lmin, light, &brt);
473 EXPECT_GE(ret, 0) << "Fail to set_brightness (" << ret << ")";
476 TEST_F(DISPLAYHalTest, GetStateP)
479 enum display_state state;
481 if (!display_dev || !display_dev->get_state) {
482 cout << "There is no function for get_state" << endl;
485 ret = display_dev->get_state(&state);
486 EXPECT_GE(ret, 0) << "Fail to get_state (" << ret << ")";
489 TEST_F(DISPLAYHalTest, SetStateP)
493 if (!display_dev || !display_dev->set_state) {
494 cout << "There is no function for set_state" << endl;
497 ret = display_dev->set_state(DISPLAY_ON);
498 EXPECT_GE(ret, 0) << "Fail to set_state (" << ret << ")";
501 TEST_F(DISPLAYHalTest, GetMaxFrameRateP)
506 if (!display_dev || !display_dev->get_max_frame_rate) {
507 cout << "There is no function for get_max_frame_rate" << endl;
510 ret = display_dev->get_max_frame_rate(&max);
511 EXPECT_GE(ret, 0) << "Fail to get_max_frame_rate (" << ret << ")";
514 TEST_F(DISPLAYHalTest, GetMinFrameRateP)
519 if (!display_dev || !display_dev->get_min_frame_rate) {
520 cout << "There is no function for get_min_frame_rate" << endl;
523 ret = display_dev->get_min_frame_rate(&min);
524 EXPECT_GE(ret, 0) << "Fail to get_min_frame_rate (" << ret << ")";
527 TEST_F(DISPLAYHalTest, GetFrameRateP)
531 if (!display_dev || !display_dev->get_frame_rate) {
532 cout << "There is no function for get_frame_rate" << endl;
535 ret = display_dev->get_frame_rate(&rate);
536 EXPECT_GE(ret, 0) << "Fail to get frame rate (" << ret << ")";
539 TEST_F(DISPLAYHalTest, SetFrameRateP)
544 if (!display_dev || !display_dev->get_max_frame_rate) {
545 cout << "There is no function for get_max_frame_rate" << endl;
548 ret = display_dev->get_max_frame_rate(&max);
549 EXPECT_GE(ret, 0) << "Fail to get_max_frame_rate (" << ret << ")";
551 if (!display_dev->set_frame_rate) {
552 cout << "There is no function for set_frame_rate" << endl;
555 ret = display_dev->set_frame_rate(max);
556 EXPECT_GE(ret, 0) << "Fail to set_frame_rate (" << ret << ")";
559 TEST_F(DISPLAYHalTest, DeinitP)
563 if (!info || !info->close) {
564 cout << "There is no function for info close" << endl;
567 ret = info->close((struct hw_common *)display_dev);
568 EXPECT_GE(ret, 0) << "Fail to close display device (" << ret << ")";
572 * Testcase for Extcon
574 TEST_F(EXTCONHalTest, InitP)
579 ret = hw_get_info(EXTERNAL_CONNECTION_HARDWARE_DEVICE_ID,
580 (const struct hw_info **)&info);
582 cout << "There is no device for extcon" << ret << endl;
585 EXPECT_EQ(ret, 0) << "Fail to load extcon hal (" << ret << ")";
588 if (!info || !info->open) {
589 cout << "There is no function for info open" << endl;
592 ret = info->open(info, NULL, (struct hw_common**)&ext_dev);
593 EXPECT_EQ(ret, 0) << "Fail to open extcon device(" << ret << ")";
596 static void extcon_updated_cb(struct connection_info *info, void *data)
601 TEST_F(EXTCONHalTest, RegisterChangedEventP)
605 if (!ext_dev || !ext_dev->register_changed_event) {
606 cout << "There is no function for register_changed_event" << endl;
609 ret = ext_dev->register_changed_event(extcon_updated_cb, NULL);
610 EXPECT_EQ(ret, 0) << "Fail to register_changed_event (" << ret << ")";
613 TEST_F(EXTCONHalTest, UnregisterChangedEventP)
615 if (!ext_dev || !ext_dev->unregister_changed_event) {
616 cout << "There is no function for unregister_changed_event" << endl;
619 ext_dev->unregister_changed_event(extcon_updated_cb);
622 TEST_F(EXTCONHalTest, GetCurrentStateP)
626 if (!ext_dev || !ext_dev->get_current_state) {
627 cout << "There is no function for unregister_changed_event" << endl;
630 ret = ext_dev->get_current_state(extcon_updated_cb, NULL);
631 EXPECT_EQ(ret, 0) << "Fail to unregister_changed_event (" << ret << ")";
634 TEST_F(EXTCONHalTest, DeinitP)
638 if (!info || !info->close) {
639 cout << "There is no function for info close" << endl;
642 ret = info->close((struct hw_common *)ext_dev);
643 EXPECT_EQ(ret, 0) << "Fail to close extcon device(" << ret << ")";
649 TEST_F(IRHalTest, InitP)
657 ret = hw_get_info(IR_HARDWARE_DEVICE_ID,
658 (const struct hw_info **)&info);
659 EXPECT_EQ(ret, 0) << "Fail to get hal for ir (" << ret << ")";
662 cout << "There is no function for info open" << endl;
665 ret = info->open(info, NULL, (struct hw_common**)&ir_dev);
666 EXPECT_EQ(ret, 0) << "Fail to open ir device (" << ret << ")";
669 TEST_F(IRHalTest, IsAvailableP)
677 if (!ir_dev->is_available) {
678 cout << "There is no function for is_available" << endl;
681 ret = ir_dev->is_available(&val);
682 EXPECT_EQ(ret, 0) << "Fail to is_available (" << ret << ")";
685 TEST_F(IRHalTest, TransmitP)
688 int pattern[5] = {100, 200, 300, 400, 500};
693 if (!ir_dev->transmit) {
694 cout << "There is no function for transmit" << endl;
697 ret = ir_dev->transmit(pattern, 5);
698 EXPECT_EQ(ret, 0) << "Fail to transmit (" << ret << ")";
701 TEST_F(IRHalTest, DeinitP)
709 cout << "There is no function for info close" << endl;
712 ret = info->close((struct hw_common *)ir_dev);
713 EXPECT_EQ(ret, 0) << "Fail to close ir device (" << ret << ")";
719 TEST_F(RGBHalTest, InitP)
727 ret = hw_get_info(LED_HARDWARE_DEVICE_ID,
728 (const struct hw_info **)&info);
729 EXPECT_EQ(ret, 0) << "Fail to get hal for rgb (" << ret << ")";
732 cout << "There is no function for info open" << endl;
735 ret = info->open(info, LED_ID_NOTIFICATION, (struct hw_common**)&rgb_dev);
736 EXPECT_EQ(ret, 0) << "Fail to open rgb device (" << ret << ")";
739 TEST_F(RGBHalTest, SetStateP)
741 struct led_state state;
747 if (!rgb_dev->set_state) {
748 cout << "There is no function for set_state" << endl;
752 state.type = LED_TYPE_BLINK;
753 state.color = 0xFFFFFF;
755 state.duty_off = 500;
756 ret = rgb_dev->set_state(&state);
757 EXPECT_GE(ret, 0) << "Fail to set_state (" << ret << ")";
760 TEST_F(RGBHalTest, DeinitP)
768 cout << "There is no function for info close" << endl;
771 ret = info->close((struct hw_common *)rgb_dev);
772 EXPECT_GE(ret, 0) << "Fail to close rgb device (" << ret << ")";
776 * Testcase for Thermal
778 TEST_F(THERMALHalTest, InitP)
786 ret = hw_get_info(THERMAL_HARDWARE_DEVICE_ID,
787 (const struct hw_info **)&info);
789 cout << "There is no device for thermal" << ret << endl;
792 EXPECT_EQ(ret, 0) << "Fail to get hal for thermal (" << ret << ")";
795 if (!info || !info->open) {
796 cout << "There is no function for info open" << endl;
799 ret = info->open(info, NULL, (struct hw_common**)&thermal_dev);
800 EXPECT_EQ(ret, 0) << "Fail to open thermal device (" << ret << ")";
803 TEST_F(THERMALHalTest, GetInfoP)
805 struct thermal_info thermal;
811 if (!thermal_dev || !thermal_dev->get_info) {
812 cout << "There is no function for get_info" << endl;
815 ret = thermal_dev->get_info(DEVICE_THERMAL_AP, &thermal);
816 EXPECT_EQ(ret, 0) << "Fail to get_info (" << ret << ")";
819 static void thermal_updated_cb(struct thermal_info *info, void *data)
824 TEST_F(THERMALHalTest, RegisterChangedEventP)
831 if (!thermal_dev || !thermal_dev->register_changed_event) {
832 cout << "There is no function for register_changed_event" << endl;
835 ret = thermal_dev->register_changed_event(thermal_updated_cb, NULL);
836 EXPECT_EQ(ret, 0) << "Fail to register_changed_event (" << ret << ")";
839 TEST_F(THERMALHalTest, UnregisterChangedEventP)
844 if (!thermal_dev || !thermal_dev->unregister_changed_event) {
845 cout << "There is no function for unregister_changed_event" << endl;
848 thermal_dev->unregister_changed_event(thermal_updated_cb);
851 TEST_F(THERMALHalTest, DeinitP)
858 if (!info || !info->close) {
859 cout << "There is no function for info close" << endl;
862 ret = info->close((struct hw_common *)thermal_dev);
863 EXPECT_EQ(ret, 0) << "Fail to close thermal device (" << ret << ")";
867 * Testcase for Touchscreen
869 TEST_F(TOUCHSCREENHalTest, InitP)
874 ret = hw_get_info(TOUCHSCREEN_HARDWARE_DEVICE_ID,
875 (const struct hw_info **)&info);
877 cout << "There is no device for touchscreen " << ret << endl;
880 EXPECT_EQ(ret, 0) << "Fail to get hal for touchscreen (" << ret << ")";
883 if (!info || !info->open) {
884 cout << "There is no function for info open" << endl;
887 ret = info->open(info, NULL, (struct hw_common**)&touchscreen_dev);
888 EXPECT_EQ(ret, 0) << "Fail to open touchscreen device (" << ret << ")";
891 TEST_F(TOUCHSCREENHalTest, SetStateP)
893 enum touchscreen_state state = TOUCHSCREEN_ON;
896 if (!touchscreen_dev || !touchscreen_dev->set_state) {
897 cout << "There is no function for set_state" << endl;
900 ret = touchscreen_dev->set_state(state);
901 EXPECT_EQ(ret, 0) << "Fail to set_state (" << ret << ")";
904 TEST_F(TOUCHSCREENHalTest, DeinitP)
908 if (!info || !info->close) {
909 cout << "There is no function for info close" << endl;
912 ret = info->close((struct hw_common *)touchscreen_dev);
913 EXPECT_EQ(ret, 0) << "Fail to close touchscreen device (" << ret << ")";
917 * Testcase for Touchsensitivity
919 TEST_F(TOUCHSENSITIVITYHalTest, InitP)
924 ret = hw_get_info(TOUCHSENSITIVITY_HARDWARE_DEVICE_ID,
925 (const struct hw_info **)&info);
927 cout << "There is no device for touchsensitivity " << ret << endl;
930 EXPECT_EQ(ret, 0) << "Fail to get hal for touchsensitivity (" << ret << ")";
933 if (!info || !info->open) {
934 cout << "There is no function for info open" << endl;
937 ret = info->open(info, NULL, (struct hw_common**)&touchsensitivity_dev);
938 EXPECT_EQ(ret, 0) << "Fail to open touchsensitivity device (" << ret << ")";
941 TEST_F(TOUCHSENSITIVITYHalTest, GetStateP)
945 if (!touchsensitivity_dev || !touchsensitivity_dev->glove_mode_get_state) {
946 cout << "There is no function for glove_mode_get_state" << endl;
949 ret = touchsensitivity_dev->glove_mode_get_state(&state);
950 EXPECT_EQ(ret, 0) << "Fail to get glove state (" << ret << ")";
953 TEST_F(TOUCHSENSITIVITYHalTest, SetStateP)
955 int ret, state = TOUCHSENSITIVITY_GLOVE_MODE_ON;
957 if (!touchsensitivity_dev || !touchsensitivity_dev->glove_mode_set_state) {
958 cout << "There is no function for glove_mode_set_state" << endl;
961 ret = touchsensitivity_dev->glove_mode_set_state(state);
962 EXPECT_EQ(ret, 0) << "Fail to set glove mode (" << ret << ")";
965 TEST_F(TOUCHSENSITIVITYHalTest, DeinitP)
969 if (!info || !info->close) {
970 cout << "There is no function for info close" << endl;
973 ret = info->close((struct hw_common *)touchsensitivity_dev);
974 EXPECT_EQ(ret, 0) << "Fail to close touchscreen device (" << ret << ")";
980 TEST_F(BEZELHalTest, InitP)
988 ret = hw_get_info(BEZEL_HARDWARE_DEVICE_ID,
989 (const struct hw_info **)&info);
991 cout << "There is no device for bezel" << ret << endl;
994 EXPECT_EQ(ret, 0) << "Fail to get hal for bezel (" << ret << ")";
997 if (!info || !info->open) {
998 cout << "There is no function for info open" << endl;
1001 ret = info->open(info, NULL, (struct hw_common**)&bezel_dev);
1002 EXPECT_EQ(ret, 0) << "Fail to open bezel device (" << ret << ")";
1005 TEST_F(BEZELHalTest, GetStateP)
1007 enum bezel_state state;
1013 if (!bezel_dev || !bezel_dev->get_state) {
1014 cout << "There is no function for get_info" << endl;
1017 ret = bezel_dev->get_state(&state);
1018 EXPECT_EQ(ret, 0) << "Fail to get_state (" << ret << ")";
1021 TEST_F(BEZELHalTest, SetStateP)
1023 enum bezel_state state = BEZEL_TURNON;
1029 if (!bezel_dev || !bezel_dev->set_state) {
1030 cout << "There is no function for set_state" << endl;
1033 ret = bezel_dev->set_state(state);
1034 EXPECT_EQ(ret, 0) << "Fail to get_state (" << ret << ")";
1037 TEST_F(BEZELHalTest, DeinitP)
1044 if (!info || !info->close) {
1045 cout << "There is no function for info close" << endl;
1048 ret = info->close((struct hw_common *)bezel_dev);
1049 EXPECT_EQ(ret, 0) << "Fail to close bezel device (" << ret << ")";
1053 * Testcase for Client
1055 TEST_F(USBCLIENTHalTest, InitP)
1063 ret = hw_get_info(USB_CLIENT_HARDWARE_DEVICE_ID,
1064 (const struct hw_info **)&info);
1066 cout << "There is no device for usb client" << ret << endl;
1069 EXPECT_EQ(ret, 0) << "Fail to get hal for usb client (" << ret << ")";
1071 if (!info || !info->open) {
1072 cout << "There is no function for info open" << endl;
1075 ret = info->open(info, NULL, (struct hw_common**)&client_dev);
1076 EXPECT_EQ(ret, 0) << "Fail to open usb client device (" << ret << ")";
1077 EXPECT_NE(client_dev, nullptr) << "Fail to get usb client device structure";
1079 ret = hw_get_info(USB_GADGET_DEVICE_ID,
1080 (const struct hw_info **)&info);
1082 cout << "There is no device for usb gadget" << ret << endl;
1085 EXPECT_EQ(ret, 0) << "Fail to get hal for usb gadget (" << ret << ")";
1088 if (!info || !info->open) {
1089 cout << "There is no function for info open" << endl;
1092 ret = info->open(info, NULL, (struct hw_common**)&gadget_translator);
1093 EXPECT_EQ(ret, 0) << "Fail to open usb gadget device (" << ret << ")";
1096 TEST_F(USBCLIENTHalTest, EnableP)
1103 if (!client_dev || !client_dev->enable) {
1104 cout << "There is no function for enable" << endl;
1107 ret = client_dev->enable(client_dev);
1108 EXPECT_EQ(ret, 0) << "Fail to enable (" << ret << ")";
1111 TEST_F(USBCLIENTHalTest, ReConfigureGadgetP)
1118 if (!gadget_translator || !gadget_translator->id_to_gadget) {
1119 cout << "There is no function for id_to_gadget" << endl;
1122 gadget_id.function_mask = 7;
1123 ret = gadget_translator->id_to_gadget(&gadget_id, &gadget_dev);
1124 EXPECT_EQ(ret, 0) << "Fail to id_to_gadget (" << ret << ")";
1126 if (!client_dev || !client_dev->disable) {
1127 cout << "There is no function for disable" << endl;
1130 ret = client_dev->disable(client_dev);
1131 EXPECT_EQ(ret, 0) << "Fail to disable (" << ret << ")";
1133 if (!client_dev || !client_dev->reconfigure_gadget) {
1134 cout << "There is no function for reconfigure_gadget" << endl;
1137 ret = client_dev->reconfigure_gadget(client_dev, gadget_dev);
1138 EXPECT_EQ(ret, 0) << "Fail to reconfigure_gadget (" << ret << ")";
1141 TEST_F(USBCLIENTHalTest, DisableP)
1148 if (!client_dev || !client_dev->disable) {
1149 cout << "There is no function for disable" << endl;
1152 ret = client_dev->disable(client_dev);
1153 EXPECT_EQ(ret, 0) << "Fail to disable (" << ret << ")";
1156 TEST_F(USBCLIENTHalTest, DeinitP)
1163 if (!info || !info->close) {
1164 cout << "There is no function for info close" << endl;
1167 ret = info->close((struct hw_common *)client_dev);
1168 EXPECT_EQ(ret, 0) << "Fail to close usb client device (" << ret << ")";
1172 * Testcase for Gadget
1174 TEST_F(USBGADGETHalTest, InitP)
1179 ret = hw_get_info(USB_GADGET_DEVICE_ID,
1180 (const struct hw_info **)&info);
1182 cout << "There is no device for usb gadget" << ret << endl;
1185 EXPECT_EQ(ret, 0) << "Fail to get hal for usb gadget (" << ret << ")";
1188 if (!info || !info->open) {
1189 cout << "There is no function for info open" << endl;
1192 ret = info->open(info, NULL, (struct hw_common**)&gadget_translator);
1193 EXPECT_EQ(ret, 0) << "Fail to open usb gadget device (" << ret << ")";
1196 TEST_F(USBGADGETHalTest, IdToGadget)
1198 struct usb_gadget_id gadget_id;
1201 if (!gadget_translator || !gadget_translator->id_to_gadget) {
1202 cout << "There is no function for id_to_gadget" << endl;
1206 gadget_id.function_mask = 7;
1207 ret = gadget_translator->id_to_gadget(&gadget_id, &gadget_dev);
1208 EXPECT_EQ(ret, 0) << "Fail to id_to_gadget (" << ret << ")";
1211 TEST_F(USBGADGETHalTest, CleanUpGadget)
1213 if (!gadget_translator || !gadget_translator->cleanup_gadget) {
1214 cout << "There is no function for cleanup_gadget" << endl;
1217 gadget_translator->cleanup_gadget(gadget_dev);
1220 TEST_F(USBGADGETHalTest, DeinitP)
1224 if (!info || !info->close) {
1225 cout << "There is no function for info close" << endl;
1228 ret = info->close((struct hw_common *)gadget_translator);
1229 EXPECT_EQ(ret, 0) << "Fail to close usb gadget device (" << ret << ")";
1232 int main(int argc, char **argv)
1237 testing::InitGoogleTest(&argc, argv);
1239 std::cout << "Exception occurred." << std::endl;
1243 ret = RUN_ALL_TESTS();
1244 } catch (const ::testing::internal::GoogleTestFailureException& e) {
1246 std::cout << "GoogleTestFailureException was thrown:" << e.what() << std::endl;