From f2ec5d37bb3e769fe75dd9a0ebd90ed8e5799864 Mon Sep 17 00:00:00 2001 From: mdejong Date: Mon, 27 May 2002 17:33:26 +0000 Subject: * tests/embed.test: Added cross platform embed tests. Check that window passed to -use has the -container option set. * tests/wm.test: Remove useless catch call. Deiconify . just in case, stackorder tests will not pass unless it is in the normal state. Add -container flag to embedded stackorder test. * unix/tkUnixEmbed.c (TkpUseWindow): * win/tkWinEmbed.c (TkpUseWindow): Lookup Tk window based on the id passed in as the value for -use. Generate an error if the Tk window did not have the -container option set. --- ChangeLog | 15 +++++++++++++++ tests/embed.test | 51 +++++++++++++++++++++++++++++++++++++++++++++++++++ tests/wm.test | 10 +++++++--- unix/tkUnixEmbed.c | 12 +++++++++++- win/tkWinEmbed.c | 12 +++++++++++- 5 files changed, 95 insertions(+), 5 deletions(-) create mode 100644 tests/embed.test diff --git a/ChangeLog b/ChangeLog index 7c50e26..f1c1e06 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,18 @@ +2002-05-27 Mo DeJong + + * tests/embed.test: Added cross platform embed tests. + Check that window passed to -use has the -container + option set. + * tests/wm.test: Remove useless catch call. Deiconify + . just in case, stackorder tests will not pass unless + it is in the normal state. Add -container flag to + embedded stackorder test. + * unix/tkUnixEmbed.c (TkpUseWindow): + * win/tkWinEmbed.c (TkpUseWindow): Lookup Tk window + based on the id passed in as the value for -use. + Generate an error if the Tk window did not have + the -container option set. + 2002-05-26 Peter Spjuth * generic/tkButton.c (ConfigureButton): When creating diff --git a/tests/embed.test b/tests/embed.test new file mode 100644 index 0000000..f19583a --- /dev/null +++ b/tests/embed.test @@ -0,0 +1,51 @@ +# This file is a Tcl script to test out embedded Windows. +# +# Copyright (c) 1996-1997 Sun Microsystems, Inc. +# Copyright (c) 1998-1999 by Scriptics Corporation. +# All rights reserved. +# +# RCS: @(#) $Id: embed.test,v 1.1 2002/05/27 17:33:26 mdejong Exp $ + +if {[lsearch [namespace children] ::tcltest] == -1} { + source [file join [pwd] [file dirname [info script]] defs.tcl] +} + +proc deleteWindows {} { + foreach i [winfo children .] { + destroy $i + } +} + +test embed-1.1 {TkpUseWindow procedure, bad window identifier} { + deleteWindows + list [catch {toplevel .t -use xyz} msg] $msg +} {1 {expected integer but got "xyz"}} + +test embed-1.2 {CreateFrame procedure, bad window identifier} { + deleteWindows + list [catch {toplevel .t -container xyz} msg] $msg +} {1 {expected boolean value but got "xyz"}} + +test embed-1.3 {CreateFrame procedure, both -use and + -container is invalid } { + deleteWindows + toplevel .container -container 1 + list [catch {toplevel .t -use [winfo id .container] \ + -container 1} msg] $msg +} {1 {A window cannot have both the -use and the -container option set.}} + +test embed-1.4 {TkpUseWindow procedure, -container must be set} { + deleteWindows + toplevel .container + list [catch {toplevel .embd -use [winfo id .container]} err] $err +} {1 {window ".container" doesn't have -container option set}} + +test embed-1.5 {TkpUseWindow procedure, -container must be set} { + deleteWindows + frame .container + list [catch {toplevel .embd -use [winfo id .container]} err] $err +} {1 {window ".container" doesn't have -container option set}} + + +# FIXME: test cases common to unixEmbed.test and macEmbed.test should +# be moved here. diff --git a/tests/wm.test b/tests/wm.test index 0665bcc..2dea668 100644 --- a/tests/wm.test +++ b/tests/wm.test @@ -7,7 +7,7 @@ # Copyright (c) 1998-1999 by Scriptics Corporation. # All rights reserved. # -# RCS: @(#) $Id: wm.test,v 1.5 2002/05/24 09:50:11 mdejong Exp $ +# RCS: @(#) $Id: wm.test,v 1.6 2002/05/27 17:33:26 mdejong Exp $ # This file tests window manager interactions that work across # platforms. Window manager tests that only work on a specific @@ -20,13 +20,14 @@ if {[lsearch [namespace children] ::tcltest] == -1} { proc deleteWindows {} { foreach i [winfo children .] { - catch [destroy $i] + destroy $i } } deleteWindows +wm deicon . test wm-stackorder-1.1 {usage} { list [catch {wm stackorder} err] $err @@ -296,7 +297,7 @@ test wm-stackorder-5.3 {An overrideredirect window test wm-stackorder-6.1 {An embedded toplevel does not appear in the stacking order} { deleteWindows - toplevel .real + toplevel .real -container 1 toplevel .embd -bg blue -use [winfo id .real] update wm stackorder . @@ -351,6 +352,9 @@ test wm-transient-1.6 {usage} { # if the window was raised after a button click for example. # This sort of testing may not be possible. + +deleteWindows + return diff --git a/unix/tkUnixEmbed.c b/unix/tkUnixEmbed.c index e996a0b..5a64713 100644 --- a/unix/tkUnixEmbed.c +++ b/unix/tkUnixEmbed.c @@ -11,7 +11,7 @@ * See the file "license.terms" for information on usage and redistribution * of this file, and for a DISCLAIMER OF ALL WARRANTIES. * - * RCS: @(#) $Id: tkUnixEmbed.c,v 1.3 1999/04/16 01:51:46 stanton Exp $ + * RCS: @(#) $Id: tkUnixEmbed.c,v 1.4 2002/05/27 17:33:26 mdejong Exp $ */ #include "tkInt.h" @@ -105,6 +105,7 @@ TkpUseWindow(interp, tkwin, string) * for tkwin; must be an integer value. */ { TkWindow *winPtr = (TkWindow *) tkwin; + TkWindow *usePtr; int id, anyError; Window parent; Tk_ErrorHandler handler; @@ -121,6 +122,15 @@ TkpUseWindow(interp, tkwin, string) } parent = (Window) id; + usePtr = (TkWindow *) Tk_IdToWindow(winPtr->display, parent); + if (usePtr != NULL) { + if (!(usePtr->flags & TK_CONTAINER)) { + Tcl_AppendResult(interp, "window \"", usePtr->pathName, + "\" doesn't have -container option set", (char *) NULL); + return TCL_ERROR; + } + } + /* * Tk sets the window colormap to the screen default colormap in * tkWindow.c:AllocWindow. This doesn't work well for embedded diff --git a/win/tkWinEmbed.c b/win/tkWinEmbed.c index 6fdcfc6..0c3f33a 100644 --- a/win/tkWinEmbed.c +++ b/win/tkWinEmbed.c @@ -11,7 +11,7 @@ * See the file "license.terms" for information on usage and redistribution * of this file, and for a DISCLAIMER OF ALL WARRANTIES. * - * RCS: @(#) $Id: tkWinEmbed.c,v 1.4 2000/07/06 03:17:44 mo Exp $ + * RCS: @(#) $Id: tkWinEmbed.c,v 1.5 2002/05/27 17:33:26 mdejong Exp $ */ #include "tkWinInt.h" @@ -148,6 +148,7 @@ TkpUseWindow(interp, tkwin, string) * for tkwin; must be an integer value. */ { TkWindow *winPtr = (TkWindow *) tkwin; + TkWindow *usePtr; int id; HWND hwnd; Container *containerPtr; @@ -177,6 +178,15 @@ TkpUseWindow(interp, tkwin, string) return TCL_ERROR; } + usePtr = (TkWindow *) Tk_HWNDToWindow(hwnd); + if (usePtr != NULL) { + if (!(usePtr->flags & TK_CONTAINER)) { + Tcl_AppendResult(interp, "window \"", usePtr->pathName, + "\" doesn't have -container option set", (char *) NULL); + return TCL_ERROR; + } + } + /* * Store the parent window in the platform private data slot so * TkWmMapWindow can use it when creating the wrapper window. -- cgit v0.12