01: package org.uispec4j;
02:
03: import junit.framework.Assert;
04: import org.uispec4j.utils.Utils;
05:
06: import java.awt.Component;
07: import java.util.Arrays;
08: import java.util.List;
09:
10: public class TestUtils {
11: public static void assertUIComponentRefersTo(
12: Component expectedComponent, UIComponent uiComponent) {
13: Assert.assertSame(expectedComponent, uiComponent
14: .getAwtComponent());
15: }
16:
17: public static void assertUIComponentsReferTo(
18: Component[] expectedComponents, UIComponent[] uiComponents) {
19: int expectedLength = expectedComponents.length;
20: int actualLength = uiComponents.length;
21: Assert.assertEquals("Expected " + expectedLength
22: + " components but was " + actualLength,
23: expectedLength, actualLength);
24:
25: List list = Arrays.asList(expectedComponents);
26: for (int i = 0; i < uiComponents.length; i++) {
27: Assert.assertTrue("unexpected component ", list
28: .contains(uiComponents[i].getAwtComponent()));
29: }
30: }
31:
32: public static void assertSwingComponentsEquals(Object[] expected,
33: Object[] actual) {
34: Utils.assertSetEquals(expected, actual,
35: SwingComponentStringifier.instance());
36: }
37: }
|