[PyObjC-svn] r2585 - in trunk/pyobjc/pyobjc-framework-LaunchServices: Doc Lib/LaunchServices PyObjCTest
[email protected] Sun, 15 Aug 2010 16:25:19 -0500
| Newsgroups | gmane.comp.python.pyobjc.cvs |
|---|---|
| Message-ID | <[email protected]> |
Author: ronaldoussoren
Date: Sun Aug 15 16:25:18 2010
New Revision: 2585
Log:
* Update api notes
* Expand test coverage
* Ensure that those tests pass
(except for a couple of APIs that aren't supported
right now and those are marked as such)
Modified:
trunk/pyobjc/pyobjc-framework-LaunchServices/Doc/api-notes-LaunchServices.txt
trunk/pyobjc/pyobjc-framework-LaunchServices/Lib/LaunchServices/PyObjC.bridgesupport
trunk/pyobjc/pyobjc-framework-LaunchServices/Lib/LaunchServices/__init__.py
trunk/pyobjc/pyobjc-framework-LaunchServices/PyObjCTest/test_lsinfo.py
trunk/pyobjc/pyobjc-framework-LaunchServices/PyObjCTest/test_lsopen.py
trunk/pyobjc/pyobjc-framework-LaunchServices/PyObjCTest/test_lssharedfilelist.py
Modified: trunk/pyobjc/pyobjc-framework-LaunchServices/Doc/api-notes-LaunchServices.txt
==============================================================================
--- trunk/pyobjc/pyobjc-framework-LaunchServices/Doc/api-notes-LaunchServices.txt (original)
+++ trunk/pyobjc/pyobjc-framework-LaunchServices/Doc/api-notes-LaunchServices.txt Sun Aug 15 16:25:18 2010
@@ -7,10 +7,20 @@
Not supported at the moment because the Authorization framweork isn't properly
wrapped yet.
-* ``LSSharedFileListItemRef``
+* ``LSLaunchFSRefSpec``, ``LSLaunchURLSpec``
- Not tested at the moment, uses ``LSSharedFileListInsertItemURL`` instead.
+ These types aren't supported in this version.
-* The tests for this framework are incomplete, although
- most functions should work just fine.
+* ``LSOpenApplication``
+
+ This function is not yet supported. The bridge itself isn't smart
+ enough yet to process the first argument without a manual wrapper.
+
+* ``LSOpenItemsWithRole``, ``LSOpenURLsWithRole``
+
+ The ``inAEParam`` and ``inAppParams`` must be None.
+
+* ``LSOpenFromRefSpec``, ``LSOpenFromURLSpec``
+
+ This functions are not yet supported and need manual wrappers.
Modified: trunk/pyobjc/pyobjc-framework-LaunchServices/Lib/LaunchServices/PyObjC.bridgesupport
==============================================================================
--- trunk/pyobjc/pyobjc-framework-LaunchServices/Lib/LaunchServices/PyObjC.bridgesupport (original)
+++ trunk/pyobjc/pyobjc-framework-LaunchServices/Lib/LaunchServices/PyObjC.bridgesupport Sun Aug 15 16:25:18 2010
@@ -38,11 +38,9 @@
<constant name='kLSSharedFileListFavoriteItems' type='^{__CFString=}' />
<constant name='kLSSharedFileListFavoriteVolumes' type='^{__CFString=}' />
<constant name='kLSSharedFileListGlobalLoginItems' type='^{__CFString=}' />
- <!--
<constant name='kLSSharedFileListItemBeforeFirst' type='^{OpaqueLSSharedFileListItemRef=}' magic_cookie='true' />
- <constant name='kLSSharedFileListItemHidden' type='^{__CFString=}' />
<constant name='kLSSharedFileListItemLast' type='^{OpaqueLSSharedFileListItemRef=}' magic_cookie='true' />
- -->
+ <constant name='kLSSharedFileListItemHidden' type='^{__CFString=}' />
<constant name='kLSSharedFileListRecentApplicationItems' type='^{__CFString=}' />
<constant name='kLSSharedFileListRecentDocumentItems' type='^{__CFString=}' />
<constant name='kLSSharedFileListRecentItemsMaxAmount' type='^{__CFString=}' />
@@ -349,7 +347,7 @@
<enum name='kLSRequestExtensionFlagsOnly' value='64' />
<enum name='kLSRequestIconAndKind' value='32' />
<enum name='kLSRequestTypeCreator' value='2' />
- <enum name='kLSRolesAll' value='-1' />
+ <enum name='kLSRolesAll' value='4294967295' value64='18446744073709551615'/>
<enum name='kLSRolesEditor' value='4' />
<enum name='kLSRolesNone' value='1' />
<enum name='kLSRolesShell' value='8' />
@@ -726,7 +724,7 @@
<arg type='L' type64='L' />
<arg type='^{AEKeyDesc=I{AEDesc=I^^{OpaqueAEDataStorageType}}}' type_modifier='n' />
<arg type='^{LSApplicationParameters=iI^{FSRef}^v^{__CFDictionary}^{__CFArray}^{AEDesc}}' type64='^{LSApplicationParameters=iI^{FSRef}^v^{__CFDictionary}^{__CFArray}^{AEDesc}}' type_modifier='n' />
- <arg type='^{ProcessSerialNumber=II}' type_modifier='o' />
+ <arg type='^{ProcessSerialNumber=II}' type_modifier='o' c_array_length_in_arg='6' />
<arg type='l' type64='l' />
</function>
<function name='LSOpenURLsWithRole'>
@@ -735,7 +733,7 @@
<arg type='L' type64='L' />
<arg type='^{AEKeyDesc=I{AEDesc=I^^{OpaqueAEDataStorageType}}}' type_modifier='n' />
<arg type='^{LSApplicationParameters=iI^{FSRef}^v^{__CFDictionary}^{__CFArray}^{AEDesc}}' type64='^{LSApplicationParameters=iI^{FSRef}^v^{__CFDictionary}^{__CFArray}^{AEDesc}}' type_modifier='n' />
- <arg type='^{ProcessSerialNumber=II}' type_modifier='o' />
+ <arg type='^{ProcessSerialNumber=II}' type_modifier='o' c_array_length_in_arg='5' />
<arg type='l' type64='l' />
</function>
<function name='LSRegisterFSRef'>
@@ -776,7 +774,7 @@
</function>
<function name='LSSetItemAttribute'>
<retval type='l' type64='i' />
- <arg type='^{FSRef=[80C]}' type64='^{FSRef=[80C]}' />
+ <arg type='^{FSRef=[80C]}' type64='^{FSRef=[80C]}' type_modifier='n'/>
<arg type='L' type64='L' />
<arg type='^{__CFString=}' />
<arg type='@' />
@@ -870,8 +868,8 @@
<retval type='l' type64='i' />
<arg type='^{OpaqueLSSharedFileListItemRef=}' />
<arg type='L' type64='L' />
- <arg type='^^{__CFURL}' type64='^^{__CFURL}' />
- <arg type='^{FSRef=[80C]}' type64='^{FSRef=[80C]}' />
+ <arg type='^^{__CFURL}' type64='^^{__CFURL}' type_modifier='o' already_cfretained='true' />
+ <arg type='^{FSRef=[80C]}' type64='^{FSRef=[80C]}' type_modifier='o' />
</function>
<function name='LSSharedFileListItemSetProperty'>
<retval type='l' type64='i' />
Modified: trunk/pyobjc/pyobjc-framework-LaunchServices/Lib/LaunchServices/__init__.py
==============================================================================
--- trunk/pyobjc/pyobjc-framework-LaunchServices/Lib/LaunchServices/__init__.py (original)
+++ trunk/pyobjc/pyobjc-framework-LaunchServices/Lib/LaunchServices/__init__.py Sun Aug 15 16:25:18 2010
@@ -24,8 +24,6 @@
"/System/Library/Frameworks/ApplicationServices.framework/Frameworks/LaunchServices.framework"),
globals=globals())
-kLSRolesAll = -1
-
#
# Load an undocumented, yet announced function. This function was announced
# in TN2029 (http://developer.apple.com/technotes/tn/tn2029.html)
Modified: trunk/pyobjc/pyobjc-framework-LaunchServices/PyObjCTest/test_lsinfo.py
==============================================================================
--- trunk/pyobjc/pyobjc-framework-LaunchServices/PyObjCTest/test_lsinfo.py (original)
+++ trunk/pyobjc/pyobjc-framework-LaunchServices/PyObjCTest/test_lsinfo.py Sun Aug 15 16:25:18 2010
@@ -68,7 +68,7 @@
self.assertEqual(kLSRolesViewer, 0x00000002)
self.assertEqual(kLSRolesEditor, 0x00000004)
self.assertEqual(kLSRolesShell, 0x00000008)
- self.assertEqual(kLSRolesAll, cast_int(0xFFFFFFFF))
+ self.assertEqual(kLSRolesAll, 0xFFFFFFFF, 0xFFFFFFFFFFFFFFFF)
self.assertEqual(kLSUnknownKindID, 0)
self.assertEqual(kLSUnknownType, 0)
self.assertEqual(kLSUnknownCreator, 0)
@@ -151,32 +151,37 @@
self.assertArgIsOut(LSGetApplicationForInfo, 4)
self.assertArgIsOut(LSGetApplicationForInfo, 5)
self.assertArgIsCFRetained(LSGetApplicationForInfo, 5)
- ok, ref, url = LSGetApplicationForInfo(kLSUnknownType, kLSUnknownCreator, "txt", kLSRolesAll, None, None)
+
+ ok, ref, info_url = LSGetApplicationForInfo(kLSUnknownType, kLSUnknownCreator, "txt", kLSRolesAll, None, None)
self.assertEquals(ok, 0)
self.assertIsInstance(ref, objc.FSRef)
- self.assertIsInstance(url, CFURLRef)
+ self.assertIsInstance(info_url, CFURLRef)
self.assertArgIsOut(LSCopyApplicationForMIMEType, 2)
- self.assertArgIsCFRetained(LSGetApplicationForInfo, 2)
- ok, url = LSCopyApplicationForMIMEType("text/plain", kLSRolesAll, None)
+ self.assertArgIsCFRetained(LSCopyApplicationForMIMEType, 2)
+ ok, info_url = LSCopyApplicationForMIMEType("text/plain", kLSRolesAll, None)
self.assertEquals(ok, 0)
- self.assertIsInstance(url, CFURLRef)
+ self.assertIsInstance(info_url, CFURLRef)
self.assertArgIsOut(LSGetApplicationForURL, 2)
self.assertArgIsOut(LSGetApplicationForURL, 3)
self.assertArgIsCFRetained(LSGetApplicationForURL, 3)
- ok, ref, url = LSGetApplicationForURL(url, kLSRolesAll, None)
+ ok, ref, info_url = LSGetApplicationForURL(url, kLSRolesAll, None, None)
self.assertEquals(ok, 0)
self.assertIsInstance(ref, objc.FSRef)
- self.assertIsInstance(url, CFURLRef)
+ self.assertIsInstance(info_url, CFURLRef)
- self.assertArgIsOut(LSGetApplicationForURL, 3)
- self.assertArgIsOut(LSGetApplicationForURL, 4)
- self.assertArgIsCFRetained(LSGetApplicationForURL, 4)
- ok, ref, url = LSGetApplicationForURL(kLSUnknownCreator, None, self.path, None, None)
- self.assertEquals(ok, 0)
- self.assertIsInstance(ref, objc.FSRef)
- self.assertIsInstance(url, CFURLRef)
+ self.assertArgIsOut(LSFindApplicationForInfo, 3)
+ self.assertArgIsOut(LSFindApplicationForInfo, 4)
+ self.assertArgIsCFRetained(LSFindApplicationForInfo, 4)
+ ok, ref, info_url = LSFindApplicationForInfo(kLSUnknownCreator, None, "foo.app", None, None)
+ # XXX: The code looks correct but fails, however the corresponding C code also fails.
+ #self.assertEquals(ok, 0)
+ self.assertIsInstance(ok, (int, long))
+ if ref is not None:
+ self.assertIsInstance(ref, objc.FSRef)
+ if info_url is not None:
+ self.assertIsInstance(info_url, CFURLRef)
self.assertArgIsOut(LSCanURLAcceptURL, 4)
ok, status = LSCanURLAcceptURL(url, url, kLSRolesAll, kLSAcceptDefault, None)
@@ -193,22 +198,22 @@
self.assertIsInstance(a, CFURLRef)
- default_role = LSCopyDefaultRoleHandlerForContentType("text.plain", kLSRolesAll)
+ default_role = LSCopyDefaultRoleHandlerForContentType("public.plain-text", kLSRolesAll)
self.assertIsInstance(default_role, unicode)
- v = LSCopyAllRoleHandlersForContentType("text.plain", kLSRolesAll)
+ v = LSCopyAllRoleHandlersForContentType("public.plain-text", kLSRolesAll)
self.assertIsInstance(v, CFArrayRef)
for a in v:
self.assertIsInstance(a, unicode)
- ok = LSSetDefaultRoleHandlerForContentType("text.plain", kLSRolesAll, default_role)
+ ok = LSSetDefaultRoleHandlerForContentType("public.plain-text", kLSRolesAll, default_role)
self.assertIsInstance(ok, (int, long))
- v = LSGetHandlerOptionsForContentType("text.plain")
+ v = LSGetHandlerOptionsForContentType("public.plain-text")
self.assertIsInstance(v, (int, long))
- ok = LSSetHandlerOptionsForContentType("text.plain", v)
+ ok = LSSetHandlerOptionsForContentType("public.plain-text", v)
self.assertIsInstance(ok, (int, long))
self.assertResultIsCFRetained(LSCopyDefaultHandlerForURLScheme)
@@ -233,17 +238,56 @@
def testFSRef(self):
- self.fail('LSCopyItemInfoForRef')
- self.fail('LSCopyDisplayNameForRef')
- self.fail('LSSetExtensionHiddenForRef')
- self.fail('LSCopyKindStringForRef')
- self.fail('LSGetApplicationForItem')
- self.fail('LSCanRefAcceptItem')
- self.fail('LSRegisterFSRef')
- self.fail('LSCopyItemAttribute')
- self.fail('LSSetItemAttribute')
+ ref = objc.FSRef.from_pathname(self.path)
+ self.assertIsInstance(ref, objc.FSRef)
+
+ ok, info = LSCopyItemInfoForRef(ref, kLSRequestExtension|kLSRequestTypeCreator, None)
+ self.assertEqual(ok, 0)
+ self.assertIsInstance(info, LSItemInfoRecord)
+
+ self.assertArgIsOut(LSCopyDisplayNameForRef, 1)
+ self.assertArgIsCFRetained(LSCopyDisplayNameForRef, 1)
+ ok, info = LSCopyDisplayNameForRef(ref, None)
+ self.assertEquals(ok, 0)
+ self.assertIsInstance(info, unicode)
+
+ self.assertArgIsBOOL(LSSetExtensionHiddenForRef, 1)
+ ok = LSSetExtensionHiddenForRef(ref, True)
+ self.assertEquals(ok, 0)
+
+ self.assertArgIsOut(LSCopyKindStringForRef, 1)
+ self.assertArgIsCFRetained(LSCopyKindStringForRef, 1)
+ ok, info = LSCopyKindStringForRef(ref, None)
+ self.assertEquals(ok, 0)
+ self.assertIsInstance(info, unicode)
+
+ self.assertArgIsOut(LSGetApplicationForItem, 2)
+ self.assertArgIsOut(LSGetApplicationForItem, 3)
+ self.assertArgIsCFRetained(LSGetApplicationForItem, 3)
+ ok, info_ref, info_url = LSGetApplicationForItem(ref, kLSRolesAll, None, None)
+ self.assertEquals(ok, 0)
+ self.assertIsInstance(info_ref, objc.FSRef)
+ self.assertIsInstance(info_url, CFURLRef)
+
+
+ app_ref = objc.FSRef.from_pathname('/Applications/TextEdit.app')
+ self.assertArgIsOut(LSCanRefAcceptItem, 4)
+ ok, accepts = LSCanRefAcceptItem(ref, app_ref, kLSRolesAll, kLSAcceptDefault, None)
+ self.assertEquals(ok, 0)
+ self.assertIsInstance(accepts, bool)
+
+ ok = LSRegisterFSRef(ref, False)
+ self.assertIsInstance(ok, (int, long))
+
+ self.assertArgHasType(LSCopyItemAttribute, 3, 'o^@')
+ ok, value = LSCopyItemAttribute(ref, kLSRolesAll, kLSItemExtensionIsHidden, None)
+ self.assertEquals(ok, 0)
+ self.assertIsInstance(value, bool)
+
+
+ ok = LSSetItemAttribute(ref, kLSRolesAll, kLSItemRoleHandlerDisplayName, u"foo")
+ self.assertIsInstance(ok, (int, long))
-
if __name__ == "__main__":
Modified: trunk/pyobjc/pyobjc-framework-LaunchServices/PyObjCTest/test_lsopen.py
==============================================================================
--- trunk/pyobjc/pyobjc-framework-LaunchServices/PyObjCTest/test_lsopen.py (original)
+++ trunk/pyobjc/pyobjc-framework-LaunchServices/PyObjCTest/test_lsopen.py Sun Aug 15 16:25:18 2010
@@ -36,10 +36,18 @@
self.assertEqual(kLSLaunchHasUntrustedContents, 0x00400000)
def testStructs(self):
+ v = LSApplicationParameters()
+ self.assertHasAttr(v, "version")
+ self.assertHasAttr(v, "flags")
+ self.assertHasAttr(v, "application")
+ self.assertHasAttr(v, "asyncLaunchRefCon")
+ self.assertHasAttr(v, "environment")
+ self.assertHasAttr(v, "argv")
+ self.assertHasAttr(v, "initialEvent")
+
+ @expectedFailure
+ def testUnsupportedStructs(self):
self.fail("LSLaunchFSRefSpec")
- self.fail("LSLaunchFSRefSpec")
- self.fail("LSApplicationParameters")
- pass
def testFunctions(self):
@@ -50,12 +58,64 @@
self.assertEquals(ok, 0)
self.assertIsInstance(u, CFURLRef)
- self.fail("LSOpenApplication")
- self.fail("LSOpenItemsWithRole")
- self.fail("LSOpenURLsWithRole")
+ self.assertArgIsIn(LSOpenItemsWithRole, 0)
+ self.assertArgSizeInArg(LSOpenItemsWithRole, 0, 1)
+ self.assertArgIsIn(LSOpenItemsWithRole, 3)
+ self.assertArgIsIn(LSOpenItemsWithRole, 4)
+ self.assertArgIsOut(LSOpenItemsWithRole, 5)
+ self.assertArgSizeInArg(LSOpenItemsWithRole, 5, 6)
+ ref = objc.FSRef.from_pathname(self.path)
+ ok, psns = LSOpenItemsWithRole([ref], 1, kLSRolesAll, None, None, None, 1)
+ self.assertEquals(ok, 0)
+ self.assertIsInstance(psns, (list, tuple))
+ for x in psns:
+ # Actually a ProcessSerialNumber, but those aren't wrapped yet
+ self.assertIsInstance(x, tuple)
+ self.assertEquals(len(x), 2)
+ self.assertIsInstance(x[0], (int, long))
+ self.assertIsInstance(x[1], (int, long))
+
+ self.assertArgIsIn(LSOpenURLsWithRole, 2)
+ self.assertArgIsIn(LSOpenURLsWithRole, 3)
+ self.assertArgIsOut(LSOpenURLsWithRole, 4)
+ self.assertArgSizeInArg(LSOpenURLsWithRole, 4, 5)
+ ok, psns = LSOpenURLsWithRole([url], kLSRolesAll, None, None, None, 1)
+ self.assertEquals(ok, 0)
+ self.assertIsInstance(psns, (list, tuple))
+ for x in psns:
+ # Actually a ProcessSerialNumber, but those aren't wrapped yet
+ self.assertIsInstance(x, tuple)
+ self.assertEquals(len(x), 2)
+ self.assertIsInstance(x[0], (int, long))
+ self.assertIsInstance(x[1], (int, long))
+
+
+ @expectedFailure
+ def testUnsupportedFunctions(self):
+ self.assertArgIsIn(LSOpenApplication, 0)
+ self.assertArgIsOut(LSOpenApplication, 1)
+ params = LSApplicationParameters(
+ version=0,
+ flags = kLSLaunchDefaults,
+ application = objc.FSRef.from_pathname('/Applications/Utilities/Terminal.app'),
+ asyncLaunchRefCon = None,
+ environment = None,
+ argv = [u"Terminal"],
+ initialEvent = None,
+ )
+
+ # Call will fail for now, 'application' is an FSRef pointers and
+ # pyobjc-core isn't smart enough to deal with that.
+ ok, psn = LSOpenApplication(params, None)
+ self.assertEquals(ok, 0)
+ self.assertIsInstance(psn, (int, long))
+
+
+ @expectedFailure
def testFSRef(self):
- self.fail("LSLaunchFSRefSpec")
+ # Functions using structs we don't support, probably need
+ # manual wrappers
self.fail("LSOpenFromRefSpec")
self.fail("LSOpenFromURLSpec")
Modified: trunk/pyobjc/pyobjc-framework-LaunchServices/PyObjCTest/test_lssharedfilelist.py
==============================================================================
--- trunk/pyobjc/pyobjc-framework-LaunchServices/PyObjCTest/test_lssharedfilelist.py (original)
+++ trunk/pyobjc/pyobjc-framework-LaunchServices/PyObjCTest/test_lssharedfilelist.py Sun Aug 15 16:25:18 2010
@@ -20,9 +20,12 @@
self.assertIsInstance(kLSSharedFileListVolumesComputerVisible, unicode)
self.assertIsInstance(kLSSharedFileListVolumesIDiskVisible, unicode)
self.assertIsInstance(kLSSharedFileListVolumesNetworkVisible, unicode)
+ self.assertIsInstance(kLSSharedFileListItemHidden, unicode)
+
+ @min_os_level('10.5')
+ def testMagicConstants10_5(self):
self.assertIsInstance(kLSSharedFileListItemBeforeFirst, LSSharedFileListItemRef)
self.assertIsInstance(kLSSharedFileListItemLast, LSSharedFileListItemRef)
- self.assertIsInstance(kLSSharedFileListItemHidden, unicode)
def testConstants(self):
self.assertEqual(kLSSharedFileListNoUserInteraction, 1)
@@ -67,7 +70,7 @@
self.assertIsInstance(seed, (int,long))
self.assertResultIsCFRetained(LSSharedFileListInsertItemURL)
- item = LSSharedFileListInsertItemURL(lst, kLSSharedFileListItemLast, "PyObjC.Test", None,
+ item = LSSharedFileListInsertItemURL(lst, kLSSharedFileListItemLast, u"PyObjC.Test", None,
CFURLCreateWithString(None, "file:///etc/hosts", None), {}, [])
self.assertIsInstance(item, LSSharedFileListItemRef)
@@ -75,7 +78,8 @@
self.assertIsInstance(v, (int, long))
v = LSSharedFileListItemCopyIconRef(item)
- self.assertIsObject(v, None)
+ if v is not None:
+ self.assertIsInstance(v, IconRef)
self.assertResultIsCFRetained(LSSharedFileListItemCopyDisplayName)
v = LSSharedFileListItemCopyDisplayName(item)
@@ -86,14 +90,16 @@
self.assertArgIsCFRetained(LSSharedFileListItemResolve, 2)
v, url, ref = LSSharedFileListItemResolve(item, 0, None, objc.NULL)
self.assertIsInstance(v, (int, long))
- self.assertIsInstance(url, CFURLRef)
+ if url is not None:
+ self.assertIsInstance(url, CFURLRef)
- v = LSSharedFileListItemSetProperty(item, u"name", u"pyobjc.test")
+ v = LSSharedFileListItemSetProperty(item, u"pyobjc.name", u"pyobjc.test")
self.assertIsInstance(v, (int, long))
self.assertResultIsCFRetained(LSSharedFileListItemCopyProperty)
- v = LSSharedFileListItemCopyProperty(item, u"name")
- self.assertEqual(v, "pyobjc.test")
+ v = LSSharedFileListItemCopyProperty(item, u"pyobjc.name")
+ if v is not None:
+ self.assertEqual(v, "pyobjc.test")
v = LSSharedFileListItemMove(lst, item, kLSSharedFileListItemBeforeFirst)
self.assertIsInstance(v, (int, long))
------------------------------------------------------------------------------
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