diff options
author | culler <culler> | 2019-01-01 19:07:32 (GMT) |
---|---|---|
committer | culler <culler> | 2019-01-01 19:07:32 (GMT) |
commit | a16300f3515fc588292543bc2d44af9a332fb84d (patch) | |
tree | 45aebdbed8304d40eace1b408c83ee2fc3b96c8d /tests | |
parent | e43d3df502249e8b7e104bb575aa7fdb3cf40144 (diff) | |
download | tk-a16300f3515fc588292543bc2d44af9a332fb84d.zip tk-a16300f3515fc588292543bc2d44af9a332fb84d.tar.gz tk-a16300f3515fc588292543bc2d44af9a332fb84d.tar.bz2 |
In the tests, always update after packing; sync and clear the queue before
binding to WidgetViewSync; make 11a.12 work harder so it is meaningful.
Diffstat (limited to 'tests')
-rw-r--r-- | tests/text.test | 32 |
1 files changed, 18 insertions, 14 deletions
diff --git a/tests/text.test b/tests/text.test index ae45e5e..311d531 100644 --- a/tests/text.test +++ b/tests/text.test @@ -2936,11 +2936,13 @@ test text-11a.1 {TextWidgetCmd procedure, "pendingsync" option} -setup { } -cleanup { destroy .yt } -result {1 {wrong # args: should be ".yt pendingsync"}} + test text-11a.2 {TextWidgetCmd procedure, "pendingsync" option} -setup { destroy .top.yt .top } -body { toplevel .top pack [text .top.yt] + update set content {} for {set i 1} {$i < 300} {incr i} { append content [string repeat "$i " 15] \n @@ -2978,9 +2980,11 @@ test text-11a.12 {TextWidgetCmd procedure, "sync" option} -setup { } -body { toplevel .top pack [text .top.yt] + update set content {} + # Use long lines so the line metrics will need updating. for {set i 1} {$i < 30} {incr i} { - append content [string repeat "$i " 15] \n + append content [string repeat "$i " 200] \n } .top.yt insert 1.0 $content # wait for end of line metrics calculation to get correct $fraction1 @@ -3053,19 +3057,18 @@ test text-11a.31 {"<<WidgetViewSync>>" event} -setup { for {set i 1} {$i < 300} {incr i} { append content [string repeat "$i " 15] \n } - .top.yt insert 1.0 $content + # Sync the widget and process <<WidgetViewSync>> events before binding. + .top.yt sync update bind .top.yt <<WidgetViewSync>> { if {%d} {set yud(%W) 1} } - # wait for end of line metrics calculation to get correct $fraction1 - # as a reference - if {[.top.yt pendingsync]} {vwait yud(.top.yt)} + .top.yt insert 1.0 $content .top.yt yview moveto 1 set fraction1 [lindex [.top.yt yview] 0] set res [expr {$fraction1 > 0}] .top.yt delete 1.0 end .top.yt insert 1.0 $content # synchronously wait for completion of line metrics calculation - # and ensure the test is relevant + # and verify that the fractions agree. set waited 0 if {[.top.yt pendingsync]} {set waited 1 ; vwait yud(.top.yt)} lappend res $waited @@ -3081,26 +3084,26 @@ test text-11a.41 {"sync" "pendingsync" and <<WidgetViewSync>>} -setup { } -body { toplevel .top pack [text .top.yt] - # make initial sync state known update - .top.yt sync set content {} for {set i 1} {$i < 300} {incr i} { append content [string repeat "$i " 50] \n } - bind .top.yt <<WidgetViewSync>> {lappend res Sync:%d} + # Sync the widget and process all <<WidgetViewSync>> events before binding. + .top.yt sync update + bind .top.yt <<WidgetViewSync>> {lappend res Sync:%d} set res {} - # the next line triggers <<WidgetViewSync>> with %d==0 i.e. we're out of sync + # The next line triggers <<WidgetViewSync>> with %d==0 i.e. out of sync. .top.yt insert 1.0 $content vwait res - # ensure the test is relevant: the line metrics are not up-to-date (pendingsync is 1) + # Verify that the line metrics are not up-to-date (pendingsync is 1). lappend res "Pending:[.top.yt pendingsync]" - # wait for the end of line metrics update by calling the sync command - # <<WidgetViewSync>> fires when sync returns with %d==1 i.e. we're in sync again - # at this time line metrics are up-to-date (pendingsync is 0) + # Update all line metrics by calling the sync command. .top.yt sync + # <<WidgetViewSync>> should fire with %d==1 i.e. back in sync. vwait res + # At this time the line metrics should be up-to-date (pendingsync is 0). lappend res "Pending:[.top.yt pendingsync]" set res } -cleanup { @@ -3115,6 +3118,7 @@ test text-11a.51 {<<WidgetViewSync>> calls TkSendVirtualEvent(), set res {} toplevel .top pack [text .top.t] + update for {set i 1} {$i < 10000} {incr i} { .top.t insert end "Hello world!\n" } |