~ci-train-bot/indicator-session/indicator-session-ubuntu-zesty-2188

« back to all changes in this revision

Viewing changes to tests/backend-dbus/mock-screen-saver.cc

  • Committer: Charles Kerr
  • Date: 2013-03-22 21:34:34 UTC
  • mto: (384.2.29 ng)
  • mto: This revision was merged to the branch mainline in revision 399.
  • Revision ID: charles.kerr@canonical.com-20130322213434-a85qbob8bi4fvfx2
port indicator-session to GMenu/cmake. Code coverage increased from 0% to 95.4%.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
 * Copyright 2013 Canonical Ltd.
 
3
 *
 
4
 * Authors:
 
5
 *   Charles Kerr <charles.kerr@canonical.com>
 
6
 *
 
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.
 
10
 *
 
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.
 
15
 *
 
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/>.
 
18
 */
 
19
 
 
20
#include "mock-screen-saver.h"
 
21
 
 
22
 
 
23
gboolean
 
24
MockScreenSaver :: handle_lock (GnomeScreenSaver      * ss,
 
25
                                GDBusMethodInvocation * inv,
 
26
                                gpointer                gself)
 
27
{
 
28
  static_cast<MockScreenSaver*>(gself)->my_last_action = Lock;
 
29
  gnome_screen_saver_complete_lock (ss, inv);
 
30
  return true;
 
31
}
 
32
 
 
33
gboolean
 
34
MockScreenSaver :: handle_simulate_user_activity (GnomeScreenSaver      * ss,
 
35
                                                  GDBusMethodInvocation * inv,
 
36
                                                  gpointer                gself)
 
37
{
 
38
  static_cast<MockScreenSaver*>(gself)->my_last_action = UserActivity;
 
39
  gnome_screen_saver_complete_simulate_user_activity (ss, inv);
 
40
  return true;
 
41
}
 
42
 
 
43
/***
 
44
****
 
45
***/
 
46
 
 
47
namespace
 
48
{
 
49
  const char * const SCREENSAVER_NAME = "org.gnome.ScreenSaver";
 
50
  const char * const SCREENSAVER_PATH = "/org/gnome/ScreenSaver";
 
51
 
 
52
}
 
53
 
 
54
MockScreenSaver :: MockScreenSaver (GMainLoop       * loop,
 
55
                                    GDBusConnection * bus_connection):
 
56
  MockObject (loop, bus_connection, SCREENSAVER_NAME, SCREENSAVER_PATH),
 
57
  my_skeleton (gnome_screen_saver_skeleton_new ()),
 
58
  my_last_action (None)
 
59
{
 
60
  g_signal_connect (my_skeleton, "handle-lock",
 
61
                    G_CALLBACK(handle_lock), this);
 
62
  g_signal_connect (my_skeleton, "handle-simulate-user-activity",
 
63
                    G_CALLBACK(handle_simulate_user_activity), this);
 
64
 
 
65
  set_skeleton (G_DBUS_INTERFACE_SKELETON(my_skeleton));
 
66
}
 
67
 
 
68
MockScreenSaver :: ~MockScreenSaver ()
 
69
{
 
70
  g_clear_object (&my_skeleton);
 
71
}