diff options
author | Dan Nicholson <dbn.lists@gmail.com> | 2009-09-16 12:20:41 -0700 |
---|---|---|
committer | Dan Nicholson <dbn.lists@gmail.com> | 2009-09-16 12:20:41 -0700 |
commit | 704eb8d4cbfa2f8c47882a8ea6c7732cf5fa20d1 (patch) | |
tree | 1f48212ecf5556fbff17172c6904e525481e8653 /xts5/Xt5 | |
parent | 5d01bd434ff7186701c931883b110c179d4fa8b8 (diff) |
xts5: Move tests out of tset directory
The tset directory was mostly useless and causes extra baggage if the
scenario files are going to be used on an installed package. The test
directories are now flattened into xts5.
Diffstat (limited to 'xts5/Xt5')
-rw-r--r-- | xts5/Xt5/XtCreateManagedWidget/XtCreateManagedWidget.m | 190 | ||||
-rw-r--r-- | xts5/Xt5/XtIsManaged/XtIsManaged.m | 124 | ||||
-rw-r--r-- | xts5/Xt5/XtManageChild/XtManageChild.m | 177 | ||||
-rw-r--r-- | xts5/Xt5/XtManageChildren/XtManageChildren.m | 228 | ||||
-rw-r--r-- | xts5/Xt5/XtMapWidget/XtMapWidget.m | 125 | ||||
-rw-r--r-- | xts5/Xt5/XtSetMappedWhenManaged/XtSetMappedWhenManaged.m | 193 | ||||
-rw-r--r-- | xts5/Xt5/XtUnmanageChild/XtUnmanageChild.m | 229 | ||||
-rw-r--r-- | xts5/Xt5/XtUnmanageChildren/XtUnmanageChildren.m | 288 | ||||
-rw-r--r-- | xts5/Xt5/XtUnmapWidget/XtUnmapWidget.m | 121 | ||||
-rw-r--r-- | xts5/Xt5/XtVaCreateManagedWidget/XtVaCreateManagedWidget.m | 992 |
10 files changed, 2667 insertions, 0 deletions
diff --git a/xts5/Xt5/XtCreateManagedWidget/XtCreateManagedWidget.m b/xts5/Xt5/XtCreateManagedWidget/XtCreateManagedWidget.m new file mode 100644 index 00000000..da60128e --- /dev/null +++ b/xts5/Xt5/XtCreateManagedWidget/XtCreateManagedWidget.m @@ -0,0 +1,190 @@ +Copyright (c) 2005 X.Org Foundation LLC + +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 +AUTHORS OR COPYRIGHT HOLDERS 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. +$Header: /cvs/xtest/xtest/xts5/tset/Xt5/XtCreateManagedWidget/XtCreateManagedWidget.m,v 1.1 2005-02-12 14:38:14 anderson Exp $ + +Copyright (c) Applied Testing and Technology, Inc. 1993, 1994, 1995 +Copyright (c) 88open Consortium, Ltd. 1990, 1991, 1992, 1993 +All Rights Reserved. + +>># +>># Project: VSW5 +>># +>># File: tset/Xt5/XtCreateManagedWidget/XtCreateManagedWidget.m +>># +>># Description: +>># Tests for XtCreateManagedWidget() +>># +>># Modifications: +>># $Log: tcramnwid.m,v $ +>># Revision 1.1 2005-02-12 14:38:14 anderson +>># Initial revision +>># +>># Revision 8.0 1998/12/23 23:36:34 mar +>># Branch point for Release 5.0.2 +>># +>># Revision 7.0 1998/10/30 22:59:27 mar +>># Branch point for Release 5.0.2b1 +>># +>># Revision 6.0 1998/03/02 05:27:44 tbr +>># Branch point for Release 5.0.1 +>># +>># Revision 5.0 1998/01/26 03:24:18 tbr +>># Branch point for Release 5.0.1b1 +>># +>># Revision 4.0 1995/12/15 09:16:33 tbr +>># Branch point for Release 5.0.0 +>># +>># Revision 3.1 1995/12/15 01:20:32 andy +>># Prepare for GA Release +>># +>>EXTERN +#include <X11/IntrinsicP.h> +#include <X11/ConstrainP.h> +#include <X11/CoreP.h> +#include <X11/Xaw/Label.h> + +XtAppContext app_ctext; +Widget topLevel, panedw, boxw1, boxw2; +Widget labelw, rowcolw, click_quit; +>>TITLE XtCreateManagedWidget Xt5 +Widget +XtCreateManagedWidget(name, widget_class, parent, args, num_args) +>>ASSERTION Good A +A call to +Widget XtCreateManagedWidget(name, widget_class, parent, +args, num_args) +shall create an instance of a widget belonging to the class +widget_class, set the widget to be managed by its parent, and return +a pointer to the newly created widget instance structure. +>>CODE +Boolean status; +Widget widget_good , labelw_good; +Widget rowcolw_good; + + avs_xt_hier("Tcramnwid1", "XtCreateManagedWidget"); + tet_infoline("PREP: Create rowcolw_good widget in box1w widget"); + rowcolw_good = (Widget) CreateRowColWidget(boxw1); + tet_infoline("TEST: Create label widget Hello"); + labelw_good = XtCreateManagedWidget( + "Hello", + labelWidgetClass, + rowcolw_good, + (ArgList)NULL, + (Cardinal)NULL); + tet_infoline("TEST: Create windows for widgets and map them"); + XtRealizeWidget(topLevel); + tet_infoline("TEST: labelw_good widget is managed"); + status = XtIsManaged(labelw_good); + check_dec(True, status, "XtIsManaged return value"); + tet_infoline("TEST: labelw_good widget is child of rowcolumn widget"); + widget_good = (Widget)XtParent(labelw_good); + if (widget_good == NULL) { + sprintf(ebuf, "ERROR: Expected parent widget instance returned NULL"); + tet_infoline(ebuf); + tet_result(TET_FAIL); + } + check_str("rowcolw", XtName(widget_good), "Widget name"); + tet_result(TET_PASS); +>>ASSERTION Good B 0 +A successful call to +Widget XtCreateManagedWidget(name, widget_class, parent, args, num_args) +shall initialize the resource fields of the widget instance using the +CoreClassPart resource list specified for widget_class and all superclasses, +overridden by the resource values specified in args. +>>ASSERTION Good B 0 +When parent is a subclass of constraintWidgetClass a successful call to Widget +XtCreateManagedWidget(name, widget_class, parent, args, num_args) +shall initialize the resource fields of the constraint record by +using the constraint resource list specified for the parent's class +and all superclasses up to constraintWidgetClass, overridden by the resource +values specified in args. +>>ASSERTION Good B 0 +When parent is a subclass of compositeWidgetClass a successful call to +Widget XtCreateManagedWidget(name, widget_class, parent, args, num_args) +shall call the insert_child procedure of the parent. +>>ASSERTION Good B 0 +A call to Widget XtCreateManagedWidget(name, widget_class, parent, args, +num_args) when widget_class is not a member of coreWidgetClass, the class +of parent is a subclass of compositeWidgetClass, and there is no extension +record in the composite class part extension field of parent with the +record_type equal to NULLQUARK shall issue a fatal error. +>>ASSERTION Good B 0 +A call to +Widget XtCreateManagedWidget(name, widget_class, parent, args, +num_args) +when widget_class is not a member of coreWidgetClass, the class of +parent is a subclass of compositeWidgetClass, and the accepts_object +field in parent's composite class part extension record is False shall issue +a fatal error. +>>ASSERTION Good B 0 +A successful call to +Widget XtCreateManagedWidget(name, widget_class, parent, args, +num_args) +shall invoke the class_initialize procedure for the class +widget_class and all superclasses for which this procedure has not been +invoked prior to this call in a superclass-to-subclass order. +>>ASSERTION Good B 0 +A successful call to +Widget XtCreateManagedWidget(name, widget_class, parent, args, +num_args) +when parent belongs to the class constraintWidgetClass or a +subclass thereof shall allocate memory for the constraints of parent +and store the address of this memory in the constraints field of the +widget instance structure. +>>ASSERTION Good B 0 +A successful call to +Widget XtCreateManagedWidget(name, widget_class, parent, args, +num_args) +shall initialize the Core non-resource data fields of the widget instance +structure. +>>ASSERTION Good B 0 +A successful call to +Widget XtCreateManagedWidget(name, widget_class, parent, args, +num_args) +shall call the initialize procedure of Object and all +the initialize procedures down to initialize procedure of the widget. +>>ASSERTION Good B 0 +A successful call to +Widget XtCreateManagedWidget(name, widget_class, parent, args, +num_args) +when parent belongs to the class contraintWidgetClass +or a subclass thereof shall call all the ConstraintClassPart initialize +procedures starting at constraintWidgetClass down to ConstraintClassPart +initialize procedure of the parent. +>>ASSERTION Good B 0 +A call to +Widget XtCreateManagedWidget(name, widget_class, parent, args, num_args) +when the newly created widget has the map_when_managed field set to True and +parent is realized shall call the change_managed procedure of the parent, +realize the widget, and map the widget window. +>>ASSERTION Good B 0 +On a successful call to +Widget XtCreateManagedWidget(name, widget_class, parent, args, num_args) +when the newly created widget has the map_when_managed field set to a value +other than True shall not have its window mapped. +>>ASSERTION Good B 0 +A call to +Widget XtCreateManagedWidget(name, widget_class, parent, args, num_args) +when parent does not belong to a subclass of compositeWidgetClass shall issue +an invalidParent error. +>>ASSERTION Good B 0 +A call to +Widget XtCreateManagedWidget(name, widget_class, parent, args, num_args) +when parent is in the process of being destroyed shall return immediately. diff --git a/xts5/Xt5/XtIsManaged/XtIsManaged.m b/xts5/Xt5/XtIsManaged/XtIsManaged.m new file mode 100644 index 00000000..d879ad4b --- /dev/null +++ b/xts5/Xt5/XtIsManaged/XtIsManaged.m @@ -0,0 +1,124 @@ +Copyright (c) 2005 X.Org Foundation LLC + +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 +AUTHORS OR COPYRIGHT HOLDERS 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. +$Header: /cvs/xtest/xtest/xts5/tset/Xt5/XtIsManaged/XtIsManaged.m,v 1.1 2005-02-12 14:38:14 anderson Exp $ + +Copyright (c) Applied Testing and Technology, Inc. 1993, 1994, 1995 +Copyright (c) 88open Consortium, Ltd. 1990, 1991, 1992, 1993 +All Rights Reserved. + +>># +>># Project: VSW5 +>># +>># File: tset/Xt5/XtIsManaged/XtIsManaged.m +>># +>># Description: +>># Tests for XtIsManaged() +>># +>># Modifications: +>># $Log: tismanage.m,v $ +>># Revision 1.1 2005-02-12 14:38:14 anderson +>># Initial revision +>># +>># Revision 8.0 1998/12/23 23:36:37 mar +>># Branch point for Release 5.0.2 +>># +>># Revision 7.0 1998/10/30 22:59:29 mar +>># Branch point for Release 5.0.2b1 +>># +>># Revision 6.0 1998/03/02 05:27:46 tbr +>># Branch point for Release 5.0.1 +>># +>># Revision 5.0 1998/01/26 03:24:20 tbr +>># Branch point for Release 5.0.1b1 +>># +>># Revision 4.0 1995/12/15 09:16:40 tbr +>># Branch point for Release 5.0.0 +>># +>># Revision 3.1 1995/12/15 01:20:41 andy +>># Prepare for GA Release +>># +>>EXTERN +#include <X11/IntrinsicP.h> +#include <X11/ConstrainP.h> +#include <X11/CoreP.h> +#include <X11/Xaw/Label.h> +#include <AvsObj.h> + +XtAppContext app_ctext; +Widget topLevel, panedw, boxw1, boxw2; +Widget labelw, rowcolw, click_quit; +>>TITLE XtIsManaged Xt5 +Boolean +XtIsManaged(w) +>>ASSERTION Good A +A successful call to +Boolean XtIsManaged(w) when the widget w belongs to the class RectObj or a +subclass thereof and is managed shall return True. +>>CODE +Boolean status; + + avs_xt_hier("Tismanage1", "XtIsManaged"); + tet_infoline("PREP: Create windows for widgets and map them"); + XtRealizeWidget(topLevel); + tet_infoline("TEST: labelw widget is managed shall return True"); + status = XtIsManaged(labelw); + check_dec(True, status, "XtIsManaged return value"); + tet_result(TET_PASS); +>>ASSERTION Good A +A call to +Boolean XtIsManaged(w) +when the widget w is not managed shall return False. +>>CODE +Widget unmngw; +Boolean status; + + avs_xt_hier("Tismanage2", "XtIsManaged"); + tet_infoline("PREP: Create unmngw label widget in box widget"); + unmngw = XtVaCreateWidget( + "Unmanaged Widget", + labelWidgetClass, + boxw1, + NULL + ); + tet_infoline("PREP: Create windows for widgets and map them"); + XtRealizeWidget(topLevel); + tet_infoline("TEST: XtIsManaged for unmngw label widget returns False"); + status = XtIsManaged(unmngw); + check_dec(False, status, "XtIsManaged return value"); + tet_result(TET_PASS); +>>ASSERTION Good A +A call to +Boolean XtIsManaged(w) +when the widget w does not belong to the class RectObj or a subclass thereof +shall return False. +>>CODE +Widget ObjectNotWidget; +Boolean status; + + avs_xt_hier("Tismanage2", "XtIsManaged"); + tet_infoline("PREP: Create an AvsObject"); + ObjectNotWidget = XtCreateWidget("ObjectNotWidget", avsObjClass, + topLevel, (ArgList) 0, 0); + tet_infoline("PREP: Create windows for widgets and map them"); + XtRealizeWidget(topLevel); + tet_infoline("TEST: XtIsManaged Returns False"); + status = XtIsManaged(ObjectNotWidget) ; + check_dec(False, status, "Return value"); + tet_result(TET_PASS); diff --git a/xts5/Xt5/XtManageChild/XtManageChild.m b/xts5/Xt5/XtManageChild/XtManageChild.m new file mode 100644 index 00000000..a2eeae36 --- /dev/null +++ b/xts5/Xt5/XtManageChild/XtManageChild.m @@ -0,0 +1,177 @@ +Copyright (c) 2005 X.Org Foundation LLC + +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 +AUTHORS OR COPYRIGHT HOLDERS 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. +$Header: /cvs/xtest/xtest/xts5/tset/Xt5/XtManageChild/XtManageChild.m,v 1.1 2005-02-12 14:38:14 anderson Exp $ + +Copyright (c) Applied Testing and Technology, Inc. 1993, 1994, 1995 +Copyright (c) 88open Consortium, Ltd. 1990, 1991, 1992, 1993 +All Rights Reserved. + +>># +>># Project: VSW5 +>># +>># File: tset/Xt5/XtManageChild/XtManageChild.m +>># +>># Description: +>># Tests for XtManageChild() +>># +>># Modifications: +>># $Log: tmngchild.m,v $ +>># Revision 1.1 2005-02-12 14:38:14 anderson +>># Initial revision +>># +>># Revision 8.0 1998/12/23 23:36:34 mar +>># Branch point for Release 5.0.2 +>># +>># Revision 7.0 1998/10/30 22:59:26 mar +>># Branch point for Release 5.0.2b1 +>># +>># Revision 6.0 1998/03/02 05:27:43 tbr +>># Branch point for Release 5.0.1 +>># +>># Revision 5.0 1998/01/26 03:24:17 tbr +>># Branch point for Release 5.0.1b1 +>># +>># Revision 4.0 1995/12/15 09:16:32 tbr +>># Branch point for Release 5.0.0 +>># +>># Revision 3.1 1995/12/15 01:20:30 andy +>># Prepare for GA Release +>># +>>EXTERN +#include <X11/IntrinsicP.h> +#include <X11/ConstrainP.h> +#include <X11/CoreP.h> +#include <X11/Xaw/Label.h> + +XtAppContext app_ctext; +Widget topLevel, panedw, boxw1, boxw2; +Widget labelw, rowcolw, click_quit; + +void XtWMH_Proc(str1, str2, str3, str4, str5, car) +String str1, str2, str3, str4, *str5; +Cardinal *car; +{ + avs_set_event(1,1); + exit(1); +} + +>>SET tpstartup avs_alloc_sem +>>SET tpcleanup avs_free_sem +>>TITLE XtManageChild Xt5 +void +XtManageChild(w) +>>ASSERTION Good A +A call to void XtManageChild(w) when widget w is not realized and has the +map_when_managed field set to True and the parent of the widget is +realized shall call the change_managed procedure of the parent, realize +the widget, and map the widget window. +>>CODE +Boolean status; +Widget labelw_good; + + avs_xt_hier("Tmngchild1", "XtManageChild"); + tet_infoline("PREP: Create a labelw_good widget"); + labelw_good = XtVaCreateWidget( + "labelw_good", + labelWidgetClass, + boxw1, + NULL + ); + tet_infoline("PREP: Create windows for widgets and map them"); + XtRealizeWidget(topLevel); + tet_infoline("TEST: Add widget labelw_good to parent's managed widget boxw1 list"); + XtManageChild(labelw_good); + tet_infoline("TEST: labelw_good widget is managed shall return True"); + status = XtIsManaged(labelw_good); + check_dec(True, status, "XtIsManaged return value"); + tet_result(TET_PASS); +>>ASSERTION Good B 0 +On a successful call to void XtManageChild(w) when the widget w has the +map_when_managed field set to a value other than True its +window shall not be mapped. +>>ASSERTION Good A +A call to void XtManageChild(w) when the parent of the widget w +does not belong to a subclass of compositeWidgetClass shall issue an +error. +>>CODE +Boolean status; +Widget labelw_good, labelw_good2; +pid_t pid2; +int invoked; + + FORK(pid2); + avs_xt_hier("Tmngchild3", "XtManageChild"); + XtAppSetErrorMsgHandler(app_ctext, XtWMH_Proc); + tet_infoline("PREP: Create test widgets"); + labelw_good = XtVaCreateWidget( + "labelw_good", + coreWidgetClass, + boxw1, + NULL + ); + labelw_good2 = XtVaCreateWidget( + "labelw_good2", + coreWidgetClass, + labelw_good, + NULL + ); + (void) ConfigureDimension(topLevel, labelw_good); + (void) ConfigureDimension(topLevel, labelw_good2); + tet_infoline("PREP: Create windows for widgets and map them"); + XtRealizeWidget(topLevel); + tet_infoline("TEST: Manage a widget with non-composite parent"); + XtManageChild(labelw_good2); + LKROF(pid2, AVSXTTIMEOUT-2); + tet_infoline("TEST: Error handler was invoked"); + invoked = avs_get_event(1); + if (!invoked) { + sprintf(ebuf, "ERROR: Error handler was not invoked"); + tet_infoline(ebuf); + tet_result(TET_FAIL); + } + tet_result(TET_PASS); +>>ASSERTION Good B 3 +A call to void XtManageChild(w) when the parent of the widget w is in the +process of being destroyed shall return immediately. +>>ASSERTION Good B 3 +A call to void XtManageChild(w) when the widget w is in the process of +being destroyed shall return immediately. +>>ASSERTION Good A +A call to void XtManageChild(w) when the widget w is already managed +shall return immediately. +>>CODE +Boolean status; +Widget labelw_good; + + avs_xt_hier("Tmngchild1", "XtManageChild"); + tet_infoline("PREP: Create a labelw_good widget"); + labelw_good = XtVaCreateWidget( + "labelw_good", + labelWidgetClass, + boxw1, + NULL + ); + tet_infoline("PREP: Create windows for widgets and map them"); + XtRealizeWidget(topLevel); + tet_infoline("PREP: Add widget labelw_good to parent's managed widget boxw1 list"); + XtManageChild(labelw_good); + tet_infoline("PREP: Call XtManageChild again for widget"); + XtManageChild(labelw_good); + tet_result(TET_PASS); diff --git a/xts5/Xt5/XtManageChildren/XtManageChildren.m b/xts5/Xt5/XtManageChildren/XtManageChildren.m new file mode 100644 index 00000000..08979100 --- /dev/null +++ b/xts5/Xt5/XtManageChildren/XtManageChildren.m @@ -0,0 +1,228 @@ +Copyright (c) 2005 X.Org Foundation LLC + +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 +AUTHORS OR COPYRIGHT HOLDERS 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. +$Header: /cvs/xtest/xtest/xts5/tset/Xt5/XtManageChildren/XtManageChildren.m,v 1.1 2005-02-12 14:38:14 anderson Exp $ + +Copyright (c) Applied Testing and Technology, Inc. 1993, 1994, 1995 +Copyright (c) 88open Consortium, Ltd. 1990, 1991, 1992, 1993 +All Rights Reserved. + +>># +>># Project: VSW5 +>># +>># File: tset/Xt5/XtManageChildren/XtManageChildren.m +>># +>># Description: +>># Tests for XtManageChildren() +>># +>># Modifications: +>># $Log: tmngchdrn.m,v $ +>># Revision 1.1 2005-02-12 14:38:14 anderson +>># Initial revision +>># +>># Revision 8.0 1998/12/23 23:36:33 mar +>># Branch point for Release 5.0.2 +>># +>># Revision 7.0 1998/10/30 22:59:24 mar +>># Branch point for Release 5.0.2b1 +>># +>># Revision 6.0 1998/03/02 05:27:43 tbr +>># Branch point for Release 5.0.1 +>># +>># Revision 5.0 1998/01/26 03:24:16 tbr +>># Branch point for Release 5.0.1b1 +>># +>># Revision 4.0 1995/12/15 09:16:30 tbr +>># Branch point for Release 5.0.0 +>># +>># Revision 3.1 1995/12/15 01:20:28 andy +>># Prepare for GA Release +>># +>>EXTERN +#include <X11/IntrinsicP.h> +#include <X11/ConstrainP.h> +#include <X11/CoreP.h> +#include <X11/Xaw/Label.h> /* label widget defs */ + +XtAppContext app_ctext; +Widget topLevel, panedw, boxw1, boxw2; +Widget labelw, rowcolw, click_quit; + +void XtWMH_Proc(str1, str2, str3, str4, str5, car) +String str1, str2, str3, str4, *str5; +Cardinal *car; +{ + avs_set_event(1,1); + exit(1); +} + +>>SET tpstartup avs_alloc_sem +>>SET tpcleanup avs_free_sem +>>TITLE XtManageChildren Xt5 +void +XtManageChildren(children, num_children) +>>ASSERTION Good A +A call to +void XtManageChildren(children, num_children) +shall call the change_managed procedure of the parent of the specified widgets, +realize the widgets which have not been realized, and map each previously +unmanaged widget window that has the mapped_when_managed field set to True. +>>CODE +Boolean status1, status2; +Widget labelw1, labelw2; +Widget children[2]; + + avs_xt_hier("Tmngchdrn1", "XtManageChildren"); + tet_infoline("PREP: Create unmanaged widget labelw1"); + labelw1 = XtVaCreateWidget( + "Hello", /* widget name */ + labelWidgetClass, /* widget class */ + boxw1, /* parent widget */ + (char *)NULL /* terminate list */ + ); + tet_infoline("PREP: Create unmanaged widget labelw2"); + labelw2 = XtVaCreateWidget( + "World", /* widget name */ + labelWidgetClass, /* widget class */ + boxw1, /* parent widget */ + (char *)NULL /* terminate list */ + ); + tet_infoline("PREP: Create windows for widgets and map them"); + XtRealizeWidget(topLevel); + tet_infoline("PREP: Add list of children to parent managed widget list"); + children[0] = labelw1; + children[1] = labelw2; + XtManageChildren(&children[0], 2); + tet_infoline("TEST: Child widget labelw1 is managed shall return True"); + status1 = XtIsManaged(labelw1); + check_dec(True, status1, "XtIsManaged return value"); + tet_infoline("TEST: Child widget labelw2 is managed shall return True"); + status2 = XtIsManaged(labelw2); + check_dec(True, status2, "XtIsManaged return value"); + tet_infoline("TEST: Child widget labelw1 is realized shall return True"); + status1 = XtIsRealized(labelw1); + check_dec(True, status1, "XtIsRealized return value"); + tet_infoline("TEST: Child widget labelw2 is realized shall return True"); + status2 = XtIsRealized(labelw2); + check_dec(True, status2, "XtIsRealized return value"); + tet_result(TET_PASS); +>>ASSERTION Good B 0 +A call to void XtManageChildren(children, num_children) +shall not map the windows of the widgets that have the +mapped_when_managed field set to a value other than True. +>>ASSERTION Good A +A call to void XtManageChildren(children, num_children) when the widgets +specified by children do not all have the same parent shall issue a +warning message. +>>CODE +Boolean status1, status2; +Widget labelw1, labelw2; +Widget children[2]; +int invoked; +pid_t pid2; + + FORK(pid2); + avs_xt_hier("Tmngchdrn1", "XtManageChildren"); + tet_infoline("PREP: Create unmanaged widget labelw1"); + labelw1 = XtVaCreateWidget( + "Hello", /* widget name */ + labelWidgetClass, /* widget class */ + boxw1, /* parent widget */ + (char *)NULL /* terminate list */ + ); + tet_infoline("PREP: Create unmanaged widget labelw2"); + labelw2 = XtVaCreateWidget( + "World", /* widget name */ + labelWidgetClass, /* widget class */ + labelw1, /* parent widget */ + (char *)NULL /* terminate list */ + ); + XtAppSetWarningMsgHandler(app_ctext, XtWMH_Proc); + tet_infoline("PREP: Create windows for widgets and map them"); + XtRealizeWidget(topLevel); + tet_infoline("PREP: Manage a child and its child"); + children[0] = labelw1; + children[1] = labelw2; + XtManageChildren(&children[0], 2); + LKROF(pid2, AVSXTTIMEOUT-2); + tet_infoline("TEST: Warning handler was invoked"); + invoked = avs_get_event(1); + if (!invoked) { + sprintf(ebuf, "ERROR: Warning handler was not invoked"); + tet_infoline(ebuf); + tet_result(TET_FAIL); + } + tet_result(TET_PASS); +>>ASSERTION Good A +A call to +void XtManageChildren(children, num_children) +when the parent of +the widgets specified by children does not belong to a subclass of +compositeWidgetClass shall issue an error. +>>CODE +Boolean status1, status2; +Widget labelw_good, labelw_good2; +Widget children[2]; +int invoked; +pid_t pid2; + + FORK(pid2); + avs_xt_hier("Tmngchdrn1", "XtManageChildren"); + XtAppSetErrorMsgHandler(app_ctext, XtWMH_Proc); + tet_infoline("PREP: Create test widgets"); + labelw_good = XtVaCreateWidget( + "labelw_good", + coreWidgetClass, + boxw1, + NULL + ); + labelw_good2 = XtVaCreateWidget( + "labelw_good2", + coreWidgetClass, + labelw_good, + NULL + ); + (void) ConfigureDimension(topLevel, labelw_good); + (void) ConfigureDimension(topLevel, labelw_good2); + tet_infoline("PREP: Create windows for widgets and map them"); + XtRealizeWidget(topLevel); + tet_infoline("TEST: Manage a widget with a non-composite parent"); + children[0] = labelw_good2; + XtManageChildren(&children[0], 1); + LKROF(pid2, AVSXTTIMEOUT-2); + tet_infoline("TEST: Error handler was invoked"); + invoked = avs_get_event(1); + if (!invoked) { + sprintf(ebuf, "ERROR: Error handler was not invoked"); + tet_infoline(ebuf); + tet_result(TET_FAIL); + } + tet_result(TET_PASS); +>>ASSERTION Good B 1 +A call to void XtManageChildren(children, num_children) when the parent +of the widgets specified by children is in the process of being destroyed +shall return immediately. +>>ASSERTION Good B 1 +On a call to void XtManageChildren(children, num_children) when a widget +in the list of widgets specified by children is in the process of being +destroyed it shall not be considered for being managed by its parent. +>>ASSERTION Good B 3 +On a call to void XtManageChildren(children, num_children) when a widget +in the list of widgets specified by children is already managed it shall +not be considered for being managed by its parent. diff --git a/xts5/Xt5/XtMapWidget/XtMapWidget.m b/xts5/Xt5/XtMapWidget/XtMapWidget.m new file mode 100644 index 00000000..8dfdbf29 --- /dev/null +++ b/xts5/Xt5/XtMapWidget/XtMapWidget.m @@ -0,0 +1,125 @@ +Copyright (c) 2005 X.Org Foundation LLC + +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 +AUTHORS OR COPYRIGHT HOLDERS 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. +$Header: /cvs/xtest/xtest/xts5/tset/Xt5/XtMapWidget/XtMapWidget.m,v 1.1 2005-02-12 14:38:14 anderson Exp $ + +Copyright (c) Applied Testing and Technology, Inc. 1993, 1994, 1995 +Copyright (c) 88open Consortium, Ltd. 1990, 1991, 1992, 1993 +All Rights Reserved. + +>># +>># Project: VSW5 +>># +>># File: tset/Xt5/XtMapWidget/XtMapWidget.m +>># +>># Description: +>># Tests for XtMapWidget() +>># +>># Modifications: +>># $Log: tmpwidget.m,v $ +>># Revision 1.1 2005-02-12 14:38:14 anderson +>># Initial revision +>># +>># Revision 8.0 1998/12/23 23:36:38 mar +>># Branch point for Release 5.0.2 +>># +>># Revision 7.0 1998/10/30 22:59:30 mar +>># Branch point for Release 5.0.2b1 +>># +>># Revision 6.0 1998/03/02 05:27:47 tbr +>># Branch point for Release 5.0.1 +>># +>># Revision 5.0 1998/01/26 03:24:21 tbr +>># Branch point for Release 5.0.1b1 +>># +>># Revision 4.0 1995/12/15 09:16:43 tbr +>># Branch point for Release 5.0.0 +>># +>># Revision 3.1 1995/12/15 01:20:44 andy +>># Prepare for GA Release +>># +>>EXTERN +#include <X11/IntrinsicP.h> +#include <X11/ConstrainP.h> +#include <X11/CoreP.h> + +XtAppContext app_ctext; +Widget topLevel, panedw, boxw1, boxw2; +Widget labelw, rowcolw, click_quit; +Window window; + +static void analyse_events(quit) +Widget quit; +{ + XtAppContext app_context; + Display *display; + XEvent loop_event; + XEvent return_event; + Widget widget; + widget = XtParent(quit); + app_context = XtWidgetToApplicationContext(widget); + display = XtDisplay(widget); + for (;;) { + XtAppNextEvent(app_context, &loop_event); + XSync(display, False); + if (loop_event.type == MapNotify) { + if (loop_event.xany.window == window) { + avs_set_event(1,1); + exit(0); + } + } + XtDispatchEvent(&loop_event); + } /* end for */ +} +>>SET tpstartup avs_alloc_sem +>>SET tpcleanup avs_free_sem +>>TITLE XtMapWidget Xt5 +void +XtMapWidget(w) +>>ASSERTION Good A +A successful call to +void XtMapWidget(w) +when the widget w is realized shall map the widget window. +>>CODE +Widget labelw_good; +Display *display; +int status = 0; +pid_t pid2; + + FORK(pid2); + avs_xt_hier("Tmpwidget1", "XtMapWidget"); + tet_infoline("PREP: Create labelw_good widget Hello"); + labelw_good = (Widget) CreateLabelWidget("Hello", boxw1); + tet_infoline("PREP: Create windows for widgets and map them"); + XtRealizeWidget(topLevel); + tet_infoline("PREP: Catch MapNotify event"); + display = XtDisplay(labelw_good); + window = XtWindow(labelw_good); + XSelectInput(display, window, (unsigned long)StructureNotifyMask); + tet_infoline("PREP: Unmap labelw_good widget"); + XtUnmapWidget(labelw_good); + tet_infoline("PREP: Map labelw_good widget"); + XtMapWidget(labelw_good); + tet_infoline("TEST: MapNotify event was generated"); + analyse_events(click_quit); + KROF(pid2); + kill(pid2, SIGKILL); + status = avs_get_event(1); + check_dec(1, status, "MapNotify event count"); + tet_result(TET_PASS); diff --git a/xts5/Xt5/XtSetMappedWhenManaged/XtSetMappedWhenManaged.m b/xts5/Xt5/XtSetMappedWhenManaged/XtSetMappedWhenManaged.m new file mode 100644 index 00000000..3b95c026 --- /dev/null +++ b/xts5/Xt5/XtSetMappedWhenManaged/XtSetMappedWhenManaged.m @@ -0,0 +1,193 @@ +Copyright (c) 2005 X.Org Foundation LLC + +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 +AUTHORS OR COPYRIGHT HOLDERS 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. +$Header: /cvs/xtest/xtest/xts5/tset/Xt5/XtSetMappedWhenManaged/XtSetMappedWhenManaged.m,v 1.1 2005-02-12 14:38:14 anderson Exp $ + +Copyright (c) Applied Testing and Technology, Inc. 1993, 1994, 1995 +Copyright (c) 88open Consortium, Ltd. 1990, 1991, 1992, 1993 +All Rights Reserved. + +>># +>># Project: VSW5 +>># +>># File: tset/Xt5/XtSetMappedWhenManaged/XtSetMappedWhenManaged.m +>># +>># Description: +>># Tests for XtSetMappedWhenManaged() +>># +>># Modifications: +>># $Log: tstmpwmng.m,v $ +>># Revision 1.1 2005-02-12 14:38:14 anderson +>># Initial revision +>># +>># Revision 8.0 1998/12/23 23:36:38 mar +>># Branch point for Release 5.0.2 +>># +>># Revision 7.0 1998/10/30 22:59:29 mar +>># Branch point for Release 5.0.2b1 +>># +>># Revision 6.0 1998/03/02 05:27:46 tbr +>># Branch point for Release 5.0.1 +>># +>># Revision 5.0 1998/01/26 03:24:20 tbr +>># Branch point for Release 5.0.1b1 +>># +>># Revision 4.0 1995/12/15 09:16:41 tbr +>># Branch point for Release 5.0.0 +>># +>># Revision 3.1 1995/12/15 01:20:42 andy +>># Prepare for GA Release +>># +>>EXTERN +#include <X11/IntrinsicP.h> +#include <X11/ConstrainP.h> +#include <X11/CoreP.h> + +XtAppContext app_ctext; +Widget topLevel, panedw, boxw1, boxw2; +Widget labelw, rowcolw, click_quit; +Window window; + +static void analyse_events2(quit) +Widget quit; +{ + XtAppContext app_context; + Display *display; + XEvent loop_event; + XEvent return_event; + Widget widget; + widget = XtParent(quit); + app_context = XtWidgetToApplicationContext(widget); + display = XtDisplay(widget); + for (;;) { + XtAppNextEvent(app_context, &loop_event); + XSync(display, False); + if (loop_event.type == UnmapNotify) { + if (loop_event.xany.window == window) { + avs_set_event(1,1); + exit(0); + } + } + } /* end for */ +} + +static void analyse_events(quit) +Widget quit; +{ + XtAppContext app_context; + Display *display; + XEvent loop_event; + XEvent return_event; + Widget widget; + widget = XtParent(quit); + app_context = XtWidgetToApplicationContext(widget); + display = XtDisplay(widget); + for (;;) { + XtAppNextEvent(app_context, &loop_event); + XSync(display, False); + if (loop_event.type == MapNotify) { + if (loop_event.xany.window == window) { + avs_set_event(1,1); + exit(0); + } + } + XtDispatchEvent(&loop_event); + } /* end for */ +} +>>SET tpstartup avs_alloc_sem +>>SET tpcleanup avs_free_sem +>>TITLE XtSetMappedWhenManaged Xt5 +void +XtSetMappedWhenManaged(w, map_when_managed) +>>ASSERTION Good A +When the widget w is realized, managed, and map_when_managed is set +to True a successful call to +void XtSetMappedWhenManaged(w, map_when_managed) +shall map the widget window. +>>CODE +Widget labelw_msg; +char *msg = "Test widget"; +Boolean value; +Arg args[1]; +Display *display; +int status = 0; +pid_t pid2; + + avs_xt_hier("Tstmpwmng1", "XtSetMappedWhenManaged"); + tet_infoline("PREP: Create labelw_msg in box1w"); + labelw_msg = (Widget) CreateLabelWidget(msg, boxw1); + tet_infoline("TEST: Set mapped_when_managed to True"); + XtSetMappedWhenManaged(labelw_msg, False); + tet_infoline("PREP: Create windows for widgets and map them"); + XtRealizeWidget(topLevel); + tet_infoline("PREP: Catch MapNotify event"); + display = XtDisplay(labelw_msg); + window = XtWindow(labelw_msg); + XSelectInput(display, window, (unsigned long)StructureNotifyMask); + tet_infoline("PREP: Unmap labelw_msg widget"); + XtUnmapWidget(labelw_msg); + tet_infoline("TEST: Set mapped_when_managed to True"); + XtSetMappedWhenManaged(labelw_msg, True); + FORK(pid2); + tet_infoline("TEST: MapNotify event was generated for widget"); + analyse_events(click_quit); + KROF(pid2); + kill(pid2, SIGKILL); + status = avs_get_event(1); + check_dec(1, status, "MapNotify event count"); + tet_infoline("TEST: Resource value XtNmappedWhenManaged is True."); + args[0].name = XtNmappedWhenManaged; + XtVaGetValues(labelw_msg, XtNmappedWhenManaged, &value, (char *)NULL); + check_dec(True, value, "XtNmappedWhenManaged"); + tet_result(TET_PASS); +>>ASSERTION Good A +When the widget w is realized, managed, and map_when_managed is set +to False a successful call to +void XtSetMappedWhenManaged(w, map_when_managed) +shall unmap the widget window. +>>CODE +Widget labelw_msg; +char *msg = "Test widget"; +Boolean value; +Display *display; +int status = 0; +pid_t pid2; + + avs_xt_hier("Tstmpwmng2", "XtSetMappedWhenManaged"); + tet_infoline("PREP: Create labelw_msg in box1w"); + labelw_msg = (Widget) CreateLabelWidget(msg, boxw1); + tet_infoline("PREP: Create windows for widgets and map them"); + XtRealizeWidget(topLevel); + tet_infoline("PREP: Catch MapNotify event"); + display = XtDisplay(labelw_msg); + window = XtWindow(labelw_msg); + XSelectInput(display, window, (unsigned long)StructureNotifyMask); + tet_infoline("TEST Set mapped_when_managed to False"); + XtSetMappedWhenManaged(labelw_msg, False); + FORK(pid2); + tet_infoline("TEST: UnmapNotify event was generated for widget"); + analyse_events2(click_quit); + KROF(pid2); + kill(pid2, SIGKILL); + status = avs_get_event(1); + check_dec(1, status, "UnmapNotify event count"); + tet_infoline("TEST: Resource value XtNmappedWhenManaged is False."); + XtVaGetValues(labelw_msg, XtNmappedWhenManaged, &value, (char *)NULL); + check_dec(False, value, "XtNmappedWhenManaged"); + tet_result(TET_PASS); diff --git a/xts5/Xt5/XtUnmanageChild/XtUnmanageChild.m b/xts5/Xt5/XtUnmanageChild/XtUnmanageChild.m new file mode 100644 index 00000000..00210936 --- /dev/null +++ b/xts5/Xt5/XtUnmanageChild/XtUnmanageChild.m @@ -0,0 +1,229 @@ +Copyright (c) 2005 X.Org Foundation LLC + +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 +AUTHORS OR COPYRIGHT HOLDERS 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. +$Header: /cvs/xtest/xtest/xts5/tset/Xt5/XtUnmanageChild/XtUnmanageChild.m,v 1.1 2005-02-12 14:38:14 anderson Exp $ + +Copyright (c) Applied Testing and Technology, Inc. 1993, 1994, 1995 +Copyright (c) 88open Consortium, Ltd. 1990, 1991, 1992, 1993 +All Rights Reserved. + +>># +>># Project: VSW5 +>># +>># File: tset/Xt5/XtUnmanageChild/XtUnmanageChild.m +>># +>># Description: +>># Tests for XtUnmanageChild() +>># +>># Modifications: +>># $Log: tunmgchld.m,v $ +>># Revision 1.1 2005-02-12 14:38:14 anderson +>># Initial revision +>># +>># Revision 8.0 1998/12/23 23:36:36 mar +>># Branch point for Release 5.0.2 +>># +>># Revision 7.0 1998/10/30 22:59:28 mar +>># Branch point for Release 5.0.2b1 +>># +>># Revision 6.0 1998/03/02 05:27:45 tbr +>># Branch point for Release 5.0.1 +>># +>># Revision 5.0 1998/01/26 03:24:19 tbr +>># Branch point for Release 5.0.1b1 +>># +>># Revision 4.0 1995/12/15 09:16:39 tbr +>># Branch point for Release 5.0.0 +>># +>># Revision 3.1 1995/12/15 01:20:39 andy +>># Prepare for GA Release +>># +>>EXTERN +#include <X11/IntrinsicP.h> +#include <X11/ConstrainP.h> +#include <X11/CoreP.h> +#include <X11/Xaw/Label.h> +#include <AvsComp2.h> + +XtAppContext app_ctext; +Widget topLevel, panedw, boxw1, boxw2; +Widget labelw, rowcolw, click_quit; + +void XtEMH2_Proc(str1, str2, str3, str4, str5, car) +String str1, str2, str3, str4, *str5; +Cardinal *car; +{ + avs_set_event(2,1); +} +/* +** Installed Error handler +*/ +void XtEMH_Proc(str1, str2, str3, str4, str5, car) +String str1, str2, str3, str4, *str5; +Cardinal *car; +{ + avs_set_event(1,1); +} +>>SET tpstartup avs_alloc_sem +>>SET tpcleanup avs_free_sem +>>TITLE XtUnmanageChild Xt5 +void +XtUnmanageChild(w) +>>ASSERTION Good A +A successful call to +void XtUnmanageChild(w) +when the widget w is managed by its parent shall make the widget to be +unmanaged. +>>CODE +Boolean status; +Widget labelw_good; + + avs_xt_hier("Tunmgchld1", "XtUnmanageChild"); + tet_infoline("PREP: Create a managed widget labelw_good"); + labelw_good = (Widget) CreateLabelWidget("Hello", boxw1); + tet_infoline("PREP: Create windows for widgets and map them"); + XtRealizeWidget(topLevel); + tet_infoline("TEST: Unmanage child"); + XtUnmanageChild(labelw_good); + tet_infoline("TEST: labelw_good widget is managed shall return False"); + status = XtIsManaged(labelw_good); + tet_result(TET_PASS); +>>ASSERTION Good B 0 +On a successful call to +void XtUnmanageChild(w) +when the widget w is realized and has become unmanaged the window of the +widget shall be unmapped. +>>ASSERTION Good A +When the parent is realized and the widget w has become unmanaged +a successful call to +void XtUnmanageChild(w) +shall invoke the change_managed routine of the parent. +>>CODE +int status; +Widget test2_widget, test_widget; + + avs_xt_hier("Tunmgchdn2", "XtUnmanageChild"); + tet_infoline("PREP: Create a test parent"); + test_widget = XtVaCreateManagedWidget("avsw2", avsComp2WidgetClass, boxw1, NULL); + tet_infoline("PREP: Create a managed child widget"); + test2_widget = (Widget) CreateLabelWidget("Hello", test_widget); + tet_infoline("PREP: Create windows for widgets and map them"); + XtRealizeWidget(topLevel); + tet_infoline("TEST: Unmanage child"); + XtUnmanageChild(test2_widget); + tet_infoline("TEST: Change managed procedure invoked"); + /*this is a test widget class with a special change managed routine*/ + /*that sets this when its called - see AvsComp2.h in the avsxt library*/ + status = avs_get_event(5); + if (status != 1 ) { + sprintf(ebuf, "ERROR: Change_managed routine not invoked"); + tet_infoline(ebuf); + tet_result(TET_FAIL); + } + tet_result(TET_PASS); +>>ASSERTION Good A +When the parent of the widget w is not a subclass of compositeWidgetClass +a successful call to +void XtUnmanageChild(w) +shall issue an invalidParent error. +>>CODE +Widget menuw; +Widget labelw_good; +Widget pushb_good; +Boolean value_good; +Widget labelw1, labelw2; +Widget children[2]; +Widget rowcolw_good; +int invoked; + + avs_xt_hier("Tunmgchdn4", "XtUnmanageChild"); + tet_infoline("PREP: Create child of non-Composite widget"); + labelw_good = XtVaCreateWidget( + "ApTest", /* arbitrary widget name */ + labelWidgetClass, /* widget class */ + labelw, /* parent widget */ + (char *)NULL /* terminate list */ + ); + tet_infoline("PREP: Register error handler"); + XtAppSetErrorMsgHandler(app_ctext, XtEMH_Proc); + XtAppSetWarningMsgHandler(app_ctext, XtEMH2_Proc); + tet_infoline("PREP: Create windows for widgets and map them"); + XtRealizeWidget(topLevel); + tet_infoline("PREP: Unmanage child of non-composite widget"); + XtUnmanageChild(labelw_good); + tet_infoline("TEST: Error handler was invoked"); + invoked = avs_get_event(1); + if (!invoked) { + sprintf(ebuf, "ERROR: Error handler was not invoked"); + tet_infoline(ebuf); + tet_result(TET_FAIL); + } + invoked = avs_get_event(2); + if (invoked) { + sprintf(ebuf, "ERROR: Warning message was generated instead of error message"); + tet_infoline(ebuf); + tet_result(TET_FAIL); + } + tet_result(TET_PASS); +>>ASSERTION Good B 3 +A successful call to +void XtUnmanageChild(w) +when the parent of the widget w is being destroyed shall return immediately. +>>ASSERTION Good B 3 +A call to +void XtUnmanageChild(w) +when the widget w is in the process of being destroyed shall return without +unmanaging the widget. +>>ASSERTION Good A +A call to +void XtUnmanageChild(w) +when the widget w is already unmanaged shall have no effect. +>>CODE +int status; +Widget test2_widget, test_widget; + + avs_xt_hier("Tunmgchdn2", "XtUnmanageChild"); + tet_infoline("PREP: Create a test parent"); + test_widget = XtVaCreateManagedWidget("avsw2", avsComp2WidgetClass, boxw1, NULL); + tet_infoline("PREP: Create a managed child widget"); + test2_widget = (Widget) CreateLabelWidget("Hello", test_widget); + tet_infoline("PREP: Create windows for widgets and map them"); + XtRealizeWidget(topLevel); + tet_infoline("TEST: Unmanage child"); + XtUnmanageChild(test2_widget); + tet_infoline("TEST: Change managed procedure invoked"); + /*this is a test widget class with a special change managed routine*/ + /*that sets this when its called - see AvsComp2.h in the avsxt library*/ + status = avs_get_event(5); + if (status != 1) { + sprintf(ebuf, "ERROR: Change_managed routine not invoked"); + tet_infoline(ebuf); + tet_result(TET_FAIL); + } + tet_infoline("TEST: Unmanage child again"); + XtUnmanageChild(test2_widget); + tet_infoline("TEST: Change managed procedure not invoked"); + avs_set_event(5, 0); + status = avs_get_event(5); + if (status != 0) { + sprintf(ebuf, "ERROR: Change_managed routine was invoked again"); + tet_infoline(ebuf); + tet_result(TET_FAIL); + } + tet_result(TET_PASS); diff --git a/xts5/Xt5/XtUnmanageChildren/XtUnmanageChildren.m b/xts5/Xt5/XtUnmanageChildren/XtUnmanageChildren.m new file mode 100644 index 00000000..dd549ed4 --- /dev/null +++ b/xts5/Xt5/XtUnmanageChildren/XtUnmanageChildren.m @@ -0,0 +1,288 @@ +Copyright (c) 2005 X.Org Foundation LLC + +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 +AUTHORS OR COPYRIGHT HOLDERS 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. +$Header: /cvs/xtest/xtest/xts5/tset/Xt5/XtUnmanageChildren/XtUnmanageChildren.m,v 1.1 2005-02-12 14:38:14 anderson Exp $ + +Copyright (c) Applied Testing and Technology, Inc. 1993, 1994, 1995 +Copyright (c) 88open Consortium, Ltd. 1990, 1991, 1992, 1993 +All Rights Reserved. + +>># +>># Project: VSW5 +>># +>># File: tset/Xt5/XtUnmanageChildren/XtUnmanageChildren.m +>># +>># Description: +>># Tests for XtUnmanageChildren() +>># +>># Modifications: +>># $Log: tunmgchdn.m,v $ +>># Revision 1.1 2005-02-12 14:38:14 anderson +>># Initial revision +>># +>># Revision 8.0 1998/12/23 23:36:36 mar +>># Branch point for Release 5.0.2 +>># +>># Revision 7.0 1998/10/30 22:59:28 mar +>># Branch point for Release 5.0.2b1 +>># +>># Revision 6.0 1998/03/02 05:27:45 tbr +>># Branch point for Release 5.0.1 +>># +>># Revision 5.0 1998/01/26 03:24:19 tbr +>># Branch point for Release 5.0.1b1 +>># +>># Revision 4.1 1996/11/05 22:39:12 andy +>># For TP4, change to require a warning message rather than an error. +>># Per req.4.W.00027 +>># +>># Revision 4.0 1995/12/15 09:16:38 tbr +>># Branch point for Release 5.0.0 +>># +>># Revision 3.1 1995/12/15 01:20:37 andy +>># Prepare for GA Release +>># +>>EXTERN +#include <X11/IntrinsicP.h> +#include <X11/ConstrainP.h> +#include <X11/CoreP.h> +#include <AvsComp2.h> +#include <X11/Xaw/Label.h> + +XtAppContext app_ctext; +Widget topLevel, panedw, boxw1, boxw2; +Widget labelw, rowcolw, click_quit; + +void XtEMH2_Proc(str1, str2, str3, str4, str5, car) +String str1, str2, str3, str4, *str5; +Cardinal *car; +{ + avs_set_event(2,1); +} +/* +** Installed Error handler +*/ +void XtEMH_Proc(str1, str2, str3, str4, str5, car) +String str1, str2, str3, str4, *str5; +Cardinal *car; +{ + avs_set_event(1,1); +} +>>SET tpstartup avs_alloc_sem +>>SET tpcleanup avs_free_sem +>>TITLE XtUnmanageChildren Xt5 +void +XtUnmanageChildren(children, num_children) +>>ASSERTION Good A +A successful call to +void XtUnmanageChildren(children, num_children) +shall cause each specified child widget which is managed by the parent +to be unmanaged. +>>CODE +Boolean value_good; +Widget labelw1, labelw2; +Widget children[2]; + + + avs_xt_hier("Tunmgchdn1", "XtUnmanageChildren"); + tet_infoline("PREP: Create a managed widget labelw1"); + labelw1 = (Widget) CreateLabelWidget("Hello", boxw1); + tet_infoline("PREP: Create a managed widget labelw2"); + labelw2 = (Widget) CreateLabelWidget("World", boxw1); + tet_infoline("PREP: Create windows for widgets and map them"); + XtRealizeWidget(topLevel); + tet_infoline("TEST: Remove list of children from the parent managed widget list"); + children[0] = labelw1; + children[1] = labelw2; + XtUnmanageChildren(children, 2); + tet_infoline("TEST: Children are not managed"); + value_good = XtIsManaged(labelw1); + check_dec(False, value_good, "XtIsManaged return value"); + value_good = XtIsManaged(labelw2); + check_dec(False, value_good, "XtIsManaged return value"); + tet_result(TET_PASS); +>>ASSERTION Good B 0 +A successful call to +void XtUnmanageChildren(children, num_children) +shall unmap the widget window of each realized child widget that has +become unmanaged. +>>ASSERTION Good A +When the parent is realized and at least one child widget has become unmanaged +a successful call to +void XtUnmanageChildren(children, num_children) +shall invoke the change_managed routine of the parent. +>>CODE +int status; +Widget children[2]; +Widget test_widget, test2_widget; + + avs_xt_hier("Tunmgchdn2", "XtUnmanageChildren"); + tet_infoline("PREP: Create a test parent"); + test_widget = XtVaCreateManagedWidget("avsw2", avsComp2WidgetClass, boxw1, NULL); + tet_infoline("PREP: Create a managed child widget"); + test2_widget = (Widget) CreateLabelWidget("Hello", test_widget); + tet_infoline("PREP: Create windows for widgets and map them"); + XtRealizeWidget(topLevel); + children[0] = test2_widget; + XtUnmanageChildren(children, 1); + tet_infoline("TEST: Change managed procedure invoked"); + /*this is a test widget class with a special change managed routine*/ + /*that sets this when its called - see AvsComp2.h in the avsxt library*/ + status = avs_get_event(5); + if (status != 1 ) { + sprintf(ebuf, "ERROR: Change_managed routine not invoked"); + tet_infoline(ebuf); + tet_result(TET_FAIL); + } + tet_result(TET_PASS); +>>ASSERTION Good A +When the widgets specified by children do not all have the same parent +a call to +void XtUnmanageChildren(children, num_children) +shall issue a warning message and continue. +>>CODE +Boolean value_good; +Widget labelw1, labelw2; +Widget children[2]; +Widget rowcolw_good; +int invoked; + + avs_xt_hier("Tunmgchdn2", "XtUnmanageChildren"); + tet_infoline("PREP: Create managed child widget labelw1 in boxw1"); + labelw1 = (Widget) CreateLabelWidget("Hello", boxw1); + tet_infoline("PREP: Create rowcolw_good widget in boxw1 widget"); + rowcolw_good = (Widget) CreateRowColWidget(boxw1); + tet_infoline("PREP: Create managed child widget labelw2 in rowcolw_good"); + labelw2 = (Widget) CreateLabelWidget("World", rowcolw_good); + tet_infoline("PREP: Create windows for widgets and map them"); + XtRealizeWidget(topLevel); + tet_infoline("PREP: Register error handler"); + XtAppSetWarningMsgHandler(app_ctext, XtEMH2_Proc); + XtAppSetErrorMsgHandler(app_ctext, XtEMH_Proc); + tet_infoline("PREP: Unmange children, with different parents"); + children[0] = labelw1; + children[1] = labelw2; + XtUnmanageChildren(children, 2); + tet_infoline("TEST: Error message was generated"); + invoked = avs_get_event(2); + if (!invoked) { + sprintf(ebuf, "ERROR: Warning handler was not invoked"); + tet_infoline(ebuf); + tet_result(TET_FAIL); + } + invoked = avs_get_event(1); + if (invoked) { + sprintf(ebuf, "ERROR: Error message was issued instead of warning message"); + tet_infoline(ebuf); + tet_result(TET_FAIL); + } + tet_result(TET_PASS); +>>ASSERTION Good A +When the parent of the widgets specified by children is not a subclass of +compositeWidgetClass a call to +void XtUnmanageChildren(children, num_children) +shall issue an invalidParent error. +>>CODE +Widget menuw; +Widget labelw_good; +Widget pushb_good; +Boolean value_good; +Widget labelw1, labelw2; +Widget children[2]; +Widget rowcolw_good; +int invoked; + + avs_xt_hier("Tunmgchdn4", "XtUnmanageChildren"); + tet_infoline("PREP: Create child of non-Composite widget"); + labelw_good = XtVaCreateWidget( + "ApTest", /* arbitrary widget name */ + labelWidgetClass, /* widget class */ + labelw, /* parent widget */ + (char *)NULL /* terminate list */ + ); + tet_infoline("PREP: Register error handler"); + XtAppSetErrorMsgHandler(app_ctext, XtEMH_Proc); + XtAppSetWarningMsgHandler(app_ctext, XtEMH2_Proc); + tet_infoline("PREP: Create windows for widgets and map them"); + XtRealizeWidget(topLevel); + tet_infoline("PREP: Unmanage child of non-composite widget"); + children[0] = labelw_good; + XtUnmanageChildren(children, 1); + tet_infoline("TEST: Error handler was invoked"); + invoked = avs_get_event(1); + if (!invoked) { + sprintf(ebuf, "ERROR: Error handler was not invoked"); + tet_infoline(ebuf); + tet_result(TET_FAIL); + } + invoked = avs_get_event(2); + if (invoked) { + sprintf(ebuf, "ERROR: Warning message was generated instead of error message"); + tet_infoline(ebuf); + tet_result(TET_FAIL); + } + tet_result(TET_PASS); +>>ASSERTION Good B 1 +When the parent of the widgets specified by children is being destroyed +a call to +void XtUnmanageChildren(children, num_children) +shall return immediately. +>>ASSERTION Good B 1 +A call to +void XtUnmanageChildren(children, num_children) +shall ignore those child widgets which are in the process of being destroyed. +>>ASSERTION Good A +A call to +void XtUnmanageChildren(children, num_children) +shall ignore those child widgets which are already unmanaged. +>>CODE +int status; +Widget children[2]; +Widget test_widget, test2_widget; + + avs_xt_hier("Tunmgchdn2", "XtUnmanageChildren"); + tet_infoline("PREP: Create a test parent"); + test_widget = XtVaCreateManagedWidget("avsw2", avsComp2WidgetClass, boxw1, NULL); + tet_infoline("PREP: Create a managed child widget"); + test2_widget = (Widget) CreateLabelWidget("Hello", test_widget); + tet_infoline("PREP: Create windows for widgets and map them"); + XtRealizeWidget(topLevel); + children[0] = test2_widget; + tet_infoline("TEST: Call XtUnmanageChildren"); + XtUnmanageChildren(children, 1); + tet_infoline("TEST: Change managed procedure invoked"); + /*this is a test widget class with a special change managed routine*/ + /*that sets this when its called - see AvsComp2.h in the avsxt library*/ + status = avs_get_event(5); + if (status != 1 ) { + sprintf(ebuf, "ERROR: Change_managed routine not invoked"); + tet_infoline(ebuf); + tet_result(TET_FAIL); + } + avs_set_event(5, 0); + tet_infoline("TEST: Call XtUnmanageChildren again"); + XtUnmanageChildren(children, 1); + tet_infoline("TEST: Change managed procedure was not invoked"); + status = avs_get_event(5); + if (status != 0 ) { + sprintf(ebuf, "ERROR: Change_managed routine was invoked again"); + tet_infoline(ebuf); + tet_result(TET_FAIL); + } + tet_result(TET_PASS); diff --git a/xts5/Xt5/XtUnmapWidget/XtUnmapWidget.m b/xts5/Xt5/XtUnmapWidget/XtUnmapWidget.m new file mode 100644 index 00000000..f1c01c95 --- /dev/null +++ b/xts5/Xt5/XtUnmapWidget/XtUnmapWidget.m @@ -0,0 +1,121 @@ +Copyright (c) 2005 X.Org Foundation LLC + +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 +AUTHORS OR COPYRIGHT HOLDERS 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. +$Header: /cvs/xtest/xtest/xts5/tset/Xt5/XtUnmapWidget/XtUnmapWidget.m,v 1.1 2005-02-12 14:38:14 anderson Exp $ + +Copyright (c) Applied Testing and Technology, Inc. 1993, 1994, 1995 +Copyright (c) 88open Consortium, Ltd. 1990, 1991, 1992, 1993 +All Rights Reserved. + +>># +>># Project: VSW5 +>># +>># File: tset/Xt5/XtUnmapWidget/XtUnmapWidget.m +>># +>># Description: +>># Tests for XtUnmapWidget() +>># +>># Modifications: +>># $Log: tunmpwdgt.m,v $ +>># Revision 1.1 2005-02-12 14:38:14 anderson +>># Initial revision +>># +>># Revision 8.0 1998/12/23 23:36:39 mar +>># Branch point for Release 5.0.2 +>># +>># Revision 7.0 1998/10/30 22:59:30 mar +>># Branch point for Release 5.0.2b1 +>># +>># Revision 6.0 1998/03/02 05:27:47 tbr +>># Branch point for Release 5.0.1 +>># +>># Revision 5.0 1998/01/26 03:24:21 tbr +>># Branch point for Release 5.0.1b1 +>># +>># Revision 4.0 1995/12/15 09:16:44 tbr +>># Branch point for Release 5.0.0 +>># +>># Revision 3.1 1995/12/15 01:20:45 andy +>># Prepare for GA Release +>># +>>EXTERN +#include <X11/IntrinsicP.h> +#include <X11/ConstrainP.h> +#include <X11/CoreP.h> + +XtAppContext app_ctext; +Widget topLevel, panedw, boxw1, boxw2; +Widget labelw, rowcolw, click_quit; +Window window; + +static void analyse_events(quit) +Widget quit; +{ + XtAppContext app_context; + Display *display; + XEvent loop_event; + Widget widget; + widget = XtParent(quit); + app_context = XtWidgetToApplicationContext(widget); + display = XtDisplay(widget); + for (;;) { + XtAppNextEvent(app_context, &loop_event); + XSync(display, False); + if (loop_event.type == UnmapNotify) { + if (loop_event.xany.window == window) { + avs_set_event(1,1); + exit(0); + } + } + XtDispatchEvent(&loop_event); + } /* end for */ +} +>>SET tpstartup avs_alloc_sem +>>SET tpcleanup avs_free_sem +>>TITLE XtUnmapWidget Xt5 +void +XtUnmapWidget(w) +>>ASSERTION Good A +A successful call to +void XtUnmapWidget(w) +when the window of the widget w is mapped shall unmap the widget window. +>>CODE +Widget labelw_good; +Display *display; +int status = 0; +pid_t pid2; + + avs_xt_hier("Tunmpwdgt1", "XtUnmapWidget"); + tet_infoline("PREP: Create labelw_good widget Hello"); + labelw_good = (Widget) CreateLabelWidget("Hello", boxw1); + tet_infoline("PREP: Create windows for widgets and map them"); + XtRealizeWidget(topLevel); + tet_infoline("PREP: Catch UnmapNotify event"); + display = XtDisplay(labelw_good); + window = XtWindow(labelw_good); + XSelectInput(display, window, (unsigned long)StructureNotifyMask); + tet_infoline("PREP: Unmap labelw_good widget"); + XtUnmapWidget(labelw_good); + FORK(pid2); + tet_infoline("TEST: UnmapNotify event generated for widget"); + analyse_events(click_quit); + KROF(pid); + status = avs_get_event(1); + check_dec(1, status, "UnmapNotify event count"); + tet_result(TET_PASS); diff --git a/xts5/Xt5/XtVaCreateManagedWidget/XtVaCreateManagedWidget.m b/xts5/Xt5/XtVaCreateManagedWidget/XtVaCreateManagedWidget.m new file mode 100644 index 00000000..e4b1cd52 --- /dev/null +++ b/xts5/Xt5/XtVaCreateManagedWidget/XtVaCreateManagedWidget.m @@ -0,0 +1,992 @@ +Copyright (c) 2005 X.Org Foundation LLC + +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 +AUTHORS OR COPYRIGHT HOLDERS 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. +$Header: /cvs/xtest/xtest/xts5/tset/Xt5/XtVaCreateManagedWidget/XtVaCreateManagedWidget.m,v 1.1 2005-02-12 14:38:14 anderson Exp $ + +Copyright (c) Applied Testing and Technology, Inc. 1993, 1994, 1995 +Copyright (c) 88open Consortium, Ltd. 1990, 1991, 1992, 1993 +All Rights Reserved. + +>># +>># Project: VSW5 +>># +>># File: tset/Xt5/XtVaCreateManagedWidget/XtVaCreateManagedWidget.m +>># +>># Description: +>># Tests for XtVaCreateManagedWidget() +>># +>># Modifications: +>># $Log: tvacrmwdt.m,v $ +>># Revision 1.1 2005-02-12 14:38:14 anderson +>># Initial revision +>># +>># Revision 8.0 1998/12/23 23:36:35 mar +>># Branch point for Release 5.0.2 +>># +>># Revision 7.0 1998/10/30 22:59:27 mar +>># Branch point for Release 5.0.2b1 +>># +>># Revision 6.0 1998/03/02 05:27:44 tbr +>># Branch point for Release 5.0.1 +>># +>># Revision 5.0 1998/01/26 03:24:18 tbr +>># Branch point for Release 5.0.1b1 +>># +>># Revision 4.0 1995/12/15 09:16:35 tbr +>># Branch point for Release 5.0.0 +>># +>># Revision 3.1 1995/12/15 01:20:34 andy +>># Prepare for GA Release +>># +>>EXTERN +#include <X11/IntrinsicP.h> +#include <X11/ConstrainP.h> +#include <X11/CoreP.h> +#include <X11/Xaw/Label.h> +#include <xt/SquareCelP.h> +#include <X11/Xaw/Form.h> +#include <AvsComp.h> +#include <AvsRectObj.h> + +XtAppContext app_ctext; +Widget topLevel, panedw, boxw1, boxw2; +Widget labelw, rowcolw, click_quit; +void XtWMH_Proc(str1, str2, str3, str4, str5, car) +String str1, str2, str3, str4, *str5; +Cardinal *car; +{ + avs_set_event(1,1); +} + +/* +** XtEMH_Proc +*/ +void XtEMH_Proc(str1, str2, str3, str4, str5, car) +String str1, str2, str3, str4, *str5; +Cardinal *car; +{ + avs_set_event(1,1); + exit(0); +} + +/* + * SquareCell.c - Square Widget + */ +#define INTERNAL_WIDTH 2 +#define INTERNAL_HEIGHT 4 +#define DEFAULT_PIXMAP_WIDTH 1 /* in cells */ +#define DEFAULT_PIXMAP_HEIGHT 1 /* in cells */ +#define DEFAULT_CELL_SIE 20 /* in pixels */ +/* values for instance variable is_drawn */ +#define DRAWN 1 +#define UNDRAWN 0 +/* modes for drawing */ +#define DRAW 1 +#define UNDRAW 0 +#define MAXLINES 10 /* max of horiz or vertical cells */ +#define SCROLLBARWIDTH 15 +#define DEFAULTWIDTH 300 /* widget size when show_all is False */ +#define offset(field) XtOffsetOf(SquareCellRec, field) +static XtResource resources[] = { + { + XtNforeground, + XtCForeground, + XtRPixel, + sizeof(Pixel), + offset(squareCell.foreground), + XtRString, + XtDefaultForeground + }, + { + XavsNtoggleCallback, + XavsCToggleCallback, + XtRCallback, + sizeof(XtPointer), + offset(squareCell.callback), + XtRCallback, + NULL + }, + { + XavsNcellSizeInPixels, + XavsCCellSizeInPixels, + XtRInt, sizeof(int), + offset(squareCell.cell_size_in_pixels), + XtRImmediate, + (XtPointer)DEFAULT_CELL_SIE + }, + { + XavsNpixmapWidthInCells, + XavsCPixmapWidthInCells, + XtRDimension, + sizeof(Dimension), + offset(squareCell.pixmap_width_in_cells), + XtRImmediate, + (XtPointer)DEFAULT_PIXMAP_WIDTH + }, + { + XavsNpixmapHeightInCells, + XavsCPixmapHeightInCells, + XtRDimension, + sizeof(Dimension), + offset(squareCell.pixmap_height_in_cells), + XtRImmediate, + (XtPointer)DEFAULT_PIXMAP_HEIGHT + }, + { + XavsNcurX, + XavsCCurX, + XtRInt, + sizeof(int), + offset(squareCell.cur_x), + XtRImmediate, + (XtPointer) 0 + }, + { + XavsNcurY, + XavsCCurY, + XtRInt, + sizeof(int), + offset(squareCell.cur_y), + XtRImmediate, + (XtPointer) 0 + }, + { + XavsNcellArray, + XavsCCellArray, + XtRString, + sizeof(String), + offset(squareCell.cell), + XtRImmediate, + (XtPointer) 0 + }, + { + XavsNshowEntireBitmap, + XavsCShowEntireBitmap, + XtRBoolean, + sizeof(Boolean), + offset(squareCell.show_all), + XtRImmediate, + (XtPointer) TRUE + }, +}; +/* Declaration of methods */ +static void Initialize(); +static void Redisplay(); +static void Destroy(); +static void Resize(); +static Boolean SetValues(); +static XtGeometryResult QueryGeometry(); +/* these Core methods not needed by SquareCell: + * + * static void ClassInitialize(); + * static void Realize(); + */ +/* the following are private functions unique to SquareCell */ +static void DrawPixmaps(), DoCell(), ChangeCellSize(); +/* the following are actions of SquareCell */ +static void DrawCell(), UndrawCell(), ToggleCell(); +/* The following are public functions of SquareCell, declared extern + * in the public include file: */ +char *SquareCellGetArray(); +static char defaultTranslations[] = + "<Btn1Down>: DrawCell() \n\ + <Btn2Down>: UndrawCell() \n\ + <Btn3Down>: ToggleCell() \n\ + <Btn1Motion>: DrawCell() \n\ + <Btn2Motion>: UndrawCell() \n\ + <Btn3Motion>: ToggleCell()"; +static XtActionsRec actions[] = { + {"DrawCell", DrawCell}, + {"UndrawCell", UndrawCell}, + {"ToggleCell", ToggleCell}, +}; +/* definition in SquareCell.h */ +static SquareCellPointInfo info; +SquareCellClassRec squareCellClassRec = { + { + /* core_class fields */ + /* superclass */ (WidgetClass) &coreClassRec, + /* class_name */ "SquareCell", + /* widget_size */ sizeof(SquareCellRec), + /* class_initialize */ NULL, + /* class_part_initialize */ NULL, + /* class_inited */ FALSE, + /* initialize */ Initialize, + /* initialize_hook */ NULL, + /* realize */ XtInheritRealize, + /* actions */ actions, + /* num_actions */ XtNumber(actions), + /* resources */ resources, + /* num_resources */ XtNumber(resources), + /* xrm_class */ NULLQUARK, + /* compress_motion */ TRUE, + /* compress_exposure */ XtExposeCompressMultiple, + /* compress_enterleave */ TRUE, + /* visible_interest */ FALSE, + /* destroy */ Destroy, + /* resize */ Resize, + /* expose */ Redisplay, + /* set_values */ SetValues, + /* set_values_hook */ NULL, + /* set_values_almost */ XtInheritSetValuesAlmost, + /* get_values_hook */ NULL, + /* accept_focus */ NULL, + /* version */ XtVersion, + /* callback_private */ NULL, + /* tm_table */ defaultTranslations, + /* query_geometry */ QueryGeometry, + /* display_accelerator */ XtInheritDisplayAccelerator, + /* extension */ NULL + }, + {/* simple_class fields */ + /* change_sensitive */ XtInheritChangeSensitive, + }, + { + /* extension */ 0, + }, +}; +WidgetClass squareCellWidgetClass = (WidgetClass) & squareCellClassRec; +static void +GetDrawGC(w) +Widget w; +{ + SquareCellWidget cw = (SquareCellWidget) w; + XGCValues values; + XtGCMask mask = GCForeground | GCBackground | GCDashOffset | + GCDashList | GCLineStyle; + /* + * Setting foreground and background to 1 and 0 looks like a + * kludge but isn't. This GC is used for drawing + * into a pixmap of depth one. Real colors are applied with a + * separate GC when the pixmap is copied into the window. + */ + values.foreground = 1; + values.background = 0; + values.dashes = 1; + values.dash_offset = 0; + values.line_style = LineOnOffDash; + cw->squareCell.draw_gc = XCreateGC(XtDisplay((Widget)cw), + cw->squareCell.big_picture, mask, &values); +} +static void +GetUndrawGC(w) +Widget w; +{ + SquareCellWidget cw = (SquareCellWidget) w; + XGCValues values; + XtGCMask mask = GCForeground | GCBackground; + /* this looks like a kludge but isn't. This GC is used for drawing + * into a pixmap of depth one. Real colors are applied as the + * pixmap is copied into the window. + */ + values.foreground = 0; + values.background = 1; + cw->squareCell.undraw_gc = XCreateGC(XtDisplay((Widget)cw), + cw->squareCell.big_picture, mask, &values); +} +static void +GetCopyGC(w) +Widget w; +{ + SquareCellWidget cw = (SquareCellWidget) w; + XGCValues values; + XtGCMask mask = GCForeground | GCBackground; + values.foreground = cw->squareCell.foreground; + values.background = cw->core.background_pixel; + cw->squareCell.copy_gc = XtGetGC((Widget)cw, mask, &values); +} +static void +Initialize(treq, tnew, args, num_args) +Widget treq, tnew; +ArgList args; +Cardinal *num_args; +{ + SquareCellWidget new = (SquareCellWidget) tnew; + new->squareCell.cur_x = 0; + new->squareCell.cur_y = 0; + /* + * Check instance values set by resources that may be invalid. + */ + if ((new->squareCell.pixmap_width_in_cells < 1) || + (new->squareCell.pixmap_height_in_cells < 1)) { + XtWarning("SquareCell: pixmapWidth and/or pixmapHeight is too small (using 10 x 10)."); + new->squareCell.pixmap_width_in_cells = 10; + new->squareCell.pixmap_height_in_cells = 10; + } + if (new->squareCell.cell_size_in_pixels < 5) { + XtWarning("SquareCell: cellSize is too small (using 5)."); + new->squareCell.cell_size_in_pixels = 5; + } + if ((new->squareCell.cur_x < 0) || (new->squareCell.cur_y < 0)) { + XtWarning("SquareCell: cur_x and cur_y must be non-negative (using 0, 0)."); + new->squareCell.cur_x = 0; + new->squareCell.cur_y = 0; + } + if (new->squareCell.cell == NULL) + new->squareCell.cell = XtCalloc( + new->squareCell.pixmap_width_in_cells * + new->squareCell.pixmap_height_in_cells, sizeof(char)); + else + new->squareCell.user_allocated = True; /* user supplied cell array */ + new->squareCell.pixmap_width_in_pixels = + new->squareCell.pixmap_width_in_cells * + new->squareCell.cell_size_in_pixels; + new->squareCell.pixmap_height_in_pixels = + new->squareCell.pixmap_height_in_cells * + new->squareCell.cell_size_in_pixels; + if (new->core.width == 0) { + if (new->squareCell.show_all == False) + new->core.width = (new->squareCell.pixmap_width_in_pixels + > DEFAULTWIDTH) ? DEFAULTWIDTH : + (new->squareCell.pixmap_width_in_pixels); + else + new->core.width = new->squareCell.pixmap_width_in_pixels; + } + if (new->core.height == 0) { + if (new->squareCell.show_all == False) + new->core.height = + (new->squareCell.pixmap_height_in_pixels > + DEFAULTWIDTH) ? DEFAULTWIDTH : + (new->squareCell.pixmap_height_in_pixels); + else + new->core.height = new->squareCell.pixmap_height_in_pixels; + } + CreateBigPixmap(new); + GetDrawGC(new); + GetUndrawGC(new); + GetCopyGC(new); + DrawIntoBigPixmap(new); +} +static void +Redisplay(w, event) +Widget w; +XExposeEvent *event; +{ + SquareCellWidget cw = (SquareCellWidget) w; + register int x, y; + unsigned int width, height; + if (!XtIsRealized((Widget)cw)) + return; + if (event) { /* called from btn-event or expose */ + x = event->x; + y = event->y; + width = event->width; + height = event->height; + } + else { /* called because complete redraw */ + x = 0; + y = 0; + width = cw->squareCell.pixmap_width_in_pixels; + height = cw->squareCell.pixmap_height_in_pixels; + } + if (DefaultDepthOfScreen(XtScreen((Widget)cw)) == 1) + XCopyArea(XtDisplay((Widget)cw), cw->squareCell.big_picture, + XtWindow((Widget)cw), cw->squareCell.copy_gc, x + + cw->squareCell.cur_x, y + cw->squareCell.cur_y, + width, height, x, y); + else + XCopyPlane(XtDisplay((Widget)cw), cw->squareCell.big_picture, + XtWindow((Widget)cw), cw->squareCell.copy_gc, x + + cw->squareCell.cur_x, y + cw->squareCell.cur_y, + width, height, x, y, 1); +} +static Boolean +SetValues(current, request, new, args, num_args) +Widget current, request, new; +ArgList args; +Cardinal *num_args; +{ + SquareCellWidget curcw = (SquareCellWidget) current; + SquareCellWidget newcw = (SquareCellWidget) new; + Boolean do_redisplay = False; + /* + ** XtSetValues invoked procedure SetValues + */ + if (curcw->squareCell.foreground != newcw->squareCell.foreground) { + XtReleaseGC((Widget)curcw, curcw->squareCell.copy_gc); + GetCopyGC(newcw); + do_redisplay = True; + } + if ((curcw->squareCell.cur_x != newcw->squareCell.cur_x) || + (curcw->squareCell.cur_y != newcw->squareCell.cur_y)) + do_redisplay = True; + if (curcw->squareCell.cell_size_in_pixels != + newcw->squareCell.cell_size_in_pixels) { + ChangeCellSize(curcw, newcw->squareCell.cell_size_in_pixels); + do_redisplay = True; + } + if (curcw->squareCell.pixmap_width_in_cells != + newcw->squareCell.pixmap_width_in_cells) { + newcw->squareCell.pixmap_width_in_cells = + curcw->squareCell.pixmap_width_in_cells; + XtWarning("SquareCell: pixmap_width_in_cells cannot be set by XtSetValues.\n"); + } + if (curcw->squareCell.pixmap_height_in_cells != + newcw->squareCell.pixmap_height_in_cells) { + newcw->squareCell.pixmap_height_in_cells = + curcw->squareCell.pixmap_height_in_cells; + XtWarning("SquareCell: pixmap_height_in_cells cannot be set by XtSetValues.\n"); + } + return do_redisplay; +} +static void +Destroy(w) +Widget w; +{ + SquareCellWidget cw = (SquareCellWidget) w; + if (cw->squareCell.big_picture) + XFreePixmap(XtDisplay(cw), cw->squareCell.big_picture); + if (cw->squareCell.draw_gc) + XFreeGC(XtDisplay(cw), cw->squareCell.draw_gc); + if (cw->squareCell.undraw_gc) + XFreeGC(XtDisplay(cw), cw->squareCell.undraw_gc); + if (cw->squareCell.copy_gc) + XFreeGC(XtDisplay(cw), cw->squareCell.copy_gc); + /* Free memory allocated with Calloc. This was done + * only if application didn't supply cell array. + */ + if (!cw->squareCell.user_allocated) + XtFree((char *)cw->squareCell.cell); +} +static void +DrawCell(w, event) +Widget w; +XEvent *event; +{ + SquareCellWidget cw = (SquareCellWidget) w; + DrawPixmaps(cw->squareCell.draw_gc, DRAW, cw, event); +} +static void +UndrawCell(w, event) +Widget w; +XEvent *event; +{ + SquareCellWidget cw = (SquareCellWidget) w; + DrawPixmaps(cw->squareCell.undraw_gc, UNDRAW, cw, event); +} +static void +ToggleCell(w, event) +Widget w; +XEvent *event; +{ + SquareCellWidget cw = (SquareCellWidget) w; + static int oldx = -1, oldy = -1; + GC gc; + int mode; + int newx, newy; + /* This is strictly correct, but doesn't + * seem to be necessary */ + if (event->type == ButtonPress) { + newx = (cw->squareCell.cur_x + ((XButtonEvent *)event)->x) / + cw->squareCell.cell_size_in_pixels; + newy = (cw->squareCell.cur_y + ((XButtonEvent *)event)->y) / + cw->squareCell.cell_size_in_pixels; + } + else { + newx = (cw->squareCell.cur_x + ((XMotionEvent *)event)->x) / + cw->squareCell.cell_size_in_pixels; + newy = (cw->squareCell.cur_y + ((XMotionEvent *)event)->y) / + cw->squareCell.cell_size_in_pixels; + } + if ((mode = cw->squareCell.cell[newx + newy * cw->squareCell.pixmap_width_in_cells]) == DRAWN) { + gc = cw->squareCell.undraw_gc; + mode = UNDRAW; + } + else { + gc = cw->squareCell.draw_gc; + mode = DRAW; + } + if (oldx != newx || oldy != newy) { + oldx = newx; + oldy = newy; + DrawPixmaps(gc, mode, cw, event); + } +} +static void +DrawPixmaps(gc, mode, w, event) +GC gc; +int mode; +Widget w; +XButtonEvent *event; +{ + SquareCellWidget cw = (SquareCellWidget) w; + int newx = (cw->squareCell.cur_x + event->x) / + cw->squareCell.cell_size_in_pixels; + int newy = (cw->squareCell.cur_y + event->y) / + cw->squareCell.cell_size_in_pixels; + XExposeEvent fake_event; + /* if already done, return */ + if (cw->squareCell.cell[newx + newy * cw->squareCell.pixmap_width_in_cells] == mode) + return; + /* otherwise, draw or undraw */ + XFillRectangle(XtDisplay((Widget)cw), cw->squareCell.big_picture, gc, + cw->squareCell.cell_size_in_pixels*newx + 2, + cw->squareCell.cell_size_in_pixels*newy + 2, + (unsigned int)cw->squareCell.cell_size_in_pixels - 3, + (unsigned int)cw->squareCell.cell_size_in_pixels - 3); + cw->squareCell.cell[newx + newy * cw->squareCell.pixmap_width_in_cells] = mode; + info.mode = mode; + info.newx = newx; + info.newy = newy; + fake_event.x = cw->squareCell.cell_size_in_pixels * newx - cw->squareCell.cur_x; + fake_event.y = cw->squareCell.cell_size_in_pixels * newy - cw->squareCell.cur_y; + fake_event.width = cw->squareCell.cell_size_in_pixels; + fake_event.height = cw->squareCell.cell_size_in_pixels; + Redisplay(cw, &fake_event); + XtCallCallbacks((Widget)cw, XavsNtoggleCallback, &info); +} +CreateBigPixmap(w) +Widget w; +{ + SquareCellWidget cw = (SquareCellWidget) w; + /* always a 1 bit deep pixmap, regardless of screen depth */ + cw->squareCell.big_picture = XCreatePixmap(XtDisplay(cw), + RootWindow(XtDisplay(cw), DefaultScreen(XtDisplay(cw))), + cw->squareCell.pixmap_width_in_pixels + 2, + cw->squareCell.pixmap_height_in_pixels + 2, 1); +} +DrawIntoBigPixmap(w) +Widget w; +{ + SquareCellWidget cw = (SquareCellWidget) w; + int n_horiz_segments, n_vert_segments; + XSegment segment[MAXLINES]; + register int x, y; + XFillRectangle(XtDisplay(cw), cw->squareCell.big_picture, + cw->squareCell.undraw_gc, 0, 0, + cw->squareCell.pixmap_width_in_pixels + + 2, cw->squareCell.pixmap_height_in_pixels + 2); + n_horiz_segments = cw->squareCell.pixmap_height_in_cells + 1; + n_vert_segments = cw->squareCell.pixmap_width_in_cells + 1; + for (x = 0; x < n_horiz_segments; x++) { + segment[x].x1 = 0; + segment[x].x2 = (short) cw->squareCell.pixmap_width_in_pixels; + segment[x].y1 = (short) cw->squareCell.cell_size_in_pixels * x; + segment[x].y2 = (short) cw->squareCell.cell_size_in_pixels * x; + } + XDrawSegments(XtDisplay(cw), cw->squareCell.big_picture, cw->squareCell.draw_gc, segment, n_horiz_segments); + for (y = 0; y < n_vert_segments; y++) { + segment[y].x1 = (short) y * cw->squareCell.cell_size_in_pixels; + segment[y].x2 = (short) y * cw->squareCell.cell_size_in_pixels; + segment[y].y1 = 0; + segment[y].y2 = (short) cw->squareCell.pixmap_height_in_pixels; + } + XDrawSegments(XtDisplay(cw), cw->squareCell.big_picture, cw->squareCell.draw_gc, segment, n_vert_segments); + /* draw current cell array into pixmap */ + for (x = 0; x < cw->squareCell.pixmap_width_in_cells; x++) { + for (y = 0; y < cw->squareCell.pixmap_height_in_cells; y++) { + if (cw->squareCell.cell[x + (y * cw->squareCell.pixmap_width_in_cells)] == DRAWN) + DoCell(cw, x, y, cw->squareCell.draw_gc); + else + DoCell(cw, x, y, cw->squareCell.undraw_gc); + } + } +} +/* A Public function, not static */ +char * +SquareCellGetArray(w, width_in_cells, height_in_cells) +Widget w; +int *width_in_cells, *height_in_cells; +{ + SquareCellWidget cw = (SquareCellWidget) w; + *width_in_cells = cw->squareCell.pixmap_width_in_cells; + *height_in_cells = cw->squareCell.pixmap_height_in_cells; + return (cw->squareCell.cell); +} +static void +Resize(w) +Widget w; +{ + SquareCellWidget cw = (SquareCellWidget) w; + /* resize does nothing unless new size is bigger than entire pixmap */ + if ((cw->core.width > cw->squareCell.pixmap_width_in_pixels) && + (cw->core.height > cw->squareCell.pixmap_height_in_pixels)) { + /* + * Calculate the maximum cell size that will allow the + * entire bitmap to be displayed. + */ + Dimension w_temp_cell_size_in_pixels, h_temp_cell_size_in_pixels; + Dimension new_cell_size_in_pixels; + + w_temp_cell_size_in_pixels = cw->core.width / cw->squareCell.pixmap_width_in_cells; + h_temp_cell_size_in_pixels = cw->core.height / cw->squareCell.pixmap_height_in_cells; + + if (w_temp_cell_size_in_pixels < h_temp_cell_size_in_pixels) + new_cell_size_in_pixels = w_temp_cell_size_in_pixels; + else + new_cell_size_in_pixels = h_temp_cell_size_in_pixels; + + /* if size change mandates a new pixmap, make one */ + if (new_cell_size_in_pixels != cw->squareCell.cell_size_in_pixels) + ChangeCellSize(cw, new_cell_size_in_pixels); + } +} +static void +ChangeCellSize(w, new_cell_size) +Widget w; +int new_cell_size; +{ + SquareCellWidget cw = (SquareCellWidget) w; + int x, y; + cw->squareCell.cell_size_in_pixels = new_cell_size; + /* recalculate variables based on cell size */ + cw->squareCell.pixmap_width_in_pixels = + cw->squareCell.pixmap_width_in_cells * + cw->squareCell.cell_size_in_pixels; + cw->squareCell.pixmap_height_in_pixels = + cw->squareCell.pixmap_height_in_cells * + cw->squareCell.cell_size_in_pixels; + + /* destroy old and create new pixmap of correct size */ + XFreePixmap(XtDisplay(cw), cw->squareCell.big_picture); + CreateBigPixmap(cw); + + /* draw lines into new pixmap */ + DrawIntoBigPixmap(cw); + + /* draw current cell array into pixmap */ + for (x = 0; x < cw->squareCell.pixmap_width_in_cells; x++) { + for (y = 0; y < cw->squareCell.pixmap_height_in_cells; y++) { + if (cw->squareCell.cell[x + (y * cw->squareCell.pixmap_width_in_cells)] == DRAWN) + DoCell(cw, x, y, cw->squareCell.draw_gc); + else + DoCell(cw, x, y, cw->squareCell.undraw_gc); + } + } +} +static void +DoCell(w, x, y, gc) +Widget w; +int x, y; +GC gc; +{ + SquareCellWidget cw = (SquareCellWidget) w; + /* otherwise, draw or undraw */ + XFillRectangle(XtDisplay(cw), cw->squareCell.big_picture, gc, + cw->squareCell.cell_size_in_pixels * x + 2, + cw->squareCell.cell_size_in_pixels * y + 2, + (unsigned int)cw->squareCell.cell_size_in_pixels - 3, + (unsigned int)cw->squareCell.cell_size_in_pixels - 3); +} +static XtGeometryResult QueryGeometry(w, proposed, answer) +Widget w; +XtWidgetGeometry *proposed, *answer; +{ + SquareCellWidget cw = (SquareCellWidget) w; + /* set fields we care about */ + answer->request_mode = CWWidth | CWHeight; + /* initial width and height */ + if (cw->squareCell.show_all == True) + answer->width = cw->squareCell.pixmap_width_in_pixels; + else + answer->width = (cw->squareCell.pixmap_width_in_pixels > + DEFAULTWIDTH) ? DEFAULTWIDTH : + cw->squareCell.pixmap_width_in_pixels; + if (cw->squareCell.show_all == True) + answer->height = cw->squareCell.pixmap_height_in_pixels; + else + answer->height = (cw->squareCell.pixmap_height_in_pixels > + DEFAULTWIDTH) ? DEFAULTWIDTH : + cw->squareCell.pixmap_height_in_pixels; + if ( ((proposed->request_mode & (CWWidth | CWHeight)) + == (CWWidth | CWHeight)) && + proposed->width == answer->width && + proposed->height == answer->height) + return XtGeometryYes; + else if (answer->width == cw->core.width && + answer->height == cw->core.height) + return XtGeometryNo; + else + return XtGeometryAlmost; +} +>>SET tpstartup avs_alloc_sem +>>SET tpcleanup avs_free_sem +>>TITLE XtVaCreateManagedWidget Xt5 +Widget +XtVaCreateManagedWidget(name, widget_class, parent, ...) +>>ASSERTION Good A +A call to +Widget XtVaCreateManagedWidget(name, widget_class, parent, ...) +shall create an instance of a widget belonging to the class +widget_class, set the widget to be managed by its parent, and return +a pointer to the newly created widget instance structure. +>>CODE +Boolean status; +Widget widget_good , labelw_good; +Widget rowcolw_good; + + avs_xt_hier("Tvacrmwdt1", "XtVaCreateManagedWidget"); + tet_infoline("PREP: Create rowcolw_good widget in box1w widget"); + rowcolw_good = (Widget) CreateRowColWidget(boxw1); + tet_infoline("PREP: Create label widget Hello"); + labelw_good = XtVaCreateManagedWidget( + "Hello", + labelWidgetClass, + rowcolw_good, + (char *)NULL); + tet_infoline("PREP: Create windows for widgets and map them"); + XtRealizeWidget(topLevel); + tet_infoline("TEST: Labelw_good widget is managed"); + status = XtIsManaged(labelw_good); + check_dec(True, status, "XtIsManaged return value"); + tet_infoline("TEST: Labelw_good widget is child of rowcolumn widget"); + widget_good = (Widget)XtParent(labelw_good); + if (widget_good == NULL) { + sprintf(ebuf, "ERROR: Expected parent widget instance returned NULL"); + tet_infoline(ebuf); + tet_result(TET_FAIL); + } + check_str("rowcolw", XtName(widget_good), "widget name"); + tet_result(TET_PASS); +>>ASSERTION Good A +A successful call to +Widget XtVaCreateManagedWidget(name, widget_class, parent, ...) +shall initialize the resource fields of the widget instance using the +the CoreClassPart resource list specified for widget_class and all +superclasses, overridden by the resource values specified in the varargs style +arguments. +>>CODE +Boolean value_good; +char string[10]; +Widget squarew; +Dimension cell_width, cell_height; + + avs_xt_hier("Tvcrtwdgt2", "XtVaCreateManagedWidget"); + tet_infoline("TEST: Create Square Cell widget"); + squarew = XtVaCreateManagedWidget("squarew", + squareCellWidgetClass, + boxw1, + NULL + ); + tet_infoline("PREP: Get resource values"); + XtVaGetValues(squarew, + XavsNpixmapWidthInCells, + &cell_width, + XavsNpixmapHeightInCells, + &cell_height, + (char *)NULL); + tet_infoline("TEST: Original values returned"); + check_dec(DEFAULT_PIXMAP_WIDTH, cell_width, + "XavsNpixmapWidthInCells"); + check_dec(DEFAULT_PIXMAP_HEIGHT, cell_height, + "XavsNpixmapHeightInCells"); + tet_result(TET_PASS); +>>ASSERTION Good A +When parent is a subclass of constraintWidgetClass a successful call to Widget +Widget XtVaCreateManagedWidget(name, widget_class, parent, ...) +shall initialize the resource fields of the constraint record by +using the constraint resource list specified for the parent's class +and all superclasses up to constraintWidgetClass, overridden by the resource +values specified in the varargs style arguments. +>>CODE +Boolean value_good; +char string[10]; +Widget formw_good, labelw_msg; +char *msg = "Failsafe widget"; +Widget labelw_good; +Boolean resizable; + + avs_xt_hier("Tvcrtwdgt3", "XtVaCreateManagedWidget"); + tet_infoline("PREP: Create formw_good widget subclass of constraintWidgetClass"); + formw_good = (Widget) CreateFormWidget(boxw1); + tet_infoline("PREP: Create failsafe widget in formw_good"); + labelw_msg = (Widget) CreateLabelWidget(msg, formw_good); + tet_infoline("TEST: Create labelw_good widget Hello"); + labelw_good = XtVaCreateManagedWidget( + "Hello", + labelWidgetClass, + formw_good, + XtNresizable, + TRUE, + NULL + ); + tet_infoline("PREP: Create windows for widgets and map them"); + XtRealizeWidget(topLevel); + tet_infoline("PREP: Get XtNresizable constraint resource value."); + XtVaGetValues(labelw_good, XtNresizable, &resizable, (char *)NULL); + tet_infoline("TEST: XtNresizable resource value"); + check_dec(TRUE, resizable, "XtNresizable resource"); + tet_result(TET_PASS); +>>ASSERTION Good B 0 +When parent is a subclass of compositeWidgetClass a successful call to +Widget XtVaCreateManagedWidget(name, widget_class, parent, ...) +shall call the insert_child procedure of the parent. +>>ASSERTION Good A +A call to +Widget XtVaCreateManagedWidget(name, widget_class, parent, ...) +when widget_class is not a member of coreWidgetClass, the class +of parent is a subclass of compositeWidgetClass, and there is no extension +record in the composite class part extension field of parent with the +record_type equal to NULLQUARK shall issue a fatal error. +>>CODE +Boolean value_good; +char string[10]; +Widget test_widget, test_widget2; +int status; +pid_t pid2; + + FORK(pid2); + avs_xt_hier("Tcrwidget5", "XtCreateManagerWidget"); + tet_infoline("PREP: Register error message handler"); + XtAppSetErrorMsgHandler(app_ctext, XtEMH_Proc); + tet_infoline("TEST: Create composite widget"); + test_widget = XtCreateWidget( + "Composite", + avsCompWidgetClass, + topLevel, + NULL, + 0 + ); + tet_infoline("PREP: Create rect obj in it"); + test_widget2 = XtVaCreateManagedWidget( + "RectObj", + avsrectObjClass, + test_widget, + (ArgList)NULL + ); + KROF(pid2); + tet_infoline("TEST: Error handler was invoked"); + status = avs_get_event(1); + check_dec(1, status , "handler invocations count"); + tet_result(TET_PASS); +>>ASSERTION Good B 0 +A call to +Widget XtVaCreateManagedWidget(name, widget_class, parent, ...) +when widget_class is not a member of coreWidgetClass, the class of +parent is a subclass of compositeWidgetClass, and the accepts_object +field in the parent's composite class part extension record is False shall +issue a fatal error. +>>ASSERTION Good B 0 +A successful call to +Widget XtVaCreateManagedWidget(name, widget_class, parent, ...) +shall invoke the class_initialize procedure for the class +widget_class and all superclasses for which this procedure has not been +invoked prior to this call in a superclass-to-subclass order. +>>ASSERTION Good B 0 +A successful call to +Widget XtVaCreateManagedWidget(name, widget_class, parent, ...) +when parent belongs to the class constraintWidgetClass or a +subclass thereof shall allocate memory for the constraints of parent +and store the address of this memory in the constraints field of the +widget instance structure. +>>ASSERTION Good B 0 +A successful call to +Widget XtVaCreateManagedWidget(name, widget_class, parent, ...) +shall initialize the Core non-resource data fields of the widget instance +structure. +>>ASSERTION Good B 0 +A successful call to +Widget XtVaCreateManagedWidget(name, widget_class, parent, ...) +shall call the initialize procedure of Object and all +the initialize procedures down to initialize procedure of the widget. +>>ASSERTION Good B 0 +A successful call to +Widget XtVaCreateManagedWidget(name, widget_class, parent, ...) +when parent belongs to the class contraintWidgetClass +or a subclass thereof shall call all the ConstraintClassPart initialize +procedures starting at constraintWidgetClass down to ConstraintClassPart +initialize procedure of the parent. +>>ASSERTION Good B 0 +A successful call to +Widget XtVaCreateManagedWidget(name, widget_class, parent, ...) +when the varargs style argument specifies the name XtVaTypedArg in place of +a resource name and the second argument following this name is XtRString shall +initialize the resource specified by the first argument following the +XtVaTypedArg name to the string pointed to by the third argument of a length +specified by the fourth argument following the XtVaTypedArg name argument. +>>ASSERTION Good B 0 +A successful call to +Widget XtVaCreateManagedWidget(name, widget_class, parent, ...) +when the varargs style argument specifies the name XtVaTypedArg in place of +a resource name, the second argument following this name is not XtRString, and +the fourth argument is less than sizeof(XtArgVal) shall +initialize the resource specified by the first argument following the +XtVaTypedArg name to the value specified in the third argument following the +XtVaTypedArg name argument. +>>ASSERTION Good B 0 +A successful call to +Widget XtVaCreateManagedWidget(name, widget_class, parent, ...) +when the varargs style argument specifies the name XtVaTypedArg in place of +a resource name, the second argument following this argument is not XtRString, +and the fourth argument is more than sizeof(XtArgVal) shall initialize the +resource specified by the first argument following the XtVaTypedArg name to +the value pointed to by the third argument following the XtVaTypedArg name +argument. +>>ASSERTION Good B 0 +A call to +Widget XtVaCreateManagedWidget(name, widget_class, parent, ...) +when the varargs style argument specifies the name XtVaTypedArg in place of +a resource name and the type conversion fails during the resource initialization +using the arguments following the XtVaTypedArg argument shall issue a warning +message. +>>ASSERTION Good B 0 +A call to +Widget XtVaCreateManagedWidget(name, widget_class, parent, ...) +when the newly created widget has the map_when_managed field set to True and +parent is realized shall call the change_managed procedure of the parent, +realize the widget, and map the widget window. +>>ASSERTION Good B 0 +On a successful call to +Widget XtVaCreateManagedWidget(name, widget_class, parent, ...) +when the newly created widget has the map_when_managed field set to a value +other than True shall not have its window mapped. +>>ASSERTION Good A +A call to +Widget XtVaCreateManagedWidget(name, widget_class, parent, ...) +when parent does not belong to a subclass of compositeWidgetClass shall issue +an invalidParent error. +>>CODE +Boolean status; +Widget labelw_good, labelw_good2, test_widget; +pid_t pid2; +int invoked; + + FORK(pid2); + avs_xt_hier("Tvacrmwdt", "XtVaCreateManagedWidget"); + XtAppSetErrorMsgHandler(app_ctext, XtEMH_Proc); + tet_infoline("PREP: Create test widgets"); + labelw_good = XtVaCreateWidget( + "labelw_good", + coreWidgetClass, + boxw1, + NULL + ); + (void) ConfigureDimension(topLevel, labelw_good); + tet_infoline("PREP: Create windows for widgets and map them"); + XtRealizeWidget(topLevel); + tet_infoline("TEST: Create a widget with non-composite parent"); + labelw_good2 = XtVaCreateManagedWidget( + "labelw_good2", + coreWidgetClass, + labelw_good, + NULL + ); + LKROF(pid2, AVSXTTIMEOUT-2); + tet_infoline("TEST: Error handler was invoked"); + invoked = avs_get_event(1); + if (!invoked) { + sprintf(ebuf, "ERROR: Error handler was not invoked"); + tet_infoline(ebuf); + tet_result(TET_FAIL); + } + tet_result(TET_PASS); +>>ASSERTION Good B 0 +A call to +Widget XtVaCreateManagedWidget(name, widget_class, parent, ...) +when parent is in the process of being destroyed shall return immediately. |