]> git.0d.be Git - empathy.git/blob - tests/check-helpers.c
Updated Basque translation.
[empathy.git] / tests / check-helpers.c
1 /*
2  * check-helpers.c - Source for some check helpers
3  * Copyright (C) 2007-2008 Collabora Ltd.
4  *
5  * This library is free software; you can redistribute it and/or
6  * modify it under the terms of the GNU Lesser General Public
7  * License as published by the Free Software Foundation; either
8  * version 2.1 of the License, or (at your option) any later version.
9  *
10  * This library is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
13  * Lesser General Public License for more details.
14  *
15  * You should have received a copy of the GNU Lesser General Public
16  * License along with this library; if not, write to the Free Software
17  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
18  */
19
20 #include <stdio.h>
21 #include <stdlib.h>
22
23 #include <glib/gstdio.h>
24 #include <gconf/gconf.h>
25 #include <gconf/gconf-client.h>
26
27 #include "check-helpers.h"
28
29 static gboolean expecting_critical = FALSE;
30 static gboolean received_critical  = FALSE;
31
32 static void
33 check_helper_log_critical_func (const gchar *log_damain,
34                                 GLogLevelFlags log_level,
35                                 const gchar *message,
36                                 gpointer user_data)
37 {
38
39   if (!expecting_critical)
40     {
41       fail("Unexpected critical message: %s\n", message);
42     }
43
44   g_assert (log_level & G_LOG_LEVEL_CRITICAL);
45
46   received_critical = TRUE;
47 }
48
49 gboolean
50 got_critical (void)
51 {
52   return received_critical;
53 }
54
55 void
56 expect_critical (gboolean expected)
57 {
58   expecting_critical = expected;
59   received_critical = FALSE;
60 }
61
62 void
63 check_helpers_init (void)
64 {
65   g_log_set_handler (NULL, G_LOG_LEVEL_CRITICAL,
66       check_helper_log_critical_func, NULL);
67 }