summaryrefslogtreecommitdiffstats
path: root/light
diff options
context:
space:
mode:
authorSteven Moreland2017-01-19 18:32:14 -0600
committerSteven Moreland2017-02-22 11:41:46 -0600
commit18fef4e88848b1f90ef2dc653bf73e75c50c0a99 (patch)
tree031acdaf1939ad8c54f938c2b79b6ba9bb021a6e /light
parent67137d497ff181792dcf0a67dc249176c5d4d87a (diff)
downloadplatform-hardware-interfaces-18fef4e88848b1f90ef2dc653bf73e75c50c0a99.tar.gz
platform-hardware-interfaces-18fef4e88848b1f90ef2dc653bf73e75c50c0a99.tar.xz
platform-hardware-interfaces-18fef4e88848b1f90ef2dc653bf73e75c50c0a99.zip
lights vts test: don't turn off the screen
Running this test on marlin turns off the screen and makes the device unuseable. Test: run test on marlin, screen doesn't turn off Change-Id: I3ef5ba180949647c2c72162fd64a3cd3fcbe88f3
Diffstat (limited to 'light')
-rw-r--r--light/2.0/vts/functional/VtsHalLightV2_0TargetTest.cpp73
1 files changed, 35 insertions, 38 deletions
diff --git a/light/2.0/vts/functional/VtsHalLightV2_0TargetTest.cpp b/light/2.0/vts/functional/VtsHalLightV2_0TargetTest.cpp
index 71a8b4e5..7abb6e71 100644
--- a/light/2.0/vts/functional/VtsHalLightV2_0TargetTest.cpp
+++ b/light/2.0/vts/functional/VtsHalLightV2_0TargetTest.cpp
@@ -37,31 +37,6 @@ using ::android::sp;
37#define ASSERT_OK(ret) ASSERT_TRUE(ret.isOk()) 37#define ASSERT_OK(ret) ASSERT_TRUE(ret.isOk())
38#define EXPECT_OK(ret) EXPECT_TRUE(ret.isOk()) 38#define EXPECT_OK(ret) EXPECT_TRUE(ret.isOk())
39 39
40class LightHidlTest : public ::testing::Test {
41public:
42 virtual void SetUp() override {
43 light = ILight::getService();
44
45 ASSERT_NE(light, nullptr);
46 LOG(INFO) << "Test is remote " << light->isRemote();
47
48 ASSERT_OK(light->getSupportedTypes([this](const hidl_vec<Type> &types) {
49 supportedTypes = types;
50 }));
51 }
52
53 virtual void TearDown() override {}
54
55 sp<ILight> light;
56 std::vector<Type> supportedTypes;
57};
58
59class LightHidlEnvironment : public ::testing::Environment {
60public:
61 virtual void SetUp() {}
62 virtual void TearDown() {}
63};
64
65const static LightState kWhite = { 40const static LightState kWhite = {
66 .color = 0xFFFFFFFF, 41 .color = 0xFFFFFFFF,
67 .flashMode = Flash::TIMED, 42 .flashMode = Flash::TIMED,
@@ -97,6 +72,41 @@ const static std::set<Type> kAllTypes = {
97 Type::WIFI 72 Type::WIFI
98}; 73};
99 74
75class LightHidlTest : public ::testing::Test {
76public:
77 virtual void SetUp() override {
78 light = ILight::getService();
79
80 ASSERT_NE(light, nullptr);
81 LOG(INFO) << "Test is remote " << light->isRemote();
82
83 ASSERT_OK(light->getSupportedTypes([this](const hidl_vec<Type> &types) {
84 supportedTypes = types;
85 }));
86 }
87
88 sp<ILight> light;
89 std::vector<Type> supportedTypes;
90
91 virtual void TearDown() override {
92 for (const Type& type: supportedTypes) {
93 Return<Status> ret = light->setLight(type, kOff);
94 EXPECT_OK(ret);
95 EXPECT_EQ(Status::SUCCESS, static_cast<Status>(ret));
96 }
97
98 // must leave the device in a useable condition
99 if (std::find(supportedTypes.begin(),
100 supportedTypes.end(),
101 Type::BACKLIGHT) != supportedTypes.end()) {
102 Return<Status> ret = light->setLight(Type::BACKLIGHT, kWhite);
103 EXPECT_OK(ret);
104 EXPECT_EQ(Status::SUCCESS, static_cast<Status>(ret));
105 }
106 }
107
108};
109
100/** 110/**
101 * Ensure all lights which are reported as supported work. 111 * Ensure all lights which are reported as supported work.
102 */ 112 */
@@ -106,12 +116,6 @@ TEST_F(LightHidlTest, TestSupported) {
106 EXPECT_OK(ret); 116 EXPECT_OK(ret);
107 EXPECT_EQ(Status::SUCCESS, static_cast<Status>(ret)); 117 EXPECT_EQ(Status::SUCCESS, static_cast<Status>(ret));
108 } 118 }
109
110 for (const Type& type: supportedTypes) {
111 Return<Status> ret = light->setLight(type, kOff);
112 EXPECT_OK(ret);
113 EXPECT_EQ(Status::SUCCESS, static_cast<Status>(ret));
114 }
115} 119}
116 120
117/** 121/**
@@ -126,12 +130,6 @@ TEST_F(LightHidlTest, TestLowPersistance) {
126 EXPECT_TRUE(Status::SUCCESS == status || 130 EXPECT_TRUE(Status::SUCCESS == status ||
127 Status::BRIGHTNESS_NOT_SUPPORTED == status); 131 Status::BRIGHTNESS_NOT_SUPPORTED == status);
128 } 132 }
129
130 for (const Type& type: supportedTypes) {
131 Return<Status> ret = light->setLight(type, kOff);
132 EXPECT_OK(ret);
133 EXPECT_EQ(Status::SUCCESS, static_cast<Status>(ret));
134 }
135} 133}
136 134
137/** 135/**
@@ -151,7 +149,6 @@ TEST_F(LightHidlTest, TestUnsupported) {
151} 149}
152 150
153int main(int argc, char **argv) { 151int main(int argc, char **argv) {
154 ::testing::AddGlobalTestEnvironment(new LightHidlEnvironment);
155 ::testing::InitGoogleTest(&argc, argv); 152 ::testing::InitGoogleTest(&argc, argv);
156 int status = RUN_ALL_TESTS(); 153 int status = RUN_ALL_TESTS();
157 LOG(INFO) << "Test result = " << status; 154 LOG(INFO) << "Test result = " << status;