>># 
>># 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: grbpntr.m,v 1.11 92/06/11 17:13:25 rws Exp $
>># 
>>#      SCCS:  @(#)  ECur.mc Rel 1.8	    (2/21/92)
>>#      SCCS:  @(#)  EVal.mc Rel 1.5	    (10/10/91)
>>#      SCCS:  @(#)  EVal.mc Rel 1.5	    (10/10/91)
>>#      SCCS:  @(#)  EVal.mc Rel 1.5	    (10/10/91)
>>#      SCCS:  @(#)  EVal.mc Rel 1.5	    (10/10/91)
>>#      SCCS:  @(#)  EWin.mc Rel 1.4	    (7/19/91)
>>#
>>TITLE XGrabPointer CH07
>>ASSERTION A XGrabPointer-1
A successful call to XGrabPointer actively grabs control of
the pointer and returns GrabSuccess.
>>STRATEGY
Call XGrabPointer.
Verify that it returns GrabSuccess.
>>ASSERTION A XGrabPointer-2
After a call to XGrabPointer is made by a client, pointer
events are reported only to that client.
>>STRATEGY
Create second client.
Create grab window.
Select pointer events for both clients.
Grab the pointer.
Warp pointer.
Verify that the event is only reported to grabbing client.
>>ASSERTION A XGrabPointer-3
A call to XGrabPointer overrides any active pointer grab by
this client.
>>STRATEGY
Create two windows.
Call XGrabPointer with confine_to as one of the windows.
Check that pointer is within that window.
Call XGrabPointer with confine_to as the other window.
Verify that pointer is within the other window.
>>ASSERTION A XGrabPointer-4
When owner_events is False, then all generated pointer
events that are selected by the event_mask are reported with
respect to the grab_window.
>>STRATEGY
Set owner_events to False.
Create grab window.
Create other window.
Set event-mask to select pointer events.
Grab pointer.
Warp pointer to other window.
Verify that events are reported with respect to the grab window.
>>ASSERTION A XGrabPointer-5
When owner_events is True, and a pointer event is
generated that would normally be reported to the client,
then it is reported on the window that it would normally be
reported on.
>>STRATEGY
Create window for grab window.
Create window2.
Set owner_events to True.
Select pointer events on window2.
Grab pointer.
Warp pointer in window2.
Verify that pointer events are generated on window2.
>>ASSERTION A XGrabPointer-6
When owner_events is True, and a pointer event is
generated that would not normally be reported to the client,
and it is selected by event_mask, then it is reported on
the grab_window.
>>STRATEGY
Create window for grab window.
Create window2.
Set owner_events to True.
Select pointer events in event_mask.
Do not select pointer events on window2.
Grab pointer.
Warp pointer in window2.
Verify that pointer events are generated on the grab window.
>>ASSERTION A XGrabPointer-7
When pointer_mode is GrabModeAsync, then pointer event
processing continues normally.
>>STRATEGY
Grab pointer with pointer_mode GrabModeAsync.
Warp pointer.
Verify that pointer events are received.
>>ASSERTION A XGrabPointer-8
When pointer_mode is GrabModeAsync and the pointer is
currently frozen by this client, then the processing of
events for the pointer is resumed.
>>STRATEGY
Freeze pointer by grabbing keyboard with pointer_mode GrabModeSync.
Warp pointer.
Verify that no pointer events received yet.
Grab pointer with GrabModeAsync.
Verify that the pointer event is now released.
>>ASSERTION A XGrabPointer-9
When pointer_mode is GrabModeSync, then the state of the
pointer, as seen by client applications, appears to freeze,
and no further pointer events are generated until the
grabbing client calls XAllowEvents or until the pointer grab
is released.
>>STRATEGY
Grab pointer with GrabModeSync.
Warp pointer.
Verify that no pointer events are received.
>>ASSERTION A XGrabPointer-10
When the pointer is frozen, then the actual pointer changes
are not lost and are processed after the grab is released or
the client calls XAllowEvents.
>>STRATEGY
Grab pointer with GrabModeSync.
Warp pointer.
Verify that no pointer events are received.
Release pointer.
Verify that pointer events are now received.
>>ASSERTION B XGrabPointer-11
When keyboard_mode is GrabModeAsync, then keyboard event
processing is unaffected by activation of the grab.
>>STRATEGY
If extension available:
  Grab pointer with keyboard_mode = GrabModeAsync.
  Check keyboard not frozen.
else
  Report untested.

>>ASSERTION B XGrabPointer-12
When keyboard_mode is GrabModeSync, then the state of the
keyboard, as seen by client applications, appears to freeze,
and no further keyboard events are generated until the
grabbing client calls XAllowEvents or until the pointer grab
is released.
>>STRATEGY
If extensions available:
  Call XGrabPointer with keyboard_mode GrabModeSync.
  Verify that keyboard is frozen.
  Release grab.
  Verify that keyboard is not frozen.
>>ASSERTION B XGrabPointer-13
When the keyboard is frozen, then the actual keyboard
changes are not lost and are processed after the grab is
released or the client calls XAllowEvents.
>>STRATEGY
If extensions available:
  Enable key events on grab_window.
  Call XGrabPointer with keyboard_mode GrabModeSync.
  Press and release key.
  Check no events arrived yet.
  Release grab.
  Verify that KeyPress and KeyRelease events are now received.
else
  Report untested.
>>ASSERTION B XGrabPointer-14
When cursor is a valid cursor, then it is displayed
regardless of which window the pointer is in.
>>STRATEGY
If extensions available:
  Make a tree of windows rooted at grab_window, all with default cursor.
  Make a non-overlapping sibling of grab_window, the cursor window.
  Set that window's cursor to be a good, non default, cursor.
  Call XGrabPointer with cursor = the good cursor.
  Warp pointer to all windows in the tree, root and cursor window, and
    validate that current cursor is equal to that of cursor window
    using extension.
else
  Report untested.
>>ASSERTION B XGrabPointer-15
When cursor is None, then the normal cursor is displayed
when the pointer position is in the grab_window and its
subwindows, and the grab_window cursor is displayed when the
pointer is in any other window.
>>STRATEGY
If extensions available:
  Make a tree of windows rooted at grab_window (parent), all with default cursor.
  Set grab_window to be one of its own children (child2), which has its own
    child (grandchild).
  Set grab_window's cursor to be a good, non default, cursor.
  Set grab_window's child's (grandchild) cursor to be yet another good,
    non default, cursor.
  Call XGrabPointer with cursor = None.
  Warp pointer to all windows in the tree, plus root, and
    validate that current cursor is equal to that of grab_window & grandchild,
    respectively, when in the corresponding windows, but equal to that of
    grab_window otherwise, using extension.
else
  Report untested.
>>ASSERTION A XGrabPointer-16
When confine_to is not None, then the pointer is confined
to that window.
>>STRATEGY
Create grab_window.
Create window as the confine_to window.
Grab pointer.
Verify that pointer is now in the confine_to window.
Warp pointer outside confine_to window.
Verify that pointer is still within the confine_to window.
>>ASSERTION A XGrabPointer-17
When the pointer is not initially in the confine_to window,
then it is warped automatically to the closest edge just
before the grab activates and enter and leave events are
generated.
>>STRATEGY
Create confine_to window.
Create grab_window.
Create spare window 'win'.
Warp pointer to win.
Enable events on win and grab and confine_to windows.
Grab pointer.
Verify that a leave event is generated on win.
Verify that an enter event is generated on the confine_to window.
>>ASSERTION A XGrabPointer-18
When the confine_to window is subsequently reconfigured,
then the pointer is warped automatically to keep it within
the window.
>>STRATEGY
Create grab_window and confine_to window.
Grab pointer.
Move window so that it does not overlap it's previous position.
Verify that pointer has been warped to the new position.
>>ASSERTION C XGrabPointer-19
If multiple screens are supported: When the confine_to
window and the grab_window are not on the same screen, then
the pointer is warped to the screen containing the
confine_to window.
>>STRATEGY
If only one screen
  UNSUPPORTED.
Create grab_window on default screen.
Create confine_to window on alternate screen.
Grab pointer.
Verify that pointer is warped to other screen.
>>ASSERTION B XGrabPointer-20
When a successful call to XGrabPointer is made, then the
last-pointer-grab time is set to the specified time with
CurrentTime replaced by the current X server time.
>>STRATEGY
If extensions are available:
  Call XGrabPointer with time = gettime(display).
  Check result and that pointer is grabbed.
  Attempt XUngrabPointer at time just before time.
  Check still grabbed.
  Attempt XUngrabPointer at time equal to time.
  Check no longer grabbed.

  Get time before with gettime(display).
  Call XGrabPointer with time = CurrentTime.
  Check result and that pointer is grabbed.
  Attempt XUngrabPointer at time before.
  Check still grabbed.
  Attempt XUngrabPointer at CurrentTime.
  Check no longer grabbed.
else
  Report untested.
>>ASSERTION A XGrabPointer-21
When the grab_window or confine_to window becomes not
viewable during an active pointer grab, then the grab is
released.
>>STRATEGY
Create new client, client2.
Create grab and confine_to windows.
Create spare window 'win' that does not overlap with the other two.
Enable events on win for client2.
Grab pointer.
Unmap grab_window.
Verify that grab is released by provoking pointer events for client2.

Re-map grab_window.
Grab pointer.
Unmap confine_to window.
Verify that grab is released by provoking pointer events for client2.
>>ASSERTION A XGrabPointer-22
When window reconfiguration causes the confine_to window to
lie completely outside the boundaries of the root window
during an active pointer grab, then the grab is released.
>>STRATEGY
Create second client.
Create grab and confine_to windows.
Create window, win.
Select events on win for second client.
Grab pointer.
Move confine_to window off the root window.
Verify that grab is released by provoking an event for second client.
>>ASSERTION A XGrabPointer-23
When the grab_window is not viewable, then a call to
XGrabPointer fails and returns GrabNotViewable.
>>STRATEGY
Create unmapped grab window.
Attempt to grab pointer.
Verify that XGrabPointer fails and returns GrabNotViewable.
>>ASSERTION A XGrabPointer-24
When the confine_to window is not viewable, then a call to
XGrabPointer fails and returns GrabNotViewable.
>>STRATEGY
Create unmapped confine_to window.
Attempt to grab pointer.
Verify that XGrabPointer fails and returns GrabNotViewable.
>>ASSERTION A XGrabPointer-25
When the confine_to window lies completely outside the
boundaries of the root window, then a call to XGrabPointer
fails and returns GrabNotViewable.
>>STRATEGY
Create confine_to window.
Move outside root window.
Attempt to grab pointer.
Verify that XGrabPointer fails and returns GrabNotViewable.
>>ASSERTION A XGrabPointer-26
When the pointer is actively grabbed by some other client,
then a call to XGrabPointer fails and returns AlreadyGrabbed.
>>STRATEGY
Create client2.
Grab pointer with client2.
Attempt to grab pointer with default client.
Verify that XGrabPointer fails and returns AlreadyGrabbed.
>>ASSERTION A XGrabPointer-27
When the pointer is frozen by an active grab of another
client, then a call to XGrabPointer fails and returns
GrabFrozen.
>>STRATEGY
Create client2.
Grab keyboard and freeze pointer with client2.
Attempt to grab pointer with default client.
Verify that XGrabPointer fails and returns GrabFrozen.
>>ASSERTION A XGrabPointer-28
When the specified time is earlier than the
last-pointer-grab time or later than the current X server
time, then a call to XGrabPointer fails and returns
GrabInvalidTime.
>>STRATEGY
Grab pointer with a given time.
Release grab.
Grab pointer with earlier time.
Verify that XGrabPointer fails and returns GrabInvalidTime.
Get current server time.
Grab pointer with later time.
Verify that XGrabPointer fails and returns GrabInvalidTime.
>>ASSERTION A XGrabPointer-29
When a cursor argument does not name a valid Cursor, then a
BadCursor error occurs.
>>STRATEGY
Create cursor with shape XT_FONTCURSOR_GOOD in font cursor.
Free cursor.
Call test function using bad cursor as the cursor argument.
Verify that a BadCursor error occurs.
>>ASSERTION A XGrabPointer-30
When the value of event_mask is not a bitwise combination
of ButtonPressMask, ButtonReleaseMask, EnterWindowMask,
LeaveWindowMask, PointerMotionMask, PointerMotionHintMask,
Button1MotionMask, Button2MotionMask, Button3MotionMask,
Button4MotionMask, Button5MotionMask, ButtonMotionMask or
KeymapStateMask, then a BadValue error occurs.
>>STRATEGY
Obtain a sequence of values which are not in the list specified by VALUE_LIST.
For each value:
  Call test function with this value in the VALUE_ARG argument.
  Verify that a BadValue error occurs.
>>ASSERTION A XGrabPointer-31
When the value of pointer_mode is other than GrabModeSync
or GrabModeAsync, then a BadValue error occurs.
>>STRATEGY
Obtain a sequence of values which are not in the list specified by VALUE_LIST.
For each value:
  Call test function with this value in the VALUE_ARG argument.
  Verify that a BadValue error occurs.
>>ASSERTION A XGrabPointer-32
When the value of keyboard_mode is other than GrabModeSync
or GrabModeAsync, then a BadValue error occurs.
>>STRATEGY
Obtain a sequence of values which are not in the list specified by VALUE_LIST.
For each value:
  Call test function with this value in the VALUE_ARG argument.
  Verify that a BadValue error occurs.
>>ASSERTION A XGrabPointer-33
When the value of owner_events is other than True or False,
then a BadValue error occurs.
>>STRATEGY
Obtain a sequence of values which are not in the list specified by VALUE_LIST.
For each value:
  Call test function with this value in the VALUE_ARG argument.
  Verify that a BadValue error occurs.
>>ASSERTION A XGrabPointer-34
When a window argument does not name a valid Window, then a
BadWindow error occurs.
>>STRATEGY
Create a bad window by creating and destroying a window.
Call test function using bad window as the window argument.
Verify that a BadWindow error occurs.
