textWind.test
上传用户:rrhhcc
上传日期:2015-12-11
资源大小:54129k
文件大小:29k
源码类别:

通讯编程

开发平台:

Visual C++

  1. # This file is a Tcl script to test the code in the file tkTextWind.c.
  2. # This file is organized in the standard fashion for Tcl tests.
  3. #
  4. # Copyright (c) 1994 The Regents of the University of California.
  5. # Copyright (c) 1994-1995 Sun Microsystems, Inc.
  6. # Copyright (c) 1998-1999 by Scriptics Corporation.
  7. # All rights reserved.
  8. #
  9. # RCS: @(#) $Id: textWind.test,v 1.5.2.1 2005/11/30 23:42:49 hobbs Exp $
  10. package require tcltest 2.1
  11. namespace import -force tcltest::configure
  12. namespace import -force tcltest::testsDirectory
  13. configure -testdir [file join [pwd] [file dirname [info script]]]
  14. configure -loadfile [file join [testsDirectory] constraints.tcl]
  15. tcltest::loadTestedCommands
  16. # Create entries in the option database to be sure that geometry options
  17. # like border width have predictable values.
  18. option add *Text.borderWidth 2
  19. option add *Text.highlightThickness 2
  20. option add *Text.font {Courier -12}
  21. text .t -width 30 -height 6 -bd 2 -highlightthickness 2
  22. pack append . .t {top expand fill}
  23. update
  24. .t debug on
  25. wm geometry . {}
  26. if {[winfo depth .t] > 1} {
  27.     set color green
  28. } else {
  29.     set color black
  30. }
  31. # The statements below reset the main window;  it's needed if the window
  32. # manager is mwm to make mwm forget about a previous minimum size setting.
  33. wm withdraw .
  34. wm minsize . 1 1
  35. wm positionfrom . user
  36. wm deiconify .
  37. test textWind-1.1 {basic tests of options} {fonts} {
  38.     .t delete 1.0 end
  39.     .t insert end "This is the first line"
  40.     .t insert end "nAnd this is a second line, which wraps around"
  41.     frame .f -width 3 -height 3 -bg $color
  42.     .t window create 2.2 -window .f
  43.     update
  44.     list [winfo ismapped .f] [winfo geom .f] [.t bbox .f] 
  45.     [.t window configure .f -window]
  46. } {1 3x3+19+23 {19 23 3 3} {-window {} {} {} .f}}
  47. test textWind-1.2 {basic tests of options} {fonts} {
  48.     .t delete 1.0 end
  49.     .t insert end "This is the first line"
  50.     .t insert end "nAnd this is a second line, which wraps around"
  51.     frame .f -width 3 -height 3 -bg $color
  52.     .t window create 2.2 -window .f -align top
  53.     update
  54.     list [winfo ismapped .f] [winfo geom .f] [.t bbox .f] 
  55.     [.t window configure .f -align]
  56. } {1 3x3+19+18 {19 18 3 3} {-align {} {} center top}}
  57. test textWind-1.3 {basic tests of options} {
  58.     .t delete 1.0 end
  59.     .t insert end "This is the first line"
  60.     .t insert end "nAnd this is a second line, which wraps around"
  61.     .t window create 2.2 -create "Test script"
  62.     .t window configure 2.2 -create
  63. } {-create {} {} {} {Test script}}
  64. test textWind-1.4 {basic tests of options} {fonts} {
  65.     .t delete 1.0 end
  66.     .t insert end "This is the first line"
  67.     .t insert end "nAnd this is a second line, which wraps around"
  68.     frame .f -width 10 -height 20 -bg $color
  69.     .t window create 2.2 -window .f -padx 5
  70.     update
  71.     list [winfo geom .f] [.t window configure .f -padx] [.t bbox 2.3]
  72. } {10x20+24+18 {-padx {} {} 0 5} {39 21 7 13}}
  73. test textWind-1.5 {basic tests of options} {fonts} {
  74.     .t delete 1.0 end
  75.     .t insert end "This is the first line"
  76.     .t insert end "nAnd this is a second line, which wraps around"
  77.     frame .f -width 10 -height 20 -bg $color
  78.     .t window create 2.2 -window .f -pady 4
  79.     update
  80.     list [winfo geom .f] [.t window configure .f -pady] [.t bbox 2.31]
  81. } {10x20+19+22 {-pady {} {} 0 4} {19 46 7 13}}
  82. test textWind-1.6 {basic tests of options} {fonts} {
  83.     .t delete 1.0 end
  84.     .t insert end "This is the first line"
  85.     .t insert end "nAnd this is a second line, which wraps around"
  86.     frame .f -width 5 -height 5 -bg $color
  87.     .t window create 2.2 -window .f -stretch 1
  88.     update
  89.     list [winfo geom .f] [.t window configure .f -stretch]
  90. } {5x13+19+18 {-stretch {} {} 0 1}}
  91. .t delete 1.0 end
  92. .t insert end "This is the first line"
  93. frame .f -width 10 -height 6 -bg $color
  94. .t window create 1.3 -window .f -padx 1 -pady 2
  95. test textWind-2.1 {TkTextWindowCmd procedure} {
  96.     list [catch {.t window} msg] $msg
  97. } {1 {wrong # args: should be ".t window option ?arg arg ...?"}}
  98. test textWind-2.2 {TkTextWindowCmd procedure, "cget" option} {
  99.     list [catch {.t window cget} msg] $msg
  100. } {1 {wrong # args: should be ".t window cget index option"}}
  101. test textWind-2.3 {TkTextWindowCmd procedure, "cget" option} {
  102.     list [catch {.t window cget a b c} msg] $msg
  103. } {1 {wrong # args: should be ".t window cget index option"}}
  104. test textWind-2.4 {TkTextWindowCmd procedure, "cget" option} {
  105.     list [catch {.t window cget gorp -padx} msg] $msg
  106. } {1 {bad text index "gorp"}}
  107. test textWind-2.5 {TkTextWindowCmd procedure, "cget" option} {
  108.     list [catch {.t window cget 1.2 -padx} msg] $msg
  109. } {1 {no embedded window at index "1.2"}}
  110. test textWind-2.6 {TkTextWindowCmd procedure, "cget" option} {
  111.     list [catch {.t window cget .f -bogus} msg] $msg
  112. } {1 {unknown option "-bogus"}}
  113. test textWind-2.7 {TkTextWindowCmd procedure, "cget" option} {
  114.     list [catch {.t window cget .f -pady} msg] $msg
  115. } {0 2}
  116. test textWind-2.8 {TkTextWindowCmd procedure} {
  117.     list [catch {.t window co} msg] $msg
  118. } {1 {wrong # args: should be ".t window configure index ?option value ...?"}}
  119. test textWind-2.9 {TkTextWindowCmd procedure} {
  120.     list [catch {.t window configure gorp} msg] $msg
  121. } {1 {bad text index "gorp"}}
  122. test textWind-2.10 {TkTextWindowCmd procedure} {
  123.     .t delete 1.0 end
  124.     list [catch {.t window configure 1.0} msg] $msg
  125. } {1 {no embedded window at index "1.0"}}
  126. test textWind-2.11 {TkTextWindowCmd procedure} {
  127.     .t delete 1.0 end
  128.     .t insert end "This is the first line"
  129.     .t insert end "nAnd this is a second line, which wraps around"
  130.     frame .f -width 10 -height 6 -bg $color
  131.     .t window create 2.2 -window .f -align baseline -padx 1 -pady 2 -create foo
  132.     update
  133.     list [catch {.t window configure .f} msg] $msg
  134. } {0 {{-align {} {} center baseline} {-create {} {} {} foo} {-padx {} {} 0 1} {-pady {} {} 0 2} {-stretch {} {} 0 0} {-window {} {} {} .f}}}
  135. test textWind-2.12 {TkTextWindowCmd procedure} {
  136.     .t delete 1.0 end
  137.     .t insert end "This is the first line"
  138.     .t insert end "nAnd this is a second line, which wraps around"
  139.     frame .f -width 10 -height 6 -bg $color
  140.     .t window create 2.2 -window .f -align baseline -padx 1 -pady 2 -create foo
  141.     update
  142.     list [.t window configure .f -padx 33] [.t window configure .f -padx]
  143. } {{} {-padx {} {} 0 33}}
  144. test textWind-2.13 {TkTextWindowCmd procedure} {
  145.     .t delete 1.0 end
  146.     .t insert end "This is the first line"
  147.     .t insert end "nAnd this is a second line, which wraps around"
  148.     frame .f -width 10 -height 6 -bg $color
  149.     .t window create 2.2 -window .f -align baseline -padx 1 -pady 2
  150.     update
  151.     list [.t window configure .f -padx 14 -pady 15] 
  152.     [.t window configure .f -padx] [.t window configure .f -pady]
  153. } {{} {-padx {} {} 0 14} {-pady {} {} 0 15}}
  154. test textWind-2.14 {TkTextWindowCmd procedure} {
  155.     list [catch {.t window create} msg] $msg
  156. } {1 {wrong # args: should be ".t window create index ?option value ...?"}}
  157. test textWind-2.15 {TkTextWindowCmd procedure} {
  158.     list [catch {.t window create gorp} msg] $msg
  159. } {1 {bad text index "gorp"}}
  160. test textWind-2.16 {TkTextWindowCmd procedure, don't insert after end} {
  161.     .t delete 1.0 end
  162.     .t insert end "Line 1nLine 2"
  163.     frame .f -width 20 -height 10 -bg $color
  164.     .t window create end -window .f
  165.     .t index .f
  166. } {2.6}
  167. test textWind-2.17 {TkTextWindowCmd procedure} {
  168.     .t delete 1.0 end
  169.     list [catch {.t window create 1.0} msg] $msg [.t window configure 1.0]
  170. } {0 {} {{-align {} {} center center} {-create {} {} {} {}} {-padx {} {} 0 0} {-pady {} {} 0 0} {-stretch {} {} 0 0} {-window {} {} {} {}}}}
  171. test textWind-2.18 {TkTextWindowCmd procedure} {
  172.     .t delete 1.0 end
  173.     frame .f -width 10 -height 6 -bg $color
  174.     list [catch {.t window create 1.0 -window .f -gorp stupid} msg] $msg 
  175.     [winfo exists .f] [.t index 1.end] [catch {.t index .f}]
  176. } {1 {unknown option "-gorp"} 0 1.0 1}
  177. test textWind-2.19 {TkTextWindowCmd procedure} {
  178.     .t delete 1.0 end
  179.     frame .f -width 10 -height 6 -bg $color
  180.     list [catch {.t window create 1.0 -gorp -window .f stupid} msg] $msg 
  181.     [winfo exists .f] [.t index 1.end] [catch {.t index .f}]
  182. } {1 {unknown option "-gorp"} 1 1.0 1}
  183. test textWind-2.20 {TkTextWindowCmd procedure} {
  184.     list [catch {.t window c} msg] $msg
  185. } {1 {bad window option "c": must be cget, configure, create, or names}}
  186. destroy .f
  187. test textWind-2.21 {TkTextWindowCmd procedure, "names" option} {
  188.     list [catch {.t window names foo} msg] $msg
  189. } {1 {wrong # args: should be ".t window names"}}
  190. test textWind-2.22 {TkTextWindowCmd procedure, "names" option} {
  191.     .t delete 1.0 end
  192.     .t window names
  193. } {}
  194. test textWind-2.23 {TkTextWindowCmd procedure, "names" option} {
  195.     .t delete 1.0 end
  196.     foreach i {.f .f2 .t.f .t.f2} {
  197. frame $i -width 20 -height 20
  198. .t window create end -window $i
  199.     }
  200.     set result [.t window names]
  201.     destroy .f .f2 .t.f .t.f2
  202.     lsort $result
  203. } {.f .f2 .t.f .t.f2}
  204. test textWind-3.1 {EmbWinConfigure procedure} {
  205.     .t delete 1.0 end
  206.     frame .f -width 10 -height 6 -bg $color
  207.     .t window create 1.0 -window .f
  208.     list [catch {.t window configure 1.0 -foo bar} msg] $msg
  209. } {1 {unknown option "-foo"}}
  210. test textWind-3.2 {EmbWinConfigure procedure} {fonts} {
  211.     .t delete 1.0 end
  212.     .t insert 1.0 "Some sample text"
  213.     frame .f -width 10 -height 20 -bg $color
  214.     .t window create 1.3 -window .f
  215.     update
  216.     .t window configure 1.3 -window {}
  217.     update
  218.     list [catch {.t index .f} msg] $msg [winfo ismapped .f] [.t bbox 1.4]
  219. } {1 {bad text index ".f"} 0 {26 5 7 13}}
  220. catch {destroy .f}
  221. test textWind-3.3 {EmbWinConfigure procedure} {fonts} {
  222.     .t delete 1.0 end
  223.     .t insert 1.0 "Some sample text"
  224.     frame .t.f -width 10 -height 20 -bg $color
  225.     .t window create 1.3 -window .t.f
  226.     update
  227.     .t window configure 1.3 -window {}
  228.     update
  229.     list [catch {.t index .t.f} msg] $msg [winfo ismapped .t.f] [.t bbox 1.4]
  230. } {1 {bad text index ".t.f"} 0 {26 5 7 13}}
  231. catch {destroy .t.f}
  232. test textWind-3.4 {EmbWinConfigure procedure} {fonts} {
  233.     .t delete 1.0 end
  234.     .t insert 1.0 "Some sample text"
  235.     frame .f -width 10 -height 20 -bg $color
  236.     .t window create 1.3
  237.     update
  238.     .t window configure 1.3 -window .f
  239.     update
  240.     list [catch {.t index .f} msg] $msg [winfo ismapped .f] [.t bbox 1.4]
  241. } {0 1.3 1 {36 8 7 13}}
  242. test textWind-3.5 {EmbWinConfigure procedure} {
  243.     .t delete 1.0 end
  244.     .t insert 1.0 "Some sample text"
  245.     frame .f
  246.     frame .f.f -width 15 -height 20 -bg $color
  247.     pack .f.f
  248.     list [catch {.t window create 1.3 -window .f.f} msg] $msg
  249. } {1 {can't embed .f.f in .t}}
  250. catch {destroy .f}
  251. test textWind-3.6 {EmbWinConfigure procedure} {
  252.     .t delete 1.0 end
  253.     .t insert 1.0 "Some sample text"
  254.     toplevel .t2 -width 20 -height 10 -bg $color
  255.     .t window create 1.3
  256.     list [catch {.t window configure 1.3 -window .t2} msg] $msg 
  257.     [.t window configure 1.3 -window]
  258. } {1 {can't embed .t2 in .t} {-window {} {} {} {}}}
  259. catch {destroy .t2}
  260. test textWind-3.7 {EmbWinConfigure procedure} {
  261.     .t delete 1.0 end
  262.     .t insert 1.0 "Some sample text"
  263.     .t window create 1.3
  264.     list [catch {.t window configure 1.3 -window .t} msg] $msg
  265. } {1 {can't embed .t in .t}}
  266. test textWind-3.8 {EmbWinConfigure procedure} {
  267.     # This test checks for various errors when the text claims
  268.     # a window away from itself.
  269.     .t delete 1.0 end
  270.     .t insert 1.0 "Some sample text"
  271.     button .t.b -text "Hello!"
  272.     .t window create 1.4 -window .t.b
  273.     .t window create 1.6 -window .t.b
  274.     update
  275.     .t index .t.b
  276. } {1.6}
  277. .t delete 1.0 end
  278. frame .f -width 10 -height 20 -bg $color
  279. .t window create 1.0 -window .f
  280. test textWind-4.1 {AlignParseProc and AlignPrintProc procedures} {
  281.     .t window configure 1.0 -align baseline
  282.     .t window configure 1.0 -align
  283. } {-align {} {} center baseline}
  284. test textWind-4.2 {AlignParseProc and AlignPrintProc procedures} {
  285.     .t window configure 1.0 -align bottom
  286.     .t window configure 1.0 -align
  287. } {-align {} {} center bottom}
  288. test textWind-4.3 {AlignParseProc and AlignPrintProc procedures} {
  289.     .t window configure 1.0 -align center
  290.     .t window configure 1.0 -align
  291. } {-align {} {} center center}
  292. test textWind-4.4 {AlignParseProc and AlignPrintProc procedures} {
  293.     .t window configure 1.0 -align top
  294.     .t window configure 1.0 -align
  295. } {-align {} {} center top}
  296. test textWind-4.5 {AlignParseProc and AlignPrintProc procedures} {
  297.     .t window configure 1.0 -align top
  298.     list [catch {.t window configure 1.0 -align gorp} msg] $msg 
  299.     [.t window configure 1.0 -align]
  300. } {1 {bad alignment "gorp": must be baseline, bottom, center, or top} {-align {} {} center top}}
  301. test textWind-5.1 {EmbWinStructureProc procedure} {fonts} {
  302.     .t delete 1.0 end
  303.     .t insert 1.0 "Some sample text"
  304.     frame .f -width 10 -height 20 -bg $color
  305.     .t window create 1.2 -window .f
  306.     update
  307.     destroy .f
  308.     list [catch {.t index .f} msg] $msg [.t bbox 1.2] [.t bbox 1.3]
  309. } {1 {bad text index ".f"} {19 11 0 0} {19 5 7 13}}
  310. test textWind-5.2 {EmbWinStructureProc procedure} {fonts} {
  311.     .t delete 1.0 end
  312.     .t insert 1.0 "Some sample text"
  313.     frame .f -width 10 -height 20 -bg $color
  314.     .t window create 1.2 -align bottom
  315.     .t window configure 1.2 -window .f
  316.     update
  317.     destroy .f
  318.     list [catch {.t index .f} msg] $msg [.t bbox 1.2] [.t bbox 1.3]
  319. } {1 {bad text index ".f"} {19 18 0 0} {19 5 7 13}}
  320. test textWind-5.3 {EmbWinStructureProc procedure} {fonts} {
  321.     .t delete 1.0 end
  322.     .t insert 1.0 "Some sample text"
  323.     .t window create 1.2 -create {frame .f -width 10 -height 20 -bg $color}
  324.     update
  325.     .t window configure 1.2 -create {frame .f -width 20 -height 10 -bg $color}
  326.     destroy .f
  327.     update
  328.     list [catch {.t index .f} msg] $msg [.t bbox 1.2] [.t bbox 1.3]
  329. } {0 1.2 {19 6 20 10} {39 5 7 13}}
  330. test textWind-6.1 {EmbWinRequestProc procedure} {fonts} {
  331.     .t delete 1.0 end
  332.     .t insert 1.0 "Some sample text"
  333.     frame .f -width 10 -height 20 -bg $color
  334.     .t window create 1.2 -window .f
  335.     set result {}
  336.     lappend result [.t bbox 1.2] [.t bbox 1.3]
  337.     .f configure -width 25 -height 30
  338.     lappend result [.t bbox 1.2] [.t bbox 1.3]
  339. } {{19 5 10 20} {29 8 7 13} {19 5 25 30} {44 13 7 13}}
  340. test textWind-7.1 {EmbWinLostSlaveProc procedure} {fonts} {
  341.     .t delete 1.0 end
  342.     .t insert 1.0 "Some sample text"
  343.     frame .f -width 10 -height 20 -bg $color
  344.     .t window create 1.2 -window .f
  345.     update
  346.     place .f -in .t -x 100 -y 50
  347.     update
  348.     list [winfo geom .f] [.t bbox 1.2]
  349. } {10x20+104+54 {19 11 0 0}}
  350. test textWind-7.2 {EmbWinLostSlaveProc procedure} {fonts} {
  351.     .t delete 1.0 end
  352.     .t insert 1.0 "Some sample text"
  353.     frame .t.f -width 10 -height 20 -bg $color
  354.     .t window create 1.2 -window .t.f
  355.     update
  356.     place .t.f -x 100 -y 50
  357.     update
  358.     list [winfo geom .t.f] [.t bbox 1.2]
  359. } {10x20+104+54 {19 11 0 0}}
  360. catch {destroy .f}
  361. catch {destroy .t.f}
  362. test textWind-8.1 {EmbWinDeleteProc procedure} {fonts} {
  363.     .t delete 1.0 end
  364.     .t insert 1.0 "Some sample text"
  365.     frame .f -width 10 -height 20 -bg $color
  366.     .t window create 1.2 -window .f
  367.     bind .f <Destroy> {set x destroyed}
  368.     set x XXX
  369.     .t delete 1.2
  370.     list $x [.t bbox 1.2] [.t bbox 1.3] [catch {.t index .f} msg] $msg 
  371.     [winfo exists .f]
  372. } {destroyed {19 5 7 13} {26 5 7 13} 1 {bad text index ".f"} 0}
  373. test textWind-9.1 {EmbWinCleanupProc procedure} {
  374.     .t delete 1.0 end
  375.     .t insert 1.0 "Some sample textnA second line."
  376.     frame .f -width 10 -height 20 -bg $color
  377.     .t window create 2.3 -window .f
  378.     .t delete 1.5 2.1
  379.     .t index .f
  380. } 1.7
  381. proc bgerror args {
  382.     global msg
  383.     set msg $args
  384. }
  385. test textWind-10.1 {EmbWinLayoutProc procedure} {
  386.     .t delete 1.0 end
  387.     .t insert 1.0 "Some sample text"
  388.     .t window create 1.5 -create {
  389. frame .f -width 10 -height 20 -bg $color
  390.     }
  391.     update
  392.     list [winfo exists .f] [winfo geom .f] [.t index .f]
  393. } {1 10x20+40+5 1.5}
  394. test textWind-10.2 {EmbWinLayoutProc procedure, error in creating window} {fonts} {
  395.     .t delete 1.0 end
  396.     .t insert 1.0 "Some sample text"
  397.     .t window create 1.5 -create {
  398. error "couldn't create window"
  399.     }
  400.     set msg xyzzy
  401.     update
  402.     list $msg [.t bbox 1.5]
  403. } {{{couldn't create window}} {40 11 0 0}}
  404. test textWind-10.3 {EmbWinLayoutProc procedure, error in creating window} {fonts} {
  405.     .t delete 1.0 end
  406.     .t insert 1.0 "Some sample text"
  407.     .t window create 1.5 -create {
  408. concat gorp
  409.     }
  410.     set msg xyzzy
  411.     update
  412.     list $msg [.t bbox 1.5]
  413. } {{{bad window path name "gorp"}} {40 11 0 0}}
  414. test textWind-10.4 {EmbWinLayoutProc procedure, error in creating window} {fonts} {
  415.     .t delete 1.0 end
  416.     .t insert 1.0 "Some sample text"
  417.     .t window create 1.5 -create {
  418. frame .t.f
  419. frame .t.f.f -width 10 -height 20 -bg $color
  420.     }
  421.     set msg xyzzy
  422.     update
  423.     list $msg [.t bbox 1.5] [winfo exists .t.f.f]
  424. } {{{can't embed .t.f.f relative to .t}} {40 11 0 0} 1}
  425. catch {destroy .t.f}
  426. test textWind-10.5 {EmbWinLayoutProc procedure, error in creating window} {fonts} {
  427.     .t delete 1.0 end
  428.     .t insert 1.0 "Some sample text"
  429.     .t window create 1.5 -create {
  430. concat .t
  431.     }
  432.     set msg xyzzy
  433.     update
  434.     list $msg [.t bbox 1.5]
  435. } {{{can't embed .t relative to .t}} {40 11 0 0}}
  436. test textWind-10.6 {EmbWinLayoutProc procedure, error in creating window} {fonts} {
  437.     .t delete 1.0 end
  438.     .t insert 1.0 "Some sample text"
  439.     .t window create 1.5 -create {
  440. toplevel .t2 -width 100 -height 150
  441. wm geom .t2 +0+0
  442. concat .t2
  443.     }
  444.     set msg xyzzy
  445.     update
  446.     list $msg [.t bbox 1.5]
  447. } {{{can't embed .t2 relative to .t}} {40 11 0 0}}
  448. test textWind-10.7 {EmbWinLayoutProc procedure, steal window from self} {
  449.     .t delete 1.0 end
  450.     .t insert 1.0 ABCDEFGHIJKLMNOP
  451.     button .t.b -text "Hello!"
  452.     .t window create 1.5 -window .t.b
  453.     update
  454.     .t window create 1.3 -create {concat .t.b}
  455.     update
  456.     .t index .t.b
  457. } {1.3}
  458. catch {destroy .t2}
  459. test textWind-10.8 {EmbWinLayoutProc procedure, doesn't fit on line} {fonts} {
  460.     .t configure -wrap char
  461.     .t delete 1.0 end
  462.     .t insert 1.0 "Some sample text"
  463.     frame .f -width 125 -height 20 -bg $color -bd 2 -relief raised
  464.     .t window create 1.12 -window .f
  465.     list [.t bbox .f] [.t bbox 1.13]
  466. } {{89 5 126 20} {5 25 7 13}}
  467. test textWind-10.9 {EmbWinLayoutProc procedure, doesn't fit on line} {fonts} {
  468.     .t configure -wrap char
  469.     .t delete 1.0 end
  470.     .t insert 1.0 "Some sample text"
  471.     frame .f -width 126 -height 20 -bg $color -bd 2 -relief raised
  472.     .t window create 1.12 -window .f
  473.     update
  474.     list [.t bbox .f] [.t bbox 1.13]
  475. } {{89 5 126 20} {5 25 7 13}}
  476. test textWind-10.10 {EmbWinLayoutProc procedure, doesn't fit on line} {fonts} {
  477.     .t configure -wrap char
  478.     .t delete 1.0 end
  479.     .t insert 1.0 "Some sample text"
  480.     frame .f -width 127 -height 20 -bg $color -bd 2 -relief raised
  481.     .t window create 1.12 -window .f
  482.     update
  483.     list [.t bbox .f] [.t bbox 1.13]
  484. } {{5 18 127 20} {132 21 7 13}}
  485. test textWind-10.11 {EmbWinLayoutProc procedure, doesn't fit on line} {
  486.     .t configure -wrap none
  487.     .t delete 1.0 end
  488.     .t insert 1.0 "Some sample text"
  489.     frame .f -width 130 -height 20 -bg $color -bd 2 -relief raised
  490.     .t window create 1.12 -window .f
  491.     update
  492.     list [.t bbox .f] [.t bbox 1.13]
  493. } {{89 5 126 20} {}}
  494. test textWind-10.12 {EmbWinLayoutProc procedure, doesn't fit on line} {fonts} {
  495.     .t configure -wrap none
  496.     .t delete 1.0 end
  497.     .t insert 1.0 "Some sample text"
  498.     frame .f -width 130 -height 220 -bg $color -bd 2 -relief raised
  499.     .t window create 1.12 -window .f
  500.     update
  501.     list [.t bbox .f] [.t bbox 1.13]
  502. } {{89 5 126 78} {}}
  503. test textWind-10.13 {EmbWinLayoutProc procedure, doesn't fit on line} {fonts} {
  504.     .t configure -wrap char
  505.     .t delete 1.0 end
  506.     .t insert 1.0 "Some sample text"
  507.     frame .f -width 250 -height 220 -bg $color -bd 2 -relief raised
  508.     .t window create 1.12 -window .f
  509.     update
  510.     list [.t bbox .f] [.t bbox 1.13]
  511. } {{5 18 210 65} {}}
  512. test textWind-11.1 {EmbWinDisplayProc procedure, geometry transforms} {
  513.     .t delete 1.0 end
  514.     .t insert 1.0 "Some sample text"
  515.     pack forget .t
  516.     place .t -x 30 -y 50
  517.     frame .f -width 30 -height 20 -bg $color
  518.     .t window create 1.12 -window .f
  519.     update
  520.     winfo geom .f
  521. } {30x20+119+55}
  522. place forget .t
  523. pack .t
  524. test textWind-11.2 {EmbWinDisplayProc procedure, geometry transforms} {
  525.     .t delete 1.0 end
  526.     .t insert 1.0 "Some sample text"
  527.     pack forget .t
  528.     place .t -x 30 -y 50
  529.     frame .t.f -width 30 -height 20 -bg $color
  530.     .t window create 1.12 -window .t.f
  531.     update
  532.     winfo geom .t.f
  533. } {30x20+89+5}
  534. place forget .t
  535. pack .t
  536. test textWind-11.3 {EmbWinDisplayProc procedure, configuration optimization} {
  537.     .t delete 1.0 end
  538.     .t insert 1.0 "Some sample text"
  539.     frame .f -width 30 -height 20 -bg $color
  540.     .t window create 1.12 -window .f
  541.     update
  542.     bind .f <Configure> {set x ".f configured"}
  543.     set x {no configures}
  544.     .t delete 1.0
  545.     .t insert 1.0 "X"
  546.     update
  547.     set x
  548. } {no configures}
  549. test textWind-11.4 {EmbWinDisplayProc procedure, horizontal scrolling} {fonts} {
  550.     .t delete 1.0 end
  551.     .t insert 1.0 "xyzzynFirst window here: "
  552.     .t configure -wrap none
  553.     frame .f -width 30 -height 20 -bg $color
  554.     .t window create end -window .f
  555.     .t insert end " and second here: "
  556.     frame .f2 -width 40 -height 10 -bg $color
  557.     .t window create end -window .f2
  558.     .t insert end " with junk after it."
  559.     .t xview moveto 0
  560.     .t xview scroll 5 units
  561.     update
  562.     list [winfo ismapped .f] [winfo geom .f] [.t bbox .f] [winfo ismapped .f2]
  563. } {1 30x20+103+18 {103 18 30 20} 0}
  564. test textWind-11.5 {EmbWinDisplayProc procedure, horizontal scrolling} {fonts} {
  565.     .t delete 1.0 end
  566.     .t insert 1.0 "xyzzynFirst window here: "
  567.     .t configure -wrap none
  568.     frame .f -width 30 -height 20 -bg $color
  569.     .t window create end -window .f
  570.     .t insert end " and second here: "
  571.     frame .f2 -width 40 -height 10 -bg $color
  572.     .t window create end -window .f2
  573.     .t insert end " with junk after it."
  574.     update
  575.     .t xview moveto 0
  576.     .t xview scroll 25 units
  577.     update
  578.     list [winfo ismapped .f] [winfo ismapped .f2] [winfo geom .f2] [.t bbox .f2]
  579. } {0 1 40x10+119+23 {119 23 40 10}}
  580. .t configure -wrap char
  581. test textWind-12.1 {EmbWinUndisplayProc procedure, mapping/unmapping} {
  582.     .t delete 1.0 end
  583.     .t insert 1.0 "Some sample text"
  584.     frame .f -width 30 -height 20 -bg $color
  585.     .t window create 1.2 -window .f
  586.     bind .f <Map> {lappend x mapped}
  587.     bind .f <Unmap> {lappend x unmapped}
  588.     set x created
  589.     update
  590.     lappend x modified
  591.     .t delete 1.0
  592.     update
  593.     lappend x replaced
  594.     .t window configure .f -window {}
  595.     .t delete 1.1
  596.     .t window create 1.4 -window .f
  597.     update
  598.     lappend x off-screen
  599.     .t configure -wrap none
  600.     .t insert 1.0 "Enough text to make the line run off-screen"
  601.     update
  602.     set x
  603. } {created mapped modified replaced unmapped mapped off-screen unmapped}
  604. test textWind-13.1 {EmbWinBboxProc procedure} {
  605.     .t delete 1.0 end
  606.     .t insert 1.0 "Some sample text"
  607.     frame .f -width 5 -height 5 -bg $color
  608.     .t window create 1.2 -window .f -align top -padx 2 -pady 1
  609.     update
  610.     list [winfo geom .f] [.t bbox .f]
  611. } {5x5+21+6 {21 6 5 5}}
  612. test textWind-13.2 {EmbWinBboxProc procedure} {
  613.     .t delete 1.0 end
  614.     .t insert 1.0 "Some sample text"
  615.     frame .f -width 5 -height 5 -bg $color
  616.     .t window create 1.2 -window .f -align center -padx 2 -pady 1
  617.     update
  618.     list [winfo geom .f] [.t bbox .f]
  619. } {5x5+21+9 {21 9 5 5}}
  620. test textWind-13.3 {EmbWinBboxProc procedure} {fonts} {
  621.     .t delete 1.0 end
  622.     .t insert 1.0 "Some sample text"
  623.     frame .f -width 5 -height 5 -bg $color
  624.     .t window create 1.2 -window .f -align baseline -padx 2 -pady 1
  625.     update
  626.     list [winfo geom .f] [.t bbox .f]
  627. } {5x5+21+10 {21 10 5 5}}
  628. test textWind-13.4 {EmbWinBboxProc procedure} {fonts} {
  629.     .t delete 1.0 end
  630.     .t insert 1.0 "Some sample text"
  631.     frame .f -width 5 -height 5 -bg $color
  632.     .t window create 1.2 -window .f -align bottom -padx 2 -pady 1
  633.     update
  634.     list [winfo geom .f] [.t bbox .f]
  635. } {5x5+21+12 {21 12 5 5}}
  636. test textWind-13.5 {EmbWinBboxProc procedure} {fonts} {
  637.     .t delete 1.0 end
  638.     .t insert 1.0 "Some sample text"
  639.     frame .f -width 5 -height 5 -bg $color
  640.     .t window create 1.2 -window .f -align top -padx 2 -pady 1 -stretch 1
  641.     update
  642.     list [winfo geom .f] [.t bbox .f]
  643. } {5x11+21+6 {21 6 5 11}}
  644. test textWind-13.6 {EmbWinBboxProc procedure} {fonts} {
  645.     .t delete 1.0 end
  646.     .t insert 1.0 "Some sample text"
  647.     frame .f -width 5 -height 5 -bg $color
  648.     .t window create 1.2 -window .f -align center -padx 2 -pady 1 -stretch 1
  649.     update
  650.     list [winfo geom .f] [.t bbox .f]
  651. } {5x11+21+6 {21 6 5 11}}
  652. test textWind-13.7 {EmbWinBboxProc procedure} {fonts} {
  653.     .t delete 1.0 end
  654.     .t insert 1.0 "Some sample text"
  655.     frame .f -width 5 -height 5 -bg $color
  656.     .t window create 1.2 -window .f -align baseline -padx 2 -pady 1 -stretch 1
  657.     update
  658.     list [winfo geom .f] [.t bbox .f]
  659. } {5x9+21+6 {21 6 5 9}}
  660. test textWind-13.8 {EmbWinBboxProc procedure} {fonts} {
  661.     .t delete 1.0 end
  662.     .t insert 1.0 "Some sample text"
  663.     frame .f -width 5 -height 5 -bg $color
  664.     .t window create 1.2 -window .f -align bottom -padx 2 -pady 1 -stretch 1
  665.     update
  666.     list [winfo geom .f] [.t bbox .f]
  667. } {5x11+21+6 {21 6 5 11}}
  668. test textWind-13.9 {EmbWinBboxProc procedure, spacing options} {
  669.     .t configure -spacing1 5 -spacing3 2
  670.     .t delete 1.0 end
  671.     .t insert 1.0 "Some sample text"
  672.     frame .f -width 5 -height 5 -bg $color
  673.     .t window create 1.2 -window .f -align center -padx 2 -pady 1
  674.     update
  675.     list [winfo geom .f] [.t bbox .f]
  676. } {5x5+21+14 {21 14 5 5}}
  677. .t configure -spacing1 0 -spacing2 0 -spacing3 0
  678. test textWind-14.1 {EmbWinDelayedUnmap procedure} {
  679.     .t delete 1.0 end
  680.     .t insert 1.0 "Some sample text"
  681.     frame .f -width 30 -height 20 -bg $color
  682.     .t window create 1.2 -window .f
  683.     update
  684.     bind .f <Unmap> {lappend x unmapped}
  685.     set x modified
  686.     .t insert 1.0 x
  687.     lappend x removed
  688.     .t window configure .f -window {}
  689.     lappend x updated
  690.     update
  691.     set x
  692. } {modified removed unmapped updated}
  693. catch {destroy .f}
  694. test textWind-14.2 {EmbWinDelayedUnmap procedure} {
  695.     .t delete 1.0 end
  696.     .t insert 1.0 "Some sample text"
  697.     frame .f -width 30 -height 20 -bg $color
  698.     .t window create 1.2 -window .f
  699.     update
  700.     bind .f <Unmap> {lappend x unmapped}
  701.     set x modified
  702.     .t insert 1.0 x
  703.     lappend x deleted
  704.     .t delete .f
  705.     lappend x updated
  706.     update
  707.     set x
  708. } {modified deleted updated}
  709. test textWind-14.3 {EmbWinDelayedUnmap procedure} {
  710.     .t delete 1.0 end
  711.     .t insert 1.0 "Some sample textnAnother linen3n4n5n6n7n8n9"
  712.     frame .f -width 30 -height 20 -bg $color
  713.     .t window create 1.2 -window .f
  714.     update
  715.     .t yview 2.0
  716.     set result [winfo ismapped .f]
  717.     update
  718.     list $result [winfo ismapped .f]
  719. } {1 0}
  720. test textWind-14.4 {EmbWinDelayedUnmap procedure} {
  721.     .t delete 1.0 end
  722.     .t insert 1.0 "Some sample textnAnother linen3n4n5n6n7n8n9"
  723.     frame .t.f -width 30 -height 20 -bg $color
  724.     .t window create 1.2 -window .t.f
  725.     update
  726.     .t yview 2.0
  727.     set result [winfo ismapped .t.f]
  728.     update
  729.     list $result [winfo ismapped .t.f]
  730. } {1 0}
  731. catch {destroy .t.f}
  732. catch {destroy .f}
  733. test textWind-15.1 {TkTextWindowIndex procedure} {
  734.     list [catch {.t index .foo} msg] $msg
  735. } {1 {bad text index ".foo"}}
  736. test textWind-15.2 {TkTextWindowIndex procedure} {fonts} {
  737.     .t configure -wrap none
  738.     .t delete 1.0 end
  739.     .t insert 1.0 "Some sample text"
  740.     frame .f -width 30 -height 20 -bg $color
  741.     .t window create 1.6 -window .f
  742.     .t tag add a 1.1
  743.     .t tag add a 1.3
  744.     list [.t index .f] [.t bbox 1.7]
  745. } {1.6 {77 8 7 13}}
  746. test textWind-16.1 {EmbWinTextStructureProc procedure} {
  747.     .t configure -wrap none
  748.     .t delete 1.0 end
  749.     .t insert 1.0 "Some sample text"
  750.     frame .f -width 30 -height 20 -bg $color
  751.     .t window create 1.6 -window .f
  752.     update
  753.     pack forget .t
  754.     update
  755.     winfo ismapped .f
  756. } 0
  757. pack .t
  758. test textWind-16.2 {EmbWinTextStructureProc procedure} {
  759.     .t configure -wrap none
  760.     .t delete 1.0 end
  761.     .t insert 1.0 "Some sample text"
  762.     frame .f -width 30 -height 20 -bg $color
  763.     .t window create 1.6 -window .f
  764.     update
  765.     set result {}
  766.     lappend result [winfo geom .f] [.t bbox .f]
  767.     frame .f2 -width 150 -height 30 -bd 2 -relief raised
  768.     pack .f2 -before .t
  769.     update
  770.     lappend result [winfo geom .f] [.t bbox .f]
  771. } {30x20+47+5 {47 5 30 20} 30x20+47+35 {47 5 30 20}}
  772. catch {destroy .f2}
  773. test textWind-16.3 {EmbWinTextStructureProc procedure} {
  774.     .t configure -wrap none
  775.     .t delete 1.0 end
  776.     .t insert 1.0 "Some sample text"
  777.     .t window create 1.6
  778.     update
  779.     pack forget .t
  780.     update
  781. } {}
  782. pack .t
  783. test textWind-16.4 {EmbWinTextStructureProc procedure} {
  784.     .t configure -wrap none
  785.     .t delete 1.0 end
  786.     .t insert 1.0 "Some sample text"
  787.     frame .t.f -width 30 -height 20 -bg $color
  788.     .t window create 1.6 -window .t.f
  789.     update
  790.     pack forget .t
  791.     update
  792.     list [winfo ismapped .t.f] [.t bbox .t.f]
  793. } {1 {47 5 30 20}}
  794. pack .t
  795. catch {destroy .t}
  796. option clear
  797. # cleanup
  798. ::tcltest::cleanupTests
  799. return