Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
View | Details | Raw Unified | Return to bug 317849 | Differences between
and this patch

Collapse All | Expand All

(-)src/org/eclipse/e4/ui/tests/workbench/MPartSashContainerTest.java (-15 lines)
Lines 23-30 Link Here
23
import org.eclipse.e4.ui.model.application.ui.basic.MPartSashContainer;
23
import org.eclipse.e4.ui.model.application.ui.basic.MPartSashContainer;
24
import org.eclipse.e4.ui.model.application.ui.basic.MWindow;
24
import org.eclipse.e4.ui.model.application.ui.basic.MWindow;
25
import org.eclipse.e4.ui.model.application.ui.basic.impl.BasicFactoryImpl;
25
import org.eclipse.e4.ui.model.application.ui.basic.impl.BasicFactoryImpl;
26
import org.eclipse.swt.SWT;
27
import org.eclipse.swt.custom.SashForm;
28
26
29
public class MPartSashContainerTest extends TestCase {
27
public class MPartSashContainerTest extends TestCase {
30
	protected IEclipseContext appContext;
28
	protected IEclipseContext appContext;
Lines 75-92 Link Here
75
73
76
		Object widget = partSashContainer.getWidget();
74
		Object widget = partSashContainer.getWidget();
77
		assertNotNull(widget);
75
		assertNotNull(widget);
78
		assertTrue(widget instanceof SashForm);
79
80
		SashForm sashForm = (SashForm) widget;
81
		assertEquals(SWT.HORIZONTAL, sashForm.getOrientation());
82
83
		partSashContainer.setHorizontal(false);
84
		assertEquals(SWT.VERTICAL, sashForm.getOrientation());
85
86
		partSashContainer.setHorizontal(true);
87
		assertEquals(SWT.HORIZONTAL, sashForm.getOrientation());
88
89
		partSashContainer.setHorizontal(true);
90
		assertEquals(SWT.HORIZONTAL, sashForm.getOrientation());
91
	}
76
	}
92
}
77
}
(-)src/org/eclipse/e4/ui/tests/workbench/MSashTest.java (-46 lines)
Lines 23-30 Link Here
23
import org.eclipse.e4.ui.model.application.ui.basic.MPartSashContainer;
23
import org.eclipse.e4.ui.model.application.ui.basic.MPartSashContainer;
24
import org.eclipse.e4.ui.model.application.ui.basic.MWindow;
24
import org.eclipse.e4.ui.model.application.ui.basic.MWindow;
25
import org.eclipse.e4.ui.model.application.ui.basic.impl.BasicFactoryImpl;
25
import org.eclipse.e4.ui.model.application.ui.basic.impl.BasicFactoryImpl;
26
import org.eclipse.swt.custom.SashForm;
27
import org.eclipse.swt.widgets.Composite;
28
import org.eclipse.swt.widgets.Shell;
26
import org.eclipse.swt.widgets.Shell;
29
import org.eclipse.swt.widgets.Widget;
27
import org.eclipse.swt.widgets.Widget;
30
28
Lines 122-171 Link Here
122
		assertTrue("Part1 data is not an integer", cdVal1 != -1);
120
		assertTrue("Part1 data is not an integer", cdVal1 != -1);
123
121
124
		assertTrue("Values should be equal", cdVal0 == cdVal1);
122
		assertTrue("Values should be equal", cdVal0 == cdVal1);
125
126
		testWeights(sash, 50, 50);
127
	}
128
129
	private void testWeights(MPartSashContainer sf, double w1, double w2) {
130
		double baseRatio = w1 / w2;
131
132
		MPart part0 = (MPart) sf.getChildren().get(0);
133
		MPart part1 = (MPart) sf.getChildren().get(1);
134
135
		int cdVal0 = -1;
136
		try {
137
			cdVal0 = Integer.parseInt(part0.getContainerData());
138
		} catch (NumberFormatException e) {
139
		}
140
		assertTrue("Part0 data is not an integer", cdVal0 != -1);
141
142
		int cdVal1 = -1;
143
		try {
144
			cdVal1 = Integer.parseInt(part1.getContainerData());
145
		} catch (NumberFormatException e) {
146
		}
147
		assertTrue("Part1 data is not an integer", cdVal1 != -1);
148
149
		// test the model
150
		checkRatio("MSashForm", cdVal0, cdVal1, baseRatio);
151
152
		// test the SashForm
153
		SashForm sfw = (SashForm) sf.getWidget();
154
		int[] sfwWghts = sfw.getWeights();
155
		checkRatio("SWT SashForm", sfwWghts[0], sfwWghts[1], baseRatio);
156
157
		// Test the controls (assume vertical for now)
158
		Composite c1 = (Composite) sfw.getChildren()[0];
159
		Composite c2 = (Composite) sfw.getChildren()[1];
160
		checkRatio("Control Bounds", c1.getSize().y, c2.getSize().y, baseRatio);
161
	}
162
163
	private void checkRatio(String label, int num, int div, double baseRatio) {
164
		double ratio = (double) num / (double) div;
165
166
		double TOLERANCE = 0.1;
167
		boolean withinTolerance = Math.abs(ratio - baseRatio) < TOLERANCE;
168
		assertTrue("Ratio mismatch on" + label + "weights", withinTolerance);
169
	}
123
	}
170
124
171
	private MWindow createSashWithNViews(int n) {
125
	private MWindow createSashWithNViews(int n) {

Return to bug 317849