Merge "Convert gnss hal test to use VtsHalHidlTargetTestEnvBase"

am: 73f36294ce

Change-Id: I565ccdbe901de2bf0fd46422773453650791248e
This commit is contained in:
Zhuoyao Zhang 2018-02-13 22:16:14 +00:00 committed by android-build-merger
commit 484489d6d7

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);
@ -449,17 +466,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();