2
* Copyright 2013 Canonical Ltd.
5
* Charles Kerr <charles.kerr@canonical.com>
7
* This program is free software: you can redistribute it and/or modify it
8
* under the terms of the GNU General Public License version 3, as published
9
* by the Free Software Foundation.
11
* This program is distributed in the hope that it will be useful, but
12
* WITHOUT ANY WARRANTY; without even the implied warranties of
13
* MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR
14
* PURPOSE. See the GNU General Public License for more details.
16
* You should have received a copy of the GNU General Public License along
17
* with this program. If not, see <http://www.gnu.org/licenses/>.
20
#include "gtest-dbus-fixture.h"
22
#include "mock-accounts.h"
23
#include "mock-consolekit-manager.h"
24
#include "mock-consolekit-seat.h"
25
#include "mock-consolekit-session.h"
26
#include "mock-display-manager-seat.h"
27
#include "mock-end-session-dialog.h"
28
#include "mock-screen-saver.h"
29
#include "mock-session-manager.h"
30
#include "mock-upower.h"
31
#include "mock-user.h"
32
#include "mock-webcredentials.h"
38
class GTestMockDBusFixture: public GTestDBusFixture
42
typedef GTestDBusFixture super;
46
MockScreenSaver * screen_saver;
47
MockSessionManager * session_manager;
48
MockDisplayManagerSeat * dm_seat;
49
MockAccounts * accounts;
50
MockConsoleKitSession * ck_session;
51
MockConsoleKitSeat * ck_seat;
52
MockConsoleKitManager * ck_manager;
54
MockEndSessionDialog * end_session_dialog;
55
MockWebcredentials * webcredentials;
63
webcredentials = new MockWebcredentials (loop, conn);
64
end_session_dialog = new MockEndSessionDialog (loop, conn);
65
session_manager = new MockSessionManager (loop, conn);
66
screen_saver = new MockScreenSaver (loop, conn);
67
upower = new MockUPower (loop, conn);
68
dm_seat = new MockDisplayManagerSeat (loop, conn);
69
g_setenv ("XDG_SEAT_PATH", dm_seat->path(), TRUE);
70
dm_seat->set_guest_allowed (false);
71
accounts = build_accounts_mock ();
72
ck_manager = new MockConsoleKitManager (loop, conn);
73
ck_seat = new MockConsoleKitSeat (loop, conn, true);
74
MockUser * user = accounts->find_by_username ("msmith");
75
ck_session = ck_seat->add_session_by_user (user);
76
ck_manager->add_seat (ck_seat);
77
dm_seat->set_consolekit_seat (ck_seat);
78
dm_seat->switch_to_user (user->username());
79
ASSERT_EQ (ck_session, ck_manager->current_session());
84
virtual void TearDown ()
91
delete session_manager;
92
delete end_session_dialog;
93
delete webcredentials;
100
MockAccounts * build_accounts_mock ()
103
guint64 login_frequency;
104
const gchar * user_name;
105
const gchar * real_name;
107
{ 134, "whartnell", "First Doctor" },
108
{ 119, "ptroughton", "Second Doctor" },
109
{ 128, "jpertwee", "Third Doctor" },
110
{ 172, "tbaker", "Fourth Doctor" },
111
{ 69, "pdavison", "Fifth Doctor" },
112
{ 31, "cbaker", "Sixth Doctor" },
113
{ 42, "smccoy", "Seventh Doctor" },
114
{ 1, "pmcgann", "Eigth Doctor" },
115
{ 13, "ceccleston", "Ninth Doctor" },
116
{ 47, "dtennant", "Tenth Doctor" },
117
{ 34, "msmith", "Eleventh Doctor" },
118
{ 1, "rhurndall", "First Doctor" }
121
MockAccounts * a = new MockAccounts (loop, conn);
122
for (int i=0, n=G_N_ELEMENTS(users); i<n; ++i)
123
a->add_user (new MockUser (loop, conn,
126
users[i].login_frequency));