diff options
Diffstat (limited to 'tests')
| -rw-r--r-- | tests/ap_interface_impl_unittest.cpp | 60 | ||||
| -rw-r--r-- | tests/client_interface_impl_unittest.cpp | 43 | ||||
| -rw-r--r-- | tests/integration/ap_interface_test.cpp | 8 | ||||
| -rw-r--r-- | tests/integration/client_interface_test.cpp | 8 | ||||
| -rw-r--r-- | tests/integration/process_utils.cpp | 2 | ||||
| -rw-r--r-- | tests/integration/process_utils.h | 6 | ||||
| -rw-r--r-- | tests/integration/scanner_test.cpp | 10 | ||||
| -rw-r--r-- | tests/mock_ap_interface_event_callback.h | 8 | ||||
| -rw-r--r-- | tests/mock_i_send_mgmt_frame_event.h | 4 | ||||
| -rw-r--r-- | tests/mock_scan_utils.h | 5 | ||||
| -rw-r--r-- | tests/native_wifi_client_unittest.cpp | 58 | ||||
| -rw-r--r-- | tests/netlink_utils_unittest.cpp | 74 | ||||
| -rw-r--r-- | tests/scan_result_unittest.cpp | 4 | ||||
| -rw-r--r-- | tests/scan_settings_unittest.cpp | 16 | ||||
| -rw-r--r-- | tests/scan_utils_unittest.cpp | 17 | ||||
| -rw-r--r-- | tests/scanner_unittest.cpp | 49 | ||||
| -rw-r--r-- | tests/server_unittest.cpp | 6 |
17 files changed, 216 insertions, 162 deletions
diff --git a/tests/ap_interface_impl_unittest.cpp b/tests/ap_interface_impl_unittest.cpp index 59d9c0f..35e8161 100644 --- a/tests/ap_interface_impl_unittest.cpp +++ b/tests/ap_interface_impl_unittest.cpp @@ -32,7 +32,7 @@ #include "wificond/ap_interface_impl.h" using android::wifi_system::MockInterfaceTool; -using com::android::server::wifi::wificond::NativeWifiClient; +using android::net::wifi::nl80211::NativeWifiClient; using std::array; using std::placeholders::_1; using std::placeholders::_2; @@ -90,60 +90,6 @@ class ApInterfaceImplTest : public ::testing::Test { } // namespace -TEST_F(ApInterfaceImplTest, CanGetConnectedClients) { - OnStationEventHandler handler; - EXPECT_CALL(*netlink_utils_, - SubscribeStationEvent(kTestInterfaceIndex, _)). - WillOnce(Invoke(bind(CaptureStationEventHandler, &handler, _1, _2))); - - ap_interface_.reset(new ApInterfaceImpl( - kTestInterfaceName, - kTestInterfaceIndex, - netlink_utils_.get(), - if_tool_.get())); - - array<uint8_t, ETH_ALEN> fake_mac_address_01 = kFakeMacAddress01; - array<uint8_t, ETH_ALEN> fake_mac_address_02 = kFakeMacAddress02; - std::vector<NativeWifiClient> associated_stations = - ap_interface_->GetConnectedClients(); - int numberOfStations = static_cast<int>(associated_stations.size()); - EXPECT_EQ(0, numberOfStations); - handler(NEW_STATION, fake_mac_address_01); - associated_stations = ap_interface_->GetConnectedClients(); - numberOfStations = static_cast<int>(associated_stations.size()); - EXPECT_EQ(1, numberOfStations); - handler(NEW_STATION, fake_mac_address_02); - associated_stations = ap_interface_->GetConnectedClients(); - numberOfStations = static_cast<int>(associated_stations.size()); - EXPECT_EQ(2, numberOfStations); - handler(DEL_STATION, fake_mac_address_01); - associated_stations = ap_interface_->GetConnectedClients(); - numberOfStations = static_cast<int>(associated_stations.size()); - EXPECT_EQ(1, numberOfStations); -} - -TEST_F(ApInterfaceImplTest, CanGetConnectedClientsSetsValues) { - OnStationEventHandler handler; - EXPECT_CALL(*netlink_utils_, - SubscribeStationEvent(kTestInterfaceIndex, _)). - WillOnce(Invoke(bind(CaptureStationEventHandler, &handler, _1, _2))); - - ap_interface_.reset(new ApInterfaceImpl( - kTestInterfaceName, - kTestInterfaceIndex, - netlink_utils_.get(), - if_tool_.get())); - - array<uint8_t, ETH_ALEN> fake_mac_address_01 = kFakeMacAddress01; - vector<uint8_t> expected_mac_address = - vector<uint8_t>(fake_mac_address_01.begin(), fake_mac_address_01.end()); - handler(NEW_STATION, fake_mac_address_01); - std::vector<NativeWifiClient> associated_stations = - ap_interface_->GetConnectedClients(); - NativeWifiClient station = associated_stations[0]; - EXPECT_EQ(expected_mac_address, station.macAddress); -} - TEST_F(ApInterfaceImplTest, CallbackIsCalledOnConnectedClientsChanged) { OnStationEventHandler handler; EXPECT_CALL(*netlink_utils_, SubscribeStationEvent(kTestInterfaceIndex, _)) @@ -160,7 +106,7 @@ TEST_F(ApInterfaceImplTest, CallbackIsCalledOnConnectedClientsChanged) { array<uint8_t, ETH_ALEN> fake_mac_address_01 = kFakeMacAddress01; array<uint8_t, ETH_ALEN> fake_mac_address_02 = kFakeMacAddress02; - EXPECT_CALL(*callback, onConnectedClientsChanged(_)).Times(3); + EXPECT_CALL(*callback, onConnectedClientsChanged(_,_)).Times(3); handler(NEW_STATION, fake_mac_address_01); handler(NEW_STATION, fake_mac_address_02); handler(DEL_STATION, fake_mac_address_01); @@ -181,7 +127,7 @@ TEST_F(ApInterfaceImplTest, CallbackIsCalledOnConnectedClientsChangedOnlyOnDiff) EXPECT_TRUE(out_success); array<uint8_t, ETH_ALEN> fake_mac_address_01 = kFakeMacAddress01; - EXPECT_CALL(*callback, onConnectedClientsChanged(_)).Times(2); + EXPECT_CALL(*callback, onConnectedClientsChanged(_,_)).Times(4); handler(NEW_STATION, fake_mac_address_01); handler(NEW_STATION, fake_mac_address_01); handler(DEL_STATION, fake_mac_address_01); diff --git a/tests/client_interface_impl_unittest.cpp b/tests/client_interface_impl_unittest.cpp index 5929139..1dc2699 100644 --- a/tests/client_interface_impl_unittest.cpp +++ b/tests/client_interface_impl_unittest.cpp @@ -77,6 +77,8 @@ class ClientInterfaceImplTest : public ::testing::Test { OnFrameTxStatusEventHandler handler) { frame_tx_status_event_handler_ = handler; }); + EXPECT_CALL(*netlink_utils_, + SubscribeChannelSwitchEvent(kTestInterfaceIndex, _)); client_interface_.reset(new ClientInterfaceImpl{ kTestWiphyIndex, kTestInterfaceName, @@ -92,6 +94,8 @@ class ClientInterfaceImplTest : public ::testing::Test { UnsubscribeMlmeEvent(kTestInterfaceIndex)); EXPECT_CALL(*netlink_utils_, UnsubscribeFrameTxStatusEvent(kTestInterfaceIndex)); + EXPECT_CALL(*netlink_utils_, + UnsubscribeChannelSwitchEvent(kTestInterfaceIndex)); } unique_ptr<NiceMock<MockInterfaceTool>> if_tool_{ @@ -110,45 +114,6 @@ class ClientInterfaceImplTest : public ::testing::Test { } // namespace -TEST_F(ClientInterfaceImplTest, SetMacAddressFailsOnInterfaceDownFailure) { - EXPECT_CALL(*if_tool_, SetWifiUpState(false)).WillOnce(Return(false)); - EXPECT_FALSE( - client_interface_->SetMacAddress(std::array<uint8_t, ETH_ALEN>())); -} - -TEST_F(ClientInterfaceImplTest, SetMacAddressFailsOnAddressChangeFailure) { - EXPECT_CALL(*if_tool_, SetWifiUpState(false)).WillOnce(Return(true)); - EXPECT_CALL(*if_tool_, SetMacAddress(_, _)).WillOnce(Return(false)); - EXPECT_FALSE( - client_interface_->SetMacAddress(std::array<uint8_t, ETH_ALEN>())); -} - -TEST_F(ClientInterfaceImplTest, SetMacAddressFailsOnInterfaceUpFailure) { - EXPECT_CALL(*if_tool_, SetWifiUpState(false)).WillOnce(Return(true)); - EXPECT_CALL(*if_tool_, SetMacAddress(_, _)).WillOnce(Return(true)); - EXPECT_CALL(*if_tool_, SetWifiUpState(true)).WillOnce(Return(false)); - EXPECT_FALSE( - client_interface_->SetMacAddress(std::array<uint8_t, ETH_ALEN>())); -} - -TEST_F(ClientInterfaceImplTest, SetMacAddressReturnsTrueOnSuccess) { - EXPECT_CALL(*if_tool_, SetWifiUpState(false)).WillOnce(Return(true)); - EXPECT_CALL(*if_tool_, SetMacAddress(_, _)).WillOnce(Return(true)); - EXPECT_CALL(*if_tool_, SetWifiUpState(true)).WillOnce(Return(true)); - EXPECT_TRUE( - client_interface_->SetMacAddress(std::array<uint8_t, ETH_ALEN>())); -} - -TEST_F(ClientInterfaceImplTest, SetMacAddressPassesCorrectAddressToIfTool) { - EXPECT_CALL(*if_tool_, SetWifiUpState(false)).WillOnce(Return(true)); - EXPECT_CALL(*if_tool_, SetMacAddress(_, - std::array<uint8_t, ETH_ALEN>{{1, 2, 3, 4, 5, 6}})) - .WillOnce(Return(true)); - EXPECT_CALL(*if_tool_, SetWifiUpState(true)).WillOnce(Return(true)); - EXPECT_TRUE(client_interface_->SetMacAddress( - std::array<uint8_t, ETH_ALEN>{{1, 2, 3, 4, 5, 6}})); -} - /** * If the device does not support sending mgmt frame at specified MCS rate, * and the caller specifies a MCS < 0, the call should still succeed (and the diff --git a/tests/integration/ap_interface_test.cpp b/tests/integration/ap_interface_test.cpp index 3af92f7..f5812c6 100644 --- a/tests/integration/ap_interface_test.cpp +++ b/tests/integration/ap_interface_test.cpp @@ -20,13 +20,13 @@ #include <utils/StrongPointer.h> #include <wifi_system/interface_tool.h> -#include "android/net/wifi/IApInterface.h" -#include "android/net/wifi/IWificond.h" +#include "android/net/wifi/nl80211/IApInterface.h" +#include "android/net/wifi/nl80211/IWificond.h" #include "wificond/tests/integration/process_utils.h" #include "wificond/tests/mock_ap_interface_event_callback.h" -using android::net::wifi::IApInterface; -using android::net::wifi::IWificond; +using android::net::wifi::nl80211::IApInterface; +using android::net::wifi::nl80211::IWificond; using android::wifi_system::InterfaceTool; using android::wificond::MockApInterfaceEventCallback; using android::wificond::tests::integration::ScopedDevModeWificond; diff --git a/tests/integration/client_interface_test.cpp b/tests/integration/client_interface_test.cpp index 37b9dba..43ec0f2 100644 --- a/tests/integration/client_interface_test.cpp +++ b/tests/integration/client_interface_test.cpp @@ -21,12 +21,12 @@ #include <utils/StrongPointer.h> #include <wifi_system/interface_tool.h> -#include "android/net/wifi/IClientInterface.h" -#include "android/net/wifi/IWificond.h" +#include "android/net/wifi/nl80211/IClientInterface.h" +#include "android/net/wifi/nl80211/IWificond.h" #include "wificond/tests/integration/process_utils.h" -using android::net::wifi::IClientInterface; -using android::net::wifi::IWificond; +using android::net::wifi::nl80211::IClientInterface; +using android::net::wifi::nl80211::IWificond; using android::wifi_system::InterfaceTool; using android::wificond::tests::integration::ScopedDevModeWificond; using std::string; diff --git a/tests/integration/process_utils.cpp b/tests/integration/process_utils.cpp index e1c7b8f..80d74f3 100644 --- a/tests/integration/process_utils.cpp +++ b/tests/integration/process_utils.cpp @@ -32,7 +32,7 @@ using android::String16; using android::base::StringPrintf; using android::base::Trim; -using android::net::wifi::IWificond; +using android::net::wifi::nl80211::IWificond; using android::sp; using android::wificond::ipc_constants::kServiceName; diff --git a/tests/integration/process_utils.h b/tests/integration/process_utils.h index 1bec3ea..6101857 100644 --- a/tests/integration/process_utils.h +++ b/tests/integration/process_utils.h @@ -24,7 +24,7 @@ #include <android-base/macros.h> #include <utils/StrongPointer.h> -#include "android/net/wifi/IWificond.h" +#include "android/net/wifi/nl80211/IWificond.h" namespace android { namespace wificond { @@ -57,9 +57,9 @@ class ScopedDevModeWificond final { // This makes avoids the nastiness of restarting a system process // because you instantiated an object. // ASSERTs that wificond starts in dev mode. - android::sp<android::net::wifi::IWificond> EnterDevModeOrDie(); + android::sp<android::net::wifi::nl80211::IWificond> EnterDevModeOrDie(); // Returns true iff wificond entered dev mode. - android::sp<android::net::wifi::IWificond> MaybeEnterDevMode(); + android::sp<android::net::wifi::nl80211::IWificond> MaybeEnterDevMode(); // This will be called for you in the destructor, but you can do it yourself // if you prefer. diff --git a/tests/integration/scanner_test.cpp b/tests/integration/scanner_test.cpp index 1844045..ff817e4 100644 --- a/tests/integration/scanner_test.cpp +++ b/tests/integration/scanner_test.cpp @@ -20,13 +20,13 @@ #include <gtest/gtest.h> #include <utils/StrongPointer.h> -#include "android/net/wifi/IClientInterface.h" -#include "android/net/wifi/IWificond.h" +#include "android/net/wifi/nl80211/IClientInterface.h" +#include "android/net/wifi/nl80211/IWificond.h" #include "wificond/tests/integration/process_utils.h" -using android::net::wifi::IClientInterface; -using android::net::wifi::IWificond; -using android::net::wifi::IWifiScannerImpl; +using android::net::wifi::nl80211::IClientInterface; +using android::net::wifi::nl80211::IWificond; +using android::net::wifi::nl80211::IWifiScannerImpl; using android::wificond::tests::integration::ScopedDevModeWificond; using std::unique_ptr; using std::vector; diff --git a/tests/mock_ap_interface_event_callback.h b/tests/mock_ap_interface_event_callback.h index 8e77fee..4177987 100644 --- a/tests/mock_ap_interface_event_callback.h +++ b/tests/mock_ap_interface_event_callback.h @@ -20,20 +20,20 @@ #include <gmock/gmock.h> #include <gtest/gtest.h> -#include "android/net/wifi/IApInterfaceEventCallback.h" +#include "android/net/wifi/nl80211/IApInterfaceEventCallback.h" namespace android { namespace wificond { class MockApInterfaceEventCallback - : public net::wifi::IApInterfaceEventCallback { + : public net::wifi::nl80211::IApInterfaceEventCallback { public: MockApInterfaceEventCallback() = default; ~MockApInterfaceEventCallback() = default; MOCK_METHOD0(onAsBinder, IBinder*()); - MOCK_METHOD1(onConnectedClientsChanged, ::android::binder::Status( - const ::std::vector<::com::android::server::wifi::wificond::NativeWifiClient> &)); + MOCK_METHOD2(onConnectedClientsChanged, ::android::binder::Status( + const android::net::wifi::nl80211::NativeWifiClient &, bool isConnected)); MOCK_METHOD2(onSoftApChannelSwitched, ::android::binder::Status(int, int)); }; diff --git a/tests/mock_i_send_mgmt_frame_event.h b/tests/mock_i_send_mgmt_frame_event.h index 30b7da7..c105590 100644 --- a/tests/mock_i_send_mgmt_frame_event.h +++ b/tests/mock_i_send_mgmt_frame_event.h @@ -20,13 +20,13 @@ #include <gmock/gmock.h> #include <gtest/gtest.h> -#include "android/net/wifi/ISendMgmtFrameEvent.h" +#include "android/net/wifi/nl80211/ISendMgmtFrameEvent.h" namespace android { namespace wificond { class MockISendMgmtFrameEvent - : public ::android::net::wifi::ISendMgmtFrameEvent { + : public ::android::net::wifi::nl80211::ISendMgmtFrameEvent { public: virtual ~MockISendMgmtFrameEvent() override = default; diff --git a/tests/mock_scan_utils.h b/tests/mock_scan_utils.h index eb7e9c7..acb7f45 100644 --- a/tests/mock_scan_utils.h +++ b/tests/mock_scan_utils.h @@ -39,7 +39,7 @@ class MockScanUtils : public ScanUtils { OnScanResultsReadyHandler handler)); MOCK_METHOD2(GetScanResult, bool( uint32_t interface_index, - std::vector<::com::android::server::wifi::wificond::NativeScanResult>* out_scan_results)); + std::vector<android::net::wifi::nl80211::NativeScanResult>* out_scan_results)); MOCK_METHOD6(Scan, bool( uint32_t interface_index, @@ -49,11 +49,12 @@ class MockScanUtils : public ScanUtils { const std::vector<uint32_t>& freqs, int* error_code)); - MOCK_METHOD9(StartScheduledScan, bool( + MOCK_METHOD10(StartScheduledScan, bool( uint32_t interface_index, const SchedScanIntervalSetting& interval_setting, int32_t rssi_threshold_2g, int32_t rssi_threshold_5g, + int32_t rssi_threshold_6g, const SchedScanReqFlags& req_flags, const std::vector<std::vector<uint8_t>>& scan_ssids, const std::vector<std::vector<uint8_t>>& match_ssids, diff --git a/tests/native_wifi_client_unittest.cpp b/tests/native_wifi_client_unittest.cpp new file mode 100644 index 0000000..e426107 --- /dev/null +++ b/tests/native_wifi_client_unittest.cpp @@ -0,0 +1,58 @@ +/* + * Copyright (C) 2019, The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include <vector> + +#include <gtest/gtest.h> + +#include "wificond/client/native_wifi_client.h" + +using ::android::net::wifi::nl80211::NativeWifiClient; +using std::vector; + +namespace android { +namespace wificond { + +namespace { + +const vector<uint8_t> kMacAddress = { 0x01, 0x02, 0x03, 0x04, 0x05, 0x06 }; +const vector<uint8_t> kMacAddressOther = { 0x01, 0x02, 0x03, 0x04, 0x05, 0x0F }; + +} // namespace + +class NativeWifiClientTest : public ::testing::Test { +}; + +TEST_F(NativeWifiClientTest, NativeWifiClientParcelableTest) { + NativeWifiClient wifi_client; + wifi_client.mac_address_ = kMacAddress; + + Parcel parcel; + EXPECT_EQ(::android::OK, wifi_client.writeToParcel(&parcel)); + + NativeWifiClient wifi_client_copy; + parcel.setDataPosition(0); + EXPECT_EQ(::android::OK, wifi_client_copy.readFromParcel(&parcel)); + + EXPECT_EQ(wifi_client, wifi_client_copy); + + NativeWifiClient wifi_client_other; + wifi_client_other.mac_address_ = kMacAddressOther; + EXPECT_FALSE(wifi_client == wifi_client_other); +} + +} // namespace wificond +} // namespace android diff --git a/tests/netlink_utils_unittest.cpp b/tests/netlink_utils_unittest.cpp index 34f5c21..986f3b2 100644 --- a/tests/netlink_utils_unittest.cpp +++ b/tests/netlink_utils_unittest.cpp @@ -75,7 +75,19 @@ const uint8_t kFakeExtFeaturesForLowPowerScan[] = {0x0, 0x0, 0x80}; const uint8_t kFakeExtFeaturesForHighAccuracy[] = {0x0, 0x0, 0x0, 0x1}; const uint8_t kFakeExtFeaturesForAllScanType[] = {0x0, 0x0, 0xC0, 0x1}; const uint8_t kFakeFrame[] = {0x00, 0x01, 0x02, 0x03}; - +constexpr bool k11nSupported = true; +constexpr bool k11acSupported = true; +constexpr bool k11axSupported = true; +constexpr uint8_t kMaxTxStreams = 4; +constexpr uint8_t kMaxRxStreams = 5; +constexpr bool k160MHzSupported = true; +constexpr bool k80p80MHzSupported = false; +const uint8_t kHtMcsSet[] = {0xff, 0xff, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, + 0x0, 0x0, 0x0, 0x0, 0xf, 0x0, 0x0, 0x0}; +const uint8_t kVhtMcsSet[] = {0xaa, 0xfe, 0xff, 0xff, 0xaa, 0xff, 0xff, 0xff}; +const uint8_t kHeMcsSet[] = {0xaa, 0xfe, 0xaa, 0xff}; +const uint8_t kVhtCap[] = {0x4, 0x0, 0x0, 0x0}; +const uint8_t kHeCapPhy[] = {0x8, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0}; // Currently, control messages are only created by the kernel and sent to us. // Therefore NL80211Packet doesn't have corresponding constructor. @@ -121,6 +133,56 @@ void AppendScanCapabilitiesAttributes(NL80211Packet* packet, } } + +NL80211Attr<std::vector<uint8_t>> GenerateBandsAttributeForHtCapa() { + std::vector<uint8_t> ht_cap(2, 0); + return NL80211Attr<std::vector<uint8_t>>(NL80211_BAND_ATTR_HT_CAPA, + ht_cap); +} + + +NL80211Attr<std::vector<uint8_t>> GenerateBandsAttributeForVhtCapa() { + std::vector<uint8_t> vht_cap(kVhtCap, kVhtCap + sizeof(kVhtCap)); + return NL80211Attr<std::vector<uint8_t>>(NL80211_BAND_ATTR_VHT_CAPA, + vht_cap); +} + +NL80211Attr<std::vector<uint8_t>> GenerateBandsAttributeForHtMcsSet() { + std::vector<uint8_t> ht_mcs_set(kHtMcsSet, kHtMcsSet + sizeof(kHtMcsSet)); + return NL80211Attr<std::vector<uint8_t>>(NL80211_BAND_ATTR_HT_MCS_SET, + ht_mcs_set); +} + +NL80211Attr<std::vector<uint8_t>> GenerateBandsAttributeForVhtMcsSet() { + std::vector<uint8_t> vht_mcs_set(kVhtMcsSet, kVhtMcsSet + sizeof(kVhtMcsSet)); + return NL80211Attr<std::vector<uint8_t>>(NL80211_BAND_ATTR_VHT_MCS_SET, + vht_mcs_set); +} + +NL80211NestedAttr GenerateBandsAttributeForIfTypeData() { + NL80211NestedAttr if_type_data(NL80211_BAND_ATTR_IFTYPE_DATA); + + NL80211NestedAttr if_type_data1(1); + std::vector<uint8_t> he_cap_phy(kHeCapPhy, kHeCapPhy + sizeof(kHeCapPhy)); + std::vector<uint8_t> he_mcs_set(kHeMcsSet, kHeMcsSet + sizeof(kHeMcsSet)); + + if_type_data1.AddAttribute(NL80211Attr<std::vector<uint8_t>>( + NL80211_BAND_IFTYPE_ATTR_HE_CAP_PHY, he_cap_phy)); + if_type_data1.AddAttribute(NL80211Attr<std::vector<uint8_t>>( + NL80211_BAND_IFTYPE_ATTR_HE_CAP_MCS_SET, he_mcs_set)); + if_type_data.AddAttribute(if_type_data1); + return if_type_data; +} + +void AppendBandPhyAttributes(NL80211NestedAttr* band_attr) { + band_attr->AddAttribute(GenerateBandsAttributeForHtCapa()); + band_attr->AddAttribute(GenerateBandsAttributeForHtMcsSet()); + band_attr->AddAttribute(GenerateBandsAttributeForVhtCapa()); + band_attr->AddAttribute(GenerateBandsAttributeForVhtMcsSet()); + + band_attr->AddAttribute(GenerateBandsAttributeForIfTypeData()); +} + NL80211NestedAttr GenerateBandsAttributeFor2g() { NL80211NestedAttr freq_2g_1(1); NL80211NestedAttr freq_2g_2(2); @@ -139,6 +201,7 @@ NL80211NestedAttr GenerateBandsAttributeFor2g() { NL80211NestedAttr band_2g_attr(1); band_2g_attr.AddAttribute(band_2g_freqs); + AppendBandPhyAttributes(&band_2g_attr); NL80211NestedAttr band_attr(NL80211_ATTR_WIPHY_BANDS); band_attr.AddAttribute(band_2g_attr); @@ -177,6 +240,7 @@ NL80211NestedAttr GenerateBandsAttributeFor5gAndDfs() { NL80211NestedAttr band_5g_attr(1); band_5g_attr.AddAttribute(band_5g_freqs); + AppendBandPhyAttributes(&band_5g_attr); NL80211NestedAttr band_attr(NL80211_ATTR_WIPHY_BANDS); band_attr.AddAttribute(band_5g_attr); @@ -187,6 +251,7 @@ void AppendBandInfoAttributes(NL80211Packet* packet) { NL80211NestedAttr attr_2g = GenerateBandsAttributeFor2g(); NL80211NestedAttr attr_5g_and_dfs = GenerateBandsAttributeFor5gAndDfs(); attr_2g.Merge(attr_5g_and_dfs); + packet->AddAttribute(attr_2g); } @@ -267,6 +332,13 @@ void VerifyBandInfo(const BandInfo& band_info) { EXPECT_EQ(band_info.band_2g, band_2g_expected); EXPECT_EQ(band_info.band_5g, band_5g_expected); EXPECT_EQ(band_info.band_dfs, band_dfs_expected); + EXPECT_EQ(band_info.is_80211n_supported, k11nSupported); + EXPECT_EQ(band_info.is_80211ac_supported, k11acSupported); + EXPECT_EQ(band_info.is_80211ax_supported, k11axSupported); + EXPECT_EQ(band_info.is_160_mhz_supported, k160MHzSupported); + EXPECT_EQ(band_info.is_80p80_mhz_supported, k80p80MHzSupported); + EXPECT_EQ(band_info.max_tx_streams, kMaxTxStreams); + EXPECT_EQ(band_info.max_rx_streams, kMaxRxStreams); } void VerifyWiphyFeatures(const WiphyFeatures& wiphy_features) { diff --git a/tests/scan_result_unittest.cpp b/tests/scan_result_unittest.cpp index facda6f..7cac000 100644 --- a/tests/scan_result_unittest.cpp +++ b/tests/scan_result_unittest.cpp @@ -23,8 +23,8 @@ #include "wificond/scanning/scan_result.h" -using ::com::android::server::wifi::wificond::NativeScanResult; -using ::com::android::server::wifi::wificond::RadioChainInfo; +using ::android::net::wifi::nl80211::NativeScanResult; +using ::android::net::wifi::nl80211::RadioChainInfo; using std::array; using std::vector; diff --git a/tests/scan_settings_unittest.cpp b/tests/scan_settings_unittest.cpp index 707392d..d3d1574 100644 --- a/tests/scan_settings_unittest.cpp +++ b/tests/scan_settings_unittest.cpp @@ -18,19 +18,19 @@ #include <gtest/gtest.h> -#include "android/net/wifi/IWifiScannerImpl.h" +#include "android/net/wifi/nl80211/IWifiScannerImpl.h" #include "wificond/scanning/channel_settings.h" #include "wificond/scanning/hidden_network.h" #include "wificond/scanning/pno_network.h" #include "wificond/scanning/pno_settings.h" #include "wificond/scanning/single_scan_settings.h" -using ::android::net::wifi::IWifiScannerImpl; -using ::com::android::server::wifi::wificond::ChannelSettings; -using ::com::android::server::wifi::wificond::HiddenNetwork; -using ::com::android::server::wifi::wificond::PnoNetwork; -using ::com::android::server::wifi::wificond::PnoSettings; -using ::com::android::server::wifi::wificond::SingleScanSettings; +using ::android::net::wifi::nl80211::IWifiScannerImpl; +using ::android::net::wifi::nl80211::ChannelSettings; +using ::android::net::wifi::nl80211::HiddenNetwork; +using ::android::net::wifi::nl80211::PnoNetwork; +using ::android::net::wifi::nl80211::PnoSettings; +using ::android::net::wifi::nl80211::SingleScanSettings; using std::vector; namespace android { @@ -46,6 +46,7 @@ const uint8_t kFakeSsid1[] = constexpr int32_t kFakePnoIntervalMs = 20000; constexpr int32_t kFakePnoMin2gRssi = -80; constexpr int32_t kFakePnoMin5gRssi = -85; +constexpr int32_t kFakePnoMin6gRssi = -89; constexpr uint32_t kFakeFrequency = 5260; constexpr uint32_t kFakeFrequency1 = 2460; @@ -162,6 +163,7 @@ TEST_F(ScanSettingsTest, PnoSettingsParcelableTest) { pno_settings.interval_ms_ = kFakePnoIntervalMs; pno_settings.min_2g_rssi_ = kFakePnoMin2gRssi; pno_settings.min_5g_rssi_ = kFakePnoMin5gRssi; + pno_settings.min_6g_rssi_ = kFakePnoMin6gRssi; pno_settings.pno_networks_ = {network, network1}; diff --git a/tests/scan_utils_unittest.cpp b/tests/scan_utils_unittest.cpp index f8ec523..051d7c0 100644 --- a/tests/scan_utils_unittest.cpp +++ b/tests/scan_utils_unittest.cpp @@ -22,7 +22,7 @@ #include <gtest/gtest.h> -#include "android/net/wifi/IWifiScannerImpl.h" +#include "android/net/wifi/nl80211/IWifiScannerImpl.h" #include "wificond/net/kernel-header-latest/nl80211.h" #include "wificond/scanning/scan_result.h" #include "wificond/scanning/scan_utils.h" @@ -40,8 +40,8 @@ using testing::Not; using testing::Return; using testing::_; -using android::net::wifi::IWifiScannerImpl; -using com::android::server::wifi::wificond::NativeScanResult; +using android::net::wifi::nl80211::IWifiScannerImpl; +using android::net::wifi::nl80211::NativeScanResult; namespace android { namespace wificond { @@ -54,6 +54,7 @@ constexpr uint32_t kFakeSequenceNumber = 1984; constexpr int kFakeErrorCode = EIO; constexpr int32_t kFake2gRssiThreshold = -80; constexpr int32_t kFake5gRssiThreshold = -77; +constexpr int32_t kFake6gRssiThreshold = -77; constexpr bool kFakeUseRandomMAC = true; constexpr bool kFakeRequestLowPower = true; constexpr bool kFakeRequestSchedScanRelativeRssi = true; @@ -281,7 +282,7 @@ TEST_F(ScanUtilsTest, CanSendSchedScanRequest) { EXPECT_TRUE(scan_utils_.StartScheduledScan( kFakeInterfaceIndex, SchedScanIntervalSetting(), - kFake2gRssiThreshold, kFake5gRssiThreshold, req_flags, {}, {}, {}, + kFake2gRssiThreshold, kFake5gRssiThreshold, kFake6gRssiThreshold, req_flags, {}, {}, {}, &errno_ignored)); // TODO(b/34231420): Add validation of requested scan ssids, threshold, // and frequencies. @@ -302,7 +303,7 @@ TEST_F(ScanUtilsTest, CanHandleSchedScanRequestFailure) { EXPECT_FALSE(scan_utils_.StartScheduledScan( kFakeInterfaceIndex, SchedScanIntervalSetting(), - kFake2gRssiThreshold, kFake5gRssiThreshold, + kFake2gRssiThreshold, kFake5gRssiThreshold, kFake6gRssiThreshold, req_flags, {}, {}, {}, &error_code)); EXPECT_EQ(kFakeErrorCode, error_code); } @@ -324,7 +325,7 @@ TEST_F(ScanUtilsTest, CanSendSchedScanRequestForLowPowerScan) { scan_utils_.StartScheduledScan( kFakeInterfaceIndex, SchedScanIntervalSetting(), - kFake2gRssiThreshold, kFake5gRssiThreshold, + kFake2gRssiThreshold, kFake5gRssiThreshold, kFake6gRssiThreshold, req_flags, {}, {}, {}, &errno_ignored); } @@ -348,7 +349,7 @@ TEST_F(ScanUtilsTest, CanSpecifyScanPlansForSchedScanRequest) { scan_utils_.StartScheduledScan( kFakeInterfaceIndex, interval_setting, - kFake2gRssiThreshold, kFake5gRssiThreshold, + kFake2gRssiThreshold, kFake5gRssiThreshold, kFake6gRssiThreshold, req_flags, {}, {}, {}, &errno_ignored); } @@ -370,7 +371,7 @@ TEST_F(ScanUtilsTest, CanSpecifySingleIntervalForSchedScanRequest) { scan_utils_.StartScheduledScan( kFakeInterfaceIndex, interval_setting, - kFake2gRssiThreshold, kFake5gRssiThreshold, + kFake2gRssiThreshold, kFake5gRssiThreshold, kFake6gRssiThreshold, req_flags, {}, {}, {}, &errno_ignored); } diff --git a/tests/scanner_unittest.cpp b/tests/scanner_unittest.cpp index 4d2ebdf..990dcb2 100644 --- a/tests/scanner_unittest.cpp +++ b/tests/scanner_unittest.cpp @@ -19,7 +19,7 @@ #include <gmock/gmock.h> #include <gtest/gtest.h> #include <wifi_system_test/mock_interface_tool.h> -#include "android/net/wifi/IWifiScannerImpl.h" +#include "android/net/wifi/nl80211/IWifiScannerImpl.h" #include "wificond/scanning/scanner_impl.h" #include "wificond/tests/mock_client_interface_impl.h" #include "wificond/tests/mock_netlink_manager.h" @@ -27,12 +27,12 @@ #include "wificond/tests/mock_scan_utils.h" using ::android::binder::Status; -using ::android::net::wifi::IWifiScannerImpl; +using ::android::net::wifi::nl80211::IWifiScannerImpl; +using ::android::net::wifi::nl80211::SingleScanSettings; +using ::android::net::wifi::nl80211::PnoNetwork; +using ::android::net::wifi::nl80211::PnoSettings; +using ::android::net::wifi::nl80211::NativeScanResult; using ::android::wifi_system::MockInterfaceTool; -using ::com::android::server::wifi::wificond::SingleScanSettings; -using ::com::android::server::wifi::wificond::PnoNetwork; -using ::com::android::server::wifi::wificond::PnoSettings; -using ::com::android::server::wifi::wificond::NativeScanResult; using ::testing::Eq; using ::testing::Invoke; using ::testing::NiceMock; @@ -75,6 +75,7 @@ bool CaptureSchedScanIntervalSetting( const SchedScanIntervalSetting& interval_setting, int32_t /* rssi_threshold_2g */, int32_t /* rssi_threshold_5g */, + int32_t /* rssi_threshold_6g */, const SchedScanReqFlags& /* req_flags */, const std::vector<std::vector<uint8_t>>& /* scan_ssids */, const std::vector<std::vector<uint8_t>>& /* match_ssids */, @@ -90,6 +91,7 @@ bool CaptureSchedScanReqFlags( const SchedScanIntervalSetting& /* interval_setting */, int32_t /* rssi_threshold_2g */, int32_t /* rssi_threshold_5g */, + int32_t /* rssi_threshold_6g */, const SchedScanReqFlags& req_flags, const std::vector<std::vector<uint8_t>>& /* scan_ssids */, const std::vector<std::vector<uint8_t>>& /* match_ssids */, @@ -231,7 +233,7 @@ TEST_F(ScannerTest, TestSingleScanFailure) { EXPECT_FALSE(success); } -TEST_F(ScannerTest, TestProcessAbortsOnScanReturningNoDeviceError) { +TEST_F(ScannerTest, TestProcessAbortsOnScanReturningNoDeviceErrorSeveralTimes) { scanner_impl_.reset(new ScannerImpl(kFakeInterfaceIndex, scan_capabilities_, wiphy_features_, &client_interface_impl_, @@ -243,8 +245,14 @@ TEST_F(ScannerTest, TestProcessAbortsOnScanReturningNoDeviceError) { ReturnErrorCodeForScanRequest, ENODEV, _1, _2, _3, _4, _5, _6))); - bool success_ignored; - EXPECT_DEATH(scanner_impl_->scan(SingleScanSettings(), &success_ignored), + bool single_scan_failure; + EXPECT_TRUE(scanner_impl_->scan(SingleScanSettings(), &single_scan_failure).isOk()); + EXPECT_FALSE(single_scan_failure); + EXPECT_TRUE(scanner_impl_->scan(SingleScanSettings(), &single_scan_failure).isOk()); + EXPECT_FALSE(single_scan_failure); + EXPECT_TRUE(scanner_impl_->scan(SingleScanSettings(), &single_scan_failure).isOk()); + EXPECT_FALSE(single_scan_failure); + EXPECT_DEATH(scanner_impl_->scan(SingleScanSettings(), &single_scan_failure), "Driver is in a bad state*"); } @@ -290,7 +298,7 @@ TEST_F(ScannerTest, TestStartPnoScanViaNetlink) { &scan_utils_); EXPECT_CALL( scan_utils_, - StartScheduledScan(_, _, _, _, _, _, _, _, _)). + StartScheduledScan(_, _, _, _, _, _, _, _, _, _)). WillOnce(Return(true)); EXPECT_TRUE(scanner_impl.startPnoScan(PnoSettings(), &success).isOk()); EXPECT_TRUE(success); @@ -305,10 +313,10 @@ TEST_F(ScannerTest, TestStartPnoScanViaNetlinkWithLowPowerScanWiphySupport) { SchedScanReqFlags req_flags = {}; EXPECT_CALL( scan_utils_, - StartScheduledScan(_, _, _, _, _, _, _, _, _)). + StartScheduledScan(_, _, _, _, _, _, _, _, _, _)). WillOnce(Invoke(bind( CaptureSchedScanReqFlags, - _1, _2, _3, _4, _5, _6, _7, _8, _9, &req_flags))); + _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, &req_flags))); EXPECT_TRUE(scanner_impl.startPnoScan(PnoSettings(), &success).isOk()); EXPECT_TRUE(success); EXPECT_TRUE(req_flags.request_low_power); @@ -348,10 +356,10 @@ TEST_F(ScannerTest, TestGenerateScanPlansIfDeviceSupports) { SchedScanIntervalSetting interval_setting; EXPECT_CALL( scan_utils_, - StartScheduledScan(_, _, _, _, _, _, _, _, _)). + StartScheduledScan(_, _, _, _, _, _, _, _, _, _)). WillOnce(Invoke(bind( CaptureSchedScanIntervalSetting, - _1, _2, _3, _4, _5, _6, _7, _8, _9, &interval_setting))); + _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, &interval_setting))); bool success_ignored = 0; EXPECT_TRUE(scanner.startPnoScan(pno_settings, &success_ignored).isOk()); @@ -381,10 +389,11 @@ TEST_F(ScannerTest, TestGenerateSingleIntervalIfDeviceDoesNotSupportScanPlan) { SchedScanIntervalSetting interval_setting; EXPECT_CALL( scan_utils_, - StartScheduledScan(_, _, _, _, _, _, _, _, _)). + StartScheduledScan(_, _, _, _, _, _, _, _, _, _)). WillOnce(Invoke(bind( CaptureSchedScanIntervalSetting, - _1, _2, _3, _4, _5, _6, _7, _8, _9, &interval_setting))); + _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, + &interval_setting))); bool success_ignored = 0; EXPECT_TRUE(scanner.startPnoScan(pno_settings, &success_ignored).isOk()); @@ -430,7 +439,7 @@ TEST_F(ScannerTest, TestStartPnoScanWithNonEmptyFrequencyList) { expected_freqs.push_back(2412); EXPECT_CALL( scan_utils_, - StartScheduledScan(_, _, _, _, _, _, _, Eq(expected_freqs), _)). + StartScheduledScan(_, _, _, _, _, _, _, _, Eq(expected_freqs), _)). WillOnce(Return(true)); EXPECT_TRUE(scanner_impl.startPnoScan(pno_settings, &success).isOk()); EXPECT_TRUE(success); @@ -469,7 +478,7 @@ TEST_F(ScannerTest, TestStartPnoScanWithFrequencyListNoDuplicates) { expected_freqs.push_back(2462); EXPECT_CALL( scan_utils_, - StartScheduledScan(_, _, _, _, _, _, _, Eq(expected_freqs), _)). + StartScheduledScan(_, _, _, _, _, _, _, _, Eq(expected_freqs), _)). WillOnce(Return(true)); EXPECT_TRUE(scanner_impl.startPnoScan(pno_settings, &success).isOk()); EXPECT_TRUE(success); @@ -505,7 +514,7 @@ TEST_F(ScannerTest, TestStartPnoScanWithFrequencyListFallbackMechanism) { vector<uint32_t> expected_frequencies(default_frequencies.begin(), default_frequencies.end()); EXPECT_CALL( scan_utils_, - StartScheduledScan(_, _, _, _, _, _, _, Eq(expected_frequencies), _)). + StartScheduledScan(_, _, _, _, _, _, _, _, Eq(expected_frequencies), _)). WillOnce(Return(true)); EXPECT_TRUE(scanner_impl.startPnoScan(pno_settings, &success).isOk()); EXPECT_TRUE(success); @@ -535,7 +544,7 @@ TEST_F(ScannerTest, TestStartPnoScanEmptyList) { pno_settings.pno_networks_.push_back(network2); EXPECT_CALL( scan_utils_, - StartScheduledScan(_, _, _, _, _, _, _, Eq(vector<uint32_t>{}), _)). + StartScheduledScan(_, _, _, _, _, _, _, _, Eq(vector<uint32_t>{}), _)). WillOnce(Return(true)); EXPECT_TRUE(scanner_impl.startPnoScan(pno_settings, &success).isOk()); EXPECT_TRUE(success); diff --git a/tests/server_unittest.cpp b/tests/server_unittest.cpp index 2175cf9..68f1429 100644 --- a/tests/server_unittest.cpp +++ b/tests/server_unittest.cpp @@ -21,14 +21,14 @@ #include <gtest/gtest.h> #include <wifi_system_test/mock_interface_tool.h> -#include "android/net/wifi/IApInterface.h" +#include "android/net/wifi/nl80211/IApInterface.h" #include "wificond/tests/mock_netlink_manager.h" #include "wificond/tests/mock_netlink_utils.h" #include "wificond/tests/mock_scan_utils.h" #include "wificond/server.h" -using android::net::wifi::IApInterface; -using android::net::wifi::IClientInterface; +using android::net::wifi::nl80211::IApInterface; +using android::net::wifi::nl80211::IClientInterface; using android::wifi_system::InterfaceTool; using android::wifi_system::MockInterfaceTool; using std::unique_ptr; |
