Changeset 738

Show
Ignore:
Timestamp:
08/22/06 00:13:59
Author:
pvanhoof
Message:

Added some tests

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/ChangeLog

    r726 r738  
     122-08-2006  Philip Van oof  <pvanhoof@gnome.org> 
     2 
     3        * tests/*: Added some tests 
     4 
    1520-08-2006  Philip Van Hoof <pvanhoof@gnome.org> 
    26 
  • trunk/configure.ac

    r731 r738  
    137137esac],[build_unittests=false]) 
    138138AM_CONDITIONAL(BUILD_UNITTESTS, test x$build_unittests = xtrue) 
     139 
     140dnl ### Enable building the tests ## 
     141AC_ARG_ENABLE(tests, 
     142[  --enable-tests          build tests [default=no]], 
     143[case "${enableval}" in 
     144  yes) build_tests=true ;; 
     145  no)  build_tests=false ;; 
     146  *) AC_MSG_ERROR(bad value ${enableval} for --enable-tests) ;; 
     147esac],[build_tests=false]) 
     148AM_CONDITIONAL(BUILD_TESTS, test x$build_tests = xtrue) 
    139149 
    140150dnl ### gtk-doc 
  • trunk/libtinymail-camel/tny-account-priv.h

    r550 r738  
    3535        TnyForgetPassFunc forget_pass_func; 
    3636        gboolean pass_func_set, forget_pass_func_set; 
    37         TnyAccountStoreIface *store; 
    3837        CamelProviderType type; 
    3938        CamelOperation *cancel; 
  • trunk/libtinymail-camel/tny-account.c

    r700 r738  
    212212} 
    213213 
    214 static void  
    215 tny_account_set_account_store (TnyAccountIface *self, TnyAccountStoreIface *store) 
    216 
    217         TnyAccountPriv *priv = TNY_ACCOUNT_GET_PRIVATE (self); 
    218  
    219         /* No need to reference (would also be cross reference): If store dies, 
    220            self should also die. */ 
    221          
    222         priv->store = (TnyAccountStoreIface*) store; 
    223  
    224         g_static_rec_mutex_lock (priv->service_lock); 
    225  
    226         priv->session = tny_account_store_get_session  
    227                         (TNY_ACCOUNT_STORE (priv->store)); 
    228  
     214void  
     215tny_account_set_session (TnyAccount *self, TnySessionCamel *session) 
     216
     217        TnyAccountPriv *priv = TNY_ACCOUNT_GET_PRIVATE (self); 
     218 
     219        g_static_rec_mutex_lock (priv->service_lock); 
     220 
     221        priv->session = session; 
     222     
    229223        TNY_ACCOUNT_GET_CLASS (self)->reconnect_func (TNY_ACCOUNT (self)); 
    230224 
     
    232226 
    233227        return; 
    234 } 
    235  
    236 static TnyAccountStoreIface* 
    237 tny_account_get_account_store (TnyAccountIface *self) 
    238 { 
    239         TnyAccountPriv *priv = TNY_ACCOUNT_GET_PRIVATE (self); 
    240  
    241         return priv->store; 
    242228} 
    243229 
     
    472458 
    473459        priv->options = NULL; 
    474         priv->store = NULL; 
    475460        priv->id = NULL; 
    476461        priv->user = NULL; 
     
    618603        klass->set_id_func = tny_account_set_id; 
    619604        klass->get_id_func = tny_account_get_id; 
    620         klass->set_account_store_func = tny_account_set_account_store; 
    621         klass->get_account_store_func = tny_account_get_account_store; 
    622605        klass->is_connected_func = tny_account_is_connected; 
    623606        klass->set_url_string_func = tny_account_set_url_string; 
  • trunk/libtinymail-camel/tny-account.h

    r550 r738  
    2323#include <glib.h> 
    2424#include <glib-object.h> 
    25  
     25#include <tny-camel-shared.h> 
    2626#include <tny-account-iface.h> 
    2727 
     
    5656 
    5757void tny_account_add_option (TnyAccount *self, const gchar *option); 
     58void tny_account_set_session (TnyAccount *self, TnySessionCamel *session); 
    5859 
    5960G_END_DECLS 
  • trunk/libtinymail-camel/tny-session-camel.c

    r729 r738  
    155155        GList *copy = password_funcs, *mark_del = NULL; 
    156156        PrivPassFunc *pf; 
    157         CamelSession *me = CAMEL_SESSION (self)
     157        CamelSession *me = (CamelSession*)self
    158158        gboolean found = FALSE; 
    159159        CamelService *service = (CamelService*)_tny_account_get_service (TNY_ACCOUNT (account)); 
     
    525525tny_session_camel_set_account_store (TnySessionCamel *self, TnyAccountStoreIface *account_store) 
    526526{ 
    527         CamelSession *session = CAMEL_SESSION (self)
     527        CamelSession *session = (CamelSession*) self
    528528        TnyDeviceIface *device = (TnyDeviceIface*)tny_account_store_iface_get_device (account_store); 
    529529 
     
    532532        gchar *base_directory = g_strdup (tny_account_store_iface_get_cache_dir (account_store)); 
    533533        gchar *camel_dir = NULL; 
    534  
     534     
    535535        if (G_LIKELY (camel_init (base_directory, TRUE) != 0)) 
    536536        { 
  • trunk/libtinymail-camel/tny-store-account.c

    r735 r738  
    173173 
    174174                priv->service = camel_session_get_service 
    175                         (CAMEL_SESSION (priv->session), priv->url_string,  
     175                        ((CamelSession*) priv->session, priv->url_string,  
    176176                        priv->type, priv->ex); 
    177177 
     
    184184 
    185185                priv->service = camel_session_get_service 
    186                         (CAMEL_SESSION (priv->session), priv->url_string,  
     186                        ((CamelSession*) priv->session, priv->url_string,  
    187187                        priv->type, priv->ex); 
    188188 
     
    353353 
    354354        g_static_rec_mutex_lock (apriv->service_lock); 
    355         store = camel_session_get_store (CAMEL_SESSION (apriv->session),  
     355        store = camel_session_get_store ((CamelSession*) apriv->session,  
    356356                        apriv->url_string, &ex); 
    357357        g_static_rec_mutex_unlock (apriv->service_lock); 
     
    472472{ 
    473473        TnyAccountPriv *apriv = TNY_ACCOUNT_GET_PRIVATE (self); 
    474         TnyAccountStoreIface *astore = (TnyAccountStoreIface *)tny_account_iface_get_account_store (TNY_ACCOUNT_IFACE (self)); 
    475474 
    476475        CamelException ex = CAMEL_EXCEPTION_INITIALISER; 
     
    478477 
    479478        g_static_rec_mutex_lock (apriv->service_lock); 
    480         store = camel_session_get_store (CAMEL_SESSION (apriv->session),  
     479        store = camel_session_get_store ((CamelSession*) apriv->session,  
    481480                        apriv->url_string, &ex); 
    482481        g_static_rec_mutex_unlock (apriv->service_lock); 
     
    486485        tny_store_account_get_folders (self, TNY_STORE_ACCOUNT_FOLDER_TYPE_SUBSCRIBED); 
    487486 
    488         if (astore) 
    489                 g_signal_emit (astore, tny_account_store_iface_signals [TNY_ACCOUNT_STORE_IFACE_ACCOUNTS_RELOADED], 0); 
    490  
    491487        /* Sync */ 
    492488        _tny_folder_set_subscribed_priv (folder, TRUE); 
     
    499495{ 
    500496        TnyAccountPriv *apriv = TNY_ACCOUNT_GET_PRIVATE (self); 
    501         TnyAccountStoreIface *astore = (TnyAccountStoreIface *)tny_account_iface_get_account_store (TNY_ACCOUNT_IFACE (self)); 
    502497 
    503498        CamelException ex = CAMEL_EXCEPTION_INITIALISER; 
     
    505500 
    506501        g_static_rec_mutex_lock (apriv->service_lock); 
    507         store = camel_session_get_store (CAMEL_SESSION (apriv->session),  
     502        store = camel_session_get_store ((CamelSession*) apriv->session,  
    508503                        apriv->url_string, &ex); 
    509504        g_static_rec_mutex_unlock (apriv->service_lock); 
     
    512507 
    513508        tny_store_account_get_folders (self, TNY_STORE_ACCOUNT_FOLDER_TYPE_SUBSCRIBED); 
    514  
    515         if (astore) 
    516                 g_signal_emit (astore, tny_account_store_iface_signals [TNY_ACCOUNT_STORE_IFACE_ACCOUNTS_RELOADED], 0); 
    517509 
    518510        /* Sync */ 
  • trunk/libtinymail-camel/tny-transport-account.c

    r715 r738  
    9191        CamelTransport *transport; 
    9292 
    93         transport = camel_session_get_transport (CAMEL_SESSION (apriv->session),  
     93        transport = camel_session_get_transport ((CamelSession*) apriv->session,  
    9494                        apriv->url_string, &ex); 
    9595 
  • trunk/libtinymail-gnome-desktop/tny-account-store.c

    r729 r738  
    3636 
    3737#include <tny-account-iface.h> 
     38#include <tny-account.h> 
    3839#include <tny-store-account-iface.h> 
    3940#include <tny-transport-account-iface.h> 
     
    7475{ 
    7576        gchar *retval = NULL; 
    76 GList *list; 
     77       GList *list; 
    7778        GnomeKeyringResult keyringret; 
    7879        gchar *keyring; 
     
    393394                if (account) 
    394395                { 
    395                         tny_account_iface_set_account_store (account, self); 
     396                        tny_account_set_session (TNY_ACCOUNT (account), priv->session); 
    396397 
    397398                        key = g_strdup_printf ("/apps/tinymail/accounts/%d/proto", i); 
     
    603604{ 
    604605        TnyAccountStore *self = g_object_new (TNY_TYPE_ACCOUNT_STORE, NULL); 
    605          
     606        TnyAccountStorePriv *priv = TNY_ACCOUNT_STORE_GET_PRIVATE (self); 
     607        priv->session = tny_session_camel_new (TNY_ACCOUNT_STORE_IFACE (self)); 
    606608 
    607609        return self; 
     
    626628        priv->device = tny_platform_factory_iface_new_device (platfact); 
    627629        /* tny_device_iface_force_online (priv->device); */ 
    628         priv->session = tny_session_camel_new (TNY_ACCOUNT_STORE_IFACE (self)); 
     630         
    629631 
    630632        return; 
  • trunk/libtinymail-gpe/tny-account-store.c

    r729 r738  
    3333#include <tny-account-store-iface.h> 
    3434#include <tny-account-store.h> 
     35#include <tny-account.h> 
     36 
    3537#include <tny-password-dialog.h> 
    3638 
     
    279281                if (account) 
    280282                { 
    281                         tny_account_iface_set_account_store (account, self); 
    282  
     283                        tny_account_set_session (TNY_ACCOUNT (account), priv->session); 
    283284 
    284285                        key = g_strdup_printf ("/apps/tinymail/accounts/%d/proto", i); 
     
    495496{ 
    496497        TnyAccountStore *self = g_object_new (TNY_TYPE_ACCOUNT_STORE, NULL); 
     498        TnyAccountStorePriv *priv = TNY_ACCOUNT_STORE_GET_PRIVATE (self); 
     499        priv->session = tny_session_camel_new (TNY_ACCOUNT_STORE_IFACE (self)); 
    497500 
    498501        return self; 
     
    519522        priv->device = tny_platform_factory_iface_new_device (platfact); 
    520523        /* tny_device_iface_force_online (priv->device); */ 
    521         priv->session = tny_session_camel_new (TNY_ACCOUNT_STORE_IFACE (self)); 
    522      
     524             
    523525        return; 
    524526} 
  • trunk/libtinymail-maemo/tny-account-store.c

    r729 r738  
    3333#include <tny-account-store-iface.h> 
    3434#include <tny-account-store.h> 
     35#include <tny-account.h> 
     36 
    3537#include <tny-password-dialog.h> 
    3638 
     
    279281                if (account) 
    280282                { 
    281                         tny_account_iface_set_account_store (account, self); 
     283                        tny_account_set_session (TNY_ACCOUNT (account), priv->session); 
    282284 
    283285 
     
    496498{ 
    497499        TnyAccountStore *self = g_object_new (TNY_TYPE_ACCOUNT_STORE, NULL); 
     500        TnyAccountStorePriv *priv = TNY_ACCOUNT_STORE_GET_PRIVATE (self); 
     501        priv->session = tny_session_camel_new (TNY_ACCOUNT_STORE_IFACE (self)); 
    498502 
    499503        return self; 
     
    520524        priv->device = tny_platform_factory_iface_new_device (platfact); 
    521525        /* tny_device_iface_force_online (priv->device); */ 
    522         priv->session = tny_session_camel_new (TNY_ACCOUNT_STORE_IFACE (self)); 
    523      
     526 
    524527        return; 
    525528} 
  • trunk/libtinymail-olpc/tny-account-store.c

    r729 r738  
    3232#include <tny-account-store-iface.h> 
    3333#include <tny-account-store.h> 
     34#include <tny-account.h> 
     35 
    3436#include <tny-password-dialog.h> 
    3537 
     
    240242                        gchar **options; 
    241243 
    242                         tny_account_iface_set_account_store (account, self); 
     244                        tny_account_set_session (TNY_ACCOUNT (account), priv->session); 
    243245 
    244246                        proto = g_key_file_get_value (keyfile, "tinymail", "proto", NULL); 
     
    369371{ 
    370372        TnyAccountStore *self = g_object_new (TNY_TYPE_ACCOUNT_STORE, NULL); 
    371          
     373        TnyAccountStorePriv *priv = TNY_ACCOUNT_STORE_GET_PRIVATE (self); 
     374        priv->session = tny_session_camel_new (TNY_ACCOUNT_STORE_IFACE (self)); 
     375 
    372376        return self; 
    373377} 
     
    383387        priv->device = tny_platform_factory_iface_new_device (platfact); 
    384388        /* tny_device_iface_force_online (priv->device); */ 
    385         priv->session = tny_session_camel_new (TNY_ACCOUNT_STORE_IFACE (self)); 
    386      
     389         
    387390        return; 
    388391} 
  • trunk/libtinymail-test/tny-test-anything.c

    r715 r738  
    115115                TNY_MIME_PART_IFACE (tny_mime_part_new (camel_mime_part_new())); 
    116116         
    117         tny_account_iface_set_account_store (TNY_ACCOUNT_IFACE (account),  
    118                 TNY_ACCOUNT_STORE_IFACE (tny_account_store_get_instance ())); 
     117        // tny_account_iface_set_session (TNY_ACCOUNT_IFACE (account), session); 
    119118 
    120119        /* tny_account_iface_set_user (TNY_ACCOUNT_IFACE (account), ""); */ 
  • trunk/libtinymail/tny-account-iface.c

    r723 r738  
    7979} 
    8080 
    81  
    82 /** 
    83  * tny_account_iface_set_account_store: 
    84  * @self: a #TnyAccountIface object 
    85  * @store: a #TnyAccountStoreIface object 
    86  * 
    87  * Set the parent account store for the account. You need to set this property 
    88  * before you can start using the account. 
    89  *  
    90  **/ 
    91 void 
    92 tny_account_iface_set_account_store (TnyAccountIface *self, TnyAccountStoreIface *store) 
    93 { 
    94 #ifdef DEBUG 
    95         if (!TNY_ACCOUNT_IFACE_GET_CLASS (self)->set_account_store_func) 
    96                 g_critical ("You must implement tny_account_iface_set_account_store\n"); 
    97 #endif 
    98  
    99         TNY_ACCOUNT_IFACE_GET_CLASS (self)->set_account_store_func (self, store); 
    100         return; 
    101 } 
    102  
    103 /** 
    104  * tny_account_iface_get_account_store: 
    105  * @self: a #TnyAccountIface object 
    106  *  
    107  * Get the parent store for the account. 
    108  *  
    109  * Return value: the store or NULL if none 
    110  **/ 
    111 TnyAccountStoreIface* 
    112 tny_account_iface_get_account_store (TnyAccountIface *self) 
    113 { 
    114 #ifdef DEBUG 
    115         if (!TNY_ACCOUNT_IFACE_GET_CLASS (self)->get_account_store_func) 
    116                 g_critical ("You must implement tny_account_iface_get_account_store\n"); 
    117 #endif 
    118  
    119         return TNY_ACCOUNT_IFACE_GET_CLASS (self)->get_account_store_func (self); 
    120 } 
    12181 
    12282/** 
  • trunk/libtinymail/tny-account-iface.h

    r652 r738  
    6767        const gchar*    (*get_url_string_func)       (TnyAccountIface *self); 
    6868        TnyAccountType  (*get_account_type_func)     (TnyAccountIface *self); 
    69  
    70         void                   (*set_account_store_func)     (TnyAccountIface *self, TnyAccountStoreIface *store); 
    71         TnyAccountStoreIface*  (*get_account_store_func)     (TnyAccountIface *self); 
    72  
    7369}; 
    7470 
     
    10399TnyForgetPassFunc tny_account_iface_get_forget_pass_func (TnyAccountIface *self); 
    104100 
    105 void tny_account_iface_set_account_store (TnyAccountIface *self, TnyAccountStoreIface *store); 
    106 TnyAccountStoreIface* tny_account_iface_get_account_store (TnyAccountIface *self); 
    107  
    108101G_END_DECLS 
    109102 
  • trunk/tests/Makefile.am

    r735 r738  
    11SUBDIRS = python-demo 
    22 
    3 if BUILD_UNITTESTS 
     3if BUILD_TESTS 
    44SUBDIRS += shared memory functional  
    55endif 
  • trunk/tests/functional/Makefile.am

    r731 r738  
    55        -I$(top_srcdir)/libtinymailui-gtk               \ 
    66        -I$(top_srcdir)/libtinymail-camel               \ 
    7         -I$(top_srcdir)/$(PLATFORMDIR)                  \ 
    87        -DASYNC_HEADERS 
    98 
     
    2726        $(top_builddir)/libtinymailui-gtk/libtinymailui-gtk-$(API_VERSION).la   \ 
    2827        $(top_builddir)/libtinymail-camel/libtinymail-camel-$(API_VERSION).la   \ 
    29         $(top_builddir)/$(PLATFORMDIR)/$(PLATFORMDIR)-$(API_VERSION).la         \ 
    3028        $(top_builddir)/tests/shared/libtestsshared.a 
    3129 
  • trunk/tests/functional/folder-lister.c

    r731 r738  
    6868{ 
    6969        TnyAccountStoreIface *account_store = TNY_ACCOUNT_STORE_IFACE  
    70                 (tny_memtest_account_store_new ()); 
     70                (tny_account_store_new ()); 
    7171        TnyListIface *accounts = tny_list_new (), *folders; 
    7272        TnyStoreAccountIface *account; 
  • trunk/tests/memory/Makefile.am

    r728 r738  
    55        -I$(top_srcdir)/libtinymailui-gtk               \ 
    66        -I$(top_srcdir)/libtinymail-camel               \ 
    7         -I$(top_srcdir)/$(PLATFORMDIR)                  \ 
    87        -DASYNC_HEADERS 
    98 
     
    2726        $(top_builddir)/libtinymailui-gtk/libtinymailui-gtk-$(API_VERSION).la   \ 
    2827        $(top_builddir)/libtinymail-camel/libtinymail-camel-$(API_VERSION).la   \ 
    29         $(top_builddir)/$(PLATFORMDIR)/$(PLATFORMDIR)-$(API_VERSION).la         \ 
    3028        $(top_builddir)/tests/shared/libtestsshared.a 
    3129 
  • trunk/tests/memory/memory-test.c

    r736 r738  
    7474{ 
    7575        TnyAccountStoreIface *account_store = TNY_ACCOUNT_STORE_IFACE  
    76                 (tny_memtest_account_store_new ()); 
     76                (tny_account_store_new ()); 
    7777        TnyListIface *accounts = tny_list_new (), *folders; 
    7878        TnyStoreAccountIface *account; 
  • trunk/tests/shared/Makefile.am

    r728 r738  
    44        -I$(top_srcdir)/libtinymailui                   \ 
    55        -I$(top_srcdir)/libtinymailui-gtk               \ 
    6         -I$(top_srcdir)/libtinymail-camel               \ 
    7         -I$(top_srcdir)/$(PLATFORMDIR)                  \ 
     6        -I$(top_srcdir)/libtinymail-camel               \ 
    87        -DASYNC_HEADERS 
    98 
     
    1716 
    1817noinst_LIBRARIES = libtestsshared.a 
    19 libtestsshared_a_SOURCES = account-store.c account-store.h 
     18libtestsshared_a_SOURCES = account-store.c account-store.h \ 
     19        platfact.c platfact.h device.c device.h device-priv.h 
     20 
    2021libtestsshared_a_LDFLAGS = $(LIBTINYMAIL_LIBS) \ 
    2122        $(LIBTINYMAIL_GNOME_DESKTOP_LIBS)                                       \ 
     
    2324        $(top_builddir)/libtinymailui/libtinymailui-$(API_VERSION).la           \ 
    2425        $(top_builddir)/libtinymailui-gtk/libtinymailui-gtk-$(API_VERSION).la   \ 
    25         $(top_builddir)/libtinymail-camel/libtinymail-camel-$(API_VERSION).la   \ 
    26         $(top_builddir)/$(PLATFORMDIR)/$(PLATFORMDIR)-$(API_VERSION).la  
     26        $(top_builddir)/libtinymail-camel/libtinymail-camel-$(API_VERSION).la 
  • trunk/tests/shared/account-store.c

    r737 r738  
    2727 
    2828#include <tny-platform-factory-iface.h> 
    29 #include <tny-platform-factory.h> 
     29#include "platfact.h" 
    3030 
    3131#include <tny-account-store-iface.h> 
    3232#include <tny-account-iface.h> 
     33#include <tny-account.h> 
     34 
    3335#include <tny-store-account-iface.h> 
    3436#include <tny-transport-account-iface.h> 
     
    3638#include <tny-transport-account.h> 
    3739#include <tny-device-iface.h> 
    38 #include <tny-device.h> 
     40 
     41#include "device.h" 
    3942 
    4043#include <tny-camel-shared.h> 
     
    6164 
    6265static gboolean 
    63 tny_memtest_account_store_alert (TnyAccountStoreIface *self, TnyAlertType type, const gchar *prompt) 
     66tny_account_store_alert (TnyAccountStoreIface *self, TnyAlertType type, const gchar *prompt) 
    6467{ 
    6568        return TRUE; 
     
    6871 
    6972static const gchar* 
    70 tny_memtest_account_store_get_cache_dir (TnyAccountStoreIface *self) 
    71 
    72         /* FIXME: Small memleak here */ 
    73         return g_build_filename (g_get_home_dir (), ".tinymail", NULL); 
    74 
    75  
    76  
    77 static void 
    78 tny_memtest_account_store_get_accounts (TnyAccountStoreIface *self, TnyListIface *list, TnyGetAccountsRequestType types) 
    79 
     73tny_account_store_get_cache_dir (TnyAccountStoreIface *self) 
     74
     75        TnyAccountStore *me = (TnyAccountStore*) self; 
     76     
     77        if (!me->cache_dir) 
     78        { 
     79                gint att=0; 
     80                GDir *dir = NULL; 
     81                do { 
     82                        gchar *attempt = g_strdup_printf ("tinymail.%d", att); 
     83                        gchar *str = g_build_filename (g_get_tmp_dir (), attempt, NULL); 
     84                        g_free (attempt);                    
     85                        dir = g_dir_open (str, 0, NULL); 
     86                        if (dir) 
     87                        { 
     88                                g_dir_close (dir); 
     89                                g_free (str); 
     90                        } else  
     91                                me->cache_dir = str; 
     92                        att++; 
     93                } while (dir != NULL);           
     94        } 
     95     
     96        return me->cache_dir; 
     97
     98 
     99 
     100static void 
     101tny_account_store_get_accounts (TnyAccountStoreIface *self, TnyListIface *list, TnyGetAccountsRequestType types) 
     102
     103        TnyAccountStore *me = (TnyAccountStore *) self; 
     104     
    80105        TnyAccountIface *account = TNY_ACCOUNT_IFACE (tny_store_account_new ()); 
    81106     
    82      
    83107        /* Dear visitor of the SVN-web. This is indeed a fully functional and 
    84            working IMAP account. This does not mean that you need to fuck it up. 
    85             
    86            And I know you can. Just like I can very easily correct your mess by 
    87            restoring the backup. 
    88             
    89            The purpose of this account is testing software. Not your enjoyment  
    90            nor showing your friends how 3l33t you are (in which case you most 
    91            certainly aren't. In that case you are just a pain in the ass or a 
    92            piece of stinking shit being annoying to people). 
    93             
    94            So .. please DO use the account of preparing your automated tests. 
    95             
    96            But don't screwup the account. */ 
    97      
    98         tny_account_iface_set_account_store (account, (TnyAccountStoreIface*)self); 
    99         tny_account_iface_set_proto (TNY_ACCOUNT_IFACE (account), "imap"); 
    100         tny_account_iface_set_name (TNY_ACCOUNT_IFACE (account), "unit test account"); 
    101         tny_account_iface_set_user (TNY_ACCOUNT_IFACE (account), "tinymailunittest"); 
    102         tny_account_iface_set_hostname (TNY_ACCOUNT_IFACE (account), "mail.tinymail.org"); 
    103         tny_account_iface_set_id (TNY_ACCOUNT_IFACE (account), "unique"); 
    104         tny_account_iface_set_forget_pass_func (TNY_ACCOUNT_IFACE (account), 
    105                         per_account_forget_pass_func); 
    106         tny_account_iface_set_pass_func (TNY_ACCOUNT_IFACE (account), 
    107                         per_account_get_pass_func); 
     108           working IMAP account. This does not mean that you need to fuck it up */ 
     109     
     110        tny_account_set_session (TNY_ACCOUNT (account), me->session); 
     111     
     112        tny_account_iface_set_proto (account, "imap"); 
     113        tny_account_iface_set_name (account, "unit test account"); 
     114        tny_account_iface_set_user (account, "tinymailunittest"); 
     115        tny_account_iface_set_hostname (account, "mail.tinymail.org"); 
     116        tny_account_iface_set_id (account, "unique"); 
     117        tny_account_iface_set_forget_pass_func (account, per_account_forget_pass_func); 
     118        tny_account_iface_set_pass_func (account, per_account_get_pass_func); 
    108119 
    109120        tny_list_iface_prepend (list, (GObject*)account); 
     
    115126 
    116127 
    117 static void 
    118 tny_memtest_account_store_add_account (TnyAccountStoreIface *self, TnyAccountIface *account, const gchar *type) 
    119 
    120         return; 
    121 
    122  
    123  
    124  
    125 TnyMemTestAccountStore* 
    126 tny_memtest_account_store_new (void) 
    127 
    128         TnyMemTestAccountStore *self = g_object_new (TNY_TYPE_MEMTEST_ACCOUNT_STORE, NULL); 
    129  
     128TnyAccountStore* 
     129tny_account_store_new (void) 
     130
     131        TnyAccountStore *self = g_object_new (TNY_TYPE_ACCOUNT_STORE, NULL); 
     132 
     133        self->session = tny_session_camel_new (TNY_ACCOUNT_STORE_IFACE (self)); 
     134     
    130135        return self; 
    131136} 
     
    133138 
    134139static void 
    135 tny_memtest_account_store_instance_init (GTypeInstance *instance, gpointer g_class) 
    136 
    137         TnyDeviceIface *device = tny_account_store_iface_get_device (TNY_ACCOUNT_STORE_IFACE (instance)); 
    138  
    139         tny_device_iface_force_online (device); 
    140      
    141         return; 
    142 
    143  
    144  
    145 static void 
    146 tny_memtest_account_store_finalize (GObject *object) 
    147 
     140tny_account_store_instance_init (GTypeInstance *instance, gpointer g_class) 
     141
     142        TnyAccountStore *self = (TnyAccountStore *)instance; 
     143        TnyPlatformFactoryIface *platfact = TNY_PLATFORM_FACTORY_IFACE ( 
     144                tny_platform_factory_get_instance ()); 
     145 
     146        self->device = tny_platform_factory_iface_new_device (platfact); 
     147        /* tny_device_iface_force_online (priv->device); */ 
     148     
     149        return; 
     150
     151 
     152 
     153static void 
     154tny_account_store_finalize (GObject *object) 
     155
     156        TnyAccountStore *me = (TnyAccountStore*) object; 
     157     
     158        if (me->cache_dir) 
     159                g_free (me->cache_dir); 
     160     
    148161        (*parent_class->finalize) (object); 
    149162 
     
    153166 
    154167static void  
    155 tny_memtest_account_store_class_init (TnyMemTestAccountStoreClass *class) 
     168tny_account_store_class_init (TnyAccountStoreClass *class) 
    156169{ 
    157170        GObjectClass *object_class; 
    158  
     171     
    159172        parent_class = g_type_class_peek_parent (class); 
    160173        object_class = (GObjectClass*) class; 
    161174 
    162         object_class->finalize = tny_memtest_account_store_finalize; 
    163  
    164         return; 
    165 
    166  
    167 static void 
    168 tny_memtest_account_store_iface_init (gpointer g_iface, gpointer iface_data) 
     175        object_class->finalize = tny_account_store_finalize; 
     176 
     177        return; 
     178
     179 
     180 
     181static void 
     182tny_account_store_add_store_account (TnyAccountStoreIface *self, TnyStoreAccountIface *account) 
     183
     184        return; 
     185
     186 
     187static void 
     188tny_account_store_add_transport_account (TnyAccountStoreIface *self, TnyTransportAccountIface *account) 
     189
     190        return; 
     191
     192 
     193static TnyDeviceIface* 
     194tny_account_store_get_device (TnyAccountStoreIface *self) 
     195
     196        TnyAccountStore *me =  (TnyAccountStore*) self; 
     197 
     198        return me->device; 
     199
     200 
     201 
     202static void 
     203tny_account_store_iface_init (gpointer g_iface, gpointer iface_data) 
    169204{ 
    170205        TnyAccountStoreIfaceClass *klass = (TnyAccountStoreIfaceClass *)g_iface; 
    171206 
    172         klass->get_accounts_func = tny_memtest_account_store_get_accounts; 
    173         klass->get_cache_dir_func = tny_memtest_account_store_get_cache_dir; 
    174         klass->alert_func = tny_memtest_account_store_alert; 
     207        klass->get_accounts_func = tny_account_store_get_accounts; 
     208        klass->get_cache_dir_func = tny_account_store_get_cache_dir; 
     209        klass->alert_func = tny_account_store_alert; 
     210        klass->add_store_account_func = tny_account_store_add_store_account; 
     211        klass->add_transport_account_func = tny_account_store_add_transport_account; 
     212        klass->get_device_func = tny_account_store_get_device; 
    175213     
    176214        return; 
     
    179217 
    180218GType  
    181 tny_memtest_account_store_get_type (void) 
     219tny_account_store_get_type (void) 
    182220{ 
    183221        static GType type = 0; 
     
    187225                static const GTypeInfo info =  
    188226                { 
    189                   sizeof (TnyMemTestAccountStoreClass), 
     227                  sizeof (TnyAccountStoreClass), 
    190228                  NULL,   /* base_init */ 
    191229                  NULL,   /* base_finalize */ 
    192                   (GClassInitFunc) tny_memtest_account_store_class_init,   /* class_init */ 
     230                  (GClassInitFunc) tny_account_store_class_init,   /* class_init */ 
    193231                  NULL,   /* class_finalize */ 
    194232                  NULL,   /* class_data */ 
    195                   sizeof (TnyMemTestAccountStore), 
     233                  sizeof (TnyAccountStore), 
    196234                  0,      /* n_preallocs */ 
    197                   tny_memtest_account_store_instance_init    /* instance_init */ 
     235                  tny_account_store_instance_init    /* instance_init */ 
    198236                }; 
    199237 
    200                 static const GInterfaceInfo tny_memtest_account_store_iface_info =  
     238                static const GInterfaceInfo tny_account_store_iface_info =  
    201239                { 
    202                   (GInterfaceInitFunc) tny_memtest_account_store_iface_init, /* interface_init */ 
     240                  (GInterfaceInitFunc) tny_account_store_iface_init, /* interface_init */ 
    203241                  NULL,         /* interface_finalize */ 
    204242                  NULL          /* interface_data */ 
    205243                }; 
    206244 
    207                 type = g_type_register_static (TNY_TYPE_ACCOUNT_STORE
    208                         "TnyMemTestAccountStore", 
     245                type = g_type_register_static (G_TYPE_OBJECT
     246                        "TnyAccountStore", 
    209247                        &info, 0); 
    210248 
    211249                g_type_add_interface_static (type, TNY_TYPE_ACCOUNT_STORE_IFACE,  
    212                         &tny_memtest_account_store_iface_info); 
     250                        &tny_account_store_iface_info); 
    213251        } 
    214252 
  • trunk/tests/shared/account-store.h

    r728 r738  
    1 #ifndef TNY_MEMTEST_ACCOUNT_STORE_H 
    2 #define TNY_MEMTEST_ACCOUNT_STORE_H 
     1#ifndef TNY_ACCOUNT_STORE_H 
     2#define TNY_ACCOUNT_STORE_H 
    33 
    44/* tinymail - Tiny Mail 
     
    2323#include <glib-object.h> 
    2424#include <tny-shared.h> 
    25 #include <tny-account-store.h> 
    2625#include <tny-camel-shared.h> 
    2726 
    2827G_BEGIN_DECLS 
    2928 
    30 #define TNY_TYPE_MEMTEST_ACCOUNT_STORE             (tny_memtest_account_store_get_type ()) 
    31 #define TNY_MEMTEST_ACCOUNT_STORE(obj)             (G_TYPE_CHECK_INSTANCE_CAST ((obj), TNY_TYPE_MEMTEST_ACCOUNT_STORE, TnyMemTestAccountStore)) 
    32 #define TNY_MEMTEST_ACCOUNT_STORE_CLASS(vtable)    (G_TYPE_CHECK_CLASS_CAST ((vtable), TNY_TYPE_MEMTEST_ACCOUNT_STORE, TnyMemTestAccountStoreClass)) 
    33 #define TNY_IS_MEMTEST_ACCOUNT_STORE(obj)          (G_TYPE_CHECK_INSTANCE_TYPE ((obj), TNY_TYPE_MEMTEST_ACCOUNT_STORE)) 
    34 #define TNY_IS_MEMTEST_ACCOUNT_STORE_CLASS(vtable) (G_TYPE_CHECK_CLASS_TYPE ((vtable), TNY_TYPE_MEMTEST_ACCOUNT_STORE)) 
    35 #define TNY_MEMTEST_ACCOUNT_STORE_GET_CLASS(inst)  (G_TYPE_INSTANCE_GET_CLASS ((inst), TNY_TYPE_MEMTEST_ACCOUNT_STORE, TnyMemTestAccountStoreClass)) 
     29#define TNY_TYPE_ACCOUNT_STORE             (tny_account_store_get_type ()) 
     30#define TNY_ACCOUNT_STORE(obj)             (G_TYPE_CHECK_INSTANCE_CAST ((obj), TNY_TYPE_ACCOUNT_STORE, TnyAccountStore)) 
     31#define TNY_ACCOUNT_STORE_CLASS(vtable)    (G_TYPE_CHECK_CLASS_CAST ((vtable), TNY_TYPE_ACCOUNT_STORE, TnyAccountStoreClass)) 
     32#define TNY_IS_ACCOUNT_STORE(obj)          (G_TYPE_CHECK_INSTANCE_TYPE ((obj), TNY_TYPE_ACCOUNT_STORE)) 
     33#define TNY_IS_ACCOUNT_STORE_CLASS(vtable) (G_TYPE_CHECK_CLASS_TYPE ((vtable), TNY_TYPE_ACCOUNT_STORE)) 
     34#define TNY_ACCOUNT_STORE_GET_CLASS(inst)  (G_TYPE_INSTANCE_GET_CLASS ((inst), TNY_TYPE_ACCOUNT_STORE, TnyAccountStoreClass)) 
    3635 
    37 typedef struct _TnyMemTestAccountStore TnyMemTestAccountStore; 
    38 typedef struct _TnyMemTestAccountStoreClass TnyMemTestAccountStoreClass; 
     36typedef struct _TnyAccountStore TnyAccountStore; 
     37typedef struct _TnyAccountStoreClass TnyAccountStoreClass; 
    3938 
    40 struct _TnyMemTestAccountStore 
     39struct _TnyAccountStore 
    4140{ 
    42         TnyAccountStore parent; 
     41        GObject parent; 
     42     
     43        gchar *cache_dir; 
     44        TnySessionCamel *session; 
     45        TnyDeviceIface *device; 
    4346}; 
    4447 
    45 struct _TnyMemTestAccountStoreClass 
     48struct _TnyAccountStoreClass 
    4649{ 
    47         TnyAccountStoreClass parent; 
     50        GObjectClass parent; 
    4851}; 
    4952 
    50 GType               tny_memtest_account_store_get_type       (void); 
    51 TnyMemTestAccountStore*    tny_memtest_account_store_new            (void); 
    52 TnySessionCamel*    tny_memtest_account_store_get_session    (TnyMemTestAccountStore *self); 
     53GType               tny_account_store_get_type       (void); 
     54TnyAccountStore*    tny_account_store_new            (void); 
     55TnySessionCamel*    tny_account_store_get_session    (TnyAccountStore *self); 
    5356 <