File: tny-device-test.c

package info (click to toggle)
libtinymail 0.0.9-4
  • links: PTS
  • area: main
  • in suites: lenny
  • size: 18,148 kB
  • ctags: 19,175
  • sloc: ansic: 151,565; xml: 20,145; sh: 9,245; makefile: 2,394; cs: 243; cpp: 141; python: 93; perl: 71
file content (84 lines) | stat: -rw-r--r-- 2,358 bytes parent folder | download
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
/* tinymail - Tiny Mail unit test
 * Copyright (C) 2006-2007 Philip Van Hoof <pvanhoof@gnome.org>
 *
 * 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 self program; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 */

#include "check_libtinymail.h"

#include <tny-device.h>
#include <device.h>

static TnyDevice *iface = NULL;
static gchar *str;

static void
tny_device_test_setup (void)
{
	iface = tny_test_device_new ();

	return;
}

static void 
tny_device_test_teardown (void)
{
	g_object_unref (G_OBJECT (iface));

	return;
}

/* TODO:  test signal connection_changed (hard to test) */

START_TEST (tny_device_test_is_online)
{
	tny_device_force_online (iface);
		
	str = g_strdup_printf ("Device should be online after force_online\n");
	fail_unless (tny_device_is_online(iface) == TRUE, str);
	g_free (str);

	tny_device_force_offline (iface);
		
	str = g_strdup_printf ("Device should be offline after force_online\n");
	fail_unless (tny_device_is_online(iface) == FALSE, str);
	g_free (str);
}
END_TEST

START_TEST (tny_device_test_connection_changed)
{
}
END_TEST

Suite *
create_tny_device_suite (void)
{
     Suite *s = suite_create ("Device");
     TCase *tc = NULL;

     tc = tcase_create ("Is Online");
     tcase_add_checked_fixture (tc, tny_device_test_setup, tny_device_test_teardown);
     tcase_add_test (tc, tny_device_test_is_online);
     suite_add_tcase (s, tc);

     /* Make sure test fails when signal is not received */
     tc = tcase_create ("Connection Changed");
     tcase_add_checked_fixture (tc, tny_device_test_setup, tny_device_test_teardown);
     tcase_add_test_raise_signal (tc, tny_device_test_connection_changed, tny_device_signals [TNY_DEVICE_CONNECTION_CHANGED]);
     suite_add_tcase (s, tc);

     return s;
}