2009-27-09 Mark Doffman <mark.doffman@codethink.co.uk>
[platform/core/uifw/at-spi2-atk.git] / tests / cspi / classy-test.h
1 /* 
2  * Classy Test - Terrible framework for testing asyncronous interface
3  *
4  * Copyright (C) 2008 Codethink Ltd
5  *
6  * This library is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU Lesser General Public
8  * License as published by the Free Software Foundation; either
9  * version 2 of the License, or (at your option) any later version.
10  *
11  * This library is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
14  * Lesser General Public License for more details.
15  *
16  * You should have received a copy of the GNU Lesser General Public
17  * License along with this library; if not, write to the
18  * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
19  * Boston, MA 02111-1307, USA.
20  */
21 #ifndef CLASSY_TEST_H
22 #define CLASSY_TEST_H
23
24 #include <glib-object.h>
25
26 G_BEGIN_DECLS
27
28 GType classy_test_get_type(void);
29
30 #define TYPE_CLASSY_TEST (classy_test_get_type())
31
32 #define CLASSY_TEST(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj),     \
33                           TYPE_CLASSY_TEST,                     \
34                           ClassyTest))
35
36 #define CLASSY_TEST_CLASS(klass)     (G_TYPE_CHECK_CLASS_CAST((klass),  \
37                                       TYPE_CLASSY_TEST,                 \
38                                       ClassyTestClass))
39
40 #define IS_CLASSY_TEST(obj)          (G_TYPE_CHECK_INSTANCE_TYPE((obj), \
41                                      TYPE_CLASSY_TEST))
42
43 #define IS_CLASSY_TEST_CLASS(klass)  (G_TYPE_CHECK_CLASS_TYPE((klass),  \
44                                       TYPE_CLASSY_TEST))
45
46 #define CLASSY_TEST_GET_CLASS(obj)   (G_TYPE_INSTANCE_GET_CLASS((obj),  \
47                                       TYPE_CLASSY_TEST,                 \
48                                       ClassyTestClass))
49
50 typedef struct _ClassyTest ClassyTest;
51 typedef struct _ClassyTestClass ClassyTestClass;
52
53 enum {
54         CLASSY_TEST_NOT_STARTED,
55         CLASSY_TEST_IN_PROGRESS,
56         CLASSY_TEST_FAIL,
57         CLASSY_TEST_WIN
58 };
59
60 struct _ClassyTest {
61         GObject parent;
62
63         gchar *name;
64         gchar *failm;
65         gint tstate;
66
67         void (*entry) (ClassyTest *tc, gpointer data);
68
69         gpointer data;
70 };
71
72 struct _ClassyTestClass {
73         GObjectClass parent;
74
75         /*Virtuals*/
76         gchar *(*report) (ClassyTest *test);
77         void   (*run)    (ClassyTest *test);
78
79         /*Signals*/
80         gint finished;
81 };
82
83 ClassyTest *
84 classy_test_new(gchar *name,
85                 void (*entry) (ClassyTest*, gpointer data),
86                 gint istate,
87                 gpointer data);
88
89 void
90 classy_test_pass(ClassyTest *test);
91
92 void
93 classy_test_fail(ClassyTest *test, gchar *fmt, ...);
94
95 gint
96 classy_test_state(ClassyTest *test);
97
98 G_END_DECLS
99 #endif /* CLASSY_TEST_H */