diff options
author | Johannes Dahlström <johannes.dahlstrom@vaadin.com> | 2011-11-29 12:12:54 +0000 |
---|---|---|
committer | Johannes Dahlström <johannes.dahlstrom@vaadin.com> | 2011-11-29 12:12:54 +0000 |
commit | 0dfc558113f59775b6d32d5c49b760e058d4e6c8 (patch) | |
tree | 302d2f660ed69d6718b8485192e9b759dbbe90b2 /tests | |
parent | ad47ed7b537acad4a4fa8d1aa68538667bce50bb (diff) | |
download | vaadin-framework-0dfc558113f59775b6d32d5c49b760e058d4e6c8.tar.gz vaadin-framework-0dfc558113f59775b6d32d5c49b760e058d4e6c8.zip |
#7668 - Formatted code to adhere to Vaadin coding conventions
svn changeset:22171/svn branch:6.7
Diffstat (limited to 'tests')
2 files changed, 48 insertions, 51 deletions
diff --git a/tests/server-side/com/vaadin/tests/server/component/abstractorderedlayout/AddComponentsTest.java b/tests/server-side/com/vaadin/tests/server/component/abstractorderedlayout/AddComponentsTest.java index cfbace2a1a..ba5ea62181 100644 --- a/tests/server-side/com/vaadin/tests/server/component/abstractorderedlayout/AddComponentsTest.java +++ b/tests/server-side/com/vaadin/tests/server/component/abstractorderedlayout/AddComponentsTest.java @@ -1,86 +1,85 @@ package com.vaadin.tests.server.component.abstractorderedlayout;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertSame;
+import static org.junit.Assert.fail;
+
import java.util.Iterator;
import java.util.NoSuchElementException;
import org.junit.Test;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertSame;
-import static org.junit.Assert.fail;
-
-import com.vaadin.ui.Component;
import com.vaadin.ui.AbstractOrderedLayout;
+import com.vaadin.ui.Component;
import com.vaadin.ui.HorizontalLayout;
+import com.vaadin.ui.Label;
import com.vaadin.ui.Layout;
import com.vaadin.ui.VerticalLayout;
-import com.vaadin.ui.Label;
public class AddComponentsTest {
- Component[] children = new Component[] {
- new Label("A"), new Label("B"),
+ Component[] children = new Component[] { new Label("A"), new Label("B"),
new Label("C"), new Label("D") };
-
+
@Test
public void moveComponentsBetweenLayouts() {
AbstractOrderedLayout layout1 = new HorizontalLayout();
AbstractOrderedLayout layout2 = new VerticalLayout();
-
+
layout1.addComponent(children[0]);
layout1.addComponent(children[1]);
-
+
layout2.addComponent(children[2]);
layout2.addComponent(children[3]);
-
+
layout2.addComponent(children[1], 1);
assertOrder(layout1, new int[] { 0 });
assertOrder(layout2, new int[] { 2, 1, 3 });
-
+
layout1.addComponent(children[3], 0);
assertOrder(layout1, new int[] { 3, 0 });
assertOrder(layout2, new int[] { 2, 1 });
-
+
layout2.addComponent(children[0]);
assertOrder(layout1, new int[] { 3 });
assertOrder(layout2, new int[] { 2, 1, 0 });
-
+
layout1.addComponentAsFirst(children[1]);
assertOrder(layout1, new int[] { 1, 3 });
assertOrder(layout2, new int[] { 2, 0 });
}
-
+
@Test
public void shuffleChildComponents() {
shuffleChildComponents(new HorizontalLayout());
shuffleChildComponents(new VerticalLayout());
}
-
+
private void shuffleChildComponents(AbstractOrderedLayout layout) {
-
+
for (int i = 0; i < children.length; ++i) {
layout.addComponent(children[i], i);
}
-
+
assertOrder(layout, new int[] { 0, 1, 2, 3 });
// Move C from #2 to #1
// Exhibits defect #7668
layout.addComponent(children[2], 1);
assertOrder(layout, new int[] { 0, 2, 1, 3 });
-
+
// Move C from #1 to #4 (which becomes #3 when #1 is erased)
layout.addComponent(children[2], 4);
assertOrder(layout, new int[] { 0, 1, 3, 2 });
-
+
// Keep everything in place
layout.addComponent(children[1], 1);
assertOrder(layout, new int[] { 0, 1, 3, 2 });
-
+
// Move D from #2 to #0
layout.addComponent(children[3], 0);
assertOrder(layout, new int[] { 3, 0, 1, 2 });
-
+
// Move A from #1 to end (#4 which becomes #3)
layout.addComponent(children[0]);
assertOrder(layout, new int[] { 3, 1, 2, 0 });
@@ -88,7 +87,7 @@ public class AddComponentsTest { // Keep everything in place
layout.addComponent(children[0]);
assertOrder(layout, new int[] { 3, 1, 2, 0 });
-
+
// Move C from #2 to #0
layout.addComponentAsFirst(children[2]);
assertOrder(layout, new int[] { 2, 3, 1, 0 });
@@ -99,17 +98,17 @@ public class AddComponentsTest { }
/**
- * Asserts that layout has the components in children
- * in the order specified by indices.
+ * Asserts that layout has the components in children in the order specified
+ * by indices.
*/
private void assertOrder(Layout layout, int[] indices) {
Iterator<?> i = layout.getComponentIterator();
try {
- for(int index : indices) {
+ for (int index : indices) {
assertSame(children[index], i.next());
}
assertFalse("Too many components in layout", i.hasNext());
- } catch(NoSuchElementException e) {
+ } catch (NoSuchElementException e) {
fail("Too few components in layout");
}
}
diff --git a/tests/server-side/com/vaadin/tests/server/component/csslayout/AddComponentsTest.java b/tests/server-side/com/vaadin/tests/server/component/csslayout/AddComponentsTest.java index 73c977694b..29657830e8 100644 --- a/tests/server-side/com/vaadin/tests/server/component/csslayout/AddComponentsTest.java +++ b/tests/server-side/com/vaadin/tests/server/component/csslayout/AddComponentsTest.java @@ -9,7 +9,6 @@ import static org.junit.Assert.assertSame; import static org.junit.Assert.assertFalse;
import static org.junit.Assert.fail;
-
import com.vaadin.ui.Component;
import com.vaadin.ui.CssLayout;
import com.vaadin.ui.Label;
@@ -17,65 +16,64 @@ import com.vaadin.ui.Layout; public class AddComponentsTest {
- private Component[] children = new Component[] {
- new Label("A"), new Label("B"),
- new Label("C"), new Label("D") };
-
+ private Component[] children = new Component[] { new Label("A"),
+ new Label("B"), new Label("C"), new Label("D") };
+
@Test
public void moveComponentsBetweenLayouts() {
CssLayout layout1 = new CssLayout();
CssLayout layout2 = new CssLayout();
-
+
layout1.addComponent(children[0]);
layout1.addComponent(children[1]);
-
+
layout2.addComponent(children[2]);
layout2.addComponent(children[3]);
-
+
layout2.addComponent(children[1], 1);
assertOrder(layout1, new int[] { 0 });
assertOrder(layout2, new int[] { 2, 1, 3 });
-
+
layout1.addComponent(children[3], 0);
assertOrder(layout1, new int[] { 3, 0 });
assertOrder(layout2, new int[] { 2, 1 });
-
+
layout2.addComponent(children[0]);
assertOrder(layout1, new int[] { 3 });
assertOrder(layout2, new int[] { 2, 1, 0 });
-
+
layout1.addComponentAsFirst(children[1]);
assertOrder(layout1, new int[] { 1, 3 });
assertOrder(layout2, new int[] { 2, 0 });
}
-
+
@Test
public void shuffleChildComponents() {
CssLayout layout = new CssLayout();
-
+
for (int i = 0; i < children.length; ++i) {
layout.addComponent(children[i], i);
}
-
+
assertOrder(layout, new int[] { 0, 1, 2, 3 });
// Move C from #2 to #1
// Exhibits defect #7668
layout.addComponent(children[2], 1);
assertOrder(layout, new int[] { 0, 2, 1, 3 });
-
+
// Move C from #1 to #4 (which becomes #3 when #1 is erased)
layout.addComponent(children[2], 4);
assertOrder(layout, new int[] { 0, 1, 3, 2 });
-
+
// Keep everything in place
layout.addComponent(children[1], 1);
assertOrder(layout, new int[] { 0, 1, 3, 2 });
-
+
// Move D from #2 to #0
layout.addComponent(children[3], 0);
assertOrder(layout, new int[] { 3, 0, 1, 2 });
-
+
// Move A from #1 to end (#4 which becomes #3)
layout.addComponent(children[0]);
assertOrder(layout, new int[] { 3, 1, 2, 0 });
@@ -83,7 +81,7 @@ public class AddComponentsTest { // Keep everything in place
layout.addComponent(children[0]);
assertOrder(layout, new int[] { 3, 1, 2, 0 });
-
+
// Move C from #2 to #0
layout.addComponentAsFirst(children[2]);
assertOrder(layout, new int[] { 2, 3, 1, 0 });
@@ -94,17 +92,17 @@ public class AddComponentsTest { }
/**
- * Asserts that layout has the components in children
- * in the order specified by indices.
+ * Asserts that layout has the components in children in the order specified
+ * by indices.
*/
private void assertOrder(Layout layout, int[] indices) {
Iterator<?> i = layout.getComponentIterator();
try {
- for(int index : indices) {
+ for (int index : indices) {
assertSame(children[index], i.next());
}
assertFalse("Too many components in layout", i.hasNext());
- } catch(NoSuchElementException e) {
+ } catch (NoSuchElementException e) {
fail("Too few components in layout");
}
}
|