wificond: Fix unit test failures

Bug: 130244585
Test: ./system/connectivity/wificond/runtests.sh
Change-Id: I05fa9e0d98a867bb3eacda355c531f686b3a44d8
This commit is contained in:
Roshan Pius 2019-04-24 13:12:15 -07:00
parent a5a61a8327
commit dba3887733
3 changed files with 5 additions and 16 deletions

View File

@ -30,6 +30,8 @@ class MockNetlinkUtils : public NetlinkUtils {
~MockNetlinkUtils() override = default;
MOCK_METHOD1(GetWiphyIndex, bool(uint32_t* out_wiphy_index));
MOCK_METHOD2(GetWiphyIndex,
bool(uint32_t* out_wiphy_index, const std::string& iface_name));
MOCK_METHOD1(UnsubscribeMlmeEvent, void(uint32_t interface_index));
MOCK_METHOD1(UnsubscribeRegDomainChange, void(uint32_t wiphy_index));
MOCK_METHOD1(UnsubscribeStationEvent, void(uint32_t interface_index));

View File

@ -351,19 +351,15 @@ TEST_F(ScannerTest, TestStartPnoScanViaNetlinkWithLowPowerScanWiphySupport) {
wiphy_features_, &client_interface_impl_,
&scan_utils_, offload_service_utils_);
SchedScanReqFlags req_flags = {};
ON_CALL(
scan_utils_,
StartScheduledScan(_, _, _, _, _, _, _, _, _)).
WillByDefault(Return(true));
EXPECT_CALL(
scan_utils_,
StartScheduledScan(_, _, _, _, _, _, _, _, _)).
WillOnce(Invoke(bind(
CaptureSchedScanReqFlags,
_1, _2, _3, _4, _5, _6, _7, _8, _9, &req_flags)));
EXPECT_TRUE(req_flags.request_low_power);
EXPECT_TRUE(scanner_impl.startPnoScan(PnoSettings(), &success).isOk());
EXPECT_TRUE(success);
EXPECT_TRUE(req_flags.request_low_power);
}
TEST_F(ScannerTest, TestStopPnoScanViaNetlink) {

View File

@ -80,6 +80,7 @@ class ServerTest : public ::testing::Test {
void SetUp() override {
ON_CALL(*if_tool_, SetUpState(_, _)).WillByDefault(Return(true));
ON_CALL(*netlink_utils_, GetWiphyIndex(_)).WillByDefault(Return(true));
ON_CALL(*netlink_utils_, GetWiphyIndex(_, _)).WillByDefault(Return(true));
ON_CALL(*netlink_utils_, GetInterfaces(_, _))
.WillByDefault(Invoke(bind(
MockGetInterfacesResponse, mock_interfaces, true, _1, _2)));
@ -155,9 +156,6 @@ TEST_F(ServerTest, CanDestroyInterfaces) {
TEST_F(ServerTest, CanTeardownApInterface) {
sp<IApInterface> ap_if;
// When we tear down the interface, we expect the iface to be unloaded.
EXPECT_CALL(*if_tool_, SetUpState(StrEq(kFakeInterfaceName), Eq(false)));
EXPECT_TRUE(server_.createApInterface(kFakeInterfaceName, &ap_if).isOk());
EXPECT_NE(nullptr, ap_if.get());
@ -174,9 +172,6 @@ TEST_F(ServerTest, CanTeardownApInterface) {
TEST_F(ServerTest, CanTeardownClientInterface) {
sp<IClientInterface> client_if;
// When we tear down the interface, we expect the iface to be unloaded.
EXPECT_CALL(*if_tool_, SetUpState(StrEq(kFakeInterfaceName), Eq(false)));
EXPECT_TRUE(server_.createClientInterface(
kFakeInterfaceName, &client_if).isOk());
EXPECT_NE(nullptr, client_if.get());
@ -202,10 +197,6 @@ TEST_F(ServerTest, CanCreateTeardownApAndClientInterface) {
EXPECT_TRUE(server_.createApInterface(kFakeInterfaceName1, &ap_if).isOk());
EXPECT_NE(nullptr, ap_if.get());
// When we tear down the interfaces, we expect the iface to be unloaded.
EXPECT_CALL(*if_tool_, SetUpState(StrEq(kFakeInterfaceName), Eq(false)));
EXPECT_CALL(*if_tool_, SetUpState(StrEq(kFakeInterfaceName1), Eq(false)));
bool success = true;
// Try to remove an invalid iface name, this should fail.
EXPECT_TRUE(server_.tearDownClientInterface(