~ubuntu-branches/ubuntu/karmic/libtinymail/karmic

« back to all changes in this revision

Viewing changes to libtinymail-test/tny-platform-factory-test.c

  • Committer: Bazaar Package Importer
  • Author(s): Steve Kowalik
  • Date: 2007-10-12 11:21:12 UTC
  • Revision ID: james.westby@ubuntu.com-20071012112112-fod9fs7yrooxjr7i
Tags: upstream-0.0.2
ImportĀ upstreamĀ versionĀ 0.0.2

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/* tinymail - Tiny Mail unit test
 
2
 * Copyright (C) 2006-2007 Philip Van Hoof <pvanhoof@gnome.org>
 
3
 *
 
4
 * This program is free software; you can redistribute it and/or modify
 
5
 * it under the terms of the GNU General Public License as published by
 
6
 * the Free Software Foundation; either version 2 of the License, or
 
7
 * (at your option) any later version.
 
8
 *
 
9
 * This program 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
 
12
 * GNU General Public License for more details.
 
13
 *
 
14
 * You should have received a copy of the GNU General Public License
 
15
 * along with self program; if not, write to the Free Software
 
16
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 
17
 */
 
18
 
 
19
#include "check_libtinymailui.h"
 
20
 
 
21
#include <tny-platform-factory.h>
 
22
 
 
23
#include <platfact.h>
 
24
 
 
25
static TnyPlatformFactory *iface = NULL;
 
26
static gchar *str;
 
27
 
 
28
static void
 
29
tny_platform_factory_test_setup (void)
 
30
{
 
31
        iface = tny_test_platform_factory_get_instance ();
 
32
 
 
33
        return;
 
34
}
 
35
 
 
36
static void 
 
37
tny_platform_factory_test_teardown (void)
 
38
{
 
39
 
 
40
        g_object_unref (G_OBJECT (iface));
 
41
        return;
 
42
}
 
43
 
 
44
 
 
45
START_TEST (tny_platform_factory_test_new_device)
 
46
{
 
47
        GObject *obj = (GObject*)tny_platform_factory_new_device (iface);
 
48
 
 
49
        str = g_strdup_printf ("Returned instance doesn't implement TnyDevice\n");
 
50
        fail_unless (TNY_IS_DEVICE (obj), str);
 
51
        g_free (str);
 
52
 
 
53
        g_object_unref (G_OBJECT (obj));
 
54
}
 
55
END_TEST
 
56
 
 
57
START_TEST (tny_platform_factory_test_new_account_store)
 
58
{
 
59
        GObject *obj = (GObject*)tny_platform_factory_new_account_store (iface);
 
60
 
 
61
        str = g_strdup_printf ("Returned instance doesn't implement TnyAccountStore\n");
 
62
        fail_unless (TNY_IS_ACCOUNT_STORE (obj), str);
 
63
        g_free (str);
 
64
 
 
65
        g_object_unref (G_OBJECT (obj));
 
66
}
 
67
END_TEST
 
68
 
 
69
START_TEST(tny_platform_factory_test_new_msg_view)
 
70
{
 
71
        GObject *obj = (GObject*)tny_platform_factory_new_msg_view (iface);
 
72
 
 
73
        str = g_strdup_printf ("Returned instance doesn't implement TnyMsgView\n");
 
74
        fail_unless (TNY_IS_MSG_VIEW (obj), str);
 
75
        g_free (str);
 
76
 
 
77
        /* It's a floating object that gets unreferenced by 
 
78
          gtk_widget_destroy() and likes
 
79
 
 
80
          TODO: Make tny-msg-view finalize properly
 
81
 
 
82
        g_object_unref (G_OBJECT (obj)); */
 
83
}
 
84
END_TEST
 
85
 
 
86
Suite *
 
87
create_tny_platform_factory_suite (void)
 
88
{
 
89
     Suite *s = suite_create ("Platform Factory");
 
90
     TCase *tc = NULL;
 
91
 
 
92
     tc = tcase_create ("New Device");
 
93
     tcase_add_checked_fixture (tc, tny_platform_factory_test_setup, tny_platform_factory_test_teardown);
 
94
     tcase_add_test (tc, tny_platform_factory_test_new_device);
 
95
     suite_add_tcase (s, tc);
 
96
 
 
97
     tc = tcase_create ("New Account Store");
 
98
     tcase_add_checked_fixture (tc, tny_platform_factory_test_setup, tny_platform_factory_test_teardown);
 
99
     tcase_add_test (tc, tny_platform_factory_test_new_account_store);
 
100
     suite_add_tcase (s, tc);
 
101
 
 
102
     tc = tcase_create ("New Message View");
 
103
     tcase_add_checked_fixture (tc, tny_platform_factory_test_setup, tny_platform_factory_test_teardown);
 
104
     tcase_add_test (tc, tny_platform_factory_test_new_msg_view);
 
105
     suite_add_tcase (s, tc);
 
106
 
 
107
     return s;
 
108
}