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-login1-manager.h"
24
#include "mock-login1-seat.h"
25
#include "mock-display-manager-seat.h"
26
#include "mock-end-session-dialog.h"
27
#include "mock-screen-saver.h"
28
#include "mock-session-manager.h"
29
#include "mock-user.h"
30
#include "mock-webcredentials.h"
36
class GTestMockDBusFixture: public GTestDBusFixture
40
typedef GTestDBusFixture super;
44
MockScreenSaver * screen_saver;
45
MockSessionManager * session_manager;
46
MockDisplayManagerSeat * dm_seat;
47
MockAccounts * accounts;
48
MockLogin1Manager * login1_manager;
49
MockLogin1Seat * login1_seat;
50
MockEndSessionDialog * end_session_dialog;
51
MockWebcredentials * webcredentials;
59
webcredentials = new MockWebcredentials (loop, conn);
60
end_session_dialog = new MockEndSessionDialog (loop, conn);
61
session_manager = new MockSessionManager (loop, conn);
62
screen_saver = new MockScreenSaver (loop, conn);
63
dm_seat = new MockDisplayManagerSeat (loop, conn);
64
g_setenv ("XDG_SEAT_PATH", dm_seat->path(), TRUE);
65
dm_seat->set_guest_allowed (false);
66
login1_manager = new MockLogin1Manager (loop, conn);
67
login1_seat = new MockLogin1Seat (loop, conn, true);
68
g_setenv ("XDG_SEAT", login1_seat->seat_id(), TRUE);
69
login1_manager->add_seat (login1_seat);
70
accounts = build_accounts_mock ();
71
MockUser * user = accounts->find_by_username ("msmith");
72
const int session_tag = login1_manager->add_session (login1_seat, user);
73
dm_seat->set_login1_seat (login1_seat);
74
dm_seat->switch_to_user (user->username());
75
ASSERT_EQ (session_tag, login1_seat->active_session());
80
virtual void TearDown ()
83
delete login1_manager;
86
delete session_manager;
87
delete end_session_dialog;
88
delete webcredentials;
95
MockAccounts * build_accounts_mock ()
98
guint64 login_frequency;
99
const gchar * user_name;
100
const gchar * real_name;
102
{ 134, "whartnell", "First Doctor" },
103
{ 119, "ptroughton", "Second Doctor" },
104
{ 128, "jpertwee", "Third Doctor" },
105
{ 172, "tbaker", "Fourth Doctor" },
106
{ 69, "pdavison", "Fifth Doctor" },
107
{ 31, "cbaker", "Sixth Doctor" },
108
{ 42, "smccoy", "Seventh Doctor" },
109
{ 1, "pmcgann", "Eigth Doctor" },
110
{ 13, "ceccleston", "Ninth Doctor" },
111
{ 47, "dtennant", "Tenth Doctor" },
112
{ 34, "msmith", "Eleventh Doctor" },
113
{ 1, "rhurndall", "First Doctor" }
116
MockAccounts * a = new MockAccounts (loop, conn);
117
for (int i=0, n=G_N_ELEMENTS(users); i<n; ++i)
118
a->add_user (new MockUser (loop, conn,
121
users[i].login_frequency));