Wyatt Riley | 6c26ed7 | 2017-02-21 17:21:53 -0800 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2017 The Android Open Source Project |
| 3 | * |
| 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | * you may not use this file except in compliance with the License. |
| 6 | * You may obtain a copy of the License at |
| 7 | * |
| 8 | * http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | * |
| 10 | * Unless required by applicable law or agreed to in writing, software |
| 11 | * distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | * See the License for the specific language governing permissions and |
| 14 | * limitations under the License. |
| 15 | */ |
| 16 | |
| 17 | #define LOG_TAG "VtsHalGnssV1_0TargetTest" |
| 18 | #include <android/hardware/gnss/1.0/IGnss.h> |
Steven Moreland | 4e7a307 | 2017-04-06 12:15:23 -0700 | [diff] [blame] | 19 | #include <log/log.h> |
Wyatt Riley | 6c26ed7 | 2017-02-21 17:21:53 -0800 | [diff] [blame] | 20 | |
Yuexi Ma | ed2bb4e | 2017-03-10 00:44:45 -0800 | [diff] [blame] | 21 | #include <VtsHalHidlTargetTestBase.h> |
Wyatt Riley | 6c26ed7 | 2017-02-21 17:21:53 -0800 | [diff] [blame] | 22 | |
| 23 | #include <chrono> |
| 24 | #include <condition_variable> |
| 25 | #include <mutex> |
| 26 | |
| 27 | using android::hardware::Return; |
| 28 | using android::hardware::Void; |
| 29 | |
| 30 | using android::hardware::gnss::V1_0::GnssLocation; |
| 31 | using android::hardware::gnss::V1_0::GnssLocationFlags; |
| 32 | using android::hardware::gnss::V1_0::IGnss; |
| 33 | using android::hardware::gnss::V1_0::IGnssCallback; |
Wyatt Riley | c139959 | 2017-03-22 14:08:26 -0700 | [diff] [blame] | 34 | using android::hardware::gnss::V1_0::IGnssDebug; |
| 35 | using android::hardware::gnss::V1_0::IGnssMeasurement; |
Wyatt Riley | 6c26ed7 | 2017-02-21 17:21:53 -0800 | [diff] [blame] | 36 | using android::sp; |
| 37 | |
Wyatt Riley | 0ee0cfb | 2017-04-04 12:34:53 -0700 | [diff] [blame] | 38 | #define TIMEOUT_SEC 2 // for basic commands/responses |
Wyatt Riley | 6c26ed7 | 2017-02-21 17:21:53 -0800 | [diff] [blame] | 39 | |
Wyatt Riley | 0ee0cfb | 2017-04-04 12:34:53 -0700 | [diff] [blame] | 40 | // for command line argument on how strictly to run the test |
| 41 | bool sAgpsIsPresent = false; // if SUPL or XTRA assistance available |
Wyatt Riley | 94c7a04 | 2017-06-15 17:16:24 -0700 | [diff] [blame^] | 42 | bool sSignalIsWeak = false; // if GNSS signals are weak (e.g. light indoor) |
Wyatt Riley | c139959 | 2017-03-22 14:08:26 -0700 | [diff] [blame] | 43 | |
Wyatt Riley | 6c26ed7 | 2017-02-21 17:21:53 -0800 | [diff] [blame] | 44 | // The main test class for GNSS HAL. |
Yuexi Ma | ed2bb4e | 2017-03-10 00:44:45 -0800 | [diff] [blame] | 45 | class GnssHalTest : public ::testing::VtsHalHidlTargetTestBase { |
Wyatt Riley | 6c26ed7 | 2017-02-21 17:21:53 -0800 | [diff] [blame] | 46 | public: |
| 47 | virtual void SetUp() override { |
Wyatt Riley | 917640b | 2017-03-16 16:25:55 -0700 | [diff] [blame] | 48 | // Clean between tests |
| 49 | capabilities_called_count_ = 0; |
| 50 | location_called_count_ = 0; |
| 51 | info_called_count_ = 0; |
Wyatt Riley | 6c26ed7 | 2017-02-21 17:21:53 -0800 | [diff] [blame] | 52 | |
Yuexi Ma | ed2bb4e | 2017-03-10 00:44:45 -0800 | [diff] [blame] | 53 | gnss_hal_ = ::testing::VtsHalHidlTargetTestBase::getService<IGnss>(); |
Wyatt Riley | 6c26ed7 | 2017-02-21 17:21:53 -0800 | [diff] [blame] | 54 | ASSERT_NE(gnss_hal_, nullptr); |
| 55 | |
| 56 | gnss_cb_ = new GnssCallback(*this); |
| 57 | ASSERT_NE(gnss_cb_, nullptr); |
| 58 | |
| 59 | auto result = gnss_hal_->setCallback(gnss_cb_); |
| 60 | if (!result.isOk()) { |
Wyatt Riley | 917640b | 2017-03-16 16:25:55 -0700 | [diff] [blame] | 61 | ALOGE("result of failed setCallback %s", result.description().c_str()); |
Wyatt Riley | 6c26ed7 | 2017-02-21 17:21:53 -0800 | [diff] [blame] | 62 | } |
| 63 | |
| 64 | ASSERT_TRUE(result.isOk()); |
| 65 | ASSERT_TRUE(result); |
| 66 | |
Wyatt Riley | 917640b | 2017-03-16 16:25:55 -0700 | [diff] [blame] | 67 | /* |
| 68 | * At least one callback should trigger - it may be capabilites, or |
| 69 | * system info first, so wait again if capabilities not received. |
Wyatt Riley | 6c26ed7 | 2017-02-21 17:21:53 -0800 | [diff] [blame] | 70 | */ |
Wyatt Riley | 917640b | 2017-03-16 16:25:55 -0700 | [diff] [blame] | 71 | EXPECT_EQ(std::cv_status::no_timeout, wait(TIMEOUT_SEC)); |
| 72 | if (capabilities_called_count_ == 0) { |
| 73 | EXPECT_EQ(std::cv_status::no_timeout, wait(TIMEOUT_SEC)); |
| 74 | } |
| 75 | |
| 76 | /* |
| 77 | * Generally should be 1 capabilites callback - |
| 78 | * or possibly 2 in some recovery cases (default cached & refreshed) |
| 79 | */ |
| 80 | EXPECT_GE(capabilities_called_count_, 1); |
| 81 | EXPECT_LE(capabilities_called_count_, 2); |
| 82 | |
| 83 | /* |
| 84 | * Clear notify/waiting counter, allowing up till the timeout after |
| 85 | * the last reply for final startup messages to arrive (esp. system |
| 86 | * info.) |
| 87 | */ |
| 88 | while (wait(TIMEOUT_SEC) == std::cv_status::no_timeout) { |
| 89 | } |
Wyatt Riley | 6c26ed7 | 2017-02-21 17:21:53 -0800 | [diff] [blame] | 90 | } |
| 91 | |
| 92 | virtual void TearDown() override { |
| 93 | if (gnss_hal_ != nullptr) { |
| 94 | gnss_hal_->cleanup(); |
| 95 | } |
| 96 | } |
| 97 | |
| 98 | /* Used as a mechanism to inform the test that a callback has occurred */ |
| 99 | inline void notify() { |
| 100 | std::unique_lock<std::mutex> lock(mtx_); |
| 101 | count++; |
| 102 | cv_.notify_one(); |
| 103 | } |
| 104 | |
| 105 | /* Test code calls this function to wait for a callback */ |
| 106 | inline std::cv_status wait(int timeoutSeconds) { |
| 107 | std::unique_lock<std::mutex> lock(mtx_); |
| 108 | |
| 109 | std::cv_status status = std::cv_status::no_timeout; |
| 110 | auto now = std::chrono::system_clock::now(); |
| 111 | while (count == 0) { |
| 112 | status = cv_.wait_until(lock, now + std::chrono::seconds(timeoutSeconds)); |
| 113 | if (status == std::cv_status::timeout) return status; |
| 114 | } |
| 115 | count--; |
| 116 | return status; |
| 117 | } |
| 118 | |
Wyatt Riley | 94c7a04 | 2017-06-15 17:16:24 -0700 | [diff] [blame^] | 119 | /* |
| 120 | * StartAndGetSingleLocation: |
| 121 | * Helper function to get one Location and check fields |
| 122 | * |
| 123 | * returns true if a location was successfully generated |
| 124 | */ |
| 125 | bool StartAndGetSingleLocation(bool checkAccuracies) { |
| 126 | auto result = gnss_hal_->start(); |
| 127 | |
| 128 | EXPECT_TRUE(result.isOk()); |
| 129 | EXPECT_TRUE(result); |
| 130 | |
| 131 | /* |
| 132 | * GPS signals initially optional for this test, so don't expect fast fix, |
| 133 | * or no timeout, unless signal is present |
| 134 | */ |
| 135 | int firstGnssLocationTimeoutSeconds = sAgpsIsPresent ? 15 : 45; |
| 136 | if (sSignalIsWeak) { |
| 137 | // allow more time for weak signals |
| 138 | firstGnssLocationTimeoutSeconds += 30; |
| 139 | } |
| 140 | |
| 141 | wait(firstGnssLocationTimeoutSeconds); |
| 142 | if (sAgpsIsPresent) { |
| 143 | EXPECT_EQ(location_called_count_, 1); |
| 144 | } |
| 145 | if (location_called_count_ > 0) { |
| 146 | CheckLocation(last_location_, checkAccuracies); |
| 147 | return true; |
| 148 | } |
| 149 | return false; |
| 150 | } |
| 151 | |
| 152 | /* |
| 153 | * StopAndClearLocations: |
| 154 | * Helper function to stop locations |
| 155 | * |
| 156 | * returns true if a location was successfully generated |
| 157 | */ |
| 158 | void StopAndClearLocations() { |
| 159 | auto result = gnss_hal_->stop(); |
| 160 | |
| 161 | EXPECT_TRUE(result.isOk()); |
| 162 | EXPECT_TRUE(result); |
| 163 | |
| 164 | /* |
| 165 | * Clear notify/waiting counter, allowing up till the timeout after |
| 166 | * the last reply for final startup messages to arrive (esp. system |
| 167 | * info.) |
| 168 | */ |
| 169 | while (wait(TIMEOUT_SEC) == std::cv_status::no_timeout) { |
| 170 | } |
| 171 | } |
| 172 | |
| 173 | /* |
| 174 | * CheckLocation: |
| 175 | * Helper function to vet Location fields |
| 176 | */ |
| 177 | void CheckLocation(GnssLocation& location, bool checkAccuracies) { |
| 178 | EXPECT_TRUE(location.gnssLocationFlags & GnssLocationFlags::HAS_LAT_LONG); |
| 179 | EXPECT_TRUE(location.gnssLocationFlags & GnssLocationFlags::HAS_ALTITUDE); |
| 180 | EXPECT_TRUE(location.gnssLocationFlags & GnssLocationFlags::HAS_SPEED); |
| 181 | EXPECT_TRUE(location.gnssLocationFlags & GnssLocationFlags::HAS_HORIZONTAL_ACCURACY); |
| 182 | // New uncertainties available in O must be provided, |
| 183 | // at least when paired with modern hardware (2017+) |
| 184 | if (checkAccuracies) { |
| 185 | EXPECT_TRUE(location.gnssLocationFlags & GnssLocationFlags::HAS_VERTICAL_ACCURACY); |
| 186 | EXPECT_TRUE(location.gnssLocationFlags & GnssLocationFlags::HAS_SPEED_ACCURACY); |
| 187 | if (location.gnssLocationFlags & GnssLocationFlags::HAS_BEARING) { |
| 188 | EXPECT_TRUE(location.gnssLocationFlags & GnssLocationFlags::HAS_BEARING_ACCURACY); |
| 189 | } |
| 190 | } |
| 191 | EXPECT_GE(location.latitudeDegrees, -90.0); |
| 192 | EXPECT_LE(location.latitudeDegrees, 90.0); |
| 193 | EXPECT_GE(location.longitudeDegrees, -180.0); |
| 194 | EXPECT_LE(location.longitudeDegrees, 180.0); |
| 195 | EXPECT_GE(location.altitudeMeters, -1000.0); |
| 196 | EXPECT_LE(location.altitudeMeters, 30000.0); |
| 197 | EXPECT_GE(location.speedMetersPerSec, 0.0); |
| 198 | EXPECT_LE(location.speedMetersPerSec, 5.0); // VTS tests are stationary. |
| 199 | |
| 200 | // Non-zero speeds must be reported with an associated bearing |
| 201 | if (location.speedMetersPerSec > 0.0) { |
| 202 | EXPECT_TRUE(location.gnssLocationFlags & GnssLocationFlags::HAS_BEARING); |
| 203 | } |
| 204 | |
| 205 | /* |
| 206 | * Tolerating some especially high values for accuracy estimate, in case of |
| 207 | * first fix with especially poor geometry (happens occasionally) |
| 208 | */ |
| 209 | EXPECT_GT(location.horizontalAccuracyMeters, 0.0); |
| 210 | EXPECT_LE(location.horizontalAccuracyMeters, 250.0); |
| 211 | |
| 212 | /* |
| 213 | * Some devices may define bearing as -180 to +180, others as 0 to 360. |
| 214 | * Both are okay & understandable. |
| 215 | */ |
| 216 | if (location.gnssLocationFlags & GnssLocationFlags::HAS_BEARING) { |
| 217 | EXPECT_GE(location.bearingDegrees, -180.0); |
| 218 | EXPECT_LE(location.bearingDegrees, 360.0); |
| 219 | } |
| 220 | if (location.gnssLocationFlags & GnssLocationFlags::HAS_VERTICAL_ACCURACY) { |
| 221 | EXPECT_GT(location.verticalAccuracyMeters, 0.0); |
| 222 | EXPECT_LE(location.verticalAccuracyMeters, 500.0); |
| 223 | } |
| 224 | if (location.gnssLocationFlags & GnssLocationFlags::HAS_SPEED_ACCURACY) { |
| 225 | EXPECT_GT(location.speedAccuracyMetersPerSecond, 0.0); |
| 226 | EXPECT_LE(location.speedAccuracyMetersPerSecond, 50.0); |
| 227 | } |
| 228 | if (location.gnssLocationFlags & GnssLocationFlags::HAS_BEARING_ACCURACY) { |
| 229 | EXPECT_GT(location.bearingAccuracyDegrees, 0.0); |
| 230 | EXPECT_LE(location.bearingAccuracyDegrees, 360.0); |
| 231 | } |
| 232 | |
| 233 | // Check timestamp > 1.48e12 (47 years in msec - 1970->2017+) |
| 234 | EXPECT_GT(location.timestamp, 1.48e12); |
| 235 | } |
| 236 | |
Wyatt Riley | 6c26ed7 | 2017-02-21 17:21:53 -0800 | [diff] [blame] | 237 | /* Callback class for data & Event. */ |
| 238 | class GnssCallback : public IGnssCallback { |
Wyatt Riley | 917640b | 2017-03-16 16:25:55 -0700 | [diff] [blame] | 239 | public: |
Wyatt Riley | 6c26ed7 | 2017-02-21 17:21:53 -0800 | [diff] [blame] | 240 | GnssHalTest& parent_; |
| 241 | |
Wyatt Riley | 6c26ed7 | 2017-02-21 17:21:53 -0800 | [diff] [blame] | 242 | GnssCallback(GnssHalTest& parent) : parent_(parent){}; |
| 243 | |
| 244 | virtual ~GnssCallback() = default; |
| 245 | |
| 246 | // Dummy callback handlers |
| 247 | Return<void> gnssStatusCb( |
Steven Moreland | 4b52395 | 2017-03-08 19:20:30 -0800 | [diff] [blame] | 248 | const IGnssCallback::GnssStatusValue /* status */) override { |
Wyatt Riley | 6c26ed7 | 2017-02-21 17:21:53 -0800 | [diff] [blame] | 249 | return Void(); |
| 250 | } |
| 251 | Return<void> gnssSvStatusCb( |
Steven Moreland | 4b52395 | 2017-03-08 19:20:30 -0800 | [diff] [blame] | 252 | const IGnssCallback::GnssSvStatus& /* svStatus */) override { |
Wyatt Riley | 6c26ed7 | 2017-02-21 17:21:53 -0800 | [diff] [blame] | 253 | return Void(); |
| 254 | } |
| 255 | Return<void> gnssNmeaCb( |
Steven Moreland | 4b52395 | 2017-03-08 19:20:30 -0800 | [diff] [blame] | 256 | int64_t /* timestamp */, |
| 257 | const android::hardware::hidl_string& /* nmea */) override { |
Wyatt Riley | 6c26ed7 | 2017-02-21 17:21:53 -0800 | [diff] [blame] | 258 | return Void(); |
| 259 | } |
| 260 | Return<void> gnssAcquireWakelockCb() override { return Void(); } |
| 261 | Return<void> gnssReleaseWakelockCb() override { return Void(); } |
| 262 | Return<void> gnssRequestTimeCb() override { return Void(); } |
| 263 | |
| 264 | // Actual (test) callback handlers |
| 265 | Return<void> gnssLocationCb(const GnssLocation& location) override { |
| 266 | ALOGI("Location received"); |
| 267 | parent_.location_called_count_++; |
| 268 | parent_.last_location_ = location; |
| 269 | parent_.notify(); |
| 270 | return Void(); |
| 271 | } |
| 272 | |
| 273 | Return<void> gnssSetCapabilitesCb(uint32_t capabilities) override { |
| 274 | ALOGI("Capabilities received %d", capabilities); |
| 275 | parent_.capabilities_called_count_++; |
| 276 | parent_.last_capabilities_ = capabilities; |
| 277 | parent_.notify(); |
| 278 | return Void(); |
| 279 | } |
| 280 | |
| 281 | Return<void> gnssSetSystemInfoCb( |
| 282 | const IGnssCallback::GnssSystemInfo& info) override { |
| 283 | ALOGI("Info received, year %d", info.yearOfHw); |
| 284 | parent_.info_called_count_++; |
| 285 | parent_.last_info_ = info; |
| 286 | parent_.notify(); |
| 287 | return Void(); |
| 288 | } |
| 289 | }; |
| 290 | |
| 291 | sp<IGnss> gnss_hal_; // GNSS HAL to call into |
| 292 | sp<IGnssCallback> gnss_cb_; // Primary callback interface |
| 293 | |
| 294 | /* Count of calls to set the following items, and the latest item (used by |
| 295 | * test.) |
| 296 | */ |
| 297 | int capabilities_called_count_; |
| 298 | uint32_t last_capabilities_; |
| 299 | |
| 300 | int location_called_count_; |
| 301 | GnssLocation last_location_; |
| 302 | |
| 303 | int info_called_count_; |
| 304 | IGnssCallback::GnssSystemInfo last_info_; |
| 305 | |
| 306 | private: |
| 307 | std::mutex mtx_; |
| 308 | std::condition_variable cv_; |
| 309 | int count; |
| 310 | }; |
| 311 | |
| 312 | /* |
| 313 | * SetCallbackCapabilitiesCleanup: |
| 314 | * Sets up the callback, awaits the capabilities, and calls cleanup |
| 315 | * |
| 316 | * Since this is just the basic operation of SetUp() and TearDown(), |
Wyatt Riley | 917640b | 2017-03-16 16:25:55 -0700 | [diff] [blame] | 317 | * the function definition is intentionally empty |
Wyatt Riley | 6c26ed7 | 2017-02-21 17:21:53 -0800 | [diff] [blame] | 318 | */ |
| 319 | TEST_F(GnssHalTest, SetCallbackCapabilitiesCleanup) {} |
| 320 | |
Wyatt Riley | 917640b | 2017-03-16 16:25:55 -0700 | [diff] [blame] | 321 | /* |
Wyatt Riley | 6c26ed7 | 2017-02-21 17:21:53 -0800 | [diff] [blame] | 322 | * GetLocation: |
| 323 | * Turns on location, waits 45 second for at least 5 locations, |
| 324 | * and checks them for reasonable validity. |
| 325 | */ |
| 326 | TEST_F(GnssHalTest, GetLocation) { |
| 327 | #define MIN_INTERVAL_MSEC 500 |
| 328 | #define PREFERRED_ACCURACY 0 // Ideally perfect (matches GnssLocationProvider) |
| 329 | #define PREFERRED_TIME_MSEC 0 // Ideally immediate |
| 330 | |
Wyatt Riley | 6c26ed7 | 2017-02-21 17:21:53 -0800 | [diff] [blame] | 331 | #define LOCATION_TIMEOUT_SUBSEQUENT_SEC 3 |
| 332 | #define LOCATIONS_TO_CHECK 5 |
| 333 | |
Wyatt Riley | 917640b | 2017-03-16 16:25:55 -0700 | [diff] [blame] | 334 | bool checkMoreAccuracies = |
| 335 | (info_called_count_ > 0 && last_info_.yearOfHw >= 2017); |
| 336 | |
Wyatt Riley | 6c26ed7 | 2017-02-21 17:21:53 -0800 | [diff] [blame] | 337 | auto result = gnss_hal_->setPositionMode( |
| 338 | IGnss::GnssPositionMode::MS_BASED, |
| 339 | IGnss::GnssPositionRecurrence::RECURRENCE_PERIODIC, MIN_INTERVAL_MSEC, |
| 340 | PREFERRED_ACCURACY, PREFERRED_TIME_MSEC); |
| 341 | |
| 342 | ASSERT_TRUE(result.isOk()); |
Wyatt Riley | c139959 | 2017-03-22 14:08:26 -0700 | [diff] [blame] | 343 | EXPECT_TRUE(result); |
Wyatt Riley | 6c26ed7 | 2017-02-21 17:21:53 -0800 | [diff] [blame] | 344 | |
Wyatt Riley | c139959 | 2017-03-22 14:08:26 -0700 | [diff] [blame] | 345 | /* |
| 346 | * GPS signals initially optional for this test, so don't expect no timeout |
| 347 | * yet |
| 348 | */ |
Wyatt Riley | 94c7a04 | 2017-06-15 17:16:24 -0700 | [diff] [blame^] | 349 | bool gotLocation = StartAndGetSingleLocation(checkMoreAccuracies); |
Wyatt Riley | 6c26ed7 | 2017-02-21 17:21:53 -0800 | [diff] [blame] | 350 | |
Wyatt Riley | 0ee0cfb | 2017-04-04 12:34:53 -0700 | [diff] [blame] | 351 | if (gotLocation) { |
| 352 | for (int i = 1; i < LOCATIONS_TO_CHECK; i++) { |
Wyatt Riley | 94c7a04 | 2017-06-15 17:16:24 -0700 | [diff] [blame^] | 353 | EXPECT_EQ(std::cv_status::no_timeout, wait(LOCATION_TIMEOUT_SUBSEQUENT_SEC)); |
| 354 | EXPECT_EQ(location_called_count_, i + 1); |
| 355 | CheckLocation(last_location_, checkMoreAccuracies); |
Wyatt Riley | 917640b | 2017-03-16 16:25:55 -0700 | [diff] [blame] | 356 | } |
Wyatt Riley | 6c26ed7 | 2017-02-21 17:21:53 -0800 | [diff] [blame] | 357 | } |
| 358 | |
Wyatt Riley | 94c7a04 | 2017-06-15 17:16:24 -0700 | [diff] [blame^] | 359 | StopAndClearLocations(); |
Wyatt Riley | 6c26ed7 | 2017-02-21 17:21:53 -0800 | [diff] [blame] | 360 | } |
| 361 | |
Wyatt Riley | c139959 | 2017-03-22 14:08:26 -0700 | [diff] [blame] | 362 | /* |
| 363 | * InjectDelete: |
| 364 | * Ensures that calls to inject and/or delete information state are handled. |
Wyatt Riley | c139959 | 2017-03-22 14:08:26 -0700 | [diff] [blame] | 365 | */ |
| 366 | TEST_F(GnssHalTest, InjectDelete) { |
| 367 | // confidently, well north of Alaska |
| 368 | auto result = gnss_hal_->injectLocation(80.0, -170.0, 1000.0); |
| 369 | |
Wyatt Riley | c139959 | 2017-03-22 14:08:26 -0700 | [diff] [blame] | 370 | ASSERT_TRUE(result.isOk()); |
| 371 | EXPECT_TRUE(result); |
| 372 | |
| 373 | // fake time, but generally reasonable values (time in Aug. 2018) |
| 374 | result = gnss_hal_->injectTime(1534567890123L, 123456L, 10000L); |
| 375 | |
| 376 | ASSERT_TRUE(result.isOk()); |
| 377 | EXPECT_TRUE(result); |
| 378 | |
| 379 | auto resultVoid = gnss_hal_->deleteAidingData(IGnss::GnssAidingData::DELETE_ALL); |
| 380 | |
| 381 | ASSERT_TRUE(resultVoid.isOk()); |
Wyatt Riley | 0ee0cfb | 2017-04-04 12:34:53 -0700 | [diff] [blame] | 382 | |
| 383 | // Ensure we can get a good location after a bad injection has been deleted |
Wyatt Riley | 94c7a04 | 2017-06-15 17:16:24 -0700 | [diff] [blame^] | 384 | StartAndGetSingleLocation(false); |
| 385 | |
| 386 | StopAndClearLocations(); |
Wyatt Riley | c139959 | 2017-03-22 14:08:26 -0700 | [diff] [blame] | 387 | } |
| 388 | |
| 389 | /* |
| 390 | * GetAllExtentions: |
| 391 | * Tries getting all optional extensions, and ensures a valid return |
| 392 | * null or actual extension, no crash. |
| 393 | * Confirms year-based required extensions (Measurement & Debug) are present |
| 394 | */ |
| 395 | TEST_F(GnssHalTest, GetAllExtensions) { |
| 396 | // Basic call-is-handled checks |
| 397 | auto gnssXtra = gnss_hal_->getExtensionXtra(); |
| 398 | ASSERT_TRUE(gnssXtra.isOk()); |
| 399 | |
| 400 | auto gnssRil = gnss_hal_->getExtensionAGnssRil(); |
| 401 | ASSERT_TRUE(gnssRil.isOk()); |
| 402 | |
| 403 | auto gnssAgnss = gnss_hal_->getExtensionAGnss(); |
| 404 | ASSERT_TRUE(gnssAgnss.isOk()); |
| 405 | |
| 406 | auto gnssNi = gnss_hal_->getExtensionGnssNi(); |
| 407 | ASSERT_TRUE(gnssNi.isOk()); |
| 408 | |
| 409 | auto gnssNavigationMessage = gnss_hal_->getExtensionGnssNavigationMessage(); |
| 410 | ASSERT_TRUE(gnssNavigationMessage.isOk()); |
| 411 | |
| 412 | auto gnssConfiguration = gnss_hal_->getExtensionGnssConfiguration(); |
| 413 | ASSERT_TRUE(gnssConfiguration.isOk()); |
| 414 | |
| 415 | auto gnssGeofencing = gnss_hal_->getExtensionGnssGeofencing(); |
| 416 | ASSERT_TRUE(gnssGeofencing.isOk()); |
| 417 | |
| 418 | auto gnssBatching = gnss_hal_->getExtensionGnssBatching(); |
| 419 | ASSERT_TRUE(gnssBatching.isOk()); |
| 420 | |
| 421 | // Verifying, in some cases, that these return actual extensions |
| 422 | auto gnssMeasurement = gnss_hal_->getExtensionGnssMeasurement(); |
| 423 | ASSERT_TRUE(gnssMeasurement.isOk()); |
| 424 | if (last_capabilities_ & IGnssCallback::Capabilities::MEASUREMENTS) { |
| 425 | sp<IGnssMeasurement> iGnssMeas = gnssMeasurement; |
| 426 | EXPECT_NE(iGnssMeas, nullptr); |
| 427 | } |
| 428 | |
| 429 | auto gnssDebug = gnss_hal_->getExtensionGnssDebug(); |
| 430 | ASSERT_TRUE(gnssDebug.isOk()); |
| 431 | if (info_called_count_ > 0 && last_info_.yearOfHw >= 2017) { |
| 432 | sp<IGnssDebug> iGnssDebug = gnssDebug; |
| 433 | EXPECT_NE(iGnssDebug, nullptr); |
| 434 | } |
| 435 | } |
| 436 | |
| 437 | /* |
| 438 | * MeasurementCapabilities: |
| 439 | * Verifies that modern hardware supports measurement capabilities. |
| 440 | */ |
| 441 | TEST_F(GnssHalTest, MeasurementCapabilites) { |
| 442 | if (info_called_count_ > 0 && last_info_.yearOfHw >= 2016) { |
| 443 | EXPECT_TRUE(last_capabilities_ & IGnssCallback::Capabilities::MEASUREMENTS); |
| 444 | } |
| 445 | } |
| 446 | |
Wyatt Riley | 6c26ed7 | 2017-02-21 17:21:53 -0800 | [diff] [blame] | 447 | int main(int argc, char** argv) { |
| 448 | ::testing::InitGoogleTest(&argc, argv); |
Wyatt Riley | 0ee0cfb | 2017-04-04 12:34:53 -0700 | [diff] [blame] | 449 | /* |
| 450 | * These arguments not used by automated VTS testing. |
| 451 | * Only for use in manual testing, when wanting to run |
| 452 | * stronger tests that require the presence of GPS signal. |
| 453 | */ |
| 454 | for (int i = 1; i < argc; i++) { |
Wyatt Riley | 94c7a04 | 2017-06-15 17:16:24 -0700 | [diff] [blame^] | 455 | if (strcmp(argv[i], "-agps") == 0) { |
| 456 | sAgpsIsPresent = true; |
| 457 | } else if (strcmp(argv[i], "-weak") == 0) { |
| 458 | sSignalIsWeak = true; |
Wyatt Riley | 0ee0cfb | 2017-04-04 12:34:53 -0700 | [diff] [blame] | 459 | } |
| 460 | } |
Wyatt Riley | 6c26ed7 | 2017-02-21 17:21:53 -0800 | [diff] [blame] | 461 | int status = RUN_ALL_TESTS(); |
| 462 | ALOGI("Test result = %d", status); |
| 463 | return status; |
Wyatt Riley | 94c7a04 | 2017-06-15 17:16:24 -0700 | [diff] [blame^] | 464 | } |