Skip to content

Commit

Permalink
Convert from approach B => A (revert access procs to the original var…
Browse files Browse the repository at this point in the history
…iable references), domain dialog
  • Loading branch information
1minus1is0 committed Feb 13, 2025
1 parent a10aea2 commit 4e9ee4b
Show file tree
Hide file tree
Showing 7 changed files with 31 additions and 36 deletions.
5 changes: 2 additions & 3 deletions tests/choosedir.test
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ eval tcltest::configure $argv
tcltest::loadTestedCommands

# Import utility procs for specific functional areas
testutils import -novars dialog
setDialogType choosedir
testutils import dialog
set dialogType choosedir

#----------------------------------------------------------------------
#
Expand Down Expand Up @@ -142,7 +142,6 @@ test choosedir-5.1 {tk_chooseDirectory, handles {} entry text} -constraints {
#

removeDirectory choosedirTest
setDialogType none
testutils forget dialog
cleanupTests
return
5 changes: 2 additions & 3 deletions tests/clrpick.test
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ tcltest::loadTestedCommands
namespace import -force tcltest::test

# Import utility procs for specific functional areas
testutils import -novars dialog
setDialogType clrpick
testutils import dialog
set dialogType clrpick

if {[testConstraint defaultPseudocolor8]} {
# let's soak up a bunch of colors...so that
Expand Down Expand Up @@ -172,7 +172,6 @@ test clrpick-4.1 {tk_chooseColor: screen is inherited from parent} -constraints
# CLEANUP
#

setDialogType none
testutils forget dialog
cleanupTests
return
5 changes: 2 additions & 3 deletions tests/filebox.test
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ eval tcltest::configure $argv
tcltest::loadTestedCommands

# Import utility procs for specific functional areas
testutils import -novars dialog
setDialogType filebox
testutils import dialog
set dialogType filebox

test fileDialog-0.1 {GetFileName: file types: MakeFilter() fails} {
# MacOS type that is too long
Expand Down Expand Up @@ -445,7 +445,6 @@ foreach mode $modes {

set tk_strictMotif $tk_strictMotif_old
removeFile filebox.tmp
setDialogType none
testutils forget dialog
cleanupTests
return
12 changes: 6 additions & 6 deletions tests/fontchooser.test
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ tcltest::loadTestedCommands
# Import utility procs for specific functional areas
testutils import dialog

set applyFontCmd [list testDialogFont set]
set applyFontCmd [list set testDialogFont]

# -------------------------------------------------------------------------

Expand Down Expand Up @@ -107,7 +107,7 @@ test fontchooser-4.0 {fontchooser -font} -constraints scriptImpl -body {
testDialog onDisplay {
Click cancel
}
testDialogFont get
set testDialogFont
} -result {}

test fontchooser-4.1 {fontchooser -font} -constraints scriptImpl -body {
Expand All @@ -118,7 +118,7 @@ test fontchooser-4.1 {fontchooser -font} -constraints scriptImpl -body {
testDialog onDisplay {
Click ok
}
expr {[testDialogFont get] ne {}}
expr {$testDialogFont ne {}}
} -result 1

test fontchooser-4.2 {fontchooser -font} -constraints scriptImpl -body {
Expand All @@ -129,7 +129,7 @@ test fontchooser-4.2 {fontchooser -font} -constraints scriptImpl -body {
testDialog onDisplay {
Click ok
}
expr {[testDialogFont get] ne {}}
expr {$testDialogFont ne {}}
} -result 1

test fontchooser-4.3 {fontchooser -font} -constraints scriptImpl -body {
Expand All @@ -140,7 +140,7 @@ test fontchooser-4.3 {fontchooser -font} -constraints scriptImpl -body {
testDialog onDisplay {
Click ok
}
expr {[testDialogFont get] ne {}}
expr {$testDialogFont ne {}}
} -result 1

test fontchooser-4.4 {fontchooser -font} -constraints {scriptImpl havePointsize14BoldFont} -body {
Expand All @@ -151,7 +151,7 @@ test fontchooser-4.4 {fontchooser -font} -constraints {scriptImpl havePointsize1
testDialog onDisplay {
Click ok
}
lrange [testDialogFont get] 1 end
lrange $testDialogFont 1 end
} -result {14 bold}

test fontchooser-5.1 {fontchooser multiple configure} -constraints {scriptImpl} -body {
Expand Down
4 changes: 2 additions & 2 deletions tests/msgbox.test
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ tcltest::loadTestedCommands
namespace import -force tcltest::test

# Import utility procs for specific functional areas
testutils import -novars dialog
setDialogType msgbox
testutils import dialog
set dialogType msgbox

test msgbox-1.1.1 {tk_messageBox command} -constraints notAqua -body {
tk_messageBox -foo
Expand Down
11 changes: 3 additions & 8 deletions tests/testutils.tcl
Original file line number Diff line number Diff line change
Expand Up @@ -520,6 +520,7 @@ namespace eval ::tk::test::dialog {
proc init {} {
variable dialogType none
variable testDialog
variable testDialogFont
}

proc Click {button} {
Expand Down Expand Up @@ -590,10 +591,6 @@ namespace eval ::tk::test::dialog {
}
}

proc setDialogType {type} {
variable dialogType $type
}

proc testDialog {stage {script ""}} {
variable testDialogCmd
variable testDialogResult
Expand Down Expand Up @@ -665,10 +662,8 @@ namespace eval ::tk::test::dialog {
}
}

::tk::test::createStdAccessProc testDialogFont

namespace export Click PressButton SendButtonPress setDialogType testDialog \
testDialogFont ToPressButton
namespace export Click PressButton SendButtonPress testDialog \
ToPressButton
}


Expand Down
25 changes: 14 additions & 11 deletions tests/winDialog.test
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ tcltest::loadTestedCommands

# Import utility procs for specific functional areas
testutils import dialog
set applyFontCmd [list testDialogFont set]
set applyFontCmd [list set testDialogFont]

if {[testConstraint testwinevent]} {
catch {testwinevent debug 1}
Expand All @@ -31,24 +31,27 @@ testConstraint english [expr {
set initialDir [tcltest::temporaryDirectory]

proc Click {button} {
variable testDialog
switch -exact -- $button {
ok { set button 1 }
cancel { set button 2 }
}
testwinevent $::testDialog $button WM_LBUTTONDOWN 1 0x000a000b
testwinevent $::testDialog $button WM_LBUTTONUP 0 0x000a000b
testwinevent $testDialog $button WM_LBUTTONDOWN 1 0x000a000b
testwinevent $testDialog $button WM_LBUTTONUP 0 0x000a000b
}

proc GetText {id} {
variable testDialog
switch -exact -- $id {
ok { set id 1 }
cancel { set id 2 }
}
return [testwinevent $::testDialog $id WM_GETTEXT]
return [testwinevent $testDialog $id WM_GETTEXT]
}

proc SetText {id text} {
return [testwinevent $::testDialog $id WM_SETTEXT $text]
variable testDialog
return [testwinevent $testDialog $id WM_SETTEXT $text]
}

# ----------------------------------------------------------------------
Expand Down Expand Up @@ -863,7 +866,7 @@ test winDialog-10.1 {Tk_FontchooserObjCmd: no arguments} -constraints {
testDialog launch {tk fontchooser show}
list [testDialog onDisplay {
Click cancel
}] [testDialogFont get]
}] $testDialogFont
} -result {0 {}}
test winDialog-10.2 {Tk_FontchooserObjCmd: -initialfont} -constraints {
nt testwinevent
Expand All @@ -874,7 +877,7 @@ test winDialog-10.2 {Tk_FontchooserObjCmd: -initialfont} -constraints {
}
list [testDialog onDisplay {
Click cancel
}] [testDialogFont get]
}] $testDialogFont
} -result {0 {}}
test winDialog-10.3 {Tk_FontchooserObjCmd: -initialfont} -constraints {
nt testwinevent
Expand All @@ -885,7 +888,7 @@ test winDialog-10.3 {Tk_FontchooserObjCmd: -initialfont} -constraints {
}
list [testDialog onDisplay {
Click 1
}] [expr {[llength [testDialogFont get]] ne {}}]
}] [expr {[llength $testDialogFont] ne {}}]
} -result {0 1}
test winDialog-10.4 {Tk_FontchooserObjCmd: -title} -constraints {
nt testwinevent
Expand All @@ -896,7 +899,7 @@ test winDialog-10.4 {Tk_FontchooserObjCmd: -title} -constraints {
}
list [testDialog onDisplay {
Click cancel
}] [testDialogFont get]
}] $testDialogFont
} -result {0 {}}
test winDialog-10.5 {Tk_FontchooserObjCmd: -parent} -constraints {
nt testwinevent
Expand All @@ -911,7 +914,7 @@ test winDialog-10.5 {Tk_FontchooserObjCmd: -parent} -constraints {
array set a [testgetwindowinfo $testDialog]
Click cancel
}
list [expr {$a(parent) == [wm frame .]}] [testDialogFont get]
list [expr {$a(parent) == [wm frame .]}] $testDialogFont
} -result {1 {}}
test winDialog-10.6 {Tk_FontchooserObjCmd: -apply} -constraints {
nt testwinevent
Expand All @@ -934,7 +937,7 @@ test winDialog-10.7 {Tk_FontchooserObjCmd: -apply} -constraints {
list [testDialog onDisplay {
Click [expr {0x0402}] ;# value from XP
Click cancel
}] [expr {[llength [testDialogFont get]] > 0}]
}] [expr {[llength $testDialogFont] > 0}]
} -result {0 1}
test winDialog-10.8 {Tk_FontchooserObjCmd: -title} -constraints {
nt testwinevent
Expand Down

0 comments on commit 4e9ee4b

Please sign in to comment.