>># 
>># 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: cpypln.m,v 1.8 92/06/11 16:21:20 rws Exp $
>># 
>>#      SCCS:  @(#)  function.mc Rel 1.11	    (1/23/92)
>>#      SCCS:  @(#)  plane-mas.mc Rel 1.9	    (6/10/91)
>>#      SCCS:  @(#)  foregroun.mc Rel 1.15	    (10/4/91)
>>#      SCCS:  @(#)  backgroun.mc Rel 1.15	    (1/3/92)
>>#      SCCS:  @(#)  subwindow.mc Rel 1.11	    (6/15/92)
>>#      SCCS:  @(#)  graphics-.mc Rel 1.1	    (7/1/91)
>>#      SCCS:  @(#)  clip-x-or.mc Rel 1.10	    (4/29/92)
>>#      SCCS:  @(#)  clip-y-or.mc Rel 1.1	    (7/1/91)
>>#      SCCS:  @(#)  clip-mask.mc Rel 1.11	    (12/20/91)
>>#      SCCS:  @(#)  EDra.mc Rel 1.5	    (10/25/91)
>>#      SCCS:  @(#)  EGC.mc Rel 1.5	    (10/25/91)
>>#      SCCS:  @(#)  EMat1.mc Rel 1.5	    (10/25/91)
>>#      SCCS:  @(#)  EMat3.mc Rel 1.5	    (10/25/91)
>>#
>>TITLE XCopyPlane CH06
>>ASSERTION A XCopyPlane-1
A call to XCopyPlane uses the foreground pixel in the GC
for each bit in src that is set to 1 and the background
pixel in the GC for each bit in src that is set to 0 and
combines the specified rectangle of src with the specified
rectangle of dest.
>>STRATEGY
Create pair of windows.
Fill one window with pixel having some bits set and some unset.
Call XCopyPlane to copy one plane of an area.
Check that the copied area is set to the foreground when
the plane contains 1 and background when the plane contains 0.
>>ASSERTION - XCopyPlane-2
A call to XCopyPlane uses a single bit plane of the
specified source rectangle src combined with the specified
GC to modify the specified rectangle of dest.
>>ASSERTION A XCopyPlane-3
If the screen supports drawables of more than one depth:+2
The drawables need not have the same depth. -2
>>STRATEGY
If there is a visual with depth other than one.
	Copy between it and a pixmap of depth one.
Else
	Report UNSUPPORTED.
>>ASSERTION A XCopyPlane-4
When regions of the source rectangle are obscured and have
not been retained in backing store or regions outside the
boundaries of the source drawable are specified, then those
regions are not copied.
>>STRATEGY
make src window and draw into it (background of 0)
make dest window with background of 1 and draw into it
copy region that extends off the edge of the source drawable
verify that it is not copied.
>>ASSERTION A XCopyPlane-5
When regions of the source rectangle are obscured and have
not been retained in backing store or regions outside the
boundaries of the source drawable are specified and the
destination is a window with a background other than None,
then all corresponding destination regions that are either
visible or are retained in backing store are tiled with that
background with plane-mask of all ones and GXcopy function.
>>STRATEGY
make src window and draw into it (background of 0)
make dest window with background of 1 and draw into it
copy region that extends off the edge of the source drawable
verify that it is not copied.
>>ASSERTION A XCopyPlane-6
When graphics-exposures is True, then GraphicsExpose
events for all corresponding destination regions are
generated.
>>STRATEGY
Set graphics-exposures to True.
Enable All Events.
DO as above.
Check events received, and x,y,width,height in each.
>>ASSERTION A XCopyPlane-7
When graphics-exposures is True and no GraphicsExpose
events are generated, then a NoExpose event is generated.
>>STRATEGY
As above, but copy visable area
check for NoExpose event
>>ASSERTION A XCopyPlane-8
When a graphics operation is performed and the source pixel
is src and the destination pixel is dst and function is
GXclear, then the destination becomes (dst AND (NOT
plane_mask)).
>>STRATEGY
Find a point (f_pix_x, f_pix_y) that is drawn by the graphics operation.

Set function component of GC to GXclear.
For destination pixel values dst = 0, 1, 2, 3
    For source pixel values of src = 0, 1
	Set all points in drawable to destination pixel value.
	Set foreground component of GC to source pixel value.
	  (or fill source drawable/image with source pixel value in the cases
	   of XCopyArea or XPutImage, while XCopyPlane always has it ~0 to
	   force a foreground fill).
	Do graphics operation.
	Verify that pixel value at f_pix_x, f_pix_y is 0.
>>ASSERTION A XCopyPlane-9
When a graphics operation is performed and the source pixel
is src and the destination pixel is dst and function is
GXand, then the destination becomes ((src AND dst) AND
plane_mask) OR (dst AND (NOT plane_mask)).
>>STRATEGY
Find a point (f_pix_x, f_pix_y) that is drawn by the graphics operation.

Set function component of GC to GXand.
For destination pixel values dst = 0, 1, 2, 3
    For source pixel values of src = 0, 1
	Set all points in drawable to destination pixel value.
	Set foreground component of GC to source pixel value.
	  (or fill source drawable/image with source pixel value in the cases
	   of XCopyArea or XPutImage, while XCopyPlane always has it ~0 to
	   force a foreground fill).
	Do graphics operation.
	Verify that pixel value at f_pix_x, f_pix_y is src&dest.
>>ASSERTION A XCopyPlane-10
When a graphics operation is performed and the source pixel
is src and the destination pixel is dst and function is
GXandReverse, then the destination becomes ((src AND (NOT
dst)) AND plane_mask) OR (dst AND (NOT plane_mask)).
>>STRATEGY
Find a point (f_pix_x, f_pix_y) that is drawn by the graphics operation.

Set function component of GC to GXandReverse.
For destination pixel values dst = 0, 1, 2, 3
    For source pixel values of src = 0, 1
	Set all points in drawable to destination pixel value.
	Set foreground component of GC to source pixel value.
	  (or fill source drawable/image with source pixel value in the cases
	   of XCopyArea or XPutImage, while XCopyPlane always has it ~0 to
	   force a foreground fill).
	Do graphics operation.
	Verify that pixel value at f_pix_x, f_pix_y is src&~dest.
>>ASSERTION A XCopyPlane-11
When a graphics operation is performed and the source pixel
is src and the destination pixel is dst and function is
GXcopy, then the destination becomes (src AND plane_mask)
OR (dst AND (NOT plane_mask)).
>>STRATEGY
Find a point (f_pix_x, f_pix_y) that is drawn by the graphics operation.

Set function component of GC to GXcopy.
For destination pixel values dst = 0, 1, 2, 3
    For source pixel values of src = 0, 1
	Set all points in drawable to destination pixel value.
	Set foreground component of GC to source pixel value.
	  (or fill source drawable/image with source pixel value in the cases
	   of XCopyArea or XPutImage, while XCopyPlane always has it ~0 to
	   force a foreground fill).
	Do graphics operation.
	Verify that pixel value at f_pix_x, f_pix_y is src.
>>ASSERTION A XCopyPlane-12
When a graphics operation is performed and the source pixel
is src and the destination pixel is dst and function is
GXandInverted, then the destination becomes (((NOT src) AND
dst) AND plane_mask) OR (dst AND (NOT plane_mask)).
>>STRATEGY
Find a point (f_pix_x, f_pix_y) that is drawn by the graphics operation.

Set function component of GC to GXandInverted.
For destination pixel values dst = 0, 1, 2, 3
    For source pixel values of src = 0, 1
	Set all points in drawable to destination pixel value.
	Set foreground component of GC to source pixel value.
	  (or fill source drawable/image with source pixel value in the cases
	   of XCopyArea or XPutImage, while XCopyPlane always has it ~0 to
	   force a foreground fill).
	Do graphics operation.
	Verify that pixel value at f_pix_x, f_pix_y is ~src&dest.
>>ASSERTION A XCopyPlane-13
When a graphics operation is performed and the source pixel
is src and the destination pixel is dst and function is
GXnoop, then the destination becomes (dst AND plane_mask)
OR (dst AND (NOT plane_mask)).
>>STRATEGY
Find a point (f_pix_x, f_pix_y) that is drawn by the graphics operation.

Set function component of GC to GXnoop.
For destination pixel values dst = 0, 1, 2, 3
    For source pixel values of src = 0, 1
	Set all points in drawable to destination pixel value.
	Set foreground component of GC to source pixel value.
	  (or fill source drawable/image with source pixel value in the cases
	   of XCopyArea or XPutImage, while XCopyPlane always has it ~0 to
	   force a foreground fill).
	Do graphics operation.
	Verify that pixel value at f_pix_x, f_pix_y is dest.
>>ASSERTION A XCopyPlane-14
When a graphics operation is performed and the source pixel
is src and the destination pixel is dst and function is
GXxor, then the destination becomes ((src XOR dst) AND
plane_mask) OR (dst AND (NOT plane_mask)).
>>STRATEGY
Find a point (f_pix_x, f_pix_y) that is drawn by the graphics operation.

Set function component of GC to GXxor.
For destination pixel values dst = 0, 1, 2, 3
    For source pixel values of src = 0, 1
	Set all points in drawable to destination pixel value.
	Set foreground component of GC to source pixel value.
	  (or fill source drawable/image with source pixel value in the cases
	   of XCopyArea or XPutImage, while XCopyPlane always has it ~0 to
	   force a foreground fill).
	Do graphics operation.
	Verify that pixel value at f_pix_x, f_pix_y is src^dest.
>>ASSERTION A XCopyPlane-15
When a graphics operation is performed and the source pixel
is src and the destination pixel is dst and function is GXor,
then the destination becomes ((src OR dst) AND plane_mask)
OR (dst AND (NOT plane_mask)).
>>STRATEGY
Find a point (f_pix_x, f_pix_y) that is drawn by the graphics operation.

Set function component of GC to GXor.
For destination pixel values dst = 0, 1, 2, 3
    For source pixel values of src = 0, 1
	Set all points in drawable to destination pixel value.
	Set foreground component of GC to source pixel value.
	  (or fill source drawable/image with source pixel value in the cases
	   of XCopyArea or XPutImage, while XCopyPlane always has it ~0 to
	   force a foreground fill).
	Do graphics operation.
	Verify that pixel value at f_pix_x, f_pix_y is src|dest.
>>ASSERTION A XCopyPlane-16
When a graphics operation is performed and the source pixel
is src and the destination pixel is dst and function is
GXnor, then the destination becomes (((NOT src) AND (NOT
dst)) AND plane_mask) OR (dst AND (NOT plane_mask)).
>>STRATEGY
Find a point (f_pix_x, f_pix_y) that is drawn by the graphics operation.

Set function component of GC to GXnor.
For destination pixel values dst = 0, 1, 2, 3
    For source pixel values of src = 0, 1
	Set all points in drawable to destination pixel value.
	Set foreground component of GC to source pixel value.
	  (or fill source drawable/image with source pixel value in the cases
	   of XCopyArea or XPutImage, while XCopyPlane always has it ~0 to
	   force a foreground fill).
	Do graphics operation.
	Verify that pixel value at f_pix_x, f_pix_y is ~src&~dest.
>>ASSERTION A XCopyPlane-17
When a graphics operation is performed and the source pixel
is src and the destination pixel is dst and function is
GXequiv, then the destination becomes (((NOT src) XOR dst)
AND plane_mask) OR (dst AND (NOT plane_mask)).
>>STRATEGY
Find a point (f_pix_x, f_pix_y) that is drawn by the graphics operation.

Set function component of GC to GXequiv.
For destination pixel values dst = 0, 1, 2, 3
    For source pixel values of src = 0, 1
	Set all points in drawable to destination pixel value.
	Set foreground component of GC to source pixel value.
	  (or fill source drawable/image with source pixel value in the cases
	   of XCopyArea or XPutImage, while XCopyPlane always has it ~0 to
	   force a foreground fill).
	Do graphics operation.
	Verify that pixel value at f_pix_x, f_pix_y is ~src^dest.
>>ASSERTION A XCopyPlane-18
When a graphics operation is performed and the source pixel
is src and the destination pixel is dst and function is
GXinvert, then the destination becomes ((NOT dst) AND
plane_mask) OR (dst AND (NOT plane_mask)).
>>STRATEGY
Find a point (f_pix_x, f_pix_y) that is drawn by the graphics operation.

Set function component of GC to GXinvert.
For destination pixel values dst = 0, 1, 2, 3
    For source pixel values of src = 0, 1
	Set all points in drawable to destination pixel value.
	Set foreground component of GC to source pixel value.
	  (or fill source drawable/image with source pixel value in the cases
	   of XCopyArea or XPutImage, while XCopyPlane always has it ~0 to
	   force a foreground fill).
	Do graphics operation.
	Verify that pixel value at f_pix_x, f_pix_y is ~dest.
>>ASSERTION A XCopyPlane-19
When a graphics operation is performed and the source pixel
is src and the destination pixel is dst and function is
GXorReverse, then the destination becomes ((src OR (NOT
dst)) AND plane_mask) OR (dst AND (NOT plane_mask)).
>>STRATEGY
Find a point (f_pix_x, f_pix_y) that is drawn by the graphics operation.

Set function component of GC to GXorReverse.
For destination pixel values dst = 0, 1, 2, 3
    For source pixel values of src = 0, 1
	Set all points in drawable to destination pixel value.
	Set foreground component of GC to source pixel value.
	  (or fill source drawable/image with source pixel value in the cases
	   of XCopyArea or XPutImage, while XCopyPlane always has it ~0 to
	   force a foreground fill).
	Do graphics operation.
	Verify that pixel value at f_pix_x, f_pix_y is src|~dest.
>>ASSERTION A XCopyPlane-20
When a graphics operation is performed and the source pixel
is src and the destination pixel is dst and function is
GXcopyInverted, then the destination becomes ((NOT src) AND
plane_mask) OR (dst AND (NOT plane_mask)).
>>STRATEGY
Find a point (f_pix_x, f_pix_y) that is drawn by the graphics operation.

Set function component of GC to GXcopyInverted.
For destination pixel values dst = 0, 1, 2, 3
    For source pixel values of src = 0, 1
	Set all points in drawable to destination pixel value.
	Set foreground component of GC to source pixel value.
	  (or fill source drawable/image with source pixel value in the cases
	   of XCopyArea or XPutImage, while XCopyPlane always has it ~0 to
	   force a foreground fill).
	Do graphics operation.
	Verify that pixel value at f_pix_x, f_pix_y is ~src.
>>ASSERTION A XCopyPlane-21
When a graphics operation is performed and the source pixel
is src and the destination pixel is dst and function is
GXorInverted, then the destination becomes (((NOT src) OR
dst) AND plane_mask) OR (dst AND (NOT plane_mask)).
>>STRATEGY
Find a point (f_pix_x, f_pix_y) that is drawn by the graphics operation.

Set function component of GC to GXorInverted.
For destination pixel values dst = 0, 1, 2, 3
    For source pixel values of src = 0, 1
	Set all points in drawable to destination pixel value.
	Set foreground component of GC to source pixel value.
	  (or fill source drawable/image with source pixel value in the cases
	   of XCopyArea or XPutImage, while XCopyPlane always has it ~0 to
	   force a foreground fill).
	Do graphics operation.
	Verify that pixel value at f_pix_x, f_pix_y is ~src|dest.
>>ASSERTION A XCopyPlane-22
When a graphics operation is performed and the source pixel
is src and the destination pixel is dst and function is
GXnand, then the destination becomes (((NOT src) OR (NOT
dst)) AND plane_mask) OR (dst AND (NOT plane_mask)).
>>STRATEGY
Find a point (f_pix_x, f_pix_y) that is drawn by the graphics operation.

Set function component of GC to GXnand.
For destination pixel values dst = 0, 1, 2, 3
    For source pixel values of src = 0, 1
	Set all points in drawable to destination pixel value.
	Set foreground component of GC to source pixel value.
	  (or fill source drawable/image with source pixel value in the cases
	   of XCopyArea or XPutImage, while XCopyPlane always has it ~0 to
	   force a foreground fill).
	Do graphics operation.
	Verify that pixel value at f_pix_x, f_pix_y is ~src|~dest.
>>ASSERTION A XCopyPlane-23
When a graphics operation is performed and the source pixel
is src and the destination pixel is dst and function is
GXset, then the destination becomes ( plane_mask) OR (dst
AND (NOT plane_mask)).
>>STRATEGY
Find a point (f_pix_x, f_pix_y) that is drawn by the graphics operation.

Set function component of GC to GXset.
For destination pixel values dst = 0, 1, 2, 3
    For source pixel values of src = 0, 1
	Set all points in drawable to destination pixel value.
	Set foreground component of GC to source pixel value.
	  (or fill source drawable/image with source pixel value in the cases
	   of XCopyArea or XPutImage, while XCopyPlane always has it ~0 to
	   force a foreground fill).
	Do graphics operation.
	Verify that pixel value at f_pix_x, f_pix_y is ~0.
>>ASSERTION A XCopyPlane-24
The value for plane_mask is truncated to the depth of the
GC.
>>STRATEGY
Set foreground to pattern of 1's and 0's
Set plane-mask to values larger than the depth.
Verify that result is what would be expected if the extra bits
 were masked off.
>>ASSERTION A XCopyPlane-25
The plane_mask specifies which planes of the destination
are to be modified, one bit per plane, with bits being
assigned to planes from the least significant bit of the
word to the most significant bit.
>>STRATEGY
Set foreground to pattern of 1's and 0's
Select a variety of plane masks.
Verify that the expected pixels are drawn.
>>ASSERTION A XCopyPlane-26
The foregound component of the gc is used to determine the
foreground pixel value.
>>STRATEGY
Set foreground to various values.
Pixmap verify the results.
>>ASSERTION A XCopyPlane-27
The value for foreground is truncated to the depth of the
GC.
>>STRATEGY
Set foreground to value with all bits set.
Find a non background pixel.
Check that this is truncated to the depth.
>>ASSERTION A XCopyPlane-28
The background component of the gc is used to determine the
background pixel value.
>>STRATEGY
Set GC component background to various values.
Pixmap verify the results.
>>ASSERTION A XCopyPlane-29
The value for background is truncated to the depth of the
GC.
>>STRATEGY
Set GC component background to value with all bits set.
If not (XDrawImageString  || XCopyPlane || XPutImage || XCopyArea)
  Set GC component stipple to all zeros
  Set GC component FillStyle to FillOpaqueStippled.
else if (XCopyPlane || XPutImage)
  Fill source drawable/image-bitmap with 0's to ensure we draw with background
else if XCopyArea
  Fill source drawable/image-bitmap with all 1's
Draw item.
Find a pixel with a value other than W_BG.
Check that this is truncated to the depth.
>>ASSERTION A XCopyPlane-30
When subwindow_mode is ClipByChildren, then the
destination window and source (if it is a window) are
clipped by all viewable InputOutput children.
>>STRATEGY
Set subwindow-mode to be ClipByChildren
Cover window with many strip sub-windows.
Do drawing operation
Verify that all subwindows are clear.
>>ASSERTION A XCopyPlane-31
When subwindow_mode is IncludeInferiors, then neither the
destination window nor source (if it is a window) is clipped
by inferiors.
>>STRATEGY
Place subwindows over parts of the main window
Create subwindows over these windows as well.
Do graphics operation.
Verify that the operation was not affected.
>>ASSERTION A XCopyPlane-32
When subwindow_mode is IncludeInferiors on a window of one
depth with mapped inferiors of differing depth, then no
errors occur.
>>STRATEGY
If only one depth window supported
  Result is UNSUPPORTED

Find two visuals with different depths.
Use one of these visuals to create a window.
Use the other to create a subwindow.
Verify that no errors occur.
For information purposes only see if graphics operation is rendered properly.
>>ASSERTION A XCopyPlane-33
The clip origin coordinates clip-x-origin and clip-y-origin
are interpreted relative to the origin of the destination
drawable specified in the graphics operation.
>>STRATEGY
Create Pixmap and set clip-mask with it.
Vary clip origin
Verify nothing is drawn outside the clip_mask based on the origin.
Pixmap verify results inside the cliparea.
>>ASSERTION A XCopyPlane-34
When the clip_mask is set to None, then the pixels are
always drawn regardless of the clip origin.
>>STRATEGY
Set clip mask to None
Verify that things are still drawn.
>>ASSERTION A XCopyPlane-35
When pixels are outside the area covered by the clip_mask,
then they are not drawn.
>>STRATEGY
Create a pixmap depth 1.
Fill it with all ones.
Set this pixmap as the clip_mask.
Verify that nothing is drawn outside the clip-mask area.
Use a pixmap size of 5x5 to ensure that all tests have some part of the
drawing outside the clip-mask.
>>ASSERTION A XCopyPlane-36
When pixels have a clip_mask bit set to 1, and they would
be drawn, then they are drawn.
>>STRATEGY
Do graphics operation.
Save the image on the drawable.
Clear drawable.
Create a pixmap depth 1 that is the same size as the window.
Set all bits in pixmap to 1.
Set GC component clip-mask to pixmap using XSetClipMask.
Do graphics operation.
Verify that the images drawn were the same.

Set pixmap to a pattern.
Do graphics operation.
Pixmap verify the result.
>>ASSERTION A XCopyPlane-37
When pixels have a clip_mask bit set to 0, then they are
not drawn.
>>STRATEGY
Create a pixmap depth 1 that is the same size as the window.
Set all bits in pixmap to 0.
Set GC component clip_mask to pixmap using XSetClipMask.
Do graphics operation.
Verify that nothing is drawn.
>>ASSERTION A XCopyPlane-38
When a drawable argument does not name a valid Drawable,
then a BadDrawable error occurs.
>>STRATEGY
Create a bad drawable by creating and destroying a window.
Call test function using bad drawable as the drawable argument.
Verify that a BadDrawable error occurs.
>>ASSERTION A XCopyPlane-39
When the GC argument does not name a defined GC, then a
BadGC error occurs.
>>STRATEGY
Create a GC.
Set GC id to -1 using XTestSetGContextOfGC.
Call test function using bad GC as the GC argument.
Verify that a BadGC error occurs.
>>ASSERTION A XCopyPlane-40
When a drawable argument is an InputOnly window then a
BadMatch error occurs.
>>STRATEGY
Create an InputOnly window.
Call test function using InputOnly window as the drawable argument.
Verify that a BadMatch error occurs.
>>ASSERTION A XCopyPlane-41
When the graphics context and the drawable were not created
for the same root, then a BadMatch error occurs.
>>STRATEGY
If multiple screens are supported
  Create pixmap of depth 1.
  Create gc on alternate screen.
  Call test function with this pixmap and gc.
  Verify that a BadMatch error occurs.
else
  report UNSUPPORTED
>>ASSERTION A XCopyPlane-42
When the bit set in plane does not refer to a valid plane
for the screen, then a BadValue error occurs.
>>STRATEGY
For each drawable type
  Ignore those that have no invalid planes.
  Call XCopyPlane with plane set to first invalid number.
  Verify that a BadValue error occurred.
>>ASSERTION A XCopyPlane-43
When plane does not have exactly one bit set to 1, then a
BadValue error occurs.
>>STRATEGY
For each drawable type
  Make window pair.
  Call XCopyPlane with plane set to 0.
  Verify that BadValue error occurs.
  If depth is greater than 1
	Call XCopyPlane with plane set to 3.
	Verify that BadValue error occurs.
