summaryrefslogtreecommitdiff
path: root/unittest/gtest_hal_touchscreen.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'unittest/gtest_hal_touchscreen.cpp')
-rwxr-xr-x[-rw-r--r--]unittest/gtest_hal_touchscreen.cpp72
1 files changed, 35 insertions, 37 deletions
diff --git a/unittest/gtest_hal_touchscreen.cpp b/unittest/gtest_hal_touchscreen.cpp
index 07cf6dc..046cef8 100644..100755
--- a/unittest/gtest_hal_touchscreen.cpp
+++ b/unittest/gtest_hal_touchscreen.cpp
@@ -9,6 +9,7 @@ using namespace std;
/*
* main class
*/
+struct hw_info *info;
struct touchscreen_device *touchscreen_dev;
class TOUCHSCREENHalTest : public testing::Test
@@ -16,44 +17,12 @@ class TOUCHSCREENHalTest : public testing::Test
public:
virtual void SetUp()
{
- struct hw_info *info;
- int ret;
- ret = hw_get_info(TOUCHSCREEN_HARDWARE_DEVICE_ID,
- (const struct hw_info **)&info);
-
- if (ret < 0) {
- cout << "Fail to load touchscreen hal(" << ret << ")" << endl;
- assert(true);
- return;
- }
- if (!info->open) {
- cout << "Failed to open touchscreen device; open(NULL)" << endl;
- assert(true);
- return;
- }
-
- ret = info->open(info, NULL, (struct hw_common**)&touchscreen_dev);
- if (ret < 0 || !touchscreen_dev) {
- cout << "Failed to get touchscreen device structure (" << ret << ")" << endl;
- assert(true);
- return;
- }
-
- return;
+
}
virtual void TearDown()
{
- struct hw_info *info;
-
- info = touchscreen_dev->common.info;
- if (!info)
- free(touchscreen_dev);
- else
- info->close((struct hw_common *)touchscreen_dev);
- touchscreen_dev = NULL;
- return;
}
};
@@ -62,7 +31,23 @@ class TOUCHSCREENHalTest : public testing::Test
*/
TEST_F(TOUCHSCREENHalTest, InitP)
{
- EXPECT_NE(touchscreen_dev, nullptr);
+ 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)
@@ -70,11 +55,24 @@ TEST_F(TOUCHSCREENHalTest, SetstateP)
enum touchscreen_state state = TOUCHSCREEN_ON;
int ret;
- EXPECT_NE(touchscreen_dev, nullptr);
- if (!touchscreen_dev->set_state)
+ 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) << "Failed to enable touchscreen (" << ret << ")";
+ 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)