1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
|
// -*- Mode: C++; indent-tabs-mode: nil; tab-width: 2 -*-
/*
* Copyright 2012 Canonical Ltd.
*
* This program is free software: you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License version 3, as
* published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranties of
* MERCHANTABILITY, SATISFACTORY QUALITY or FITNESS FOR A PARTICULAR
* PURPOSE. See the applicable version of the GNU Lesser General Public
* License for more details.
*
* You should have received a copy of both the GNU Lesser General Public
* License version 3 along with this program. If not, see
* <http://www.gnu.org/licenses/>
*
* Authored by: Andrea Azzarone <andrea.azzarone@canonical.com>
*
*/
#ifndef TEST_MOCK_DEVICES_H
#define TEST_MOCK_DEVICES_H
#include <gmock/gmock.h>
#include "DeviceLauncherSection.h"
#include "AbstractVolumeMonitorWrapper.h"
#include "Volume.h"
#include "gmockvolume.h"
using namespace unity::launcher;
namespace unity
{
namespace
{
struct MockVolumeMonitorWrapper : public AbstractVolumeMonitorWrapper
{
typedef std::shared_ptr<MockVolumeMonitorWrapper> Ptr;
MockVolumeMonitorWrapper(unsigned size = 2)
{
for (unsigned i = 0; i < size; ++i)
{
glib::Object<GVolume> volume(G_VOLUME(g_mock_volume_new()));
volumes_.push_back(volume);
}
}
VolumeList GetVolumes() { return volumes_; }
VolumeList volumes_;
};
struct MockDevicesSettings : DevicesSettings
{
typedef std::shared_ptr<MockDevicesSettings> Ptr;
typedef testing::NiceMock<MockDevicesSettings> Nice;
MOCK_CONST_METHOD1(IsABlacklistedDevice, bool(std::string const& uuid));
MOCK_METHOD1(TryToBlacklist, void(std::string const& uuid));
MOCK_METHOD1(TryToUnblacklist, void(std::string const& uuid));
};
struct MockDeviceLauncherSection : DeviceLauncherSection
{
MockDeviceLauncherSection(unsigned size = 2)
: DeviceLauncherSection(MockVolumeMonitorWrapper::Ptr(new testing::NiceMock<MockVolumeMonitorWrapper>(size)),
DevicesSettings::Ptr(new testing::NiceMock<MockDevicesSettings>))
{}
};
struct MockVolume : Volume
{
typedef std::shared_ptr<MockVolume> Ptr;
typedef testing::NiceMock<MockVolume> Nice;
MOCK_CONST_METHOD0(CanBeRemoved, bool(void));
MOCK_CONST_METHOD0(CanBeStopped, bool(void));
MOCK_CONST_METHOD0(GetName, std::string(void));
MOCK_CONST_METHOD0(GetIconName, std::string(void));
MOCK_CONST_METHOD0(GetIdentifier, std::string(void));
MOCK_CONST_METHOD0(GetUri, std::string(void));
MOCK_CONST_METHOD0(HasSiblings, bool(void));
MOCK_CONST_METHOD0(CanBeEjected, bool(void));
MOCK_CONST_METHOD0(IsMounted, bool(void));
MOCK_METHOD0(Eject, void());
MOCK_METHOD0(Mount, void());
MOCK_METHOD0(StopDrive, void(void));
MOCK_METHOD0(Unmount, void(void));
};
struct MockDeviceNotificationDisplay : DeviceNotificationDisplay
{
typedef std::shared_ptr<MockDeviceNotificationDisplay> Ptr;
typedef testing::NiceMock<MockDeviceNotificationDisplay> Nice;
MOCK_METHOD2(Display, void(std::string const& icon_name, std::string const& volume_name));
};
} // anonymous namespace
} // unity namespace
#endif
|