>># 
>># Copyright 1990, 1991 by the Massachusetts Institute of Technology and
>># UniSoft Group Limited.
>># 
>># Permission to use, copy, modify, distribute, and sell this software and
>># its documentation for any purpose is hereby granted without fee,
>># provided that the above copyright notice appear in all copies and that
>># both that copyright notice and this permission notice appear in
>># supporting documentation, and that the names of MIT and UniSoft not be
>># used in advertising or publicity pertaining to distribution of the
>># software without specific, written prior permission.  MIT and UniSoft
>># make no representations about the suitability of this software for any
>># purpose.  It is provided "as is" without express or implied warranty.
>># 
>># $XConsortium: clsdsply.m,v 1.23 92/06/29 18:14:34 rws Exp $
>># 
>>#
>>TITLE XCloseDisplay CH02
>>ASSERTION B XCloseDisplay-1
A call to XCloseDisplay flushes the output buffer and waits
until each flushed request has been received and processed
by the X server.
>>STRATEGY
Report UNTESTED
>>ASSERTION B XCloseDisplay-2
A call to XCloseDisplay closes the connection specified by
the display argument.
>>STRATEGY
If the system is POSIX compliant:
  Open a display using XOpenDisplay.
  Obtain the file descriptor of the connection using XConnectionNumber.
  Close the display using XCloseDisplay.
  Close the file descriptor using close.
  Verify that the call returned -1.
Otherwise:
  UNTESTED.
>>ASSERTION A XCloseDisplay-3
A call to XCloseDisplay disowns all selections made by the
client.
>>STRATEGY
Open a display using XOpenDisplay.
Create a client window using XCreateWindow.
Acquire the XA_PRIMARY selection using XSetSelectionOwner.
Verify that the client owns the selection with XGetSelectionOwner.
Close the display using XCloseDisplay.
Verify that the XA_PRIMARY selection is not owned with XGetSelectionOwner.
>>ASSERTION A XCloseDisplay-4
When the client has actively grabbed the pointer, then a
call to XCloseDisplay performs a XUngrabPointer.
>>STRATEGY
Open a display using XOpenDisplay.
Grab the pointer using XGrabPointer.
Verify that the call returned GrabSuccess.
Close the display using XCloseDisplay.
Grab the pointer using XGrabPointer.
Verify that the call returned GrabSuccess.
>>ASSERTION A XCloseDisplay-5
When the client has actively grabbed the keyboard, then a
call to XCloseDisplay performs a XUngrabKeyboard.
>>STRATEGY
Open a display using XOpenDisplay.
Grab the keyboard using XGrabKeyboard.
Verify that the call returned GrabSuccess.
Close the display using XCloseDisplay.
Grab the keyboard using XGrabKeyboard.
Verify that the call returned GrabSuccess.
>>ASSERTION A XCloseDisplay-6
When the client has grabbed the server, then a call to
XCloseDisplay performs a XUngrabServer.
>>STRATEGY
Create a connection for client1 using XOpenDisplay.
Create a connection for client2 using XOpenDisplay.
Create a window using XCreateWindow.
Grab the server for the default display using XGrabServer.
Create a process using tet_fork.
In child process:
   Generate a ChangeProperty request using XChangeProperty.
Wait sufficient time for the ChangeProperty request to be processed.
Verify that no PropertyChange event has been generated by client2 using XCheckWindowEvent.
Close the client1 connection using XCloseDisplay.
Wait suffient time for the ChangeProperty request to be processed.
Verify that a ChangeProperty request was generated by client2.
>>ASSERTION B XCloseDisplay-7
A call to XCloseDisplay releases all passive grabs made by
the client.
>>STRATEGY
Report UNTESTED
>>ASSERTION A XCloseDisplay-8
A call to XCloseDisplay frees the default GC for the
client.
>>STRATEGY
Open a connection using XOpenDisplay.
Obtain the default gc id using XDefaultGC.
Close the display using XCloseDisplay.
Call XDrawPoint using the default gc id.
Verify that a BadGC error occurred.
>>ASSERTION B XCloseDisplay-9
When the closedown mode of the client is RetainPermanent,
then all resources allocated by the client are marked as
permanent.
>>STRATEGY
Report UNTESTED
>>ASSERTION B XCloseDisplay-10
When the closedown mode of the client is RetainTemporary,
then all resources allocated by the client are marked as
temporary.
>>STRATEGY
Report UNTESTED
>>ASSERTION A XCloseDisplay-11
When the closedown mode of the client is DestroyAll, then
on a call to XCloseDisplay all windows in the client's
save-set that are inferiors of a window created by the
client are reparented, with no change in position relative
to the root window, to the closest ancestor such that it is
not an inferior of a client's window.
>>STRATEGY
Open a display using XOpenDisplay.
Set the closedown mode of the display to DestroyAll using XSetCloseDownMode.
Create save set with setupsaveset.
Close the display using XCloseDisplay.
Verify reparenting for the save-set occurs and positioning is correct.
>>ASSERTION A XCloseDisplay-12
When the closedown mode of the client is DestroyAll, then
a call to XCloseDisplay performs a XMapWindow request on all
unmapped windows in the client's save-set.
>>STRATEGY
Open a display using XOpenDisplay.
Create save set with setupsaveset.
Close the display using XCloseDisplay.
Get all map events.
Compare each event against expected values.
Verify that map events were received for all save-set windows that
were inferiors of client1 or were not originally mapped.
Verify that map events were received for the parents of all save-set
windows that were inferiors of client1 or were not originally mapped.
>>ASSERTION A XCloseDisplay-13
When the closedown mode of the client is DestroyAll, then
a call to XCloseDisplay destroys all Window, Font, Pixmap,
Colormap, Cursor and GContext resources allocated by the
client.
>>STRATEGY
Open a display using XOpenDisplay.
Set the closedown mode of the display to DestroyAll using XSetCloseDownMode.
Create a font using XLoadFont.
Create a window using XCreateSimpleWindow.
Create a pixmap using XCreatePixmap.
Create a colormap using XCreateColormap.
Create a cursor using XCreateFontCursor.
Create a GC using XCreateGC.
Close the display using XCloseDisplay.
Free the GC using XFreeGC.
Verify that a BadGC error occurred.
Free the cursor using XFreeCursor.
Verify that a BadCursor error occurred.
Free the colormap using XFreeColormap.
Verify that a BadColor error occurred.
Draw on the pixmap with XDrawPoint.
Verify that a BadDrawable error occurred.
Draw on the window using XDrawPoint.
Verify that a BadDrawable error occurred.
Free the font using XUnloadFont.
Verify that a BadFont error occurred.
>>ASSERTION A XCloseDisplay-14
When the last connection to the X server closes with a
closedown mode of DestroyAll, then the server destroys all
lingering resources from clients that have terminated in
RetainPermanent or RetainTemporary mode.
>>STRATEGY
Set the closedown mode of client Dsp to DestroyAll using XSetCloseDownMode.
Open 2 clients with XOpenDisplay.
Set the closedown mode of the first to RetainPermanent using XSetCloseDownMode.
Set the closedown mode of the second to RetainTemporary using XSetCloseDownMode.
Create a font for each client using XLoadFont.
Create a window for each client using XCreateSimpleWindow.
Create a pixmap for each client using XCreatePixmap.
Create a colormap for each client using XCreateColormap.
Create a cursor for each client using XCreateFontCursor.
Create a gc for each client using XCreateGC.
Close the 2 clients.
Close client Dsp using XCloseDisplay.

Open client Dsp using XOpenDisplay.
Free the GCs using XFreeGC.
Verify that a BadGC error occurred.
Free the cursors using XFreeCursor.
Verify that a BadCursor error occurred.
Free the colormaps using XFreeColormap.
Verify that a BadColor occurred.
Draw on the pixmaps with XDrawPoint.
Verify that a BadDrawable error occurred.
Draw on the windows using XDrawPoint.
Verify that a BadDrawable error occurred.
Free the fonts using XUnloadFont.
Verify that a BadFont error occurred.
>>ASSERTION A XCloseDisplay-15
When the last connection to the X server closes with a
closedown mode of DestroyAll, then the server deletes all
but the predefined atom IDs.
>>STRATEGY
Set the closedown mode to DestroyAll using XSetCloseDownMode.
Create and intern the atom XT_TEST_Atom using XInternAtom.
Close all the server displays.
Open the display.
Verify that the atom XT_TEST_Atom no longer exists.
Verify that each of the predefined atoms exists.
>>ASSERTION A XCloseDisplay-16
When the last connection to the server closes with a
closedown mode of DestroyAll, then the server deletes all
properties on all the root windows.
>>STRATEGY
For each screen:
  Obtain the root window of the screen using RootWindow.
  Set the XA_PRIMARY property on the window using XChangeProperty.
Close all connections to the server using XCloseDisplay.
Open a server connection using XOpenDisplay.
For each screen: 
  Obtain the value of the XA_PRIMARY property using XGetWindowProperty.
  Verify that returned type was None, the returned format was 0 and 
  that the bytes_after_return was 0.
>>ASSERTION B XCloseDisplay-17
When the last connection to the server closes with a
closedown mode of DestroyAll, then the server resets all
device maps, attributes and the access control list.
>>STRATEGY
Report UNTESTED
>>ASSERTION B XCloseDisplay-18
When the last connection to the server closes with a
closedown mode of DestroyAll, then the server restores the
standard root tiles and cursors.
>>STRATEGY
Report UNTESTED
>>ASSERTION A XCloseDisplay-19
When the last connection to the server closes with a
closedown mode of DestroyAll, then the server restores the
default font path.
>>STRATEGY
Set the closedown mode of a connection to DestroyAll.
Set the font path to XT_FONTPATH using XSetFontPath
Close all connections to the server using XCloseDisplay.
Open a connection using XOpenDisplay.
Set the closedown mode of the connection to DestroyAll.
Set the font path to XT_FONTPATH_GOOD using XSetFontPath
Close all connections to the server using XCloseDisplay.
Verify that the font path is restored in each case to the same font path.
Set the font path to the restored font path using XSetFontPath.
Verify that no error occurs.
Verify that the cursor font can be accessed.
>>ASSERTION A XCloseDisplay-20
When the last connection to the server closes with a
closedown mode of DestroyAll, then the server restores the
input focus to PointerRoot.
>>STRATEGY
Set the closedown mode of a connection to DestroyAll.
Set the input focus of a connection to None with XSetInputFocus.
Close all connections to the server using XCloseDisplay.
Open a connection using XOpenDisplay.
Obtain the current input focus using XGetInputFocus.
Verify that the input focus is PointerRoot.
>>ASSERTION A XCloseDisplay-21
When the last connection to the server closes with a
closedown mode of RetainPermanent or RetainTemporary, then
a call to XCloseDisplay does not affect any window in the
client's save-set.
>>STRATEGY
Open a display using XOpenDisplay.
Set the closedown mode of the display to RetainPermanent using XSetCloseDownMode.
Create save set with setupsaveset.
Close the display using XCloseDisplay.
Verify parents and positions of the save-set members stay the same.
Open a display using XOpenDisplay.
Set the closedown mode of the display to RetainTemporary using XSetCloseDownMode.
Create save set with setupsaveset.
Close the display using XCloseDisplay.
Verify parents and positions of the save-set members stay the same.
>>ASSERTION A XCloseDisplay-22
When the last connection to the server closes with a
closedown mode of RetainPermanent or RetainTemporary, then
a call to XCloseDisplay does not delete any Window, Font,
Pixmap, Colormap, Cursor and GContext resources allocated
by the client.
>>STRATEGY
Set the closedown mode of the display to RetainPermanent using XSetCloseDownMode.
Create a font using XLoadFont.
Create a window using XCreateSimpleWindow.
Create a pixmap using XCreatePixmap.
Create a colormap using XCreateColormap.
Create a cursor using XCreateFontCursor.
Create a GC using XCreateGC.

Close the display using XCloseDisplay.
Open the display using XOpenDisplay.
Free the GC using XFreeGC.
Verify that no errors occurred.
Free the cursor using XFreeCursor.
Verify that no errors occurred.
Free the colormap using XFreeColormap.
Verify that no errors occurred.
Draw on the pixmap with XDrawPoint.
Verify that no errors occurred.
Draw on the window using XDrawPoint.
Verify that no errors occurred.
Free the font using XUnloadFont.
Verify that no errors occurred.

Set the closedown mode of the display to RetainTemporary using XSetCloseDownMode.
Create a font using XLoadFont.
Create a window using XCreateSimpleWindow.
Create a pixmap using XCreatePixmap.
Create a colormap using XCreateColormap.
Create a cursor using XCreateFontCursor.
Create a GC using XCreateGC.

Close the display using XCloseDisplay.
Open the display using XOpenDisplay.
Free the GC using XFreeGC.
Verify that no errors occurred.
Free the cursor using XFreeCursor.
Verify that no errors occurred.
Free the colormap using XFreeColormap.
Verify that no errors occurred.
Draw on the pixmap with XDrawPoint.
Verify that no errors occurred.
Draw on the window using XDrawPoint.
Verify that no errors occurred.
Free the font using XUnloadFont.
Verify that no errors occurred.
>>ASSERTION A XCloseDisplay-23
When the last connection to the server closes with a
closedown mode of RetainPermanent or RetainTemporary, then
a call to XCloseDisplay does not delete any of the atom IDs.
>>STRATEGY
Set the closedown mode to RetainPermanent using XSetCloseDownMode.
Create and intern the atom XT_TEST_Atom using XInternAtom.
Close all connections to the server using XCloseDisplay.
Open a server connection using XOpenDisplay.
Verify that the atom XT_TEST_Atom is still interned.
Verify that all the predefined atoms still exist.

Set the closedown mode to RetainTemporary using XSetCloseDownMode.
Create and intern the atom XT_TEST_Atom using XInternAtom.
Close all connections to the server using XCloseDisplay.
Open a server connection using XOpenDisplay.
Verify that the atom XT_TEST_Atom is still interned.
Verify that all the predefined atoms still exist.
>>ASSERTION B XCloseDisplay-24
When the last connection to the server closes with a
closedown mode of RetainPermanent or RetainTemporary, then
a call to XCloseDisplay does not delete any property on any
root window.
>>STRATEGY
Report UNTESTED
>>ASSERTION B XCloseDisplay-25
When the last connection to the server closes with a
closedown mode of RetainPermanent or RetainTemporary, then
a call to XCloseDisplay does not affect any device map, any
attributes or the access control list.
>>STRATEGY
Report UNTESTED
>>ASSERTION B XCloseDisplay-26
When the last connection to the server closes with a
closedown mode of RetainPermanent or RetainTemporary, then
a call to XCloseDisplay does not affect the standard root
tiles and cursors.
>>STRATEGY
Report UNTESTED
>>ASSERTION B XCloseDisplay-27
When the last connection to the server closes with a
closedown mode of RetainPermanent or RetainTemporary, then
a call to XCloseDisplay does not affect the default font
path.
>>STRATEGY
Report UNTESTED
>>ASSERTION A XCloseDisplay-28
When the last connection to the server closes with a
closedown mode of RetainPermanent or RetainTemporary, then
a call to XCloseDisplay does not affect the input focus.
>>STRATEGY
Set the closedown mode to RetainPermanent using XSetCloseDownMode.
Set the input focus to None with XSetInputFocus.
Close all connections to the server using XCloseDisplay.
Open a connection using XOpenDisplay.
Obtain the current input focus using XGetInputFocus.
Verify that the input focus is None.

Set the closedown mode to RetainTemporary using XSetCloseDownMode.
Set the input focus to None with XSetInputFocus.
Close all connections to the server using XCloseDisplay.
Open a connection using XOpenDisplay.
Obtain the current input focus using XGetInputFocus.
Verify that the input focus is None.
