Tk Source Code

View Ticket
Login
Ticket UUID: c12af747658732ef1276d7e5950ce66bd0e685db
Title: OS X - text-21.1 fails
Type: Bug Version: core-8-6-branch
Submitter: fvogel Created on: 2017-01-05 23:18:05
Subsystem: 86. Test Tools Assigned To: fvogel
Priority: 6 Severity: Minor
Status: Closed Last Modified: 2017-01-07 15:19:40
Resolution: Fixed Closed By: fvogel
    Closed on: 2017-01-07 15:19:40
Description:

On OS X only:

==== text-21.1 TkTextLostSelection procedure FAILED
==== Contents of test case:

    .t2 tag add sel 1.2 3.3
    .t.e select from 0
    .t.e select to 1
    .t2 tag ranges sel

---- Result was:
1.2 3.3
---- Result should have been (exact matching):

==== text-21.1 FAILED

In the source code, this behaviour is intentional. In TkTextLostSelection() one can read:

	/*
	 * On Windows and Mac systems, we want to remember the selection for
	 * the next time the focus enters the window. On Unix, just remove the
	 * "sel" tag from everything in the widget.
	 */

So this is a wrong constraint setting. Indeed tests text-21.1 and -21.2 are as follows:

test text-21.1 {TkTextLostSelection procedure} -constraints unix -setup {
    text .t
    .t insert 1.0 "Line 1"
    entry .t.e
    .t.e insert end "abcdefg"
    text .t2
    .t2 insert 1.0 "abc\ndef\nghijk\n1234"
} -body {
    .t2 tag add sel 1.2 3.3
    .t.e select from 0
    .t.e select to 1
    .t2 tag ranges sel
} -cleanup {
    destroy .t .t2
} -result {}

test text-21.2 {TkTextLostSelection procedure} -constraints win -setup {
    text .t
    .t insert 1.0 "Line 1"
    entry .t.e
    .t.e insert end "abcdefg"
    text .t2
    .t2 insert 1.0 "abc\ndef\nghijk\n1234"
} -body {
    .t2 tag add sel 1.2 3.3
    .t.e select from 0
    .t.e select to 1
    .t2 tag ranges sel
} -cleanup {
    destroy .t .t2
} -result {1.2 3.3}

text-21.1 should be constrainted by {unix notAqua}.

And text-21.2 should be constrained so that in addition to Win it is run on OS X (i.e. when {unix aqua} are all true).

User Comments: fvogel added on 2017-01-07 15:19:40:
Merged into core-8-6-branch and trunk.

fvogel added on 2017-01-06 14:19:56:

Better fix now proposed. See [d7e0134ed1] in branch bug-c12af74765


fvogel added on 2017-01-06 07:12:48:

Another possibility would be to create a new constraint in constraints.tcl:

testConstraint aquaOrWin [expr {
    [testConstraint win] ||
    ([testConstraint unix] && [testConstraint aqua])
}]


fvogel added on 2017-01-05 23:21:32:

Fix proposed in [e28a89af4d].

Couldn't find how to express "in addition to Win the test shall run on OS X (i.e. when {unix aqua} are all true)" within a single constraint, so I duplicated the test and created text-21.1a specifically for OS X.