Re: [Evolution-hackers] Regarding API breakage and lost test cases



On Tue, 2012-10-02 at 13:30 +0900, Tristan Van Berkom wrote:
> I'm still trying to find my footing here, the migration guide
> and new documentation on ESourceRegistry don't seem to outline
> how a new addressbook is actually created.
> 
> i.e. if I wanted to test a specific addressbook backend,
> I would need a way to create one and populate it inside some sandbox
> directory.

The location of the database files is fixed for the file backend. It has
to be in ~/.local/share/evolution and is derived from the UUID. I agree
that an explicit path property for the file backend would be nice.

> I'm getting as far as:
> 
>     // Create scratch source
>     e_source_new_with_uid();
> 
>     // Add it to the registry
>     e_source_registry_new();
>     e_source_registry_add_sources();
> 
>     // Fetch the new source from the registry (no longer 'scratch')
>     e_source_registry_ref_source();
> 
>     // Create the book now that we have a valid source (... or so we
>     // suspected)
>     e_book_new ();
> 
> Problems I'm encountering are:
> 
>     a.) It seems that e_source_registry_ref_source() only finds the
>         newly created source the next time I startup the test app
>         (so this may indicate a bug, that the local registry is not
>         updated after adding a new source).

Not sure about that one. To some extend the API depends on processing
D-Bus events in the main event loop. Perhaps that's not happening in
your test app?

>     b.) e_book_new() complains that the new source has no backend:
> 
>        "e-book.c:2944: cannot get book from factory:
>         No backend name in source 'Unnamed'"

You need to add the right extensions to the new source:
    source = e_source_new();
    ESourceBackend *backend = e_source_get_extension(source, E_SOURCE_EXTENSION_ADDRESS_BOOK);
    e_source_backend_set_backend_name(backend, "local");

> I'm sure I've missed something ridiculous here, while observing
> the sources e-data-book-factory.c, it seems that if the source
> were given an addressbook extension with the intended backend
> name... that it would happily go ahead and create a book.
> 
> But, while we do have:
>     e_source_get_extension() & e_source_has_extension()
> 
> I'm not seeing:
>     e_source_add_extension()

_get_extension() adds the extension implicitly.

-- 
Bye, Patrick Ohly
--  
Patrick Ohly gmx de
http://www.estamos.de/




[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]