Merge "Convert gnss hal test to use VtsHalHidlTargetTestEnvBase"
This commit is contained in:
commit
56ef9e277a
4 changed files with 48 additions and 9 deletions
|
@ -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();
|
||||
|
|
|
@ -13,12 +13,17 @@
|
|||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
#define LOG_TAG "VtsHalGnssV1_1TargetTest"
|
||||
|
||||
#include <VtsHalHidlTargetTestBase.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;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -27,7 +27,8 @@ GnssHalTest::GnssHalTest()
|
|||
notify_count_(0) {}
|
||||
|
||||
void GnssHalTest::SetUp() {
|
||||
gnss_hal_ = ::testing::VtsHalHidlTargetTestBase::getService<IGnss>();
|
||||
gnss_hal_ = ::testing::VtsHalHidlTargetTestBase::getService<IGnss>(
|
||||
GnssHidlEnvironment::Instance()->getServiceName<IGnss>());
|
||||
list_gnss_sv_status_.clear();
|
||||
ASSERT_NE(gnss_hal_, nullptr);
|
||||
}
|
||||
|
|
|
@ -17,11 +17,10 @@
|
|||
#ifndef GNSS_HAL_TEST_H_
|
||||
#define GNSS_HAL_TEST_H_
|
||||
|
||||
#define LOG_TAG "VtsHalGnssV1_1TargetTest"
|
||||
|
||||
#include <android/hardware/gnss/1.1/IGnss.h>
|
||||
|
||||
#include <VtsHalHidlTargetTestBase.h>
|
||||
#include <VtsHalHidlTargetTestEnvBase.h>
|
||||
|
||||
#include <condition_variable>
|
||||
#include <list>
|
||||
|
@ -40,6 +39,21 @@ 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:
|
||||
|
|
Loading…
Reference in a new issue