summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorJohannes Dahlström <johannes.dahlstrom@vaadin.com>2011-11-24 10:44:54 +0000
committerJohannes Dahlström <johannes.dahlstrom@vaadin.com>2011-11-24 10:44:54 +0000
commit1c6a751a5a1315b74b3e5adac337058e803e9d1f (patch)
treef397da1e7e075e5dfea40c8a126c0362f9caba2b /tests
parent9d6099ffc787dbc2e95b74d0ad5741b231246c74 (diff)
downloadvaadin-framework-1c6a751a5a1315b74b3e5adac337058e803e9d1f.tar.gz
vaadin-framework-1c6a751a5a1315b74b3e5adac337058e803e9d1f.zip
Enhanced tests and fix for #7668 - re-adding a component at an index before its current one does nothing
Simplified the logic in AbstractOrderedLayout/CssLayout#addComponent*() - super.addComponent() is now called first so that the invariant that there's never duplicate elements in the component list always holds, this fixes #7668. addComponent(c, index) now has a piece of additional logic handling the case when a component is moved to an index *after* its current one. svn changeset:22117/svn branch:6.7
Diffstat (limited to 'tests')
-rw-r--r--tests/server-side/com/vaadin/tests/server/component/abstractorderedlayout/AddComponentsTest.java24
-rw-r--r--tests/server-side/com/vaadin/tests/server/component/csslayout/AddComponentsTest.java24
2 files changed, 48 insertions, 0 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 3df4d5ff5d..cfbace2a1a 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
@@ -40,6 +40,14 @@ public class AddComponentsTest {
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
@@ -72,6 +80,22 @@ public class AddComponentsTest {
// 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 });
+
+ // 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 });
+
+ // Keep everything in place
+ layout.addComponentAsFirst(children[2]);
+ assertOrder(layout, new int[] { 2, 3, 1, 0 });
}
/**
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 6e69dfe915..73c977694b 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
@@ -39,6 +39,14 @@ public class AddComponentsTest {
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
@@ -67,6 +75,22 @@ public class AddComponentsTest {
// 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 });
+
+ // 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 });
+
+ // Keep everything in place
+ layout.addComponentAsFirst(children[2]);
+ assertOrder(layout, new int[] { 2, 3, 1, 0 });
}
/**