Code

Give priority to devlibs bin directory in PATH when
[inkscape.git] / src / color-profile-test.h
index 56134ef4ae3fe338085f8a2c19f2c1436a2a3df7..cdbf76b446721bcd2f4799ed08442ab8eeb6a8fc 100644 (file)
@@ -1,61 +1,51 @@
 
+#ifndef SEEN_COLOR_PROFILE_TEST_H
+#define SEEN_COLOR_PROFILE_TEST_H
 
 #include <cxxtest/TestSuite.h>
 #include <cassert>
 
-#include "inkscape-private.h"
-#include "sp-object.h"
-#include "document.h"
+#include "test-helpers.h"
+
 
 #include "color-profile.h"
 #include "color-profile-fns.h"
 
-using Inkscape::ColorProfile;
-
-/// Dummy functions to keep linker happy
-#if !defined(DUMMY_MAIN_TEST_CALLS_SEEN)
-#define DUMMY_MAIN_TEST_CALLS_SEEN
-int sp_main_gui (int, char const**) { return 0; }
-int sp_main_console (int, char const**) { return 0; }
-#endif // DUMMY_MAIN_TEST_CALLS_SEEN
-
 class ColorProfileTest : public CxxTest::TestSuite
 {
 public:
+    SPDocument* _doc;
 
     ColorProfileTest() :
-        TestSuite(),
         _doc(0)
     {
     }
-    virtual ~ColorProfileTest() {}
 
-// createSuite and destroySuite get us per-suite setup and teardown
-// without us having to worry about static initialization order, etc.
-    static ColorProfileTest *createSuite()
+    virtual ~ColorProfileTest()
     {
-        ColorProfileTest* suite = 0;
-        bool canRun = false;
-
-        g_type_init();
-        Inkscape::GC::init();
-
-        ColorProfile *prof = static_cast<ColorProfile *>(g_object_new(COLORPROFILE_TYPE, NULL));
-        canRun = prof;
-        canRun &= prof->rendering_intent == (guint)Inkscape::RENDERING_INTENT_UNKNOWN;
-        TS_ASSERT_EQUALS( prof->rendering_intent, (guint)Inkscape::RENDERING_INTENT_UNKNOWN );
-        g_object_unref(prof);
+        if ( _doc )
+        {
+            sp_document_unref( _doc );
+        }
+    }
 
-        if ( canRun ) {
-            // Create the global inkscape object.
-            static_cast<void>(g_object_new(inkscape_get_type(), NULL));
-            SPDocument* tmp = sp_document_new_dummy();
-            if ( tmp ) {
-                suite = new ColorProfileTest();
-                suite->_doc = tmp;
+    static void createSuiteSubclass( ColorProfileTest*& dst )
+    {
+        Inkscape::ColorProfile *prof = static_cast<Inkscape::ColorProfile *>(g_object_new(COLORPROFILE_TYPE, NULL));
+        if ( prof ) {
+            if ( prof->rendering_intent == (guint)Inkscape::RENDERING_INTENT_UNKNOWN ) {
+                TS_ASSERT_EQUALS( prof->rendering_intent, (guint)Inkscape::RENDERING_INTENT_UNKNOWN );
+                dst = new ColorProfileTest();
             }
+            g_object_unref(prof);
         }
+    }
 
+// createSuite and destroySuite get us per-suite setup and teardown
+// without us having to worry about static initialization order, etc.
+    static ColorProfileTest *createSuite()
+    {
+        ColorProfileTest* suite = Inkscape::createSuiteAndDocument<ColorProfileTest>( createSuiteSubclass );
         return suite;
     }
 
@@ -64,9 +54,8 @@ public:
         delete suite; 
     }
 
-
-    SPDocument* _doc;
-
+    // ---------------------------------------------------------------
+    // ---------------------------------------------------------------
     // ---------------------------------------------------------------
 
     void testSetRenderingIntent()
@@ -85,7 +74,7 @@ public:
             {"auto2", (guint)Inkscape::RENDERING_INTENT_UNKNOWN},
         };
 
-        ColorProfile *prof = static_cast<ColorProfile *>(g_object_new(COLORPROFILE_TYPE, NULL));
+        Inkscape::ColorProfile *prof = static_cast<Inkscape::ColorProfile *>(g_object_new(COLORPROFILE_TYPE, NULL));
         TS_ASSERT( prof );
         SP_OBJECT(prof)->document = _doc;
 
@@ -105,7 +94,7 @@ public:
             "something",
         };
 
-        ColorProfile *prof = static_cast<ColorProfile *>(g_object_new(COLORPROFILE_TYPE, NULL));
+        Inkscape::ColorProfile *prof = static_cast<Inkscape::ColorProfile *>(g_object_new(COLORPROFILE_TYPE, NULL));
         TS_ASSERT( prof );
         SP_OBJECT(prof)->document = _doc;
 
@@ -129,7 +118,7 @@ public:
             "something",
         };
 
-        ColorProfile *prof = static_cast<ColorProfile *>(g_object_new(COLORPROFILE_TYPE, NULL));
+        Inkscape::ColorProfile *prof = static_cast<Inkscape::ColorProfile *>(g_object_new(COLORPROFILE_TYPE, NULL));
         TS_ASSERT( prof );
         SP_OBJECT(prof)->document = _doc;
 
@@ -147,6 +136,8 @@ public:
     }
 };
 
+#endif // SEEN_COLOR_PROFILE_TEST_H
+
 /*
   Local Variables:
   mode:c++