summaryrefslogtreecommitdiff
path: root/tests/libtracker-miner/thumbnailer-mock.c
blob: 880f56fd9745bec629fcb7bc41eb2cc3b503e67a (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
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
/*
 * Copyright (C) 2010, Nokia <ivan.frade@nokia.com>
 *
 * This program is free software; you can redistribute it and/or
 * modify it under the terms of the GNU General Public License
 * as published by the Free Software Foundation; either version 2
 * of the License, or (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY 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, write to the Free Software
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
 * 02110-1301, USA.
 */

#include <glib-object.h>
#include <gobject/gvaluecollector.h>

#include "empty-gobject.h"
#include "thumbnailer-mock.h"

static GList *calls = NULL;

void
dbus_mock_call_log_reset ()
{
	if (calls) {
		g_list_foreach (calls, (GFunc)g_free, NULL);
		g_list_free (calls);
		calls = NULL;
	}
}

GList *
dbus_mock_call_log_get ()
{
	return calls;
}

#if 0

static void
dbus_mock_call_log_append (const gchar *function_name)
{
	calls = g_list_append (calls, g_strdup (function_name));
}


/* Port to gdbus */
/*
 * DBus overrides
 */

DBusGConnection *
dbus_g_bus_get (DBusBusType type, GError **error)
{
	return (DBusGConnection *) empty_object_new ();
}

DBusGProxy *
dbus_g_proxy_new_for_name (DBusGConnection *connection,
                           const gchar *service,
                           const gchar *path,
                           const gchar *interface )
{
	return (DBusGProxy *) empty_object_new ();
}

gboolean
dbus_g_proxy_call (DBusGProxy *proxy,
                   const gchar *function_name,
                   GError  **error,
                   GType first_arg_type, ...)
{
	va_list args;
	GType arg_type;
	const gchar *supported_mimes[] = { "mock/one", "mock/two", NULL};
	int     counter;

	g_assert (g_strcmp0 (function_name, "GetSupported") == 0);

	/*
	  G_TYPE_INVALID,
	  G_TYPE_STRV, &uri_schemes,
	  G_TYPE_STRV, &mime_types,
	  G_TYPE_INVALID);

	  Set the mock values in the second parameter :)
	*/

	va_start (args, first_arg_type);
	arg_type = va_arg (args, GType);

	counter = 1;
	while (arg_type != G_TYPE_INVALID) {

		if (arg_type == G_TYPE_STRV && counter == 2) {
			gchar *local_error = NULL;
			GValue value = { 0, };
			g_value_init (&value, arg_type);
			g_value_set_boxed (&value, supported_mimes);
			G_VALUE_LCOPY (&value,
			               args, 0,
			               &local_error);
			g_free (local_error);
			g_value_unset (&value);
		} else {
			gpointer *out_param;
			out_param = va_arg (args, gpointer *);
		}
		arg_type = va_arg (args, GType);
		counter += 1;
	}

	va_end (args);
	return TRUE;
}


void
dbus_g_proxy_call_no_reply (DBusGProxy        *proxy,
                            const char        *method,
                            GType              first_arg_type,
                            ...)
{
	dbus_mock_call_log_append (method);
}
#endif