|
2 | 2 |
|
3 | 3 | import com.codename1.junit.FormTest; |
4 | 4 | import com.codename1.junit.UITestBase; |
| 5 | +import com.codename1.ui.CN; |
5 | 6 | import com.codename1.ui.Component; |
| 7 | +import com.codename1.ui.Form; |
| 8 | +import com.codename1.ui.Label; |
6 | 9 | import com.codename1.ui.TextArea; |
7 | 10 |
|
8 | 11 | import java.util.Comparator; |
9 | | -import java.util.Date; |
10 | 12 | import java.lang.reflect.Method; |
11 | 13 |
|
12 | 14 | import static org.junit.jupiter.api.Assertions.*; |
@@ -89,4 +91,29 @@ private Component findHeaderButton(Table table) { |
89 | 91 | // Row 0 is header if includeHeader is true (default). |
90 | 92 | return tl.getComponentAt(0, 0); |
91 | 93 | } |
| 94 | + |
| 95 | + /** |
| 96 | + * Test for a size regression bug in table layout discussed here: https://www.reddit.com/r/cn1/comments/1q6pmek/android_screen_out_of_ranges/ |
| 97 | + */ |
| 98 | + @FormTest |
| 99 | + void testTableLayoutDefaultSizing() { |
| 100 | + Form f = CN.getCurrentForm(); |
| 101 | + TableLayout tl = new TableLayout(3, 2); |
| 102 | + f.setLayout(tl); |
| 103 | + f.setScrollable(false); |
| 104 | + f.getContentPane().getAllStyles().setPadding(0, 0, 0, 0); |
| 105 | + for(int iter = 0 ; iter < 6 ; iter++) { |
| 106 | + Label l = new Label("T: " + iter); |
| 107 | + l.getAllStyles().setMargin(0, 0, 0, 0); |
| 108 | + f.addComponent(tl.createConstraint() |
| 109 | + .hp(33) |
| 110 | + .wp(50), l); |
| 111 | + } |
| 112 | + f.revalidate(); |
| 113 | + |
| 114 | + for(Component cmp : f.getContentPane()) { |
| 115 | + assertTrue(cmp.getHeight() >= f.getContentPane().getHeight() / 100 * 32, "Height should be close to 33 percent"); |
| 116 | + assertTrue(cmp.getWidth() >= f.getContentPane().getWidth() / 2 - 1, "Width should be 50%"); |
| 117 | + } |
| 118 | + } |
92 | 119 | } |
0 commit comments