|
| 1 | +/******************************************************************************* |
| 2 | + * Java2Script Pacemaker (http://j2s.sourceforge.net) |
| 3 | + * |
| 4 | + * Copyright (c) 2006 ognize.com and others. |
| 5 | + * All rights reserved. This program and the accompanying materials |
| 6 | + * are made available under the terms of the Eclipse Public License v1.0 |
| 7 | + * which accompanies this distribution, and is available at |
| 8 | + * http://www.eclipse.org/legal/epl-v10.html |
| 9 | + * |
| 10 | + * Contributors: |
| 11 | + * ognize.com - initial API and implementation |
| 12 | + *******************************************************************************/ |
| 13 | + |
| 14 | +package net.sf.j2s.test.swt.ajunit; |
| 15 | + |
| 16 | +import net.sf.j2s.ajax.junit.AsyncSWT; |
| 17 | +import net.sf.j2s.ajax.junit.AsyncTestCase; |
| 18 | +import net.sf.j2s.ajax.junit.AsyncTestRunnable; |
| 19 | +import net.sf.j2s.ajax.junit.AsyncTestRunner; |
| 20 | +import org.eclipse.swt.SWT; |
| 21 | +import org.eclipse.swt.layout.FillLayout; |
| 22 | +import org.eclipse.swt.widgets.Display; |
| 23 | +import org.eclipse.swt.widgets.Shell; |
| 24 | +import org.eclipse.swt.widgets.Tree; |
| 25 | +import org.eclipse.swt.widgets.TreeItem; |
| 26 | + |
| 27 | +/** |
| 28 | + * @author josson smith |
| 29 | + * |
| 30 | + * 2006-8-1 |
| 31 | + */ |
| 32 | +public class TreeStructureTest extends AsyncTestCase { |
| 33 | + |
| 34 | + public void treeStruct(int d1, int d2, int d3, int d4) { |
| 35 | + Display display = new Display (); |
| 36 | + Shell shell = new Shell (display); |
| 37 | + shell.setLayout(new FillLayout()); |
| 38 | + final Tree tree = new Tree (shell, SWT.BORDER | SWT.CHECK); |
| 39 | + tree.setSize (100, 100); |
| 40 | + shell.setSize (300, 200); |
| 41 | + int[] dims = new int[] {d1, d2, d3, d4}; |
| 42 | + for (int i=0; i<dims[0]; i++) { |
| 43 | + TreeItem iItem = new TreeItem (tree, 0); |
| 44 | + iItem.setText ("TreeItem (0) -" + i); |
| 45 | + for (int j=0; j<dims[1]; j++) { |
| 46 | + TreeItem jItem = new TreeItem (iItem, 0); |
| 47 | + jItem.setText ("TreeItem (1) -" + j); |
| 48 | + for (int k=0; k<dims[2]; k++) { |
| 49 | + TreeItem kItem = new TreeItem (jItem, 0); |
| 50 | + kItem.setText ("TreeItem (2) -" + k); |
| 51 | + for (int l=0; l<dims[3]; l++) { |
| 52 | + TreeItem lItem = new TreeItem (kItem, 0); |
| 53 | + lItem.setText ("TreeItem (3) -" + l); |
| 54 | + } |
| 55 | + } |
| 56 | + } |
| 57 | + } |
| 58 | + shell.open (); |
| 59 | + AsyncSWT.waitLayout(shell, new AsyncTestRunnable(this) { |
| 60 | + public void run() { |
| 61 | + } |
| 62 | + }); |
| 63 | + display.dispose (); |
| 64 | + } |
| 65 | + |
| 66 | + public void testStruct29() { |
| 67 | + Display display = new Display (); |
| 68 | + Shell shell = new Shell (display); |
| 69 | + shell.setLayout(new FillLayout()); |
| 70 | + final Tree tree = new Tree (shell, SWT.BORDER | SWT.CHECK); |
| 71 | + tree.setSize (100, 100); |
| 72 | + shell.setSize (300, 200); |
| 73 | + int[] dims = new int[] {2, 1, 2}; |
| 74 | + for (int i=0; i<dims[0]; i++) { |
| 75 | + TreeItem iItem = new TreeItem (tree, 0); |
| 76 | + iItem.setText ("TreeItem (0) -" + i); |
| 77 | + for (int j=0; j<dims[1]; j++) { |
| 78 | + TreeItem jItem = new TreeItem (iItem, 0); |
| 79 | + jItem.setText ("TreeItem (1) -" + j); |
| 80 | + for (int k=0; k<dims[2]; k++) { |
| 81 | + TreeItem kItem = new TreeItem (jItem, 0); |
| 82 | + kItem.setText ("TreeItem (2) -" + k); |
| 83 | + for (int l=0; l<dims[3]; l++) { |
| 84 | + TreeItem lItem = new TreeItem (kItem, 0); |
| 85 | + lItem.setText ("TreeItem (3) -" + l); |
| 86 | + } |
| 87 | + } |
| 88 | + } |
| 89 | + } |
| 90 | + TreeItem iItem = new TreeItem (tree, 0); |
| 91 | + iItem.setText("Last Item"); |
| 92 | + shell.open (); |
| 93 | + AsyncSWT.waitLayout(shell, new AsyncTestRunnable(this) { |
| 94 | + public void run() { |
| 95 | + } |
| 96 | + }); |
| 97 | + display.dispose (); |
| 98 | + } |
| 99 | + |
| 100 | + public void testStruct28() { |
| 101 | + treeStruct(4, 2, 4, 2); |
| 102 | + } |
| 103 | + public void testStruct27() { |
| 104 | + treeStruct(4, 2, 2, 2); |
| 105 | + } |
| 106 | + public void testStruct26() { |
| 107 | + treeStruct(4, 1, 2, 2); |
| 108 | + } |
| 109 | + public void testStruct25() { |
| 110 | + treeStruct(4, 5, 1, 2); |
| 111 | + } |
| 112 | + public void testStruct24() { |
| 113 | + treeStruct(4, 2, 1, 2); |
| 114 | + } |
| 115 | + public void testStruct23() { |
| 116 | + treeStruct(4, 1, 1, 5); |
| 117 | + } |
| 118 | + public void testStruct22() { |
| 119 | + treeStruct(1, 1, 1, 5); |
| 120 | + } |
| 121 | + public void testStruct21() { |
| 122 | + treeStruct(1, 1, 1, 2); |
| 123 | + } |
| 124 | + public void testStruct20() { |
| 125 | + /** |
| 126 | + * @j2sNative |
| 127 | + * window["defaultWindowLeft"] = 100; |
| 128 | + * window["defaultWindowTop"] = 100; |
| 129 | + */ {} |
| 130 | + treeStruct(1, 1, 1, 1); |
| 131 | + } |
| 132 | + public void testStruct19() { |
| 133 | + treeStruct(5, 1, 6, 0); |
| 134 | + } |
| 135 | + public void testStruct18() { |
| 136 | + treeStruct(2, 1, 2, 0); |
| 137 | + } |
| 138 | + public void testStruct17() { |
| 139 | + treeStruct(5, 1, 1, 0); |
| 140 | + } |
| 141 | + public void testStruct16() { |
| 142 | + treeStruct(2, 1, 1, 0); |
| 143 | + } |
| 144 | + public void testStruct15() { |
| 145 | + treeStruct(1, 1, 12, 0); |
| 146 | + } |
| 147 | + public void testStruct14() { |
| 148 | + treeStruct(1, 1, 2, 0); |
| 149 | + } |
| 150 | + public void testStruct13() { |
| 151 | + treeStruct(1, 1, 1, 0); |
| 152 | + } |
| 153 | + public void testStruct12() { |
| 154 | + treeStruct(4, 3, 0, 0); |
| 155 | + } |
| 156 | + public void testStruct11() { |
| 157 | + treeStruct(2, 3, 0, 0); |
| 158 | + } |
| 159 | + public void testStruct10() { |
| 160 | + /** |
| 161 | + * @j2sNative |
| 162 | + * window["defaultWindowLeft"] = 100; |
| 163 | + * window["defaultWindowTop"] = 100; |
| 164 | + */ {} |
| 165 | + treeStruct(2, 2, 0, 0); |
| 166 | + } |
| 167 | + public void testStruct9() { |
| 168 | + treeStruct(13, 1, 0, 0); |
| 169 | + } |
| 170 | + public void testStruct8() { |
| 171 | + treeStruct(3, 1, 0, 0); |
| 172 | + } |
| 173 | + public void testStruct7() { |
| 174 | + treeStruct(2, 1, 0, 0); |
| 175 | + } |
| 176 | + public void testStruct6() { |
| 177 | + treeStruct(1, 12, 0, 0); |
| 178 | + } |
| 179 | + public void testStruct5() { |
| 180 | + treeStruct(1, 2, 0, 0); |
| 181 | + } |
| 182 | + public void testStruct4() { |
| 183 | + treeStruct(1, 1, 0, 0); |
| 184 | + } |
| 185 | + public void testStruct3() { |
| 186 | + treeStruct(12, 0, 0, 0); |
| 187 | + } |
| 188 | + public void testStruct2() { |
| 189 | + treeStruct(2, 0, 0, 0); |
| 190 | + } |
| 191 | + public void testStruct1() { |
| 192 | + treeStruct(1, 0, 0, 0); |
| 193 | + } |
| 194 | + |
| 195 | + public static void main(String[] args) { |
| 196 | + AsyncSWT.setShellAutoClose(false); |
| 197 | + AsyncTestRunner.asyncRun (TreeStructureTest.class); |
| 198 | + } |
| 199 | +} |
0 commit comments