~morphis/aethercast/enable-arm64-builds

« back to all changes in this revision

Viewing changes to tests/w11tng/interfacestub_tests.cpp

  • Committer: Tarmac
  • Author(s): Simon Fels
  • Date: 2016-02-04 06:38:31 UTC
  • mfrom: (119.1.65 trunk)
  • Revision ID: tarmac-20160204063831-b6q9o8ktznevvd8x
Add a network manager implementation to use the DBus interface of wpa-supplicant.

Approved by PS Jenkins bot.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
 * Copyright (C) 2015 Canonical, Ltd.
 
3
 *
 
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.
 
7
 *
 
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.
 
12
 *
 
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/>.
 
15
 *
 
16
 */
 
17
 
 
18
#include <cstdint>
 
19
 
 
20
#include <gtest/gtest.h>
 
21
#include <gmock/gmock.h>
 
22
 
 
23
#include <core/posix/fork.h>
 
24
 
 
25
#include <common/glibhelpers.h>
 
26
#include <common/dbusfixture.h>
 
27
#include <common/dbusnameowner.h>
 
28
 
 
29
#include <mcs/keep_alive.h>
 
30
#include <w11tng/interfacestub.h>
 
31
 
 
32
#include "interfaceskeleton.h"
 
33
 
 
34
namespace {
 
35
class InterfaceStubFixture : public ::testing::Test,
 
36
                        public mcs::testing::DBusFixture,
 
37
                        public mcs::testing::DBusNameOwner {
 
38
public:
 
39
    InterfaceStubFixture() :
 
40
        mcs::testing::DBusNameOwner("fi.w1.wpa_supplicant1") {
 
41
    }
 
42
};
 
43
 
 
44
class MockInterfaceStubDelegate : public w11tng::InterfaceStub::Delegate {
 
45
public:
 
46
    MOCK_METHOD0(OnInterfaceReady, void());
 
47
};
 
48
}
 
49
 
 
50
TEST_F(InterfaceStubFixture, ConstructionAndProperties) {
 
51
 
 
52
    auto skeleton = std::make_shared<w11tng::testing::InterfaceSkeleton>("/interface_1");
 
53
 
 
54
    auto delegate = std::make_shared<MockInterfaceStubDelegate>();
 
55
 
 
56
    EXPECT_CALL(*delegate, OnInterfaceReady()).Times(1);
 
57
 
 
58
    auto stub = w11tng::InterfaceStub::Create("/interface_1");
 
59
    EXPECT_TRUE(!!stub);
 
60
    stub->SetDelegate(delegate);
 
61
 
 
62
    mcs::testing::RunMainLoop(std::chrono::seconds{1});
 
63
 
 
64
    EXPECT_EQ(stub->Capabilities().size(), 0);
 
65
    EXPECT_EQ(stub->Driver(), "");
 
66
    EXPECT_EQ(stub->Ifname(), "");
 
67
 
 
68
    skeleton->SetDriver("nl80211");
 
69
    skeleton->SetIfname("wlan0");
 
70
 
 
71
    mcs::testing::RunMainLoop(std::chrono::seconds{1});
 
72
 
 
73
    EXPECT_EQ(stub->Driver(), "nl80211");
 
74
    EXPECT_EQ(stub->Ifname(), "wlan0");
 
75
}