home *** CD-ROM | disk | FTP | other *** search
/ Celestin Apprentice 7 / Apprentice-Release7.iso / Source Code / C / Applications / Tcl-Tk 8.0 / Pre-installed version / tk8.0 / tests / textWind.test < prev    next >
Encoding:
Text File  |  1997-08-15  |  28.5 KB  |  827 lines  |  [TEXT/ALFA]

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