aboutsummaryrefslogtreecommitdiff
path: root/tests/backend-dbus/mock-consolekit-seat.h
blob: aa52276a4ff8e1c2487b8ec4a53582d0f241f793 (plain)
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
/*
 * Copyright 2013 Canonical Ltd.
 *
 * Authors:
 *   Charles Kerr <charles.kerr@canonical.com>
 *
 * This program is free software: you can redistribute it and/or modify it
 * under the terms of the GNU 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 GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License along
 * with this program.  If not, see <http://www.gnu.org/licenses/>.
 */

#ifndef MOCK_CONSOLEKIT_SEAT_H
#define MOCK_CONSOLEKIT_SEAT_H

#include <set>
#include <string>
#include "backend-dbus/dbus-consolekit-seat.h"
#include "mock-object.h"

class MockUser;
class MockConsoleKitSession;

class MockConsoleKitSeat: public MockObject
{
  public:

    MockConsoleKitSeat (GMainLoop       * loop,
                        GDBusConnection * bus_connection,
                        bool              can_activate_sessions);
    virtual ~MockConsoleKitSeat ();

    const char * sid() { return path(); }
    MockConsoleKitSession * add_session_by_user (MockUser * user);
    void add_session (MockConsoleKitSession * session);
    void remove_session (MockConsoleKitSession * session);
    void activate_session (MockConsoleKitSession * session);
    void switch_to_guest ();
    void switch_to_user (const char * username);
    bool can_activate_sessions () const { return my_can_activate_sessions; }
    MockConsoleKitSession * find (const char * ssid);

  private:

    static gboolean on_get_active_session (ConsoleKitSeat        * cks,
                                           GDBusMethodInvocation * inv,
                                           gpointer                gself);
    static gboolean on_get_sessions (ConsoleKitSeat         * cks,
                                     GDBusMethodInvocation  * inv,
                                     gpointer                 gself);
    static gboolean on_can_activate_sessions (ConsoleKitSeat        * cks,
                                              GDBusMethodInvocation * inv,
                                              gpointer                gself);


  private:

    ConsoleKitSeat * my_skeleton;

    std::string my_active_ssid;

    typedef std::set<MockConsoleKitSession*> sessions_t;
    sessions_t my_sessions;
    bool my_can_activate_sessions;

};

#endif // #ifndef MOCK_CONSOLEKIT_SEAT_H