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 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837
|
# This file is a Tcl script to test the procedures in tkConfig.c,
# which comprise the new new option configuration system. It is
# organized in the standard "white-box" fashion for Tcl tests.
#
# Copyright (c) 1997 Sun Microsystems, Inc.
# Copyright (c) 1998-1999 by Scriptics Corporation.
# All rights reserved.
#
# RCS: @(#) $Id: config.test,v 1.3 2000/03/02 21:52:25 hobbs Exp $
if {[lsearch [namespace children] ::tcltest] == -1} {
source [file join [pwd] [file dirname [info script]] defs.tcl]
}
if {[info command testobjconfig] != "testobjconfig"} {
puts "This application hasn't been compiled with the \"testobjconfig\""
puts "command, so I can't run this test. Are you sure you're using"
puts "tktest instead of wish?"
::tcltest::cleanupTests
return
}
proc killTables {} {
# Note: it's important to delete chain2 before chain1, because
# chain2 depends on chain1. If chain1 is deleted first, the
# delete of chain2 will crash.
foreach t {alltypes chain2 chain1 configerror internal new notenoughparams
twowindows} {
while {[testobjconfig info $t] != ""} {
testobjconfig delete $t
}
}
}
foreach i [winfo children .] {
destroy $i
}
killTables
wm geometry . {}
raise .
test config-1.1 {Tk_CreateOptionTable - reference counts} {
eval destroy [winfo children .]
killTables
set x {}
testobjconfig alltypes .a
lappend x [testobjconfig info alltypes]
testobjconfig alltypes .b
lappend x [testobjconfig info alltypes]
eval destroy [winfo children .]
set x
} {{1 15 -boolean} {2 15 -boolean}}
test config-1.2 {Tk_CreateOptionTable - synonym initialization} {
eval destroy [winfo children .]
testobjconfig alltypes .a -synonym green
.a cget -color
} {green}
test config-1.3 {Tk_CreateOptionTable - option database initialization} {
eval destroy [winfo children .]
option clear
testobjconfig alltypes .a
option add *b.string different
testobjconfig alltypes .b
list [.a cget -string] [.b cget -string]
} {foo different}
test config-1.4 {Tk_CreateOptionTable - option database initialization} {
eval destroy [winfo children .]
option clear
testobjconfig alltypes .a
option add *b.String bar
testobjconfig alltypes .b
list [.a cget -string] [.b cget -string]
} {foo bar}
test config-1.5 {Tk_CreateOptionTable - default initialization} {
eval destroy [winfo children .]
testobjconfig alltypes .a
.a cget -relief
} {raised}
test config-1.6 {Tk_CreateOptionTable - chained tables} {
eval destroy [winfo children .]
killTables
testobjconfig chain1 .a
testobjconfig chain2 .b
testobjconfig info chain2
} {1 4 -three 2 2 -one}
test config-1.7 {Tk_CreateOptionTable - chained tables} {
eval destroy [winfo children .]
killTables
testobjconfig chain2 .b
testobjconfig chain1 .a
testobjconfig info chain2
} {1 4 -three 2 2 -one}
test config-1.8 {Tk_CreateOptionTable - chained tables} {
eval destroy [winfo children .]
testobjconfig chain1 .a
testobjconfig chain2 .b
list [catch {.a cget -four} msg] $msg [.a cget -one] \
[.b cget -four] [.b cget -one]
} {1 {unknown option "-four"} one four one}
test config-2.1 {Tk_DeleteOptionTable - reference counts} {
eval destroy [winfo children .]
killTables
testobjconfig chain1 .a
testobjconfig chain2 .b
testobjconfig chain2 .c
eval destroy [winfo children .]
set x {}
testobjconfig delete chain2
lappend x [testobjconfig info chain2] [testobjconfig info chain1]
testobjconfig delete chain2
lappend x [testobjconfig info chain2] [testobjconfig info chain1]
} {{1 4 -three 2 2 -one} {2 2 -one} {} {1 2 -one}}
# No tests for DestroyOptionHashTable; couldn't figure out how to test.
test config-3.1 {Tk_InitOptions - priority of chained tables} {
eval destroy [winfo children .]
testobjconfig chain1 .a
testobjconfig chain2 .b
list [.a cget -two] [.b cget -two]
} {two {two and a half}}
test config-3.2 {Tk_InitOptions - initialize from database} {
eval destroy [winfo children .]
option clear
option add *a.color blue
testobjconfig alltypes .a
list [.a cget -color]
} {blue}
test config-3.3 {Tk_InitOptions - initialize from database} {
eval destroy [winfo children .]
option clear
option add *a.justify bogus
testobjconfig alltypes .a
list [.a cget -justify]
} {left}
test config-3.4 {Tk_InitOptions - initialize from widget class} {
eval destroy [winfo children .]
testobjconfig alltypes .a
list [.a cget -color]
} {red}
test config-3.5 {Tk_InitOptions - no initial value} {
eval destroy [winfo children .]
testobjconfig alltypes .a
.a cget -anchor
} {}
test config-3.6 {Tk_InitOptions - bad initial value} {
eval destroy [winfo children .]
option clear
option add *a.color non-existent
list [catch {testobjconfig alltypes .a} msg] $msg $errorInfo
} {1 {unknown color name "non-existent"} {unknown color name "non-existent"
(database entry for "-color" in widget ".a")
invoked from within
"testobjconfig alltypes .a"}}
option clear
test config-3.7 {Tk_InitOptions - bad initial value} {
eval destroy [winfo children .]
list [catch {testobjconfig configerror} msg] $msg $errorInfo
} {1 {expected integer but got "bogus"} {expected integer but got "bogus"
(default value for "-int")
invoked from within
"testobjconfig configerror"}}
option clear
test config-4.1 {DoObjConfig - boolean} {
catch {rename .foo {}}
list [catch {testobjconfig alltypes .foo -boolean 0} msg] $msg [catch {.foo cget -boolean} result] $result [catch {rename .foo {}}]
} {0 .foo 0 0 0}
test config-4.2 {DoObjConfig - boolean} {
catch {rename .foo {}}
list [catch {testobjconfig alltypes .foo -boolean 1} msg] $msg [catch {.foo cget -boolean} result] $result [catch {rename .foo {}}]
} {0 .foo 0 1 0}
test config-4.3 {DoObjConfig - invalid boolean} {
catch {rename .foo {}}
list [catch {testobjconfig alltypes .foo -boolean {}} msg] $msg
} {1 {expected boolean value but got ""}}
test config-4.4 {DoObjConfig - boolean internal value} {
catch {rename .foo {}}
testobjconfig internal .foo -boolean 0
.foo cget -boolean
} {0}
test config-4.5 {DoObjConfig - integer} {
catch {rename .foo {}}
list [catch {testobjconfig alltypes .foo -integer 3} msg] $msg [catch {.foo cget -integer} result] $result [catch {rename .foo {}}]
} {0 .foo 0 3 0}
test config-4.6 {DoObjConfig - invalid integer} {
catch {rename .foo {}}
list [catch {testobjconfig alltypes .foo -integer bar} msg] $msg
} {1 {expected integer but got "bar"}}
test config-4.7 {DoObjConfig - integer internal value} {
catch {rename .foo {}}
testobjconfig internal .foo -integer 421
.foo cget -integer
} {421}
test config-4.8 {DoObjConfig - double} {
catch {rename .foo {}}
list [catch {testobjconfig alltypes .foo -double 3.14} msg] $msg [catch {.foo cget -double} result] $result [catch {rename .foo {}}]
} {0 .foo 0 3.14 0}
test config-4.9 {DoObjConfig - invalid double} {
catch {rename .foo {}}
list [catch {testobjconfig alltypes .foo -double bar} msg] $msg
} {1 {expected floating-point number but got "bar"}}
test config-4.10 {DoObjConfig - double internal value} {
catch {rename .foo {}}
testobjconfig internal .foo -double 62.75
.foo cget -double
} {62.75}
test config-4.11 {DoObjConfig - string} {
catch {destroy .foo}
list [catch {testobjconfig alltypes .foo -string test} msg] $msg [catch {.foo cget -string} result] $result [destroy .foo]
} {0 .foo 0 test {}}
test config-4.12 {DoObjConfig - null string} {
catch {destroy .foo}
list [catch {testobjconfig alltypes .foo -string {}} msg] $msg [catch {.foo cget -string} result] $result [destroy .foo]
} {0 .foo 0 {} {}}
test config-4.13 {DoObjConfig - string internal value} {
catch {rename .foo {}}
testobjconfig internal .foo -string "this is a test"
.foo cget -string
} {this is a test}
test config-4.14 {DoObjConfig - string table} {
catch {destroy .foo}
list [catch {testobjconfig alltypes .foo -stringtable two} msg] $msg [catch {.foo cget -stringtable} result] $result [destroy .foo]
} {0 .foo 0 two {}}
test config-4.15 {DoObjConfig - invalid string table} {
catch {destroy .foo}
list [catch {testobjconfig alltypes .foo -stringtable foo} msg] $msg
} {1 {bad stringtable "foo": must be one, two, three, or four}}
test config-4.16 {DoObjConfig - new string table} {
catch {destroy .foo}
testobjconfig alltypes .foo -stringtable two
list [catch {.foo configure -stringtable three} msg] $msg [catch {.foo cget -stringtable} result] $result [destroy .foo]
} {0 16 0 three {}}
test config-4.17 {DoObjConfig - stringtable internal value} {
catch {rename .foo {}}
testobjconfig internal .foo -stringtable "four"
.foo cget -stringtable
} {four}
test config-4.18 {DoObjConfig - color} {
catch {rename .foo {}}
list [catch {testobjconfig alltypes .foo -color blue} msg] $msg [catch {.foo cget -color} result] $result [destroy .foo]
} {0 .foo 0 blue {}}
test config-4.19 {DoObjConfig - invalid color} {
catch {destroy .foo}
list [catch {testobjconfig alltypes .foo -color xxx} msg] $msg
} {1 {unknown color name "xxx"}}
test config-4.20 {DoObjConfig - color internal value} {
catch {rename .foo {}}
testobjconfig internal .foo -color purple
.foo cget -color
} {purple}
test config-4.21 {DoObjConfig - null color} {
catch {rename .foo {}}
list [catch {testobjconfig alltypes .foo -color {}} msg] $msg [catch {.foo cget -color} result] $result [destroy .foo]
} {0 .foo 0 {} {}}
test config-4.22 {DoObjConfig - getting rid of old color} {
catch {destroy .foo}
testobjconfig alltypes .foo -color #333333
list [catch {.foo configure -color #444444} msg] $msg [catch {.foo cget -color} result] $result [destroy .foo]
} {0 32 0 #444444 {}}
test config-4.23 {DoObjConfig - font} {
catch {rename .foo {}}
list [catch {testobjconfig alltypes .foo -font {Helvetica 72}} msg] $msg [catch {.foo cget -font} result] $result [destroy .foo]
} {0 .foo 0 {Helvetica 72} {}}
test config-4.24 {DoObjConfig - new font} {
catch {rename .foo {}}
testobjconfig alltypes .foo -font {Courier 12}
list [catch {.foo configure -font {Helvetica 72}} msg] $msg [catch {.foo cget -font} result] $result [destroy .foo]
} {0 64 0 {Helvetica 72} {}}
test config-4.25 {DoObjConfig - invalid font} {
catch {rename .foo {}}
list [catch {testobjconfig alltypes .foo -font {Helvetica 12 foo}} msg] $msg
} {1 {unknown font style "foo"}}
test config-4.26 {DoObjConfig - null font} {
catch {rename .foo {}}
list [catch {testobjconfig alltypes .foo -font {}} msg] $msg [catch {.foo cget -font} result] $result [destroy .foo]
} {0 .foo 0 {} {}}
test config-4.27 {DoObjConfig - font internal value} {
catch {rename .foo {}}
testobjconfig internal .foo -font {Times 16}
.foo cget -font
} {Times 16}
test config-4.28 {DoObjConfig - bitmap} {
catch {destroy .foo}
list [catch {testobjconfig alltypes .foo -bitmap gray75} msg] $msg [catch {.foo cget -bitmap} result] $result [destroy .foo]
} {0 .foo 0 gray75 {}}
test config-4.29 {DoObjConfig - new bitmap} {
catch {destroy .foo}
testobjconfig alltypes .foo -bitmap gray75
list [catch {.foo configure -bitmap gray50} msg] $msg [catch {.foo cget -bitmap} result] $result [destroy .foo]
} {0 128 0 gray50 {}}
test config-4.30 {DoObjConfig - invalid bitmap} {
catch {destroy .foo}
list [catch {testobjconfig alltypes .foo -bitmap foo} msg] $msg
} {1 {bitmap "foo" not defined}}
test config-4.31 {DoObjConfig - null bitmap} {
catch {destroy .foo}
list [catch {testobjconfig alltypes .foo -bitmap {}} msg] $msg [catch {.foo cget -bitmap} result] $result [destroy .foo]
} {0 .foo 0 {} {}}
test config-4.32 {DoObjConfig - bitmap internal value} {
catch {rename .foo {}}
testobjconfig internal .foo -bitmap gray25
.foo cget -bitmap
} {gray25}
test config-4.33 {DoObjConfig - border} {
catch {rename .foo {}}
list [catch {testobjconfig alltypes .foo -border green} msg] $msg [catch {.foo cget -border} result] $result [destroy .foo]
} {0 .foo 0 green {}}
test config-4.34 {DoObjConfig - invalid border} {
catch {destroy .foo}
list [catch {testobjconfig alltypes .foo -border xxx} msg] $msg
} {1 {unknown color name "xxx"}}
test config-4.35 {DoObjConfig - null border} {
catch {rename .foo {}}
list [catch {testobjconfig alltypes .foo -border {}} msg] $msg [catch {.foo cget -border} result] $result [destroy .foo]
} {0 .foo 0 {} {}}
test config-4.36 {DoObjConfig - border internal value} {
catch {rename .foo {}}
testobjconfig internal .foo -border #123456
.foo cget -border
} {#123456}
test config-4.37 {DoObjConfig - getting rid of old border} {
catch {destroy .foo}
testobjconfig alltypes .foo -border #333333
list [catch {.foo configure -border #444444} msg] $msg [catch {.foo cget -border} result] $result [destroy .foo]
} {0 256 0 #444444 {}}
test config-4.38 {DoObjConfig - relief} {
catch {destroy .foo}
list [catch {testobjconfig alltypes .foo -relief flat} msg] $msg [catch {.foo cget -relief} result] $result [destroy .foo]
} {0 .foo 0 flat {}}
test config-4.39 {DoObjConfig - invalid relief} {
catch {destroy .foo}
list [catch {testobjconfig alltypes .foo -relief foo} msg] $msg
} {1 {bad relief "foo": must be flat, groove, raised, ridge, solid, or sunken}}
test config-4.40 {DoObjConfig - new relief} {
catch {destroy .foo}
testobjconfig alltypes .foo -relief raised
list [catch {.foo configure -relief flat} msg] $msg [catch {.foo cget -relief} result] $result [destroy .foo]
} {0 512 0 flat {}}
test config-4.41 {DoObjConfig - relief internal value} {
catch {rename .foo {}}
testobjconfig internal .foo -relief ridge
.foo cget -relief
} {ridge}
test config-4.42 {DoObjConfig - cursor} {
catch {destroy .foo}
list [catch {testobjconfig alltypes .foo -cursor arrow} msg] $msg [catch {.foo cget -cursor} result] $result [destroy .foo]
} {0 .foo 0 arrow {}}
test config-4.43 {DoObjConfig - invalid cursor} {
catch {destroy .foo}
list [catch {testobjconfig alltypes .foo -cursor foo} msg] $msg
} {1 {bad cursor spec "foo"}}
test config-4.44 {DoObjConfig - null cursor} {
catch {destroy .foo}
list [catch {testobjconfig alltypes .foo -cursor {}} msg] $msg [catch {.foo cget -cursor} result] $result [destroy .foo]
} {0 .foo 0 {} {}}
test config-4.45 {DoObjConfig - new cursor} {
catch {destroy .foo}
testobjconfig alltypes .foo -cursor xterm
list [catch {.foo configure -cursor arrow} msg] $msg [catch {.foo cget -cursor} result] $result [destroy .foo]
} {0 1024 0 arrow {}}
test config-4.46 {DoObjConfig - cursor internal value} {
catch {rename .foo {}}
testobjconfig internal .foo -cursor watch
.foo cget -cursor
} {watch}
test config-4.47 {DoObjConfig - justify} {
catch {destroy .foo}
list [catch {testobjconfig alltypes .foo -justify center} msg] $msg [catch {.foo cget -justify} result] $result [destroy .foo]
} {0 .foo 0 center {}}
test config-4.48 {DoObjConfig - invalid justify} {
catch {destroy .foo}
list [catch {testobjconfig alltypes .foo -justify foo} msg] $msg
} {1 {bad justification "foo": must be left, right, or center}}
test config-4.49 {DoObjConfig - new justify} {
catch {destroy .foo}
testobjconfig alltypes .foo -justify left
list [catch {.foo configure -justify right} msg] $msg [catch {.foo cget -justify} result] $result [destroy .foo]
} {0 2048 0 right {}}
test config-4.50 {DoObjConfig - justify internal value} {
catch {rename .foo {}}
testobjconfig internal .foo -justify center
.foo cget -justify
} {center}
test config-4.51 {DoObjConfig - anchor} {
catch {destroy .foo}
list [catch {testobjconfig alltypes .foo -anchor center} msg] $msg [catch {.foo cget -anchor} result] $result [destroy .foo]
} {0 .foo 0 center {}}
test config-4.52 {DoObjConfig - invalid anchor} {
catch {destroy .foo}
list [catch {testobjconfig alltypes .foo -anchor foo} msg] $msg
} {1 {bad anchor "foo": must be n, ne, e, se, s, sw, w, nw, or center}}
test config-4.53 {DoObjConfig - new anchor} {
catch {destroy .foo}
testobjconfig alltypes .foo -anchor e
list [catch {.foo configure -anchor n} msg] $msg [catch {.foo cget -anchor} result] $result [destroy .foo]
} {0 4096 0 n {}}
test config-4.54 {DoObjConfig - anchor internal value} {
catch {rename .foo {}}
testobjconfig internal .foo -anchor sw
.foo cget -anchor
} {sw}
test config-4.55 {DoObjConfig - pixel} {
catch {destroy .foo}
list [catch {testobjconfig alltypes .foo -pixel 42} msg] $msg [catch {.foo cget -pixel} result] $result [destroy .foo]
} {0 .foo 0 42 {}}
test config-4.56 {DoObjConfig - invalid pixel} {
catch {destroy .foo}
list [catch {testobjconfig alltypes .foo -pixel foo} msg] $msg
} {1 {bad screen distance "foo"}}
test config-4.57 {DoObjConfig - new pixel} {
catch {destroy .foo}
testobjconfig alltypes .foo -pixel 42m
list [catch {.foo configure -pixel 3c} msg] $msg [catch {.foo cget -pixel} result] $result [destroy .foo]
} {0 8192 0 3c {}}
test config-4.58 {DoObjConfig - pixel internal value} {
catch {rename .foo {}}
testobjconfig internal .foo -pixel [winfo screenmmwidth .]m
.foo cget -pixel
} [winfo screenwidth .]
test config-4.59 {DoObjConfig - window} {
catch {destroy .foo}
catch {destroy .bar}
toplevel .bar
list [catch {testobjconfig twowindows .foo -window .bar} msg] $msg [catch {.foo cget -window} result] $result [destroy .foo] [destroy .bar]
} {0 .foo 0 .bar {} {}}
test config-4.60 {DoObjConfig - invalid window} {
catch {destroy .foo}
toplevel .bar
list [catch {testobjconfig twowindows .foo -window foo} msg] $msg [destroy .bar]
} {1 {bad window path name "foo"} {}}
test config-4.61 {DoObjConfig - null window} {
catch {destroy .foo}
catch {destroy .bar}
toplevel .bar
list [catch {testobjconfig twowindows .foo -window {}} msg] $msg [catch {.foo cget -window} result] $result [destroy .foo]
} {0 .foo 0 {} {}}
test config-4.62 {DoObjConfig - new window} {
catch {destroy .foo}
catch {destroy .bar}
catch {destroy .blamph}
toplevel .bar
toplevel .blamph
testobjconfig twowindows .foo -window .bar
list [catch {.foo configure -window .blamph} msg] $msg [catch {.foo cget -window} result] $result [destroy .foo] [destroy .bar] [destroy .blamph]
} {0 0 0 .blamph {} {} {}}
test config-4.63 {DoObjConfig - window internal value} {
catch {rename .foo {}}
testobjconfig internal .foo -window .
.foo cget -window
} {.}
test config-4.64 {DoObjConfig - releasing old values} {
# This test doesn't generate a useful value to check; if an
# error occurs, it will be detected only by memory checking software
# such as Purify or Tcl's built-in checker.
catch {rename .foo {}}
testobjconfig alltypes .foo -string {Test string} -color yellow \
-font {Courier 18} -bitmap questhead -border green -cursor cross
.foo configure -string {new string} -color brown \
-font {Times 8} -bitmap gray75 -border pink -cursor watch
concat {}
} {}
test config-4.65 {DoObjConfig - releasing old values} {
# This test doesn't generate a useful value to check; if an
# error occurs, it will be detected only by memory checking software
# such as Purify or Tcl's built-in checker.
catch {rename .foo {}}
testobjconfig internal .foo -string {Test string} -color yellow \
-font {Courier 18} -bitmap questhead -border green -cursor cross
.foo configure -string {new string} -color brown \
-font {Times 8} -bitmap gray75 -border pink -cursor watch
concat {}
} {}
test config-5.1 {ObjectIsEmpty - object is already string} {
catch {destroy .foo}
testobjconfig alltypes .foo -color [format ""]
.foo cget -color
} {}
test config-5.2 {ObjectIsEmpty - object is already string} {
catch {destroy .foo}
list [catch {testobjconfig alltypes .foo -color [format " "]} msg] $msg
} {1 {unknown color name " "}}
test config-5.3 {ObjectIsEmpty - must convert back to string} {
catch {destroy .foo}
testobjconfig alltypes .foo -color [list]
.foo cget -color
} {}
eval destroy [winfo children .]
testobjconfig chain2 .a
testobjconfig alltypes .b
test config-6.1 {GetOptionFromObj - cached answer} {
list [.a cget -three] [.a cget -three]
} {three three}
test config-6.2 {GetOptionFromObj - exact match} {
.a cget -one
} {one}
test config-6.3 {GetOptionFromObj - abbreviation} {
.a cget -fo
} {four}
test config-6.4 {GetOptionFromObj - ambiguous abbreviation} {
list [catch {.a cget -on} msg] $msg
} {1 {unknown option "-on"}}
test config-6.5 {GetOptionFromObj - duplicate options in different tables} {
.a cget -tw
} {two and a half}
test config-6.6 {GetOptionFromObj - synonym} {
.b cget -synonym
} {red}
eval destroy [winfo children .]
testobjconfig alltypes .a
test config-7.1 {Tk_SetOptions - basics} {
.a configure -color green -rel sunken
list [.a cget -color] [.a cget -relief]
} {green sunken}
test config-7.2 {Tk_SetOptions - bogus option name} {
list [catch {.a configure -bogus} msg] $msg
} {1 {unknown option "-bogus"}}
test config-7.3 {Tk_SetOptions - synonym} {
.a configure -synonym blue
.a cget -color
} {blue}
test config-7.4 {Tk_SetOptions - missing value} {
list [catch {.a configure -color green -relief} msg] $msg [.a cget -color]
} {1 {value for "-relief" missing} green}
test config-7.5 {Tk_SetOptions - saving old values} {
.a configure -color red -int 7 -relief raised -double 3.14159
list [catch {.a csave -color green -int 432 -relief sunken \
-double 2.0 -color bogus} msg] $msg [.a cget -color] \
[.a cget -int] [.a cget -relief] [.a cget -double]
} {1 {unknown color name "bogus"} red 7 raised 3.14159}
test config-7.6 {Tk_SetOptions - error in DoObjConfig call} {
list [catch {.a configure -color bogus} msg] $msg $errorInfo
} {1 {unknown color name "bogus"} {unknown color name "bogus"
(processing "-color" option)
invoked from within
".a configure -color bogus"}}
test config-7.7 {Tk_SetOptions - synonym name in error message} {
list [catch {.a configure -synonym bogus} msg] $msg $errorInfo
} {1 {unknown color name "bogus"} {unknown color name "bogus"
(processing "-synonym" option)
invoked from within
".a configure -synonym bogus"}}
test config-7.8 {Tk_SetOptions - returning mask} {
format %x [.a configure -color red -int 7 -relief raised -double 3.14159]
} {226}
test config-8.1 {Tk_RestoreSavedOptions - restore in proper order} {
eval destroy [winfo children .]
testobjconfig alltypes .a
list [catch {.a csave -color green -color black -color blue \
-color #ffff00 -color #ff00ff -color bogus} msg] $msg \
[.a cget -color]
} {1 {unknown color name "bogus"} red}
test config-8.2 {Tk_RestoreSavedOptions - freeing object memory} {
eval destroy [winfo children .]
testobjconfig alltypes .a
.a csave -color green -color black -color blue -color #ffff00 \
-color #ff00ff
} {32}
test config-8.3 {Tk_RestoreSavedOptions - boolean internal form} {
eval destroy [winfo children .]
testobjconfig internal .a
list [catch {.a csave -boolean 0 -color bogus}] [.a cget -boolean]
} {1 1}
test config-8.4 {Tk_RestoreSavedOptions - integer internal form} {
eval destroy [winfo children .]
testobjconfig internal .a
list [catch {.a csave -integer 24 -color bogus}] [.a cget -integer]
} {1 148962237}
test config-8.5 {Tk_RestoreSavedOptions - double internal form} {
eval destroy [winfo children .]
testobjconfig internal .a
list [catch {.a csave -double 62.4 -color bogus}] [.a cget -double]
} {1 3.14159}
test config-8.6 {Tk_RestoreSavedOptions - string internal form} {
eval destroy [winfo children .]
testobjconfig internal .a
list [catch {.a csave -string "A long string" -color bogus}] \
[.a cget -string]
} {1 foo}
test config-8.7 {Tk_RestoreSavedOptions - string table internal form} {
eval destroy [winfo children .]
testobjconfig internal .a
list [catch {.a csave -stringtable three -color bogus}] \
[.a cget -stringtable]
} {1 one}
test config-8.8 {Tk_RestoreSavedOptions - color internal form} {
eval destroy [winfo children .]
testobjconfig internal .a
list [catch {.a csave -color green -color bogus}] [.a cget -color]
} {1 red}
test config-8.9 {Tk_RestoreSavedOptions - font internal form} {nonPortable} {
eval destroy [winfo children .]
testobjconfig internal .a
list [catch {.a csave -font {Times 12} -color bogus}] [.a cget -font]
} {1 {Helvetica 12}}
test config-8.10 {Tk_RestoreSavedOptions - bitmap internal form} {
eval destroy [winfo children .]
testobjconfig internal .a
list [catch {.a csave -bitmap questhead -color bogus}] [.a cget -bitmap]
} {1 gray50}
test config-8.11 {Tk_RestoreSavedOptions - border internal form} {
eval destroy [winfo children .]
testobjconfig internal .a
list [catch {.a csave -border brown -color bogus}] [.a cget -border]
} {1 blue}
test config-8.12 {Tk_RestoreSavedOptions - relief internal form} {
eval destroy [winfo children .]
testobjconfig internal .a
list [catch {.a csave -relief sunken -color bogus}] [.a cget -relief]
} {1 raised}
test config-8.13 {Tk_RestoreSavedOptions - cursor internal form} {
eval destroy [winfo children .]
testobjconfig internal .a
list [catch {.a csave -cursor watch -color bogus}] [.a cget -cursor]
} {1 xterm}
test config-8.14 {Tk_RestoreSavedOptions - justify internal form} {
eval destroy [winfo children .]
testobjconfig internal .a
list [catch {.a csave -justify right -color bogus}] [.a cget -justify]
} {1 left}
test config-8.15 {Tk_RestoreSavedOptions - anchor internal form} {
eval destroy [winfo children .]
testobjconfig internal .a
list [catch {.a csave -anchor center -color bogus}] [.a cget -anchor]
} {1 n}
test config-8.16 {Tk_RestoreSavedOptions - window internal form} {
eval destroy [winfo children .]
testobjconfig internal .a -window .a
list [catch {.a csave -window .a -color bogus}] [.a cget -window]
} {1 .a}
# Most of the tests below will cause memory leakage if there is a
# problem. This may not be evident unless the tests are run in
# conjunction with a memory usage analyzer such as Purify.
test config-9.1 {Tk_FreeConfigOptions/FreeResources - string internal form} {
catch {destroy .foo}
testobjconfig internal .foo
.foo configure -string "two words"
destroy .foo
} {}
test config-9.2 {Tk_FreeConfigOptions/FreeResources - color internal form} {
catch {destroy .foo}
testobjconfig internal .foo
.foo configure -color yellow
destroy .foo
} {}
test config-9.3 {Tk_FreeConfigOptions/FreeResources - color} {
catch {destroy .foo}
testobjconfig alltypes .foo
.foo configure -color [format blue]
destroy .foo
} {}
test config-9.4 {Tk_FreeConfigOptions/FreeResources - font internal form} {
catch {destroy .foo}
testobjconfig internal .foo
.foo configure -font {Courier 20}
destroy .foo
} {}
test config-9.5 {Tk_FreeConfigOptions/FreeResources - font} {
catch {destroy .foo}
testobjconfig alltypes .foo
.foo configure -font [format {Courier 24}]
destroy .foo
} {}
test config-9.6 {Tk_FreeConfigOptions/FreeResources - bitmap internal form} {
catch {destroy .foo}
testobjconfig internal .foo
.foo configure -bitmap gray75
destroy .foo
} {}
test config-9.7 {Tk_FreeConfigOptions/FreeResources - bitmap} {
catch {destroy .foo}
testobjconfig alltypes .foo
.foo configure -bitmap [format gray75]
destroy .foo
} {}
test config-9.8 {Tk_FreeConfigOptions/FreeResources - border internal form} {
catch {destroy .foo}
testobjconfig internal .foo
.foo configure -border orange
destroy .foo
} {}
test config-9.9 {Tk_FreeConfigOptions/FreeResources - border} {
catch {destroy .foo}
testobjconfig alltypes .foo
.foo configure -border [format blue]
destroy .foo
} {}
test config-9.10 {Tk_FreeConfigOptions/FreeResources - cursor internal form} {
catch {destroy .foo}
testobjconfig internal .foo
.foo configure -cursor cross
destroy .foo
} {}
test config-9.11 {Tk_FreeConfigOptions/FreeResources - cursor} {
catch {destroy .foo}
testobjconfig alltypes .foo
.foo configure -cursor [format watch]
destroy .foo
} {}
test config-9.12 {Tk_FreeConfigOptions/FreeResources - not special} {
catch {destroy .foo}
testobjconfig alltypes .foo
.foo configure -integer [format 27]
destroy .foo
} {}
test config-10.1 {Tk_GetOptionInfo - one item} {
catch {destroy .foo}
testobjconfig alltypes .foo
.foo configure -relief groove
.foo configure -relief
} {-relief relief Relief raised groove}
test config-10.2 {Tk_GetOptionInfo - one item, synonym} {
catch {destroy .foo}
testobjconfig alltypes .foo
.foo configure -color black
.foo configure -synonym
} {-color color Color red black}
test config-10.3 {Tk_GetOptionInfo - all items} {
catch {destroy .foo}
testobjconfig alltypes .foo -font {Helvetica 18} -integer 13563
.foo configure
} {{-boolean boolean Boolean 1 1} {-integer integer Integer 7 13563} {-double double Double 3.14159 3.14159} {-string string String foo foo} {-stringtable StringTable stringTable one one} {-color color Color red red} {-font font Font {Helvetica 12} {Helvetica 18}} {-bitmap bitmap Bitmap gray50 gray50} {-border border Border blue blue} {-relief relief Relief raised raised} {-cursor cursor Cursor xterm xterm} {-justify {} {} left left} {-anchor anchor Anchor {} {}} {-pixel pixel Pixel 1 1} {-synonym -color}}
test config-10.4 {Tk_GetOptionInfo - chaining through tables} {
catch {destroy .foo}
testobjconfig chain2 .foo -one asdf -three xyzzy
.foo configure
} {{-three three Three three xyzzy} {-four four Four four four} {-two two Two {two and a half} {two and a half}} {-oneAgain oneAgain OneAgain {one again} {one again}} {-one one One one asdf} {-two two Two two {two and a half}}}
eval destroy [winfo children .]
testobjconfig alltypes .a
test config-11.1 {GetConfigList - synonym} {
lindex [.a configure] end
} {-synonym -color}
test config-11.2 {GetConfigList - null database names} {
.a configure -justify
} {-justify {} {} left left}
test config-11.3 {GetConfigList - null default and current value} {
.a configure -anchor
} {-anchor anchor Anchor {} {}}
eval destroy [winfo children .]
testobjconfig internal .a
test config-12.1 {GetObjectForOption - boolean} {
.a configure -boolean 0
.a cget -boolean
} {0}
test config-12.2 {GetObjectForOption - integer} {
.a configure -integer 1247
.a cget -integer
} {1247}
test config-12.3 {GetObjectForOption - double} {
.a configure -double -88.82
.a cget -double
} {-88.82}
test config-12.4 {GetObjectForOption - string} {
.a configure -string "test value"
.a cget -string
} {test value}
test config-12.5 {GetObjectForOption - stringTable} {
.a configure -stringtable "two"
.a cget -stringtable
} {two}
test config-12.6 {GetObjectForOption - color} {
.a configure -color "green"
.a cget -color
} {green}
test config-12.7 {GetObjectForOption - font} {
.a configure -font {Times 36}
.a cget -font
} {Times 36}
test config-12.8 {GetObjectForOption - bitmap} {
.a configure -bitmap "questhead"
.a cget -bitmap
} {questhead}
test config-12.9 {GetObjectForOption - border} {
.a configure -border #33217c
.a cget -border
} {#33217c}
test config-12.10 {GetObjectForOption - relief} {
.a configure -relief groove
.a cget -relief
} {groove}
test config-12.11 {GetObjectForOption - cursor} {
.a configure -cursor watch
.a cget -cursor
} {watch}
test config-12.12 {GetObjectForOption - justify} {
.a configure -justify right
.a cget -justify
} {right}
test config-12.13 {GetObjectForOption - anchor} {
.a configure -anchor e
.a cget -anchor
} {e}
test config-12.14 {GetObjectForOption - pixels} {
.a configure -pixel 193.2
.a cget -pixel
} {193}
test config-12.15 {GetObjectForOption - window} {
.a configure -window .a
.a cget -window
} {.a}
test config-12.16 {GetObjectForOption - null values} {
.a configure -string {} -color {} -font {} -bitmap {} -border {} \
-cursor {} -window {}
list [.a cget -string] [.a cget -color] [.a cget -font] \
[.a cget -string] [.a cget -bitmap] [.a cget -border] \
[.a cget -cursor] [.a cget -window]
} {{} {} {} {} {} {} {} {}}
test config-13.1 {proper cleanup of options with widget destroy} {
foreach type {
button canvas entry frame listbox menu menubutton message
scale scrollbar text radiobutton checkbutton
} {
destroy .w
$type .w -cursor crosshair
destroy .w
}
} {}
# cleanup
eval destroy [winfo children .]
killTables
::tcltest::cleanupTests
return
|