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> |
| 19 | #include <android/log.h> |
| 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 | 917640b | 2017-03-16 16:25:55 -0700 | [diff] [blame] | 38 | #define TIMEOUT_SEC 3 // for basic commands/responses |
Wyatt Riley | 6c26ed7 | 2017-02-21 17:21:53 -0800 | [diff] [blame] | 39 | |
Wyatt Riley | c139959 | 2017-03-22 14:08:26 -0700 | [diff] [blame^] | 40 | // Set these false for release, true for stronger test |
| 41 | #define GNSS_SIGNAL_IS_PRESENT false |
| 42 | #define GNSS_ASSISTANCE_IS_PRESENT false |
| 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 | |
| 119 | /* Callback class for data & Event. */ |
| 120 | class GnssCallback : public IGnssCallback { |
Wyatt Riley | 917640b | 2017-03-16 16:25:55 -0700 | [diff] [blame] | 121 | public: |
Wyatt Riley | 6c26ed7 | 2017-02-21 17:21:53 -0800 | [diff] [blame] | 122 | GnssHalTest& parent_; |
| 123 | |
Wyatt Riley | 6c26ed7 | 2017-02-21 17:21:53 -0800 | [diff] [blame] | 124 | GnssCallback(GnssHalTest& parent) : parent_(parent){}; |
| 125 | |
| 126 | virtual ~GnssCallback() = default; |
| 127 | |
| 128 | // Dummy callback handlers |
| 129 | Return<void> gnssStatusCb( |
Steven Moreland | 4b52395 | 2017-03-08 19:20:30 -0800 | [diff] [blame] | 130 | const IGnssCallback::GnssStatusValue /* status */) override { |
Wyatt Riley | 6c26ed7 | 2017-02-21 17:21:53 -0800 | [diff] [blame] | 131 | return Void(); |
| 132 | } |
| 133 | Return<void> gnssSvStatusCb( |
Steven Moreland | 4b52395 | 2017-03-08 19:20:30 -0800 | [diff] [blame] | 134 | const IGnssCallback::GnssSvStatus& /* svStatus */) override { |
Wyatt Riley | 6c26ed7 | 2017-02-21 17:21:53 -0800 | [diff] [blame] | 135 | return Void(); |
| 136 | } |
| 137 | Return<void> gnssNmeaCb( |
Steven Moreland | 4b52395 | 2017-03-08 19:20:30 -0800 | [diff] [blame] | 138 | int64_t /* timestamp */, |
| 139 | const android::hardware::hidl_string& /* nmea */) override { |
Wyatt Riley | 6c26ed7 | 2017-02-21 17:21:53 -0800 | [diff] [blame] | 140 | return Void(); |
| 141 | } |
| 142 | Return<void> gnssAcquireWakelockCb() override { return Void(); } |
| 143 | Return<void> gnssReleaseWakelockCb() override { return Void(); } |
| 144 | Return<void> gnssRequestTimeCb() override { return Void(); } |
| 145 | |
| 146 | // Actual (test) callback handlers |
| 147 | Return<void> gnssLocationCb(const GnssLocation& location) override { |
| 148 | ALOGI("Location received"); |
| 149 | parent_.location_called_count_++; |
| 150 | parent_.last_location_ = location; |
| 151 | parent_.notify(); |
| 152 | return Void(); |
| 153 | } |
| 154 | |
| 155 | Return<void> gnssSetCapabilitesCb(uint32_t capabilities) override { |
| 156 | ALOGI("Capabilities received %d", capabilities); |
| 157 | parent_.capabilities_called_count_++; |
| 158 | parent_.last_capabilities_ = capabilities; |
| 159 | parent_.notify(); |
| 160 | return Void(); |
| 161 | } |
| 162 | |
| 163 | Return<void> gnssSetSystemInfoCb( |
| 164 | const IGnssCallback::GnssSystemInfo& info) override { |
| 165 | ALOGI("Info received, year %d", info.yearOfHw); |
| 166 | parent_.info_called_count_++; |
| 167 | parent_.last_info_ = info; |
| 168 | parent_.notify(); |
| 169 | return Void(); |
| 170 | } |
| 171 | }; |
| 172 | |
| 173 | sp<IGnss> gnss_hal_; // GNSS HAL to call into |
| 174 | sp<IGnssCallback> gnss_cb_; // Primary callback interface |
| 175 | |
| 176 | /* Count of calls to set the following items, and the latest item (used by |
| 177 | * test.) |
| 178 | */ |
| 179 | int capabilities_called_count_; |
| 180 | uint32_t last_capabilities_; |
| 181 | |
| 182 | int location_called_count_; |
| 183 | GnssLocation last_location_; |
| 184 | |
| 185 | int info_called_count_; |
| 186 | IGnssCallback::GnssSystemInfo last_info_; |
| 187 | |
| 188 | private: |
| 189 | std::mutex mtx_; |
| 190 | std::condition_variable cv_; |
| 191 | int count; |
| 192 | }; |
| 193 | |
| 194 | /* |
| 195 | * SetCallbackCapabilitiesCleanup: |
| 196 | * Sets up the callback, awaits the capabilities, and calls cleanup |
| 197 | * |
| 198 | * Since this is just the basic operation of SetUp() and TearDown(), |
Wyatt Riley | 917640b | 2017-03-16 16:25:55 -0700 | [diff] [blame] | 199 | * the function definition is intentionally empty |
Wyatt Riley | 6c26ed7 | 2017-02-21 17:21:53 -0800 | [diff] [blame] | 200 | */ |
| 201 | TEST_F(GnssHalTest, SetCallbackCapabilitiesCleanup) {} |
| 202 | |
Wyatt Riley | 917640b | 2017-03-16 16:25:55 -0700 | [diff] [blame] | 203 | /* |
| 204 | * CheckLocation: |
| 205 | * Helper function to vet Location fields |
| 206 | */ |
| 207 | |
| 208 | void CheckLocation(GnssLocation& location, bool checkAccuracies) { |
Wyatt Riley | 6c26ed7 | 2017-02-21 17:21:53 -0800 | [diff] [blame] | 209 | EXPECT_TRUE(location.gnssLocationFlags & GnssLocationFlags::HAS_LAT_LONG); |
| 210 | EXPECT_TRUE(location.gnssLocationFlags & GnssLocationFlags::HAS_ALTITUDE); |
| 211 | EXPECT_TRUE(location.gnssLocationFlags & GnssLocationFlags::HAS_SPEED); |
| 212 | EXPECT_TRUE(location.gnssLocationFlags & |
| 213 | GnssLocationFlags::HAS_HORIZONTAL_ACCURACY); |
Wyatt Riley | 917640b | 2017-03-16 16:25:55 -0700 | [diff] [blame] | 214 | // New uncertainties available in O must be provided, |
| 215 | // at least when paired with modern hardware (2017+) |
| 216 | if (checkAccuracies) { |
| 217 | EXPECT_TRUE(location.gnssLocationFlags & |
| 218 | GnssLocationFlags::HAS_VERTICAL_ACCURACY); |
| 219 | EXPECT_TRUE(location.gnssLocationFlags & |
| 220 | GnssLocationFlags::HAS_SPEED_ACCURACY); |
| 221 | if (location.gnssLocationFlags & GnssLocationFlags::HAS_BEARING) { |
| 222 | EXPECT_TRUE(location.gnssLocationFlags & |
| 223 | GnssLocationFlags::HAS_BEARING_ACCURACY); |
| 224 | } |
| 225 | } |
Wyatt Riley | 6c26ed7 | 2017-02-21 17:21:53 -0800 | [diff] [blame] | 226 | EXPECT_GE(location.latitudeDegrees, -90.0); |
| 227 | EXPECT_LE(location.latitudeDegrees, 90.0); |
| 228 | EXPECT_GE(location.longitudeDegrees, -180.0); |
| 229 | EXPECT_LE(location.longitudeDegrees, 180.0); |
| 230 | EXPECT_GE(location.altitudeMeters, -1000.0); |
| 231 | EXPECT_LE(location.altitudeMeters, 30000.0); |
| 232 | EXPECT_GE(location.speedMetersPerSec, 0.0); |
| 233 | EXPECT_LE(location.speedMetersPerSec, 5.0); // VTS tests are stationary. |
| 234 | |
Wyatt Riley | 917640b | 2017-03-16 16:25:55 -0700 | [diff] [blame] | 235 | // Non-zero speeds must be reported with an associated bearing |
| 236 | if (location.speedMetersPerSec > 0.0) { |
| 237 | EXPECT_TRUE(location.gnssLocationFlags & GnssLocationFlags::HAS_BEARING); |
| 238 | } |
| 239 | |
Wyatt Riley | 6c26ed7 | 2017-02-21 17:21:53 -0800 | [diff] [blame] | 240 | /* |
| 241 | * Tolerating some especially high values for accuracy estimate, in case of |
Wyatt Riley | 917640b | 2017-03-16 16:25:55 -0700 | [diff] [blame] | 242 | * first fix with especially poor geometry (happens occasionally) |
Wyatt Riley | 6c26ed7 | 2017-02-21 17:21:53 -0800 | [diff] [blame] | 243 | */ |
| 244 | EXPECT_GT(location.horizontalAccuracyMeters, 0.0); |
Wyatt Riley | 917640b | 2017-03-16 16:25:55 -0700 | [diff] [blame] | 245 | EXPECT_LE(location.horizontalAccuracyMeters, 250.0); |
Wyatt Riley | 6c26ed7 | 2017-02-21 17:21:53 -0800 | [diff] [blame] | 246 | |
| 247 | /* |
| 248 | * Some devices may define bearing as -180 to +180, others as 0 to 360. |
| 249 | * Both are okay & understandable. |
| 250 | */ |
| 251 | if (location.gnssLocationFlags & GnssLocationFlags::HAS_BEARING) { |
| 252 | EXPECT_GE(location.bearingDegrees, -180.0); |
| 253 | EXPECT_LE(location.bearingDegrees, 360.0); |
| 254 | } |
| 255 | if (location.gnssLocationFlags & GnssLocationFlags::HAS_VERTICAL_ACCURACY) { |
| 256 | EXPECT_GT(location.verticalAccuracyMeters, 0.0); |
| 257 | EXPECT_LE(location.verticalAccuracyMeters, 500.0); |
| 258 | } |
| 259 | if (location.gnssLocationFlags & GnssLocationFlags::HAS_SPEED_ACCURACY) { |
| 260 | EXPECT_GT(location.speedAccuracyMetersPerSecond, 0.0); |
| 261 | EXPECT_LE(location.speedAccuracyMetersPerSecond, 50.0); |
| 262 | } |
| 263 | if (location.gnssLocationFlags & GnssLocationFlags::HAS_BEARING_ACCURACY) { |
| 264 | EXPECT_GT(location.bearingAccuracyDegrees, 0.0); |
| 265 | EXPECT_LE(location.bearingAccuracyDegrees, 360.0); |
| 266 | } |
| 267 | |
| 268 | // Check timestamp > 1.48e12 (47 years in msec - 1970->2017+) |
| 269 | EXPECT_GT(location.timestamp, 1.48e12); |
Wyatt Riley | 6c26ed7 | 2017-02-21 17:21:53 -0800 | [diff] [blame] | 270 | } |
| 271 | |
| 272 | /* |
| 273 | * GetLocation: |
| 274 | * Turns on location, waits 45 second for at least 5 locations, |
| 275 | * and checks them for reasonable validity. |
| 276 | */ |
| 277 | TEST_F(GnssHalTest, GetLocation) { |
| 278 | #define MIN_INTERVAL_MSEC 500 |
| 279 | #define PREFERRED_ACCURACY 0 // Ideally perfect (matches GnssLocationProvider) |
| 280 | #define PREFERRED_TIME_MSEC 0 // Ideally immediate |
| 281 | |
Wyatt Riley | c139959 | 2017-03-22 14:08:26 -0700 | [diff] [blame^] | 282 | #if GNSS_ASSISTANCE_IS_PRESENT |
| 283 | #define LOCATION_TIMEOUT_FIRST_SEC 15 |
| 284 | #else |
Wyatt Riley | 6c26ed7 | 2017-02-21 17:21:53 -0800 | [diff] [blame] | 285 | #define LOCATION_TIMEOUT_FIRST_SEC 45 |
Wyatt Riley | c139959 | 2017-03-22 14:08:26 -0700 | [diff] [blame^] | 286 | #endif |
| 287 | |
Wyatt Riley | 6c26ed7 | 2017-02-21 17:21:53 -0800 | [diff] [blame] | 288 | #define LOCATION_TIMEOUT_SUBSEQUENT_SEC 3 |
| 289 | #define LOCATIONS_TO_CHECK 5 |
| 290 | |
Wyatt Riley | 917640b | 2017-03-16 16:25:55 -0700 | [diff] [blame] | 291 | bool checkMoreAccuracies = |
| 292 | (info_called_count_ > 0 && last_info_.yearOfHw >= 2017); |
| 293 | |
Wyatt Riley | 6c26ed7 | 2017-02-21 17:21:53 -0800 | [diff] [blame] | 294 | auto result = gnss_hal_->setPositionMode( |
| 295 | IGnss::GnssPositionMode::MS_BASED, |
| 296 | IGnss::GnssPositionRecurrence::RECURRENCE_PERIODIC, MIN_INTERVAL_MSEC, |
| 297 | PREFERRED_ACCURACY, PREFERRED_TIME_MSEC); |
| 298 | |
| 299 | ASSERT_TRUE(result.isOk()); |
Wyatt Riley | c139959 | 2017-03-22 14:08:26 -0700 | [diff] [blame^] | 300 | EXPECT_TRUE(result); |
Wyatt Riley | 6c26ed7 | 2017-02-21 17:21:53 -0800 | [diff] [blame] | 301 | |
| 302 | result = gnss_hal_->start(); |
| 303 | |
| 304 | ASSERT_TRUE(result.isOk()); |
Wyatt Riley | c139959 | 2017-03-22 14:08:26 -0700 | [diff] [blame^] | 305 | EXPECT_TRUE(result); |
Wyatt Riley | 6c26ed7 | 2017-02-21 17:21:53 -0800 | [diff] [blame] | 306 | |
Wyatt Riley | c139959 | 2017-03-22 14:08:26 -0700 | [diff] [blame^] | 307 | /* |
| 308 | * GPS signals initially optional for this test, so don't expect no timeout |
| 309 | * yet |
| 310 | */ |
Wyatt Riley | 917640b | 2017-03-16 16:25:55 -0700 | [diff] [blame] | 311 | wait(LOCATION_TIMEOUT_FIRST_SEC); |
Wyatt Riley | c139959 | 2017-03-22 14:08:26 -0700 | [diff] [blame^] | 312 | if (GNSS_SIGNAL_IS_PRESENT) { |
| 313 | ASSERT_GT(location_called_count_, 0); |
| 314 | } |
Wyatt Riley | 917640b | 2017-03-16 16:25:55 -0700 | [diff] [blame] | 315 | if (location_called_count_ > 0) { |
| 316 | CheckLocation(last_location_, checkMoreAccuracies); |
| 317 | } |
Wyatt Riley | 6c26ed7 | 2017-02-21 17:21:53 -0800 | [diff] [blame] | 318 | |
| 319 | for (int i = 1; i < LOCATIONS_TO_CHECK; i++) { |
Wyatt Riley | 917640b | 2017-03-16 16:25:55 -0700 | [diff] [blame] | 320 | wait(LOCATION_TIMEOUT_SUBSEQUENT_SEC); |
| 321 | if (location_called_count_ > 0) { |
| 322 | CheckLocation(last_location_, checkMoreAccuracies); |
| 323 | } |
Wyatt Riley | 6c26ed7 | 2017-02-21 17:21:53 -0800 | [diff] [blame] | 324 | } |
| 325 | |
| 326 | result = gnss_hal_->stop(); |
| 327 | |
| 328 | ASSERT_TRUE(result.isOk()); |
| 329 | ASSERT_TRUE(result); |
| 330 | } |
| 331 | |
Wyatt Riley | c139959 | 2017-03-22 14:08:26 -0700 | [diff] [blame^] | 332 | /* |
| 333 | * InjectDelete: |
| 334 | * Ensures that calls to inject and/or delete information state are handled. |
| 335 | * Better tests await GPS signal |
| 336 | */ |
| 337 | TEST_F(GnssHalTest, InjectDelete) { |
| 338 | // confidently, well north of Alaska |
| 339 | auto result = gnss_hal_->injectLocation(80.0, -170.0, 1000.0); |
| 340 | |
| 341 | // TODO: full self-diff including TODO's :) |
| 342 | ASSERT_TRUE(result.isOk()); |
| 343 | EXPECT_TRUE(result); |
| 344 | |
| 345 | // fake time, but generally reasonable values (time in Aug. 2018) |
| 346 | result = gnss_hal_->injectTime(1534567890123L, 123456L, 10000L); |
| 347 | |
| 348 | ASSERT_TRUE(result.isOk()); |
| 349 | EXPECT_TRUE(result); |
| 350 | |
| 351 | auto resultVoid = gnss_hal_->deleteAidingData(IGnss::GnssAidingData::DELETE_ALL); |
| 352 | |
| 353 | ASSERT_TRUE(resultVoid.isOk()); |
| 354 | } |
| 355 | |
| 356 | /* |
| 357 | * GetAllExtentions: |
| 358 | * Tries getting all optional extensions, and ensures a valid return |
| 359 | * null or actual extension, no crash. |
| 360 | * Confirms year-based required extensions (Measurement & Debug) are present |
| 361 | */ |
| 362 | TEST_F(GnssHalTest, GetAllExtensions) { |
| 363 | // Basic call-is-handled checks |
| 364 | auto gnssXtra = gnss_hal_->getExtensionXtra(); |
| 365 | ASSERT_TRUE(gnssXtra.isOk()); |
| 366 | |
| 367 | auto gnssRil = gnss_hal_->getExtensionAGnssRil(); |
| 368 | ASSERT_TRUE(gnssRil.isOk()); |
| 369 | |
| 370 | auto gnssAgnss = gnss_hal_->getExtensionAGnss(); |
| 371 | ASSERT_TRUE(gnssAgnss.isOk()); |
| 372 | |
| 373 | auto gnssNi = gnss_hal_->getExtensionGnssNi(); |
| 374 | ASSERT_TRUE(gnssNi.isOk()); |
| 375 | |
| 376 | auto gnssNavigationMessage = gnss_hal_->getExtensionGnssNavigationMessage(); |
| 377 | ASSERT_TRUE(gnssNavigationMessage.isOk()); |
| 378 | |
| 379 | auto gnssConfiguration = gnss_hal_->getExtensionGnssConfiguration(); |
| 380 | ASSERT_TRUE(gnssConfiguration.isOk()); |
| 381 | |
| 382 | auto gnssGeofencing = gnss_hal_->getExtensionGnssGeofencing(); |
| 383 | ASSERT_TRUE(gnssGeofencing.isOk()); |
| 384 | |
| 385 | auto gnssBatching = gnss_hal_->getExtensionGnssBatching(); |
| 386 | ASSERT_TRUE(gnssBatching.isOk()); |
| 387 | |
| 388 | // Verifying, in some cases, that these return actual extensions |
| 389 | auto gnssMeasurement = gnss_hal_->getExtensionGnssMeasurement(); |
| 390 | ASSERT_TRUE(gnssMeasurement.isOk()); |
| 391 | if (last_capabilities_ & IGnssCallback::Capabilities::MEASUREMENTS) { |
| 392 | sp<IGnssMeasurement> iGnssMeas = gnssMeasurement; |
| 393 | EXPECT_NE(iGnssMeas, nullptr); |
| 394 | } |
| 395 | |
| 396 | auto gnssDebug = gnss_hal_->getExtensionGnssDebug(); |
| 397 | ASSERT_TRUE(gnssDebug.isOk()); |
| 398 | if (info_called_count_ > 0 && last_info_.yearOfHw >= 2017) { |
| 399 | sp<IGnssDebug> iGnssDebug = gnssDebug; |
| 400 | EXPECT_NE(iGnssDebug, nullptr); |
| 401 | } |
| 402 | } |
| 403 | |
| 404 | /* |
| 405 | * MeasurementCapabilities: |
| 406 | * Verifies that modern hardware supports measurement capabilities. |
| 407 | */ |
| 408 | TEST_F(GnssHalTest, MeasurementCapabilites) { |
| 409 | if (info_called_count_ > 0 && last_info_.yearOfHw >= 2016) { |
| 410 | EXPECT_TRUE(last_capabilities_ & IGnssCallback::Capabilities::MEASUREMENTS); |
| 411 | } |
| 412 | } |
| 413 | |
Wyatt Riley | 6c26ed7 | 2017-02-21 17:21:53 -0800 | [diff] [blame] | 414 | int main(int argc, char** argv) { |
| 415 | ::testing::InitGoogleTest(&argc, argv); |
| 416 | int status = RUN_ALL_TESTS(); |
| 417 | ALOGI("Test result = %d", status); |
| 418 | return status; |
Wyatt Riley | 917640b | 2017-03-16 16:25:55 -0700 | [diff] [blame] | 419 | } |