summaryrefslogtreecommitdiffstats
path: root/tkhtml1/tests/html2.test
blob: 79f42a9362442cebeef09f414ec50e9b57a79da4 (plain)
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
#
# Test script for the Tk HTML widget
#
wm withdraw .
if {[lsearch [namespace children] ::tcltest] == -1} {
  source [file dirname $argv0]/engine.tcl
  namespace import ::tcltest::*
  cd [file dirname $argv0]
}


# in image to use for all GIFs.
#
image create photo nogifsm -data {
    R0lGODdhEAAQAPEAAACQkADQ0PgAAAAAACwAAAAAEAAQAAACNISPacHtD4IQz80QJ60as25d
    3idKZdR0IIOm2ta0Lhw/Lz2S1JqvK8ozbTKlEIVYceWSjwIAO///
}

# A callback to handle image requests
#
proc ImageCmd {args} {
  set fn [lindex $args 0]
  if {[catch {image create photo -file $fn} img]} {
    set img nogifsm
  }
  return $img
}

# Free all images
#
proc FreeImages {} {
  foreach img [image names] {
    image delete $img
  }
}

# Create the HTML widget to use for all testing.
#
set h [tkhtml_test_widget]
$h config -imagecommand ImageCmd

::tcltest::test html-2.1 {
  A snapshot of Slashdot on Jan 29, 2000.
} {
  set file page1/index.html
  $h clear
  set f [open $file r]
  $h config -base $file
  $h parse [read $f [file size $file]]
  close $f
  set r [::tcltest::user-result]
  $h clear
  FreeImages
  return $r
} {2 pass}

::tcltest::test html-2.2 {
  A snapshot of a page from the Scriptics website on Jan 29, 2000.
} {
  set file page2/index.html
  $h clear
  set f [open $file r]
  $h config -base $file
  $h parse [read $f [file size $file]]
  close $f
  set r [::tcltest::user-result]
  $h clear
  FreeImages
  return $r
} {2 pass}

::tcltest::test html-2.3 {
  A snapshot of freshmeat on Jan 29, 2000
} {
  set file page4/index.html
  $h clear
  set f [open $file r]
  $h config -base $file
  $h parse [read $f [file size $file]]
  close $f
  set r [::tcltest::user-result]
  $h clear
  FreeImages
  return $r
} {2 pass}

::tcltest::test html-2.4 {
  A slide show about mktclapp
} {
  set file page3/index.html
  $h clear
  set f [open $file r]
  $h config -base $file
  $h parse [read $f [file size $file]]
  close $f
  set r [::tcltest::user-result]
  $h clear
  FreeImages
  return $r
} {2 pass}