1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132
|
# Test script for Tkhtml
proc sourcefile {file} {
set fname [file join [file dirname [info script]] $file]
uplevel #0 [list source $fname]
}
sourcefile common.tcl
html .h
.h handler script style styleHandler
proc styleHandler {data} {
.h style $data
}
proc property {node prop} {
array set properties [$node prop]
return $properties($prop)
}
tcltest::test dynamic-1.0 {} -body {
.h reset
.h parse -final {
<html>
<body>
<a>Some Text</a>
<b>Some Text</b>
</html>
}
set ::node_a [lindex [.h search a] 0]
set ::node_b [lindex [.h search b] 0]
$::node_a dynamic set
} -result {}
tcltest::test dynamic-1.1 {} -body {
$::node_b dynamic set
} -result {}
tcltest::test dynamic-1.2 {} -body {
$::node_a dynamic set hover
} -result {hover}
tcltest::test dynamic-1.3 {} -body {
$::node_a dynamic set
} -result {hover}
tcltest::test dynamic-2.0 {} -body {
.h reset
.h parse -final {
<html>
<style>
:hover {color:white}
</style>
<body>
<a>Some Text</a>
</html>
}
set ::node [lindex [.h search a] 0]
property $::node color
} -result {black}
tcltest::test dynamic-2.1 {} -body {
$::node dynamic set hover
$::node dynamic set
} -result {hover}
tcltest::test dynamic-2.2 {} -body {
property $::node color
} -result {white}
tcltest::test dynamic-3.0 {} -body {
.h reset
.h parse -final {
<html>
<style>
a:link {color:white}
a:visited {color:blue}
a {color:black}
</style>
<body>
<a>Some Text</a>
</html>
}
set ::node [lindex [.h search a] 0]
property $::node color
} -result {black}
tcltest::test dynamic-3.1 {} -body {
$::node dynamic set visited
$::node dynamic set
} -result visited
tcltest::test dynamic-3.2 {} -body {
property $::node color
} -result {blue}
tcltest::test dynamic-3.3 {} -body {
$::node dynamic set link
property $::node color
} -result {blue}
tcltest::test dynamic-3.4 {} -body {
$::node dynamic clear visited
property $::node color
} -result {white}
tcltest::test dynamic-3.5 {} -body {
$::node dynamic clear link
$::node dynamic set
} -result {}
tcltest::test dynamic-3.6 {} -body {
property $::node color
} -result {black}
tcltest::test dynamic-4.0 {} -body {
.h reset
.h parse -final {
<html>
<style>
body a:hover {color:red}
</style>
<body>
<a>Some Text</a>
</html>
}
set ::node [lindex [.h search a] 0]
$::node dynamic conditions
} -result {:link {body a:hover}}
finish_test
|