2 #ifndef SEEN_TEST_HELPERS_H
3 #define SEEN_TEST_HELPERS_H
6 #include <cxxtest/TestSuite.h>
8 #include "document.h"
9 #include "inkscape-private.h"
12 /// Dummy functions to keep linker happy
13 #if !defined(DUMMY_MAIN_TEST_CALLS_SEEN)
14 #define DUMMY_MAIN_TEST_CALLS_SEEN
15 int sp_main_gui (int, char const**) { return 0; }
16 int sp_main_console (int, char const**) { return 0; }
17 #endif // DUMMY_MAIN_TEST_CALLS_SEEN
19 namespace Inkscape
20 {
22 template <class T>
23 T* createSuiteAndDocument( void (*fun)(T*&) )
24 {
25 T* suite = 0;
27 g_type_init();
28 Inkscape::GC::init();
29 if ( !inkscape_get_instance() )
30 {
31 // Create the global inkscape object.
32 static_cast<void>(g_object_new(inkscape_get_type(), NULL));
33 }
35 SPDocument* tmp = sp_document_new( NULL, TRUE, true );
36 if ( tmp ) {
37 fun( suite );
38 if ( suite )
39 {
40 suite->_doc = tmp;
41 }
42 else
43 {
44 sp_document_unref( tmp );
45 }
46 }
48 return suite;
49 }
51 } // namespace Inkscape
53 #endif // SEEN_TEST_HELPERS_H
55 /*
56 Local Variables:
57 mode:c++
58 c-file-style:"stroustrup"
59 c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +))
60 indent-tabs-mode:nil
61 fill-column:99
62 End:
63 */
64 // vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=99 :