1 /* -*- Mode: C; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3  *  Copyright (C) 2007-2009  Kouhei Sutou <kou@cozmixng.org>
4  *
5  *  This library is free software: you can redistribute it and/or modify
6  *  it under the terms of the GNU Lesser General Public License as published by
7  *  the Free Software Foundation, either version 3 of the License, or
8  *  (at your option) any later version.
9  *
10  *  This library is distributed in the hope that it will be useful,
11  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
12  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13  *  GNU Lesser General Public License for more details.
14  *
15  *  You should have received a copy of the GNU Lesser General Public License
16  *  along with this program.  If not, see <http://www.gnu.org/licenses/>.
17  *
18  */
19 
20 #ifndef __CUT_TEST_CASE_H__
21 #define __CUT_TEST_CASE_H__
22 
23 #include <glib-object.h>
24 
25 #include <cutter/cut-test-container.h>
26 #include <cutter/cut-test-iterator.h>
27 
28 G_BEGIN_DECLS
29 
30 #define CUT_TYPE_TEST_CASE            (cut_test_case_get_type ())
31 #define CUT_TEST_CASE(obj)            (G_TYPE_CHECK_INSTANCE_CAST ((obj), CUT_TYPE_TEST_CASE, CutTestCase))
32 #define CUT_TEST_CASE_CLASS(klass)    (G_TYPE_CHECK_CLASS_CAST ((klass), CUT_TYPE_TEST_CASE, CutTestCaseClass))
33 #define CUT_IS_TEST_CASE(obj)         (G_TYPE_CHECK_INSTANCE_TYPE ((obj), CUT_TYPE_TEST_CASE))
34 #define CUT_IS_TEST_CASE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), CUT_TYPE_TEST_CASE))
35 #define CUT_TEST_CASE_GET_CLASS(obj)  (G_TYPE_INSTANCE_GET_CLASS((obj), CUT_TYPE_TEST_CASE, CutTestCaseClass))
36 
37 typedef void (*CutStartupFunction)    (void);
38 typedef void (*CutShutdownFunction)   (void);
39 
40 typedef struct _CutTestCaseClass CutTestCaseClass;
41 
42 struct _CutTestCase
43 {
44     CutTestContainer object;
45 };
46 
47 struct _CutTestCaseClass
48 {
49     CutTestContainerClass parent_class;
50 
51     void (*ready)         (CutTestCase    *test_case,
52                            guint           n_tests);
53     void (*start_test)    (CutTestCase    *test_case,
54                            CutTest        *test,
55                            CutTestContext *test_context);
56     void (*complete_test) (CutTestCase    *test_case,
57                            CutTest        *test,
58                            CutTestContext *test_context);
59     void (*start_test_iterator)
60                           (CutTestCase    *test_case,
61                            CutTestIterator *test_iterator,
62                            CutTestContext *test_context);
63     void (*complete_test_iterator)
64                           (CutTestCase    *test_case,
65                            CutTestIterator *test_iterator,
66                            CutTestContext *test_context,
67                            gboolean        success);
68 
69     void (*failure_in)    (CutTestCase    *test_case,
70                            CutTestContext *test_context,
71                            CutTestResult  *result);
72     void (*error_in)      (CutTestCase    *test_case,
73                            CutTestContext *test_context,
74                            CutTestResult  *result);
75     void (*pending_in)    (CutTestCase    *test_case,
76                            CutTestContext *test_context,
77                            CutTestResult  *result);
78     void (*notification_in)
79                           (CutTestCase    *test_case,
80                            CutTestContext *test_context,
81                            CutTestResult  *result);
82     void (*omission_in)   (CutTestCase    *test_case,
83                            CutTestContext *test_context,
84                            CutTestResult  *result);
85     void (*crash_in)      (CutTestCase    *test_case,
86                            CutTestContext *test_context,
87                            CutTestResult  *result);
88 };
89 
90 GType        cut_test_case_get_type       (void) G_GNUC_CONST;
91 
92 CutTestCase *cut_test_case_new            (const gchar *name,
93                                            CutSetupFunction setup,
94                                            CutTeardownFunction teardown,
95                                            CutStartupFunction startup,
96                                            CutShutdownFunction shutdown);
97 CutTestCase *cut_test_case_new_empty      (void);
98 void         cut_test_case_add_test       (CutTestCase *test_case,
99                                            CutTest *test);
100 gboolean     cut_test_case_run            (CutTestCase   *test_case,
101                                            CutRunContext *run_context);
102 gboolean     cut_test_case_run_test       (CutTestCase   *test_case,
103                                            CutRunContext *run_context,
104                                            const gchar   *name);
105 gboolean     cut_test_case_run_with_filter(CutTestCase   *test_case,
106                                            CutRunContext *run_context,
107                                            const gchar  **test_names);
108 
109 void         cut_test_case_run_setup      (CutTestCase    *test_case,
110                                            CutTestContext *test_context);
111 void         cut_test_case_run_teardown   (CutTestCase    *test_case,
112                                            CutTestContext *test_context);
113 
114 G_END_DECLS
115 
116 #endif /* __CUT_TEST_CASE_H__ */
117 
118 /*
119 vi:nowrap:ai:expandtab:sw=4
120 */
121