2 * Copyright (C) 2016, The Android Open Source Project
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
8 * http://www.apache.org/licenses/LICENSE-2.0
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.
22 #include <gtest/gtest.h>
24 #include "wificond/scanning/scan_result.h"
25 #include "wificond/scanning/offload/offload_callback.h"
26 #include "wificond/tests/offload_test_utils.h"
28 using android::hardware::wifi::offload::V1_0::ScanResult;
29 using android::hardware::hidl_vec;
34 class OffloadCallbackTest: public ::testing::Test {
36 virtual void SetUp() {
37 dummy_scan_results_ = OffloadTestUtils::createOffloadScanResults();
40 void TearDown() override {
41 dummy_scan_results_.clear();
44 std::vector<ScanResult> dummy_scan_results_;
45 std::unique_ptr<OffloadCallback> dut_;
49 * Testing OffloadCallback to invoke the registered callback handler
50 * with the scan results when they are available
52 TEST_F(OffloadCallbackTest, checkScanResultSize) {
53 std::vector<ScanResult> scan_result;
54 dut_.reset(new OffloadCallback(
55 [&scan_result] (std::vector<ScanResult> scanResult) -> void {
56 scan_result = scanResult;
58 hidl_vec<ScanResult> offloadScanResult(dummy_scan_results_);
59 dut_->onScanResult(offloadScanResult);
60 EXPECT_EQ(dummy_scan_results_.size(), scan_result.size());
63 } // namespace wificond
64 } // namespace android