Code

Fix change in revision 9947 to be consistent with rest of the codebase.
[inkscape.git] / src / test-helpers.h
1 #ifndef SEEN_TEST_HELPERS_H
2 #define SEEN_TEST_HELPERS_H
5 #include <cxxtest/TestSuite.h>
7 #include "document.h"
8 #include "inkscape-private.h"
11 /// Dummy functions to keep linker happy
12 #if !defined(DUMMY_MAIN_TEST_CALLS_SEEN)
13 #define DUMMY_MAIN_TEST_CALLS_SEEN
14 int sp_main_gui (int, char const**) { return 0; }
15 int sp_main_console (int, char const**) { return 0; }
16 #endif // DUMMY_MAIN_TEST_CALLS_SEEN
18 namespace Inkscape
19 {
21 template <class T>
22 T* createSuiteAndDocument( void (*fun)(T*&) )
23 {
24     T* suite = 0;
26     g_type_init();
27     Inkscape::GC::init();
28     if ( !inkscape_get_instance() )
29     {
30         // Create the global inkscape object.
31         static_cast<void>(g_object_new(inkscape_get_type(), NULL));
32     }
34     SPDocument* tmp = SPDocument::createNewDoc( NULL, TRUE, true );
35     if ( tmp ) {
36         fun( suite );
37         if ( suite )
38         {
39             suite->_doc = tmp;
40         }
41         else
42         {
43             tmp->doUnref();
44         }
45     }
47     return suite;
48 }
50 } // namespace Inkscape
52 #endif // SEEN_TEST_HELPERS_H
54 /*
55   Local Variables:
56   mode:c++
57   c-file-style:"stroustrup"
58   c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +))
59   indent-tabs-mode:nil
60   fill-column:99
61   End:
62 */
63 // vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8:textwidth=99 :