>># 
>># 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: stinptfcs.m,v 1.8 92/06/11 17:16:29 rws Exp $
>># 
>>#      SCCS:  @(#)  EVal.mc Rel 1.5	    (10/10/91)
>>#      SCCS:  @(#)  EWin.mc Rel 1.4	    (7/19/91)
>>#
>>TITLE XSetInputFocus CH07
>>ASSERTION A XSetInputFocus-1
A call to XSetInputFocus changes the input focus window to
that specified in the focus argument.
>>STRATEGY
Create window.
Set input focus with that window.
Verify that input focus has been set with XGetInputFocus.
>>ASSERTION B XSetInputFocus-2
When the focus argument is None, then all keyboard events
are discarded until a new focus window is set.
>>STRATEGY
If extension available:
  Create a window and select KeyPress and KeyRelease events.
  Call XSetInputFocus with focus = None.
  Warp pointer into window and simulate keypress using extension.
  Ensure no event received.
  Call XSetInputFocus with focus = window.
  Simulate key release.
  Ensure event now received.
else
  report untested.
>>ASSERTION B XSetInputFocus-3
When the focus argument is a window, then keyboard events
that would normally be reported to the focus window or one
of its inferiors are reported as usual and all other
keyboard events are reported relative to the focus window.
>>STRATEGY
If extension available:
  Create a window tree and select KeyPress and KeyRelease events on all.
  Call XSetInputFocus with focus = window in tree with child (child2, with child
    grandchild).
  Warp pointer into all windows, and root, and simulate keypress/release using
    extension in each.
  Ensure event.xany.window is focus (child2) in all cases except grandchild,
    when it should be grandchild.
  Release any remaining keys.
else
  report untested.
>>ASSERTION B XSetInputFocus-4
When the focus argument is PointerRoot, then the focus
window is taken to be the root window of the screen the
pointer is on at each keyboard event.
>>STRATEGY
If extension available:
  Create a toplevel window and select KeyPress and KeyRelease events.
  Select KeyPress and KeyRelease events in root window.
  Call XSetInputFocus with focus = PointerRoot.
  Warp pointer into window and simulate keypress using extension.
  Ensure event received and that event.xany.window = window.
  Warp pointer into root window.
  Simulate key release.
  Ensure event received and that event.xany.window = root (focus).
  If more than one screen:
    Select KeyPress and KeyRelease events in root window of alternate screen.
    Warp pointer into root window of alternate screen.
    Simulate KeyPress/KeyRelease.
    Ensure event received and that event.xany.window = altroot (focus) and
      event.xkey.same_screen is True and event.xkey.root is altroot.
  else
    Issue incomplete testing message and report untested.
else
  report untested.
>>ASSERTION A XSetInputFocus-5
When the focus window later becomes not viewable and
revert_to is RevertToParent, then the focus reverts to the
closest viewable ancestor of the focus window, the revert_to
value is changed to RevertToNone and FocusIn and FocusOut
events are generated.
>>STRATEGY
Create base window
Create child of this window and set focus argument to it.
Set revert_to argument to RevertToParent.
Call XSetInputFocus.
Enable events on windows.
Unmap focus window.
Verify that focus is the base window.
Verify that revert_to is RevertToNone.
Verify that Focus events are generated.
>>ASSERTION A XSetInputFocus-6
When the focus window later becomes not viewable and
revert_to is RevertToPointerRoot, then the focus window
reverts to PointerRoot and FocusIn and FocusOut events are
generated.
>>STRATEGY
Create base window
Create child of this window and set focus argument to it.
Set revert_to argument to RevertToPointerRoot.
Warp pointer to 0,0 (guaranteed none of our windows are here)
Call XSetInputFocus.
Unmap focus window.
Verify that focus is PointerRoot.
Verify that revert_to is RevertToPointerRoot.
Verify that Focus events are generated.
>>ASSERTION A XSetInputFocus-7
When the focus window later becomes not viewable and
revert_to is RevertToNone, then the focus window reverts to
None and FocusIn and FocusOut events are generated.
>>STRATEGY
Create base window
Create child of this window and set focus argument to it.
Set revert_to argument to RevertToNone.
Call XSetInputFocus.
Unmap focus window.
Verify that focus is None
Verify that revert_to is RevertToNone.
Verify that Focus events are generated.
>>ASSERTION A XSetInputFocus-8
When the specified time is earlier than the current
last-focus-change time or is later than the current X server
time, then a call to XSetInputFocus has no effect.
>>STRATEGY
Create window.
Get current X server time with gettime().
Set focus to None using this time.

Attempt to set the focus window with a time less than the previous time.
Verify that focus is still None.

Get current time again.
Add amount to get time in the future.
Attempt to set the focus window with this time.
Verify that focus is still None.
>>ASSERTION A XSetInputFocus-9
A successful call to XSetInputFocus sets the
last-focus-change time to the specified time with
CurrentTime being replaced by the current X server time.
>>STRATEGY
Create toplevel window.
Call XSetInputFocus with time = gettime(display) and focus = window.
Call XGetInputFocus and verify that focus_return is window.
Attempt XSetInputFocus at time just before time with focus = root.
Check focus is still window.
Attempt XSetInputFocus at time equal to time and focus = root.
Check focus is now root.

Get time before with gettime(display).
Call XSetInputFocus with time = CurrentTime and focus = window.
Call XGetInputFocus and verify that focus_return is window.
Attempt XSetInputFocus at time before with focus = root.
Check focus is still window.
Attempt XSetInputFocus at CurrentTime and focus = root.
Check focus is now root.
>>ASSERTION A XSetInputFocus-10
When the focus changes, then FocusIn and FocusOut events
are generated.
>>STRATEGY
Create base window.
Create two subwindows on base.
Set focus to first subwindow.
Enable events on all three windows.
Call XSetInputFocus to change focus to second subwindow.
Verify that focus events are generated.
>>ASSERTION A XSetInputFocus-11
When the specified focus window is not viewable, then a
BadMatch error occurs.
>>STRATEGY
Create unmapped window.
Attempt to set focus to it.
Verify that a BadMatch error occurs.
>>ASSERTION A XSetInputFocus-12
When the value of revert_to is other than RevertToParent,
RevertToPointerRoot or RevertToNone, 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 XSetInputFocus-13
When a window argument does not name a valid Window,
PointerRoot or None, 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.
