>># 
>># 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: grbkybrd.m,v 1.7 92/06/11 17:13:17 rws Exp $
>># 
>>#      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 XGrabKeyboard CH07
>>ASSERTION A XGrabKeyboard-1
A successful call to XGrabKeyboard actively grabs control
of the keyboard and returns GrabSuccess.
>>STRATEGY
Touch test for return value.
>>ASSERTION A XGrabKeyboard-2
When the keyboard is grabbed, then FocusIn and FocusOut
events are generated as though the focus had changed from
the previous focus window to grab_window.
>>STRATEGY
Create window.
Set Focus to that window.
Enable events on grab and focus window.
Grab keyboard.
Verify grab-mode FocusOut from window.
Verify grab-mode FocusIn to grab window.
>>ASSERTION B XGrabKeyboard-3
When a successful call to XGrabKeyboard is made by a
client, then subsequent keyboard events are reported only to
that client.
>>STRATEGY
If extensions are available:
  Create a second client.
  Select key events for default client.
  Select key events for second client.
  Call XGrabKeyboard with default client.

  Press key in window.
  Verify that key event is received only by default client.
>>ASSERTION A XGrabKeyboard-4
A call to XGrabKeyboard overrides any active keyboard grab
by this client.
>>STRATEGY
Call XGrabKeyboard with pointer_mode GrabModeAsync.
Check that pointer is not frozen.
Call XGrabKeyboard with pointer_mode GrabModeSync.
Verify that pointer is frozen and so the last grab was overriden.
>>ASSERTION B XGrabKeyboard-5
When owner_events is False, then all generated keyboard
events are reported with respect to the grab_window.
>>STRATEGY
If extensions available:
  Create grab_window.
  Create window2.
  Select key events on both windows.
  Call XGrabKeyboard with owner_events False.
  Move pointer to window2 (focus is the root).
  Press key.
  Verify that event is reported on grab_window.
>>ASSERTION B XGrabKeyboard-6
When owner_events is True and a keyboard event is generated
that would normally be reported to the client, then it is
reported on the window it would normally be reported on.
>>STRATEGY
If extensions available:
  Create grab_window.
  Create window2.
  Select key events on both windows.
  Call XGrabKeyboard with owner_events True.
  Move pointer to window2 (focus is the root).
  Press key.
  Verify that event is reported on window2.
>>ASSERTION B XGrabKeyboard-7
When owner_events is True, and a keyboard event is
generated that would not normally be reported to the client,
then it is reported on the grab_window.
>>STRATEGY
If extensions available:
  Create grab_window.
  Create window2.
  Call XGrabKeyboard with owner_events True.
  Move pointer to window2 (focus is the root).
  Press key.
  Verify that event is reported on grab_window.
>>ASSERTION B XGrabKeyboard-8
When the keyboard is grabbed, then KeyPress and KeyRelease
events are always reported, independent of any event
selection made by the client.
>>STRATEGY
If extensions available:
  Grab keyboard by calling XGrabKeyboard.
  Press key.
  Verify that a KeyPress event is reported.
  Release key.
  Verify that a KeyRelease event is reported.
>>ASSERTION B XGrabKeyboard-9
When keyboard_mode is GrabModeAsync, then keyboard event
processing continues normally.
>>STRATEGY
If extensions available:
  Call XGrabKeyboard with keyboard_mode GrabModeAsync.
  Verify that keyboard is not frozen.
>>ASSERTION B XGrabKeyboard-10
When keyboard_mode is GrabModeAsync, and the keyboard is
currently frozen by this client, then processing of keyboard
events is resumed.
>>STRATEGY
If extensions available:
  Freeze keyboard using XGrabPointer.
  Call XGrabKeyboard with keyboard_mode GrabModeAsync.
  Verify that keyboard is not frozen.
>>ASSERTION B XGrabKeyboard-11
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 issues a releasing XAllowEvents call or
until the keyboard grab is released.
>>STRATEGY
If extensions available:
  Call XGrabKeyboard with keyboard_mode GrabModeSync.
  Verify that keyboard is frozen.
  Release grab.
  Verify that keyboard is not frozen.
>>ASSERTION B XGrabKeyboard-12
When the keyboard is frozen, then the actual keyboard
changes are not lost while the keyboard is frozen and are
processed after the grab is released or the client calls
XAllowEvents.
>>STRATEGY
If extensions available:
  Enable key events on grab_window.
  Call XGrabKeyboard with keyboard_mode GrabModeSync.
  Press and release key.
  Check no events arrived yet.
  Release grab.
  Verify that KeyPress and KeyRelease events are now received.
>>ASSERTION A XGrabKeyboard-13
When pointer_mode is GrabModeAsync, then pointer event
processing is unaffected by activation of the grab.
>>STRATEGY
Grab keyboard with pointer_mode GrabModeAsync.
Verify that pointer events are still received.
>>ASSERTION A XGrabKeyboard-14
When pointer_mode is GrabModeSync, then state of the
pointer as seen by client applications appears to freeze and
no further pointer events are generated until the grabbing
client issues a releasing XAllowEvents call or until the
keyboard grab is released.
>>STRATEGY
Call XGrabKeyboard with pointer_mode GrabModeSync.
Verify that pointer events are frozen.
>>ASSERTION A XGrabKeyboard-15
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
Call XGrabKeyboard with pointer_mode GrabModeSync.
Warp pointer to create some pointer events.
Check that they are not received yet.
Release grab.
Verify that events are now received.
>>ASSERTION A XGrabKeyboard-16
When the event window for an active grab becomes not
viewable, then the grab is released automatically.
>>STRATEGY
Call XGrabKeyboard with pointer_mode GrabModeSync to freeze pointer.
Unmap the grab_window.
Verify that pointer is unfrozen, and that therefore the grab has
been released.
>>ASSERTION A XGrabKeyboard-17
A successful call to XGrabKeyboard sets the
last-keyboard-grab time to the specified time, with
CurrentTime being replaced by the current X server time.
>>STRATEGY
Get a server time.
Use this time in the XGrabKeyboard call with a pointer_mode of GrabModeSync.
Check that pointer is frozen.
Call XUngrabKeyboard with time-1.
Verify that pointer is still frozen.
Call XUngrabKeyboard with time.
Verify that pointer is released.
>>ASSERTION A XGrabKeyboard-18
When the keyboard is actively grabbed by some other client,
then a call to XGrabKeyboard fails and returns
AlreadyGrabbed.
>>STRATEGY
Create client2.
Call XGrabKeyboard with default client.
Attempt to call XGrabKeyboard with client2.
Verify that XGrabKeyboard fails with AlreadyGrabbed.
>>ASSERTION A XGrabKeyboard-19
When the grab_window is not viewable, then a call to
XGrabKeyboard fails and returns GrabNotViewable.
>>STRATEGY
Unmap grab_window.
Call XGrabKeyboard.
Verify that XGrabKeyboard fails with GrabNotViewable.
>>ASSERTION A XGrabKeyboard-20
When the keyboard is frozen by an active grab of another
client, then a call to XGrabKeyboard fails and returns
GrabFrozen.
>>STRATEGY
Grab and freeze keyboard with default client using XGrabPointer.
Create client2.
Call XGrabKeyboard with client2.
Verify that XGrabKeyboard returns GrabFrozen.
>>ASSERTION A XGrabKeyboard-21
When the specified time is earlier than the
last-keyboard-grab time or later than the current X server
time, then a call to XGrabKeyboard fails and returns
GrabInvalidTime.
>>STRATEGY
Get current time.
Grab keyboard using this time to set last-keyboard-grab time.
Attempt to grab keyboard with an earlier time.
Verify that XGrabKeyboard returns GrabInvalidTime.

Attempt to grab keyboard with a future time.
Verify that XGrabKeyboard returns GrabInvalidTime.
>>ASSERTION A XGrabKeyboard-22
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 XGrabKeyboard-23
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 XGrabKeyboard-24
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 XGrabKeyboard-25
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.
