[PyObjC-svn] r2574 - in trunk/pyobjc/pyobjc-framework-CoreText: . Doc Lib/CoreText PyObjCTest

[email protected] Sun, 15 Aug 2010 04:56:32 -0500
Newsgroups gmane.comp.python.pyobjc.cvs
Message-ID <[email protected]>
Author: ronaldoussoren
Date: Sun Aug 15 04:56:31 2010
New Revision: 2574

Log:
* All tests now pass

* Added tests and metadata for a couple of functions that weren't available
  yet.


Modified:
   trunk/pyobjc/pyobjc-framework-CoreText/Doc/api-notes-CoreText.txt
   trunk/pyobjc/pyobjc-framework-CoreText/Lib/CoreText/PyObjC.bridgesupport
   trunk/pyobjc/pyobjc-framework-CoreText/PyObjCTest/test_ctframesetter.py
   trunk/pyobjc/pyobjc-framework-CoreText/PyObjCTest/test_ctglyphinfo.py
   trunk/pyobjc/pyobjc-framework-CoreText/PyObjCTest/test_ctrun.py
   trunk/pyobjc/pyobjc-framework-CoreText/setup.py

Modified: trunk/pyobjc/pyobjc-framework-CoreText/Doc/api-notes-CoreText.txt
==============================================================================
--- trunk/pyobjc/pyobjc-framework-CoreText/Doc/api-notes-CoreText.txt	(original)
+++ trunk/pyobjc/pyobjc-framework-CoreText/Doc/api-notes-CoreText.txt	Sun Aug 15 04:56:31 2010
@@ -43,3 +43,5 @@
 
   Use ``CTParagraphStyleGetTabStops`` to fetch the tabstops from a style object, using
   ``CTParagraphStyleGetValueSpecifieker`` is not supported with key ``kCTParagraphStyleSpecifierTabStops``.
+
+* ``CTRunGetAdvancesPtr`` is not supported, use ``CTRunGetAdvances`` instead.

Modified: trunk/pyobjc/pyobjc-framework-CoreText/Lib/CoreText/PyObjC.bridgesupport
==============================================================================
--- trunk/pyobjc/pyobjc-framework-CoreText/Lib/CoreText/PyObjC.bridgesupport	(original)
+++ trunk/pyobjc/pyobjc-framework-CoreText/Lib/CoreText/PyObjC.bridgesupport	Sun Aug 15 04:56:31 2010
@@ -921,5 +921,19 @@
     <arg type='l' type64='l' />
     <arg type='d' />
   </function>
+  <function name='CTFramesetterSuggestFrameSizeWithConstraints'>
+    <retval type='{_NSSize=ff}' type64='{CGSize=dd}' />
+    <arg type='^{__CTTypesetter=}' />
+    <arg type='{_CFRange=ll}' type64='{_CFRange=ll}' />
+    <arg type='@' />
+    <arg type='{_NSSize=ff}' type64='{CGSize=dd}' />
+    <arg type='^{_CFRange=ll}' type64='^{_CFRange=ll}' type_modifier='o' />
+  </function>
+  <function name='CTRunGetAdvances'>
+    <retval type='v' />
+    <arg type='^{__CTRun=}' />
+    <arg type='{_CFRange=ll}' type64='{_CFRange=ll}' />
+    <arg type='^{_NSSize=ff}' type64='^{CGSize=dd}' type_modifier='o' c_array_length_in_arg='1' />
+  </function>
 </signatures>
 

Modified: trunk/pyobjc/pyobjc-framework-CoreText/PyObjCTest/test_ctframesetter.py
==============================================================================
--- trunk/pyobjc/pyobjc-framework-CoreText/PyObjCTest/test_ctframesetter.py	(original)
+++ trunk/pyobjc/pyobjc-framework-CoreText/PyObjCTest/test_ctframesetter.py	Sun Aug 15 04:56:31 2010
@@ -2,6 +2,12 @@
 from PyObjCTools.TestSupport import *
 from CoreText import *
 
+try:
+    from Quartz import CGSize
+except ImportError:
+    CGSize = None, None
+
+
 class TestCTFramesetter (TestCase):
 
     def testTypes(self):
@@ -21,8 +27,26 @@
         self.assertIsInstance(v, CTTypesetterRef)
 
     @min_os_level('10.5')
+    @onlyIf(CGSize is not None, "CoreGraphics not available")
     def testMethods10_5(self):
-        self.fail('CTFramesetterSuggestFrameSizeWithConstraints')
+        #self.fail('CTFramesetterSuggestFrameSizeWithConstraints')
+        setter = CTFramesetterCreateWithAttributedString(
+                    CFAttributedStringCreate(None, u"hello", None))
+        self.assertIsInstance(setter, CTFramesetterRef)
+
+        self.assertArgIsOut(CTFramesetterSuggestFrameSizeWithConstraints, 4)
+
+        r = CTFramesetterSuggestFrameSizeWithConstraints(
+                setter, CFRange(0, 2), None, CGSize(100, 500),
+                None)
+        self.assertIsInstance(r, tuple)
+        self.assertEquals(len(r), 2)
+
+        size, range = r
+
+        self.assertIsInstance(size, CGSize)
+        self.assertIsInstance(range, CFRange)
+
 
 
 if __name__ == "__main__":

Modified: trunk/pyobjc/pyobjc-framework-CoreText/PyObjCTest/test_ctglyphinfo.py
==============================================================================
--- trunk/pyobjc/pyobjc-framework-CoreText/PyObjCTest/test_ctglyphinfo.py	(original)
+++ trunk/pyobjc/pyobjc-framework-CoreText/PyObjCTest/test_ctglyphinfo.py	Sun Aug 15 04:56:31 2010
@@ -34,7 +34,13 @@
         self.assertIsInstance(v, CTGlyphInfoRef)
 
         self.assertResultIsCFRetained(CTGlyphInfoCreateWithCharacterIdentifier)
-        v = CTGlyphInfoCreateWithCharacterIdentifier(3254, kCTIdentityMappingCharacterCollection, "(c)")
+
+        for collection in (kCTIdentityMappingCharacterCollection, kCTAdobeCNS1CharacterCollection,
+                kCTAdobeGB1CharacterCollection, kCTAdobeJapan1CharacterCollection, 
+                kCTAdobeJapan2CharacterCollection, kCTAdobeKorea1CharacterCollection):
+            v = CTGlyphInfoCreateWithCharacterIdentifier(3254, collection, "(c)")
+            if v is not None:
+                break
         self.assertIsInstance(v, CTGlyphInfoRef)
 
         v = CTGlyphInfoGetGlyphName(info)

Modified: trunk/pyobjc/pyobjc-framework-CoreText/PyObjCTest/test_ctrun.py
==============================================================================
--- trunk/pyobjc/pyobjc-framework-CoreText/PyObjCTest/test_ctrun.py	(original)
+++ trunk/pyobjc/pyobjc-framework-CoreText/PyObjCTest/test_ctrun.py	Sun Aug 15 04:56:31 2010
@@ -15,7 +15,6 @@
         self.assertEqual(kCTRunStatusHasNonIdentityMatrix, (1 << 2))
 
     def testFunctions(self):
-        return
         self.assertIsInstance(CTRunGetTypeID(), (int, long))
 
         line = CTLineCreateWithAttributedString(
@@ -88,8 +87,29 @@
 
     @min_os_level('10.5')
     def testFunctions10_5(self):
-        self.fail('CTRunGetAdvancesPtr')
-        self.fail('CTRunGetAdvances')
+        self.assertArgIsOut(CTRunGetAdvances, 2)
+        self.assertArgSizeInArg(CTRunGetAdvances, 2, 1)
+
+        line = CTLineCreateWithAttributedString(
+                CFAttributedStringCreate(None, u"hello world", None))
+        self.assertIsInstance(line, CTLineRef)
+
+        run = CTLineGetGlyphRuns(line)[0]
+        self.assertIsInstance(run, CTRunRef)
+
+        r = CTRunGetAdvances(run, CFRange(1, 3), None)
+        self.assertIsInstance(r, (list, tuple))
+        self.assertEquals(len(r), 3)
+        for i in xrange(3):
+            self.assertIsInstance(r[i], CGSize)
+
+
+        try:
+            CTRunGetAdvancesPtr
+        except NameError:
+            pass
+        else:
+            self.fail("CTRunGetAdvancesPtr is defined")
 
 
 if __name__ == "__main__":

Modified: trunk/pyobjc/pyobjc-framework-CoreText/setup.py
==============================================================================
--- trunk/pyobjc/pyobjc-framework-CoreText/setup.py	(original)
+++ trunk/pyobjc/pyobjc-framework-CoreText/setup.py	Sun Aug 15 04:56:31 2010
@@ -7,6 +7,15 @@
 for information on how to use this framework and PyObjC's documentation
 for general tips and tricks regarding the translation between Python
 and (Objective-)C frameworks
+
+NEWS
+====
+
+2.4
+---
+
+* The wrappers now cover all useful functionality (see the documentation
+  for the exceptions)
 '''
 from pyobjc_setup import setup, Extension
 

------------------------------------------------------------------------------
This SF.net email is sponsored by 

Make an app they can't live without
Enter the BlackBerry Developer Challenge
http://p.sf.net/sfu/RIM-dev2dev