diff options
author | fvogel <fvogelnew1@free.fr> | 2022-01-08 20:40:58 (GMT) |
---|---|---|
committer | fvogel <fvogelnew1@free.fr> | 2022-01-08 20:40:58 (GMT) |
commit | ccd575043a9bc05d0d09afd58a6f808c09a6cb8f (patch) | |
tree | 4336d2eb2d4fd25ceb7fd105eb70cc6080b466b0 /tests/textWind.test | |
parent | 2037dfb3c40c6bf2f7e8b838f73f4882f749e6ab (diff) | |
download | tk-ccd575043a9bc05d0d09afd58a6f808c09a6cb8f.zip tk-ccd575043a9bc05d0d09afd58a6f808c09a6cb8f.tar.gz tk-ccd575043a9bc05d0d09afd58a6f808c09a6cb8f.tar.bz2 |
Add many more explanations in textWind-17.10 since what's happening in this test is hard to grasp. Also, add an 'updateText' between the two lines configuring -window {} which should stabilize the test and remove any race condition. Indeed, line '.t window configure 1.2 -window {}' will run the (still existing at this point) -create script at display (i.e. idle) time, which creates a race condition with the following line '.tt.t window configure 1.2 -window {}' that does the same -create script run.
Diffstat (limited to 'tests/textWind.test')
-rw-r--r-- | tests/textWind.test | 45 |
1 files changed, 33 insertions, 12 deletions
diff --git a/tests/textWind.test b/tests/textWind.test index 93c5d8c..8dcdfff 100644 --- a/tests/textWind.test +++ b/tests/textWind.test @@ -1560,25 +1560,46 @@ test textWind-17.10 {peer widget window configuration} -setup { updateText .t window create 1.2 -window [frame .t.f -width 10 -height 20 -bg blue] updateText - # There should be a window in the main widget but not in the peer. - lappend res [.t window configure 1.2 -window] - lappend res [.tt.t window configure 1.2 -window] - .tt.t window create 1.2 -window [frame .tt.t.f -width 25 -height 20 -bg blue] - updateText + # There is a blue window in the main widget .t but not in the peer .tt.t + lappend res [.t window cget 1.2 -window] + lappend res [.tt.t window cget 1.2 -window] + # Insert a green window in the peer. Warning: the blue window previously + # inserted in .t at index 1.2 will now be found in .t at index 1.3 + # The underlying linked segments are common in a text widget and its peers. + .tt.t window create 1.2 -window [frame .tt.t.f -width 25 -height 20 -bg green] + updateText + lappend res [.t window cget 1.2 -window] + lappend res [.t window cget 1.3 -window] + # In the peer, the green window still is at 1.2, and there is no window at 1.3 + lappend res [.tt.t window cget 1.2 -window] + lappend res [.tt.t window cget 1.3 -window] + # Insert a red window in .t at index 1.2. This replaces the blue window originally at 1.2 + # in .t, because the green window inserted in the peer is not visible from .t, therefore + # the embedded window found at index 1.2 in .t is the one originally at 1.2 in .t, i.e. + # the blue one .t window configure 1.2 -create {destroy %W.f ; frame %W.f -width 50 -height 7 -bg red} updateText - # The main widget should not have changed. - lappend res [.t window configure 1.2 -window] + # The main widget .t still has a window named .t.f at 1.2. This is NOT the blue + # frame but the red frame from the -create script, which bears the same name. + lappend res [.t window cget 1.2 -window] + # The peer still has its green .tt.t.f at 1.2 + lappend res [.tt.t window cget 1.2 -window] + # When removing the -window option the create script plays, therefore .t still has + # the red frame .t.f at 1.2 .t window configure 1.2 -window {} + updateText + lappend res [.t window cget 1.2 -window] + # The -create script associated to index 1.2 applies to all peers (that's the reason + # why the manual states that "If multiple peer widgets are in use, it is usually simpler + # to use the -create option if embedded windows are desired in each peer."). Therefore + # when removing the -window option in the peer, the -create script is run, which replaces + # the green frame by the red one named as per the -create script, i.e. .tt.t.f .tt.t window configure 1.2 -window {} updateText - # Nothing should have changed. - lappend res [.t window configure 1.2 -window] - lappend res [.tt.t window configure 1.2 -window] + lappend res [.tt.t window cget 1.2 -window] } -cleanup { destroy .tt .t -} -result {{-window {} {} {} .t.f} {-window {} {} {} {}} {-window {} {} {} .t.f}\ -{-window {} {} {} .t.f} {-window {} {} {} .tt.t.f}} +} -result {.t.f {} {} .t.f .tt.t.f {} .t.f .tt.t.f .t.f .tt.t.f} test textWind-18.1 {embedded window deletion triggered by a script bound to <Map>} -setup { catch {destroy .t .f .f2} |