1 /*
2 * Copyright (C) 2016, 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 #include <functional>
18 #include <memory>
19 #include <string>
20 #include <vector>
21
22 #include <android/hardware/wifi/offload/1.0/IOffload.h>
23 #include <gtest/gtest.h>
24
25 #include "wificond/tests/mock_offload.h"
26 #include "wificond/tests/mock_offload_scan_callback_interface.h"
27 #include "wificond/tests/mock_offload_service_utils.h"
28 #include "wificond/tests/offload_hal_test_constants.h"
29 #include "wificond/tests/offload_test_utils.h"
30
31 #include "wificond/scanning/offload/offload_callback.h"
32 #include "wificond/scanning/offload/offload_callback_handlers.h"
33 #include "wificond/scanning/offload/offload_scan_manager.h"
34 #include "wificond/scanning/scan_result.h"
35
36 using android::hardware::Return;
37 using android::hardware::Void;
38 using android::hardware::wifi::offload::V1_0::IOffload;
39 using android::hardware::wifi::offload::V1_0::ScanResult;
40 using android::hardware::wifi::offload::V1_0::OffloadStatus;
41 using android::hardware::wifi::offload::V1_0::OffloadStatusCode;
42 using android::hardware::wifi::offload::V1_0::ScanParam;
43 using android::hardware::wifi::offload::V1_0::ScanFilter;
44 using android::hardware::wifi::offload::V1_0::ScanStats;
45 using android::sp;
46 using com::android::server::wifi::wificond::NativeScanResult;
47 using com::android::server::wifi::wificond::NativeScanStats;
48 using testing::NiceMock;
49 using testing::_;
50 using testing::Invoke;
51 using std::shared_ptr;
52 using std::unique_ptr;
53 using std::vector;
54 using std::bind;
55
56 using namespace std::placeholders;
57 using namespace android::wificond::offload_hal_test_constants;
58
59 namespace android {
60 namespace wificond {
61
CaptureCallback(OffloadCallbackHandlers * handler,sp<OffloadCallback> * offload_callback)62 sp<OffloadCallback> CaptureCallback(OffloadCallbackHandlers* handler,
63 sp<OffloadCallback>* offload_callback) {
64 *offload_callback = sp<OffloadCallback>(new OffloadCallback(handler));
65 return *offload_callback;
66 }
67
CaptureDeathRecipient(OffloadDeathRecipientHandler handler,sp<OffloadDeathRecipient> * death_recipient_)68 OffloadDeathRecipient* CaptureDeathRecipient(
69 OffloadDeathRecipientHandler handler,
70 sp<OffloadDeathRecipient>* death_recipient_) {
71 OffloadDeathRecipient* death_recipient = new OffloadDeathRecipient(handler);
72 *death_recipient_ = sp<OffloadDeathRecipient>(death_recipient);
73 return death_recipient;
74 }
75
HidlStatusReturn(android::wificond::StatusCallback cb,OffloadStatus * status)76 Return<void> HidlStatusReturn(android::wificond::StatusCallback cb,
77 OffloadStatus* status) {
78 cb(*status);
79 return Void();
80 }
81
ScanStatusReturn(android::wificond::OnScanStatsCallback cb,OffloadStatus * status)82 Return<void> ScanStatusReturn(android::wificond::OnScanStatsCallback cb,
83 OffloadStatus* status) {
84 ScanStats stats;
85 cb(*status, stats);
86 return Void();
87 }
88
89 class OffloadScanManagerTest : public ::testing::Test {
90 protected:
SetUp()91 virtual void SetUp() {
92 ON_CALL(*mock_offload_service_utils_, GetOffloadCallback(_))
93 .WillByDefault(Invoke(bind(CaptureCallback, _1, &offload_callback_)));
94 ON_CALL(*mock_offload_service_utils_, GetOffloadDeathRecipient(_))
95 .WillByDefault(
96 Invoke(bind(CaptureDeathRecipient, _1, &death_recipient_)));
97 status = OffloadTestUtils::createOffloadStatus(OffloadStatusCode::OK);
98 ON_CALL(*mock_offload_, configureScans(_, _, _))
99 .WillByDefault(Invoke(bind(HidlStatusReturn, _3, &status)));
100 ON_CALL(*mock_offload_, subscribeScanResults(_, _))
101 .WillByDefault(Invoke(bind(HidlStatusReturn, _2, &status)));
102 ON_CALL(*mock_offload_, getScanStats(_))
103 .WillByDefault(Invoke(bind(ScanStatusReturn, _1, &status)));
104 }
105
TearDown()106 void TearDown() override {
107 offload_callback_.clear();
108 death_recipient_.clear();
109 }
110
111 sp<NiceMock<MockOffload>> mock_offload_{new NiceMock<MockOffload>()};
112 sp<OffloadCallback> offload_callback_;
113 sp<OffloadDeathRecipient> death_recipient_;
114 shared_ptr<NiceMock<MockOffloadServiceUtils>> mock_offload_service_utils_{
115 new NiceMock<MockOffloadServiceUtils>()};
116 shared_ptr<NiceMock<MockOffloadScanCallbackInterface>>
117 mock_offload_scan_callback_interface_{
118 new NiceMock<MockOffloadScanCallbackInterface>()};
119 unique_ptr<OffloadScanManager> offload_scan_manager_;
120 OffloadStatus status;
121 vector<vector<uint8_t>> scan_ssids{kSsid1, kSsid2};
122 vector<vector<uint8_t>> match_ssids{kSsid1, kSsid2};
123 vector<uint8_t> security_flags{kNetworkFlags, kNetworkFlags};
124 vector<uint32_t> frequencies{kFrequency1, kFrequency2};
125 uint64_t cookie_ = reinterpret_cast<uint64_t>(mock_offload_.get());
126 };
127
128 /**
129 * Testing OffloadScanManager for binder death with registered cookie
130 */
TEST_F(OffloadScanManagerTest,BinderDeathRegisteredCookieAndService)131 TEST_F(OffloadScanManagerTest, BinderDeathRegisteredCookieAndService) {
132 EXPECT_CALL(*mock_offload_service_utils_, GetOffloadService());
133 EXPECT_CALL(*mock_offload_service_utils_, GetOffloadCallback(_));
134 EXPECT_CALL(*mock_offload_service_utils_, GetOffloadDeathRecipient(_));
135 ON_CALL(*mock_offload_service_utils_, GetOffloadService())
136 .WillByDefault(testing::Return(mock_offload_));
137 offload_scan_manager_.reset(new OffloadScanManager(
138 mock_offload_service_utils_, mock_offload_scan_callback_interface_));
139 EXPECT_CALL(*mock_offload_scan_callback_interface_, OnOffloadError(_));
140 death_recipient_->serviceDied(cookie_, mock_offload_);
141 EXPECT_EQ(OffloadScanManager::kNoService,
142 offload_scan_manager_->getOffloadStatus());
143 }
144
145 /**
146 * Testing OffloadScanManager for binder death with invalid cookie
147 */
TEST_F(OffloadScanManagerTest,BinderDeathUnregisteredCookie)148 TEST_F(OffloadScanManagerTest, BinderDeathUnregisteredCookie) {
149 EXPECT_CALL(*mock_offload_service_utils_, GetOffloadService());
150 EXPECT_CALL(*mock_offload_service_utils_, GetOffloadDeathRecipient(_));
151 ON_CALL(*mock_offload_service_utils_, GetOffloadService())
152 .WillByDefault(testing::Return(mock_offload_));
153 offload_scan_manager_.reset(new OffloadScanManager(
154 mock_offload_service_utils_, mock_offload_scan_callback_interface_));
155 death_recipient_->serviceDied(kDeathCode, mock_offload_);
156 EXPECT_FALSE(OffloadScanManager::kNoService ==
157 offload_scan_manager_->getOffloadStatus());
158 }
159
160 /**
161 * Testing OffloadScanManager with no handle on Offloal HAL service
162 * and no registered handler for Offload Scan results
163 */
TEST_F(OffloadScanManagerTest,ServiceNotAvailableTest)164 TEST_F(OffloadScanManagerTest, ServiceNotAvailableTest) {
165 EXPECT_CALL(*mock_offload_service_utils_, GetOffloadService());
166 ON_CALL(*mock_offload_service_utils_, GetOffloadService())
167 .WillByDefault(testing::Return(nullptr));
168 offload_scan_manager_.reset(new OffloadScanManager(
169 mock_offload_service_utils_, mock_offload_scan_callback_interface_));
170 EXPECT_EQ(OffloadScanManager::kNoService,
171 offload_scan_manager_->getOffloadStatus());
172 }
173
174 /**
175 * Testing OffloadScanManager when service is available and valid handler
176 * registered for Offload Scan results
177 */
TEST_F(OffloadScanManagerTest,ServiceAvailableTest)178 TEST_F(OffloadScanManagerTest, ServiceAvailableTest) {
179 EXPECT_CALL(*mock_offload_service_utils_, GetOffloadService());
180 EXPECT_CALL(*mock_offload_service_utils_, GetOffloadCallback(_));
181 EXPECT_CALL(*mock_offload_service_utils_, GetOffloadDeathRecipient(_));
182 ON_CALL(*mock_offload_service_utils_, GetOffloadService())
183 .WillByDefault(testing::Return(mock_offload_));
184 offload_scan_manager_.reset(new OffloadScanManager(
185 mock_offload_service_utils_, mock_offload_scan_callback_interface_));
186 EXPECT_EQ(OffloadScanManager::kNoError,
187 offload_scan_manager_->getOffloadStatus());
188 }
189
190 /**
191 * Testing OffloadScanManager when service is available and valid handler
192 * is registered, test to ensure that registered handler is invoked when
193 * scan results are available
194 */
TEST_F(OffloadScanManagerTest,CallbackInvokedTest)195 TEST_F(OffloadScanManagerTest, CallbackInvokedTest) {
196 EXPECT_CALL(*mock_offload_service_utils_, GetOffloadService());
197 EXPECT_CALL(*mock_offload_service_utils_, GetOffloadCallback(_));
198 EXPECT_CALL(*mock_offload_service_utils_, GetOffloadDeathRecipient(_));
199 ON_CALL(*mock_offload_service_utils_, GetOffloadService())
200 .WillByDefault(testing::Return(mock_offload_));
201 EXPECT_CALL(*mock_offload_scan_callback_interface_, OnOffloadScanResult());
202 offload_scan_manager_.reset(new OffloadScanManager(
203 mock_offload_service_utils_, mock_offload_scan_callback_interface_));
204 vector<ScanResult> dummy_scan_results_ =
205 OffloadTestUtils::createOffloadScanResults();
206 offload_callback_->onScanResult(dummy_scan_results_);
207 }
208
209 /**
210 * Testing OffloadScanManager when service is available and valid handler
211 * is registered, ensure that error callback is invoked
212 */
TEST_F(OffloadScanManagerTest,ErrorCallbackInvokedTest)213 TEST_F(OffloadScanManagerTest, ErrorCallbackInvokedTest) {
214 EXPECT_CALL(*mock_offload_service_utils_, GetOffloadService());
215 EXPECT_CALL(*mock_offload_service_utils_, GetOffloadCallback(_));
216 EXPECT_CALL(*mock_offload_service_utils_, GetOffloadDeathRecipient(_));
217 ON_CALL(*mock_offload_service_utils_, GetOffloadService())
218 .WillByDefault(testing::Return(mock_offload_));
219 offload_scan_manager_.reset(new OffloadScanManager(
220 mock_offload_service_utils_, mock_offload_scan_callback_interface_));
221 OffloadStatus status =
222 OffloadTestUtils::createOffloadStatus(OffloadStatusCode::ERROR);
223 EXPECT_CALL(*mock_offload_scan_callback_interface_, OnOffloadError(_));
224 offload_callback_->onError(status);
225 EXPECT_EQ(offload_scan_manager_->getOffloadStatus(),
226 OffloadScanManager::kError);
227 }
228
229 /**
230 * Testing OffloadScanManager for subscribing to the scan results from
231 * Offload HAL when service is running without errors
232 */
TEST_F(OffloadScanManagerTest,StartScanTestWhenServiceIsOk)233 TEST_F(OffloadScanManagerTest, StartScanTestWhenServiceIsOk) {
234 EXPECT_CALL(*mock_offload_service_utils_, GetOffloadService());
235 EXPECT_CALL(*mock_offload_service_utils_, GetOffloadCallback(_));
236 EXPECT_CALL(*mock_offload_service_utils_, GetOffloadDeathRecipient(_));
237 ON_CALL(*mock_offload_service_utils_, GetOffloadService())
238 .WillByDefault(testing::Return(mock_offload_));
239 offload_scan_manager_.reset(new OffloadScanManager(
240 mock_offload_service_utils_, mock_offload_scan_callback_interface_));
241 EXPECT_CALL(*mock_offload_, subscribeScanResults(_, _));
242 EXPECT_CALL(*mock_offload_, configureScans(_, _, _));
243 OffloadScanManager::ReasonCode reason_code = OffloadScanManager::kNone;
244 bool result = offload_scan_manager_->startScan(
245 kDisconnectedModeScanIntervalMs, kRssiThreshold, scan_ssids, match_ssids,
246 security_flags, frequencies, &reason_code);
247 EXPECT_EQ(result, true);
248 }
249
250 /**
251 * Testing OffloadScanManager for subscribing to the scan results from
252 * Offload HAL when service is not available
253 */
TEST_F(OffloadScanManagerTest,StartScanTestWhenServiceIsNotAvailable)254 TEST_F(OffloadScanManagerTest, StartScanTestWhenServiceIsNotAvailable) {
255 EXPECT_CALL(*mock_offload_service_utils_, GetOffloadService()).Times(2);
256 ON_CALL(*mock_offload_service_utils_, GetOffloadService())
257 .WillByDefault(testing::Return(nullptr));
258 offload_scan_manager_.reset(new OffloadScanManager(
259 mock_offload_service_utils_, mock_offload_scan_callback_interface_));
260 OffloadScanManager::ReasonCode reason_code = OffloadScanManager::kNone;
261 bool result = offload_scan_manager_->startScan(
262 kDisconnectedModeScanIntervalMs, kRssiThreshold, scan_ssids, match_ssids,
263 security_flags, frequencies, &reason_code);
264 EXPECT_EQ(result, false);
265 EXPECT_EQ(reason_code, OffloadScanManager::kNotAvailable);
266 }
267
268 /**
269 * Testing OffloadScanManager for subscribing to the scan results from
270 * Offload HAL when service is not working correctly
271 */
TEST_F(OffloadScanManagerTest,StartScanTestWhenServiceIsNotConnected)272 TEST_F(OffloadScanManagerTest, StartScanTestWhenServiceIsNotConnected) {
273 EXPECT_CALL(*mock_offload_service_utils_, GetOffloadService());
274 EXPECT_CALL(*mock_offload_service_utils_, GetOffloadCallback(_));
275 EXPECT_CALL(*mock_offload_service_utils_, GetOffloadDeathRecipient(_));
276 ON_CALL(*mock_offload_service_utils_, GetOffloadService())
277 .WillByDefault(testing::Return(mock_offload_));
278 offload_scan_manager_.reset(new OffloadScanManager(
279 mock_offload_service_utils_, mock_offload_scan_callback_interface_));
280 OffloadStatus status =
281 OffloadTestUtils::createOffloadStatus(OffloadStatusCode::NO_CONNECTION);
282 offload_callback_->onError(status);
283 OffloadScanManager::ReasonCode reason_code = OffloadScanManager::kNone;
284 bool result = offload_scan_manager_->startScan(
285 kDisconnectedModeScanIntervalMs, kRssiThreshold, scan_ssids, match_ssids,
286 security_flags, frequencies, &reason_code);
287 EXPECT_EQ(result, false);
288 EXPECT_EQ(reason_code, OffloadScanManager::kNotAvailable);
289 }
290
291 /**
292 * Testing OffloadScanManager for subscribing to the scan results from
293 * Offload HAL twice when service is okay
294 */
TEST_F(OffloadScanManagerTest,StartScanTwiceTestWhenServiceIsOk)295 TEST_F(OffloadScanManagerTest, StartScanTwiceTestWhenServiceIsOk) {
296 EXPECT_CALL(*mock_offload_service_utils_, GetOffloadService());
297 EXPECT_CALL(*mock_offload_service_utils_, GetOffloadCallback(_));
298 EXPECT_CALL(*mock_offload_service_utils_, GetOffloadDeathRecipient(_));
299 ON_CALL(*mock_offload_service_utils_, GetOffloadService())
300 .WillByDefault(testing::Return(mock_offload_));
301 offload_scan_manager_.reset(new OffloadScanManager(
302 mock_offload_service_utils_, mock_offload_scan_callback_interface_));
303 EXPECT_CALL(*mock_offload_, subscribeScanResults(_, _)).Times(2);
304 EXPECT_CALL(*mock_offload_, configureScans(_, _, _)).Times(2);
305 OffloadScanManager::ReasonCode reason_code = OffloadScanManager::kNone;
306 bool result = offload_scan_manager_->startScan(
307 kDisconnectedModeScanIntervalMs, kRssiThreshold, scan_ssids, match_ssids,
308 security_flags, frequencies, &reason_code);
309 EXPECT_EQ(result, true);
310 result = offload_scan_manager_->startScan(
311 kDisconnectedModeScanIntervalMs, kRssiThreshold, scan_ssids, match_ssids,
312 security_flags, frequencies, &reason_code);
313 EXPECT_EQ(result, true);
314 }
315
316 /**
317 * Testing OffloadScanManager for unsubscribing to the scan results from
318 * Offload HAL when service is ok
319 */
TEST_F(OffloadScanManagerTest,StopScanTestWhenServiceIsOk)320 TEST_F(OffloadScanManagerTest, StopScanTestWhenServiceIsOk) {
321 EXPECT_CALL(*mock_offload_service_utils_, GetOffloadService());
322 EXPECT_CALL(*mock_offload_service_utils_, GetOffloadCallback(_));
323 EXPECT_CALL(*mock_offload_service_utils_, GetOffloadDeathRecipient(_));
324 ON_CALL(*mock_offload_service_utils_, GetOffloadService())
325 .WillByDefault(testing::Return(mock_offload_));
326 offload_scan_manager_.reset(new OffloadScanManager(
327 mock_offload_service_utils_, mock_offload_scan_callback_interface_));
328 EXPECT_CALL(*mock_offload_, subscribeScanResults(_, _));
329 EXPECT_CALL(*mock_offload_, configureScans(_, _, _));
330 EXPECT_CALL(*mock_offload_, unsubscribeScanResults());
331 OffloadScanManager::ReasonCode reason_code = OffloadScanManager::kNone;
332 bool result = offload_scan_manager_->startScan(
333 kDisconnectedModeScanIntervalMs, kRssiThreshold, scan_ssids, match_ssids,
334 security_flags, frequencies, &reason_code);
335 EXPECT_EQ(result, true);
336 result = offload_scan_manager_->stopScan(&reason_code);
337 EXPECT_EQ(result, true);
338 }
339
340 /**
341 * Testing OffloadScanManager for unsubscribing to the scan results from
342 * when service is not connected to the hardware
343 */
TEST_F(OffloadScanManagerTest,StopScanTestWhenServiceIsNotConnectedAnymore)344 TEST_F(OffloadScanManagerTest, StopScanTestWhenServiceIsNotConnectedAnymore) {
345 EXPECT_CALL(*mock_offload_service_utils_, GetOffloadService());
346 EXPECT_CALL(*mock_offload_service_utils_, GetOffloadCallback(_));
347 ON_CALL(*mock_offload_service_utils_, GetOffloadService())
348 .WillByDefault(testing::Return(mock_offload_));
349 offload_scan_manager_.reset(new OffloadScanManager(
350 mock_offload_service_utils_, mock_offload_scan_callback_interface_));
351 EXPECT_CALL(*mock_offload_, subscribeScanResults(_, _));
352 EXPECT_CALL(*mock_offload_, configureScans(_, _, _));
353 OffloadScanManager::ReasonCode reason_code = OffloadScanManager::kNone;
354 bool result = offload_scan_manager_->startScan(
355 kDisconnectedModeScanIntervalMs, kRssiThreshold, scan_ssids, match_ssids,
356 security_flags, frequencies, &reason_code);
357 EXPECT_EQ(result, true);
358 OffloadStatus status =
359 OffloadTestUtils::createOffloadStatus(OffloadStatusCode::NO_CONNECTION);
360 offload_callback_->onError(status);
361 result = offload_scan_manager_->stopScan(&reason_code);
362 EXPECT_EQ(result, false);
363 }
364
365 /**
366 * Testing OffloadScanManager for getting scan statistics when the
367 * Offload HAL service is running without errors
368 */
TEST_F(OffloadScanManagerTest,getScanStatsTestWhenServiceIsOk)369 TEST_F(OffloadScanManagerTest, getScanStatsTestWhenServiceIsOk) {
370 EXPECT_CALL(*mock_offload_service_utils_, GetOffloadService());
371 EXPECT_CALL(*mock_offload_service_utils_, GetOffloadCallback(_));
372 EXPECT_CALL(*mock_offload_service_utils_, GetOffloadDeathRecipient(_));
373 ON_CALL(*mock_offload_service_utils_, GetOffloadService())
374 .WillByDefault(testing::Return(mock_offload_));
375 offload_scan_manager_.reset(new OffloadScanManager(
376 mock_offload_service_utils_, mock_offload_scan_callback_interface_));
377 EXPECT_CALL(*mock_offload_, getScanStats(_));
378 NativeScanStats stats;
379 bool result = offload_scan_manager_->getScanStats(&stats);
380 EXPECT_EQ(result, true);
381 }
382
383 /**
384 * Testing OffloadScanManager for getting scan statistics when the
385 * Offload HAL service is not connected
386 */
TEST_F(OffloadScanManagerTest,getScanStatsTestWhenServiceIsNotOk)387 TEST_F(OffloadScanManagerTest, getScanStatsTestWhenServiceIsNotOk) {
388 EXPECT_CALL(*mock_offload_service_utils_, GetOffloadService());
389 EXPECT_CALL(*mock_offload_service_utils_, GetOffloadCallback(_));
390 EXPECT_CALL(*mock_offload_service_utils_, GetOffloadDeathRecipient(_));
391 ON_CALL(*mock_offload_service_utils_, GetOffloadService())
392 .WillByDefault(testing::Return(mock_offload_));
393 offload_scan_manager_.reset(new OffloadScanManager(
394 mock_offload_service_utils_, mock_offload_scan_callback_interface_));
395 OffloadStatus status =
396 OffloadTestUtils::createOffloadStatus(OffloadStatusCode::NO_CONNECTION);
397 offload_callback_->onError(status);
398 EXPECT_CALL(*mock_offload_, getScanStats(_)).Times(0);
399 NativeScanStats stats;
400 bool result = offload_scan_manager_->getScanStats(&stats);
401 EXPECT_EQ(result, false);
402 }
403
404 /**
405 * Testing OffloadScanManager for subscribing to the scan results from
406 * Offload HAL when service is running without errors, operation failure
407 */
TEST_F(OffloadScanManagerTest,StartScanFailedTest)408 TEST_F(OffloadScanManagerTest, StartScanFailedTest) {
409 EXPECT_CALL(*mock_offload_service_utils_, GetOffloadService());
410 EXPECT_CALL(*mock_offload_service_utils_, GetOffloadCallback(_));
411 EXPECT_CALL(*mock_offload_service_utils_, GetOffloadDeathRecipient(_));
412 ON_CALL(*mock_offload_service_utils_, GetOffloadService())
413 .WillByDefault(testing::Return(mock_offload_));
414 offload_scan_manager_.reset(new OffloadScanManager(
415 mock_offload_service_utils_, mock_offload_scan_callback_interface_));
416 EXPECT_CALL(*mock_offload_, subscribeScanResults(_, _)).Times(0);
417 EXPECT_CALL(*mock_offload_, configureScans(_, _, _)).Times(1);
418 status = OffloadTestUtils::createOffloadStatus(OffloadStatusCode::ERROR);
419 OffloadScanManager::ReasonCode reason_code = OffloadScanManager::kNone;
420 bool result = offload_scan_manager_->startScan(
421 kDisconnectedModeScanIntervalMs, kRssiThreshold, scan_ssids, match_ssids,
422 security_flags, frequencies, &reason_code);
423 EXPECT_EQ(result, false);
424 EXPECT_EQ(reason_code, OffloadScanManager::kOperationFailed);
425 }
426
427 /**
428 * Testing OffloadScanManager for getting scan statistics when the
429 * Offload HAL service is running without errors, getting scan stats failure
430 */
TEST_F(OffloadScanManagerTest,getScanStatsFailedTest)431 TEST_F(OffloadScanManagerTest, getScanStatsFailedTest) {
432 EXPECT_CALL(*mock_offload_service_utils_, GetOffloadService());
433 EXPECT_CALL(*mock_offload_service_utils_, GetOffloadCallback(_));
434 EXPECT_CALL(*mock_offload_service_utils_, GetOffloadDeathRecipient(_));
435 ON_CALL(*mock_offload_service_utils_, GetOffloadService())
436 .WillByDefault(testing::Return(mock_offload_));
437 offload_scan_manager_.reset(new OffloadScanManager(
438 mock_offload_service_utils_, mock_offload_scan_callback_interface_));
439 status = OffloadTestUtils::createOffloadStatus(OffloadStatusCode::TIMEOUT);
440 EXPECT_CALL(*mock_offload_, getScanStats(_));
441 NativeScanStats stats;
442 bool result = offload_scan_manager_->getScanStats(&stats);
443 EXPECT_EQ(result, false);
444 }
445
446 } // namespace wificond
447 } // namespace android
448