3 #include <gtest/gtest.h>
4 #include "hw/display.h"
12 #define LOWBATTERY "LowBattery"
15 struct display_device *display_dev;
17 class DISPLAYHalTest : public testing::Test
25 virtual void TearDown()
34 TEST_F(DISPLAYHalTest, InitP)
38 ret = hw_get_info(DISPLAY_HARDWARE_DEVICE_ID,
39 (const struct hw_info **)&info);
41 cout << "There is no device for display" << ret << endl;
44 EXPECT_EQ(ret, 0) << "Fail to load display hal (" << ret << ")";
47 if (!info || !info->open) {
48 cout << "There is no function for info open" << endl;
51 ret = info->open(info, NULL, (struct hw_common**)&display_dev);
52 EXPECT_EQ(ret, 0) << "Fail to open display device (" << ret << ")";
55 TEST_F(DISPLAYHalTest, GetMaxBrightnessP)
60 if (!display_dev || !display_dev->get_max_brightness) {
61 cout << "There is no function for get_max_brightness" << endl;
64 ret = display_dev->get_max_brightness(&max);
65 EXPECT_EQ(ret, 0) << "Fail to get_max_brightness (" << ret << ")";
68 TEST_F(DISPLAYHalTest, GetBrightnessP)
73 if (!display_dev || !display_dev->get_brightness) {
74 cout << "There is no function for get_brightness" << endl;
77 ret = display_dev->get_brightness(&brt);
78 EXPECT_EQ(ret, 0) << "Fail to get_brightness (" << ret << ")";
81 TEST_F(DISPLAYHalTest, SetBrightnessP)
86 if (!display_dev || !display_dev->get_max_brightness) {
87 cout << "There is no function for get_max_brightness" << endl;
90 ret = display_dev->get_max_brightness(&max);
91 EXPECT_EQ(ret, 0) << "Fail to get_max_brightness (" << ret << ")";
93 if (!display_dev || !display_dev->set_brightness) {
94 cout << "There is no function for set_brightness" << endl;
97 ret = display_dev->set_brightness(max);
98 EXPECT_EQ(ret, 0) << "Fail to set_brightness (" << ret << ")";
101 TEST_F(DISPLAYHalTest, GetAutoBrightnessP)
105 float lmax = 0, lmin = 0, light = 0;
107 if (!display_dev || !display_dev->get_auto_brightness) {
108 cout << "There is no function for get_auto_brightness" << endl;
111 ret = display_dev->get_auto_brightness(lmax, lmin, light, &brt);
112 EXPECT_GE(ret, 0) << "Fail to set_brightness (" << ret << ")";
115 TEST_F(DISPLAYHalTest, GetStateP)
118 enum display_state state;
120 if (!display_dev || !display_dev->get_state) {
121 cout << "There is no function for get_state" << endl;
124 ret = display_dev->get_state(&state);
125 EXPECT_GE(ret, 0) << "Fail to get_state (" << ret << ")";
128 TEST_F(DISPLAYHalTest, SetStateP)
132 if (!display_dev || !display_dev->set_state) {
133 cout << "There is no function for set_state" << endl;
136 ret = display_dev->set_state(DISPLAY_ON);
137 EXPECT_GE(ret, 0) << "Fail to set_state (" << ret << ")";
140 TEST_F(DISPLAYHalTest, GetMaxFrameRateP)
145 if (!display_dev || !display_dev->get_max_frame_rate) {
146 cout << "There is no function for get_max_frame_rate" << endl;
149 ret = display_dev->get_max_frame_rate(&max);
150 EXPECT_GE(ret, 0) << "Fail to get_max_frame_rate (" << ret << ")";
153 TEST_F(DISPLAYHalTest, GetMinFrameRateP)
158 if (!display_dev || !display_dev->get_min_frame_rate) {
159 cout << "There is no function for get_min_frame_rate" << endl;
162 ret = display_dev->get_min_frame_rate(&min);
163 EXPECT_GE(ret, 0) << "Fail to get_min_frame_rate (" << ret << ")";
166 TEST_F(DISPLAYHalTest, SetFrameRateP)
171 if (!display_dev || !display_dev->get_max_frame_rate) {
172 cout << "There is no function for get_max_frame_rate" << endl;
175 ret = display_dev->get_max_frame_rate(&max);
176 EXPECT_GE(ret, 0) << "Fail to get_max_frame_rate (" << ret << ")";
178 if (!display_dev->set_frame_rate) {
179 cout << "There is no function for set_frame_rate" << endl;
182 ret = display_dev->set_frame_rate(max);
183 EXPECT_GE(ret, 0) << "Fail to set_frame_rate (" << ret << ")";
186 TEST_F(DISPLAYHalTest, DeinitP)
190 if (!info || !info->close) {
191 cout << "There is no function for info close" << endl;
194 ret = info->close((struct hw_common *)display_dev);
195 EXPECT_GE(ret, 0) << "Fail to close display device (" << ret << ")";
198 int main(int argc, char **argv)
200 testing::InitGoogleTest(&argc, argv);
202 return RUN_ALL_TESTS();