- # This file is a Tcl script to test menus in Tk. It is
- # organized in the standard fashion for Tcl tests. This
- # file tests the Macintosh-specific features of the menu
- # system.
- #
- # Copyright (c) 1995-1997 Sun Microsystems, Inc.
- # Copyright (c) 1998-1999 by Scriptics Corporation.
- # All rights reserved.
- #
- # RCS: @(#) $Id: macMenu.test,v 1.7 2002/07/13 20:28:35 dgp Exp $
- package require tcltest 2.1
- namespace import -force tcltest::configure
- namespace import -force tcltest::testsDirectory
- configure -testdir [file join [pwd] [file dirname [info script]]]
- configure -loadfile [file join [testsDirectory] constraints.tcl]
- tcltest::loadTestedCommands
- test macMenu-1.0 {TkMacUseMenuID} {macOnly} {
- # Can't really test TkMacUseMenuID; it's only called on startup.
- } {}
- test macMenu-2.1 {GetNewID} {macOnly} {
- catch {destroy .m1}
- list [catch {menu .m1} msg] $msg [destroy .m1]
- } {0 .m1 {}}
- test macMenu-2.2 {GetNewID - cascade menu} {macOnly} {
- catch {destroy .m1}
- menu .m1
- .m1 add cascade -menu .m2
- list [catch {menu .m2} msg] $msg [destroy .m1] [destroy .m2]
- } {0 .m2 {} {}}
- test macMenu-2.3 {GetNewID - running out of ids} {macOnly} {
- deleteWindows
- menu .menu
- for {set i 0} {$i < 230} {incr i} {
- menu .m$i
- .menu add cascade -label ".m$i" -menu .m$i
- }
- menu .breaker
- list [catch {.menu add cascade -menu .breaker} msg] $msg [deleteWindows]
- } {1 {No more menus can be allocated.} {}}
- test macMenu-3.1 {FreeID} {macOnly} {
- catch {destroy .m1}
- menu .m1
- list [catch {destroy .m1} msg] $msg
- } {0 {}}
- # No way to test running out of ids in TkpNewPlatformMenu
- test macMenu-4.1 {TkpNewMenu} {macOnly} {
- catch {destroy .m1}
- list [catch {menu .m1} msg] $msg [catch {destroy .m1} msg2] $msg2
- } {0 .m1 0 {}}
- test macMenu-4.2 {TkpNewMenu - checking for help menu when one is there} {macOnly} {
- catch {destroy .m1}
- catch {destroy .m2}
- menu .m1
- menu .m1.help -tearoff 0
- .m1.help add command -label Test
- . configure -menu .m1
- raise .
- update
- list [catch {menu .m2} msg] $msg [destroy .m1] [destroy .m2] [. configure -menu ""]
- } {0 .m2 {} {} {}}
- test macMenu-4.3 {TkpNewMenu - menubar set but different interp} {macOnly} {
- catch {interp delete testinterp}
- catch {destroy .m1}
- interp create testinterp
- load {} Tk testinterp
- interp eval testinterp {raise .}
- interp eval testinterp {menu .m1}
- interp eval testinterp {. configure -menu .m1}
- interp eval testinterp {update}
- list [catch {menu .m1} msg] $msg [destroy .m1] [interp delete testinterp]
- } {0 .m1 {} {}}
- test macMenu-4.4 {TkpNewMenu - menubar set but new menu has different parent} {macOnly} {
- catch {destroy .m1}
- catch {destroy .m2}
- menu .m1 -tearoff 0
- .m1 add cascade -menu .m1.help
- menu .m2
- .m2 add cascade -menu .m2.help
- . configure -menu .m1
- raise .
- update
- list [catch {menu .m2.help} msg] $msg [. configure -menu ""] [destroy .m1] [destroy .m2]
- } {0 .m2.help {} {} {}}
- test macMenu-4.5 {TkpNewMenu - menubar set, same parent, not .help} {macOnly} {
- catch {destroy .m1}
- menu .m1 -tearoff 0
- .m1 add cascade -menu .m1.help
- . configure -menu .m1
- raise .
- update
- list [catch {menu .m1.foo} msg] $msg [. configure -menu ""] [destroy .m1]
- } {0 .m1.foo {} {}}
- test macMenu-4.6 {TkpNewMenu - creating the help menu} {macOnly} {
- catch {destroy .m1}
- menu .m1 -tearoff 0
- .m1 add cascade -menu .m1.help
- . configure -menu .m1
- raise .
- update
- list [catch {menu .m1.help} msg] $msg [. configure -menu ""] [destroy .m1]
- } {0 .m1.help {} {}}
- test macMenu-5.1 {TkpDestroyMenu} {macOnly} {
- catch {destroy .m1}
- menu .m1
- list [catch {destroy .m1} msg] $msg
- } {0 {}}
- test macMenu-5.2 {TkpDestroyMenu - help menu} {macOnly} {
- catch {destroy .m1}
- menu .m1 -tearoff 0
- .m1 add cascade -menu .m1.help
- . configure -menu .m1
- menu .m1.help
- raise .
- update
- list [catch {destroy .m1.help} msg] $msg [. configure -menu ""] [destroy .m1]
- } {0 {} {} {}}
- test macMenu-5.3 {TkpDestroyMenu - idle handler pending} {macOnly} {
- catch {destroy .m1}
- menu .m1
- .m1 add command -label test
- list [catch {destroy .m1} msg] $msg
- } {0 {}}
- test macMenu-5.4 {TkpDestroyMenu - idle handler not pending} {macOnly} {
- catch {destroy .m1}
- menu .m1
- .m1 add command -label test
- update idletasks
- list [catch {destroy .m1} msg] $msg
- } {0 {}}
- test macMenu-6.1 {SetMenuCascade} {macOnly} {
- catch {destroy .m1}
- catch {destroy .m2}
- menu .m1
- menu .m2
- list [catch {.m2 add cascade -menu .m1} msg] $msg [destroy .m1 .m2]
- } {0 {} {}}
- test macMenu-6.2 {SetMenuCascade - running out of ids} {macOnly} {
- deleteWindows
- menu .menu
- for {set i 0} {$i < 230} {incr i} {
- menu .m$i
- .menu add cascade -label ".m$i" -menu .m$i
- }
- menu .breaker
- list [catch {.menu add cascade -menu .breaker} msg] $msg [deleteWindows]
- } {1 {No more menus can be allocated.} {}}
- test macMenu-7.1 {TkpDestroyMenuEntry} {macOnly} {
- catch {destroy .m1}
- menu .m1
- .m1 add command -label "test"
- list [catch {.m1 delete 1} msg] $msg [destroy .m1]
- } {0 {} {}}
- test macMenu-7.2 {TkpDestroyMenuEntry - help menu} {macOnly} {
- catch {destroy .m1}
- menu .m1
- .m1 add cascade -menu .m1.help
- menu .m1.help -tearoff 0
- .m1.help add command -label "test"
- . configure -menu .m1
- raise .
- update
- list [catch {.m1.help delete test} msg] $msg [. configure -menu ""] [destroy .m1]
- } {0 {} {} {}}
- test macMenu-8.1 {GetEntryText} {macOnly} {
- catch {destroy .m1}
- list [catch {menu .m1} msg] $msg [destroy .m1]
- } {0 .m1 {}}
- test macMenu-8.2 {GetEntryText} {macOnly testImageType} {
- catch {destroy .m1}
- catch {image delete image1}
- menu .m1
- image create test image1
- list [catch {.m1 add command -image image1} msg] $msg [destroy .m1] [image delete image1]
- } {0 {} {} {}}
- test macMenu-8.3 {GetEntryText} {macOnly} {
- catch {destroy .m1}
- menu .m1
- list [catch {.m1 add command -bitmap questhead} msg] $msg [destroy .m1]
- } {0 {} {}}
- test macMenu-8.4 {GetEntryText} {macOnly} {
- catch {destroy .m1}
- menu .m1
- list [catch {.m1 add command} msg] $msg [destroy .m1]
- } {0 {} {}}
- test macMenu-8.5 {GetEntryText} {macOnly} {
- catch {destroy .m1}
- menu .m1
- .m1 add command -label "foo"
- list [catch {.m1 add command -label "foo"} msg] $msg [destroy .m1]
- } {0 {} {}}
- test macMenu-8.6 {GetEntryText} {macOnly} {
- catch {destroy .m1}
- menu .m1
- list [catch {.m1 add command -label "This is a very long string. 9012345678900123456789001234567890012345678900123456789001234567890012345678900123456789001234567890012345678900123456789001234567890012345678900123456789001234567890012345678900123456789001234567890012345678900123456789001234567890"}
- msg] $msg [destroy .m1]
- } {0 {} {}}
- test macMenu-8.7 {GetEntryText - elipses character} {macOnly} {
- catch {destroy .m1}
- menu .m1
- list [catch {.m1 add command -label "foo..."} msg] $msg [destroy .m1]
- } {0 {} {}}
- test macMenu-8.8 {GetEntryText - false elipses character} {macOnly} {
- catch {destroy .m1}
- menu .m1
- list [catch {.m1 add command -label "foo."} msg] $msg [destroy .m1]
- } {0 {} {}}
- test macMenu-8.9 {GetEntryText - false elipses character} {macOnly} {
- catch {destroy .m1}
- menu .m1
- list [catch {.m1 add command -label "foo.."} msg] $msg [destroy .m1]
- } {0 {} {}}
- test macMenu-8.10 {GetEntryText - false elipses character} {macOnly} {
- catch {destroy .m1}
- menu .m1
- list [catch {.m1 add command -label "foo.b"} msg] $msg [destroy .m1]
- } {0 {} {}}
- test macMenu-8.11 {GetEntryText - false elipses character} {macOnly} {
- catch {destroy .m1}
- menu .m1
- list [catch {.m1 add command -label "foo..b"} msg] $msg [destroy .m1]
- } {0 {} {}}
- # test macMenu-9.1 - assumes some fonts
- test macMenu-9.1 {FindMarkCharacter} {macOnly} {
- catch {destroy .m1}
- menu .m1 -font "Helvetica 12" -tearoff 0
- .m1 add checkbutton -label test
- .m1 invoke test
- list [catch {update idletasks} msg] $msg [destroy .m1]
- } {0 {} {}}
- # All standard fonts have "