summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorfvogel <fvogelnew1@free.fr>2022-11-13 16:08:58 (GMT)
committerfvogel <fvogelnew1@free.fr>2022-11-13 16:08:58 (GMT)
commita6b8b2e865254c615224120ad7a0425c69f04aad (patch)
tree445adb8ec585316fd8d6a47e103b0d5e83c2f095
parent8b444aadb1193b5d2c32cb32166de9e091761c89 (diff)
downloadtk-a6b8b2e865254c615224120ad7a0425c69f04aad.zip
tk-a6b8b2e865254c615224120ad7a0425c69f04aad.tar.gz
tk-a6b8b2e865254c615224120ad7a0425c69f04aad.tar.bz2
entry-8.18 and spinbox-8.18: Use implementation available in trunk (committed in [678fdae069]).
-rw-r--r--tests/entry.test18
-rw-r--r--tests/spinbox.test25
2 files changed, 33 insertions, 10 deletions
diff --git a/tests/entry.test b/tests/entry.test
index 186602b..5f28ad8 100644
--- a/tests/entry.test
+++ b/tests/entry.test
@@ -2318,10 +2318,20 @@ test entry-8.18 {DeleteChars procedure} -setup {
.e insert 0 "xyzzy"
update
.e delete 2 4
- winfo reqwidth .e
-} -cleanup {
- destroy .e
-} -result [expr {[font measure {Courier -12} 0]*3 + 2*(2+2+1)}] ; # 3 chars + (highlightthickness + bd + XPAD) on each side (see tkEntry.c)
+ # To check that deletion actually happened we measure the new width
+ # of the widget, based on the measuring width of the remaining text ("xyy")
+ # in the widget. For that purpose we have to mirror the code in tkEntry.c
+ # for computation of the reqwidth
+ # note: XPAD corresponds to the hardcoded #define XPAD 1
+ set XPAD 1
+ set expected [expr { [font measure [.e cget -font] "xyy"] \
+ + 2 * ( [.e cget -borderwidth] + \
+ [.e cget -highlightthickness] + $XPAD ) } ]
+ expr {[winfo reqwidth .e] == $expected}
+} -cleanup {
+ destroy .e
+ unset XPAD expected
+} -result {1}
test entry-9.1 {EntryValueChanged procedure} -setup {
unset -nocomplain x
diff --git a/tests/spinbox.test b/tests/spinbox.test
index ef51b10..0f67b37 100644
--- a/tests/spinbox.test
+++ b/tests/spinbox.test
@@ -2597,8 +2597,6 @@ test spinbox-8.17 {DeleteChars procedure} -setup {
} -cleanup {
destroy .e
} -result 4
-set arrowsWidth [expr {[font measure {Courier -12} 0] + 2*(1+1)}] ; # one character width + 2*(1+XPAD)
-set arrowsWidth [expr {$arrowsWidth < 11 ? 11 : $arrowsWidth}] ; # (see tkEntry.c)
test spinbox-8.18 {DeleteChars procedure} -setup {
spinbox .e -width 0 -font {Courier -12} -highlightthickness 2 -bd 2
pack .e
@@ -2607,10 +2605,25 @@ test spinbox-8.18 {DeleteChars procedure} -setup {
.e insert 0 "xyzzy"
update
.e delete 2 4
- winfo reqwidth .e
-} -cleanup {
- destroy .e
-} -result [expr {[font measure {Courier -12} 0]*3 + 2*(2+2+1) + $arrowsWidth}] ; # 3 chars + (highlightthickness + bd + XPAD) on each side + arrows (see tkEntry.c)
+ # To check that deletion actually happened we measure the new width
+ # of the widget, based on the measuring width of the remaining text ("xyy")
+ # in the widget. For that purpose we have to mirror the code in tkEntry.c
+ # for computation of the reqwidth
+ # note: XPAD corresponds to the hardcoded #define XPAD 1
+ set XPAD 1
+ set buttonWidth [expr { [font measure [.e cget -font] "0"] + 2 * (1 + $XPAD) }]
+ if {$buttonWidth < 11} {
+ set buttonWidth 11
+ }
+ set expected [expr { [font measure [.e cget -font] "xyy"] \
+ + 2 * ( [.e cget -borderwidth] + \
+ [.e cget -highlightthickness] + $XPAD ) \
+ + $buttonWidth } ]
+ expr {[winfo reqwidth .e] == $expected}
+} -cleanup {
+ destroy .e
+ unset XPAD buttonWidth expected
+} -result {1}
test spinbox-9.1 {SpinboxValueChanged procedure} -setup {
unset -nocomplain x