From c9fa73560e09fd8645deaee8706d15a6f0d8c80c Mon Sep 17 00:00:00 2001 From: sbron Date: Mon, 20 Mar 2023 10:04:59 +0000 Subject: Add tests for TIP 658. --- tests/menu.test | 130 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 130 insertions(+) diff --git a/tests/menu.test b/tests/menu.test index 47f9919..e330417 100644 --- a/tests/menu.test +++ b/tests/menu.test @@ -4004,6 +4004,136 @@ test menu-39.1 {empty -type - bug be8f5b9fc2} -setup { destroy .m } -returnCodes error -result {ambiguous type "": must be menubar, normal, or tearoff} +test menu-40.1 {identifiers - auto generated} -setup { + destroy .m +} -body { + menu .m + list [.m add command -label 1] [.m add command -label 2] [.m add command -label 3] +} -cleanup { + destroy .m +} -result {e001 e002 e003} +test menu-40.2 {identifiers - out of sequence} -setup { + destroy .m +} -body { + menu .m -tearoff 0 + .m add command -label 1 + .m insert 0 command -label 2 + .m add command -label 3 + list [.m index e001] [.m index e002] [.m index e003] +} -cleanup { + destroy .m +} -result {1 0 2} +test menu-40.3 {identifiers - out of sequence with tearoff} -setup { + destroy .m +} -body { + menu .m -tearoff 1 + .m add command -label 1 + .m insert 0 command -label 2 + .m add command -label 3 + list [.m index e001] [.m index e002] [.m index e003] +} -cleanup { + destroy .m +} -result {2 1 3} +test menu-40.4 {identifiers - entry id} -setup { + destroy .m +} -body { + menu .m -tearoff 1 + .m add command -label 1 + .m insert 0 command -label 2 + .m add command -label 3 + list [.m id 0] [.m id 1] [.m id 2] [.m id 3] +} -cleanup { + destroy .m +} -result {{} e002 e001 e003} +test menu-40.5 {identifiers - assigned} -setup { + destroy .m +} -body { + menu .m + list [.m add command cmd1 -label 1] [.m insert 0 command cmd2 -label 2] [.m add command cmd3 -label 3] +} -cleanup { + destroy .m +} -result {cmd1 cmd2 cmd3} +test menu-40.6 {identifiers - mixed} -setup { + destroy .m +} -body { + menu .m + list [.m add command -label 1] [.m insert 0 command cmd2 -label 2] [.m add command -label 3] +} -cleanup { + destroy .m +} -result {e001 cmd2 e002} +test menu-40.7 {identifiers - conflict} -setup { + destroy .m +} -body { + menu .m + list [.m add command e002 -label 1] [.m add command -label 2] [.m add command -label 3] +} -cleanup { + destroy .m +} -result {e002 e001 e003} +test menu-40.8 {identifiers - clone of complete menu} -setup { + destroy .m1 .m2 +} -body { + menu .m1 -tearoff 0 + .m1 add command -label 1 + .m1 insert 0 command -label 2 + .m1 add command cmd3 -label 3 + .m1 clone .m2 + list [.m2 index e001] [.m2 index e002] [.m2 index cmd3] +} -cleanup { + destroy .m1 .m2 +} -result {1 0 2} +test menu-40.9 {identifiers - modify after cloning} -setup { + destroy .m1 .m2 +} -body { + menu .m1 -tearoff 0 + .m1 clone .m2 + .m1 add command -label 1 + .m1 insert 0 command -label 2 + .m1 add command cmd3 -label 3 + list [.m2 index e001] [.m2 index e002] [.m2 index cmd3] +} -cleanup { + destroy .m1 .m2 +} -result {1 0 2} +test menu-40.10 {identifiers - modify clone} -setup { + destroy .m1 .m2 +} -body { + menu .m1 -tearoff 0 + .m1 clone .m2 + .m2 add command -label 1 + .m2 insert 0 command -label 2 + .m2 add command cmd3 -label 3 + list [.m1 index e001] [.m1 index e002] [.m1 index cmd3] +} -cleanup { + destroy .m1 .m2 +} -result {1 0 2} +test menu-40.11 {identifiers - entrycget by id} -setup { + destroy .m +} -body { + menu .m + .m add command -label 1 + .m add command -label 2 + .m add command cmd3 -label 3 + list [.m entrycget e001 -label] [.m entrycget e002 -label] [.m entrycget cmd3 -label] +} -cleanup { + destroy .m +} -result {1 2 3} +test menu-40.12 {identifiers - delete by id} -setup { + destroy .m +} -body { + menu .m + .m add command -label 1 + .m add command -label 2 + .m add command -label 3 + .m add command -label 4 + .m add command -label 5 + .m add command -label 6 + .m add command -label 7 + .m add command cmd8 -label 8 + .m add command cmd9 -label 9 + .m delete e003 cmd8 + list [.m id 0] [.m id 1] [.m id 2] +} -cleanup { + destroy .m +} -result {e001 e002 cmd9} # cleanup imageFinish -- cgit v0.12