1 # This file is a Tcl script to test the tk command.
2 # It is organized in the standard fashion for Tcl tests.
4 # Copyright (c) 1997 Sun Microsystems, Inc.
5 # Copyright (c) 1998-1999 by Scriptics Corporation.
10 if {[lsearch [namespace children] ::tcltest] == -1} {
11 source [file join [pwd] [file dirname [info script]] defs.tcl]
14 test tk-1.1 {tk command: general} {
15 list [catch {tk} msg] $msg
16 } {1 {wrong # args: should be "tk option ?arg?"}}
17 test tk-1.2 {tk command: general} {
18 list [catch {tk xyz} msg] $msg
19 } {1 {bad option "xyz": must be appname, scaling, or useinputmethods}}
21 set appname [tk appname]
22 test tk-2.1 {tk command: appname} {
23 list [catch {tk appname xyz abc} msg] $msg
24 } {1 {wrong # args: should be "tk appname ?newName?"}}
25 test tk-2.2 {tk command: appname} {
26 tk appname foobazgarply
28 test tk-2.3 {tk command: appname} {unixOnly} {
29 tk appname bazfoogarply
30 expr {[lsearch -exact [winfo interps] [tk appname]] >= 0}
32 test tk-2.4 {tk command: appname} {
37 set scaling [tk scaling]
38 test tk-3.1 {tk command: scaling} {
39 list [catch {tk scaling -displayof} msg] $msg
40 } {1 {value for "-displayof" missing}}
41 test tk-3.2 {tk command: scaling: get current} {
43 format %.2g [tk scaling]
45 test tk-3.3 {tk command: scaling: get current} {
46 tk scaling -displayof . 1.25
47 format %.3g [tk scaling]
49 test tk-3.4 {tk command: scaling: set new} {
50 list [catch {tk scaling xyz} msg] $msg
51 } {1 {expected floating-point number but got "xyz"}}
52 test tk-3.5 {tk command: scaling: set new} {
53 list [catch {tk scaling -displayof . xyz} msg] $msg
54 } {1 {expected floating-point number but got "xyz"}}
55 test tk-3.6 {tk command: scaling: set new} {
57 format %.2g [tk scaling]
59 test tk-3.7 {tk command: scaling: set new} {
60 tk scaling -displayof . 1.25
61 format %.3g [tk scaling]
63 test tk-3.8 {tk command: scaling: negative} {
65 expr {[tk scaling] > 0}
67 test tk-3.9 {tk command: scaling: too big} {
69 expr {[tk scaling] < 10000}
71 test tk-3.10 {tk command: scaling: widthmm} {
73 expr {int((25.4*[winfo screenwidth .])/(72*1.25)+0.5)-[winfo screenmmwidth .]}
75 test tk-3.11 {tk command: scaling: heightmm} {
77 expr {int((25.4*[winfo screenheight .])/(72*1.25)+0.5)-[winfo screenmmheight .]}
81 set useim [tk useinputmethods]
82 test tk-4.1 {tk command: useinputmethods} {
83 list [catch {tk useinputmethods -displayof} msg] $msg
84 } {1 {value for "-displayof" missing}}
85 test tk-4.2 {tk command: useinputmethods: get current} {
88 test tk-4.3 {tk command: useinputmethods: get current} {
89 tk useinputmethods -displayof .
91 test tk-4.4 {tk command: useinputmethods: set new} {
92 list [catch {tk useinputmethods xyz} msg] $msg
93 } {1 {expected boolean value but got "xyz"}}
94 test tk-4.5 {tk command: useinputmethods: set new} {
95 list [catch {tk useinputmethods -displayof . xyz} msg] $msg
96 } {1 {expected boolean value but got "xyz"}}
97 test tk-4.6 {tk command: useinputmethods: set new} {unixOnly} {
98 # This isn't really a test, but more of a check...
99 # The answer is what was given, because we may be on a Unix
100 # system that doesn't have the XIM stuff
101 if {[tk useinputmethods 1] == 0} {
102 puts "this wish doesn't have XIM (X Input Methods) support"
104 # We should always start with XIM support off
107 test tk-4.7 {tk command: useinputmethods: set new} {macOrPc} {
108 # Mac and Windows don't have X Input Methods, so this should
112 tk useinputmethods $useim
115 ::tcltest::cleanupTests