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
diff --git a/light/2.0/vts/functional/VtsHalLightV2_0TargetTest.cpp b/light/2.0/vts/functional/VtsHalLightV2_0TargetTest.cpp
index 71a8b4e..7abb6e7 100644
--- a/light/2.0/vts/functional/VtsHalLightV2_0TargetTest.cpp
+++ b/light/2.0/vts/functional/VtsHalLightV2_0TargetTest.cpp
@@ -37,31 +37,6 @@
#define ASSERT_OK(ret) ASSERT_TRUE(ret.isOk())
#define EXPECT_OK(ret) EXPECT_TRUE(ret.isOk())
-class LightHidlTest : public ::testing::Test {
-public:
- virtual void SetUp() override {
- light = ILight::getService();
-
- ASSERT_NE(light, nullptr);
- LOG(INFO) << "Test is remote " << light->isRemote();
-
- ASSERT_OK(light->getSupportedTypes([this](const hidl_vec<Type> &types) {
- supportedTypes = types;
- }));
- }
-
- virtual void TearDown() override {}
-
- sp<ILight> light;
- std::vector<Type> supportedTypes;
-};
-
-class LightHidlEnvironment : public ::testing::Environment {
-public:
- virtual void SetUp() {}
- virtual void TearDown() {}
-};
-
const static LightState kWhite = {
.color = 0xFFFFFFFF,
.flashMode = Flash::TIMED,
@@ -97,6 +72,41 @@
Type::WIFI
};
+class LightHidlTest : public ::testing::Test {
+public:
+ virtual void SetUp() override {
+ light = ILight::getService();
+
+ ASSERT_NE(light, nullptr);
+ LOG(INFO) << "Test is remote " << light->isRemote();
+
+ ASSERT_OK(light->getSupportedTypes([this](const hidl_vec<Type> &types) {
+ supportedTypes = types;
+ }));
+ }
+
+ sp<ILight> light;
+ std::vector<Type> supportedTypes;
+
+ virtual void TearDown() override {
+ for (const Type& type: supportedTypes) {
+ Return<Status> ret = light->setLight(type, kOff);
+ EXPECT_OK(ret);
+ EXPECT_EQ(Status::SUCCESS, static_cast<Status>(ret));
+ }
+
+ // must leave the device in a useable condition
+ if (std::find(supportedTypes.begin(),
+ supportedTypes.end(),
+ Type::BACKLIGHT) != supportedTypes.end()) {
+ Return<Status> ret = light->setLight(Type::BACKLIGHT, kWhite);
+ EXPECT_OK(ret);
+ EXPECT_EQ(Status::SUCCESS, static_cast<Status>(ret));
+ }
+ }
+
+};
+
/**
* Ensure all lights which are reported as supported work.
*/
@@ -106,12 +116,6 @@
EXPECT_OK(ret);
EXPECT_EQ(Status::SUCCESS, static_cast<Status>(ret));
}
-
- for (const Type& type: supportedTypes) {
- Return<Status> ret = light->setLight(type, kOff);
- EXPECT_OK(ret);
- EXPECT_EQ(Status::SUCCESS, static_cast<Status>(ret));
- }
}
/**
@@ -126,12 +130,6 @@
EXPECT_TRUE(Status::SUCCESS == status ||
Status::BRIGHTNESS_NOT_SUPPORTED == status);
}
-
- for (const Type& type: supportedTypes) {
- Return<Status> ret = light->setLight(type, kOff);
- EXPECT_OK(ret);
- EXPECT_EQ(Status::SUCCESS, static_cast<Status>(ret));
- }
}
/**
@@ -151,7 +149,6 @@
}
int main(int argc, char **argv) {
- ::testing::AddGlobalTestEnvironment(new LightHidlEnvironment);
::testing::InitGoogleTest(&argc, argv);
int status = RUN_ALL_TESTS();
LOG(INFO) << "Test result = " << status;