summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Tianyu Jiang <tianyuj@google.com> 2019-03-28 15:43:03 -0700
committer Tianyu Jiang <tianyuj@google.com> 2019-03-28 15:43:03 -0700
commit51ecd25f658bb70fa94e7f7aeab9a1ff95609d38 (patch)
tree3621eee165584abd3acf21ec4fecb1a0d9d7b21d
parent0625533ee5f7427d2eef74e9f8df041f34604a47 (diff)
Skip tests in DvrDisplayManagerTest test case for boot.vr devices.
Previously, SurfaceAttributeTypes was not skipped if device boots to VR. However, currently, display manager client cannot be created on devices boots to VR, and thus, SurfaceAttributeTypes should also be skipped. Test: dvr_api-test on walleye_xr Change-Id: I7231808de1c0c6c67528d496711494627ac98df2 Fix: 121329335
-rw-r--r--libs/vr/libdvr/tests/dvr_display_manager-test.cpp79
1 files changed, 35 insertions, 44 deletions
diff --git a/libs/vr/libdvr/tests/dvr_display_manager-test.cpp b/libs/vr/libdvr/tests/dvr_display_manager-test.cpp
index ed725777aa..7b3717e979 100644
--- a/libs/vr/libdvr/tests/dvr_display_manager-test.cpp
+++ b/libs/vr/libdvr/tests/dvr_display_manager-test.cpp
@@ -28,6 +28,8 @@ namespace dvr {
namespace {
+using ::testing::Test;
+
DvrSurfaceAttribute MakeAttribute(DvrSurfaceAttributeKey key, nullptr_t) {
DvrSurfaceAttribute attribute;
attribute.key = key;
@@ -141,6 +143,23 @@ Status<UniqueDvrWriteBufferQueue> CreateSurfaceQueue(
return {UniqueDvrWriteBufferQueue(queue)};
}
+Status<std::vector<uint8_t>> GetConfigData(int config_type) {
+ uint8_t* data = nullptr;
+ size_t data_size = 0;
+ int error = dvrConfigurationDataGet(config_type, &data, &data_size);
+ if (error < 0) {
+ return ErrorStatus(-error);
+ }
+
+ if (!data || data_size == 0) {
+ return ErrorStatus(EINVAL);
+ }
+ std::vector<uint8_t> data_result(data, data + data_size);
+ dvrConfigurationDataDestroy(data);
+ std::string s(data, data + data_size);
+ return {std::move(data_result)};
+}
+
class TestDisplayManager {
public:
TestDisplayManager(UniqueDvrDisplayManager display_manager,
@@ -275,23 +294,6 @@ class TestDisplayManager {
return {std::move(queue_ids)};
}
- Status<std::vector<uint8_t>> GetConfigData(int config_type) {
- uint8_t* data = nullptr;
- size_t data_size = 0;
- int error = dvrConfigurationDataGet(config_type, &data, &data_size);
- if (error < 0) {
- return ErrorStatus(-error);
- }
-
- if (!data || data_size == 0) {
- return ErrorStatus(EINVAL);
- }
- std::vector<uint8_t> data_result(data, data + data_size);
- dvrConfigurationDataDestroy(data);
- std::string s(data, data + data_size);
- return {std::move(data_result)};
- }
-
private:
UniqueDvrDisplayManager display_manager_;
UniqueDvrSurfaceState surface_state_;
@@ -303,9 +305,17 @@ class TestDisplayManager {
void operator=(const TestDisplayManager&) = delete;
};
-class DvrDisplayManagerTest : public ::testing::Test {
+class DvrDisplayManagerTest : public Test {
protected:
void SetUp() override {
+ // dvr display manager test doesn't apply to standalone vr devices because
+ // tests cannot create display manager client on these devices.
+ if (property_get_bool("ro.boot.vr", false)) {
+ GTEST_SKIP()
+ << "All tests in DvrDisplayManagerTest test case are skipped "
+ "because the device boot to VR.";
+ }
+
int ret;
DvrDisplayManager* display_manager;
DvrSurfaceState* surface_state;
@@ -429,7 +439,7 @@ testing::AssertionResult StatusPred(const char* status_expression,
#if 0
// Verify utility predicate/macro functionality. This section is commented out
// because it is designed to fail in some cases to validate the helpers.
-TEST_F(DvrDisplayManagerTest, ExpectVoid) {
+TEST_F(Test, ExpectVoid) {
Status<void> status_error{ErrorStatus{EINVAL}};
Status<void> status_ok{};
@@ -444,7 +454,7 @@ TEST_F(DvrDisplayManagerTest, ExpectVoid) {
EXPECT_STATUS_ERROR_VALUE(ENOMEM, status_ok);
}
-TEST_F(DvrDisplayManagerTest, ExpectInt) {
+TEST_F(Test, ExpectInt) {
Status<int> status_error{ErrorStatus{EINVAL}};
Status<int> status_ok{10};
@@ -480,11 +490,6 @@ TEST_F(DvrDisplayManagerTest, ExpectInt) {
#endif
TEST_F(DvrDisplayManagerTest, SurfaceCreateEvent) {
- // This test doesn't apply to standalone vr devices.
- if (property_get_bool("ro.boot.vr", false)) {
- return;
- }
-
// Get surface state and verify there are no surfaces.
ASSERT_STATUS_OK(manager_->UpdateSurfaceState());
ASSERT_STATUS_EQ(0u, manager_->GetSurfaceCount());
@@ -524,11 +529,6 @@ TEST_F(DvrDisplayManagerTest, SurfaceCreateEvent) {
}
TEST_F(DvrDisplayManagerTest, SurfaceAttributeEvent) {
- // This test doesn't apply to standalone vr devices.
- if (property_get_bool("ro.boot.vr", false)) {
- return;
- }
-
// Get surface state and verify there are no surfaces.
ASSERT_STATUS_OK(manager_->UpdateSurfaceState());
ASSERT_STATUS_EQ(0u, manager_->GetSurfaceCount());
@@ -768,11 +768,6 @@ TEST_F(DvrDisplayManagerTest, SurfaceAttributeTypes) {
}
TEST_F(DvrDisplayManagerTest, SurfaceQueueEvent) {
- // This test doesn't apply to standalone vr devices.
- if (property_get_bool("ro.boot.vr", false)) {
- return;
- }
-
// Create an application surface.
auto surface_status = CreateApplicationSurface();
ASSERT_STATUS_OK(surface_status);
@@ -841,11 +836,6 @@ TEST_F(DvrDisplayManagerTest, SurfaceQueueEvent) {
}
TEST_F(DvrDisplayManagerTest, MultiLayerBufferQueue) {
- // This test doesn't apply to standalone vr devices.
- if (property_get_bool("ro.boot.vr", false)) {
- return;
- }
-
// Create an application surface.
auto surface_status = CreateApplicationSurface();
ASSERT_STATUS_OK(surface_status);
@@ -884,16 +874,17 @@ TEST_F(DvrDisplayManagerTest, MultiLayerBufferQueue) {
dvrWriteBufferDestroy(buffer);
}
-TEST_F(DvrDisplayManagerTest, ConfigurationData) {
- // TODO(hendrikw): Move this out of the display manager tests.
- auto data1 = manager_->GetConfigData(-1);
+TEST_F(Test, ConfigurationData) {
+ // TODO(hendrikw): Move this test and GetConfigData helper function out of the
+ // display manager tests.
+ auto data1 = GetConfigData(-1);
ASSERT_STATUS_ERROR(data1);
const char kDvrLensMetricsProperty[] = "ro.dvr.lens_metrics";
// This should be run on devices with and without built in metrics.
bool has_metric = !base::GetProperty(kDvrLensMetricsProperty, "").empty();
- auto data2 = manager_->GetConfigData(DVR_CONFIGURATION_DATA_LENS_METRICS);
+ auto data2 = GetConfigData(DVR_CONFIGURATION_DATA_LENS_METRICS);
if (has_metric) {
ASSERT_STATUS_OK(data2);
ASSERT_NE(0u, data2.get().size());