
/* $XConsortium: dcrefmod.pi,v 5.3 94/04/17 20:47:49 hersh Exp $ */

/*****************************************************************

Copyright (c) 1989, 1990, 1991,1990  X Consortium

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL THE
X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

Except as contained in this notice, the name of the X Consortium shall not be
used in advertising or otherwise to promote the sale, use or other dealings
in this Software without prior written authorization from the X Consortium.

Copyright (c) 1989, 1990, 1991,1990 by Sun Microsystems, Inc.

                        All Rights Reserved

Permission to use, copy, modify, and distribute this software and its 
documentation for any purpose and without fee is hereby granted, 
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 Sun Microsystems,
and the X Consortium, not be used in advertising or publicity 
pertaining to distribution of the software without specific, written 
prior permission.  

SUN MICROSYSTEMS DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, 
INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT 
SHALL SUN MICROSYSTEMS BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL 
DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
SOFTWARE.

******************************************************************/


## dcrefmod.pi -  
## Test requirements:
##   test display update with reference modification 

source macro.pi
source dcmacro.pi
source xpmacro.pi

tbegintest("dcrefmod","display update with reference modification");

# INITIALIZE: data for a line
line = IA_Ppoint(2, 0.25,0.25, 0.75,0.75);
line3 = IA_Ppoint3(2, 0.25,0.25,0.0, 0.75,0.75,0.0);
pl = I_Ppoint_list(2,line);

# SETUP: open phigs and a workstation, create empty structure 2,
#   create structure1 which execute structure2, create structure 3
#   which contains a polyline element, post structure 1

i_open_phigs(NULL,0);
i_open_x_ws(1,&xdisplay,&xwindow,0,0,200,200);
pempty_struct(2);
popen_struct(1);
pexec_struct(2);
pclose_struct()
popen_struct(3);
ppolyline(&pl);
pclose_struct();
ppost_struct(1,1,1.0);

#OPERATION: set display update modes to WAIT/UQUM, 
#  change structure ref of structure 2 to 3
pset_disp_upd_st(1,PDEFER_WAIT,PMODE_UQUM);
pchange_struct_refs(2,3);

#VERIFICATION: 
dynmod = i_get_struct_dyn_mod(1,"reference modification");
if (dynmod == PDYN_IRG) # if reference mod's dynamic modification is IRG

	# verify that visual rep state is PVISUAL_ST_DEFER
	im_confirm_visual_rep(1,PVISUAL_ST_DEFER,
  		"failed: visual rep=%d,expected PVISUAL_ST_DEFER before updatews\n");
	#  Verify the picture by sampling pixels at the expected locations.
	status = i_check_line3(xdisplay,xwindow,1,0,line3,5,1);
	im_ifneq(status,0,"failed: line should not exist before updatews\n",NULL);
endif

if (dynmod == PDYN_CBS) # if reference mod's dynamic modification is CBS
	# verify that visual rep state is PVISUAL_ST_SIMULATED
	im_confirm_visual_rep(1,PVISUAL_ST_SIMULATED,
  		"failed: visual rep=%d,expected PVISUAL_ST_SIMULATED before updatews\n");
endif

if (dynmod == PDYN_IMM) # if reference mod's dynamic modification is IMM
	# verify that visual rep state is PVISUAL_ST_CORRECT
	im_confirm_visual_rep(1,PVISUAL_ST_CORRECT,
  		"failed: visual rep=%d,expected PVISUAL_ST_CORRECT before updatews\n");
	#  Verify the picture by sampling pixels at the expected locations.
	im_confirm_line3(xdisplay,xwindow,1,0,line3,5,1,
		"failed: line is missing before updatews\n",NULL);
endif
tvprintf(2,"before updatews\n");
i_pause();

#OPERATION: update workstation with PERFORM
pupd_ws(1,PFLAG_PERFORM);

#VERIFICATION: 
#verify visual rep state is PVISUAL_ST_CORRECT
im_confirm_visual_rep(1,PVISUAL_ST_CORRECT,
  "failed: visual rep=%d,expected PVISUAL_ST_CORRECT after updatews\n");

#  Verify the picture by sampling pixels at the expected locations.
im_confirm_line3(xdisplay,xwindow,1,0,line3,5,1,
	"failed: line is missing after updatews\n",NULL);
tvprintf(2,"after updatews\n");
i_pause();

tendtest();
