[PyObjC-svn] r2067 - in trunk/pyobjc/pyobjc-framework-Quartz: Doc Exceptions Lib/Quartz/CoreGraphics Modules PyObjCTest

[email protected]
Newsgroups gmane.comp.python.pyobjc.cvs
Message-ID <[email protected]>
Author: ronaldoussoren
Date: Sun Mar  8 09:38:04 2009
New Revision: 2067

Log:
There's now almost complete test coverage for Quartz.CoreGraphics. The exception
begin CGPSConverter and low-level CGPDF API's (such as CGPDFArrayRef and friends).


Modified:
   trunk/pyobjc/pyobjc-framework-Quartz/Doc/api-notes.txt
   trunk/pyobjc/pyobjc-framework-Quartz/Exceptions/CoreGraphics.bridgesupport
   trunk/pyobjc/pyobjc-framework-Quartz/Lib/Quartz/CoreGraphics/PyObjC.bridgesupport
   trunk/pyobjc/pyobjc-framework-Quartz/Modules/_coregraphics.m
   trunk/pyobjc/pyobjc-framework-Quartz/PyObjCTest/test_cgdisplayconfiguration.py
   trunk/pyobjc/pyobjc-framework-Quartz/PyObjCTest/test_cgdisplayfade.py
   trunk/pyobjc/pyobjc-framework-Quartz/PyObjCTest/test_cgeventtypes.py
   trunk/pyobjc/pyobjc-framework-Quartz/PyObjCTest/test_cgfont.py
   trunk/pyobjc/pyobjc-framework-Quartz/PyObjCTest/test_cgpath.py
   trunk/pyobjc/pyobjc-framework-Quartz/PyObjCTest/test_cgpdfarray.py
   trunk/pyobjc/pyobjc-framework-Quartz/PyObjCTest/test_cgpdfcontentstream.py
   trunk/pyobjc/pyobjc-framework-Quartz/PyObjCTest/test_cgpdfcontext.py
   trunk/pyobjc/pyobjc-framework-Quartz/PyObjCTest/test_cgshading.py

Modified: trunk/pyobjc/pyobjc-framework-Quartz/Doc/api-notes.txt
==============================================================================
--- trunk/pyobjc/pyobjc-framework-Quartz/Doc/api-notes.txt	(original)
+++ trunk/pyobjc/pyobjc-framework-Quartz/Doc/api-notes.txt	Sun Mar  8 09:38:04 2009
@@ -96,3 +96,19 @@
 
 This function has an output buffer of indetermined size. You cannot pass ``None`` as the value of that buffer but have
 to explicitly specify a writable output buffer (such an ``array.array`` or the right type and size).
+
+Low-level PDF support
+---------------------
+
+Low-level PDF support in the CoreGraphics framework (such as the ``PDFArrayRef``
+type) are barely supported by PyObjC and these API's are currently not covered 
+by PyObjC's testsuite.
+
+Adding support for these API's is on the todo-list, but adding proper support
+requires work because the ``PDFArrayRef`` type (and simular types) is not
+a CoreFoundation based type.
+
+``CGPSConverter``
+------------------
+
+The API's related to CGPSConverter are not supported at the moment.

Modified: trunk/pyobjc/pyobjc-framework-Quartz/Exceptions/CoreGraphics.bridgesupport
==============================================================================
--- trunk/pyobjc/pyobjc-framework-Quartz/Exceptions/CoreGraphics.bridgesupport	(original)
+++ trunk/pyobjc/pyobjc-framework-Quartz/Exceptions/CoreGraphics.bridgesupport	Sun Mar  8 09:38:04 2009
@@ -342,6 +342,7 @@
   <function name='CGFontCreatePostScriptSubset'>
     <retval already_cfretained='true' type='^{__CFData=}' type64='^{__CFData=}' />
     <arg c_array_length_in_arg='4' index='3' type_modifier='n' />
+    <arg index='4' type_modifier='n' />
   </function>
   <function name='CGFontCreateWithDataProvider'>
     <retval already_cfretained='true' />
@@ -351,15 +352,15 @@
   </function>
   <function name='CGFontCreateWithPlatformFont'>
     <retval already_cfretained='true' />
-    <arg comment='ATSFontRef' index='0' type='L' type64='L' />
+    <arg comment='ATSFontRef' index='0' type='I' type64='I' />
   </function>
   <function name='CGFontGetGlyphAdvances'>
-    <arg c_array_length_in_arg='2' index='1' />
-    <arg c_array_length_in_arg='2' index='3' />
+    <arg c_array_length_in_arg='2' index='1' type_modifier='n' />
+    <arg c_array_length_in_arg='2' index='3' type_modifier='o' />
   </function>
   <function name='CGFontGetGlyphBBoxes'>
-    <arg c_array_length_in_arg='2' index='1' />
-    <arg c_array_length_in_arg='2' index='3' />
+    <arg c_array_length_in_arg='2' index='1' type_modifier='n' />
+    <arg c_array_length_in_arg='2' index='3' type_modifier='o' />
   </function>
   <function comment='manual wrapper' name='CGFunctionCreate'>
     <retval already_cfretained='true' />

Modified: trunk/pyobjc/pyobjc-framework-Quartz/Lib/Quartz/CoreGraphics/PyObjC.bridgesupport
==============================================================================
--- trunk/pyobjc/pyobjc-framework-Quartz/Lib/Quartz/CoreGraphics/PyObjC.bridgesupport	(original)
+++ trunk/pyobjc/pyobjc-framework-Quartz/Lib/Quartz/CoreGraphics/PyObjC.bridgesupport	Sun Mar  8 09:38:04 2009
@@ -461,11 +461,6 @@
   <string_constant name='kCGNotifyEventTapRemoved' value='com.apple.coregraphics.eventTapRemoved' />
   <string_constant name='kCGNotifyGUIConsoleSessionChanged' value='com.apple.coregraphics.GUIConsoleSessionChanged' />
   <string_constant name='kCGNotifyGUISessionUserChanged' value='com.apple.coregraphics.GUISessionUserChanged' />
-  <string_constant name='kCGPDFContextAuthor' nsstring='true' value='kCGPDFContextAuthor' />
-  <string_constant name='kCGPDFContextCreator' nsstring='true' value='kCGPDFContextCreator' />
-  <string_constant name='kCGPDFContextOutputIntent' nsstring='true' value='kCGPDFContextOutputIntent' />
-  <string_constant name='kCGPDFContextOutputIntents' nsstring='true' value='kCGPDFContextOutputIntents' />
-  <string_constant name='kCGPDFContextTitle' nsstring='true' value='kCGPDFContextTitle' />
   <string_constant name='kCGSessionConsoleSetKey' nsstring='true' value='kCGSSessionConsoleSetKey' />
   <string_constant name='kCGSessionLoginDoneKey' nsstring='true' value='kCGSessionLoginDoneKey' />
   <string_constant name='kCGSessionOnConsoleKey' nsstring='true' value='kCGSSessionOnConsoleKey' />
@@ -1955,7 +1950,7 @@
   <function name='CGFontCreatePostScriptEncoding'>
     <retval already_cfretained='true' type='^{__CFData=}' type64='^{__CFData=}' />
     <arg type='^{CGFont=}' />
-    <arg type='[256S]' />
+    <arg c_array_of_fixed_length='256' type='^S' type_modifier='n' />
   </function>
   <function name='CGFontCreatePostScriptSubset'>
     <retval already_cfretained='true' type='^{__CFData=}' type64='^{__CFData=}' />
@@ -1964,7 +1959,7 @@
     <arg type='i' />
     <arg c_array_length_in_arg='4' type='^S' type_modifier='n' />
     <arg type='L' type64='L' />
-    <arg type='[256S]' />
+    <arg c_array_of_fixed_length='256' type='^S' type_modifier='n' />
   </function>
   <function name='CGFontCreateWithDataProvider'>
     <retval already_cfretained='true' type='^{CGFont=}' />
@@ -1976,7 +1971,7 @@
   </function>
   <function name='CGFontCreateWithPlatformFont'>
     <retval already_cfretained='true' type='^{CGFont=}' />
-    <arg type='L' type64='L' />
+    <arg type='I' type64='I' />
   </function>
   <function name='CGFontGetAscent'>
     <retval type='i' />
@@ -1997,16 +1992,16 @@
   <function name='CGFontGetGlyphAdvances'>
     <retval type='Z' />
     <arg type='^{CGFont=}' />
-    <arg c_array_length_in_arg='2' type='^S' />
+    <arg c_array_length_in_arg='2' type='^S' type_modifier='n' />
     <arg type='L' type64='L' />
-    <arg c_array_length_in_arg='2' type='^i' />
+    <arg c_array_length_in_arg='2' type='^i' type_modifier='o' />
   </function>
   <function name='CGFontGetGlyphBBoxes'>
     <retval type='Z' />
     <arg type='^{CGFont=}' />
-    <arg c_array_length_in_arg='2' type='^S' />
+    <arg c_array_length_in_arg='2' type='^S' type_modifier='n' />
     <arg type='L' type64='L' />
-    <arg c_array_length_in_arg='2' type='^{CGRect={CGPoint=ff}{CGSize=ff}}' type64='^{CGRect={CGPoint=ff}{CGSize=ff}}' />
+    <arg c_array_length_in_arg='2' type='^{CGRect={CGPoint=ff}{CGSize=ff}}' type64='^{CGRect={CGPoint=ff}{CGSize=ff}}' type_modifier='o' />
   </function>
   <function name='CGFontGetGlyphWithGlyphName'>
     <retval type='S' />

Modified: trunk/pyobjc/pyobjc-framework-Quartz/Modules/_coregraphics.m
==============================================================================
--- trunk/pyobjc/pyobjc-framework-Quartz/Modules/_coregraphics.m	(original)
+++ trunk/pyobjc/pyobjc-framework-Quartz/Modules/_coregraphics.m	Sun Mar  8 09:38:04 2009
@@ -7,6 +7,61 @@
 #import <ApplicationServices/ApplicationServices.h>
 
 static PyObject*
+m_CGFontCopyTableTags(PyObject* self __attribute__((__unused__)), 
+		PyObject* args)
+{
+	PyObject* py_font;
+	CGFontRef font;
+	CFArrayRef tags;
+
+	if (!PyArg_ParseTuple(args, "O", &py_font)) {
+		return NULL;
+	}
+
+	if (PyObjC_PythonToObjC(@encode(CGFontRef), py_font, &font) == -1) {
+		return NULL;
+	}
+
+	tags = NULL;
+	PyObjC_DURING
+		tags = CGFontCopyTableTags(font);
+
+	PyObjC_HANDLER
+		tags = NULL;
+		PyObjCErr_FromObjC(localException);
+	PyObjC_ENDHANDLER
+
+	if (tags == NULL && PyErr_Occurred()) {
+		return NULL;
+	}
+
+	if (tags == NULL)  {
+		Py_INCREF(Py_None);
+		return Py_None;
+	}
+
+	Py_ssize_t len = CFArrayGetCount(tags);
+	Py_ssize_t i;
+	PyObject* result = PyTuple_New(len);
+	if (result == NULL) {
+		CFRelease(tags);
+		return NULL;
+	}
+
+	for (i = 0; i < len; i++) {
+		uint32_t cur = (uint32_t)(uintptr_t)CFArrayGetValueAtIndex(tags, i);
+		PyObject* v = PyObjC_ObjCToPython(@encode(uint32_t), &cur);
+		if (v == NULL) {
+			CFRelease(tags);
+			return NULL;
+		}
+		PyTuple_SET_ITEM(result, i, v);
+	}
+	CFRelease(tags);
+	return result;
+}
+
+static PyObject*
 m_CGWindowListCreate(PyObject* self __attribute__((__unused__)), 
 		PyObject* args)
 {
@@ -279,6 +334,12 @@
 
 static PyMethodDef m_methods[] = {
 	{
+		"CGFontCopyTableTags",
+		(PyCFunction)m_CGFontCopyTableTags,
+		METH_VARARGS,
+		NULL
+	},
+	{
 		"CGWindowListCreate",
 		(PyCFunction)m_CGWindowListCreate,
 		METH_VARARGS,

Modified: trunk/pyobjc/pyobjc-framework-Quartz/PyObjCTest/test_cgdisplayconfiguration.py
==============================================================================
--- trunk/pyobjc/pyobjc-framework-Quartz/PyObjCTest/test_cgdisplayconfiguration.py	(original)
+++ trunk/pyobjc/pyobjc-framework-Quartz/PyObjCTest/test_cgdisplayconfiguration.py	Sun Mar  8 09:38:04 2009
@@ -141,10 +141,5 @@
         self.failUnlessEqual(kCGDisplayUnMirrorFlag, (1 << 11))
         self.failUnlessEqual(kCGDisplayDesktopShapeChangedFlag, (1 << 12))
 
-        
-
-
-
-
 if __name__ == "__main__":
     main()

Modified: trunk/pyobjc/pyobjc-framework-Quartz/PyObjCTest/test_cgdisplayfade.py
==============================================================================
--- trunk/pyobjc/pyobjc-framework-Quartz/PyObjCTest/test_cgdisplayfade.py	(original)
+++ trunk/pyobjc/pyobjc-framework-Quartz/PyObjCTest/test_cgdisplayfade.py	Sun Mar  8 09:38:04 2009
@@ -33,8 +33,5 @@
         self.failUnlessIsInstance(v, (int, long))
 
 
-
-
-
 if __name__ == "__main__":
     main()

Modified: trunk/pyobjc/pyobjc-framework-Quartz/PyObjCTest/test_cgeventtypes.py
==============================================================================
--- trunk/pyobjc/pyobjc-framework-Quartz/PyObjCTest/test_cgeventtypes.py	(original)
+++ trunk/pyobjc/pyobjc-framework-Quartz/PyObjCTest/test_cgeventtypes.py	Sun Mar  8 09:38:04 2009
@@ -126,7 +126,5 @@
         self.failUnless(hasattr(v, 'maxUsecLatency'))
 
 
-
-
 if __name__ == "__main__":
     main()

Modified: trunk/pyobjc/pyobjc-framework-Quartz/PyObjCTest/test_cgfont.py
==============================================================================
--- trunk/pyobjc/pyobjc-framework-Quartz/PyObjCTest/test_cgfont.py	(original)
+++ trunk/pyobjc/pyobjc-framework-Quartz/PyObjCTest/test_cgfont.py	Sun Mar  8 09:38:04 2009
@@ -91,20 +91,73 @@
         self.failUnlessIsInstance(v, bool)
         
 
-
-
-
-    def testMissing(self):
-        self.fail('GFontCreateWithPlatformFont')
-        self.fail('CGFontCreateWithDataProvider')
-        self.fail('CGFontGetGlyphAdvances')
-        self.fail('CGFontGetGlyphBBoxes')
-        self.fail('CGFontGetGlyphWithGlyphName')
-        self.fail('CGFontCopyGlyphNameForGlyph')
-        self.fail('CGFontCreatePostScriptSubset')
-        self.fail('CGFontCreatePostScriptEncoding')
-        self.fail('CGFontCopyTableTags')
-        self.fail('CGFontCopyTableForTag')
+        # PyObjC doesn't wrap ATSUI, therefore we cannot actually call
+        # the function.
+        #self.fail('CGFontCreateWithPlatformFont')
+        self.failUnlessArgHasType(CGFontCreateWithPlatformFont, 0,
+                objc._C_UINT)
+        self.failUnlessResultIsCFRetained(CGFontCreateWithPlatformFont)
+
+
+        data = open('/Library/Fonts/Webdings.ttf', 'rb').read()
+        self.failUnlessResultIsCFRetained(CGFontCreateWithDataProvider)
+        font = CGFontCreateWithDataProvider(
+                CGDataProviderCreateWithCFData(buffer(data))
+        )
+        self.failUnlessIsInstance(font, CGFontRef)
+
+        tags = CGFontCopyTableTags(font)
+        self.failUnlessIsInstance(tags, tuple)
+        self.failIfEqual(len(tags), 0)
+        self.failUnlessIsInstance(tags[0], (int, long))
+
+        self.failUnlessResultIsCFRetained(CGFontCopyTableForTag)
+        for tg in tags:
+            data = CGFontCopyTableForTag(font, 0)
+            if data is None:
+                continue
+            self.failUnlessIsInstance(data, CFDataRef)
+
+        v = CGFontCopyGlyphNameForGlyph(font, ord('A'))
+        self.failUnlessIsInstance(v, unicode)
+
+        glyphnames = ['chat', 'conference', 'woman' ]
+
+        v = CGFontGetGlyphWithGlyphName(font, glyphnames[0])
+        self.failUnlessIsInstance(v, (int, long))
+
+        glyphs = [ CGFontGetGlyphWithGlyphName(font, nm)
+                    for nm in glyphnames ]
+
+        self.failUnlessResultHasType(CGFontGetGlyphAdvances, objc._C_BOOL)
+        v, advances = CGFontGetGlyphAdvances(
+                font, glyphs, len(glyphs), None)
+        self.failUnlessIsInstance(v, bool)
+        self.failUnlessEqual(len(advances), 3)
+        for v in advances:
+            self.failUnlessIsInstance(v, (int, long))
+
+        self.failUnlessResultHasType(CGFontGetGlyphBBoxes, objc._C_BOOL)
+        v, bboxes = CGFontGetGlyphBBoxes(
+                font, glyphs, len(glyphs), None)
+        self.failUnlessIsInstance(v, bool)
+        self.failUnlessEqual(len(bboxes), 3)
+        for v in bboxes:
+            self.failUnlessIsInstance(v, CGRect)
+
+        self.failUnlessResultIsCFRetained(CGFontCreatePostScriptSubset)
+        psfont = CGFontCreatePostScriptSubset(
+                font, "pybobjc-characters",
+                kCGFontPostScriptFormatType42,
+                glyphs, len(glyphs), None)
+        self.failUnlessIsInstance(psfont, CFDataRef)
+
+
+        self.failUnlessResultIsCFRetained(CGFontCreatePostScriptEncoding)
+        map = glyphs + [0]*(256-len(glyphs))
+        psfont = CGFontCreatePostScriptEncoding(
+                font, map)
+        self.failUnlessIsInstance(psfont, CFDataRef)
     
 
 

Modified: trunk/pyobjc/pyobjc-framework-Quartz/PyObjCTest/test_cgpath.py
==============================================================================
--- trunk/pyobjc/pyobjc-framework-Quartz/PyObjCTest/test_cgpath.py	(original)
+++ trunk/pyobjc/pyobjc-framework-Quartz/PyObjCTest/test_cgpath.py	Sun Mar  8 09:38:04 2009
@@ -138,8 +138,5 @@
 
 
 
-
-
-
 if __name__ == "__main__":
     main()

Modified: trunk/pyobjc/pyobjc-framework-Quartz/PyObjCTest/test_cgpdfarray.py
==============================================================================
--- trunk/pyobjc/pyobjc-framework-Quartz/PyObjCTest/test_cgpdfarray.py	(original)
+++ trunk/pyobjc/pyobjc-framework-Quartz/PyObjCTest/test_cgpdfarray.py	Sun Mar  8 09:38:04 2009
@@ -6,5 +6,40 @@
     def testIncomplete(self):
         self.fail("Add header tests for <CoreGraphics/CGPDFArray.h>")
 
+    def testTypes(self):
+        self.failUnlessIsOpaquePointer(CGPDFArrayRef)
+
+    def testFunctions(self):
+        self.failUnlessResultHasType(CGPDFArrayGetArray, objc._C_BOOL)
+        self.failUnlessArgIsOut(CGPDFArrayGetArray, 2)
+
+        self.failUnlessResultHasType(CGPDFArrayGetBoolean, objc._C_BOOL)
+        self.failUnlessArgIsOut(CGPDFArrayGetBoolean, 2)
+
+        self.failUnlessResultHasType(CGPDFArrayGetDictionary, objc._C_BOOL)
+        self.failUnlessArgIsOut(CGPDFArrayGetDictionary, 2)
+
+        self.failUnlessResultHasType(CGPDFArrayGetInteger, objc._C_BOOL)
+        self.failUnlessArgIsOut(CGPDFArrayGetInteger, 2)
+
+        self.failUnlessResultHasType(CGPDFArrayGetName, objc._C_BOOL)
+        self.failUnlessArgIsOut(CGPDFArrayGetName, 2)
+
+        self.failUnlessResultHasType(CGPDFArrayGetNull, objc._C_BOOL)
+
+        self.failUnlessResultHasType(CGPDFArrayGetNumber, objc._C_BOOL)
+        self.failUnlessArgIsOut(CGPDFArrayGetNumber, 2)
+
+        self.failUnlessResultHasType(CGPDFArrayGetObject, objc._C_BOOL)
+        self.failUnlessArgIsOut(CGPDFArrayGetObject, 2)
+
+        self.failUnlessResultHasType(CGPDFArrayGetStream, objc._C_BOOL)
+        self.failUnlessArgIsOut(CGPDFArrayGetStream, 2)
+
+        self.failUnlessResultHasType(CGPDFArrayGetString, objc._C_BOOL)
+        self.failUnlessArgIsOut(CGPDFArrayGetString, 2)
+
+        CGPDFArrayGetCount
+
 if __name__ == "__main__":
     main()

Modified: trunk/pyobjc/pyobjc-framework-Quartz/PyObjCTest/test_cgpdfcontentstream.py
==============================================================================
--- trunk/pyobjc/pyobjc-framework-Quartz/PyObjCTest/test_cgpdfcontentstream.py	(original)
+++ trunk/pyobjc/pyobjc-framework-Quartz/PyObjCTest/test_cgpdfcontentstream.py	Sun Mar  8 09:38:04 2009
@@ -3,8 +3,34 @@
 from Quartz.CoreGraphics import *
 
 class TestCGPDFContentStream (TestCase):
+    def testTypes(self):
+        self.failUnlessIsOpaquePointer(CGPDFContentStreamRef)
+
+    def testFunctions(self):
+        doc = CGPDFDocumentCreateWithURL(
+                CFURLCreateWithFileSystemPath(None,
+                    "/Library/Documentation/Applications/iMovie/Acknowledgements.pdf",
+                    kCFURLPOSIXPathStyle, False))
+        self.failUnlessIsInstance(doc, CGPDFDocumentRef)
+
+        page = CGPDFDocumentGetPage(doc, 1)
+        self.failUnlessIsInstance(page, CGPDFPageRef)
+
+        stream = CGPDFContentStreamCreateWithPage(page)
+        self.failUnlessIsInstance(stream, CGPDFContentStreamRef)
+
+
+        v = CGPDFContentStreamRetain(stream)
+        self.failUnlessEqual(v.__pointer__, stream.__pointer__)
+
+
     def testIncomplete(self):
-        self.fail("Add header tests for <CoreGraphics/CGPDFContentStream.h>")
+        self.fail("CGPDFContentStreamRelease")
+        self.fail("CGPDFContentStreamGetResource")
+        self.fail("CGPDFContentStreamGetStreams") # Need manual wrapper
+
+
+
 
 if __name__ == "__main__":
     main()

Modified: trunk/pyobjc/pyobjc-framework-Quartz/PyObjCTest/test_cgpdfcontext.py
==============================================================================
--- trunk/pyobjc/pyobjc-framework-Quartz/PyObjCTest/test_cgpdfcontext.py	(original)
+++ trunk/pyobjc/pyobjc-framework-Quartz/PyObjCTest/test_cgpdfcontext.py	Sun Mar  8 09:38:04 2009
@@ -1,10 +1,69 @@
 
 from PyObjCTools.TestSupport import *
 from Quartz.CoreGraphics import *
+from Foundation import NSMutableData
 
 class TestCGPDFContext (TestCase):
-    def testIncomplete(self):
-        self.fail("Add header tests for <CoreGraphics/CGPDFContext.h>")
+    def testFunctions(self):
+        data = NSMutableData.data()
+        self.failUnlessIsInstance(data, CFMutableDataRef)
+
+        consumer = CGDataConsumerCreateWithCFData(data)
+        self.failUnlessIsInstance(consumer, CGDataConsumerRef)
+
+        self.failUnlessArgIsIn(CGPDFContextCreate, 1)
+        self.failUnlessResultIsCFRetained(CGPDFContextCreate)
+        context = CGPDFContextCreate(consumer, None, None)
+        self.failUnlessIsInstance(context, CGContextRef)
+
+        CGPDFContextClose(context)
+
+        self.failUnlessResultIsCFRetained(CGPDFContextCreateWithURL)
+        url = CFURLCreateWithFileSystemPath(None,
+            "/tmp/pyobjc.test.pdf", kCFURLPOSIXPathStyle, False)
+        self.failUnlessArgIsIn(CGPDFContextCreateWithURL, 1)
+        context = CGPDFContextCreateWithURL(url, None, None)
+        self.failUnlessIsInstance(context, CGContextRef)
+
+        CGPDFContextBeginPage(context, None)
+
+        CGPDFContextSetURLForRect(context, url, ((0, 0), (10, 10)))
+        CGPDFContextAddDestinationAtPoint(context, "target", (50, 50))
+
+        CGPDFContextSetDestinationForRect(context, "target", ((100, 120), (50, 60)))
+
+        CGPDFContextEndPage(context)
+
+        CGPDFContextClose(context)
+
+    def testConstants(self):
+        self.failUnlessIsInstance(kCGPDFContextMediaBox, unicode)
+        self.failUnlessIsInstance(kCGPDFContextCropBox, unicode)
+        self.failUnlessIsInstance(kCGPDFContextBleedBox, unicode)
+        self.failUnlessIsInstance(kCGPDFContextTrimBox, unicode)
+        self.failUnlessIsInstance(kCGPDFContextArtBox, unicode)
+        self.failUnlessIsInstance(kCGPDFContextTitle, unicode)
+        self.failUnlessIsInstance(kCGPDFContextAuthor, unicode)
+        self.failUnlessIsInstance(kCGPDFContextSubject, unicode)
+        self.failUnlessIsInstance(kCGPDFContextKeywords, unicode)
+        self.failUnlessIsInstance(kCGPDFContextCreator, unicode)
+        self.failUnlessIsInstance(kCGPDFContextOwnerPassword, unicode)
+        self.failUnlessIsInstance(kCGPDFContextUserPassword, unicode)
+        self.failUnlessIsInstance(kCGPDFContextEncryptionKeyLength, unicode)
+        self.failUnlessIsInstance(kCGPDFContextAllowsPrinting, unicode)
+        self.failUnlessIsInstance(kCGPDFContextAllowsCopying, unicode)
+        self.failUnlessIsInstance(kCGPDFContextOutputIntent, unicode)
+        self.failUnlessIsInstance(kCGPDFXOutputIntentSubtype, unicode)
+        self.failUnlessIsInstance(kCGPDFXOutputConditionIdentifier, unicode)
+        self.failUnlessIsInstance(kCGPDFXOutputCondition, unicode)
+        self.failUnlessIsInstance(kCGPDFXRegistryName, unicode)
+        self.failUnlessIsInstance(kCGPDFXInfo, unicode)
+        self.failUnlessIsInstance(kCGPDFXDestinationOutputProfile, unicode)
+        self.failUnlessIsInstance(kCGPDFContextOutputIntents, unicode)
+
+
+
+
 
 if __name__ == "__main__":
     main()

Modified: trunk/pyobjc/pyobjc-framework-Quartz/PyObjCTest/test_cgshading.py
==============================================================================
--- trunk/pyobjc/pyobjc-framework-Quartz/PyObjCTest/test_cgshading.py	(original)
+++ trunk/pyobjc/pyobjc-framework-Quartz/PyObjCTest/test_cgshading.py	Sun Mar  8 09:38:04 2009
@@ -3,15 +3,47 @@
 from Quartz.CoreGraphics import *
 
 class TestCGShading (TestCase):
-    def testIncomplete(self):
-        self.fail("Add header tests for <CoreGraphics/CGShading.h>")
-
     def testTypes(self):
         self.failUnlessIsCFType(CGShadingRef)
 
     def testFunctions(self):
         self.failUnlessIsInstance(CGShadingGetTypeID(), (int, long))
 
+        values = []
+        def evaluate(info, input, output):
+            values.append(input)
+            return input * 4
+        
+        self.failUnlessIsInstance(CGFunctionGetTypeID(), (int, long))
+
+        myInfo = object()
+        func = CGFunctionCreate(myInfo, 1, [0, 1], 4, [0, 1, 0, 1, 0, 1, 0, 1], evaluate)
+        self.failUnlessIsInstance(func, CGFunctionRef)
+
+
+        self.failUnlessResultIsCFRetained(CGShadingCreateAxial)
+        self.failUnlessArgHasType(CGShadingCreateAxial, 4, objc._C_BOOL)
+        self.failUnlessArgHasType(CGShadingCreateAxial, 5, objc._C_BOOL)
+        shading = CGShadingCreateAxial(
+                CGColorSpaceCreateDeviceRGB(), CGPoint(0, 0), CGPoint(50, 200),
+                func, False, False)
+        self.failUnlessIsInstance(shading, CGShadingRef)
+
+        self.failUnlessResultIsCFRetained(CGShadingCreateRadial)
+        self.failUnlessArgHasType(CGShadingCreateRadial, 6, objc._C_BOOL)
+        self.failUnlessArgHasType(CGShadingCreateRadial, 7, objc._C_BOOL)
+        shading = CGShadingCreateRadial(
+                CGColorSpaceCreateDeviceRGB(), CGPoint(0, 0), 5.0, 
+                CGPoint(50, 200), 10.5, func, False, False)
+        self.failUnlessIsInstance(shading, CGShadingRef)
+
+        v = CGShadingRetain(shading)
+        self.failUnless(v is shading)
+
+        CGShadingRelease(shading)
+
+
+
 
 if __name__ == "__main__":
     main()

------------------------------------------------------------------------------
Open Source Business Conference (OSBC), March 24-25, 2009, San Francisco, CA
-OSBC tackles the biggest issue in open source: Open Sourcing the Enterprise
-Strategies to boost innovation and cut costs with open source participation
-Receive a $600 discount off the registration fee with the source code: SFAD
http://p.sf.net/sfu/XcvMzF8H
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.