3 #include <gtest/gtest.h>
5 #include "hw/touchscreen.h"
13 struct touchscreen_device *touchscreen_dev;
15 class TOUCHSCREENHalTest : public testing::Test
23 virtual void TearDown()
32 TEST_F(TOUCHSCREENHalTest, InitP)
36 ret = hw_get_info(TOUCHSCREEN_HARDWARE_DEVICE_ID,
37 (const struct hw_info **)&info);
39 cout << "There is no device for touchscreen" << ret << endl;
42 EXPECT_EQ(ret, 0) << "Fail to get hal for touchscreen (" << ret << ")";
45 if (!info || !info->open) {
46 cout << "There is no function for info open" << endl;
49 ret = info->open(info, NULL, (struct hw_common**)&touchscreen_dev);
50 EXPECT_EQ(ret, 0) << "Fail to open touchscreen device (" << ret << ")";
53 TEST_F(TOUCHSCREENHalTest, SetstateP)
55 enum touchscreen_state state = TOUCHSCREEN_ON;
58 if (!touchscreen_dev || !touchscreen_dev->set_state) {
59 cout << "There is no function for set_state" << endl;
62 ret = touchscreen_dev->set_state(state);
63 EXPECT_EQ(ret, 0) << "Fail to set_state (" << ret << ")";
66 TEST_F(TOUCHSCREENHalTest, DeinitP)
70 if (!info || !info->close) {
71 cout << "There is no function for info close" << endl;
74 ret = info->close((struct hw_common *)touchscreen_dev);
75 EXPECT_EQ(ret, 0) << "Fail to close touchscreen device (" << ret << ")";
78 int main(int argc, char **argv)
80 testing::InitGoogleTest(&argc, argv);
82 return RUN_ALL_TESTS();