diff options
author | fvogel <fvogelnew1@free.fr> | 2023-06-04 17:18:27 (GMT) |
---|---|---|
committer | fvogel <fvogelnew1@free.fr> | 2023-06-04 17:18:27 (GMT) |
commit | a0d9703131628d169c2b9abcc842d058a3899a91 (patch) | |
tree | 832dbdfebddecaa689090bd446570a42c5873077 /tests | |
parent | 399eacbc0271601773bf04e62ef4bd9a2d13033f (diff) | |
parent | 3813048adc609662006a24942ac3f05c76f6ae79 (diff) | |
download | tk-a0d9703131628d169c2b9abcc842d058a3899a91.zip tk-a0d9703131628d169c2b9abcc842d058a3899a91.tar.gz tk-a0d9703131628d169c2b9abcc842d058a3899a91.tar.bz2 |
Merge implementation of TIP #658 - Attach identifiers to Tk menu entries, following positive vote from the TCT. Thanks to the author, Schelte Bron!
Diffstat (limited to 'tests')
-rw-r--r-- | tests/menu.test | 209 | ||||
-rw-r--r-- | tests/menuDraw.test | 18 | ||||
-rw-r--r-- | tests/winMenu.test | 36 |
3 files changed, 207 insertions, 56 deletions
diff --git a/tests/menu.test b/tests/menu.test index ed40e07..4f28fbb 100644 --- a/tests/menu.test +++ b/tests/menu.test @@ -1310,7 +1310,7 @@ test menu-3.10 {MenuWidgetCmd procedure, "add" option} -setup { .m1 add separator } -cleanup { destroy .m1 -} -result {} +} -result {e001} test menu-3.11 {MenuWidgetCmd procedure, "cget" option} -setup { destroy .m1 } -body { @@ -1819,7 +1819,7 @@ test menu-3.67 {MenuWidgetCmd procedure, bad option} -setup { .m1 foo } -cleanup { destroy .m1 -} -returnCodes error -result {bad option "foo": must be activate, add, cget, clone, configure, delete, entrycget, entryconfigure, index, insert, invoke, post, postcascade, type, unpost, xposition, or yposition} +} -returnCodes error -result {bad option "foo": must be activate, add, cget, clone, configure, delete, entrycget, entryconfigure, id, index, insert, invoke, post, postcascade, type, unpost, xposition, or yposition} test menu-3.68 {MenuWidgetCmd procedure, fix for bug#508988} -setup { deleteWindows } -body { @@ -2647,7 +2647,7 @@ test menu-11.15 {ConfigureMenuEntry} -setup { list [.m1 add checkbutton -label "test"] [.m1 entrycget 1 -variable] } -cleanup { deleteWindows -} -result {{} test} +} -result {e001 test} test menu-11.16 {ConfigureMenuEntry} -setup { deleteWindows } -body { @@ -2655,7 +2655,7 @@ test menu-11.16 {ConfigureMenuEntry} -setup { .m1 add radiobutton -label "test" } -cleanup { deleteWindows -} -result {} +} -result {e001} test menu-11.17 {ConfigureMenuEntry} -setup { deleteWindows } -body { @@ -2818,7 +2818,7 @@ test menu-13.4 {TkGetMenuIndex} -setup { list [.m1 insert last command -label "test2"] [.m1 entrycget last -label] } -cleanup { deleteWindows -} -result {{} test2} +} -result {e002 test2} test menu-13.5 {TkGetMenuIndex} -setup { deleteWindows } -body { @@ -2827,7 +2827,7 @@ test menu-13.5 {TkGetMenuIndex} -setup { list [.m1 insert end command -label "test2"] [.m1 entrycget end -label] } -cleanup { deleteWindows -} -result {{} test2} +} -result {e002 test2} test menu-13.6 {TkGetMenuIndex} -setup { deleteWindows } -body { @@ -2924,7 +2924,7 @@ test menu-15.1 {MenuNewEntry} -setup { .m1 add command -label "test" } -cleanup { deleteWindows -} -result {} +} -result {e001} test menu-15.2 {MenuNewEntry} -setup { deleteWindows } -body { @@ -2934,7 +2934,7 @@ test menu-15.2 {MenuNewEntry} -setup { .m1 insert 2 command -label "test2" } -cleanup { deleteWindows -} -result {} +} -result {e003} test menu-15.3 {MenuNewEntry} -setup { deleteWindows } -body { @@ -2943,7 +2943,7 @@ test menu-15.3 {MenuNewEntry} -setup { .m1 add command -label "test2" } -cleanup { deleteWindows -} -result {} +} -result {e002} test menu-15.4 {MenuNewEntry} -setup { deleteWindows } -body { @@ -2951,7 +2951,7 @@ test menu-15.4 {MenuNewEntry} -setup { .m1 add command -label "test" } -cleanup { deleteWindows -} -result {} +} -result {e001} test menu-16.1 {MenuAddOrInsert} -setup { deleteWindows @@ -2967,7 +2967,7 @@ test menu-16.2 {MenuAddOrInsert} -setup { .m1 insert test command -label "foo" } -cleanup { deleteWindows -} -result {} +} -result {e002} test menu-16.3 {MenuAddOrInsert} -setup { deleteWindows } -body { @@ -2991,7 +2991,7 @@ test menu-16.5 {MenuAddOrInsert} -setup { .m1 add cascade } -cleanup { deleteWindows -} -result {} +} -result {e001} test menu-16.6 {MenuAddOrInsert} -setup { deleteWindows } -body { @@ -2999,7 +2999,7 @@ test menu-16.6 {MenuAddOrInsert} -setup { .m1 add checkbutton } -cleanup { deleteWindows -} -result {} +} -result {e001} test menu-16.7 {MenuAddOrInsert} -setup { deleteWindows } -body { @@ -3007,7 +3007,7 @@ test menu-16.7 {MenuAddOrInsert} -setup { .m1 add command } -cleanup { deleteWindows -} -result {} +} -result {e001} test menu-16.8 {MenuAddOrInsert} -setup { deleteWindows } -body { @@ -3015,7 +3015,7 @@ test menu-16.8 {MenuAddOrInsert} -setup { .m1 add radiobutton } -cleanup { deleteWindows -} -result {} +} -result {e001} test menu-16.9 {MenuAddOrInsert} -setup { deleteWindows } -body { @@ -3023,7 +3023,7 @@ test menu-16.9 {MenuAddOrInsert} -setup { .m1 add separator } -cleanup { deleteWindows -} -result {} +} -result {e001} test menu-16.10 {MenuAddOrInsert} -setup { deleteWindows } -body { @@ -3037,7 +3037,7 @@ test menu-16.11 {MenuAddOrInsert} -setup { .m1 add command } -cleanup { deleteWindows -} -result {} +} -result {e001} test menu-16.12 {MenuAddOrInsert} -setup { deleteWindows } -body { @@ -3047,7 +3047,7 @@ test menu-16.12 {MenuAddOrInsert} -setup { list [.m2 add command -label "test"] [.m1 entrycget 1 -label] [.m3 entrycget 1 -label] } -cleanup { deleteWindows -} -result {{} test test} +} -result {e001 test test} test menu-16.13 {MenuAddOrInsert} -setup { deleteWindows } -body { @@ -3057,12 +3057,12 @@ test menu-16.13 {MenuAddOrInsert} -setup { list [.m3 add command -label "test"] [.m1 entrycget 1 -label] [.m2 entrycget 1 -label] } -cleanup { deleteWindows -} -result {{} test test} +} -result {e001 test test} test menu-16.14 {MenuAddOrInsert} -setup { deleteWindows } -body { menu .m1 - .m1 add command -blork + .m1 add command -blork fish } -returnCodes error -result {unknown option "-blork"} test menu-16.15 {MenuAddOrInsert} -setup { deleteWindows @@ -3074,7 +3074,7 @@ test menu-16.15 {MenuAddOrInsert} -setup { list [.container add cascade -label "File" -menu .m1] [. configure -menu ""] } -cleanup { deleteWindows -} -result {{} {}} +} -result {e001 {}} test menu-16.16 {MenuAddOrInsert} -setup { deleteWindows } -body { @@ -3084,7 +3084,7 @@ test menu-16.16 {MenuAddOrInsert} -setup { list [.m2 add cascade -menu .m1] [$tearoff unpost] } -cleanup { deleteWindows -} -result {{} {}} +} -result {e001 {}} test menu-16.17 {MenuAddOrInsert} -setup { deleteWindows } -body { @@ -3095,7 +3095,7 @@ test menu-16.17 {MenuAddOrInsert} -setup { list [.container add cascade -label "File" -menu .m1] [. configure -menu ""] } -cleanup { deleteWindows -} -result {{} {}} +} -result {e001 {}} test menu-16.18 {MenuAddOrInsert} -setup { deleteWindows } -body { @@ -3106,7 +3106,7 @@ test menu-16.18 {MenuAddOrInsert} -setup { list [.container add cascade -label "File" -menu .m1] [. configure -menu ""] } -cleanup { deleteWindows -} -result {{} {}} +} -result {e002 {}} test menu-16.19 {MenuAddOrInsert - Insert a cascade deep into the tree} -setup { deleteWindows } -body { @@ -3135,7 +3135,7 @@ test menu-17.1 {MenuVarProc} -setup { [unset foo] } -cleanup { deleteWindows -} -result {{} {}} +} -result {e001 {}} # menu-17.2 - Don't know how to generate the flags in the if test menu-17.2 {MenuVarProc} -setup { deleteWindows @@ -3146,7 +3146,7 @@ test menu-17.2 {MenuVarProc} -setup { [set foo ""] } -cleanup { deleteWindows -} -result {{} {}} +} -result {e001 {}} test menu-17.3 {MenuVarProc} -setup { deleteWindows } -body { @@ -3157,7 +3157,7 @@ test menu-17.3 {MenuVarProc} -setup { [set foo "hello"] [unset foo] } -cleanup { deleteWindows -} -result {{} hello {}} +} -result {e001 hello {}} test menu-17.4 {MenuVarProc} -setup { deleteWindows } -body { @@ -3167,7 +3167,7 @@ test menu-17.4 {MenuVarProc} -setup { [set foo "hello"] [unset foo] } -cleanup { deleteWindows -} -result {{} hello {}} +} -result {e001 hello {}} test menu-17.5 {MenuVarProc} -setup { deleteWindows } -body { @@ -3177,7 +3177,7 @@ test menu-17.5 {MenuVarProc} -setup { [set foo "goodbye"] [unset foo] } -cleanup { deleteWindows -} -result {{} goodbye {}} +} -result {e001 goodbye {}} test menu-17.6 {MenuVarProc [5d991b822e]} -setup { deleteWindows } -body { @@ -4056,6 +4056,157 @@ 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} +test menu-40.13 {identifiers - duplicate} -setup { + destroy .m +} -body { + menu .m + .m add command foo -label 1 + .m add command bar -label 2 + .m add command foo -label 3 +} -cleanup { + destroy .m +} -returnCodes error -result {entry "foo" already exists} +test menu-40.14 {identifiers - reserved word} -setup { + destroy .m +} -body { + menu .m -tearoff 0 + .m add command last -label 1 + .m add command -label 2 + .m add command -label 3 + .m index last +} -cleanup { + destroy .m +} -result {2} # cleanup imageFinish diff --git a/tests/menuDraw.test b/tests/menuDraw.test index ff639c1..2cafc31 100644 --- a/tests/menuDraw.test +++ b/tests/menuDraw.test @@ -27,7 +27,7 @@ test menuDraw-2.1 {TkInitializeMenuEntryDrawingFields} -setup { .m1 add command } -cleanup { deleteWindows -} -result {} +} -result {e001} test menuDraw-3.1 {TkMenuFreeDrawOptions} -setup { @@ -86,7 +86,7 @@ test menuDraw-6.1 {TkMenuConfigureEntryDrawOptions - no tkfont specified} -setup .m1 add command -label "foo" } -cleanup { deleteWindows -} -result {} +} -result {e001} test menuDraw-6.2 {TkMenuConfigureEntryDrawOptions - tkfont specified} -setup { deleteWindows } -body { @@ -94,7 +94,7 @@ test menuDraw-6.2 {TkMenuConfigureEntryDrawOptions - tkfont specified} -setup { .m1 add command -label "foo" -font "Courier 12" } -cleanup { deleteWindows -} -result {} +} -result {e001} test menuDraw-6.3 {TkMenuConfigureEntryDrawOptions - active state - wrong entry} -setup { deleteWindows } -body { @@ -140,7 +140,7 @@ test menuDraw-6.7 {TkMenuConfigureEntryDrawOptions - tkfont specified} -setup { .m1 add command -label "foo" -font "Courier 12" } -cleanup { deleteWindows -} -result {} +} -result {e001} test menuDraw-6.8 {TkMenuConfigureEntryDrawOptions - border specified} -setup { deleteWindows } -body { @@ -148,7 +148,7 @@ test menuDraw-6.8 {TkMenuConfigureEntryDrawOptions - border specified} -setup { .m1 add command -label "foo" -background "red" } -cleanup { deleteWindows -} -result {} +} -result {e001} test menuDraw-6.9 {TkMenuConfigureEntryDrawOptions - foreground specified} -setup { deleteWindows } -body { @@ -156,7 +156,7 @@ test menuDraw-6.9 {TkMenuConfigureEntryDrawOptions - foreground specified} -setu .m1 add command -label "foo" -foreground "red" } -cleanup { deleteWindows -} -result {} +} -result {e001} test menuDraw-6.10 {TkMenuConfigureEntryDrawOptions - activeBorder specified} -setup { deleteWindows } -body { @@ -164,7 +164,7 @@ test menuDraw-6.10 {TkMenuConfigureEntryDrawOptions - activeBorder specified} -s .m1 add command -label "foo" -activebackground "red" } -cleanup { deleteWindows -} -result {} +} -result {e001} test menuDraw-6.11 {TkMenuConfigureEntryDrawOptions - activeforeground specified} -setup { deleteWindows } -body { @@ -172,7 +172,7 @@ test menuDraw-6.11 {TkMenuConfigureEntryDrawOptions - activeforeground specified .m1 add command -label "foo" -activeforeground "red" } -cleanup { deleteWindows -} -result {} +} -result {e001} test menuDraw-6.12 {TkMenuConfigureEntryDrawOptions - selectcolor specified} -setup { deleteWindows } -body { @@ -180,7 +180,7 @@ test menuDraw-6.12 {TkMenuConfigureEntryDrawOptions - selectcolor specified} -se .m1 add radiobutton -label "foo" -selectcolor "red" } -cleanup { deleteWindows -} -result {} +} -result {e001} test menuDraw-6.13 {TkMenuConfigureEntryDrawOptions - textGC disposal} -setup { deleteWindows } -body { diff --git a/tests/winMenu.test b/tests/winMenu.test index 3b7dbec..21768ef 100644 --- a/tests/winMenu.test +++ b/tests/winMenu.test @@ -93,91 +93,91 @@ test winMenu-6.2 {GetEntryText} -constraints { menu .m1 image create test image1 list [catch {.m1 add command -image image1} msg] $msg [destroy .m1] [image delete image1] -} -result {0 {} {} {}} +} -result {0 e001 {} {}} test winMenu-6.3 {GetEntryText} -constraints win -setup { destroy .m1 } -body { menu .m1 list [catch {.m1 add command -bitmap questhead} msg] $msg [destroy .m1] -} -result {0 {} {}} +} -result {0 e001 {}} test winMenu-6.4 {GetEntryText} -constraints win -setup { destroy .m1 } -body { menu .m1 list [catch {.m1 add command} msg] $msg [destroy .m1] -} -result {0 {} {}} +} -result {0 e001 {}} test winMenu-6.5 {GetEntryText} -constraints win -setup { destroy .m1 } -body { menu .m1 list [catch {.m1 add command -label "foo"} msg] $msg [destroy .m1] -} -result {0 {} {}} +} -result {0 e001 {}} test winMenu-6.6 {GetEntryText} -constraints win -setup { destroy .m1 } -body { menu .m1 list [catch {.m1 add command -label "This string has one & in it"} msg] $msg [destroy .m1] -} -result {0 {} {}} +} -result {0 e001 {}} test winMenu-6.7 {GetEntryText} -constraints win -setup { destroy .m1 } -body { menu .m1 list [catch {.m1 add command -label "The & should be underlined." -underline 4} msg] $msg [destroy .m1] -} -result {0 {} {}} +} -result {0 e001 {}} test winMenu-6.8 {GetEntryText} -constraints win -setup { destroy .m1 } -body { menu .m1 list [catch {.m1 add command -label "The * should be underlined." -underline 4} msg] $msg [destroy .m1] -} -result {0 {} {}} +} -result {0 e001 {}} test winMenu-6.9 {GetEntryText} -constraints win -setup { destroy .m1 } -body { menu .m1 list [catch {.m1 add command -label "foo" -accel "bar"} msg] $msg [destroy .m1] -} -result {0 {} {}} +} -result {0 e001 {}} test winMenu-6.10 {GetEntryText} -constraints win -setup { destroy .m1 } -body { menu .m1 list [catch {.m1 add command -label "This string has one & in it" -accel "bar"} msg] $msg [destroy .m1] -} -result {0 {} {}} +} -result {0 e001 {}} test winMenu-6.11 {GetEntryText} -constraints win -setup { destroy .m1 } -body { menu .m1 list [catch {.m1 add command -label "The & should be underlined." -underline 4 -accel "bar"} msg] $msg [destroy .m1] -} -result {0 {} {}} +} -result {0 e001 {}} test winMenu-6.12 {GetEntryText} -constraints win -setup { destroy .m1 } -body { menu .m1 list [catch {.m1 add command -label "The * should be underlined." -underline 4 -accel "bar"} msg] $msg [destroy .m1] -} -result {0 {} {}} +} -result {0 e001 {}} test winMenu-6.13 {GetEntryText} -constraints win -setup { destroy .m1 } -body { menu .m1 list [catch {.m1 add command -label "foo" -accel "&bar"} msg] $msg [destroy .m1] -} -result {0 {} {}} +} -result {0 e001 {}} test winMenu-6.14 {GetEntryText} -constraints win -setup { destroy .m1 } -body { menu .m1 list [catch {.m1 add command -label "This string has one & in it" -accel "&bar"} msg] $msg [destroy .m1] -} -result {0 {} {}} +} -result {0 e001 {}} test winMenu-6.15 {GetEntryText} -constraints win -setup { destroy .m1 } -body { menu .m1 list [catch {.m1 add command -label "The & should be underlined." -underline 4 -accel "&bar"} msg] $msg [destroy .m1] -} -result {0 {} {}} +} -result {0 e001 {}} test winMenu-6.16 {GetEntryText} -constraints win -setup { destroy .m1 } -body { menu .m1 list [catch {.m1 add command -label "The * should be underlined." -underline 4 -accel "&bar"} msg] $msg [destroy .m1] -} -result {0 {} {}} +} -result {0 e001 {}} test winMenu-7.1 {ReconfigureWindowsMenu - system menu item removal} -constraints { win @@ -427,7 +427,7 @@ test winMenu-9.1 {TkpMenuNewEntry} -constraints win -setup { } -body { menu .m1 list [catch {.m1 add command} msg] $msg [destroy .m1] -} -result {0 {} {}} +} -result {0 e001 {}} test winMenu-10.1 {TkwinMenuProc} -constraints { @@ -859,7 +859,7 @@ test winMenu-28.1 {TkpConfigureMenuEntry - update pending} -constraints { menu .m1 -tearoff 0 .m1 add command -label Hello list [catch {.m1 add command -label Two} msg] $msg [destroy .m1] -} -result {0 {} {}} +} -result {0 e002 {}} test winMenu-28.2 {TkpConfigureMenuEntry - update not pending} -constraints { win } -setup { @@ -869,7 +869,7 @@ test winMenu-28.2 {TkpConfigureMenuEntry - update not pending} -constraints { .m1 add command -label One update idletasks list [catch {.m1 add command -label Two} msg] $msg [destroy .m1] -} -result {0 {} {}} +} -result {0 e002 {}} test winMenu-29.1 {TkpDrawMenuEntry - gc for active and not strict motif} -constraints { |