Merge "Update GNSS VTS 2.0 tests to address sub-HAL support requirements" into qt-dev

This commit is contained in:
Anil Admal 2019-05-03 04:26:24 +00:00 committed by Android (Google) Code Review
commit bb477b95ad

View file

@ -29,6 +29,7 @@ using IGnssMeasurement_2_0 = android::hardware::gnss::V2_0::IGnssMeasurement;
using IGnssMeasurement_1_1 = android::hardware::gnss::V1_1::IGnssMeasurement; using IGnssMeasurement_1_1 = android::hardware::gnss::V1_1::IGnssMeasurement;
using IGnssMeasurement_1_0 = android::hardware::gnss::V1_0::IGnssMeasurement; using IGnssMeasurement_1_0 = android::hardware::gnss::V1_0::IGnssMeasurement;
using IAGnssRil_2_0 = android::hardware::gnss::V2_0::IAGnssRil; using IAGnssRil_2_0 = android::hardware::gnss::V2_0::IAGnssRil;
using IAGnssRil_1_0 = android::hardware::gnss::V1_0::IAGnssRil;
using IAGnss_2_0 = android::hardware::gnss::V2_0::IAGnss; using IAGnss_2_0 = android::hardware::gnss::V2_0::IAGnss;
using IAGnss_1_0 = android::hardware::gnss::V1_0::IAGnss; using IAGnss_1_0 = android::hardware::gnss::V1_0::IAGnss;
using IAGnssCallback_2_0 = android::hardware::gnss::V2_0::IAGnssCallback; using IAGnssCallback_2_0 = android::hardware::gnss::V2_0::IAGnssCallback;
@ -125,16 +126,21 @@ TEST_F(GnssHalTest, TestGnssConfiguration_setGpsLock_Deprecation) {
* TestAGnssRilExtension: * TestAGnssRilExtension:
* Gets the AGnssRilExtension and verifies that it returns an actual extension. * Gets the AGnssRilExtension and verifies that it returns an actual extension.
* *
* The GNSS HAL 2.0 implementation must support @2.0::IAGnssRil interface due to the deprecation * If IAGnssRil interface is supported, then the GNSS HAL 2.0 implementation must support
* of framework network API methods needed to support the @1.0::IAGnssRil interface. * @2.0::IAGnssRil interface due to the deprecation of framework network API methods needed
* * to support the @1.0::IAGnssRil interface.
* TODO (b/121287858): Enforce gnss@2.0 HAL package is supported on devices launched with Q or later
*/ */
TEST_F(GnssHalTest, TestAGnssRilExtension) { TEST_F(GnssHalTest, TestAGnssRilExtension) {
auto agnssRil = gnss_hal_->getExtensionAGnssRil_2_0(); auto agnssRil_2_0 = gnss_hal_->getExtensionAGnssRil_2_0();
ASSERT_TRUE(agnssRil.isOk()); ASSERT_TRUE(agnssRil_2_0.isOk());
sp<IAGnssRil_2_0> iAGnssRil = agnssRil; sp<IAGnssRil_2_0> iAGnssRil_2_0 = agnssRil_2_0;
ASSERT_NE(iAGnssRil, nullptr); if (iAGnssRil_2_0 == nullptr) {
// Verify IAGnssRil 1.0 is not supported.
auto agnssRil_1_0 = gnss_hal_->getExtensionAGnssRil();
ASSERT_TRUE(agnssRil_1_0.isOk());
sp<IAGnssRil_1_0> iAGnssRil_1_0 = agnssRil_1_0;
ASSERT_EQ(iAGnssRil_1_0, nullptr);
}
} }
/* /*
@ -146,7 +152,9 @@ TEST_F(GnssHalTest, TestAGnssRil_UpdateNetworkState_2_0) {
auto agnssRil = gnss_hal_->getExtensionAGnssRil_2_0(); auto agnssRil = gnss_hal_->getExtensionAGnssRil_2_0();
ASSERT_TRUE(agnssRil.isOk()); ASSERT_TRUE(agnssRil.isOk());
sp<IAGnssRil_2_0> iAGnssRil = agnssRil; sp<IAGnssRil_2_0> iAGnssRil = agnssRil;
ASSERT_NE(iAGnssRil, nullptr); if (iAGnssRil == nullptr) {
return;
}
// Update GNSS HAL that a network has connected. // Update GNSS HAL that a network has connected.
IAGnssRil_2_0::NetworkAttributes networkAttributes = { IAGnssRil_2_0::NetworkAttributes networkAttributes = {
@ -219,44 +227,35 @@ TEST_F(GnssHalTest, TestGnssMeasurementFields) {
/* /*
* TestAGnssExtension: * TestAGnssExtension:
* Gets the AGnssExtension and verifies that it supports @2.0::IAGnss interface by invoking * Gets the AGnssExtension and verifies that it returns an actual extension.
* a method.
* *
* The GNSS HAL 2.0 implementation must support @2.0::IAGnss interface due to the deprecation * If IAGnss interface is supported, then the GNSS HAL 2.0 implementation must support
* of framework network API methods needed to support the @1.0::IAGnss interface. * @2.0::IAGnss interface due to the deprecation of framework network API methods needed
* * to support the @1.0::IAGnss interface.
* TODO (b/121287858): Enforce gnss@2.0 HAL package is supported on devices launched with Q or later
*/ */
TEST_F(GnssHalTest, TestAGnssExtension) { TEST_F(GnssHalTest, TestAGnssExtension) {
// Verify IAGnss 2.0 is supported. auto agnss_2_0 = gnss_hal_->getExtensionAGnss_2_0();
auto agnss = gnss_hal_->getExtensionAGnss_2_0(); ASSERT_TRUE(agnss_2_0.isOk());
ASSERT_TRUE(agnss.isOk()); sp<IAGnss_2_0> iAGnss_2_0 = agnss_2_0;
sp<IAGnss_2_0> iAGnss = agnss; if (iAGnss_2_0 == nullptr) {
ASSERT_NE(iAGnss, nullptr); // Verify IAGnss 1.0 is not supported.
auto agnss_1_0 = gnss_hal_->getExtensionAGnss();
ASSERT_TRUE(agnss_1_0.isOk());
sp<IAGnss_1_0> iAGnss_1_0 = agnss_1_0;
ASSERT_EQ(iAGnss_1_0, nullptr);
return;
}
// Set SUPL server host/port // Set SUPL server host/port
auto result = iAGnss->setServer(IAGnssCallback_2_0::AGnssType::SUPL, "supl.google.com", 7275); auto result =
iAGnss_2_0->setServer(IAGnssCallback_2_0::AGnssType::SUPL, "supl.google.com", 7275);
ASSERT_TRUE(result.isOk()); ASSERT_TRUE(result.isOk());
EXPECT_TRUE(result); EXPECT_TRUE(result);
} }
/*
* TestAGnssExtension_1_0_Deprecation:
* Gets the @1.0::IAGnss extension and verifies that it is a nullptr.
*
* TODO (b/121287858): Enforce gnss@2.0 HAL package is supported on devices launched with Q or later
*/
TEST_F(GnssHalTest, TestAGnssExtension_1_0_Deprecation) {
// Verify IAGnss 1.0 is not supported.
auto agnss_1_0 = gnss_hal_->getExtensionAGnss();
ASSERT_TRUE(!agnss_1_0.isOk() || ((sp<IAGnss_1_0>)agnss_1_0) == nullptr);
}
/* /*
* TestGnssNiExtension_Deprecation: * TestGnssNiExtension_Deprecation:
* Gets the @1.0::IGnssNi extension and verifies that it is a nullptr. * Gets the @1.0::IGnssNi extension and verifies that it is a nullptr.
*
* TODO (b/121287858): Enforce gnss@2.0 HAL package is supported on devices launched with Q or later
*/ */
TEST_F(GnssHalTest, TestGnssNiExtension_Deprecation) { TEST_F(GnssHalTest, TestGnssNiExtension_Deprecation) {
// Verify IGnssNi 1.0 is not supported. // Verify IGnssNi 1.0 is not supported.
@ -266,22 +265,19 @@ TEST_F(GnssHalTest, TestGnssNiExtension_Deprecation) {
/* /*
* TestGnssVisibilityControlExtension: * TestGnssVisibilityControlExtension:
* Gets the GnssVisibilityControlExtension and verifies that it supports the * Gets the GnssVisibilityControlExtension and if it is not null, verifies that it supports
* gnss.visibility_control@1.0::IGnssVisibilityControl interface by invoking a method. * the gnss.visibility_control@1.0::IGnssVisibilityControl interface by invoking a method.
*
* The GNSS HAL 2.0 implementation must support gnss.visibility_control@1.0::IGnssVisibilityControl.
*
* TODO (b/121287858): Enforce gnss@2.0 HAL package is supported on devices launched with Q or later
*/ */
TEST_F(GnssHalTest, TestGnssVisibilityControlExtension) { TEST_F(GnssHalTest, TestGnssVisibilityControlExtension) {
// Verify IGnssVisibilityControl is supported.
auto gnssVisibilityControl = gnss_hal_->getExtensionVisibilityControl(); auto gnssVisibilityControl = gnss_hal_->getExtensionVisibilityControl();
ASSERT_TRUE(gnssVisibilityControl.isOk()); ASSERT_TRUE(gnssVisibilityControl.isOk());
sp<IGnssVisibilityControl> iGnssVisibilityControl = gnssVisibilityControl; sp<IGnssVisibilityControl> iGnssVisibilityControl = gnssVisibilityControl;
ASSERT_NE(iGnssVisibilityControl, nullptr); if (iGnssVisibilityControl == nullptr) {
return;
}
// Set non-framework proxy apps. // Set non-framework proxy apps.
hidl_vec<hidl_string> proxyApps{"ims.example.com", "mdt.example.com"}; hidl_vec<hidl_string> proxyApps{"com.example.ims", "com.example.mdt"};
auto result = iGnssVisibilityControl->enableNfwLocationAccess(proxyApps); auto result = iGnssVisibilityControl->enableNfwLocationAccess(proxyApps);
ASSERT_TRUE(result.isOk()); ASSERT_TRUE(result.isOk());
EXPECT_TRUE(result); EXPECT_TRUE(result);
@ -408,17 +404,10 @@ TEST_F(GnssHalTest, TestInjectBestLocation_2_0) {
/* /*
* TestGnssBatchingExtension: * TestGnssBatchingExtension:
* Gets the GnssBatchingExtension and verifies that it supports either the @1.0::IGnssBatching * Gets the @2.0::IGnssBatching extension and verifies that it doesn't return an error. Support
* or @2.0::IGnssBatching extension. * for this interface is optional.
*/ */
TEST_F(GnssHalTest, TestGnssBatchingExtension) { TEST_F(GnssHalTest, TestGnssBatchingExtension) {
auto gnssBatching_V2_0 = gnss_hal_->getExtensionGnssBatching_2_0(); auto gnssBatching_2_0 = gnss_hal_->getExtensionGnssBatching_2_0();
ASSERT_TRUE(gnssBatching_V2_0.isOk()); ASSERT_TRUE(gnssBatching_2_0.isOk());
auto gnssBatching_V1_0 = gnss_hal_->getExtensionGnssBatching();
ASSERT_TRUE(gnssBatching_V1_0.isOk());
sp<IGnssBatching_V1_0> iGnssBatching_V1_0 = gnssBatching_V1_0;
sp<IGnssBatching_V2_0> iGnssBatching_V2_0 = gnssBatching_V2_0;
ASSERT_TRUE(iGnssBatching_V1_0 != nullptr || iGnssBatching_V2_0 != nullptr);
} }