2016-12-14 23:05:13 +01:00
|
|
|
/*
|
|
|
|
* 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>
|
2019-10-29 09:16:55 +01:00
|
|
|
#include <gtest/gtest.h>
|
2016-12-14 23:05:13 +01:00
|
|
|
#include <hardware/vr.h>
|
2019-10-29 09:16:55 +01:00
|
|
|
#include <hidl/GtestPrinter.h>
|
|
|
|
#include <hidl/ServiceManagement.h>
|
2017-04-06 21:15:23 +02:00
|
|
|
#include <log/log.h>
|
2016-12-14 23:05:13 +01:00
|
|
|
|
|
|
|
using ::android::hardware::vr::V1_0::IVr;
|
|
|
|
using ::android::hardware::Return;
|
|
|
|
using ::android::hardware::Void;
|
|
|
|
using ::android::sp;
|
|
|
|
|
|
|
|
// The main test class for VR HIDL HAL.
|
2019-10-29 09:16:55 +01:00
|
|
|
class VrHidlTest : public ::testing::TestWithParam<std::string> {
|
2016-12-14 23:05:13 +01:00
|
|
|
public:
|
|
|
|
void SetUp() override {
|
2019-10-29 09:16:55 +01:00
|
|
|
vr = IVr::getService(GetParam());
|
2016-12-14 23:05:13 +01:00
|
|
|
ASSERT_NE(vr, nullptr);
|
|
|
|
}
|
|
|
|
|
|
|
|
void TearDown() override {}
|
|
|
|
|
|
|
|
sp<IVr> vr;
|
|
|
|
};
|
|
|
|
|
|
|
|
// Sanity check that Vr::init does not crash.
|
2019-10-29 09:16:55 +01:00
|
|
|
TEST_P(VrHidlTest, Init) {
|
2016-12-14 23:05:13 +01:00
|
|
|
EXPECT_TRUE(vr->init().isOk());
|
|
|
|
}
|
|
|
|
|
|
|
|
// Sanity check Vr::setVrMode is able to enable and disable VR mode.
|
2019-10-29 09:16:55 +01:00
|
|
|
TEST_P(VrHidlTest, SetVrMode) {
|
2016-12-14 23:05:13 +01:00
|
|
|
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.
|
2019-10-29 09:16:55 +01:00
|
|
|
TEST_P(VrHidlTest, ReInit) {
|
2016-12-14 23:05:13 +01:00
|
|
|
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());
|
|
|
|
}
|
|
|
|
|
2019-10-29 09:16:55 +01:00
|
|
|
INSTANTIATE_TEST_SUITE_P(
|
|
|
|
PerInstance, VrHidlTest,
|
|
|
|
testing::ValuesIn(android::hardware::getAllHalInstanceNames(IVr::descriptor)),
|
|
|
|
android::hardware::PrintInstanceNameToString);
|
|
|
|
|