ETestServerFixture: Evolution-Data-Server Reference Manual

## ETestServerFixture ETestServerFixture — A utility for unit testing EDS |

## Functions

#define | E_TEST_SERVER_UTILS_SERVICE()
void | (*ETestSourceCustomizeFunc) ()
void | e_test_server_utils_setup ()
void | e_test_server_utils_teardown ()
gint | e_test_server_utils_run ()
gint | e_test_server_utils_run_full ()

## Types and Values

enum | ETestServiceType
struct | ETestServerClosure
| ETestService
struct | ETestServerFixture
enum | ETestServerFlags

## Description

This test fixture provides an encapsulated testing environment for test cases to test EBookClient and ECalClient.

The ETestServerFixture should be used as a fixture and must be coupled with the ETestServerClosure to configure how the test fixture will operate.

Both the ETestServerFixture and ETestServerClosure can be extended with more complex test fixtures, which must remember to call `e_test_server_utils_setup()` and `e_test_server_utils_teardown()` in thier fixture's setup and teardown routines.

## Functions

### E_TEST_SERVER_UTILS_SERVICE()

    #define             E_TEST_SERVER_UTILS_SERVICE(fixture, service_type)

A convenience macro to fetch the service for a given test case:

    1
    EBookClient *book = E_TEST_SERVER_UTILS_SERVICE (fixture, EBookClient);

#### Parameters

fixture | An ETestServerFixture |
service_type | The type to cast for the service in use |

### ETestSourceCustomizeFunc ()

    void
    (*ETestSourceCustomizeFunc) (ESource *scratch,
                                 ETestServerClosure *closure);

This can be used to parameterize the addressbook or calendar `scratch` ESource before creating/committing it.

#### Parameters

scratch | The scratch ESource template being used to create an addressbook or calendar |
closure | The ETestServerClosure for this test case |

### e_test_server_utils_setup ()

    void
    e_test_server_utils_setup (ETestServerFixture *fixture,
                               gconstpointer user_data);

A setup function for the ETestServerFixture fixture

#### Parameters

fixture | A ETestServerFixture |
user_data | A ETestServerClosure or derived structure provided by the test. |

### e_test_server_utils_teardown ()

    void
    e_test_server_utils_teardown (ETestServerFixture *fixture,
                                  gconstpointer user_data);

A teardown function for the ETestServerFixture fixture

#### Parameters

fixture | A ETestServerFixture |
user_data | A ETestServerClosure or derived structure provided by the test. |

### e_test_server_utils_run ()

    gint
    e_test_server_utils_run (void);

### e_test_server_utils_run_full ()

    gint
    e_test_server_utils_run_full (ETestServerFlags flags);

## Types and Values

### enum ETestServiceType

The type of service to test

#### Members

E_TEST_SERVER_NONE | Only the ESourceRegistry will be created |
E_TEST_SERVER_ADDRESS_BOOK | An EBookCLient will be created and opened for the test |
E_TEST_SERVER_DIRECT_ADDRESS_BOOK | An EBookCLient in direct read access mode will be created and opened for the test |
E_TEST_SERVER_CALENDAR | An ECalClient will be created and opened for the test |
E_TEST_SERVER_DEPRECATED_ADDRESS_BOOK | An EBook will be created and opened for the test |
E_TEST_SERVER_DEPRECATED_CALENDAR |  |

### struct ETestServerClosure

    struct ETestServerClosure {
    	ETestServiceType         type;
    	ETestSourceCustomizeFunc customize;
    	gint                     calendar_source_type;
    	gboolean                 keep_work_directory;
    	GDestroyNotify           destroy_closure_func;
    	gboolean                 use_async_connect;
    };

This structure provides the parameters for the ETestServerFixture tests, it can be included as the first member of a derived structure for any tests deriving from the ETestServerFixture test type

#### Members

ETestServiceType `type`; |  |
ETestSourceCustomizeFunc `customize`; | An ETestSourceCustomizeFunc to use to parameterize the scratch ESource, or `NULL` |
gint `calendar_source_type`; | An ECalClientSourceType or ECalSourceType; for `E_TEST_SERVER_CALENDAR` and `E_TEST_SERVER_DEPRECATED_CALENDAR` tests |
gboolean `keep_work_directory`; | If specified, the work directory will not be deleted between tests |
GDestroyNotify `destroy_closure_func`; | A function to destroy an allocated ETestServerClosure, this it typically used by sub-fixtures which embed this structure in their closures. |
gboolean `use_async_connect`; | Specifies whether a synchronous or asyncrhonous API should be used to create the EClient you plan to test. |

### ETestService

A union of service types, holds the object to test in a ETestServerFixture.

#### Members

gpointer `generic`; | A generic pointer for the test service. |
EBookClient *`book_client`; | An EBookClient, created for `E_TEST_SERVER_ADDRESS_BOOK` tests |
ECalClient *`calendar_client`; | An ECalClient, created for `E_TEST_SERVER_CALENDAR` tests |
EBook *`book`; | An EBook, created for `E_TEST_SERVER_DEPRECATED_ADDRESS_BOOK` tests |
ECal *`calendar`; | An ECal, created for `E_TEST_SERVER_DEPRECATED_CALENDAR` tests |

### struct ETestServerFixture

    struct ETestServerFixture {
    	GMainLoop       *loop;
    	GTestDBus       *dbus;
    	ESourceRegistry *registry;
    	ETestService     service;
    	gchar           *source_name;
    };

A fixture for running tests on the Evolution Data Server components in an encapsulated D-Bus environment.

#### Members

GMainLoop *`loop`; | A Main loop to run traffic in |
GTestDBus *`dbus`; | The D-Bus test scaffold |
ESourceRegistry *`registry`; | An ESourceRegistry |
ETestService `service`; | The ETestService |
gchar *`source_name`; | This can be given an allocated string before calling `e_test_server_utils_setup()` and will be the ESource UID for the test addressbook or calendar, leaving this `NULL` will result in a suitable unique id being generated for the test. |

### enum ETestServerFlags

#### Members

E_TEST_SERVER_KEEP_WORK_DIRECTORY |  |