
# Set up the test environment, if it does not already exist. Delete any
# canvas3d items that may be left over from a previous test script.
if {[info commands .win] == ""} {
    source [file join [file dirname [info script]] interactive.tcl]
}
i_test text-1.1 {
The size of the canvas is 600x400. There should be two white lines
dividing the canvas area into quarters (lines defined by y=200 and x=300).

There are two text items in a large font. Both have coordinates (300,
200). The anchor of one item is SE, the other NW. The SE item should
appear in the top left quadrant. The NW item in the bottom left.
} {
.win delete all
.win configure -width 600 -height 400

.win create 2dline {0 200 600 200} -color white
.win create 2dline {300 0 300 400} -color white

.win create 2dtext {300 200} -tags SE
.win create 2dtext {300 200} -tags NW

.win itemconfigure SE -font {Arial 30} -text Anchor:SE -anchor se
.win itemconfigure NW -font {Arial 30} -text Anchor:NW -anchor nw
}

i_test text-1.2 {
Set the color of the SE text to green.
Set the color of the NW text to red.
} {
.win itemconfigure SE -color green
.win itemconfigure NW -color red
}

i_test text-1.3 {
The font of each text item was originally "Arial 30".
Both should now be "Arial 15".
} {
.win itemconfigure SE -font {Arial 15}
.win itemconfigure NW -font {Arial 15}
}

i_test text-1.4 {
The text of the SE item should now be "Anchor: Now NW"
The text of the NW item should now be "Anchor: Now SE"
} {
.win itemconfigure SE -text {Anchor: Now NW}
.win itemconfigure NW -text {Anchor: Now SE}
}

i_test text-1.5 {
The anchors of the text items now match the new text.
} {
.win itemconfigure SE -anchor nw
.win itemconfigure NW -anchor se
}

i_test text-2.1 {
The two text items should now be deleted. The lines remain.
} {
.win delete type(2dtext)
}

i_test text-2.2 {
Test the "-anchor center" option.
} {
.win create 2dtext {300 200} -tags T -font {Arial 30}
.win itemconfigure T -text {-anchor center} -anchor center
}
i_test text-2.3 {
Test the "-anchor e" option.
} {
.win itemconfigure T -text {-anchor e} -anchor e
}
i_test text-2.4 {
Test the "-anchor w" option.
} {
.win itemconfigure T -text {-anchor w} -anchor w
}
i_test text-2.5 {
Test the "-anchor n" option.
} {
.win itemconfigure T -text {-anchor n} -anchor n
}
i_test text-2.6 {
Test the "-anchor s" option.
} {
.win itemconfigure T -text {-anchor s} -anchor s
}
i_test text-2.7 {
Test the "-anchor ne" option.
} {
.win itemconfigure T -text {-anchor ne} -anchor ne
}
i_test text-2.7 {
Test the "-anchor sw" option.
} {
.win itemconfigure T -text {-anchor sw} -anchor sw
}

i_test text-3.1 {
Delete the existing text items.
Create a text item with zero length text. This was crashing at one point.
} {
.win delete type(2dtext)
.win create 2dtext {300 200} -text ""
}

i_test text-4.1 {
Delete the existing text items.
This test tests window clipping of text bitmaps. The string "Clipped Text"
should be present on each edge of the viewport. In each case approximately
half of the text should be visible.
} {
.win delete type(2dtext)
.win create 2dtext {300 0}
.win create 2dtext {300 400}
.win create 2dtext {0 200}
.win create 2dtext {600 200}
.win itemconfigure type(2dtext) -font {Arial 30} -text {Clipped Text}
}

