| 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_libtinymailui.h" |
| 21 |
|
| 22 |
#include <tny-platform-factory.h> |
| 23 |
|
| 24 |
#include <platfact.h> |
| 25 |
|
| 26 |
static TnyPlatformFactory *iface = NULL; |
| 27 |
static gchar *str; |
| 28 |
|
| 29 |
static void |
| 30 |
tny_platform_factory_test_setup (void) |
| 31 |
{ |
| 32 |
iface = tny_test_platform_factory_get_instance (); |
| 33 |
|
| 34 |
return; |
| 35 |
} |
| 36 |
|
| 37 |
static void |
| 38 |
tny_platform_factory_test_teardown (void) |
| 39 |
{ |
| 40 |
|
| 41 |
g_object_unref (G_OBJECT (iface)); |
| 42 |
return; |
| 43 |
} |
| 44 |
|
| 45 |
|
| 46 |
START_TEST (tny_platform_factory_test_new_device) |
| 47 |
{ |
| 48 |
GObject *obj = (GObject*)tny_platform_factory_new_device (iface); |
| 49 |
|
| 50 |
str = g_strdup_printf ("Returned instance doesn't implement TnyDevice\n"); |
| 51 |
fail_unless (TNY_IS_DEVICE (obj), str); |
| 52 |
g_free (str); |
| 53 |
|
| 54 |
g_object_unref (G_OBJECT (obj)); |
| 55 |
} |
| 56 |
END_TEST |
| 57 |
|
| 58 |
START_TEST (tny_platform_factory_test_new_account_store) |
| 59 |
{ |
| 60 |
GObject *obj = (GObject*)tny_platform_factory_new_account_store (iface); |
| 61 |
|
| 62 |
str = g_strdup_printf ("Returned instance doesn't implement TnyAccountStore\n"); |
| 63 |
fail_unless (TNY_IS_ACCOUNT_STORE (obj), str); |
| 64 |
g_free (str); |
| 65 |
|
| 66 |
g_object_unref (G_OBJECT (obj)); |
| 67 |
} |
| 68 |
END_TEST |
| 69 |
|
| 70 |
START_TEST(tny_platform_factory_test_new_msg_view) |
| 71 |
{ |
| 72 |
GObject *obj = (GObject*)tny_platform_factory_new_msg_view (iface); |
| 73 |
|
| 74 |
str = g_strdup_printf ("Returned instance doesn't implement TnyMsgView\n"); |
| 75 |
fail_unless (TNY_IS_MSG_VIEW (obj), str); |
| 76 |
g_free (str); |
| 77 |
|
| 78 |
/* It's a floating object that gets unreferenced by |
| 79 |
gtk_widget_destroy() and likes |
| 80 |
|
| 81 |
TODO: Make tny-msg-view finalize properly |
| 82 |
|
| 83 |
g_object_unref (G_OBJECT (obj)); */ |
| 84 |
} |
| 85 |
END_TEST |
| 86 |
|
| 87 |
Suite * |
| 88 |
create_tny_platform_factory_suite (void) |
| 89 |
{ |
| 90 |
Suite *s = suite_create ("Platform Factory"); |
| 91 |
TCase *tc = NULL; |
| 92 |
|
| 93 |
tc = tcase_create ("New Device"); |
| 94 |
tcase_add_checked_fixture (tc, tny_platform_factory_test_setup, tny_platform_factory_test_teardown); |
| 95 |
tcase_add_test (tc, tny_platform_factory_test_new_device); |
| 96 |
suite_add_tcase (s, tc); |
| 97 |
|
| 98 |
tc = tcase_create ("New Account Store"); |
| 99 |
tcase_add_checked_fixture (tc, tny_platform_factory_test_setup, tny_platform_factory_test_teardown); |
| 100 |
tcase_add_test (tc, tny_platform_factory_test_new_account_store); |
| 101 |
suite_add_tcase (s, tc); |
| 102 |
|
| 103 |
tc = tcase_create ("New Message View"); |
| 104 |
tcase_add_checked_fixture (tc, tny_platform_factory_test_setup, tny_platform_factory_test_teardown); |
| 105 |
tcase_add_test (tc, tny_platform_factory_test_new_msg_view); |
| 106 |
suite_add_tcase (s, tc); |
| 107 |
|
| 108 |
return s; |
| 109 |
} |