diff options
author | fvogel <fvogelnew1@free.fr> | 2021-11-21 17:09:22 (GMT) |
---|---|---|
committer | fvogel <fvogelnew1@free.fr> | 2021-11-21 17:09:22 (GMT) |
commit | f72dd49ac61ae106f240af1c9dbb199c1ef57427 (patch) | |
tree | d31a620bb167638d3bb77d198af9b13a109f3882 /tests | |
parent | 0fe1ce891fb643d8ce6df72b25351577dcd34bca (diff) | |
download | tk-f72dd49ac61ae106f240af1c9dbb199c1ef57427.zip tk-f72dd49ac61ae106f240af1c9dbb199c1ef57427.tar.gz tk-f72dd49ac61ae106f240af1c9dbb199c1ef57427.tar.bz2 |
Rework <<TreeviewSelect>> tests.
Diffstat (limited to 'tests')
-rw-r--r-- | tests/ttk/treeview.test | 121 |
1 files changed, 77 insertions, 44 deletions
diff --git a/tests/ttk/treeview.test b/tests/ttk/treeview.test index 40eda04..ca25306 100644 --- a/tests/ttk/treeview.test +++ b/tests/ttk/treeview.test @@ -460,69 +460,102 @@ test treeview-8.5 "Selection - bad operation" -body { .tv selection badop foo } -returnCodes error -match glob -result {bad selection operation "badop": must be *} -test treeview-8.6 "Selection - <<TreeviewSelect>> on selection add" -body { - .tv selection set {} - bind .tv <<TreeviewSelect>> {set res 1} - set res 0 - .tv selection add newnode.n1 +test treeview-8.7 "<<TreeviewSelect>> when deleting items" -body { + .tv delete [.tv children {}] + .tv insert "" end -id myItem1 -text FirstItem + .tv insert "" end -id myItem2 -text SecondItem + .tv selection add myItem1 + update + bind .tv <<TreeviewSelect>> {lappend res $val} + set res {} + set val 1 + .tv delete myItem2 ; # no <<TreeviewSelect>> (selection unchanged) + update + set val 2 + .tv delete myItem1 ; # <<TreeviewSelect>> triggers update set res -} -result {1} +} -result {2} -test treeview-8.7 "<<TreeviewSelect>> on selected item deletion" -body { - .tv selection set {} - .tv insert "" end -id selectedDoomed -text DeadItem - .tv insert "" end -id doomed -text AlsoDead - .tv selection add selectedDoomed +test treeview-8.8 "<<TreeviewSelect>> when setting the selection" -body { + .tv delete [.tv children {}] + .tv insert "" end -id myItem1 -text FirstItem update - bind .tv <<TreeviewSelect>> {lappend res 1} - set res 0 - .tv delete doomed + bind .tv <<TreeviewSelect>> {lappend res $val} + set res {} + set val 1 + .tv selection set "" ; # no <<TreeviewSelect>> (selection unchanged) update - set res [expr {$res == 0}] - .tv delete selectedDoomed + set val 2 + .tv selection set myItem1 ; # <<TreeviewSelect>> triggers update - set res -} -result {1 1} - -test treeview-8.8 "No <<TreeviewSelect>> when setting the selection to the empty string" -body { - .tv selection set {} - bind .tv <<TreeviewSelect>> {set res 1} - set res 0 - .tv selection set "" + set val 3 + .tv selection set myItem1 ; # no <<TreeviewSelect>> (already selected) update set res -} -result {0} +} -result {2} -test treeview-8.9 "No <<TreeviewSelect>> when removing an empty selection" -body { - .tv selection set {} - bind .tv <<TreeviewSelect>> {set res 1} - set res 0 - .tv selection remove "" +test treeview-8.9 "<<TreeviewSelect>> when removing items from the selection" -body { + .tv delete [.tv children {}] + .tv insert "" end -id myItem1 -text FirstItem + .tv selection set myItem1 + update + bind .tv <<TreeviewSelect>> {lappend res $val} + set res {} + set val 1 + .tv selection remove "" ; # no <<TreeviewSelect>> (selection unchanged) + update + set val 2 + .tv selection remove myItem1 ; # <<TreeviewSelect>> triggers + update + set val 3 + .tv selection remove myItem1 ; # no <<TreeviewSelect>> (selection unchanged) update set res -} -result {0} +} -result {2} -test treeview-8.10 "No <<TreeviewSelect>> when selecting already selected items" -body { - .tv selection set {} +test treeview-8.10 "<<TreeviewSelect>> when adding items in the selection" -body { + .tv delete [.tv children {}] .tv insert "" end -id myItem1 -text FirstItem .tv insert "" end -id myItem2 -text SecondItem - .tv selection add myItem2 - bind .tv <<TreeviewSelect>> {set res 1} - set res 0 - .tv selection add myItem2 + .tv insert "" end -id myItem3 -text ThirdItem + update + bind .tv <<TreeviewSelect>> {lappend res $val} + set res {} + set val 1 + .tv selection add myItem2 ; # <<TreeviewSelect>> triggers + update + set val 2 + .tv selection add myItem2 ; # no <<TreeviewSelect>> (selection unchanged) + update + set val 3 + .tv selection add myItem3 ; # <<TreeviewSelect>> triggers update set res -} -result {0} +} -result {1 3} -test treeview-8.11 "No <<TreeviewSelect>> when toggling an empty selection" -body { - .tv selection set {} - bind .tv <<TreeviewSelect>> {set res 1} - set res 0 - .tv selection toggle "" +test treeview-8.11 "<<TreeviewSelect>> when toggling" -body { + .tv delete [.tv children {}] + .tv insert "" end -id myItem1 -text FirstItem + .tv insert "" end -id myItem2 -text SecondItem + .tv insert "" end -id myItem3 -text ThirdItem + update + bind .tv <<TreeviewSelect>> {lappend res $val} + set res {} + set val 1 + .tv selection toggle "" ; # no <<TreeviewSelect>> (selection unchanged) + update + set val 2 + .tv selection toggle {myItem1 myItem3} ; # <<TreeviewSelect>> triggers + update + set val 3 + .tv selection toggle {myItem3 myItem2} ; # <<TreeviewSelect>> triggers + update + set val 4 + .tv selection toggle {myItem3 myItem2} ; # <<TreeviewSelect>> triggers update set res -} -result {0} +} -result {2 3 4} ### NEED: more tests for see/yview/scrolling |