Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit ac3a81bd authored by TreeHugger Robot's avatar TreeHugger Robot Committed by Android (Google) Code Review
Browse files

Merge "Add VR Hal target test."

parents 07af06ae 63cd88ef
Loading
Loading
Loading
Loading
+2 −0
Original line number Diff line number Diff line
@@ -76,3 +76,5 @@ LOCAL_PROTOC_OPTIMIZE_TYPE := full

include $(BUILD_SHARED_LIBRARY)

# include hidl test makefiles
include $(LOCAL_PATH)/functional/vts/testcases/hal/vr/hidl/Android.mk
+32 −0
Original line number Diff line number Diff line
//
// Copyright (C) 2016 The Android Open Source Project
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
//      http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//

cc_test {
    name: "vr_hidl_hal_test",
    gtest: true,
    srcs: ["vr_hidl_hal_test.cpp"],
    shared_libs: [
        "liblog",
        "libhidlbase",
        "libutils",
        "android.hardware.vr@1.0",
    ],
    static_libs: ["libgtest"],
    cflags: [
        "-O0",
        "-g",
    ],
}
+84 −0
Original line number Diff line number Diff line
/*
 * Copyright (C) 2016 The Android Open Source Project
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

#define LOG_TAG "vr_hidl_hal_test"
#include <android-base/logging.h>
#include <android/hardware/vr/1.0/IVr.h>
#include <android/log.h>
#include <gtest/gtest.h>
#include <hardware/vr.h>

using ::android::hardware::vr::V1_0::IVr;
using ::android::hardware::Return;
using ::android::hardware::Void;
using ::android::sp;

#define VR_SERVICE_NAME "vr"

// The main test class for VR HIDL HAL.
class VrHidlTest : public ::testing::Test {
 public:
  void SetUp() override {
    // currently test passthrough mode only
    vr = IVr::getService(VR_SERVICE_NAME, true);
    ASSERT_NE(vr, nullptr);
    ASSERT_TRUE(!vr->isRemote());
  }

  void TearDown() override {}

  sp<IVr> vr;
};


// A class for test environment setup (kept since this file is a template).
class VrHidlEnvironment : public ::testing::Environment {
 public:
  void SetUp() {}
  void TearDown() {}

 private:
};

// Sanity check that Vr::init does not crash.
TEST_F(VrHidlTest, Init) {
  EXPECT_TRUE(vr->init().isOk());
}

// Sanity check Vr::setVrMode is able to enable and disable VR mode.
TEST_F(VrHidlTest, SetVrMode) {
  EXPECT_TRUE(vr->init().isOk());
  EXPECT_TRUE(vr->setVrMode(true).isOk());
  EXPECT_TRUE(vr->setVrMode(false).isOk());
}

// Sanity check that Vr::init and Vr::setVrMode can be used in any order.
TEST_F(VrHidlTest, ReInit) {
  EXPECT_TRUE(vr->init().isOk());
  EXPECT_TRUE(vr->setVrMode(true).isOk());
  EXPECT_TRUE(vr->init().isOk());
  EXPECT_TRUE(vr->setVrMode(false).isOk());
  EXPECT_TRUE(vr->init().isOk());
  EXPECT_TRUE(vr->setVrMode(false).isOk());
}

int main(int argc, char **argv) {
  ::testing::AddGlobalTestEnvironment(new VrHidlEnvironment);
  ::testing::InitGoogleTest(&argc, argv);
  int status = RUN_ALL_TESTS();
  ALOGI("Test result = %d", status);
  return status;
}
+19 −0
Original line number Diff line number Diff line
#
# Copyright (C) 2016 The Android Open Source Project
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#      http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#

LOCAL_PATH := $(call my-dir)

include $(call all-subdir-makefiles)
+19 −0
Original line number Diff line number Diff line
#
# Copyright (C) 2016 The Android Open Source Project
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#      http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#

LOCAL_PATH := $(call my-dir)

include $(call all-subdir-makefiles)
Loading