diff options
Diffstat (limited to 'unittest/gtest_hal_rgb.cpp')
-rwxr-xr-x | unittest/gtest_hal_rgb.cpp | 100 |
1 files changed, 0 insertions, 100 deletions
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(); -} |