2
* Copyright (C) 2015 Canonical, Ltd.
4
* This program is free software: you can redistribute it and/or modify it
5
* under the terms of the GNU General Public License version 3, as published
6
* by the Free Software Foundation.
8
* This program is distributed in the hope that it will be useful, but
9
* WITHOUT ANY WARRANTY; without even the implied warranties of
10
* MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR
11
* PURPOSE. See the GNU General Public License for more details.
13
* You should have received a copy of the GNU General Public License along
14
* with this program. If not, see <http://www.gnu.org/licenses/>.
20
#include <gtest/gtest.h>
21
#include <gmock/gmock.h>
23
#include <core/posix/fork.h>
25
#include <common/glibhelpers.h>
26
#include <common/dbusfixture.h>
27
#include <common/dbusnameowner.h>
29
#include <mcs/keep_alive.h>
30
#include <w11tng/interfacestub.h>
32
#include "interfaceskeleton.h"
35
class InterfaceStubFixture : public ::testing::Test,
36
public mcs::testing::DBusFixture,
37
public mcs::testing::DBusNameOwner {
39
InterfaceStubFixture() :
40
mcs::testing::DBusNameOwner("fi.w1.wpa_supplicant1") {
44
class MockInterfaceStubDelegate : public w11tng::InterfaceStub::Delegate {
46
MOCK_METHOD0(OnInterfaceReady, void());
50
TEST_F(InterfaceStubFixture, ConstructionAndProperties) {
52
auto skeleton = std::make_shared<w11tng::testing::InterfaceSkeleton>("/interface_1");
54
auto delegate = std::make_shared<MockInterfaceStubDelegate>();
56
EXPECT_CALL(*delegate, OnInterfaceReady()).Times(1);
58
auto stub = w11tng::InterfaceStub::Create("/interface_1");
60
stub->SetDelegate(delegate);
62
mcs::testing::RunMainLoop(std::chrono::seconds{1});
64
EXPECT_EQ(stub->Capabilities().size(), 0);
65
EXPECT_EQ(stub->Driver(), "");
66
EXPECT_EQ(stub->Ifname(), "");
68
skeleton->SetDriver("nl80211");
69
skeleton->SetIfname("wlan0");
71
mcs::testing::RunMainLoop(std::chrono::seconds{1});
73
EXPECT_EQ(stub->Driver(), "nl80211");
74
EXPECT_EQ(stub->Ifname(), "wlan0");