From 96cf871d54db54453e7e29dca5a64b7da157a22f Mon Sep 17 00:00:00 2001 From: patthoyts Date: Mon, 14 Apr 2008 20:48:50 +0000 Subject: Fixed bug #1941740: tk_chooseColor -title was broken in revision 1.40 after some code cleanup. Added tests for this windows dialog to avoid regression. --- ChangeLog | 6 ++++ tests/winDialog.test | 80 ++++++++++++++++++++++++++++++++++++++++++++++++---- win/tkWinDialog.c | 6 ++-- win/tkWinTest.c | 5 +++- 4 files changed, 89 insertions(+), 8 deletions(-) diff --git a/ChangeLog b/ChangeLog index 610e634..288b1a4 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +2008-04-14 Pat Thoyts + + * win/tkWinDialog.c: Fix bug #1941740: tk_chooseColor -title broken + * win/tkWinTest.c: Added parent to testgetwininfo + * tests/winDialog.test: Created some tk_chooseColor win tests. + 2008-04-09 Jan Nijtmans * generic/tkImgGIF.c: Let the GIF writer use a real LZW compressor. diff --git a/tests/winDialog.test b/tests/winDialog.test index d4e24e5..2ba2873 100644 --- a/tests/winDialog.test +++ b/tests/winDialog.test @@ -6,7 +6,7 @@ # Copyright (c) 1998-1999 by Scriptics Corporation. # Copyright (c) 1998-1999 ActiveState Corporation. # -# RCS: @(#) $Id: winDialog.test,v 1.15 2007/12/13 15:27:55 dgp Exp $ +# RCS: @(#) $Id: winDialog.test,v 1.16 2008/04/14 20:48:50 patthoyts Exp $ package require tcltest 2.1 eval tcltest::configure $argv @@ -57,10 +57,80 @@ proc SetText {button text} { return [testwinevent $::tk_dialog $button WM_SETTEXT $text] } -test winDialog-1.1 {Tk_ChooseColorObjCmd} {nt} { -} {} - -test winDialog-2.1 {ColorDlgHookProc} {nt} { +test winDialog-1.1.0 {Tk_ChooseColorObjCmd} -constraints { + testwinevent +} -body { + start {tk_chooseColor} + then { + Click cancel + } +} -result {0} +test winDialog-1.1.1 {Tk_ChooseColorObjCmd} -constraints { + testwinevent +} -body { + start {set clr [tk_chooseColor -initialcolor "#ff9933"]} + then { + set x [Click cancel] + } + list $x $clr +} -result {0 {}} +test winDialog-1.1.2 {Tk_ChooseColorObjCmd} -constraints { + testwinevent +} -body { + start {set clr [tk_chooseColor -initialcolor "#ff9933"]} + then { + set x [Click 1] + } + list $x $clr +} -result [list 0 "#ff9933"] +test winDialog-1.1.3 {Tk_ChooseColorObjCmd: -title} -constraints { + testwinevent +} -body { + set x {} + start {set clr [tk_chooseColor -initialcolor "#ff9933" -title "Hello"]} + then { + array set a [testgetwindowinfo $::tk_dialog] + if {[info exists a(text)]} {lappend x $a(text)} + lappend x [Click 1] + } + lappend x $clr +} -result [list Hello 0 "#ff9933"] +test winDialog-1.1.4 {Tk_ChooseColorObjCmd: -title} -constraints { + testwinevent +} -body { + set x {} + start { + set clr [tk_chooseColor -initialcolor "#ff9933" \ + -title "\u041f\u0440\u0438\u0432\u0435\u0442"] + } + then { + array set a [testgetwindowinfo $::tk_dialog] + if {[info exists a(text)]} {lappend x $a(text)} + lappend x [Click 1] + } + lappend x $clr +} -result [list "\u041f\u0440\u0438\u0432\u0435\u0442" 0 "#ff9933"] +test winDialog-1.1.5 {Tk_ChooseColorObjCmd: -parent} -constraints { + testwinevent +} -body { + start {set clr [tk_chooseColor -initialcolor "#ff9933" -parent .]} + set x {} + then { + array set a [testgetwindowinfo $::tk_dialog] + if {[info exists a(parent)]} { + append x [expr {$a(parent) == [wm frame .]}] + } + Click 1 + } + list $x $clr +} -result [list 1 "#ff9933"] +test winDialog-1.1.6 {Tk_ChooseColorObjCmd: -parent} -constraints { + testwinevent +} -body { + tk_chooseColor -initialcolor "#ff9933" -parent .xyzzy12 +} -returnCodes error -match glob -result {bad window path name*} + +test winDialog-2.1 {ColorDlgHookProc} {emptyTest nt} { } {} test winDialog-3.1 {Tk_GetOpenFileObjCmd} {nt testwinevent} { diff --git a/win/tkWinDialog.c b/win/tkWinDialog.c index ec6ede9..da88672 100644 --- a/win/tkWinDialog.c +++ b/win/tkWinDialog.c @@ -8,7 +8,7 @@ * See the file "license.terms" for information on usage and redistribution of * this file, and for a DISCLAIMER OF ALL WARRANTIES. * - * RCS: @(#) $Id: tkWinDialog.c,v 1.50 2008/01/31 23:31:02 hobbs Exp $ + * RCS: @(#) $Id: tkWinDialog.c,v 1.51 2008/04/14 20:48:50 patthoyts Exp $ * */ @@ -455,13 +455,15 @@ ColorDlgHookProc( const char *title; CHOOSECOLOR *ccPtr; - switch (uMsg) { + if (WM_INITDIALOG == uMsg) { + /* * Set the title string of the dialog. */ ccPtr = (CHOOSECOLOR *) lParam; title = (const char *) ccPtr->lCustData; + if ((title != NULL) && (title[0] != '\0')) { Tcl_DString ds; diff --git a/win/tkWinTest.c b/win/tkWinTest.c index f92a8cc..0cdcb58 100644 --- a/win/tkWinTest.c +++ b/win/tkWinTest.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: tkWinTest.c,v 1.15 2008/04/09 20:48:10 nijtmans Exp $ + * RCS: @(#) $Id: tkWinTest.c,v 1.16 2008/04/14 20:48:51 patthoyts Exp $ */ #include "tkWinInt.h" @@ -464,6 +464,9 @@ TestgetwindowinfoObjCmd( Tcl_ListObjAppendElement(interp, resObj, Tcl_NewStringObj("text", -1)); Tcl_ListObjAppendElement(interp, resObj, textObj); + Tcl_ListObjAppendElement(interp, resObj, Tcl_NewStringObj("parent", -1)); + Tcl_ListObjAppendElement(interp, resObj, + Tcl_NewLongObj((long)GetParent(hwnd))); childrenObj = Tcl_NewListObj(0, NULL); EnumChildWindows(hwnd, EnumChildrenProc, (LPARAM)childrenObj); -- cgit v0.12