1
/* tinymail - Tiny Mail unit test
2
 * Copyright (C) 2006-2007 Philip Van Hoof <pvanhoof@gnome.org>
3
 *
4
 * This library is free software; you can redistribute it and/or
5
 * modify it under the terms of the GNU Lesser General Public
6
 * License as published by the Free Software Foundation; either
7
 * version 2 of the License, or (at your option) any later version.
8
 *
9
 * This library is distributed in the hope that it will be useful,
10
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.	 See the GNU
12
 * Lesser General Public License for more details.
13
 *
14
 * You should have received a copy of the GNU Lesser General Public
15
 * License along with self library; if not, write to the
16
 * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
17
 * Boston, MA 02110-1301, USA.
18
 */
19
20
#include "check_libtinymail.h"
21
22
#include <tny-device.h>
23
#include <device.h>
24
25
static TnyDevice *iface = NULL;
26
static gchar *str;
27
28
static void
29
tny_device_test_setup (void)
30
{
31
	iface = tny_test_device_new ();
32
33
	return;
34
}
35
36
static void 
37
tny_device_test_teardown (void)
38
{
39
	g_object_unref (G_OBJECT (iface));
40
41
	return;
42
}
43
44
/* TODO:  test signal connection_changed (hard to test) */
45
46
START_TEST (tny_device_test_is_online)
47
{
48
	tny_device_force_online (iface);
49
		
50
	str = g_strdup_printf ("Device should be online after force_online\n");
51
	fail_unless (tny_device_is_online(iface) == TRUE, str);
52
	g_free (str);
53
54
	tny_device_force_offline (iface);
55
		
56
	str = g_strdup_printf ("Device should be offline after force_online\n");
57
	fail_unless (tny_device_is_online(iface) == FALSE, str);
58
	g_free (str);
59
}
60
END_TEST
61
62
START_TEST (tny_device_test_connection_changed)
63
{
64
}
65
END_TEST
66
67
Suite *
68
create_tny_device_suite (void)
69
{
70
     Suite *s = suite_create ("Device");
71
     TCase *tc = NULL;
72
73
     tc = tcase_create ("Is Online");
74
     tcase_add_checked_fixture (tc, tny_device_test_setup, tny_device_test_teardown);
75
     tcase_add_test (tc, tny_device_test_is_online);
76
     suite_add_tcase (s, tc);
77
78
     /* Make sure test fails when signal is not received */
79
     tc = tcase_create ("Connection Changed");
80
     tcase_add_checked_fixture (tc, tny_device_test_setup, tny_device_test_teardown);
81
     tcase_add_test_raise_signal (tc, tny_device_test_connection_changed, tny_device_signals [TNY_DEVICE_CONNECTION_CHANGED]);
82
     suite_add_tcase (s, tc);
83
84
     return s;
85
}