1
/* This file is part of Maliit framework
3
* Copyright (C) 2012 Openismus GmbH
5
* Contact: maliit-discuss@lists.maliit.org
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.
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.
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.
23
#include "mockmaliitserver.h"
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>
29
static MockMaliitServer *global_server_instance = NULL;
31
struct _MockMaliitServerPriv {
32
MeegoImConnector *connector;
35
/* Record the call, and respond with a list of settings */
37
load_plugin_settings (MeegoIMProxy *proxy G_GNUC_UNUSED,
38
const gchar *locale_name G_GNUC_UNUSED)
40
MockMaliitServer *self = global_server_instance;
42
self->load_plugin_settings_called = TRUE;
43
meego_imcontext_dbus_plugin_settings_loaded(self->priv->connector->dbusobj, self->settings, NULL);
48
mock_maliit_server_new()
50
MockMaliitServer *self = g_new(MockMaliitServer, 1);
51
self->priv = g_new(MockMaliitServerPriv, 1);
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;
60
g_assert(!global_server_instance); // XXX: cannot use multiple instances at the same time
61
global_server_instance = self;
66
mock_maliit_server_free(MockMaliitServer *self)
68
meego_im_connector_free(self->priv->connector);
69
meego_im_connector_set_singleton(NULL);
74
g_assert(global_server_instance == self); // XXX: cannot use multiple instances at the same time
75
global_server_instance = NULL;
78
/* Fake the MeegoIMProxy::connection-established signal that connecting to maliit-server will emit */
80
mock_maliit_server_emulate_connect(MockMaliitServer *self)
82
g_signal_emit_by_name(self->priv->connector->proxy, "connection-established");
85
/* Fake the MeegoIMProxy::connection-dropped signal that disconnecting to maliit-server will emit */
87
mock_maliit_server_emulate_disconnect(MockMaliitServer *self)
89
g_signal_emit_by_name(self->priv->connector->proxy, "connection-dropped");