Many hyperlinks are disabled.
Use anonymous login
to enable hyperlinks.
Overview
Comment: | Improve image testing for Aqua |
---|---|
Downloads: | Tarball | ZIP archive |
Timelines: | family | ancestors | descendants | both | core-8-6-branch |
Files: | files | file ages | folders |
SHA3-256: |
d326a1b3df87be02d60ae15f1424c136 |
User & Date: | culler 2019-05-24 21:18:53.112 |
Context
2019-05-24
| ||
21:55 | Tweak test image-7.1. check-in: 0ed60e17 user: culler tags: core-8-6-branch | |
21:18 | Improve image testing for Aqua check-in: d326a1b3 user: culler tags: core-8-6-branch | |
2019-05-23
| ||
14:21 | Wait more carefully, since no wait is needed for Windows or linux. Closed-Leaf check-in: ba19b270 user: culler tags: aqua_image_tests | |
2019-05-20
| ||
21:23 | In Aqua, make XUnmapWindow also redraw the toplevel. Edit a comment in tkTest.c. check-in: 78a3bdc4 user: culler tags: core-8-6-branch | |
Changes
Changes to generic/tkTest.c.
︙ | ︙ | |||
27 28 29 30 31 32 33 | #ifdef _WIN32 #include "tkWinInt.h" #endif #if defined(MAC_OSX_TK) #include "tkMacOSXInt.h" #include "tkScrollbar.h" | | | | 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 | #ifdef _WIN32 #include "tkWinInt.h" #endif #if defined(MAC_OSX_TK) #include "tkMacOSXInt.h" #include "tkScrollbar.h" #define LOG_DISPLAY TkTestLogDisplay() #else #define LOG_DISPLAY 1 #endif #ifdef __UNIX__ #include "tkUnixInt.h" #endif /* |
︙ | ︙ | |||
1552 1553 1554 1555 1556 1557 1558 | { TImageInstance *instPtr = (TImageInstance *) clientData; char buffer[200 + TCL_INTEGER_SPACE * 6]; /* * The purpose of the test image type is to track the calls to an image * display proc and record the parameters passed in each call. On macOS | < < < | | | > > | > > > | | > > | > > > > > > | < < > > > | | < | | 1552 1553 1554 1555 1556 1557 1558 1559 1560 1561 1562 1563 1564 1565 1566 1567 1568 1569 1570 1571 1572 1573 1574 1575 1576 1577 1578 1579 1580 1581 1582 1583 1584 1585 1586 1587 1588 1589 1590 1591 1592 1593 1594 1595 | { TImageInstance *instPtr = (TImageInstance *) clientData; char buffer[200 + TCL_INTEGER_SPACE * 6]; /* * The purpose of the test image type is to track the calls to an image * display proc and record the parameters passed in each call. On macOS * a display proc must be run inside of the drawRect method of an NSView * in order for the graphics operations to have any effect. To deal with * this, whenever a display proc is called outside of any drawRect method * it schedules a redraw of the NSView by calling [view setNeedsDisplay:YES]. * This will trigger a later call to the view's drawRect method which will * run the display proc a second time. * * This complicates testing, since it can result in more calls to the display * proc than are expected by the test. It can also result in an inconsistent * number of calls unless the test waits until the call to drawRect actually * occurs before validating its results. * * In an attempt to work around this, this display proc only logs those * calls which occur within a drawRect method. This means that tests must * be written so as to ensure that the drawRect method is run before * results are validated. In practice it usually suffices to run update * idletasks (to run the display proc the first time) followed by update * (to run the display proc in drawRect). * * This also has the consequence that the image changed command will log * different results on Aqua than on other systems, because when the image * is redisplayed in the drawRect method the entire image will be drawn, * not just the changed portion. Tests must account for this. */ if (LOG_DISPLAY) { sprintf(buffer, "%s display %d %d %d %d", instPtr->masterPtr->imageName, imageX, imageY, width, height); Tcl_SetVar2(instPtr->masterPtr->interp, instPtr->masterPtr->varName, NULL, buffer, TCL_GLOBAL_ONLY|TCL_APPEND_VALUE|TCL_LIST_ELEMENT); } if (width > (instPtr->masterPtr->width - imageX)) { width = instPtr->masterPtr->width - imageX; } if (height > (instPtr->masterPtr->height - imageY)) { height = instPtr->masterPtr->height - imageY; } |
︙ | ︙ |
Changes to macosx/tkMacOSXInt.h.
︙ | ︙ | |||
198 199 200 201 202 203 204 | MODULE_SCOPE void TkpClipDrawableToRect(Display *display, Drawable d, int x, int y, int width, int height); MODULE_SCOPE void TkpRetainRegion(TkRegion r); MODULE_SCOPE void TkpReleaseRegion(TkRegion r); MODULE_SCOPE void TkpShiftButton(NSButton *button, NSPoint delta); MODULE_SCOPE Bool TkpAppIsDrawing(void); MODULE_SCOPE void TkpDisplayWindow(Tk_Window tkwin); | | | 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 | MODULE_SCOPE void TkpClipDrawableToRect(Display *display, Drawable d, int x, int y, int width, int height); MODULE_SCOPE void TkpRetainRegion(TkRegion r); MODULE_SCOPE void TkpReleaseRegion(TkRegion r); MODULE_SCOPE void TkpShiftButton(NSButton *button, NSPoint delta); MODULE_SCOPE Bool TkpAppIsDrawing(void); MODULE_SCOPE void TkpDisplayWindow(Tk_Window tkwin); MODULE_SCOPE Bool TkTestLogDisplay(void); MODULE_SCOPE Bool TkMacOSXInDarkMode(Tk_Window tkwin); /* * Include the stubbed internal platform-specific API. */ #include "tkIntPlatDecls.h" |
︙ | ︙ |
Changes to macosx/tkMacOSXTest.c.
︙ | ︙ | |||
86 87 88 89 90 91 92 | return TCL_OK; } #endif /* *---------------------------------------------------------------------- * | | | | | | > | > | < | > > | > | > > > | 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 | return TCL_OK; } #endif /* *---------------------------------------------------------------------- * * TkTestLogDisplay -- * * The test image display procedure calls this to determine whether it * should write a log message recording that it has being run. On OSX * 10.14 and later, only calls to the display procedure which occur inside * of the drawRect method should be logged, since those are the only ones * which actually draw anything. On earlier systems the opposite is true. * The calls from within the drawRect method are redundant, since the * first time the display procedure is run it will do the drawing and that * first call will usually not occur inside of drawRect. * * Results: * On OSX 10.14 and later, returns true if and only if called from * within [NSView drawRect]. On earlier systems returns false if * and only if called from with [NSView drawRect]. * * Side effects: * None * *---------------------------------------------------------------------- */ MODULE_SCOPE Bool TkTestLogDisplay(void) { if ([NSApp macMinorVersion] >= 14) { return [NSApp isDrawing]; } else { return ![NSApp isDrawing]; } } /* * Local Variables: * mode: objc * c-basic-offset: 4 |
︙ | ︙ |
Changes to tests/canvImg.test.
︙ | ︙ | |||
152 153 154 155 156 157 158 | .c itemconfigure i1 -image {} update list $x [.c bbox i1] } -cleanup { .c delete all image delete foo } -result {{{foo free}} {}} | | | > > > > > > > | 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 | .c itemconfigure i1 -image {} update list $x [.c bbox i1] } -cleanup { .c delete all image delete foo } -result {{{foo free}} {}} test canvImg-4.2 {ConfigureImage procedure} -constraints testImageType -setup { .c delete all } -body { image create test foo -variable x image create test foo2 -variable y foo2 changed 0 0 0 0 80 60 .c create image 50 100 -image foo -tags i1 -anchor nw update set x {} set y {} set timer [after 300 {lappend y "timeout"}] .c itemconfigure i1 -image foo2 update idletasks update # On MacOS we need to wait for the test image display procedure to run. while {"timeout" ni $y && [lindex $y end 1] ne "display"} { vwait y } after cancel timer list $x $y [.c bbox i1] } -cleanup { .c delete all image delete foo image delete foo2 } -result {{{foo free}} {{foo2 get} {foo2 display 0 0 80 60}} {50 100 130 160}} test canvImg-4.3 {ConfiugreImage procedure} -constraints testImageType -setup { |
︙ | ︙ | |||
716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 | .c scale image 25 0 2.0 1.5 .c bbox image } -cleanup { .c delete all image delete foo } -result {75 150 105 165} test canvImg-10.1 {TranslateImage procedure} -constraints testImageType -setup { .c delete all update } -body { image create test foo -variable x .c create image 50 100 -image foo -tags image -anchor nw update set x {} foo changed 2 4 6 8 30 15 update return $x } -cleanup { .c delete all image delete foo | > > > > > > | | 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 | .c scale image 25 0 2.0 1.5 .c bbox image } -cleanup { .c delete all image delete foo } -result {75 150 105 165} if {[tk windowingsystem] == "aqua" && $tcl_platform(osVersion) > 18} { # Aqua >= 10.14 will redraw the entire image. set result_10_1 {{foo display 0 0 30 15}} } else { set result_10_1 {{foo display 2 4 6 8}} } test canvImg-10.1 {TranslateImage procedure} -constraints testImageType -setup { .c delete all update } -body { image create test foo -variable x .c create image 50 100 -image foo -tags image -anchor nw update set x {} foo changed 2 4 6 8 30 15 update return $x } -cleanup { .c delete all image delete foo } -result $result_10_1 test canvImg-11.1 {TranslateImage procedure} -constraints testImageType -setup { .c delete all update } -body { image create test foo -variable x .c create image 50 100 -image foo -tags image -anchor nw |
︙ | ︙ | |||
762 763 764 765 766 767 768 769 770 771 772 773 774 775 | set x {} foo changed 0 0 0 0 40 50 .c bbox image } -cleanup { .c delete all image delete foo } -result {30 75 70 125} test canvImg-11.3 {ImageChangedProc procedure} -constraints { testImageType } -setup { .c delete all update } -body { image create test foo -variable x | > > > > > > | | | 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 | set x {} foo changed 0 0 0 0 40 50 .c bbox image } -cleanup { .c delete all image delete foo } -result {30 75 70 125} if {[tk windowingsystem] == "aqua" && $tcl_platform(osVersion) > 18} { # Aqua >= 10.14 will redraw the entire image. set result_11_3 {{foo2 display 0 0 80 60}} } else { set result_11_3 {{foo2 display 0 0 20 40}} } test canvImg-11.3 {ImageChangedProc procedure} -constraints { testImageType } -setup { .c delete all update } -body { image create test foo -variable x image create test foo2 -variable y foo changed 0 0 0 0 40 50 foo2 changed 0 0 0 0 80 60 .c create image 50 100 -image foo -tags image -anchor nw .c create image 70 110 -image foo2 -anchor nw update set y {} image create test foo -variable x update return $y } -cleanup { .c delete all image delete foo foo2 } -result $result_11_3 # cleanup imageFinish cleanupTests return # Local variables: # mode: tcl # End: |
Changes to tests/image.test.
︙ | ︙ | |||
29 30 31 32 33 34 35 | test image-1.3 {Tk_ImageCmd procedure, "create" option} -body { image create } -returnCodes error -result {wrong # args: should be "image create type ?name? ?-option value ...?"} test image-1.4 {Tk_ImageCmd procedure, "create" option} -body { image c bad_type } -returnCodes error -result {image type "bad_type" doesn't exist} test image-1.5 {Tk_ImageCmd procedure, "create" option} -constraints { | | | | > > > > > > > | | | | 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 | test image-1.3 {Tk_ImageCmd procedure, "create" option} -body { image create } -returnCodes error -result {wrong # args: should be "image create type ?name? ?-option value ...?"} test image-1.4 {Tk_ImageCmd procedure, "create" option} -body { image c bad_type } -returnCodes error -result {image type "bad_type" doesn't exist} test image-1.5 {Tk_ImageCmd procedure, "create" option} -constraints { testImageType } -body { list [image create test myimage] [imageNames] } -cleanup { imageCleanup } -result {myimage myimage} test image-1.6 {Tk_ImageCmd procedure, "create" option} -constraints { testImageType } -setup { imageCleanup } -body { scan [image create test] image%d first image create test myimage scan [image create test -variable x] image%d second expr $second-$first } -cleanup { imageCleanup } -result {1} test image-1.7 {Tk_ImageCmd procedure, "create" option} -constraints { testImageType } -setup { imageCleanup } -body { image create test myimage -variable x .c create image 100 50 -image myimage .c create image 100 150 -image myimage update set x {} set timer [after 500 {lappend x "timeout"}] image create test myimage -variable x update idletasks update # On MacOS we need to wait for the test image display procedure to run. while {"timeout" ni $x && [lindex $x end 1] ne "display"} { vwait x } after cancel timer return $x } -cleanup { imageCleanup } -result {{myimage free} {myimage free} {myimage delete} {myimage get} {myimage get} {myimage display 0 0 30 15} {myimage display 0 0 30 15}} test image-1.8 {Tk_ImageCmd procedure, "create" option} -constraints { testImageType } -setup { .c delete all imageCleanup } -body { image create test myimage -variable x .c create image 100 50 -image myimage .c create image 100 150 -image myimage image delete myimage update set x {} image create test myimage -variable x update return $x } -cleanup { .c delete all imageCleanup } -result {{myimage get} {myimage get} {myimage display 0 0 30 15} {myimage display 0 0 30 15}} test image-1.9 {Tk_ImageCmd procedure, "create" option} -constraints { testImageType } -body { image create test -badName foo } -returnCodes error -result {bad option name "-badName"} test image-1.10 {Tk_ImageCmd procedure, "create" option} -constraints { testImageType } -body { catch {image create test -badName foo} imageNames } -result {} test image-1.11 {Tk_ImageCmd procedure, "create" option with same name as main window} -body { set code [loadTkCommand] append code { |
︙ | ︙ | |||
138 139 140 141 142 143 144 | image delete $i $j } -result works test image-2.1 {Tk_ImageCmd procedure, "delete" option} -body { image delete } -result {} test image-2.2 {Tk_ImageCmd procedure, "delete" option} -constraints { | | | | | 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 | image delete $i $j } -result works test image-2.1 {Tk_ImageCmd procedure, "delete" option} -body { image delete } -result {} test image-2.2 {Tk_ImageCmd procedure, "delete" option} -constraints { testImageType } -setup { imageCleanup set result {} } -body { image create test myimage image create test img2 lappend result [lsort [imageNames]] image d myimage img2 lappend result [imageNames] } -cleanup { imageCleanup } -result {{img2 myimage} {}} test image-2.3 {Tk_ImageCmd procedure, "delete" option} -constraints { testImageType } -setup { imageCleanup } -body { image create test myimage image create test img2 image delete myimage gorp img2 } -cleanup { imageCleanup } -returnCodes error -result {image "gorp" doesn't exist} test image-2.4 {Tk_ImageCmd procedure, "delete" option} -constraints { testImageType } -setup { imageCleanup } -body { image create test myimage image create test img2 catch {image delete myimage gorp img2} imageNames |
︙ | ︙ | |||
186 187 188 189 190 191 192 | test image-3.2 {Tk_ImageCmd procedure, "height" option} -body { image height a b } -returnCodes error -result {wrong # args: should be "image height name"} test image-3.3 {Tk_ImageCmd procedure, "height" option} -body { image height foo } -returnCodes error -result {image "foo" doesn't exist} test image-3.4 {Tk_ImageCmd procedure, "height" option} -constraints { | | | | 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 | test image-3.2 {Tk_ImageCmd procedure, "height" option} -body { image height a b } -returnCodes error -result {wrong # args: should be "image height name"} test image-3.3 {Tk_ImageCmd procedure, "height" option} -body { image height foo } -returnCodes error -result {image "foo" doesn't exist} test image-3.4 {Tk_ImageCmd procedure, "height" option} -constraints { testImageType } -setup { imageCleanup } -body { image create test myimage set x [image h myimage] myimage changed 0 0 0 0 60 50 list $x [image height myimage] } -cleanup { imageCleanup } -result {15 50} test image-4.1 {Tk_ImageCmd procedure, "names" option} -body { image names x } -returnCodes error -result {wrong # args: should be "image names"} test image-4.2 {Tk_ImageCmd procedure, "names" option} -constraints { testImageType } -setup { catch {interp delete testinterp} } -body { interp create testinterp load {} Tk testinterp interp eval testinterp { image delete {*}[image names] |
︙ | ︙ | |||
245 246 247 248 249 250 251 | image type a b } -returnCodes error -result {wrong # args: should be "image type name"} test image-5.3 {Tk_ImageCmd procedure, "type" option} -body { image type foo } -returnCodes error -result {image "foo" doesn't exist} test image-5.4 {Tk_ImageCmd procedure, "type" option} -constraints { | | | | | | | | | > > > > > | > > > > > > > | > > > > > > < | | 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 | image type a b } -returnCodes error -result {wrong # args: should be "image type name"} test image-5.3 {Tk_ImageCmd procedure, "type" option} -body { image type foo } -returnCodes error -result {image "foo" doesn't exist} test image-5.4 {Tk_ImageCmd procedure, "type" option} -constraints { testImageType } -setup { imageCleanup } -body { image create test myimage image type myimage } -cleanup { imageCleanup } -result {test} test image-5.5 {Tk_ImageCmd procedure, "type" option} -constraints { testImageType } -setup { imageCleanup } -body { image create test myimage .c create image 50 50 -image myimage image delete myimage image type myimage } -cleanup { imageCleanup } -returnCodes error -result {image "myimage" doesn't exist} test image-5.6 {Tk_ImageCmd procedure, "type" option} -constraints { testOldImageType } -setup { imageCleanup } -body { image create oldtest myimage image type myimage } -cleanup { imageCleanup } -result {oldtest} test image-5.7 {Tk_ImageCmd procedure, "type" option} -constraints { testOldImageType } -setup { .c delete all imageCleanup } -body { image create oldtest myimage .c create image 50 50 -image myimage image delete myimage image type myimage } -cleanup { .c delete all imageCleanup } -returnCodes error -result {image "myimage" doesn't exist} test image-6.1 {Tk_ImageCmd procedure, "types" option} -body { image types x } -returnCodes error -result {wrong # args: should be "image types"} test image-6.2 {Tk_ImageCmd procedure, "types" option} -constraints { testImageType } -body { lsort [image types] } -result {bitmap oldtest photo test} test image-7.1 {Tk_ImageCmd procedure, "width" option} -body { image width } -returnCodes error -result {wrong # args: should be "image width name"} test image-7.2 {Tk_ImageCmd procedure, "width" option} -body { image width a b } -returnCodes error -result {wrong # args: should be "image width name"} test image-7.3 {Tk_ImageCmd procedure, "width" option} -body { image width foo } -returnCodes error -result {image "foo" doesn't exist} test image-7.4 {Tk_ImageCmd procedure, "width" option} -constraints { testImageType } -setup { imageCleanup } -body { image create test myimage set x [image w myimage] myimage changed 0 0 0 0 60 50 list $x [image width myimage] } -cleanup { imageCleanup } -result {30 60} test image-8.1 {Tk_ImageCmd procedure, "inuse" option} -constraints { testImageType } -setup { imageCleanup set res {} destroy .b } -body { image create test myimage2 lappend res [image inuse myimage2] button .b -image myimage2 lappend res [image inuse myimage2] } -cleanup { imageCleanup catch {destroy .b} } -result [list 0 1] if {[tk windowingsystem] == "aqua" && $tcl_platform(osVersion) > 18} { # Aqua >= 10.14 will redraw the entire image in drawRect. set result_9_1 {{foo display 0 0 30 15}} } else { set result_9_1 {{foo display 5 6 7 8}} } test image-9.1 {Tk_ImageChanged procedure} -constraints testImageType -setup { .c delete all imageCleanup update } -body { image create test foo -variable x .c create image 50 50 -image foo update set x {} set timer [after 500 {lappend x "timeout"}] foo changed 5 6 7 8 30 15 update idletasks update # On MacOS we need to wait for the test image display procedure to run. while {"timeout" ni $x && [lindex $x end 1] ne "display"} { vwait x } after cancel timer return $x } -cleanup { .c delete all imageCleanup } -result $result_9_1 if {[tk windowingsystem] == "aqua" && $tcl_platform(osVersion) > 18} { # Aqua >= 10.14 will redraw the entire image. set result_9_2 {{foo display 0 0 30 15} {foo display 0 0 30 15}} } else { set result_9_2 {{foo display 5 6 25 9} {foo display 0 0 12 14}} } test image-9.2 {Tk_ImageChanged procedure} -constraints testImageType -setup { .c delete all imageCleanup update } -body { image create test foo -variable x .c create image 50 50 -image foo .c create image 90 100 -image foo update set x {} foo changed 5 6 7 8 30 15 update return $x } -cleanup { .c delete all imageCleanup } -result $result_9_2 test image-10.1 {Tk_GetImage procedure} -setup { imageCleanup } -body { .c create image 100 10 -image bad_name } -cleanup { imageCleanup |
︙ | ︙ | |||
611 612 613 614 615 616 617 | lappend x [imageNames] image create photo foo -width 20 -height 20 lappend x [.c bbox i1] [imageNames] } -cleanup { .c delete all imageCleanup } -result {10 10 20 20 foo {} {10 10 30 30} foo} | | | 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 | lappend x [imageNames] image create photo foo -width 20 -height 20 lappend x [.c bbox i1] [imageNames] } -cleanup { .c delete all imageCleanup } -result {10 10 20 20 foo {} {10 10 30 30} foo} destroy .c imageFinish # cleanup cleanupTests return # Local variables: # mode: tcl # End: |