~timo-jyrinki/ubuntu/trusty/maliit-framework/fix_qt52

« back to all changes in this revision

Viewing changes to tests/ut_maliit_glib_settings/mockmaliitserver.c

  • Committer: Package Import Robot
  • Author(s): Ricardo Salveti de Araujo, Sergio Schvezov, Ricardo Salveti de Araujo
  • Date: 2013-07-23 19:47:04 UTC
  • mfrom: (1.1.2) (1.2.1 experimental)
  • Revision ID: package-import@ubuntu.com-20130723194704-1lsy1kmlda069cea
Tags: 0.99.0+git20130615+97e8335-0ubuntu1
[ Sergio Schvezov ]
* New build from HEAD 97e8335.
* Packaging import from lp:phablet-extras/maliit-framework.

[ Ricardo Salveti de Araujo ]
* debian/control: adding vcs and fixing dependencies
* General package cleanup

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/* This file is part of Maliit framework
2
 
 *
3
 
 * Copyright (C) 2012 Openismus GmbH
4
 
 *
5
 
 * Contact: maliit-discuss@lists.maliit.org
6
 
 *
7
 
 * This library is free software; you can redistribute it and/or
8
 
 * modify it under the terms of the GNU Lesser General Public
9
 
 * License as published by the Free Software Foundation; either
10
 
 * version 2.1 of the licence, or (at your option) any later version.
11
 
 *
12
 
 * This library is distributed in the hope that it will be useful,
13
 
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14
 
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
15
 
 * Lesser General Public License for more details.
16
 
 *
17
 
 * You should have received a copy of the GNU Lesser General Public
18
 
 * License along with this library; if not, write to the
19
 
 * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
20
 
 * Boston, MA 02111-1307, USA.
21
 
 */
22
 
 
23
 
#include "mockmaliitserver.h"
24
 
 
25
 
#include <connection-glib/meego-im-connector.h>
26
 
#include <connection-glib/meego-im-connector-private.h>
27
 
#include <connection-glib/meego-imcontext-dbus-private.h>
28
 
 
29
 
static MockMaliitServer *global_server_instance = NULL;
30
 
 
31
 
struct _MockMaliitServerPriv {
32
 
    MeegoImConnector *connector;
33
 
};
34
 
 
35
 
/* Record the call, and respond with a list of settings */
36
 
gboolean
37
 
load_plugin_settings (MeegoIMProxy *proxy G_GNUC_UNUSED,
38
 
                      const gchar *locale_name G_GNUC_UNUSED)
39
 
{
40
 
    MockMaliitServer *self = global_server_instance;
41
 
 
42
 
    self->load_plugin_settings_called = TRUE;
43
 
    meego_imcontext_dbus_plugin_settings_loaded(self->priv->connector->dbusobj, self->settings, NULL);
44
 
    return TRUE;
45
 
}
46
 
 
47
 
MockMaliitServer *
48
 
mock_maliit_server_new()
49
 
{
50
 
    MockMaliitServer *self = g_new(MockMaliitServer, 1);
51
 
    self->priv = g_new(MockMaliitServerPriv, 1);
52
 
 
53
 
    self->load_plugin_settings_called = FALSE;
54
 
    self->priv->connector = meego_im_connector_new();
55
 
    self->priv->connector->try_reconnect = FALSE;
56
 
    meego_im_connector_set_singleton(self->priv->connector);
57
 
    self->priv->connector->proxy->load_plugin_settings_observer = load_plugin_settings;
58
 
    self->settings = NULL;
59
 
 
60
 
    g_assert(!global_server_instance); // XXX: cannot use multiple instances at the same time
61
 
    global_server_instance = self;
62
 
    return self;
63
 
}
64
 
 
65
 
void
66
 
mock_maliit_server_free(MockMaliitServer *self)
67
 
{
68
 
    meego_im_connector_free(self->priv->connector);
69
 
    meego_im_connector_set_singleton(NULL);
70
 
 
71
 
    g_free(self->priv);
72
 
    g_free(self);
73
 
 
74
 
    g_assert(global_server_instance == self); // XXX: cannot use multiple instances at the same time
75
 
    global_server_instance = NULL;
76
 
}
77
 
 
78
 
/* Fake the MeegoIMProxy::connection-established signal that connecting to maliit-server will emit */
79
 
void
80
 
mock_maliit_server_emulate_connect(MockMaliitServer *self)
81
 
{
82
 
    g_signal_emit_by_name(self->priv->connector->proxy, "connection-established");
83
 
}
84
 
 
85
 
/* Fake the MeegoIMProxy::connection-dropped signal that disconnecting to maliit-server will emit */
86
 
void
87
 
mock_maliit_server_emulate_disconnect(MockMaliitServer *self)
88
 
{
89
 
    g_signal_emit_by_name(self->priv->connector->proxy, "connection-dropped");
90
 
}