home *** CD-ROM | disk | FTP | other *** search
- /*
- File: LibraryManagerTest2.c
-
- Contains: xxx put contents here xxx
-
- Copyright: © 1991-1994 by Apple Computer, Inc., all rights reserved.
-
- */
-
- #ifndef __EXAMPLECLASS__
- #include "ExampleClass.h"
- #endif
- #ifndef __EVENTS__
- #include <Events.h>
- #endif
- #ifndef __CURSORCTL__
- #include <CursorCtl.h>
- #endif
-
- #ifndef __STDIO__
- #include <stdio.h>
- #endif
-
- static void Idle(RgnHandle);
-
- void DoTests(TExampleClass* object1, TExampleClass* object2, int count, Boolean trace, Boolean verbose)
- {
- RgnHandle myRgn;
- unsigned long endcount, startcount;
-
- InitGraf(&qd.thePort); // initialize quickdraw so we can use regions
- myRgn = NewRgn(); // a region to use for WaitNextEvent
-
- InitCursorCtl(NULL);
-
- if (object1 && object2) {
- startcount = TickCount();
- ExSetObjectName(object1, "object1");
- ExSetObjectName(object2, "object2");
-
- while (count-- > 0) { // <-- here is the test while loop
- ExDoThisAndThat(object1); // here we test DoThisAndThat for object1
- ExDoThisAndThat(object2); // here we test DoThisAndThat for object2
- if (trace) Idle(myRgn); // if we are tracing we must idle
- if (verbose) SpinCursor(1); // if we are verbose we will spin the cursor
- }
-
- // test accessing globals
- ExSetGlobalInt(object1, 42); // set the global using object1
-
- // get the global using object2
- // since object1 and object2 share the same A5 world this will return
- // 42!
- printf("%s ExGetGlobalInt() returns: %d",ExGetObjectName(object2),ExGetGlobalInt(object2));
- printf("\n"); // hack to keep SC 7.0.5 from crashing
- endcount = TickCount();
- printf("Dispatches took %d ticks\n", endcount - startcount);
- }
-
- if (object1) {
- if (verbose) printf("Disposing object1\n");
- ExDestructor(object1);
- }
-
- if (object2) {
- if (verbose) printf("Disposing object2\n");
- ExDestructor(object2);
- }
-
- DisposeRgn(myRgn);
- }
-
- static void Idle(RgnHandle myRgn)
- {
- EventRecord myEvent;
- WaitNextEvent(nullEvent, &myEvent, 0, myRgn);
- }