1# This file is a Tcl script to test out the procedures in tkCanvWind.c, 2# which implement canvas "window" items. It is organized in the standard 3# fashion for Tcl tests. 4# 5# Copyright (c) 1997 Sun Microsystems, Inc. 6# Copyright (c) 1998-1999 by Scriptics Corporation. 7# All rights reserved. 8# 9# RCS: @(#) $Id: canvWind.test,v 1.4 2002/07/14 05:48:46 dgp Exp $ 10 11package require tcltest 2.1 12namespace import -force tcltest::configure 13namespace import -force tcltest::testsDirectory 14configure -testdir [file join [pwd] [file dirname [info script]]] 15configure -loadfile [file join [testsDirectory] constraints.tcl] 16tcltest::loadTestedCommands 17 18test canvWind-1.1 {DisplayWinItem, windows off-screen vertically} { 19 catch {destroy .t} 20 toplevel .t 21 canvas .t.c -scrollregion {0 0 1000 800} -width 250 -height 200 -bd 2 \ 22 -relief sunken -xscrollincrement 1 -yscrollincrement 1 \ 23 -highlightthickness 1 24 pack .t.c -fill both -expand 1 -padx 20 -pady 20 25 wm geometry .t +0+0 26 set f .t.f 27 frame $f -width 80 -height 50 -bg red 28 .t.c create window 300 400 -window $f -anchor nw 29 .t.c xview moveto .3 30 .t.c yview moveto .50 31 update 32 set x [list [list [winfo ismapped $f] [winfo y $f]]] 33 .t.c yview scroll 52 units 34 update 35 lappend x [list [winfo ismapped $f] [winfo y $f]] 36 .t.c yview scroll 1 units 37 update 38 lappend x [list [winfo ismapped $f] [winfo y $f]] 39 .t.c yview scroll -255 units 40 update 41 lappend x [list [winfo ismapped $f] [winfo y $f]] 42 .t.c yview scroll -1 units 43 update 44 lappend x [list [winfo ismapped $f] [winfo y $f]] 45} {{1 23} {1 -29} {0 -29} {1 225} {0 225}} 46test canvWind-1.2 {DisplayWinItem, windows off-screen vertically} { 47 catch {destroy .t} 48 toplevel .t 49 canvas .t.c -scrollregion {0 0 1000 800} -width 250 -height 200 -bd 2 \ 50 -relief sunken -xscrollincrement 1 -yscrollincrement 1 \ 51 -highlightthickness 1 52 pack .t.c -fill both -expand 1 -padx 20 -pady 20 53 wm geometry .t +0+0 54 set f .t.c.f 55 frame $f -width 80 -height 50 -bg red 56 .t.c create window 300 400 -window $f -anchor nw 57 .t.c xview moveto .3 58 .t.c yview moveto .50 59 update 60 set x [list [list [winfo ismapped $f] [winfo y $f]]] 61 .t.c yview scroll 52 units 62 update 63 lappend x [list [winfo ismapped $f] [winfo y $f]] 64 .t.c yview scroll 1 units 65 update 66 lappend x [list [winfo ismapped $f] [winfo y $f]] 67 .t.c yview scroll -255 units 68 update 69 lappend x [list [winfo ismapped $f] [winfo y $f]] 70 .t.c yview scroll -1 units 71 update 72 lappend x [list [winfo ismapped $f] [winfo y $f]] 73} {{1 3} {1 -49} {0 -49} {1 205} {0 205}} 74test canvWind-1.3 {DisplayWinItem, windows off-screen horizontally} { 75 catch {destroy .t} 76 toplevel .t 77 canvas .t.c -scrollregion {0 0 1000 800} -width 250 -height 200 -bd 2 \ 78 -relief sunken -xscrollincrement 1 -yscrollincrement 1 \ 79 -highlightthickness 1 80 pack .t.c -fill both -expand 1 -padx 20 -pady 20 81 wm geometry .t +0+0 82 set f .t.f 83 frame $f -width 80 -height 50 -bg red 84 .t.c create window 300 400 -window $f -anchor nw 85 .t.c xview moveto .3 86 .t.c yview moveto .50 87 update 88 set x [list [list [winfo ismapped $f] [winfo x $f]]] 89 .t.c xview scroll 82 units 90 update 91 lappend x [list [winfo ismapped $f] [winfo x $f]] 92 .t.c xview scroll 1 units 93 update 94 lappend x [list [winfo ismapped $f] [winfo x $f]] 95 .t.c xview scroll -335 units 96 update 97 lappend x [list [winfo ismapped $f] [winfo x $f]] 98 .t.c xview scroll -1 units 99 update 100 lappend x [list [winfo ismapped $f] [winfo x $f]] 101} {{1 23} {1 -59} {0 -59} {1 275} {0 275}} 102test canvWind-1.4 {DisplayWinItem, windows off-screen horizontally} { 103 catch {destroy .t} 104 toplevel .t 105 canvas .t.c -scrollregion {0 0 1000 800} -width 250 -height 200 -bd 2 \ 106 -relief sunken -xscrollincrement 1 -yscrollincrement 1 \ 107 -highlightthickness 1 108 pack .t.c -fill both -expand 1 -padx 20 -pady 20 109 wm geometry .t +0+0 110 set f .t.c.f 111 frame $f -width 80 -height 50 -bg red 112 .t.c create window 300 400 -window $f -anchor nw 113 .t.c xview moveto .3 114 .t.c yview moveto .50 115 update 116 set x [list [list [winfo ismapped $f] [winfo x $f]]] 117 .t.c xview scroll 82 units 118 update 119 lappend x [list [winfo ismapped $f] [winfo x $f]] 120 .t.c xview scroll 1 units 121 update 122 lappend x [list [winfo ismapped $f] [winfo x $f]] 123 .t.c xview scroll -335 units 124 update 125 lappend x [list [winfo ismapped $f] [winfo x $f]] 126 .t.c xview scroll -1 units 127 update 128 lappend x [list [winfo ismapped $f] [winfo x $f]] 129} {{1 3} {1 -79} {0 -79} {1 255} {0 255}} 130catch {destroy .t} 131 132# cleanup 133::tcltest::cleanupTests 134return 135 136 137 138 139 140 141 142 143 144 145 146 147 148