~oif-team/geis/trunk

« back to all changes in this revision

Viewing changes to libutouch-geis/geis_backend_test_fixture.c

  • Committer: Stephen M. Webb
  • Date: 2010-12-06 12:10:40 UTC
  • mfrom: (87.1.25 geis2)
  • Revision ID: stephen.webb@canonical.com-20101206121040-y9dnfcl89kdot63t
Added a back end base and test fixture.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/**
 
2
 * @file geis_backend_test_fixture.c
 
3
 * @brief GEIS mock back end test fixture implementation
 
4
 *
 
5
 * Copyright 2010 Canonical Ltd.
 
6
 *
 
7
 * This library is free software; you can redistribute it and/or modify it under
 
8
 * the terms of the GNU Lesser General Public License as published by the Free
 
9
 * Software Foundation; either version 3 of the License, or (at your option) any
 
10
 * later version.
 
11
 *
 
12
 * This library is distributed in the hope that it will be useful, but WITHOUT
 
13
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 
14
 * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
 
15
 * details.
 
16
 *
 
17
 * You should have received a copy of the GNU Lesser General Public License
 
18
 * along with this program; if not, write to the Free Software Foundation, Inc.,
 
19
 * 51 Franklin St, Fifth Floor, Boston, MA  02110-1301 USA
 
20
 */
 
21
#include "geis_backend.h"
 
22
#include "geis_backend_protected.h"
 
23
 
 
24
#include "geis_logging.h"
 
25
#include <stdlib.h>
 
26
 
 
27
 
 
28
typedef struct _GeisBackendTestFixture
 
29
{
 
30
  struct _GeisBackend  tf_base;
 
31
} *GeisBackendTestFixture;
 
32
 
 
33
 
 
34
static void 
 
35
geis_backend_finalize(GeisBackend be)
 
36
{
 
37
  GeisBackendTestFixture tf __attribute__((unused)) = (GeisBackendTestFixture)be;
 
38
}
 
39
 
 
40
 
 
41
static struct _GeisBackendVtable tf_vtbl = {
 
42
  geis_backend_finalize
 
43
};
 
44
 
 
45
GeisBackend
 
46
geis_backend_new_test_fixture(Geis geis __attribute__((unused)))
 
47
{
 
48
  GeisBackendTestFixture tf = calloc(1, sizeof(struct _GeisBackendTestFixture));
 
49
  if (!tf)
 
50
  {
 
51
    geis_error("failed to allocate GEIS back end test fixture");
 
52
    goto nomem;
 
53
  }
 
54
 
 
55
  geis_backend_init_base(&tf->tf_base, &tf_vtbl, "GEIS2 test fixture");
 
56
 
 
57
  geis_debug("%s back end created", geis_backend_name(&tf->tf_base));
 
58
 
 
59
nomem:
 
60
  return (GeisBackend)tf;
 
61
}
 
62
 
 
63