mirror of
https://github.com/Evolution-X/hardware_interfaces
synced 2026-02-01 11:36:00 +00:00
Merge "Convert VtsHalGnssV1_0TargetTest to be parameterized test"
This commit is contained in:
@@ -45,4 +45,5 @@ cc_defaults {
|
|||||||
"-g",
|
"-g",
|
||||||
],
|
],
|
||||||
|
|
||||||
|
require_root: true,
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -19,5 +19,5 @@ cc_test {
|
|||||||
defaults: ["VtsHalTargetTestDefaults"],
|
defaults: ["VtsHalTargetTestDefaults"],
|
||||||
srcs: ["VtsHalGnssV1_0TargetTest.cpp"],
|
srcs: ["VtsHalGnssV1_0TargetTest.cpp"],
|
||||||
static_libs: ["android.hardware.gnss@1.0"],
|
static_libs: ["android.hardware.gnss@1.0"],
|
||||||
test_suites: ["general-tests"],
|
test_suites: ["general-tests", "vts-core"],
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -16,11 +16,11 @@
|
|||||||
|
|
||||||
#define LOG_TAG "VtsHalGnssV1_0TargetTest"
|
#define LOG_TAG "VtsHalGnssV1_0TargetTest"
|
||||||
#include <android/hardware/gnss/1.0/IGnss.h>
|
#include <android/hardware/gnss/1.0/IGnss.h>
|
||||||
|
#include <gtest/gtest.h>
|
||||||
|
#include <hidl/GtestPrinter.h>
|
||||||
|
#include <hidl/ServiceManagement.h>
|
||||||
#include <log/log.h>
|
#include <log/log.h>
|
||||||
|
|
||||||
#include <VtsHalHidlTargetTestBase.h>
|
|
||||||
#include <VtsHalHidlTargetTestEnvBase.h>
|
|
||||||
|
|
||||||
#include <chrono>
|
#include <chrono>
|
||||||
#include <condition_variable>
|
#include <condition_variable>
|
||||||
#include <mutex>
|
#include <mutex>
|
||||||
@@ -42,23 +42,8 @@ using android::sp;
|
|||||||
bool sAgpsIsPresent = false; // if SUPL or XTRA assistance available
|
bool sAgpsIsPresent = false; // if SUPL or XTRA assistance available
|
||||||
bool sSignalIsWeak = false; // if GNSS signals are weak (e.g. light indoor)
|
bool sSignalIsWeak = false; // if GNSS signals are weak (e.g. light indoor)
|
||||||
|
|
||||||
// Test environment for GNSS HIDL HAL.
|
|
||||||
class GnssHidlEnvironment : public ::testing::VtsHalHidlTargetTestEnvBase {
|
|
||||||
public:
|
|
||||||
// get the test environment singleton
|
|
||||||
static GnssHidlEnvironment* Instance() {
|
|
||||||
static GnssHidlEnvironment* instance = new GnssHidlEnvironment;
|
|
||||||
return instance;
|
|
||||||
}
|
|
||||||
|
|
||||||
virtual void registerTestServices() override { registerTestService<IGnss>(); }
|
|
||||||
|
|
||||||
private:
|
|
||||||
GnssHidlEnvironment() {}
|
|
||||||
};
|
|
||||||
|
|
||||||
// The main test class for GNSS HAL.
|
// The main test class for GNSS HAL.
|
||||||
class GnssHalTest : public ::testing::VtsHalHidlTargetTestBase {
|
class GnssHalTest : public testing::TestWithParam<std::string> {
|
||||||
public:
|
public:
|
||||||
virtual void SetUp() override {
|
virtual void SetUp() override {
|
||||||
// Clean between tests
|
// Clean between tests
|
||||||
@@ -67,8 +52,7 @@ class GnssHalTest : public ::testing::VtsHalHidlTargetTestBase {
|
|||||||
info_called_count_ = 0;
|
info_called_count_ = 0;
|
||||||
notify_count_ = 0;
|
notify_count_ = 0;
|
||||||
|
|
||||||
gnss_hal_ = ::testing::VtsHalHidlTargetTestBase::getService<IGnss>(
|
gnss_hal_ = IGnss::getService(GetParam());
|
||||||
GnssHidlEnvironment::Instance()->getServiceName<IGnss>());
|
|
||||||
ASSERT_NE(gnss_hal_, nullptr);
|
ASSERT_NE(gnss_hal_, nullptr);
|
||||||
|
|
||||||
gnss_cb_ = new GnssCallback(*this);
|
gnss_cb_ = new GnssCallback(*this);
|
||||||
@@ -344,14 +328,14 @@ class GnssHalTest : public ::testing::VtsHalHidlTargetTestBase {
|
|||||||
* Since this is just the basic operation of SetUp() and TearDown(),
|
* Since this is just the basic operation of SetUp() and TearDown(),
|
||||||
* the function definition is intentionally empty
|
* the function definition is intentionally empty
|
||||||
*/
|
*/
|
||||||
TEST_F(GnssHalTest, SetCallbackCapabilitiesCleanup) {}
|
TEST_P(GnssHalTest, SetCallbackCapabilitiesCleanup) {}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* GetLocation:
|
* GetLocation:
|
||||||
* Turns on location, waits 45 second for at least 5 locations,
|
* Turns on location, waits 45 second for at least 5 locations,
|
||||||
* and checks them for reasonable validity.
|
* and checks them for reasonable validity.
|
||||||
*/
|
*/
|
||||||
TEST_F(GnssHalTest, GetLocation) {
|
TEST_P(GnssHalTest, GetLocation) {
|
||||||
#define MIN_INTERVAL_MSEC 500
|
#define MIN_INTERVAL_MSEC 500
|
||||||
#define PREFERRED_ACCURACY 0 // Ideally perfect (matches GnssLocationProvider)
|
#define PREFERRED_ACCURACY 0 // Ideally perfect (matches GnssLocationProvider)
|
||||||
#define PREFERRED_TIME_MSEC 0 // Ideally immediate
|
#define PREFERRED_TIME_MSEC 0 // Ideally immediate
|
||||||
@@ -391,7 +375,7 @@ TEST_F(GnssHalTest, GetLocation) {
|
|||||||
* InjectDelete:
|
* InjectDelete:
|
||||||
* Ensures that calls to inject and/or delete information state are handled.
|
* Ensures that calls to inject and/or delete information state are handled.
|
||||||
*/
|
*/
|
||||||
TEST_F(GnssHalTest, InjectDelete) {
|
TEST_P(GnssHalTest, InjectDelete) {
|
||||||
// confidently, well north of Alaska
|
// confidently, well north of Alaska
|
||||||
auto result = gnss_hal_->injectLocation(80.0, -170.0, 1000.0);
|
auto result = gnss_hal_->injectLocation(80.0, -170.0, 1000.0);
|
||||||
|
|
||||||
@@ -424,7 +408,7 @@ TEST_F(GnssHalTest, InjectDelete) {
|
|||||||
* null or actual extension, no crash.
|
* null or actual extension, no crash.
|
||||||
* Confirms year-based required extensions (Measurement & Debug) are present
|
* Confirms year-based required extensions (Measurement & Debug) are present
|
||||||
*/
|
*/
|
||||||
TEST_F(GnssHalTest, GetAllExtensions) {
|
TEST_P(GnssHalTest, GetAllExtensions) {
|
||||||
// Basic call-is-handled checks
|
// Basic call-is-handled checks
|
||||||
auto gnssXtra = gnss_hal_->getExtensionXtra();
|
auto gnssXtra = gnss_hal_->getExtensionXtra();
|
||||||
ASSERT_TRUE(gnssXtra.isOk());
|
ASSERT_TRUE(gnssXtra.isOk());
|
||||||
@@ -470,7 +454,7 @@ TEST_F(GnssHalTest, GetAllExtensions) {
|
|||||||
* MeasurementCapabilities:
|
* MeasurementCapabilities:
|
||||||
* Verifies that modern hardware supports measurement capabilities.
|
* Verifies that modern hardware supports measurement capabilities.
|
||||||
*/
|
*/
|
||||||
TEST_F(GnssHalTest, MeasurementCapabilites) {
|
TEST_P(GnssHalTest, MeasurementCapabilites) {
|
||||||
if (info_called_count_ > 0 && last_info_.yearOfHw >= 2016) {
|
if (info_called_count_ > 0 && last_info_.yearOfHw >= 2016) {
|
||||||
EXPECT_TRUE(last_capabilities_ & IGnssCallback::Capabilities::MEASUREMENTS);
|
EXPECT_TRUE(last_capabilities_ & IGnssCallback::Capabilities::MEASUREMENTS);
|
||||||
}
|
}
|
||||||
@@ -480,16 +464,19 @@ TEST_F(GnssHalTest, MeasurementCapabilites) {
|
|||||||
* SchedulingCapabilities:
|
* SchedulingCapabilities:
|
||||||
* Verifies that 2018+ hardware supports Scheduling capabilities.
|
* Verifies that 2018+ hardware supports Scheduling capabilities.
|
||||||
*/
|
*/
|
||||||
TEST_F(GnssHalTest, SchedulingCapabilities) {
|
TEST_P(GnssHalTest, SchedulingCapabilities) {
|
||||||
if (info_called_count_ > 0 && last_info_.yearOfHw >= 2018) {
|
if (info_called_count_ > 0 && last_info_.yearOfHw >= 2018) {
|
||||||
EXPECT_TRUE(last_capabilities_ & IGnssCallback::Capabilities::SCHEDULING);
|
EXPECT_TRUE(last_capabilities_ & IGnssCallback::Capabilities::SCHEDULING);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
INSTANTIATE_TEST_SUITE_P(
|
||||||
|
PerInstance, GnssHalTest,
|
||||||
|
testing::ValuesIn(android::hardware::getAllHalInstanceNames(IGnss::descriptor)),
|
||||||
|
android::hardware::PrintInstanceNameToString);
|
||||||
|
|
||||||
int main(int argc, char** argv) {
|
int main(int argc, char** argv) {
|
||||||
::testing::AddGlobalTestEnvironment(GnssHidlEnvironment::Instance());
|
|
||||||
::testing::InitGoogleTest(&argc, argv);
|
::testing::InitGoogleTest(&argc, argv);
|
||||||
GnssHidlEnvironment::Instance()->init(&argc, argv);
|
|
||||||
/*
|
/*
|
||||||
* These arguments not used by automated VTS testing.
|
* These arguments not used by automated VTS testing.
|
||||||
* Only for use in manual testing, when wanting to run
|
* Only for use in manual testing, when wanting to run
|
||||||
@@ -502,7 +489,6 @@ int main(int argc, char** argv) {
|
|||||||
sSignalIsWeak = true;
|
sSignalIsWeak = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
int status = RUN_ALL_TESTS();
|
|
||||||
ALOGI("Test result = %d", status);
|
return RUN_ALL_TESTS();
|
||||||
return status;
|
}
|
||||||
}
|
|
||||||
Reference in New Issue
Block a user