Merge "Convert gnss hal test to use VtsHalHidlTargetTestEnvBase" am: 73f36294ce

am: 484489d6d7

Change-Id: I84827668a962b4bbbf8d7d997ee451dc8d3a8d8c
This commit is contained in:
Zhuoyao Zhang 2018-02-13 22:29:04 +00:00 committed by android-build-merger
commit 2db2c60f5d

View file

@ -19,6 +19,7 @@
#include <log/log.h>
#include <VtsHalHidlTargetTestBase.h>
#include <VtsHalHidlTargetTestEnvBase.h>
#include <chrono>
#include <condition_variable>
@ -41,6 +42,21 @@ using android::sp;
bool sAgpsIsPresent = false; // if SUPL or XTRA assistance available
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.
class GnssHalTest : public ::testing::VtsHalHidlTargetTestBase {
public:
@ -51,7 +67,8 @@ class GnssHalTest : public ::testing::VtsHalHidlTargetTestBase {
info_called_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);
gnss_cb_ = new GnssCallback(*this);
@ -456,17 +473,19 @@ TEST_F(GnssHalTest, MeasurementCapabilites) {
}
int main(int argc, char** argv) {
::testing::AddGlobalTestEnvironment(GnssHidlEnvironment::Instance());
::testing::InitGoogleTest(&argc, argv);
GnssHidlEnvironment::Instance()->init(&argc, argv);
/*
* These arguments not used by automated VTS testing.
* Only for use in manual testing, when wanting to run
* stronger tests that require the presence of GPS signal.
*/
for (int i = 1; i < argc; i++) {
if (strcmp(argv[i], "-agps") == 0) {
sAgpsIsPresent = true;
} else if (strcmp(argv[i], "-weak") == 0) {
sSignalIsWeak = true;
if (strcmp(argv[i], "-agps") == 0) {
sAgpsIsPresent = true;
} else if (strcmp(argv[i], "-weak") == 0) {
sSignalIsWeak = true;
}
}
int status = RUN_ALL_TESTS();