mirror of
https://github.com/Evolution-X/hardware_interfaces
synced 2026-02-02 10:05:19 +00:00
Merge "Convert gnss hal test to use VtsHalHidlTargetTestEnvBase"
This commit is contained in:
@@ -19,6 +19,7 @@
|
|||||||
#include <log/log.h>
|
#include <log/log.h>
|
||||||
|
|
||||||
#include <VtsHalHidlTargetTestBase.h>
|
#include <VtsHalHidlTargetTestBase.h>
|
||||||
|
#include <VtsHalHidlTargetTestEnvBase.h>
|
||||||
|
|
||||||
#include <chrono>
|
#include <chrono>
|
||||||
#include <condition_variable>
|
#include <condition_variable>
|
||||||
@@ -41,6 +42,21 @@ 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::VtsHalHidlTargetTestBase {
|
||||||
public:
|
public:
|
||||||
@@ -51,7 +67,8 @@ 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_ = ::testing::VtsHalHidlTargetTestBase::getService<IGnss>(
|
||||||
|
GnssHidlEnvironment::Instance()->getServiceName<IGnss>());
|
||||||
ASSERT_NE(gnss_hal_, nullptr);
|
ASSERT_NE(gnss_hal_, nullptr);
|
||||||
|
|
||||||
gnss_cb_ = new GnssCallback(*this);
|
gnss_cb_ = new GnssCallback(*this);
|
||||||
@@ -449,17 +466,19 @@ TEST_F(GnssHalTest, MeasurementCapabilites) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
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
|
||||||
* stronger tests that require the presence of GPS signal.
|
* stronger tests that require the presence of GPS signal.
|
||||||
*/
|
*/
|
||||||
for (int i = 1; i < argc; i++) {
|
for (int i = 1; i < argc; i++) {
|
||||||
if (strcmp(argv[i], "-agps") == 0) {
|
if (strcmp(argv[i], "-agps") == 0) {
|
||||||
sAgpsIsPresent = true;
|
sAgpsIsPresent = true;
|
||||||
} else if (strcmp(argv[i], "-weak") == 0) {
|
} else if (strcmp(argv[i], "-weak") == 0) {
|
||||||
sSignalIsWeak = true;
|
sSignalIsWeak = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
int status = RUN_ALL_TESTS();
|
int status = RUN_ALL_TESTS();
|
||||||
|
|||||||
Reference in New Issue
Block a user