aboutsummaryrefslogtreecommitdiffstats
path: root/eclipse/plugins/com.android.ide.eclipse.tests
diff options
context:
space:
mode:
authorTor Norbye <tnorbye@google.com>2011-06-10 13:41:51 -0700
committerTor Norbye <tnorbye@google.com>2011-06-10 13:41:51 -0700
commit8f21dc3e82c298e727b8813e10896e55f82406f9 (patch)
tree07ec8efd97986a62cb7bdaca3eaa5c1d0fde4c97 /eclipse/plugins/com.android.ide.eclipse.tests
parentb051619189b4c0be377ea080a3f1d188d3f8c073 (diff)
downloadsdk-8f21dc3e82c298e727b8813e10896e55f82406f9.zip
sdk-8f21dc3e82c298e727b8813e10896e55f82406f9.tar.gz
sdk-8f21dc3e82c298e727b8813e10896e55f82406f9.tar.bz2
Workaround view info cookie bug
This changeset works around the case where a ViewInfo cookie is identical to its parent. This is for example the case for a ZoomControls widget, where the child views have MergeCookies whole value points to the parent ZoomControl. Change-Id: Ie0eb62750fba6eeaa7241edce68e05f853e08a75
Diffstat (limited to 'eclipse/plugins/com.android.ide.eclipse.tests')
-rw-r--r--eclipse/plugins/com.android.ide.eclipse.tests/unittests/com/android/ide/eclipse/adt/internal/editors/layout/gle2/CanvasViewInfoTest.java28
1 files changed, 28 insertions, 0 deletions
diff --git a/eclipse/plugins/com.android.ide.eclipse.tests/unittests/com/android/ide/eclipse/adt/internal/editors/layout/gle2/CanvasViewInfoTest.java b/eclipse/plugins/com.android.ide.eclipse.tests/unittests/com/android/ide/eclipse/adt/internal/editors/layout/gle2/CanvasViewInfoTest.java
index 2df472e..bca7cae 100644
--- a/eclipse/plugins/com.android.ide.eclipse.tests/unittests/com/android/ide/eclipse/adt/internal/editors/layout/gle2/CanvasViewInfoTest.java
+++ b/eclipse/plugins/com.android.ide.eclipse.tests/unittests/com/android/ide/eclipse/adt/internal/editors/layout/gle2/CanvasViewInfoTest.java
@@ -623,6 +623,34 @@ public class CanvasViewInfoTest extends TestCase {
assertEquals(new Rectangle(0, 40, 49, 19), bounds2);
}
+ public void testCookieWorkaround() throws Exception {
+ UiViewElementNode rootNode = createNode("android.widget.LinearLayout", true);
+ ViewInfo root = new ViewInfo("included", null, 0, 0, 100, 100);
+
+ UiViewElementNode node2 = createNode(rootNode, "childNode2", false);
+ MergeCookie mergeCookie = new MergeCookie(root);
+
+ ViewInfo childView1 = new ViewInfo("childView1", mergeCookie, 0, 20, 50, 40);
+ ViewInfo childView2 = new ViewInfo("childView2", node2, 0, 40, 50, 60);
+
+ root.setChildren(Arrays.asList(childView1, childView2));
+
+ Pair<CanvasViewInfo, List<Rectangle>> result = CanvasViewInfo.create(root, true);
+ CanvasViewInfo rootView = result.getFirst();
+ List<Rectangle> bounds = result.getSecond();
+ assertNotNull(rootView);
+
+ assertEquals("included", rootView.getName());
+ assertNull(rootView.getParent());
+ assertNull(rootView.getUiViewNode());
+ // childView1 should have been removed since it has the wrong merge cookie
+ assertEquals(1, rootView.getChildren().size());
+ assertEquals(1, rootView.getUniqueChildren().size());
+
+ Rectangle bounds1 = bounds.get(0);
+ assertEquals(new Rectangle(0, 40, 49, 19), bounds1);
+ }
+
public void testGestureOverlayView() throws Exception {
boolean layoutlib5 = true;