summaryrefslogtreecommitdiffstats
path: root/tests/grid.test
blob: 27df602a03c2b446f4f6c5d35962da315f0a3252 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
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
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
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
185
186
187
188
189
190
191
192
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
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
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
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
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
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
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
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
1477
1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
1488
1489
1490
1491
1492
1493
1494
1495
1496
1497
1498
1499
1500
1501
1502
1503
1504
1505
1506
1507
1508
1509
1510
1511
1512
1513
1514
1515
1516
1517
1518
1519
1520
1521
1522
1523
1524
1525
1526
1527
1528
1529
1530
1531
1532
1533
1534
1535
1536
1537
1538
1539
1540
1541
1542
1543
1544
1545
1546
1547
1548
1549
1550
1551
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
1596
1597
1598
1599
1600
1601
1602
1603
1604
1605
1606
1607
1608
1609
1610
1611
1612
1613
1614
1615
1616
1617
1618
1619
1620
1621
1622
1623
1624
1625
1626
1627
1628
1629
1630
1631
1632
1633
1634
1635
1636
1637
1638
1639
1640
1641
1642
1643
1644
1645
1646
1647
1648
1649
1650
1651
1652
1653
1654
1655
1656
1657
1658
1659
1660
1661
1662
1663
1664
1665
1666
1667
1668
1669
1670
1671
1672
1673
1674
1675
1676
1677
1678
1679
1680
1681
1682
1683
1684
1685
1686
1687
1688
1689
1690
1691
1692
1693
1694
1695
1696
1697
1698
1699
1700
1701
1702
1703
1704
1705
1706
1707
1708
1709
1710
1711
1712
1713
1714
1715
1716
1717
1718
1719
1720
1721
1722
1723
1724
1725
1726
1727
1728
1729
1730
1731
1732
1733
1734
1735
1736
1737
1738
1739
1740
1741
1742
1743
1744
1745
1746
1747
1748
1749
1750
1751
1752
1753
1754
1755
1756
1757
1758
1759
1760
1761
1762
1763
1764
1765
1766
1767
1768
1769
1770
1771
1772
1773
1774
1775
1776
1777
1778
1779
1780
1781
1782
1783
1784
1785
1786
1787
1788
1789
1790
1791
1792
1793
1794
1795
1796
1797
1798
1799
1800
1801
1802
1803
1804
1805
1806
1807
1808
1809
1810
1811
1812
1813
1814
1815
1816
1817
1818
1819
1820
1821
1822
1823
1824
1825
1826
1827
1828
1829
1830
1831
1832
1833
1834
1835
1836
1837
1838
1839
1840
1841
1842
1843
1844
1845
1846
1847
1848
1849
1850
1851
1852
1853
1854
1855
1856
1857
1858
1859
1860
1861
1862
1863
1864
1865
1866
1867
1868
1869
1870
1871
1872
1873
1874
1875
1876
1877
1878
1879
1880
1881
1882
1883
1884
1885
1886
1887
1888
1889
1890
1891
1892
1893
1894
1895
1896
1897
1898
1899
1900
1901
1902
1903
1904
1905
1906
1907
1908
1909
1910
1911
1912
1913
1914
1915
1916
1917
1918
1919
1920
1921
1922
1923
1924
1925
1926
1927
1928
1929
1930
1931
1932
1933
1934
1935
1936
1937
1938
1939
1940
1941
1942
1943
1944
1945
1946
1947
1948
1949
1950
1951
1952
1953
1954
1955
1956
1957
1958
1959
1960
1961
1962
1963
1964
1965
1966
1967
1968
1969
1970
1971
1972
1973
1974
1975
1976
1977
1978
1979
1980
1981
1982
1983
1984
1985
1986
1987
1988
1989
1990
1991
1992
1993
1994
1995
1996
1997
1998
1999
2000
2001
2002
2003
2004
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
2026
2027
2028
2029
2030
2031
2032
2033
2034
2035
2036
2037
2038
2039
2040
2041
2042
2043
2044
2045
2046
2047
2048
2049
2050
2051
2052
2053
2054
2055
2056
2057
2058
2059
2060
2061
2062
2063
2064
2065
2066
2067
2068
2069
2070
2071
2072
2073
2074
2075
2076
2077
2078
2079
2080
2081
2082
2083
2084
2085
2086
2087
2088
2089
2090
2091
2092
2093
2094
2095
2096
2097
2098
2099
2100
2101
2102
2103
2104
2105
2106
2107
2108
2109
2110
2111
2112
2113
2114
2115
2116
2117
2118
2119
2120
2121
2122
2123
2124
2125
2126
2127
2128
2129
2130
2131
2132
2133
2134
2135
2136
2137
2138
2139
2140
2141
2142
2143
2144
2145
2146
2147
2148
2149
2150
2151
2152
2153
2154
2155
2156
2157
2158
2159
2160
2161
2162
2163
2164
# This file is a Tcl script to test out the *NEW* "grid" command of Tk. It is
# (almost) organized in the standard fashion for Tcl tests.
#
# Copyright © 1996 Sun Microsystems, Inc.
# Copyright © 1998-1999 Scriptics Corporation.
# All rights reserved.

package require tcltest 2.2
eval tcltest::configure $argv
tcltest::loadTestedCommands
namespace import -force tcltest::test

# helper routine to return "." to a sane state after a test.
# The variable GRID_VERBOSE can be used to "look" at the result of one or all
# of the tests

proc grid_reset {{test ?} {top .}} {
    global GRID_VERBOSE
    if {[info exists GRID_VERBOSE]} {
	if {$GRID_VERBOSE eq "" || $GRID_VERBOSE eq $test} {
	    puts -nonewline "grid test $test: "
	    flush stdout
	    gets stdin
	}
    }
    eval destroy [winfo children $top]
    update
    foreach {cols rows} [grid size .] {}
    for {set i 0} {$i <= $cols} {incr i} {
	grid columnconfigure . $i -weight 0 -minsize 0 -pad 0 -uniform ""
    }
    for {set i 0} {$i <= $rows} {incr i} {
	grid rowconfigure . $i -weight 0 -minsize 0 -pad 0 -uniform ""
    }
    grid propagate . 1
    grid anchor . nw
    update
}

grid_reset 0.0
wm geometry . {}

test grid-1.1 {basic argument checking} -body {
    grid
} -returnCodes error -result {wrong # args: should be "grid option arg ?arg ...?"}
test grid-1.2 {basic argument checking} -body {
    grid foo bar
} -returnCodes error -result {bad option "foo": must be anchor, bbox, columnconfigure, configure, content, forget, info, location, propagate, remove, rowconfigure, or size}
test grid-1.3 {basic argument checking} -body {
    button .b
    grid .b -row 0 -column
} -cleanup {
    grid_reset 1.3
} -returnCodes error -result {extra option or option with no value}
test grid-1.4 {basic argument checking} -body {
    button .b
    grid configure .b - foo
} -cleanup {
    grid_reset 1.4
} -returnCodes error -result {unexpected parameter "foo" in configure list: should be window name or option}
test grid-1.5 {basic argument checking} -body {
    grid .
} -returnCodes error -result {can't manage ".": it's a top-level window}
test grid-1.6 {basic argument checking} -body {
    grid x
} -returnCodes error -result {can't determine container window}
test grid-1.7 {basic argument checking} -body {
    grid configure x
} -returnCodes error -result {can't determine container window}
test grid-1.8 {basic argument checking} -body {
    button .b
    grid x .b
} -cleanup {
    grid_reset 1.8
} -returnCodes ok -result {}
test grid-1.9 {basic argument checking} -body {
    button .b
    grid configure x .b
} -cleanup {
    grid_reset 1.9
} -returnCodes ok -result {}


test grid-2.1 {bbox} -body {
    grid bbox .
} -result {0 0 0 0}
test grid-2.2 {bbox} -body {
    button .b
    grid .b
    destroy .b
    update
    grid bbox .
} -result {0 0 0 0}
test grid-2.3 {bbox: argument checking} -body {
    grid bbox . 0 0 5
} -returnCodes error -result {wrong # args: should be "grid bbox window ?column row ?column row??"}
test grid-2.4 {bbox} -body {
    grid bbox .bad 0 0
} -returnCodes error -result {bad window path name ".bad"}
test grid-2.5 {bbox} -body {
    grid bbox . x 0
} -returnCodes error -result {expected integer but got "x"}
test grid-2.6 {bbox} -body {
    grid bbox . 0 x
} -returnCodes error -result {expected integer but got "x"}
test grid-2.7 {bbox} -body {
    grid bbox . 0 0 x 0
} -returnCodes error -result {expected integer but got "x"}
test grid-2.8 {bbox} -body {
    grid bbox . 0 0 0 x
} -returnCodes error -result {expected integer but got "x"}
test grid-2.9 {bbox} -body {
    frame .1 -width 75 -height 75 -bg red
    frame .2 -width 90 -height 90 -bg red
    grid .1 -row 0 -column 0
    grid .2 -row 1 -column 1
    update
    set a ""
    lappend a [grid bbox .]
    lappend a [grid bbox . 0 0]
    lappend a [grid bbox . 0 0 1 1]
    lappend a [grid bbox . 1 1]
    return $a
} -cleanup {
    grid_reset 2.9
} -result {{0 0 165 165} {0 0 75 75} {0 0 165 165} {75 75 90 90}}
test grid-2.10 {bbox} -body {
    frame .1 -width 75 -height 75 -bg red
    frame .2 -width 90 -height 90 -bg red
    grid .1 -row 0 -column 0
    grid .2 -row 1 -column 1
    update
    set a ""
    lappend a [grid bbox . 10 10 0 0]
    lappend a [grid bbox . -2 -2 -1 -1]
    lappend a [grid bbox . 10 10 12 12]
    return $a
} -cleanup {
    grid_reset 2.10
} -result {{0 0 165 165} {0 0 0 0} {165 165 0 0}}

test grid-3.1 {configure: basic argument checking} -body {
    grid configure foo
} -returnCodes error -result {bad argument "foo": must be name of window}
test grid-3.2 {configure: basic argument checking} -body {
    button .b
    grid configure .b
    grid content .
} -cleanup {
    grid_reset 3.2
} -result {.b}
test grid-3.3 {configure: basic argument checking} -body {
    button .b
    grid .b -row -1
} -cleanup {
    grid_reset 3.3
} -returnCodes error -result {bad row value "-1": must be a non-negative integer}
test grid-3.4 {configure: basic argument checking} -body {
    button .b
    grid .b -column -1
} -cleanup {
    grid_reset 3.4
} -returnCodes error -result {bad column value "-1": must be a non-negative integer}
test grid-3.5 {configure: basic argument checking} -body {
    button .b
    grid .b -rowspan 0
} -cleanup {
    grid_reset 3.5
} -returnCodes error -result {bad rowspan value "0": must be a positive integer}
test grid-3.6 {configure: basic argument checking} -body {
    button .b
    grid .b -columnspan 0
} -cleanup {
    grid_reset 3.6
} -returnCodes error -result {bad columnspan value "0": must be a positive integer}
test grid-3.7 {configure: basic argument checking} -body {
    frame .f
    button .f.b
    grid .f .f.b
} -cleanup {
    grid_reset 3.7
} -returnCodes error -result {can't put ".f.b" inside "."}
test grid-3.8 {configure: basic argument checking} -body {
    button .b
    grid configure x .b
    grid content .
} -cleanup {
    grid_reset 3.8
} -result {.b}
test grid-3.9 {configure: basic argument checking} -body {
    button .b
    grid configure y .b
} -cleanup {
    grid_reset 3.9
} -returnCodes error -result {invalid window shortcut, "y" should be '-', 'x', or '^'}
test grid-3.10 {ConfigureContent procedure, bad -in option} -body {
    frame .f
    grid .f -in .f
} -cleanup {
    grid_reset 3.10
} -returnCodes error -result {window can't be managed in itself}
test grid-3.11 {prevent management loops} -body {
    frame .f1
    frame .f2
    grid .f1 -in .f2
    grid .f2 -in .f1
} -cleanup {
    grid_reset 3.11
} -returnCodes error -result {can't put ".f2" inside ".f1": would cause management loop}
test grid-3.12 {prevent management loops} -body {
    frame .f1
    frame .f2
    frame .f3
    grid .f1 -in .f2
    grid .f2 -in .f3
    grid .f3 -in .f1
} -cleanup {
    grid_reset 3.12
} -returnCodes error -result {can't put ".f3" inside ".f1": would cause management loop}

test grid-4.1 {forget: basic argument checking} -body {
    grid forget foo
} -returnCodes error -result {bad window path name "foo"}
test grid-4.2 {forget} -body {
    button .c
    grid [button .b]
    set a [grid content .]
    grid forget .b .c
    lappend a [grid content .]
    return $a
} -cleanup {
    grid_reset 4.2
} -result {.b {}}
test grid-4.3 {forget} -body {
    button .c
    grid .c -row 2 -column 2 -rowspan 2 -columnspan 2 -padx 3 -pady 4 -sticky ns
    grid forget .c
    grid .c -row 0 -column 0
    grid info .c
} -cleanup {
    grid_reset 4.3
} -result {-in . -column 0 -row 0 -columnspan 1 -rowspan 1 -ipadx 0 -ipady 0 -padx 0 -pady 0 -sticky {}}
test grid-4.4 {forget} -body {
    button .c
    grid .c -row 2 -column 2 -rowspan 2 -columnspan 2 -padx {3 5} -pady {4 7} -sticky ns
    grid forget .c
    grid .c -row 0 -column 0
    grid info .c
} -cleanup {
    grid_reset 4.3.1
} -result {-in . -column 0 -row 0 -columnspan 1 -rowspan 1 -ipadx 0 -ipady 0 -padx 0 -pady 0 -sticky {}}
test grid-4.5 {forget, calling Tk_UnmaintainGeometry} -body {
    frame .f -bd 2 -relief raised
    place .f -x 10 -y 20 -width 200 -height 100
    frame .f2 -width 50 -height 30 -bg red
    grid .f2 -in .f
    update
    set x [winfo ismapped .f2]
    grid forget .f2
    place .f -x 30
    update
    lappend x [winfo ismapped .f2]
} -cleanup {
    grid_reset 4.4
} -result {1 0}

test grid-5.1 {info: basic argument checking} -body {
    grid info a b
} -returnCodes error -result {wrong # args: should be "grid info window"}
test grid-5.2 {info} -body {
    frame .1 -width 75 -height 75 -bg red
    grid .1 -row 0 -column 0
    update
    grid info .x
} -cleanup {
    grid_reset 5.2
} -returnCodes error -result {bad window path name ".x"}
test grid-5.3 {info} -body {
    frame .1 -width 75 -height 75 -bg red
    grid .1 -row 0 -column 0
    update
    grid info .1
} -cleanup {
    grid_reset 5.3
} -result {-in . -column 0 -row 0 -columnspan 1 -rowspan 1 -ipadx 0 -ipady 0 -padx 0 -pady 0 -sticky {}}
test grid-5.4 {info} -body {
    frame .1 -width 75 -height 75 -bg red
    update
    grid info .1
} -cleanup {
    grid_reset 5.4
} -returnCodes ok -result {}

test grid-6.1 {location: basic argument checking} -body {
    grid location .
} -returnCodes error -result {wrong # args: should be "grid location window x y"}
test grid-6.2 {location: basic argument checking} -body {
    grid location .bad 0 0
} -returnCodes error -result {bad window path name ".bad"}
test grid-6.3 {location: basic argument checking} -body {
    grid location . x y
} -returnCodes error -result {bad screen distance "x"}
test grid-6.4 {location: basic argument checking} -body {
    grid location . 1c y
} -returnCodes error -result {bad screen distance "y"}
test grid-6.5 {location: basic argument checking} -body {
    frame .f
    grid location .f 10 10
} -cleanup {
    grid_reset 6.5
} -result {-1 -1}
test grid-6.6 {location (x)} -body {
    frame .f -width 200 -height 100 -highlightthickness 0 -bg red
    grid .f
    update
    set got ""
    set result ""
    for {set x -10} { $x < 220} { incr x} {
	set a [grid location . $x 0]
	if {$a != $got} {
	    lappend result $x->$a
	    set got $a
	}
    }
    return $result
} -cleanup {
    grid_reset 6.6
} -result {{-10->-1 0} {0->0 0} {201->1 0}}
test grid-6.7 {location (y)} -body {
    frame .f -width 200 -height 100 -highlightthickness 0 -bg red
    grid .f
    update
    set got ""
    set result ""
    for {set y -10} { $y < 110} { incr y} {
	set a [grid location . 0 $y]
	if {$a != $got} {
	    lappend result $y->$a
	    set got $a
	}
    }
    return $result
} -cleanup {
    grid_reset 6.7
} -result {{-10->0 -1} {0->0 0} {101->0 1}}
test grid-6.8 {location (weights)} -body {
    frame .f -width 300 -height 100 -highlightthickness 0 -bg red
    frame .a
    grid .a
    grid .f -in .a
    grid rowconfigure .f 0 -weight 1
    grid columnconfigure .f 0 -weight 1
    grid propagate .a 0
    .a configure -width 200 -height 15
    update
    set got ""
    set result ""
    for {set y -10} { $y < 210} { incr y} {
	set a [grid location . $y $y]
	if {$a != $got} {
	    lappend result $y->$a
	    set got $a
	}
    }
    return $result
} -cleanup {
    grid_reset 6.8
} -result {{-10->-1 -1} {0->0 0} {16->0 1} {201->1 1}}
test grid-6.9 {location: check updates pending} -body {
    set a ""
    foreach i {0 1 2} {
	frame .$i -width 120 -height 75 -bg red
	lappend a [grid location . 150 90]
	grid .$i -row $i -column $i
    }
    return $a
} -cleanup {
    grid_reset 6.9
} -result {{0 0} {1 1} {1 1}}

test grid-7.1 {propagate} -body {
    grid propagate . 1 xxx
} -cleanup {
    grid_reset 7.1
} -returnCodes error -result {wrong # args: should be "grid propagate window ?boolean?"}
test grid-7.2 {propagate} -body {
    grid propagate .
} -cleanup {
    grid_reset 7.2
} -result 1
test grid-7.3 {propagate} -body {
    grid propagate . 0;grid propagate .
} -cleanup {
    grid_reset 7.3
} -result 0
test grid-7.4 {propagate} -body {
    grid propagate .x
} -cleanup {
    grid_reset 7.4
} -returnCodes error -result {bad window path name ".x"}
test grid-7.5 {propagate} -body {
    grid propagate . x
} -cleanup {
    grid_reset 7.5
} -returnCodes error -result {expected boolean value but got "x"}
test grid-7.6 {propagate} -body {
    frame .f -width 100 -height 100 -bg red
    grid .f -row 0 -column 0
    update
    set a [winfo width .f]x[winfo height .f]
    grid propagate .f 0
    frame .g -width 75 -height 85 -bg green
    grid .g -in .f -row 0 -column 0
    update
    lappend a [winfo width .f]x[winfo height .f]
    grid propagate .f 1
    update
    lappend a [winfo width .f]x[winfo height .f]
    return $a
} -cleanup {
    grid_reset 7.6
} -result {100x100 100x100 75x85}
test grid-7.7 {propagate} -body {
    grid propagate . 1
    set res [list [grid propagate .]]
    grid propagate . 0
    lappend res [grid propagate .]
    grid propagate . 0
    lappend res [grid propagate .]
    return $res
} -cleanup {
    grid_reset 7.7
} -result [list 1 0 0]

test grid-8.1 {size} -body {
    grid size . foo
} -cleanup {
    grid_reset 8.1
} -returnCodes error -result {wrong # args: should be "grid size window"}
test grid-8.2 {size} -body {
    grid size .x
} -cleanup {
    grid_reset 8.2
} -returnCodes error -result {bad window path name ".x"}
test grid-8.3 {size} -body {
    frame .f
    grid size .f
} -cleanup {
    grid_reset 8.3
} -result {0 0}
test grid-8.4 {size} -body {
    catch {unset a}
    scale .f
    grid .f -row 0 -column 0
    update
    lappend a [grid size .]
    grid .f -row 4 -column 5
    update
    lappend a [grid size .]
    grid .f -row 947 -column 663
    update
    lappend a [grid size .]
    grid .f -row 0 -column 0
    update
    lappend a [grid size .]
    return $a
} -cleanup {
    grid_reset 8.4
} -result {{1 1} {6 5} {664 948} {1 1}}
test grid-8.5 {size} -body {
    catch {unset a}
    scale .f
    grid .f -row 0 -column 0
    update
    lappend a [grid size .]
    grid rowconfigure . 17 -weight 1
    update
    lappend a [grid size .]
    grid columnconfigure . 63 -weight 1
    update
    lappend a [grid size .]
    grid columnconfigure . 63 -weight 0
    grid rowconfigure . 17 -weight 0
    update
    lappend a [grid size .]
    return $a
} -cleanup {
    grid_reset 8.5
} -result {{1 1} {1 18} {64 18} {1 1}}
test grid-8.6 {size} -body {
    catch {unset a}
    scale .f
    grid .f -row 10 -column 50
    update
    lappend a [grid size .]
    grid columnconfigure . 15 -weight 1
    grid columnconfigure . 30 -weight 1
    update
    lappend a [grid size .]
    grid .f -row 10 -column 20
    update
    lappend a [grid size .]
    grid columnconfigure . 30 -weight 0
    update
    lappend a [grid size .]
    grid .f -row 0 -column 0
    update
    lappend a [grid size .]
    grid columnconfigure . 15 -weight 0
    update
    lappend a [grid size .]
    return $a
} -cleanup {
    grid_reset 8.6
} -result {{51 11} {51 11} {31 11} {21 11} {16 1} {1 1}}

test grid-9.1 {content} -body {
    grid content .
} -returnCodes ok -result {}
test grid-9.2 {content} -body {
    grid content .foo
} -returnCodes error -result {bad window path name ".foo"}
test grid-9.3 {content} -body {
    grid content a b
} -returnCodes error -result {wrong # args: should be "grid content window ?-option value ...?"}
test grid-9.4 {content} -body {
    grid content . a b
} -returnCodes error -result {bad option "a": must be -column or -row}
test grid-9.5 {content} -body {
    grid content . -column x
} -returnCodes error -result {expected integer but got "x"}
test grid-9.6 {content} -body {
    grid content . -row -3
} -returnCodes error -result {-3 is an invalid value: should NOT be < 0}
test grid-9.7 {content} -body {
    grid content . -foo 3
} -returnCodes error -result {bad option "-foo": must be -column or -row}
test grid-9.8 {content} -body {
    grid content .x -row 3
} -returnCodes error -result {bad window path name ".x"}
test grid-9.9 {content} -body {
    grid content . -row 3
} -returnCodes ok -result {}
test grid-9.10 {content} -body {
    foreach i {0 1 2} {
	label .$i -text $i
	grid .$i -row $i -column $i
    }
    grid content .
} -cleanup {
    grid_reset 9.10
} -result {.2 .1 .0}
test grid-9.11 {content} -body {
    catch {unset a}
    foreach i {0 1 2} {
	label .$i -text $i
	label .$i-x -text $i-x
	grid .$i -row $i -column $i
	grid .$i-x -row $i -column [incr i]
    }
    foreach row {0 1 2 3} {
	lappend a $row{[grid content . -row $row]}
    }
    foreach col {0 1 2 3} {
	lappend a $col{[grid content . -column $col]}
    }
    return $a
} -cleanup {
    grid_reset 9.11
} -result {{0{.0-x .0}} {1{.1-x .1}} {2{.2-x .2}} 3{} 0{.0} {1{.1 .0-x}} {2{.2 .1-x}} 3{.2-x}}

# column/row configure
test grid-10.1 {column/row configure} -body {
    grid columnconfigure .
} -cleanup {
    grid_reset 10.1
} -returnCodes error -result {wrong # args: should be "grid columnconfigure window index ?-option value ...?"}
test grid-10.2 {column/row configure} -body {
    grid columnconfigure . 0 -weight 0 -pad
} -cleanup {
    grid_reset 10.2
} -returnCodes error -result {wrong # args: should be "grid columnconfigure window index ?-option value ...?"}
test grid-10.3 {column/row configure} -body {
    grid columnconfigure .f 0 -weight
} -cleanup {
    grid_reset 10.3
} -returnCodes error -result {bad window path name ".f"}
test grid-10.4 {column/row configure} -body {
    grid columnconfigure . nine -weight
} -cleanup {
    grid_reset 10.4
} -returnCodes error -result {expected integer but got "nine" (when retrieving options only integer indices are allowed)}
test grid-10.5 {column/row configure} -body {
    grid columnconfigure . 265 -weight
} -cleanup {
    grid_reset 10.5
} -result 0
test grid-10.6 {column/row configure} -body {
    grid columnconfigure . 0
} -cleanup {
    grid_reset 10.6
} -result {-minsize 0 -pad 0 -uniform {} -weight 0}
test grid-10.7 {column/row configure} -body {
    grid columnconfigure . 0 -foo
} -cleanup {
    grid_reset 10.7
} -returnCodes error -result {bad option "-foo": must be -minsize, -pad, -uniform, or -weight}
test grid-10.8 {column/row configure} -body {
    grid columnconfigure . 0 -minsize foo
} -cleanup {
    grid_reset 10.8
} -returnCodes error -result {bad screen distance "foo"}
test grid-10.9 {column/row configure} -body {
    grid columnconfigure . 0 -minsize foo
} -cleanup {
    grid_reset 10.9
} -returnCodes error -result {bad screen distance "foo"}
test grid-10.10 {column/row configure} -body {
    grid columnconfigure . 0 -minsize 10
    grid columnconfigure . 0 -minsize
} -cleanup {
    grid_reset 10.10
} -result 10
test grid-10.11 {column/row configure} -body {
    grid columnconfigure . 0 -weight bad
} -cleanup {
    grid_reset 10.11
} -returnCodes error -result {expected integer but got "bad"}
test grid-10.12 {column/row configure} -body {
    grid columnconfigure . 0 -weight -3
} -cleanup {
    grid_reset 10.12
} -returnCodes error -result {invalid arg "-weight": should be non-negative}
test grid-10.13 {column/row configure} -body {
    grid columnconfigure . 0 -weight 3
    grid columnconfigure . 0 -weight
} -cleanup {
    grid_reset 10.13
} -result 3
test grid-10.14 {column/row configure} -body {
    grid columnconfigure . 0 -pad foo
} -cleanup {
    grid_reset 10.14
} -returnCodes error -result {bad screen distance "foo"}
test grid-10.15 {column/row configure} -body {
    grid columnconfigure . 0 -pad -3
} -cleanup {
    grid_reset 10.15
} -returnCodes error -result {invalid arg "-pad": should be non-negative}
test grid-10.16 {column/row configure} -body {
    grid columnconfigure . 0 -pad 3
    grid columnconfigure . 0 -pad
} -cleanup {
    grid_reset 10.16
} -result 3
test grid-10.17 {column/row configure} -body {
    frame .f
    set a ""
    grid columnconfigure .f 0 -weight 0
    lappend a [grid columnconfigure .f 0 -weight]
    grid columnconfigure .f 0 -weight 1
    lappend a [grid columnconfigure .f 0 -weight]
    grid rowconfigure .f 0 -weight 0
    lappend a [grid rowconfigure .f 0 -weight]
    grid rowconfigure .f 0 -weight 1
    lappend a [grid columnconfigure .f 0 -weight]
    grid columnconfigure .f 0 -weight 0
    return $a
} -cleanup {
    grid_reset 10.17
} -result {0 1 0 1}
test grid-10.18 {column/row configure} -body {
    frame .f
    grid columnconfigure .f {0 2} -minsize 10 -weight 1
    list [grid columnconfigure .f 0 -minsize] \
	[grid columnconfigure .f 1 -minsize] \
	[grid columnconfigure .f 2 -minsize] \
	[grid columnconfigure .f 0 -weight] \
	[grid columnconfigure .f 1 -weight] \
	[grid columnconfigure .f 2 -weight]
} -cleanup {
    grid_reset 10.18
} -result {10 0 10 1 0 1}
test grid-10.19 {column/row configure} -body {
    grid columnconfigure . {0 -1 2} -weight 1
} -cleanup {
    grid_reset 10.19
} -returnCodes error -result {"-1" is out of range}
test grid-10.20 {column/row configure} -body {
    grid columnconfigure . 0 -uniform foo
    grid columnconfigure . 0 -uniform
} -cleanup {
    grid_reset 10.20
} -result {foo}
test grid-10.21 {column/row configure} -body {
    grid columnconfigure . .b -weight 1
} -cleanup {
    grid_reset 10.21
} -returnCodes error -result {illegal index ".b"}
test grid-10.22 {column/row configure} -body {
    button .b
    grid columnconfigure . .b -weight 1
} -cleanup {
    grid_reset 10.22
} -returnCodes error -result {the window ".b" is not managed by "."}
test grid-10.23 {column/row configure} -body {
    button .b
    grid .b -column 1 -columnspan 2
    grid columnconfigure . .b -weight 1
    set res {}
    foreach i {0 1 2 3} {
        lappend res [grid columnconfigure . $i -weight]
    }
    return $res
} -cleanup {
    grid_reset 10.23
} -result {0 1 1 0}
test grid-10.24 {column/row configure} -body {
    button .b
    button .c
    button .d
    grid .b -column 1 -columnspan 2
    grid .c -column 2 -columnspan 3
    grid .d -column 4 -columnspan 2
    grid columnconfigure . {.b .d} -weight 1
    grid columnconfigure . .c -weight 2
    set res {}
    foreach i {0 1 2 3 4 5 6} {
        lappend res [grid columnconfigure . $i -weight]
    }
    return $res
} -cleanup {
    grid_reset 10.24
} -result {0 1 2 2 2 1 0}
test grid-10.25 {column/row configure} -body {
    button .b
    button .c
    button .d
    grid .b -row 1 -rowspan 2
    grid .c -row 2 -rowspan 3
    grid .d -row 4 -rowspan 2
    grid rowconfigure . {7 all} -weight 1
    grid rowconfigure . {1 .d} -weight 2
    set res {}
    foreach i {0 1 2 3 4 5 6 7} {
        lappend res [grid rowconfigure . $i -weight]
    }
    return $res
} -cleanup {
    grid_reset 10.25
} -result {0 2 1 1 2 2 0 1}
test grid-10.26 {column/row configure} -body {
    button .b
    grid columnconfigure .b 0
} -cleanup {
    grid_reset 10.26
} -result {-minsize 0 -pad 0 -uniform {} -weight 0}
test grid-10.27 {column/row configure - no indices} -body {
    # Bug 1422430
    set t [toplevel .test]
    grid columnconfigure $t "" -weight 1
} -cleanup {
    destroy $t
} -returnCodes error -result {no column indices specified}
test grid-10.28 {column/row configure - no indices} -body {
    set t [toplevel .test]
    grid rowconfigure $t "" -weight 1
} -cleanup {
    destroy $t
} -returnCodes error -result {no row indices specified}
test grid-10.29 {column/row configure - invalid indices} -body {
    grid columnconfigure . {0 1 2} -weight
} -returnCodes error -result {must specify a single element on retrieval}
test grid-10.30 {column/row configure - invalid indices} -body {
    grid rowconfigure . {0 1 2} -weight
} -returnCodes error -result {must specify a single element on retrieval}
test grid-10.31 {column/row configure - empty 'all' configure} -body {
    # Bug 1422430
    set t [toplevel .test]
    grid rowconfigure $t all -weight 1
    destroy $t
} -result {}
test grid-10.32 {column/row configure} -body {
    # Test that no lingering message is there
    frame .f
    set res    [grid columnconfigure .f all -weight 1]
    append res [grid columnconfigure .f {0 all} -weight 1]
    frame .f.f
    grid .f.f
    append res [grid columnconfigure .f {.f.f} -weight 1]
    append res [grid columnconfigure .f {.f.f 1} -weight 1]
    append res [grid columnconfigure .f {2 .f.f} -weight 1]
    destroy .f
    return $res
} -cleanup {
    grid_reset 10.35
} -result {}
test grid-10.33 {column/row configure} -body {
    grid columnconfigure . all
} -cleanup {
    grid_reset 10.36
} -returnCodes error -result {expected integer but got "all" (when retrieving options only integer indices are allowed)}
test grid-10.34 {column/row configure} -body {
    grid columnconfigure . 100000
} -cleanup {
    grid_reset 10.37
} -result {-minsize 0 -pad 0 -uniform {} -weight 0}
test grid-10.35 {column/row configure} -body {
    # This is a test for bug 1423666 where a column >= 10000 caused
    # a crash in layout.  The update is needed to reach the layout stage.
    # Test different combinations of row/column overflow
    frame .f
    set res {}
    lappend res [catch {grid .f -row 10 -column 9999} msg] $msg ; update
    lappend res [catch {grid .f -row 9999 -column 10} msg] $msg ; update
    lappend res [catch {grid .f -columnspan 2 -column 9998} msg] $msg ; update
    lappend res [catch {grid .f -rowspan 2 -row 9998} msg] $msg ; update
    lappend res [catch {grid .f -column 9998 -columnspan 2} msg] $msg ; update
    lappend res [catch {grid .f -row 9998 -rowspan 2} msg] $msg ; update
    return $res
} -cleanup {destroy .f} -result [lrange {
    1 {column out of bounds}
    1 {row out of bounds}
    1 {column out of bounds}
    1 {row out of bounds}
    1 {column out of bounds}
    1 {row out of bounds}
} 0 end]
grid_reset 10.38
test grid-10.36 {column/row configure} -body {
    # Additional tests for row/column overflow
    frame .f
    frame .g
    set res {}
    grid .f -row 9998 -column 0
    lappend res [catch {grid ^ -in .} msg] $msg  ; update
    lappend res [catch {grid .g} msg] $msg  ; update
    grid forget .f .g
    lappend res [catch {grid .f - -column 9998} msg] $msg ; update
    grid forget .f .g
    lappend res [catch {eval grid [string repeat " x " 9999] .f} msg] $msg
    update
    return $res
} -cleanup {destroy .f .g} -result [lrange {
    1 {row out of bounds}
    1 {row out of bounds}
    1 {column out of bounds}
    1 {column out of bounds}
} 0 end]
grid_reset 10.39

# auto-placement tests
test grid-11.1 {default widget placement} -body {
    grid ^
} -cleanup {
    grid_reset 11.1
} -returnCodes error -result {can't use '^', can't find container window}
test grid-11.2 {default widget placement} -body {
    button .b
    grid .b ^
} -cleanup {
    grid_reset 11.2
} -returnCodes error -result {can't find content to extend with "^"}
test grid-11.3 {default widget placement} -body {
    button .b
    grid .b - - .c
} -cleanup {
    grid_reset 11.3
} -returnCodes error -result {bad window path name ".c"}
test grid-11.4 {default widget placement} -body {
    button .b
    grid .b - - = -
} -cleanup {
    grid_reset 11.4
} -returnCodes error -result {invalid window shortcut, "=" should be '-', 'x', or '^'}
test grid-11.5 {default widget placement} -body {
    button .b
    grid .b - x -
} -cleanup {
    grid_reset 11.5
} -returnCodes error -result {must specify window before shortcut '-'}
test grid-11.6 {default widget placement} -body {
    foreach i {1 2 3 4 5 6} {
	frame .f$i -width 50 -height 50 -highlightthickness 0 -bg red
    }
    grid .f1 .f2 .f3 .f4
    grid .f5   -  x  .f6 -sticky nsew
    update
    set a ""
    foreach i {5 6} {
	lappend a "[winfo x .f$i],[winfo y .f$i] \
		[winfo width .f$i],[winfo height .f$i]"
    }
    return $a
} -cleanup {
    grid_reset 11.6
} -result {{0,50  100,50} {150,50  50,50}}
test grid-11.7 {default widget placement} -body {
    frame .f -width 20 -height 20 -highlightthickness 0 -bg red
    grid .f -row 5 -column 5
    grid .f x -
} -cleanup {
    grid_reset 11.7
} -returnCodes error -result {must specify window before shortcut '-'}
test grid-11.8 {default widget placement} -body {
    frame .f -width 20 -height 20 -highlightthickness 0 -bg red
    grid .f -row 5 -column 5
    grid .f ^ -
} -cleanup {
    grid_reset 11.8
} -returnCodes error -result {must specify window before shortcut '-'}
test grid-11.9 {default widget placement} -body {
    frame .f -width 20 -height 20 -highlightthickness 0 -bg red
    grid .f -row 5 -column 5
    grid .f x ^
} -cleanup {
    grid_reset 11.9
} -returnCodes error -result {can't find content to extend with "^"}
test grid-11.10 {default widget placement} -body {
    foreach i {1 2 3} {
	frame .f$i -width 100 -height 50 -highlightthickness 0 -bg red
    }
    grid .f1 .f2  -sticky nsew
    grid .f3   ^  -sticky nsew
    update
    set a ""
    foreach i {1 2 3} {
	lappend a "[winfo x .f$i],[winfo y .f$i] \
		[winfo width .f$i],[winfo height .f$i]"
    }
    return $a
} -cleanup {
    grid_reset 11.10
} -result {{0,0  100,50} {100,0  100,100} {0,50  100,50}}
test grid-11.11 {default widget placement} -body {
    foreach i {1 2 3 4 5 6 7 8 9 10 11 12} {
	frame .f$i -width 50 -height 50 -highlightthickness 1 -highlightbackground black
    }
    grid .f1  .f2  .f3 .f4  -sticky nsew
    grid .f5  .f6   -  .f7  -sticky nsew
    grid .f8    ^   ^  .f9  -sticky nsew
    grid .f10   ^   ^  .f11 -sticky nsew
    grid .f12   -   -   -   -sticky nsew
    update
    set a ""
    foreach i {5 6 7 8 9 10 11 12 } {
	lappend a "[winfo x .f$i],[winfo y .f$i] \
		[winfo width .f$i],[winfo height .f$i]"
    }
    return $a
} -cleanup {
    grid_reset 11.11
} -result {{0,50  50,50} {50,50  100,150} {150,50  50,50} {0,100  50,50} {150,100  50,50} {0,150  50,50} {150,150  50,50} {0,200  200,50}}
test grid-11.12 {default widget placement} -body {
    foreach i {1 2 3 4} {
	frame .f$i -width 75 -height 50 -highlightthickness 1 -highlightbackground black
    }
    grid .f1  .f2   .f3     -sticky nsew
    grid .f4    ^           -sticky nsew
    update
    set a ""
    foreach i {1 2 3 4} {
	lappend a "[winfo x .f$i],[winfo y .f$i] \
		[winfo width .f$i],[winfo height .f$i]"
    }
    grid .f4    ^   -column 1
    update
    foreach i {1 2 3 4} {
	lappend a "[winfo x .f$i],[winfo y .f$i] \
		[winfo width .f$i],[winfo height .f$i]"
    }
    return $a
} -cleanup {
    grid_reset 11.12
} -result {{0,0  75,50} {75,0  75,100} {150,0  75,50} {0,50  75,50} {0,0  75,50} {75,0  75,100} {150,0  75,100} {75,50  75,50}}
test grid-11.13 {default widget placement} -body {
    foreach i {1 2 3 4 5 6 7} {
	frame .f$i -width 40 -height 50 -highlightthickness 1 -highlightbackground black
    }
    grid .f1  .f2  .f3 .f4 .f5 -sticky nsew
    grid .f6    -  .f7         -sticky nsew -columnspan 2
    update
    set a ""
    foreach i {6 7} {
	lappend a "[winfo x .f$i],[winfo y .f$i] \
		[winfo width .f$i],[winfo height .f$i]"
    }
    return $a
} -cleanup {
    grid_reset 11.13
} -result {{0,50  120,50} {120,50  80,50}}
test grid-11.14 {default widget placement} -body {
    foreach i {1 2 3} {
	frame .f$i -width 60 -height 60 -highlightthickness 0 -bg red
    }
    grid .f1 .f2
    grid  ^  .f3
    update
    set a ""
    foreach i {1 2 3} {
	lappend a "[winfo x .f$i],[winfo y .f$i] \
		[winfo width .f$i],[winfo height .f$i]"
    }
    return $a
} -cleanup {
    grid_reset 11.14
} -result {{0,30  60,60} {60,0  60,60} {60,60  60,60}}
test grid-11.15 {^ ^ test with multiple windows} -body {
    foreach i {1 2 3 4} {
	frame .f$i -width 50 -height 50 -bd 1 -relief solid
    }
    grid .f1 .f2 .f3 -sticky ns
    grid .f4 ^ ^
    update
    set a ""
    foreach i {1 2 3 4} {
	lappend a "[winfo x .f$i],[winfo y .f$i]\
		[winfo width .f$i],[winfo height .f$i]"
    }
    return $a
} -cleanup {
    grid_reset 11.15
} -result {{0,0 50,50} {50,0 50,100} {100,0 50,100} {0,50 50,50}}
test grid-11.16 {default widget placement} -body {
    foreach l {a b c d e} {
        frame .$l -width 50 -height 50
    }
    grid .a .b .c .d -sticky news
    grid  x  ^  x .e -sticky news
    update
    set res ""
    lappend res [winfo height .a]
    lappend res [winfo height .b]
    lappend res [winfo height .c]
} -cleanup {
    grid_reset 11.16
} -result {50 100 50}
test grid-11.17 {default widget placement} -body {
    foreach l {a b c d e} {
        frame .$l -width 50 -height 50
    }
    grid .a .b .c .d -sticky news
    grid  ^  x  ^ .e -sticky news
    update
    set res ""
    lappend res [winfo height .a]
    lappend res [winfo height .b]
    lappend res [winfo height .c]
} -cleanup {
    grid_reset 11.17
} -result {100 50 100}
test grid-11.18 {default widget placement} -body {
    foreach l {a b c d e} {
        frame .$l -width 50 -height 50
    }
    grid .a .b .c .d -sticky news
    grid  ^  ^  ^  x -in .           ;# ^ and no child should work with -in.
    grid rowconfigure . {0 1} -uniform a
    update
    set res ""
    lappend res [winfo height .a]
    lappend res [winfo height .b]
    lappend res [winfo height .c]
    lappend res [winfo height .d]
} -cleanup {
    grid_reset 11.18
} -result {100 100 100 50}
test grid-11.19 {default widget placement} -body {
    foreach l {a b c d e} {
        frame .$l -width 50 -height 50
    }
    grid .a .b -sticky news
    grid .c .d -sticky news
    grid ^     -in . -row 2
    grid x  ^  -in . -row 1
    grid rowconfigure . {0 1 2} -uniform a
    update
    set res ""
    lappend res [winfo height .a]
    lappend res [winfo height .b]
    lappend res [winfo height .c]
    lappend res [winfo height .d]
} -cleanup {
    grid_reset 11.19
} -result {50 100 100 50}

test grid-12.1 {-sticky} -body {
    catch {unset data}
    frame .f -width 200 -height 100 -highlightthickness 0 -bg red
    set a ""
    grid .f
    grid rowconfigure . 0 -weight 1
    grid columnconfigure . 0 -weight 1
    grid propagate . 0
    . configure -width 250 -height 150
    foreach i { {} n s e w ns ew nw ne se sw nse nsw sew new nsew} {
	grid .f -sticky $i
	update
	array set data [grid info .f]
	append a "($data(-sticky)) [winfo x .f] [winfo y .f] [winfo width .f] [winfo height .f]\n"
    }
    return $a
} -cleanup {
    grid_reset 12.1
} -result {() 25 25 200 100
(n) 25 0 200 100
(s) 25 50 200 100
(e) 50 25 200 100
(w) 0 25 200 100
(ns) 25 0 200 150
(ew) 0 25 250 100
(nw) 0 0 200 100
(ne) 50 0 200 100
(es) 50 50 200 100
(sw) 0 50 200 100
(nes) 50 0 200 150
(nsw) 0 0 200 150
(esw) 0 50 250 100
(new) 0 0 250 100
(nesw) 0 0 250 150
}
test grid-12.2 {-sticky} -body {
    frame .f -bg red
    grid .f -sticky glue
} -cleanup {
    grid_reset 12.2
} -returnCodes error -result {bad stickyness value "glue": must be a string containing n, e, s, and/or w}
test grid-12.3 {-sticky} -body {
    frame .f -bg red
    grid .f -sticky {n,s,e,w}
    array set A [grid info .f]
    set A(-sticky)
} -cleanup {
    grid_reset 12.3
} -result {nesw}

test grid-13.1 {-in} -body {
    frame .f -bg red
    grid .f -in .f
} -cleanup {
    grid_reset 13.1
} -returnCodes error -result {window can't be managed in itself}
test grid-13.2 {-in} -body {
    frame .f -bg red
    list [winfo manager .f] \
         [catch {grid .f -in .f} err] $err \
         [winfo manager .f]
} -cleanup {
    grid_reset 13.1.1
} -result {{} 1 {window can't be managed in itself} {}}
test grid-13.3 {-in} -body {
    frame .f -bg red
    grid .f -in .bad
} -cleanup {
    grid_reset 13.2
} -returnCodes error -result {bad window path name ".bad"}
test grid-13.4 {-in} -body {
    frame .f -bg red
    toplevel .top
    grid .f -in .top
} -cleanup {
    grid_reset 13.3
} -returnCodes error -result {can't put ".f" inside ".top"}
destroy .top
test grid-13.5 {-ipadx} -body {
    frame .f -width 20 -height 20 -highlightthickness 0 -bg red
    grid .f -ipadx x
} -cleanup {
    grid_reset 13.4
} -returnCodes error -result {bad ipadx value "x": must be positive screen distance}
test grid-13.6 {-ipadx} -body {
    frame .f -width 20 -height 20 -highlightthickness 0 -bg red
    grid .f -ipadx {5 5}
} -cleanup {
    grid_reset 13.4.1
} -returnCodes error -result {bad ipadx value "5 5": must be positive screen distance}
test grid-13.7 {-ipadx} -body {
    frame .f -width 200 -height 100 -highlightthickness 0 -bg red
    grid .f
    update
    set a [winfo width .f]
    grid .f -ipadx 1
    update
    list $a [winfo width .f]
} -cleanup {
    grid_reset 13.5
} -result {200 202}
test grid-13.8 {-ipady} -body {
    frame .f -width 20 -height 20 -highlightthickness 0 -bg red
    grid .f -ipady x
} -cleanup {
    grid_reset 13.6
} -returnCodes error -result {bad ipady value "x": must be positive screen distance}
test grid-13.9 {-ipady} -body {
    frame .f -width 20 -height 20 -highlightthickness 0 -bg red
    grid .f -ipady {5 5}
} -cleanup {
    grid_reset 13.6.1
} -returnCodes error -result {bad ipady value "5 5": must be positive screen distance}
test grid-13.10 {-ipady} -body {
    frame .f -width 200 -height 100 -highlightthickness 0 -bg red
    grid .f
    update
    set a [winfo height .f]
    grid .f -ipady 1
    update
    list $a [winfo height .f]
} -cleanup {
    grid_reset 13.7
} -result {100 102}
test grid-13.11 {-padx} -body {
    frame .f -width 20 -height 20 -highlightthickness 0 -bg red
    grid .f -padx x
} -cleanup {
    grid_reset 13.8
} -returnCodes error -result {bad pad value "x": must be positive screen distance}
test grid-13.12 {-padx} -body {
    frame .f -width 20 -height 20 -highlightthickness 0 -bg red
    grid .f -padx {10 x}
} -cleanup {
    grid_reset 13.8.1
} -returnCodes error -result {bad 2nd pad value "x": must be positive screen distance}
test grid-13.13 {-padx} -body {
    frame .f -width 200 -height 100 -highlightthickness 0 -bg red
    grid .f
    update
    set a "[winfo width .f] [winfo width .]"
    grid .f -padx 1
    update
    list $a "[winfo width .f] [winfo width .] [winfo x .f]"
} -cleanup {
    grid_reset 13.9
} -result {{200 200} {200 202 1}}
test grid-13.14 {-padx} -body {
    frame .f -width 200 -height 100 -highlightthickness 0 -bg red
    grid .f
    update
    set a "[winfo width .f] [winfo width .]"
    grid .f -padx {10 5}
    update
    list $a "[winfo width .f] [winfo width .] [winfo x .f]"
} -cleanup {
    grid_reset 13.9.1
} -result {{200 200} {200 215 10}}
test grid-13.15 {-pady} -body {
    frame .f -width 20 -height 20 -highlightthickness 0 -bg red
    grid .f -pady x
} -cleanup {
    grid_reset 13.10
} -returnCodes error -result {bad pad value "x": must be positive screen distance}
test grid-13.16 {-pady} -body {
    frame .f -width 20 -height 20 -highlightthickness 0 -bg red
    grid .f -pady {10 x}
} -cleanup {
    grid_reset 13.10.1
} -returnCodes error -result {bad 2nd pad value "x": must be positive screen distance}
test grid-13.17 {-pady} -body {
    frame .f -width 200 -height 100 -highlightthickness 0 -bg red
    grid .f
    update
    set a "[winfo height .f] [winfo height .]"
    grid .f -pady 1
    update
    list $a "[winfo height .f] [winfo height .] [winfo y .f]"
} -cleanup {
    grid_reset 13.11
} -result {{100 100} {100 102 1}}
test grid-13.18 {-pady} -body {
    frame .f -width 200 -height 100 -highlightthickness 0 -bg red
    grid .f
    update
    set a "[winfo height .f] [winfo height .]"
    grid .f -pady {4 16}
    update
    list $a "[winfo height .f] [winfo height .] [winfo y .f]"
} -cleanup {
    grid_reset 13.11.1
} -result {{100 100} {100 120 4}}
test grid-13.19 {-ipad x and y} -body {
    frame .f -width 20 -height 20 -highlightthickness 0 -bg red
    grid columnconfigure . 0 -minsize 150
    grid rowconfigure . 0 -minsize 100
    set a ""
    foreach x {0 5} {
	foreach y {0 5} {
	    grid .f -ipadx $x -ipady $y
	    update
	    append a " $x,$y:"
	    foreach prop {x y width height} {
		append a ,[winfo $prop .f]
	    }
	}
    }
    return $a
} -cleanup {
    grid_reset 13.12
} -result { 0,0:,65,40,20,20 0,5:,65,35,20,30 5,0:,60,40,30,20 5,5:,60,35,30,30}
test grid-13.20 {reparenting} -body {
    frame .1
    frame .2
    button .b
    grid .1 .2
    grid .b -in .1
    set a ""
    catch {unset info}; array set info [grid info .b]
    lappend a [grid content .1],[grid content .2],$info(-in)
    grid .b -in .2
    catch {unset info}; array set info [grid info .b]
    lappend a [grid content .1],[grid content .2],$info(-in)
    unset info
    return $a
} -cleanup {
    grid_reset 13.13
} -result {.b,,.1 ,.b,.2}

test grid-14.1 {structure notify} -body {
    frame .f -width 200 -height 100 -highlightthickness 0 -bg red
    frame .g -width 200 -height 100 -highlightthickness 0 -bg red
    grid .f
    grid .g -in .f
    update
    set a ""
    lappend a "[winfo x .g],[winfo y .g] \
        [winfo width .g],[winfo height .g]"
    .f configure -bd 5 -relief raised
    update
    lappend a "[winfo x .g],[winfo y .g] \
        [winfo width .g],[winfo height .g]"
    return $a
} -cleanup {
    grid_reset 14.1
} -result {{0,0  200,100} {5,5  200,100}}
test grid-14.2 {structure notify} -body {
    frame .f -width 200 -height 100
    frame .f.g -width 200 -height 100
    grid .f
    grid .f.g
    update
    set a ""
    lappend a [grid bbox .],[grid bbox .f]
    .f config -bd 20
    update
    lappend a [grid bbox .],[grid bbox .f]
} -cleanup {
    grid_reset 14.2
} -result {{0 0 200 100,0 0 200 100} {0 0 240 140,20 20 200 100}}
test grid-14.3 {map notify: bug 1648} -constraints {nonPortable} -body {
    # This test is nonPortable because the number of times
    # A(.) will be incremented is unspecified--the behavior
    # is different accross window managers.
    global A
    catch {unset A}
    bind . <Configure> {incr A(%W)}
    set A(.) 0
    foreach i {0 1 2} {
	frame .$i -width 100 -height 75
	set A(.$i) 0
    }
    grid .0 .1 .2
    update
    bind <Configure> .1 {destroy .0}
    .2 configure -bd 10
    update
    bind . <Configure> {}
    array get A
} -cleanup {
    grid_reset 14.3
} -result {.2 2 .0 1 . 2 .1 1}

test grid-15.1 {lost content} -body {
    button .b
    grid .b
    set a [grid content .]
    pack .b
    lappend a [grid content .]
    grid .b
    lappend a [grid content .]
} -cleanup {
    grid_reset 15.1
} -result {.b {} .b}
test grid-15.2 {lost content} -body {
    frame .f
    grid .f
    button .b
    grid .b -in .f
    set a [grid content .f]
    pack .b -in .f
    lappend a [grid content .f]
    grid .b -in .f
    lappend a [grid content .f]
} -cleanup {
    grid_reset 15.2
} -result {.b {} .b}

test grid-16.1 {layout centering} -body {
    foreach i {0 1 2} {
	frame .$i -bg gray  -width 75 -height 50 -bd 2 -relief ridge
	grid .$i -row $i -column $i -sticky nswe
    }
    grid propagate . 0
    grid anchor . center
    . configure -width 300 -height 250
    update
    grid bbox .
} -cleanup {
    grid_reset 16.1
} -result {37 50 225 150}
test grid-16.2 {layout weights (expanding)} -body {
    foreach i {0 1 2} {
	frame .$i -bg gray  -width 75 -height 50 -bd 2 -relief ridge
	grid .$i -row $i -column $i -sticky nswe
	grid rowconfigure . $i -weight [expr $i + 1]
	grid columnconfigure . $i -weight [expr $i + 1]
    }
    grid propagate . 0
    . configure -width 500 -height 300
    set a ""
    update
    foreach i {0 1 2} {
	lappend a [winfo width .$i]-[winfo height .$i]
    }
    return $a
} -cleanup {
    grid_reset 16.2
} -result {120-75 167-100 213-125}
test grid-16.3 {layout weights (shrinking)} -body {
    foreach i {0 1 2} {
	frame .$i -bg gray -width 100 -height 75 -bd 2 -relief ridge
	grid .$i -row $i -column $i -sticky nswe
	grid rowconfigure . $i -weight [expr $i + 1]
	grid columnconfigure . $i -weight [expr $i + 1]
    }
    grid propagate . 0
    . configure -width 200 -height 150
    set a ""
    update
    foreach i {0 1 2} {
	lappend a [winfo width .$i]-[winfo height .$i]
    }
    return $a
} -cleanup {
    grid_reset 16.3
} -result {84-63 66-50 50-37}
test grid-16.4 {layout weights (shrinking with minsize)} -body {
    foreach i {0 1 2} {
	frame .$i -bg gray  -width 100 -height 75 -bd 2 -relief ridge
	grid .$i -row $i -column $i -sticky nswe
	grid rowconfigure . $i -weight [expr $i + 1] -minsize 45
	grid columnconfigure . $i -weight [expr $i + 1] -minsize 65
    }
    grid propagate . 0
    . configure -width 200 -height 150
    set a ""
    update
    foreach i {0 1 2} {
	lappend a [winfo width .$i]-[winfo height .$i]
    }
    return $a
} -cleanup {
    grid_reset 16.4
} -result {70-60 65-45 65-45}
test grid-16.5 {layout weights (shrinking at minsize)} -body {
    foreach i {0 1 2} {
	frame .$i -bg gray  -width 100 -height 75 -bd 2 -relief ridge
	grid .$i -row $i -column $i -sticky nswe
	grid rowconfigure . $i -weight 0 -minsize 70
	grid columnconfigure . $i -weight 0 -minsize 90
    }
    grid propagate . 0
    . configure -width 100 -height 75
    set a ""
    update
    foreach i {0 1 2} {
	lappend a [winfo width .$i]-[winfo height .$i]
    }
    return $a
} -cleanup {
    grid_reset 16.5
} -result {100-75 100-75 100-75}
test grid-16.6 {layout weights (shrinking at minsize)} -body {
    foreach i {0 1 2} {
	frame .$i -bg gray  -width 100 -height 75 -bd 2 -relief ridge
	grid .$i -row $i -column $i -sticky nswe
	grid rowconfigure . $i -weight [expr $i + 1] -minsize 52
	grid columnconfigure . $i -weight [expr $i + 1] -minsize 69
    }
    grid propagate . 0
    . configure -width 200 -height 150
    set a ""
    update
    foreach i {0 1 2} {
	lappend a [winfo width .$i]-[winfo height .$i]
    }
    return $a
} -cleanup {
    grid_reset 16.6
} -result {69-52 69-52 69-52}
# test fails when run alone
# reason (I think): -minsize 0 causes both:
# [winfo ismapped .$i] => 0 and
# not responding for width ang height settings, so that
# [winfo width .$i] [winfo height .$i] take different values
# That doesn't happen if previous tests run
test grid-16.7 {layout weights (shrinking at minsize)} -body {
    foreach i {0 1 2} {
	frame .$i -bg gray  -width 100 -height 75 -bd 2 -relief ridge
	grid .$i -row $i -column $i -sticky nswe
    }
    grid propagate . 0
    grid columnconfigure . 1 -weight 1 -minsize 0
    grid rowconfigure . 1 -weight 1 -minsize 0
    . configure -width 100 -height 1
    set a ""
    update
    foreach i {0 1 2} {
	lappend a [winfo width .$i]-[winfo height .$i]-[winfo ismapped .$i]
    }
    return $a
} -cleanup {
    grid_reset 16.7
} -result {100-75-1 1-1-0 100-75-1}
test grid-16.8 {layout internal constraints} -body {
    foreach i {0 1 2 3 4} {
	frame .$i -bg gray  -width 30 -height 25 -bd 2 -relief ridge
	grid .$i -row $i -column $i -sticky nswe
    }
    frame .f -bg red -width 250 -height 200
    frame .g -bg green -width 200 -height 180
    lower .f
    raise .g .f
    grid .f -row 1 -column 1 -rowspan 3 -columnspan 3 -sticky nswe
    grid .g -row 1 -column 1 -rowspan 2 -columnspan 2 -sticky nswe
    update
    set a ""
    foreach i {0 1 2 3 4} {
	append a "[winfo x .$i] "
    }
    append a ", "
    grid remove .f
    update
    foreach i {0 1 2 3 4} {
	append a "[winfo x .$i] "
    }
    append a ", "
    grid remove .g
    grid .f
    update
    foreach i {0 1 2 3 4} {
	append a "[winfo x .$i] "
    }
    append a ", "
    grid remove .f
    update
    foreach i {0 1 2 3 4} {
	append a "[winfo x .$i] "
    }
    return $a
} -cleanup {
    grid_reset 16.8
} -result {0 30 130 230 280 , 0 30 130 230 260 , 0 30 113 196 280 , 0 30 60 90 120 }
test grid-16.9 {layout uniform} -body {
    frame .f1 -width 75 -height 50
    frame .f2 -width 60 -height 25
    frame .f3 -width 95 -height 75
    frame .f4 -width 135 -height 100
    frame .f5 -width 80 -height 40
    for {set t 1} {$t <= 5} {incr t} {
        grid .f$t
    }
    grid rowconfigure . {0 2} -uniform a
    grid rowconfigure . {1 3} -uniform b
    update
    list [grid bbox . 0 0] [grid bbox . 0 1] [grid bbox . 0 2] \
            [grid bbox . 0 3] [grid bbox . 0 4]
} -cleanup {
    grid_reset 16.9
} -result {{0 0 135 75} {0 75 135 100} {0 175 135 75} {0 250 135 100} {0 350 135 40}}
test grid-16.10 {layout uniform} -body {
    grid [frame .f1 -width  75 -height  50] -row 0 -column 0
    grid [frame .f2 -width  60 -height  30] -row 1 -column 2
    grid [frame .f3 -width  95 -height  90] -row 2 -column 1
    grid [frame .f4 -width  60 -height 100] -row 3 -column 4
    grid [frame .f5 -width  60 -height  40] -row 4 -column 3
    grid rowconfigure . {0 1} -uniform a
    grid rowconfigure . {2 4} -uniform b
    grid rowconfigure . {0 2} -weight 2
    grid columnconfigure . {0 2} -uniform a
    grid columnconfigure . {3 4} -uniform b
    grid columnconfigure . {2 4} -weight 2
    grid columnconfigure . 3 -minsize 70
    grid columnconfigure . 4 -minsize 130
    update
    list [grid bbox . 0 0] [grid bbox . 2 1] [grid bbox . 1 2] \
            [grid bbox . 4 3] [grid bbox . 3 4]
} -cleanup {
    grid_reset 16.10
} -result {{0 0 75 60} {170 60 150 30} {75 90 95 90} {390 180 140 100} {320 280 70 45}}
test grid-16.11 {layout uniform (shrink)} -body {
    frame .f1 -width 75 -height 50
    frame .f2 -width 100 -height 95
    grid .f1 .f2 -sticky news
    grid columnconfigure . {0 1} -uniform a
    grid columnconfigure . 0 -weight 1
    update
    set res {}
    lappend res [grid bbox . 0 0] [grid bbox . 1 0]
    grid propagate . 0
    . configure -width 150 -height 95
    update
    lappend res [grid bbox . 0 0] [grid bbox . 1 0]
} -cleanup {
    grid_reset 16.11
} -result {{0 0 100 95} {100 0 100 95} {0 0 50 95} {50 0 100 95}}
test grid-16.12 {layout uniform (grow)} -body {
    frame .f1 -width 40 -height 50
    frame .f2 -width 50 -height 95
    frame .f3 -width 60 -height 50
    frame .f4 -width 70 -height 95
    grid .f1 .f2 .f3 .f4 -sticky news
    grid columnconfigure . {0 1 2} -uniform a
    # Put weight 2 on the biggest in the group to see that the groups
    # adapt to one of the smaller.
    grid columnconfigure . 2 -weight 2
    grid columnconfigure . {0 3} -weight 1
    update
    set res {}
    lappend res [grid bbox . 0 0] [grid bbox . 1 0]
    lappend res [grid bbox . 2 0] [grid bbox . 3 0]
    grid propagate . 0
    . configure -width 350 -height 95
    update
    lappend res [grid bbox . 0 0] [grid bbox . 1 0]
    lappend res [grid bbox . 2 0] [grid bbox . 3 0]
} -cleanup {
    grid_reset 16.12
} -result [list {0 0 50 95} {50 0 50 95} {100 0 100 95} {200 0 70 95} \
        {0 0 70 95} {70 0 50 95} {120 0 140 95} {260 0 90 95}]
test grid-16.13 {layout span} -body {
    frame .f1 -width 24 -height 20
    frame .f2 -width 38 -height 20
    frame .f3 -width 150 -height 20
    grid .f1 - - .f2
    grid .f3 - - -
    set res {}
    foreach w {{0 1 0 0} {0 0 1 0} {1 3 4 0} {1 2 1 2} {1 1 1 12}} {
        for {set c 0} {$c < 4} {incr c} {
            grid columnconfigure . $c -weight [lindex $w $c]
        }
        update
        set res2 {}
        for {set c 0} {$c <= 4} {incr c} {
            lappend res2 [lindex [grid bbox . $c 0] 2]
        }
        lappend res $res2
    }
    return $res
    # The last result below should ideally be 8 8 8 126 but the current
    # implementation is not exact enough.
} -cleanup {
    grid_reset 16.13
} -result [list [list 0 112 0 38 0] [list 0 0 112 38 0] [list 14 42 56 38 0] \
           [list 18 38 18 76 0] [list 7 8 9 126 0]]
test grid-16.14 {layout span} -body {
    frame .f1 -width 110 -height 20
    frame .f2 -width 38 -height 20
    frame .f3 -width 150 -height 20
    grid .f1 - - .f2
    grid .f3 - - -
    set res {}
    foreach w {{0 1 0 0} {0 0 1 0} {1 3 4 0} {1 2 1 3} {1 1 1 12}} {
        for {set c 0} {$c < 4} {incr c} {
            grid columnconfigure . $c -weight [lindex $w $c]
        }
        update
        set res2 {}
        for {set c 0} {$c <= 4} {incr c} {
            lappend res2 [lindex [grid bbox . $c 0] 2]
        }
        lappend res $res2
    }
    return $res
} -cleanup {
    grid_reset 16.14
} -result [list [list 0 112 0 38 0] [list 0 0 112 38 0] [list 14 42 56 38 0] \
           [list 27 55 28 40 0] [list 36 37 37 40 0]]
test grid-16.15 {layout span} -body {
    frame .f1 -width 24 -height 20
    frame .f2 -width 38 -height 20
    frame .f3 -width 150 -height 20
    grid .f1 - - .f2
    grid x .f3 - -
    set res {}
    foreach w {{0 1 0 0} {0 0 1 0} {1 0 1 0} {0 0 0 0} {1 0 0 6}} {
        for {set c 0} {$c < 4} {incr c} {
            grid columnconfigure . $c -weight [lindex $w $c]
        }
        update
        set res2 {}
        for {set c 0} {$c <= 4} {incr c} {
            lappend res2 [lindex [grid bbox . $c 0] 2]
        }
        lappend res $res2
    }
    return $res
} -cleanup {
    grid_reset 16.15
} -result [list [list 0 112 0 38 0] [list 0 0 112 38 0] [list 0 0 112 38 0] \
           [list 0 37 37 76 0] [list 0 12 12 126 0]]
test grid-16.16 {layout span} -body {
    frame .f1 -width 64 -height 20
    frame .f2 -width 38 -height 20
    frame .f3 -width 150 -height 20
    frame .f4 -width 15 -height 20
    frame .f5 -width 18 -height 20
    frame .f6 -width 20 -height 20
    grid .f1 - x .f2
    grid .f3 - - -
    grid .f4 .f5 .f6
    set res {}
    foreach w {{1 1 5 1} {0 0 1 0} {1 3 4 0} {1 2 1 2} {1 1 1 12}} {
        for {set c 0} {$c < 4} {incr c} {
            grid columnconfigure . $c -weight [lindex $w $c]
        }
        update
        set res2 {}
        for {set c 0} {$c <= 4} {incr c} {
            lappend res2 [lindex [grid bbox . $c 0] 2]
        }
        lappend res $res2
    }
    return $res
} -cleanup {
    grid_reset 16.16
} -result [list [list 30 34 43 43 0] [list 30 34 48 38 0] [list 22 42 48 38 0] \
           [list 25 39 29 57 0] [list 30 34 22 64 0]]
test grid-16.17 {layout weights (shrinking at minsize)} -body {
    foreach i {0 1 2 3} {
	frame .$i -bg gray  -width 100 -height 75 -bd 2 -relief ridge
	grid .$i -row $i -column $i -sticky nswe
    }
    grid propagate . 0
    grid columnconfigure . {0 1} -weight 1 -minsize 0
    grid rowconfigure . {0 1} -weight 1 -minsize 0
    set a ""
    . configure -width 250 -height 200
    update
    foreach i {0 1 2 3} {
	lappend a [winfo width .$i]-[winfo height .$i]-[winfo ismapped .$i]
    }
    . configure -width 150 -height 100
    update
    foreach i {0 1 2 3} {
	lappend a [winfo width .$i]-[winfo height .$i]-[winfo ismapped .$i]
    }
    return $a
} -cleanup {
    grid_reset 16.17
} -result {25-25-1 25-25-1 100-75-1 100-75-1 25-25-0 25-25-0 100-75-1 100-75-1}
test grid-16.18 {layout span} -body {
    frame .f1 -width 30  -height 20
    frame .f2 -width 166 -height 20
    frame .f3 -width 39  -height 20
    frame .f4 -width 10  -height 20
    grid .f1 .f3 -
    grid .f2 -   .f4
    grid columnconfigure . 0 -weight 1
    set res {}
    foreach w {{1 0 0} {0 1 0} {0 0 1}} {
        for {set c 0} {$c < 3} {incr c} {
            grid columnconfigure . $c -weight [lindex $w $c]
        }
        update
        set res2 {}
        for {set c 0} {$c <= 2} {incr c} {
            lappend res2 [lindex [grid bbox . $c 0] 2]
        }
        lappend res $res2
    }
    return $res
} -cleanup {
    grid_reset 16.18
} -result [list [list 137 29 10] [list 30 136 10] [list 98 68 10]]
test grid-16.19 {layout span} -constraints { knownBug } -body {
    # This test shows the problem in Bug 2075285
    # Several overlapping multi-span widgets is a weak spot
    # in the current implementation.
    # Test present as a reminder in case a future algorithm update is made.
    frame .f1 -width 100 -height 20
    frame .f2 -width 20  -height 20
    frame .f3 -width 10  -height 20
    frame .f4 -width 20  -height 20
    grid .f1 - -   - -   - -sticky we
    grid .f2 - .f3 - .f4 - -sticky we
    grid columnconfigure . {1 5} -weight 1
    set res {}
    update
    for {set c 0} {$c <= 5} {incr c} {
        lappend res [lindex [grid bbox . $c 0] 2]
    }
    return $res
} -cleanup {
    grid_reset 16.19
} -result [list 0 45 5 5 0 45]

test grid-17.1 {forget and pending idle handlers} -body {
    # This test is intended to detect a crash caused by a failure to remove
    # pending idle handlers when grid forget is invoked.
    toplevel .t
    wm geometry .t +0+0
    frame .t.f
    label .t.f.l -text foobar
    grid .t.f.l
    grid .t.f
    update
    grid forget .t.f.l
    grid forget .t.f
    destroy .t
    toplevel .t
    frame .t.f
    label .t.f.l -text foobar
    grid .t.f.l
    destroy .t
    set result ok
} -result ok

test grid-18.1 {test respect for internalborder} -body {
    toplevel .pack
    wm geometry .pack 200x200
    frame .pack.l -width 15 -height 10
    labelframe .pack.lf -labelwidget .pack.l
    pack .pack.lf -fill both -expand 1
    frame .pack.lf.f
    grid .pack.lf.f -sticky news
    grid columnconfigure .pack.lf 0 -weight 1
    grid rowconfigure .pack.lf 0 -weight 1
    update
    set res [list [winfo geometry .pack.lf.f]]
    .pack.lf configure -labelanchor e -padx 3 -pady 5
    update
    lappend res [winfo geometry .pack.lf.f]
    destroy .pack
    return $res
} -result {196x188+2+10 177x186+5+7}
test grid-18.2 {test support for minreqsize} -body {
    toplevel .pack
    wm geometry .pack {}
    frame .pack.l -width 150 -height 100
    labelframe .pack.lf -labelwidget .pack.l
    pack .pack.lf -fill both -expand 1
    frame .pack.lf.f -width 20 -height 25
    grid .pack.lf.f
    update
    set res [list [winfo geometry .pack.lf]]
    .pack.lf configure -labelanchor ws
    update
    lappend res [winfo geometry .pack.lf]
    destroy .pack
    return $res
} -result {162x127+0+0 172x112+0+0}

test grid-19.1 {uniform realloc} -body {
    # Use a lot of uniform groups to test the reallocation mechanism
    for {set t 0} {$t < 100} {incr t 2} {
        frame .fa$t -width 5 -height 20
        frame .fb$t -width 6 -height 20
        grid .fa$t .fb$t -row 0 -column $t -sticky news
        grid columnconfigure . [list $t [expr {$t + 1}]] -uniform a$t
    }
    update
    grid bbox .
} -cleanup {
    grid_reset 19.1
} -result {0 0 600 20}

test grid-20.1 {recalculate size after removal (destroy)} -body {
    label .l1 -text l1
    grid .l1 -row 2 -column 2
    destroy .l1
    label .l2 -text l2
    grid .l2
    grid size .
} -cleanup {
    grid_reset 20.1
} -result {1 1}
test grid-20.2 {recalculate size after removal (forget)} -body {
    label .l1 -text l1
    grid .l1 -row 2 -column 2
    grid forget .l1
    label .l2 -text l2
    grid .l2
    grid size .
} -cleanup {
    grid_reset 20.2
} -result {1 1}

test grid-21.1 {anchor} -body {
    grid anchor . 1 xxx
} -cleanup {
    grid_reset 21.1
} -returnCodes error -result {wrong # args: should be "grid anchor window ?anchor?"}
test grid-21.2 {anchor} -body {
    grid anchor .
} -cleanup {
    grid_reset 21.2
} -result {nw}
test grid-21.3 {anchor} -body {
    grid anchor . se;grid anchor .
} -cleanup {
    grid_reset 21.3
} -result {se}
test grid-21.4 {anchor} -body {
    grid anchor .x
} -cleanup {
    grid_reset 21.4
} -returnCodes error -result {bad window path name ".x"}
test grid-21.5 {anchor} -body {
    grid anchor . x
} -cleanup {
    grid_reset 21.5
} -returnCodes error -result {bad anchor "x": must be n, ne, e, se, s, sw, w, nw, or center}
test grid-21.6 {anchor} -body {
    foreach i {0 1 2} {
	frame .$i -bg gray  -width 75 -height 50 -bd 2 -relief ridge
	grid .$i -row $i -column $i -sticky nswe
    }
    grid propagate . 0
    . configure -width 300 -height 250
    set res {}
    foreach a {n ne e se s sw w nw center} {
        grid anchor . $a
        update
        lappend res [grid bbox .]
    }
    return $res
} -cleanup {
    grid_reset 21.6
} -result [list {37 0 225 150} {75 0 225 150} {75 50 225 150} {75 100 225 150} \
           {37 100 225 150} {0 100 225 150} {0 50 225 150} {0 0 225 150} \
           {37 50 225 150}]
test grid-21.7 {anchor} -body {
    # Test with a non-symmetric internal border.
    # This only tests vertically, there is currently no way to get
    # it assymetric horizontally.
    labelframe .f -bd 0
    frame .f.x -width 20 -height 20
    .f configure -labelwidget .f.x
    pack .f -fill both -expand 1
    foreach i {0 1 2} {
	frame .$i -bg gray  -width 75 -height 50 -bd 2 -relief ridge
	grid .$i -in .f -row $i -column $i -sticky nswe
    }
    pack propagate . 0
    grid propagate .f 0
    . configure -width 300 -height 250
    set res {}
    foreach a {n ne e se s sw w nw center} {
        grid anchor .f $a
        update
        lappend res [grid bbox .f]
    }
    pack propagate . 1 ; wm geometry . {}
    return $res
} -cleanup {
    grid_reset 21.7
} -result [list {37 20 225 150} {75 20 225 150} {75 60 225 150} {75 100 225 150} \
           {37 100 225 150} {0 100 225 150} {0 60 225 150} {0 20 225 150} \
           {37 60 225 150}]

test grid-22.1 {remove: basic argument checking} {
    list [catch {grid remove foo} msg] $msg
} {1 {bad window path name "foo"}}
test grid-22.2 {remove} {
    button .c
    grid [button .b]
    set a [grid content .]
    grid remove .b .c
    lappend a [grid content .]
    return $a
} {.b {}}
grid_reset 22.2
test grid-22.3 {remove} {
    button .c
    grid .c -row 2 -column 2 -rowspan 2 -columnspan 2 -padx 3 -pady 4 -sticky ns
    grid remove .c
    grid .c -row 0 -column 0
    grid info .c
} {-in . -column 0 -row 0 -columnspan 2 -rowspan 2 -ipadx 0 -ipady 0 -padx 3 -pady 4 -sticky ns}
grid_reset 22.3
test grid-22.3.1 {remove} {
    frame .a
    button .c
    grid .c -in .a -row 2 -column 2 -rowspan 2 -columnspan 2 -padx {3 5} -pady {4 7} -sticky ns
    grid remove .c
    grid .c -row 0 -column 0
    grid info .c
} {-in .a -column 0 -row 0 -columnspan 2 -rowspan 2 -ipadx 0 -ipady 0 -padx {3 5} -pady {4 7} -sticky ns}
grid_reset 22.3.1
test grid-22.4 {remove, calling Tk_UnmaintainGeometry} {
    frame .f -bd 2 -relief raised
    place .f -x 10 -y 20 -width 200 -height 100
    frame .f2 -width 50 -height 30 -bg red
    grid .f2 -in .f
    update
    set x [winfo ismapped .f2]
    grid remove .f2
    place .f -x 30
    update
    lappend x [winfo ismapped .f2]
} {1 0}
grid_reset 22.4
test grid-22.5 {remove} {
    frame .a
    button .c
    grid .c -in .a -row 2 -column 2 -rowspan 2 -columnspan 2 -padx {3 5} -pady {4 7} -sticky ns
    grid remove .c
    # If .a was destroyed while remembered by the removed .c, make sure it
    # is ignored.
    destroy .a
    grid .c -row 0 -column 0
    grid info .c
} {-in . -column 0 -row 0 -columnspan 2 -rowspan 2 -ipadx 0 -ipady 0 -padx {3 5} -pady {4 7} -sticky ns}
grid_reset 22.5

test grid-23 {grid configure -in leaked from previous container window - bug
              6aea69fccbb266b7f0437686379fbe5b55442958} {
    frame .f
    frame .g
    pack .f .g
    text .t
    grid .t -in .f
    pack forget .f
    update
    grid .t -in .g
    # .t is now managed by .g; following lines must have no effect on .t
    pack .f
    update
    pack forget .f
    update
    winfo ismapped .t ; # must return 1
} 1
grid_reset 23

test grid-24.1 {<<NoManagedChild>> fires on last grid forget} -setup {
    global A
    unset -nocomplain A
} -body {
    grid [frame .1]
    update
    bind . <<NoManagedChild>> {set A 1}
    grid forget .1
    update
    info exists A
} -cleanup {
    bind . <<NoManagedChild>> {}
    grid_reset 24.1
} -result 1
test grid-24.2 {<<NoManagedChild>> fires on last grid remove} -setup {
    global A
    unset -nocomplain A
} -body {
    grid [frame .1]
    update
    bind . <<NoManagedChild>> {set A 1}
    grid remove .1
    update
    info exists A
} -cleanup {
    bind . <<NoManagedChild>> {}
    grid_reset 24.2
} -result 1
test grid-24.3 {<<NoManagedChild>> fires on last gridded child destruction} -setup {
    global A
    unset -nocomplain A
} -body {
    grid [frame .1]
    update
    bind . <<NoManagedChild>> {incr A}
    destroy .1
    update
    set A
} -cleanup {
    bind . <<NoManagedChild>> {}
    grid_reset 24.3
} -result 1
test grid-24.4 {<Configure> does not fire on last grid forget} -setup {
    global A
    unset -nocomplain A
} -body {
    grid [frame .1]
    update
    bind . <Configure> {set A 1}
    grid forget .1
    update
    info exists A
} -cleanup {
    bind . <Configure> {}
    grid_reset 24.4
} -result 0
test grid-24.5 {<Configure> fires on forelast grid forget} -setup {
    global A
    unset -nocomplain A
} -body {
    grid [frame .1]
    grid [frame .2]
    update
    bind . <Configure> {set A 1}
    grid forget .1
    update
    info exists A
} -cleanup {
    bind . <Configure> {}
    grid_reset 24.5
} -result 1
test grid-24.6 {<<NoManagedChild>> does not fire on forelast grid forget} -setup {
    global A
    unset -nocomplain A
} -body {
    grid [frame .1]
    grid [frame .2]
    update
    bind . <<NoManagedChild>> {set A 1}
    grid forget .1
    update
    info exists A
} -cleanup {
    bind . <<NoManagedChild>> {}
    grid_reset 24.6
} -result 0
test grid-24.7 {<<NoManagedChild>> does not fire on grid anchor} -setup {
    global A
    unset -nocomplain A
} -body {
    bind . <<NoManagedChild>> {set A 1}
    grid anchor . w
    update
    info exists A
} -cleanup {
    grid anchor . nw
    bind . <<NoManagedChild>> {}
    grid_reset 24.7
} -result 0
test grid-24.8 {<<NoManagedChild>> does not fire on last grid forget if propagation is off} -setup {
    global A
    unset -nocomplain A
} -body {
    grid [frame .1]
    grid propagate . 0
    update
    bind . <<NoManagedChild>> {set A 1}
    grid forget .1
    update
    info exists A
} -cleanup {
    bind . <<NoManagedChild>> {}
    grid_reset 24.8
} -result 0

# cleanup
cleanupTests
return

# Local Variables:
# mode: tcl
# End: