diff options
author | andreask <andreask> | 2013-01-22 19:30:43 (GMT) |
---|---|---|
committer | andreask <andreask> | 2013-01-22 19:30:43 (GMT) |
commit | 48c9fcb7281cc6aa076113db874c7ae0e105795d (patch) | |
tree | 7187940ff056462bfa41705a2ce04d0ed07d424e /tests/focus.test | |
parent | 41f5d19540b0b3f053da352e1569c9a4ed019dd5 (diff) | |
download | tk-contrib_patrick_fradin_code_cleanup.zip tk-contrib_patrick_fradin_code_cleanup.tar.gz tk-contrib_patrick_fradin_code_cleanup.tar.bz2 |
Contribution by Patrick Fradin <patrick.fradin@planar.com>contrib_patrick_fradin_code_cleanup
Quoting his mail:
<pre>
==========================================================
Hi Jeff,
I spent some of my time to contribute to the TclTk community ! I'm in
late for Christmas gift but like we said in French : "Mieux vaut tard
que jamais". ;-)
I've use TclDevKit 5.3.0 tclchecker to analyse TclTk code in Tcl and
Tk library directories (library, tools and tests) to correct a lot of
warnings and few errors. (encapsulate some expr, use 'chan xxx'
instead of fconfigure, fileevent...)
I've made some improvements too :
Examples :
- Use 'lassign' instead of many 'lindex' of 'foreach/break' loop.
- Use 'in' or 'ni' operators instead of 'lsearch -exact' or to
factorise some eq/ne && / || tests.
- Use 'eq' or 'ne' to tests strings instead of '==' or '!='.
- Use 'unset -nocomplain' to avoid 'catch {unset...}'.
- Remove some useless catch around 'destroy' calls.
- Use expand {*} instead of 'eval'. Don't touch a lot of code because
I don't know all structs and lists. I think it could be a greater
improvement to reduce 'eval' calls.
Due to previous experience, I dot not change any indentation ! ;-)
==========================================================
</pre>
Diffstat (limited to 'tests/focus.test')
-rw-r--r-- | tests/focus.test | 27 |
1 files changed, 9 insertions, 18 deletions
diff --git a/tests/focus.test b/tests/focus.test index 45cf73b..3a71d3a 100644 --- a/tests/focus.test +++ b/tests/focus.test @@ -16,7 +16,7 @@ proc focusSetup {} { toplevel .t wm geom .t +0+0 foreach i {b1 b2 b3 b4} { - button .t.$i -text .t.$i -relief raised -bd 2 + button .t.$i -text .t.$i -relief raised -borderwidth 2 pack .t.$i } tkwait visibility .t.b4 @@ -26,7 +26,7 @@ proc focusSetupAlt {} { destroy .alt toplevel .alt -screen $env(TK_ALT_DISPLAY) foreach i {a b c d} { - button .alt.$i -text .alt.$i -relief raised -bd 2 + button .alt.$i -text .alt.$i -relief raised -borderwidth 2 pack .alt.$i } tkwait visibility .alt.d @@ -47,9 +47,8 @@ proc focusClear {} { update } - # Button used in some tests in the whole test file -button .b -text .b -relief raised -bd 2 +button .b -text .b -relief raised -borderwidth 2 pack .b # Make sure the window manager knows who has focus @@ -72,7 +71,6 @@ if {[testConstraint altDisplay]} { focusSetupAlt } - test focus-1.1 {Tk_FocusCmd procedure} -constraints unix -body { focusClear focus @@ -111,8 +109,8 @@ test focus-1.8 {Tk_FocusCmd procedure, focussing on dead window} -constraints { focusClear toplevel .t2 wm geom .t2 +10+10 - frame .t2.f -width 200 -height 100 -bd 2 -relief raised - frame .t2.f2 -width 200 -height 100 -bd 2 -relief raised + frame .t2.f -width 200 -height 100 -borderwidth 2 -relief raised + frame .t2.f2 -width 200 -height 100 -borderwidth 2 -relief raised pack .t2.f .t2.f2 bind .t2.f <Destroy> {focus .t2.f} bind .t2.f2 <Destroy> {focus .t2} @@ -220,7 +218,6 @@ test focus-1.25 {Tk_FocusCmd procedure} -constraints unix -body { focus -unknown } -returnCodes error -result {bad option "-unknown": must be -displayof, -force, or -lastfor} - focusSetup test focus-2.1 {TkFocusFilterEvent procedure} -constraints { unix nonPortable testwrapper @@ -455,7 +452,6 @@ test focus-2.17 {TkFocusFilterEvent procedure, Leave events} -constraints { out .t NotifyVirtual } {}} - test focus-3.1 {SetFocus procedure, create record on focus} -constraints { unix testwrapper } -body { @@ -546,7 +542,6 @@ unix nonPortable testwrapper return $focusInfo } -result {} - test focus-4.1 {TkFocusDeadWindow procedure} -constraints { unix testwrapper } -body { @@ -593,7 +588,6 @@ test focus-4.4 {TkFocusDeadWindow procedure} -constraints { } -result {.t} cleanupbg - # I don't know how to test most of the remaining procedures of this file # explicitly; they've already been exercised by the preceding tests. @@ -619,7 +613,6 @@ bind all <FocusIn> {} bind all <FocusOut> {} bind all <KeyPress> {} - fixfocus test focus-6.1 {miscellaneous - embedded application in same process} -constraints { unix testwrapper @@ -631,7 +624,7 @@ test focus-6.1 {miscellaneous - embedded application in same process} -constrain frame .t.f1 -container 1 frame .t.f2 pack .t.f1 .t.f2 - entry .t.f2.e1 -bg red + entry .t.f2.e1 -background red pack .t.f2.e1 bind all <FocusIn> {lappend x "focus in %W %d"} bind all <FocusOut> {lappend x "focus out %W %d"} @@ -639,7 +632,7 @@ test focus-6.1 {miscellaneous - embedded application in same process} -constrain child eval "set argv {-use [winfo id .t.f1]}" load {} Tk child child eval { - entry .e1 -bg lightBlue + entry .e1 -background lightBlue pack .e1 bind all <FocusIn> {lappend x "focus in %W %d"} bind all <FocusOut> {lappend x "focus out %W %d"} @@ -686,13 +679,13 @@ test focus-6.2 {miscellaneous - embedded application in different process} -cons frame .t.f1 -container 1 frame .t.f2 pack .t.f1 .t.f2 - entry .t.f2.e1 -bg red + entry .t.f2.e1 -background red pack .t.f2.e1 bind all <FocusIn> {lappend x "focus in %W %d"} bind all <FocusOut> {lappend x "focus out %W %d"} setupbg -use [winfo id .t.f1] dobg { - entry .e1 -bg lightBlue + entry .e1 -background lightBlue pack .e1 bind all <FocusIn> {lappend x "focus in %W %d"} bind all <FocusOut> {lappend x "focus out %W %d"} @@ -730,8 +723,6 @@ test focus-6.2 {miscellaneous - embedded application in different process} -cons bind all <FocusOut> {} } -result {{.t.f2.e1 {} {focus out .t.f2.e1 NotifyNonlinear} {focus out .t.f2 NotifyNonlinearVirtual} {focus in .t.f1 NotifyNonlinear} | {focus out .t.f1 NotifyNonlinear} {focus in .t.f2 NotifyNonlinearVirtual} {focus in .t.f2.e1 NotifyNonlinear}} {{focus in . NotifyVirtual} {focus in .e1 NotifyAncestor} | {focus out .e1 NotifyAncestor} {focus out . NotifyVirtual}}} - - deleteWindows # cleanup |