mirror of
https://github.com/Evolution-X/hardware_interfaces
synced 2026-02-01 11:36:00 +00:00
Convert VtsHalGnssV1_1TargetTest to be parameterized test
Bug: 142397658 Test: atest VtsHalGnssV1_1TargetTest atest VtsHalGnssV1_1Target Change-Id: I575630c8cbbf8bbd341425c5bbe04ca49c2c1758
This commit is contained in:
@@ -45,4 +45,5 @@ cc_defaults {
|
||||
"-g",
|
||||
],
|
||||
|
||||
require_root: true,
|
||||
}
|
||||
|
||||
@@ -30,5 +30,5 @@ cc_test {
|
||||
shared_libs: [
|
||||
"android.hardware.gnss.measurement_corrections@1.0",
|
||||
],
|
||||
test_suites: ["general-tests"],
|
||||
test_suites: ["general-tests", "vts-core"],
|
||||
}
|
||||
|
||||
@@ -15,15 +15,15 @@
|
||||
*/
|
||||
#define LOG_TAG "VtsHalGnssV1_1TargetTest"
|
||||
|
||||
#include <VtsHalHidlTargetTestBase.h>
|
||||
#include <gtest/gtest.h>
|
||||
#include <hidl/GtestPrinter.h>
|
||||
#include <hidl/ServiceManagement.h>
|
||||
|
||||
#include "gnss_hal_test.h"
|
||||
|
||||
int main(int argc, char** argv) {
|
||||
::testing::AddGlobalTestEnvironment(GnssHidlEnvironment::Instance());
|
||||
::testing::InitGoogleTest(&argc, argv);
|
||||
GnssHidlEnvironment::Instance()->init(&argc, argv);
|
||||
int status = RUN_ALL_TESTS();
|
||||
ALOGI("Test result = %d", status);
|
||||
return status;
|
||||
}
|
||||
using android::hardware::gnss::V1_1::IGnss;
|
||||
|
||||
INSTANTIATE_TEST_SUITE_P(
|
||||
PerInstance, GnssHalTest,
|
||||
testing::ValuesIn(android::hardware::getAllHalInstanceNames(IGnss::descriptor)),
|
||||
android::hardware::PrintInstanceNameToString);
|
||||
@@ -17,6 +17,8 @@
|
||||
#define LOG_TAG "GnssHalTest"
|
||||
|
||||
#include <android/hidl/manager/1.2/IServiceManager.h>
|
||||
#include <gtest/gtest.h>
|
||||
#include <hidl/GtestPrinter.h>
|
||||
#include <hidl/ServiceManagement.h>
|
||||
|
||||
#include <gnss_hal_test.h>
|
||||
@@ -29,8 +31,7 @@ using ::android::hardware::hidl_vec;
|
||||
using ::android::hardware::gnss::common::Utils;
|
||||
|
||||
void GnssHalTest::SetUp() {
|
||||
gnss_hal_ = ::testing::VtsHalHidlTargetTestBase::getService<IGnss>(
|
||||
GnssHidlEnvironment::Instance()->getServiceName<IGnss>());
|
||||
gnss_hal_ = IGnss::getService(GetParam());
|
||||
ASSERT_NE(gnss_hal_, nullptr);
|
||||
|
||||
SetUpGnssCallback();
|
||||
|
||||
@@ -19,8 +19,7 @@
|
||||
|
||||
#include <android/hardware/gnss/1.1/IGnss.h>
|
||||
|
||||
#include <VtsHalHidlTargetTestBase.h>
|
||||
#include <VtsHalHidlTargetTestEnvBase.h>
|
||||
#include <gtest/gtest.h>
|
||||
#include "GnssCallbackEventQueue.h"
|
||||
|
||||
using android::hardware::Return;
|
||||
@@ -37,24 +36,9 @@ using android::sp;
|
||||
|
||||
#define TIMEOUT_SEC 2 // for basic commands/responses
|
||||
|
||||
// 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.
|
||||
class GnssHalTest : public ::testing::VtsHalHidlTargetTestBase {
|
||||
public:
|
||||
class GnssHalTest : public testing::TestWithParam<std::string> {
|
||||
public:
|
||||
virtual void SetUp() override;
|
||||
|
||||
virtual void TearDown() override;
|
||||
|
||||
@@ -18,9 +18,8 @@
|
||||
|
||||
#include <gnss_hal_test.h>
|
||||
|
||||
#include <VtsHalHidlTargetTestBase.h>
|
||||
|
||||
#include <android/hardware/gnss/1.1/IGnssConfiguration.h>
|
||||
#include <gtest/gtest.h>
|
||||
|
||||
using android::hardware::hidl_vec;
|
||||
|
||||
@@ -39,13 +38,13 @@ using android::hardware::gnss::V1_1::IGnssMeasurement;
|
||||
*
|
||||
* Empty test fixture to verify basic Setup & Teardown
|
||||
*/
|
||||
TEST_F(GnssHalTest, SetupTeardownCreateCleanup) {}
|
||||
TEST_P(GnssHalTest, SetupTeardownCreateCleanup) {}
|
||||
|
||||
/*
|
||||
* TestGnssMeasurementCallback:
|
||||
* Gets the GnssMeasurementExtension and verify that it returns an actual extension.
|
||||
*/
|
||||
TEST_F(GnssHalTest, TestGnssMeasurementCallback) {
|
||||
TEST_P(GnssHalTest, TestGnssMeasurementCallback) {
|
||||
auto gnssMeasurement_1_1 = gnss_hal_->getExtensionGnssMeasurement_1_1();
|
||||
ASSERT_TRUE(gnssMeasurement_1_1.isOk());
|
||||
auto gnssMeasurement_1_0 = gnss_hal_->getExtensionGnssMeasurement();
|
||||
@@ -65,7 +64,7 @@ TEST_F(GnssHalTest, TestGnssMeasurementCallback) {
|
||||
* NO_LOCATION_PERIOD_SEC and verfiy that no location is received. Also perform validity checks on
|
||||
* each received location.
|
||||
*/
|
||||
TEST_F(GnssHalTest, GetLocationLowPower) {
|
||||
TEST_P(GnssHalTest, GetLocationLowPower) {
|
||||
if (!IsGnssHalVersion_1_1()) {
|
||||
ALOGI("Test GetLocationLowPower skipped. GNSS HAL version is greater than 1.1.");
|
||||
return;
|
||||
@@ -97,7 +96,6 @@ TEST_F(GnssHalTest, GetLocationLowPower) {
|
||||
|
||||
gnss_cb_->location_cbq_.retrieve(gnss_cb_->last_location_, kNoLocationPeriodSec);
|
||||
const int location_called_count = gnss_cb_->location_cbq_.calledCount();
|
||||
|
||||
// Tolerate (ignore) one extra location right after the first one
|
||||
// to handle startup edge case scheduling limitations in some implementations
|
||||
if ((i == 1) && (location_called_count == 2)) {
|
||||
@@ -132,7 +130,8 @@ TEST_F(GnssHalTest, GetLocationLowPower) {
|
||||
*/
|
||||
|
||||
IGnssConfiguration::BlacklistedSource FindStrongFrequentNonGpsSource(
|
||||
const list<IGnssCallback::GnssSvStatus> list_gnss_sv_status, const int min_observations) {
|
||||
const std::list<IGnssCallback::GnssSvStatus> list_gnss_sv_status,
|
||||
const int min_observations) {
|
||||
struct ComparableBlacklistedSource {
|
||||
IGnssConfiguration::BlacklistedSource id;
|
||||
|
||||
@@ -218,7 +217,7 @@ IGnssConfiguration::BlacklistedSource FindStrongFrequentNonGpsSource(
|
||||
* 5b) Retry a few times, in case GNSS search strategy takes a while to reacquire even the
|
||||
* formerly strongest satellite
|
||||
*/
|
||||
TEST_F(GnssHalTest, BlacklistIndividualSatellites) {
|
||||
TEST_P(GnssHalTest, BlacklistIndividualSatellites) {
|
||||
if (!IsGnssHalVersion_1_1()) {
|
||||
ALOGI("Test BlacklistIndividualSatellites skipped. GNSS HAL version is greater than 1.1.");
|
||||
return;
|
||||
@@ -244,7 +243,7 @@ TEST_F(GnssHalTest, BlacklistIndividualSatellites) {
|
||||
*/
|
||||
|
||||
const int kGnssSvStatusTimeout = 2;
|
||||
list<IGnssCallback::GnssSvStatus> sv_status_list;
|
||||
std::list<IGnssCallback::GnssSvStatus> sv_status_list;
|
||||
int count = gnss_cb_->sv_status_cbq_.retrieve(sv_status_list, sv_status_cbq_size,
|
||||
kGnssSvStatusTimeout);
|
||||
ASSERT_EQ(count, sv_status_cbq_size);
|
||||
@@ -362,7 +361,7 @@ TEST_F(GnssHalTest, BlacklistIndividualSatellites) {
|
||||
* GnssStatus does not use any constellation but GPS.
|
||||
* 4a & b) Clean up by turning off location, and send in empty blacklist.
|
||||
*/
|
||||
TEST_F(GnssHalTest, BlacklistConstellation) {
|
||||
TEST_P(GnssHalTest, BlacklistConstellation) {
|
||||
if (!IsGnssHalVersion_1_1()) {
|
||||
ALOGI("Test BlacklistConstellation skipped. GNSS HAL version is greater than 1.1.");
|
||||
return;
|
||||
@@ -457,7 +456,7 @@ TEST_F(GnssHalTest, BlacklistConstellation) {
|
||||
*
|
||||
* Ensure successfully injecting a location.
|
||||
*/
|
||||
TEST_F(GnssHalTest, InjectBestLocation) {
|
||||
TEST_P(GnssHalTest, InjectBestLocation) {
|
||||
StartAndCheckLocations(1);
|
||||
GnssLocation gnssLocation = gnss_cb_->last_location_;
|
||||
CheckLocation(gnssLocation, true);
|
||||
@@ -476,7 +475,7 @@ TEST_F(GnssHalTest, InjectBestLocation) {
|
||||
* GnssDebugValuesSanityTest:
|
||||
* Ensures that GnssDebug values make sense.
|
||||
*/
|
||||
TEST_F(GnssHalTest, GnssDebugValuesSanityTest) {
|
||||
TEST_P(GnssHalTest, GnssDebugValuesSanityTest) {
|
||||
auto gnssDebug = gnss_hal_->getExtensionGnssDebug();
|
||||
ASSERT_TRUE(gnssDebug.isOk());
|
||||
if (gnss_cb_->info_cbq_.calledCount() > 0 && gnss_cb_->last_info_.yearOfHw >= 2017) {
|
||||
|
||||
@@ -53,7 +53,7 @@ class GnssCallbackEventQueue {
|
||||
* timeout_seconds to retrieve each event. If timeout occurs, it returns the number of
|
||||
* items retrieved which will be less than count.
|
||||
*/
|
||||
int retrieve(list<T>& event_list, int count, int timeout_seconds);
|
||||
int retrieve(std::list<T>& event_list, int count, int timeout_seconds);
|
||||
|
||||
/* Returns the number of events pending to be retrieved from the callback event queue. */
|
||||
int size() const;
|
||||
@@ -97,7 +97,7 @@ bool GnssCallbackEventQueue<T>::retrieve(T& event, int timeout_seconds) {
|
||||
}
|
||||
|
||||
template <class T>
|
||||
int GnssCallbackEventQueue<T>::retrieve(list<T>& event_list, int count, int timeout_seconds) {
|
||||
int GnssCallbackEventQueue<T>::retrieve(std::list<T>& event_list, int count, int timeout_seconds) {
|
||||
for (int i = 0; i < count; ++i) {
|
||||
T event;
|
||||
if (!retrieve(event, timeout_seconds)) {
|
||||
|
||||
Reference in New Issue
Block a user