summaryrefslogtreecommitdiff
path: root/Mac/Lib/test
diff options
context:
space:
mode:
Diffstat (limited to 'Mac/Lib/test')
-rw-r--r--Mac/Lib/test/AEservertest.py207
-rw-r--r--Mac/Lib/test/AEservertest.rsrcbin25637 -> 0 bytes
-rw-r--r--Mac/Lib/test/aete.py475
-rw-r--r--Mac/Lib/test/cmtest.py45
-rw-r--r--Mac/Lib/test/ctbtest.py50
-rw-r--r--Mac/Lib/test/dragtest.py43
-rw-r--r--Mac/Lib/test/echo.py155
-rw-r--r--Mac/Lib/test/fgbgtimetest.py17
-rw-r--r--Mac/Lib/test/icgluetest.py28
-rw-r--r--Mac/Lib/test/mkcwproj/mkcwtestmodule.c211
-rw-r--r--Mac/Lib/test/mkcwproj/testmkcwproj.py12
-rw-r--r--Mac/Lib/test/readme.txt4
-rw-r--r--Mac/Lib/test/tell.py63
-rw-r--r--Mac/Lib/test/test_finder_ae5
-rw-r--r--Mac/Lib/test/test_setcontroldata.py13
-rw-r--r--Mac/Lib/test/tlist.py92
-rw-r--r--Mac/Lib/test/tsnd.py18
-rw-r--r--Mac/Lib/test/tte.py17
-rw-r--r--Mac/Lib/test/twin.py9
19 files changed, 0 insertions, 1464 deletions
diff --git a/Mac/Lib/test/AEservertest.py b/Mac/Lib/test/AEservertest.py
deleted file mode 100644
index d474f43722..0000000000
--- a/Mac/Lib/test/AEservertest.py
+++ /dev/null
@@ -1,207 +0,0 @@
-"""AEservertest - Test AppleEvent server interface
-
-(adapted from Guido's 'echo' program).
-
-Build an applet from this source, and include the aete resource that you
-want to test. Use the AEservertest script to try things.
-"""
-
-import sys
-sys.stdout = sys.stderr
-import traceback
-import MacOS
-from Carbon import AE
-from Carbon.AppleEvents import *
-from Carbon import Evt
-from Carbon.Events import *
-from Carbon import Menu
-from Carbon import Dlg
-from Carbon import Win
-from Carbon.Windows import *
-from Carbon import Qd
-import macfs
-
-import aetools
-import EasyDialogs
-
-kHighLevelEvent = 23 # Not defined anywhere for Python yet?
-
-Quit='Quit'
-
-def mymessage(str):
- err = AE.AEInteractWithUser(kAEDefaultTimeout)
- if err:
- print str
- EasyDialogs.Message(str)
-
-def myaskstring(str, default=''):
- err = AE.AEInteractWithUser(kAEDefaultTimeout)
- if err:
- return default
- return EasyDialogs.AskString(str, default)
-
-def main():
- echo = EchoServer()
- savepars = MacOS.SchedParams(0, 0) # Disable Python's own "event handling"
- try:
- try:
- echo.mainloop(everyEvent, 0)
- except Quit:
- pass
- finally:
- apply(MacOS.SchedParams, savepars) # Let Python have a go at events
- echo.close()
-
-
-class EchoServer:
-
- suites = ['aevt', 'core', 'reqd']
-
- def __init__(self):
- self.active = 0
- #
- # Install the handlers
- #
- for suite in self.suites:
- AE.AEInstallEventHandler(suite, typeWildCard, self.aehandler)
- print (suite, typeWildCard, self.aehandler)
- self.active = 1
- #
- # Setup the apple menu and file/quit
- #
- self.appleid = 1
- self.fileid = 2
-
- Menu.ClearMenuBar()
- self.applemenu = applemenu = Menu.NewMenu(self.appleid, "\024")
- applemenu.AppendMenu("All about echo...;(-")
- applemenu.InsertMenu(0)
-
- self.filemenu = Menu.NewMenu(self.fileid, 'File')
- self.filemenu.AppendMenu("Quit/Q")
- self.filemenu.InsertMenu(0)
-
- Menu.DrawMenuBar()
- #
- # Set interaction allowed (for the return values)
- #
- AE.AESetInteractionAllowed(kAEInteractWithAll)
-
- def __del__(self):
- self.close()
-
- def close(self):
- if self.active:
- self.active = 0
- for suite in self.suites:
- AE.AERemoveEventHandler(suite, typeWildCard)
-
- def mainloop(self, mask = everyEvent, timeout = 60*60):
- while 1:
- self.dooneevent(mask, timeout)
-
- def dooneevent(self, mask = everyEvent, timeout = 60*60):
- got, event = Evt.WaitNextEvent(mask, timeout)
- if got:
- self.lowlevelhandler(event)
-
- def lowlevelhandler(self, event):
- what, message, when, where, modifiers = event
- h, v = where
- if what == kHighLevelEvent:
- msg = "High Level Event: %s %s" % \
- (`code(message)`, `code(h | (v<<16))`)
- self.handled_by_us = 0
- try:
- AE.AEProcessAppleEvent(event)
- except AE.Error, err:
- mymessage(msg + "\015AEProcessAppleEvent error: %s" % str(err))
- traceback.print_exc()
- else:
- if self.handled_by_us == 0:
- print msg, "Handled by AE, somehow"
- else:
- print msg, 'Handled by us.'
- elif what == keyDown:
- c = chr(message & charCodeMask)
- if modifiers & cmdKey:
- if c == '.':
- raise KeyboardInterrupt, "Command-period"
- else:
- self.menuhit(Menu.MenuKey(message&charCodeMask))
- ##MacOS.HandleEvent(event)
- elif what == mouseDown:
- partcode, window = Win.FindWindow(where)
- if partcode == inMenuBar:
- result = Menu.MenuSelect(where)
- self.menuhit(result)
- elif what <> autoKey:
- print "Event:", (eventname(what), message, when, (h, v), modifiers)
-## MacOS.HandleEvent(event)
-
- def menuhit(self, result):
- id = (result>>16) & 0xffff # Hi word
- item = result & 0xffff # Lo word
- if id == self.appleid:
- if item == 1:
- mymessage("Echo -- echo AppleEvents")
- elif id == self.fileid:
- if item == 1:
- raise Quit
-
- def aehandler(self, request, reply):
- print "Apple Event!"
- self.handled_by_us = 1
- parameters, attributes = aetools.unpackevent(request)
- print "class =", `attributes['evcl'].type`,
- print "id =", `attributes['evid'].type`
- print "Parameters:"
- keys = parameters.keys()
- keys.sort()
- for key in keys:
- print "%s: %.150s" % (`key`, `parameters[key]`)
- print " :", str(parameters[key])
- print "Attributes:"
- keys = attributes.keys()
- keys.sort()
- for key in keys:
- print "%s: %.150s" % (`key`, `attributes[key]`)
- parameters['----'] = self.askreplyvalue()
- aetools.packevent(reply, parameters)
-
- def askreplyvalue(self):
- while 1:
- str = myaskstring('Reply value to send (python-style)', 'None')
- try:
- rv = eval(str)
- break
- except:
- pass
- return rv
-
-_eventnames = {
- keyDown: 'keyDown',
- autoKey: 'autoKey',
- mouseDown: 'mouseDown',
- mouseUp: 'mouseUp',
- updateEvt: 'updateEvt',
- diskEvt: 'diskEvt',
- activateEvt: 'activateEvt',
- osEvt: 'osEvt',
-}
-
-def eventname(what):
- if _eventnames.has_key(what): return _eventnames[what]
- else: return `what`
-
-def code(x):
- "Convert a long int to the 4-character code it really is"
- s = ''
- for i in range(4):
- x, c = divmod(x, 256)
- s = chr(c) + s
- return s
-
-
-if __name__ == '__main__':
- main()
diff --git a/Mac/Lib/test/AEservertest.rsrc b/Mac/Lib/test/AEservertest.rsrc
deleted file mode 100644
index 268bc27371..0000000000
--- a/Mac/Lib/test/AEservertest.rsrc
+++ /dev/null
Binary files differ
diff --git a/Mac/Lib/test/aete.py b/Mac/Lib/test/aete.py
deleted file mode 100644
index 3945a86199..0000000000
--- a/Mac/Lib/test/aete.py
+++ /dev/null
@@ -1,475 +0,0 @@
-# Look for scriptable applications -- that is, applications with an 'aete' resource
-# Also contains (partially) reverse engineered 'aete' resource decoding
-
-import MacOS
-import os
-import string
-import sys
-import types
-import StringIO
-
-from Carbon.Res import *
-
-def main():
- filename = ""
- redirect(filename, realmain)
-
-def redirect(filename, func, *args):
- f = filename and open(filename, 'w')
- save_stdout = sys.stdout
- try:
- if f: sys.stdout = f
- return apply(func, args)
- finally:
- sys.stdout = save_stdout
- if f: f.close()
-
-def realmain():
- #list('C:System Folder:Extensions:AppleScript\252')
- #list('C:Tao AppleScript:Finder Liaison:Finder Liaison 1.0')
- list('C:Tao AppleScript:Scriptable Text Editor')
- #list('C:Internet:Eudora 1.4.2:Eudora1.4.2')
- #list('E:Excel 4.0:Microsoft Excel')
- #list('C:Internet:Netscape 1.0N:Netscape 1.0N')
- #find('C:')
- #find('D:')
- #find('E:')
- #find('F:')
-
-def find(dir, maxlevel = 5):
- hits = []
- cur = CurResFile()
- names = os.listdir(dir)
- tuples = map(lambda x: (os.path.normcase(x), x), names)
- tuples.sort()
- names = map(lambda (x, y): y, tuples)
- for name in names:
- if name in (os.curdir, os.pardir): continue
- fullname = os.path.join(dir, name)
- if os.path.islink(fullname):
- pass
- if os.path.isdir(fullname):
- if maxlevel > 0:
- sys.stderr.write(" %s\n" % `fullname`)
- hits = hits + find(fullname, maxlevel-1)
- else:
- ctor, type = MacOS.GetCreatorAndType(fullname)
- if type in ('APPL', 'FNDR', 'zsys', 'INIT', 'scri', 'cdev'):
- sys.stderr.write(" %s\n" % `fullname`)
- try:
- rf = OpenRFPerm(fullname, 0, '\1')
- except MacOS.Error, msg:
- print "Error:", fullname, msg
- continue
- UseResFile(rf)
- n = Count1Resources('aete')
- if rf <> cur:
- CloseResFile(rf)
- UseResFile(cur)
- if n > 1:
- hits.append(fullname)
- sys.stderr.write("YES! %d in %s\n" % (n, `fullname`))
- list(fullname)
- return hits
-
-def list(fullname):
- cur = CurResFile()
- rf = OpenRFPerm(fullname, 0, '\1')
- try:
- UseResFile(rf)
- resources = []
- for i in range(Count1Resources('aete')):
- res = Get1IndResource('aete', 1+i)
- resources.append(res)
- for i in range(Count1Resources('aeut')):
- res = Get1IndResource('aeut', 1+i)
- resources.append(res)
- print "\nLISTING aete+aeut RESOURCES IN", `fullname`
- for res in resources:
- print "decoding", res.GetResInfo(), "..."
- data = res.data
- try:
- aete = decode(data)
- showaete(aete)
- print "Checking putaete..."
- f = StringIO.StringIO()
- putaete(f, aete)
- newdata = f.getvalue()
- if len(newdata) == len(data):
- if newdata == data:
- print "putaete created identical data"
- else:
- newaete = decode(newdata)
- if newaete == aete:
- print "putaete created equivalent data"
- else:
- print "putaete failed the test:"
- showaete(newaete)
- else:
- print "putaete created different data:"
- print `newdata`
- except:
- import traceback
- traceback.print_exc()
- sys.stdout.flush()
- finally:
- if rf <> cur:
- CloseResFile(rf)
- UseResFile(cur)
-
-def decode(data):
- f = StringIO.StringIO(data)
- aete = generic(getaete, f)
- aete = simplify(aete)
- processed = f.tell()
- unprocessed = len(f.read())
- total = f.tell()
- if unprocessed:
- sys.stderr.write("%d processed + %d unprocessed = %d total\n" %
- (processed, unprocessed, total))
- return aete
-
-def simplify(item):
- if type(item) is types.ListType:
- return map(simplify, item)
- elif type(item) == types.TupleType and len(item) == 2:
- return simplify(item[1])
- else:
- return item
-
-
-# Here follows the aete resource decoder.
-# It is presented bottom-up instead of top-down because there are direct
-# references to the lower-level part-decoders from the high-level part-decoders.
-
-def getbyte(f, *args):
- c = f.read(1)
- if not c:
- raise EOFError, 'in getbyte' + str(args)
- return ord(c)
-
-def getword(f, *args):
- getalign(f)
- s = f.read(2)
- if len(s) < 2:
- raise EOFError, 'in getword' + str(args)
- return (ord(s[0])<<8) | ord(s[1])
-
-def getlong(f, *args):
- getalign(f)
- s = f.read(4)
- if len(s) < 4:
- raise EOFError, 'in getlong' + str(args)
- return (ord(s[0])<<24) | (ord(s[1])<<16) | (ord(s[2])<<8) | ord(s[3])
-
-def getostype(f, *args):
- getalign(f)
- s = f.read(4)
- if len(s) < 4:
- raise EOFError, 'in getostype' + str(args)
- return s
-
-def getpstr(f, *args):
- c = f.read(1)
- if len(c) < 1:
- raise EOFError, 'in getpstr[1]' + str(args)
- nbytes = ord(c)
- if nbytes == 0: return ''
- s = f.read(nbytes)
- if len(s) < nbytes:
- raise EOFError, 'in getpstr[2]' + str(args)
- return s
-
-def getalign(f):
- if f.tell() & 1:
- c = f.read(1)
- ##if c <> '\0':
- ## print 'align:', `c`
-
-def getlist(f, description, getitem):
- count = getword(f)
- list = []
- for i in range(count):
- list.append(generic(getitem, f))
- getalign(f)
- return list
-
-def alt_generic(what, f, *args):
- print "generic", `what`, args
- res = vageneric(what, f, args)
- print '->', `res`
- return res
-
-def generic(what, f, *args):
- if type(what) == types.FunctionType:
- return apply(what, (f,) + args)
- if type(what) == types.ListType:
- record = []
- for thing in what:
- item = apply(generic, thing[:1] + (f,) + thing[1:])
- record.append((thing[1], item))
- return record
- return "BAD GENERIC ARGS: %s" % `what`
-
-getdata = [
- (getostype, "type"),
- (getpstr, "description"),
- (getword, "flags")
- ]
-getargument = [
- (getpstr, "name"),
- (getostype, "keyword"),
- (getdata, "what")
- ]
-getevent = [
- (getpstr, "name"),
- (getpstr, "description"),
- (getostype, "suite code"),
- (getostype, "event code"),
- (getdata, "returns"),
- (getdata, "accepts"),
- (getlist, "optional arguments", getargument)
- ]
-getproperty = [
- (getpstr, "name"),
- (getostype, "code"),
- (getdata, "what")
- ]
-getelement = [
- (getostype, "type"),
- (getlist, "keyform", getostype)
- ]
-getclass = [
- (getpstr, "name"),
- (getostype, "class code"),
- (getpstr, "description"),
- (getlist, "properties", getproperty),
- (getlist, "elements", getelement)
- ]
-getcomparison = [
- (getpstr, "operator name"),
- (getostype, "operator ID"),
- (getpstr, "operator comment"),
- ]
-getenumerator = [
- (getpstr, "enumerator name"),
- (getostype, "enumerator ID"),
- (getpstr, "enumerator comment")
- ]
-getenumeration = [
- (getostype, "enumeration ID"),
- (getlist, "enumerator", getenumerator)
- ]
-getsuite = [
- (getpstr, "suite name"),
- (getpstr, "suite description"),
- (getostype, "suite ID"),
- (getword, "suite level"),
- (getword, "suite version"),
- (getlist, "events", getevent),
- (getlist, "classes", getclass),
- (getlist, "comparisons", getcomparison),
- (getlist, "enumerations", getenumeration)
- ]
-getaete = [
- (getword, "major/minor version in BCD"),
- (getword, "language code"),
- (getword, "script code"),
- (getlist, "suites", getsuite)
- ]
-
-
-# Display 'aete' resources in a friendly manner.
-# This one's done top-down again...
-
-def showaete(aete):
- [version, language, script, suites] = aete
- major, minor = divmod(version, 256)
- print "\nVersion %d/%d, language %d, script %d" % \
- (major, minor, language, script)
- for suite in suites:
- showsuite(suite)
-
-def showsuite(suite):
- [name, desc, code, level, version, events, classes, comps, enums] = suite
- print "\nSuite %s -- %s (%s)" % (`name`, `desc`, `code`)
- print "Level %d, version %d" % (level, version)
- for event in events:
- showevent(event)
- for cls in classes:
- showclass(cls)
- for comp in comps:
- showcomparison(comp)
- for enum in enums:
- showenumeration(enum)
-
-def showevent(event):
- [name, desc, code, subcode, returns, accepts, arguments] = event
- print "\n Command %s -- %s (%s, %s)" % (`name`, `desc`, `code`, `subcode`)
- print " returns", showdata(returns)
- print " accepts", showdata(accepts)
- for arg in arguments:
- showargument(arg)
-
-def showargument(arg):
- [name, keyword, what] = arg
- print " %s (%s)" % (name, `keyword`), showdata(what)
-
-def showclass(cls):
- [name, code, desc, properties, elements] = cls
- print "\n Class %s (%s) -- %s" % (`name`, `code`, `desc`)
- for prop in properties:
- showproperty(prop)
- for elem in elements:
- showelement(elem)
-
-def showproperty(prop):
- [name, code, what] = prop
- print " property %s (%s)" % (`name`, `code`), showdata(what)
-
-def showelement(elem):
- [code, keyform] = elem
- print " element %s" % `code`, "as", keyform
-
-def showcomparison(comp):
- [name, code, comment] = comp
- print " comparison %s (%s) -- %s" % (`name`, `code`, comment)
-
-def showenumeration(enum):
- [code, items] = enum
- print "\n Enum %s" % `code`
- for item in items:
- showenumerator(item)
-
-def showenumerator(item):
- [name, code, desc] = item
- print " %s (%s) -- %s" % (`name`, `code`, `desc`)
-
-def showdata(data):
- [type, description, flags] = data
- return "%s -- %s %s" % (`type`, `description`, showdataflags(flags))
-
-dataflagdict = {15: "optional", 14: "list", 13: "enum", 12: "mutable"}
-def showdataflags(flags):
- bits = []
- for i in range(16):
- if flags & (1<<i):
- if i in dataflagdict.keys():
- bits.append(dataflagdict[i])
- else:
- bits.append(`i`)
- return '[%s]' % string.join(bits)
-
-
-# Write an 'aete' resource.
-# Closedly modelled after showaete()...
-
-def putaete(f, aete):
- [version, language, script, suites] = aete
- putword(f, version)
- putword(f, language)
- putword(f, script)
- putlist(f, suites, putsuite)
-
-def putsuite(f, suite):
- [name, desc, code, level, version, events, classes, comps, enums] = suite
- putpstr(f, name)
- putpstr(f, desc)
- putostype(f, code)
- putword(f, level)
- putword(f, version)
- putlist(f, events, putevent)
- putlist(f, classes, putclass)
- putlist(f, comps, putcomparison)
- putlist(f, enums, putenumeration)
-
-def putevent(f, event):
- [name, desc, eventclass, eventid, returns, accepts, arguments] = event
- putpstr(f, name)
- putpstr(f, desc)
- putostype(f, eventclass)
- putostype(f, eventid)
- putdata(f, returns)
- putdata(f, accepts)
- putlist(f, arguments, putargument)
-
-def putargument(f, arg):
- [name, keyword, what] = arg
- putpstr(f, name)
- putostype(f, keyword)
- putdata(f, what)
-
-def putclass(f, cls):
- [name, code, desc, properties, elements] = cls
- putpstr(f, name)
- putostype(f, code)
- putpstr(f, desc)
- putlist(f, properties, putproperty)
- putlist(f, elements, putelement)
-
-putproperty = putargument
-
-def putelement(f, elem):
- [code, parts] = elem
- putostype(f, code)
- putlist(f, parts, putostype)
-
-def putcomparison(f, comp):
- [name, id, comment] = comp
- putpstr(f, name)
- putostype(f, id)
- putpstr(f, comment)
-
-def putenumeration(f, enum):
- [code, items] = enum
- putostype(f, code)
- putlist(f, items, putenumerator)
-
-def putenumerator(f, item):
- [name, code, desc] = item
- putpstr(f, name)
- putostype(f, code)
- putpstr(f, desc)
-
-def putdata(f, data):
- [type, description, flags] = data
- putostype(f, type)
- putpstr(f, description)
- putword(f, flags)
-
-def putlist(f, list, putitem):
- putword(f, len(list))
- for item in list:
- putitem(f, item)
- putalign(f)
-
-def putalign(f):
- if f.tell() & 1:
- f.write('\0')
-
-def putbyte(f, value):
- f.write(chr(value))
-
-def putword(f, value):
- putalign(f)
- f.write(chr((value>>8)&0xff))
- f.write(chr(value&0xff))
-
-def putostype(f, value):
- putalign(f)
- if type(value) != types.StringType or len(value) != 4:
- raise TypeError, "ostype must be 4-char string"
- f.write(value)
-
-def putpstr(f, value):
- if type(value) != types.StringType or len(value) > 255:
- raise TypeError, "pstr must be string <= 255 chars"
- f.write(chr(len(value)) + value)
-
-
-# Call the main program
-
-if __name__ == '__main__':
- main()
-else:
- realmain()
diff --git a/Mac/Lib/test/cmtest.py b/Mac/Lib/test/cmtest.py
deleted file mode 100644
index bdbca23d30..0000000000
--- a/Mac/Lib/test/cmtest.py
+++ /dev/null
@@ -1,45 +0,0 @@
-"""cmtest - List all components in the system"""
-
-from Carbon import Cm
-from Carbon import Res
-from Carbon import sys
-
-def getstr255(r):
- """Get string from str255 resource"""
- if not r.data: return ''
- len = ord(r.data[0])
- return r.data[1:1+len]
-
-def getinfo(c):
- """Return (type, subtype, creator, fl1, fl2, name, description) for component"""
- h1 = Res.Resource('')
- h2 = Res.Resource('')
- h3 = Res.Resource('')
- type, subtype, creator, fl1, fl2 = c.GetComponentInfo(h1, h2, h3)
- name = getstr255(h1)
- description = getstr255(h2)
- return type, subtype, creator, fl1, fl2, name, description
-
-def getallcomponents():
- """Return list with info for all components, sorted"""
- any = ('\0\0\0\0', '\0\0\0\0', '\0\0\0\0', 0, 0)
- c = None
- rv = []
- while 1:
- try:
- c = Cm.FindNextComponent(c, any)
- except Cm.Error:
- break
- rv.append(getinfo(c))
- rv.sort()
- return rv
-
-def main():
- """Print info for all components"""
- info = getallcomponents()
- for type, subtype, creator, f1, f2, name, description in info:
- print '%4.4s %4.4s %4.4s %s 0x%x 0x%x'%(type, subtype, creator, name, f1, f2)
- print ' ', description
- sys.exit(1)
-
-main()
diff --git a/Mac/Lib/test/ctbtest.py b/Mac/Lib/test/ctbtest.py
deleted file mode 100644
index 91824d3558..0000000000
--- a/Mac/Lib/test/ctbtest.py
+++ /dev/null
@@ -1,50 +0,0 @@
-#
-# Simple test program for ctb module: emulate a terminal.
-# To simplify matters use the python console window for output.
-#
-import ctb
-from Carbon import Evt
-from Carbon import Events
-import MacOS
-import sys
-
-def cb(err):
- print 'Done, err=', err
-
-def main():
- if not ctb.available():
- print 'Communications Toolbox not available'
- sys.exit(1)
- # Disable Python's event processing (we do that)
- MacOS.SchedParams(1, 0)
- print 'Minimal terminal emulator V1.0'
- print '(type command-Q to exit)'
- print
-
- l = ctb.CMNew('Serial Tool', None)
- l.Open(10)
- l.SetConfig(l.GetConfig() + ' baud 4800')
-
- while 1:
- l.Idle() # Give time to ctb
-
- ok, evt = Evt.WaitNextEvent(0xffff, 0)
- if ok:
- what, message, when, where, modifiers = evt
-
- if what == Events.keyDown:
- # It is ours. Check for command-. to terminate
- ch = chr(message & Events.charCodeMask)
- if ch == 'q' and (modifiers & Events.cmdKey):
- break
- l.Write(ch, ctb.cmData, -1, 0)
- d, dummy = l.Read(1000, ctb.cmData, 1)
- if d:
- for ch in d:
- if ch != '\r':
- sys.stdout.write(ch)
- sys.stdout.flush()
- l.Close(-1, 1)
- del l
-
-main()
diff --git a/Mac/Lib/test/dragtest.py b/Mac/Lib/test/dragtest.py
deleted file mode 100644
index 28eb1a963e..0000000000
--- a/Mac/Lib/test/dragtest.py
+++ /dev/null
@@ -1,43 +0,0 @@
-from Carbon import Drag
-import time
-xxxx=1
-def decode_hfs(data):
- import struct, macfs
- tp = data[0:4]
- cr = data[4:8]
- flags = struct.unpack("h", data[8:10])
- fss = macfs.RawFSSpec(data[10:])
- return tp, cr, flags, fss
-
-def tracker(msg, dragref, window):
- pass
-
-def dropper(dragref, window):
- global xxxx
- n = dragref.CountDragItems()
- print 'Drop %d items:'%n
- for i in range(1, n+1):
- refnum = dragref.GetDragItemReferenceNumber(i)
- print '%d (ItemReference 0x%x)'%(i, refnum)
- nf = dragref.CountDragItemFlavors(refnum)
- print ' %d flavors:'%nf
- for j in range(1, nf+1):
- ftype = dragref.GetFlavorType(refnum, j)
- fflags = dragref.GetFlavorFlags(refnum, ftype)
- print ' "%4.4s" 0x%x'%(ftype, fflags)
- if ftype == 'hfs ':
- datasize = dragref.GetFlavorDataSize(refnum, ftype)
- data = dragref.GetFlavorData(refnum, ftype, datasize, 0)
- print ' datasize', `data`
- xxxx = data
- print ' ->', decode_hfs(data)
-
-
-def main():
- print "Drag things onto output window. Press command-. to quit."
- Drag.InstallTrackingHandler(tracker)
- Drag.InstallReceiveHandler(dropper)
- while 1:
- time.sleep(100)
-
-main()
diff --git a/Mac/Lib/test/echo.py b/Mac/Lib/test/echo.py
deleted file mode 100644
index f84e13baf4..0000000000
--- a/Mac/Lib/test/echo.py
+++ /dev/null
@@ -1,155 +0,0 @@
-"""'echo' -- an AppleEvent handler which handles all events the same.
-
-It replies to each event by echoing the parameter back to the client.
-This is a good way to find out how the Script Editor formats AppleEvents,
-especially to figure out all the different forms an object specifier
-can have (without having to rely on Apple's implementation).
-"""
-
-import sys
-sys.stdout = sys.stderr
-import traceback
-import MacOS
-from Carbon import AE
-from Carbon.AppleEvents import *
-from Carbon import Evt
-from Carbon.Events import *
-from Carbon import Menu
-from Carbon import Dlg
-from Carbon import Win
-from Carbon.Windows import *
-from Carbon import Qd
-
-import aetools
-import EasyDialogs
-
-kHighLevelEvent = 23 # Not defined anywhere for Python yet?
-
-def mymessage(str):
- err = AE.AEInteractWithUser(kAEDefaultTimeout)
- if err:
- print str
- EasyDialogs.Message(str)
-
-def main():
- echo = EchoServer()
- saveparams = MacOS.SchedParams(0, 0) # Disable Python's own "event handling"
- try:
- echo.mainloop(everyEvent, 0)
- finally:
- apply(MacOS.SchedParams, saveparams) # Let Python have a go at events
- echo.close()
-
-
-class EchoServer:
-
- #suites = ['aevt', 'core', 'reqd']
- suites = ['****']
-
- def __init__(self):
- self.active = 0
- for suite in self.suites:
- AE.AEInstallEventHandler(suite, typeWildCard, self.aehandler)
- print (suite, typeWildCard, self.aehandler)
- self.active = 1
- self.appleid = 1
- Menu.ClearMenuBar()
- self.applemenu = applemenu = Menu.NewMenu(self.appleid, "\024")
- applemenu.AppendMenu("All about echo...;(-")
- applemenu.InsertMenu(0)
- Menu.DrawMenuBar()
-
- def __del__(self):
- self.close()
-
- def close(self):
- if self.active:
- self.active = 0
- for suite in self.suites:
- AE.AERemoveEventHandler(suite, typeWildCard)
-
- def mainloop(self, mask = everyEvent, timeout = 60*60):
- while 1:
- self.dooneevent(mask, timeout)
-
- def dooneevent(self, mask = everyEvent, timeout = 60*60):
- got, event = Evt.WaitNextEvent(mask, timeout)
- if got:
- self.lowlevelhandler(event)
-
- def lowlevelhandler(self, event):
- what, message, when, where, modifiers = event
- h, v = where
- if what == kHighLevelEvent:
- msg = "High Level Event: %s %s" % \
- (`code(message)`, `code(h | (v<<16))`)
- try:
- AE.AEProcessAppleEvent(event)
- except AE.Error, err:
- mymessage(msg + "\015AEProcessAppleEvent error: %s" % str(err))
- traceback.print_exc()
- else:
- mymessage(msg + "\015OK!")
- elif what == keyDown:
- c = chr(message & charCodeMask)
- if c == '.' and modifiers & cmdKey:
- raise KeyboardInterrupt, "Command-period"
- MacOS.HandleEvent(event)
- elif what == mouseDown:
- partcode, window = Win.FindWindow(where)
- if partcode == inMenuBar:
- result = Menu.MenuSelect(where)
- id = (result>>16) & 0xffff # Hi word
- item = result & 0xffff # Lo word
- if id == self.appleid:
- if item == 1:
- mymessage("Echo -- echo AppleEvents")
- elif what <> autoKey:
- print "Event:", (eventname(what), message, when, (h, v), modifiers)
-## MacOS.HandleEvent(event)
-
- def aehandler(self, request, reply):
- print "Apple Event!"
- parameters, attributes = aetools.unpackevent(request)
- print "class =", `attributes['evcl'].type`,
- print "id =", `attributes['evid'].type`
- print "Parameters:"
- keys = parameters.keys()
- keys.sort()
- for key in keys:
- print "%s: %.150s" % (`key`, `parameters[key]`)
- print " :", str(parameters[key])
- print "Attributes:"
- keys = attributes.keys()
- keys.sort()
- for key in keys:
- print "%s: %.150s" % (`key`, `attributes[key]`)
- aetools.packevent(reply, parameters)
-
-
-_eventnames = {
- keyDown: 'keyDown',
- autoKey: 'autoKey',
- mouseDown: 'mouseDown',
- mouseUp: 'mouseUp',
- updateEvt: 'updateEvt',
- diskEvt: 'diskEvt',
- activateEvt: 'activateEvt',
- osEvt: 'osEvt',
-}
-
-def eventname(what):
- if _eventnames.has_key(what): return _eventnames[what]
- else: return `what`
-
-def code(x):
- "Convert a long int to the 4-character code it really is"
- s = ''
- for i in range(4):
- x, c = divmod(x, 256)
- s = chr(c) + s
- return s
-
-
-if __name__ == '__main__':
- main()
diff --git a/Mac/Lib/test/fgbgtimetest.py b/Mac/Lib/test/fgbgtimetest.py
deleted file mode 100644
index fd2b64956c..0000000000
--- a/Mac/Lib/test/fgbgtimetest.py
+++ /dev/null
@@ -1,17 +0,0 @@
-"""fgbgtest - See how many CPU cycles we get"""
-
-import time
-
-loopct = 0L
-oldloopct = 0L
-oldt = time.time()
-
-while 1:
- t = time.time()
- if t - oldt >= 1:
- if oldloopct:
- print loopct-oldloopct,'in one second'
- oldloopct = loopct
- oldt = time.time()
- loopct = loopct + 1
-
diff --git a/Mac/Lib/test/icgluetest.py b/Mac/Lib/test/icgluetest.py
deleted file mode 100644
index dd34bd033b..0000000000
--- a/Mac/Lib/test/icgluetest.py
+++ /dev/null
@@ -1,28 +0,0 @@
-"""Test icglue module by printing all preferences. Note that the ic module,
-not the icglue module, is what you should normally use."""
-
-import icglue
-from Carbon import Res
-
-ici = icglue.ICStart('Pyth')
-#ici.ICFindConfigFile()
-h = Res.Resource("")
-
-ici.ICBegin(1)
-numprefs = ici.ICCountPref()
-print "Number of preferences:", numprefs
-
-for i in range(1, numprefs+1):
- key = ici.ICGetIndPref(i)
- print "Key: ", key
-
- h.data = ""
- attrs = ici.ICFindPrefHandle(key, h)
- print "Attr: ", attrs
- print "Data: ", `h.data[:64]`
-
-ici.ICEnd()
-del ici
-
-import sys
-sys.exit(1)
diff --git a/Mac/Lib/test/mkcwproj/mkcwtestmodule.c b/Mac/Lib/test/mkcwproj/mkcwtestmodule.c
deleted file mode 100644
index 84d0e2d3bc..0000000000
--- a/Mac/Lib/test/mkcwproj/mkcwtestmodule.c
+++ /dev/null
@@ -1,211 +0,0 @@
-
-/* Use this file as a template to start implementing a module that
- also declares object types. All occurrences of 'Xxo' should be changed
- to something reasonable for your objects. After that, all other
- occurrences of 'xx' should be changed to something reasonable for your
- module. If your module is named foo your sourcefile should be named
- foomodule.c.
-
- You will probably want to delete all references to 'x_attr' and add
- your own types of attributes instead. Maybe you want to name your
- local variables other than 'self'. If your object type is needed in
- other files, you'll have to create a file "foobarobject.h"; see
- intobject.h for an example. */
-
-/* Xxo objects */
-
-#include "Python.h"
-
-static PyObject *ErrorObject;
-
-typedef struct {
- PyObject_HEAD
- PyObject *x_attr; /* Attributes dictionary */
-} XxoObject;
-
-static PyTypeObject Xxo_Type;
-
-#define XxoObject_Check(v) ((v)->ob_type == &Xxo_Type)
-
-static XxoObject *
-newXxoObject(PyObject *arg)
-{
- XxoObject *self;
- self = PyObject_New(XxoObject, &Xxo_Type);
- if (self == NULL)
- return NULL;
- self->x_attr = NULL;
- return self;
-}
-
-/* Xxo methods */
-
-static void
-Xxo_dealloc(XxoObject *self)
-{
- Py_XDECREF(self->x_attr);
- PyObject_Del(self);
-}
-
-static PyObject *
-Xxo_demo(XxoObject *self, PyObject *args)
-{
- if (!PyArg_ParseTuple(args, ":demo"))
- return NULL;
- Py_INCREF(Py_None);
- return Py_None;
-}
-
-static PyMethodDef Xxo_methods[] = {
- {"demo", (PyCFunction)Xxo_demo, METH_VARARGS},
- {NULL, NULL} /* sentinel */
-};
-
-static PyObject *
-Xxo_getattr(XxoObject *self, char *name)
-{
- if (self->x_attr != NULL) {
- PyObject *v = PyDict_GetItemString(self->x_attr, name);
- if (v != NULL) {
- Py_INCREF(v);
- return v;
- }
- }
- return Py_FindMethod(Xxo_methods, (PyObject *)self, name);
-}
-
-static int
-Xxo_setattr(XxoObject *self, char *name, PyObject *v)
-{
- if (self->x_attr == NULL) {
- self->x_attr = PyDict_New();
- if (self->x_attr == NULL)
- return -1;
- }
- if (v == NULL) {
- int rv = PyDict_DelItemString(self->x_attr, name);
- if (rv < 0)
- PyErr_SetString(PyExc_AttributeError,
- "delete non-existing Xxo attribute");
- return rv;
- }
- else
- return PyDict_SetItemString(self->x_attr, name, v);
-}
-
-statichere PyTypeObject Xxo_Type = {
- /* The ob_type field must be initialized in the module init function
- * to be portable to Windows without using C++. */
- PyObject_HEAD_INIT(NULL)
- 0, /*ob_size*/
- "Xxmodule.Xxo", /*tp_name*/
- sizeof(XxoObject), /*tp_basicsize*/
- 0, /*tp_itemsize*/
- /* methods */
- (destructor)Xxo_dealloc, /*tp_dealloc*/
- 0, /*tp_print*/
- (getattrfunc)Xxo_getattr, /*tp_getattr*/
- (setattrfunc)Xxo_setattr, /*tp_setattr*/
- 0, /*tp_compare*/
- 0, /*tp_repr*/
- 0, /*tp_as_number*/
- 0, /*tp_as_sequence*/
- 0, /*tp_as_mapping*/
- 0, /*tp_hash*/
-};
-/* --------------------------------------------------------------------- */
-
-/* Function of two integers returning integer */
-
-static PyObject *
-xx_foo(PyObject *self, PyObject *args)
-{
- long i, j;
- long res;
- if (!PyArg_ParseTuple(args, "ll:foo", &i, &j))
- return NULL;
- res = i+j; /* XXX Do something here */
- return PyInt_FromLong(res);
-}
-
-
-/* Function of no arguments returning new Xxo object */
-
-static PyObject *
-xx_new(PyObject *self, PyObject *args)
-{
- XxoObject *rv;
-
- if (!PyArg_ParseTuple(args, ":new"))
- return NULL;
- rv = newXxoObject(args);
- if ( rv == NULL )
- return NULL;
- return (PyObject *)rv;
-}
-
-/* Example with subtle bug from extensions manual ("Thin Ice"). */
-
-static PyObject *
-xx_bug(PyObject *self, PyObject *args)
-{
- PyObject *list, *item;
-
- if (!PyArg_ParseTuple(args, "O:bug", &list))
- return NULL;
-
- item = PyList_GetItem(list, 0);
- /* Py_INCREF(item); */
- PyList_SetItem(list, 1, PyInt_FromLong(0L));
- PyObject_Print(item, stdout, 0);
- printf("\n");
- /* Py_DECREF(item); */
-
- Py_INCREF(Py_None);
- return Py_None;
-}
-
-/* Test bad format character */
-
-static PyObject *
-xx_roj(PyObject *self, PyObject *args)
-{
- PyObject *a;
- long b;
- if (!PyArg_ParseTuple(args, "O#:roj", &a, &b))
- return NULL;
- Py_INCREF(Py_None);
- return Py_None;
-}
-
-
-/* List of functions defined in the module */
-
-static PyMethodDef xx_methods[] = {
- {"roj", xx_roj, METH_VARARGS},
- {"foo", xx_foo, METH_VARARGS},
- {"new", xx_new, METH_VARARGS},
- {"bug", xx_bug, METH_VARARGS},
- {NULL, NULL} /* sentinel */
-};
-
-
-/* Initialization function for the module (*must* be called initxx) */
-
-DL_EXPORT(void)
-initmkcwtest(void)
-{
- PyObject *m, *d;
-
- /* Initialize the type of the new type object here; doing it here
- * is required for portability to Windows without requiring C++. */
- Xxo_Type.ob_type = &PyType_Type;
-
- /* Create the module and add the functions */
- m = Py_InitModule("mkcwtest", xx_methods);
-
- /* Add some symbolic constants to the module */
- d = PyModule_GetDict(m);
- ErrorObject = PyErr_NewException("xx.error", NULL, NULL);
- PyDict_SetItemString(d, "error", ErrorObject);
-}
diff --git a/Mac/Lib/test/mkcwproj/testmkcwproj.py b/Mac/Lib/test/mkcwproj/testmkcwproj.py
deleted file mode 100644
index ac1cb8ec76..0000000000
--- a/Mac/Lib/test/mkcwproj/testmkcwproj.py
+++ /dev/null
@@ -1,12 +0,0 @@
-import mkcwproject
-import sys
-
-dict = {
- "sysprefix": sys.prefix,
- "sources": ["mkcwtestmodule.c"],
- "extrasearchdirs": [],
-}
-
-
-mkcwproject.mkproject("mkcwtest.prj", "mkcwtest", dict)
-mkcwproject.buildproject("mkcwtest.prj")
diff --git a/Mac/Lib/test/readme.txt b/Mac/Lib/test/readme.txt
deleted file mode 100644
index dbf671f1f9..0000000000
--- a/Mac/Lib/test/readme.txt
+++ /dev/null
@@ -1,4 +0,0 @@
-The files in this folder are not maintained very well. They have worked at some
-point in the past, but they may not work anymore. They may contain interesting
-information, but they could also very well contain misinformation. Use at your
-own risk.
diff --git a/Mac/Lib/test/tell.py b/Mac/Lib/test/tell.py
deleted file mode 100644
index fcacb7ed58..0000000000
--- a/Mac/Lib/test/tell.py
+++ /dev/null
@@ -1,63 +0,0 @@
-# (Slightly less) primitive operations for sending Apple Events to applications.
-# This could be the basis of a Script Editor like application.
-
-from Carbon.AE import *
-from Carbon.AppleEvents import *
-import aetools
-import types
-
-class TalkTo:
- def __init__(self, signature):
- """Create a communication channel with a particular application.
-
- For now, the application must be given by its 4-character signature
- (because I don't know yet how to do other target types).
- """
- if type(signature) != types.StringType or len(signature) != 4:
- raise TypeError, "signature should be 4-char string"
- self.target = AECreateDesc(typeApplSignature, signature)
- self.send_flags = kAEWaitReply
- self.send_priority = kAENormalPriority
- self.send_timeout = kAEDefaultTimeout
- def newevent(self, code, subcode, parameters = {}, attributes = {}):
- event = AECreateAppleEvent(code, subcode, self.target,
- kAutoGenerateReturnID, kAnyTransactionID)
- aetools.packevent(event, parameters, attributes)
- return event
- def sendevent(self, event):
- reply = event.AESend(self.send_flags, self.send_priority,
- self.send_timeout)
- parameters, attributes = aetools.unpackevent(reply)
- return reply, parameters, attributes
-
- def send(self, code, subcode, parameters = {}, attributes = {}):
- return self.sendevent(self.newevent(code, subcode, parameters, attributes))
-
- def activate(self):
- # Send undocumented but easily reverse engineered 'activate' command
- self.send('misc', 'actv')
-
-
-# This object is equivalent to "selection" in AppleScript
-# (in the core suite, if that makes a difference):
-get_selection = aetools.Property('sele', None)
-
-# Test program. You can make it do what you want by passing parameters.
-# The default gets the selection from Quill (Scriptable Text Editor).
-
-def test(app = 'quil', suite = 'core', id = 'getd', arg = get_selection):
- t = TalkTo(app)
- t.activate()
- if arg:
- dict = {'----': arg}
- else:
- dict = {}
- reply, parameters, attributes = t.send(suite, id, dict)
- print reply, parameters
- if parameters.has_key('----'): print "returns:", str(parameters['----'])
-
-
-test()
-# So we can see it:
-import sys
-sys.exit(1)
diff --git a/Mac/Lib/test/test_finder_ae b/Mac/Lib/test/test_finder_ae
deleted file mode 100644
index b6241a2ce4..0000000000
--- a/Mac/Lib/test/test_finder_ae
+++ /dev/null
@@ -1,5 +0,0 @@
-tell application "AEservertest"
- activate
- set x to window "testing"
- open file x
-end tell
diff --git a/Mac/Lib/test/test_setcontroldata.py b/Mac/Lib/test/test_setcontroldata.py
deleted file mode 100644
index 81672145ac..0000000000
--- a/Mac/Lib/test/test_setcontroldata.py
+++ /dev/null
@@ -1,13 +0,0 @@
-import W
-from Carbon.Controls import *
-
-w = W.Window((200,200), "Test")
-
-w.c = W.Button((5,5,100,50), "Test")
-
-w.open()
-
-print repr(w.c._control.GetControlData(0, 'dflt'))
-
-str = '\001'
-w.c._control.SetControlData(0, 'dflt', str) \ No newline at end of file
diff --git a/Mac/Lib/test/tlist.py b/Mac/Lib/test/tlist.py
deleted file mode 100644
index 5b84fc5164..0000000000
--- a/Mac/Lib/test/tlist.py
+++ /dev/null
@@ -1,92 +0,0 @@
-# Test List module.
-# Draw a window with all the files in the current folder.
-# double-clicking will change folder.
-#
-# This test expects Win, Evt and FrameWork (and anything used by those)
-# to work.
-#
-# Actually, it is more a test of FrameWork by now....
-
-from FrameWork import *
-from Carbon import Win
-from Carbon import Qd
-from Carbon import List
-from Carbon import Lists
-import os
-
-class ListWindow(Window):
- def open(self, name, where):
- self.where = where
- r = (40, 40, 400, 300)
- w = Win.NewWindow(r, name, 1, 0, -1, 1, 0x55555555)
- r2 = (0, 0, 345, 245)
- Qd.SetPort(w)
- self.wid = w
- self.list = List.LNew(r2, (0, 0, 1, 1), (0,0), 0, w, 0, 1, 1, 1)
- self.list.selFlags = Lists.lOnlyOne
- self.filllist()
- w.DrawGrowIcon()
- self.do_postopen()
-
- def do_activate(self, onoff, evt):
- self.list.LActivate(onoff)
-
- def do_update(self, *args):
- self.list.LUpdate(self.wid.GetWindowPort().visRgn)
-
- def do_contentclick(self, local, modifiers, evt):
- dclick = self.list.LClick(local, modifiers)
- if dclick:
- h, v = self.list.LLastClick()
- file = self.list.LGetCell(1000, (h, v))
- self.where = os.path.join(self.where, file)
- self.filllist()
-
- def filllist(self):
- """Fill the list with the contents of the current directory"""
- l = self.list
- l.LSetDrawingMode(0)
- l.LDelRow(0, 0)
- contents = os.listdir(self.where)
- l.LAddRow(len(contents), 0)
- for i in range(len(contents)):
- l.LSetCell(contents[i], (0, i))
- l.LSetDrawingMode(1)
- l.LUpdate(self.wid.GetWindowPort().visRgn)
-
-
-class TestList(Application):
- def __init__(self):
- Application.__init__(self)
- self.num = 0
- self.listoflists = []
-
- def makeusermenus(self):
- self.filemenu = m = Menu(self.menubar, "File")
- self.newitem = MenuItem(m, "New window...", "O", self.open)
- self.quititem = MenuItem(m, "Quit", "Q", self.quit)
-
- def open(self, *args):
- import macfs
- fss, ok = macfs.GetDirectory()
- if not ok:
- return
- w = ListWindow(self)
- w.open('Window %d'%self.num, fss.as_pathname())
- self.num = self.num + 1
- self.listoflists.append(w)
-
- def quit(self, *args):
- raise self
-
- def do_about(self, id, item, window, event):
- EasyDialogs.Message("""Test the List Manager interface.
- Simple inward-only folder browser""")
-
-def main():
- App = TestList()
- App.mainloop()
-
-if __name__ == '__main__':
- main()
-
diff --git a/Mac/Lib/test/tsnd.py b/Mac/Lib/test/tsnd.py
deleted file mode 100644
index 919785a306..0000000000
--- a/Mac/Lib/test/tsnd.py
+++ /dev/null
@@ -1,18 +0,0 @@
-# Show off SndPlay (and some resource manager functions).
-# Get a list of all 'snd ' resources in the system and play them all.
-
-from Carbon.Res import *
-from Carbon.Snd import *
-
-ch = SndNewChannel(0, 0, None)
-print "Channel:", ch
-
-type = 'snd '
-
-for i in range(CountResources(type)):
- r = GetIndResource(type, i+1)
- print r.GetResInfo(), r.size
- if r.GetResInfo()[0] == 1:
- print "Skipping simple beep"
- continue
- ch.SndPlay(r, 0)
diff --git a/Mac/Lib/test/tte.py b/Mac/Lib/test/tte.py
deleted file mode 100644
index bde7de247a..0000000000
--- a/Mac/Lib/test/tte.py
+++ /dev/null
@@ -1,17 +0,0 @@
-# Test TE module, simple version
-
-from Carbon.Win import *
-from Carbon.TE import *
-from Carbon import Qd
-
-r = (40, 40, 140, 140)
-w = NewWindow(r, "TETextBox test", 1, 0, -1, 1, 0x55555555)
-##w.DrawGrowIcon()
-
-r = (10, 10, 90, 90)
-
-Qd.SetPort(w)
-t = TETextBox("Nobody expects the SPANISH inquisition", r, 1)
-
-import time
-time.sleep(10)
diff --git a/Mac/Lib/test/twin.py b/Mac/Lib/test/twin.py
deleted file mode 100644
index 0904d320bc..0000000000
--- a/Mac/Lib/test/twin.py
+++ /dev/null
@@ -1,9 +0,0 @@
-# Test Win module
-
-from Win import *
-
-r = (40, 40, 400, 300)
-w = NewWindow(r, "Hello world", 1, 0, -1, 1, 0x55555555)
-w.DrawGrowIcon()
-import time
-time.sleep(10)