3 #include <gtest/gtest.h>
4 #include <system_info.h>
5 #include "hw/thermal.h"
14 struct thermal_device *thermal_dev;
16 class THERMALHalTest : public testing::Test
24 virtual void TearDown()
33 TEST_F(THERMALHalTest, InitP)
37 ret = hw_get_info(THERMAL_HARDWARE_DEVICE_ID,
38 (const struct hw_info **)&info);
40 cout << "There is no device for thermal" << ret << endl;
43 EXPECT_EQ(ret, 0) << "Fail to get hal for thermal (" << ret << ")";
46 if (!info || !info->open) {
47 cout << "There is no function for info open" << endl;
50 ret = info->open(info, NULL, (struct hw_common**)&thermal_dev);
51 EXPECT_EQ(ret, 0) << "Fail to open thermal device (" << ret << ")";
54 TEST_F(THERMALHalTest, GetStateP)
56 struct thermal_info thermal;
59 if (!thermal_dev || !thermal_dev->get_state) {
60 cout << "There is no function for get_state" << endl;
63 ret = thermal_dev->get_state(&thermal);
64 EXPECT_EQ(ret, 0) << "Fail to get_state (" << ret << ")";
67 static void updated_cb(struct thermal_info *info, void *data)
72 TEST_F(THERMALHalTest, RegisterChangedEventP)
76 if (!thermal_dev || !thermal_dev->register_changed_event) {
77 cout << "There is no function for register_changed_event" << endl;
80 ret = thermal_dev->register_changed_event(updated_cb, NULL);
81 EXPECT_EQ(ret, 0) << "Fail to register_changed_event (" << ret << ")";
84 TEST_F(THERMALHalTest, UnregisterChangedEventP)
86 if (!thermal_dev || !thermal_dev->unregister_changed_event) {
87 cout << "There is no function for unregister_changed_event" << endl;
90 thermal_dev->unregister_changed_event(updated_cb);
93 TEST_F(THERMALHalTest, DeinitP)
97 if (!info || !info->close) {
98 cout << "There is no function for info close" << endl;
101 ret = info->close((struct hw_common *)thermal_dev);
102 EXPECT_EQ(ret, 0) << "Fail to close thermal device (" << ret << ")";
105 int main(int argc, char **argv)
107 testing::InitGoogleTest(&argc, argv);
109 return RUN_ALL_TESTS();