diff options
author | Tor Norbye <tnorbye@google.com> | 2010-12-16 13:17:04 -0800 |
---|---|---|
committer | Tor Norbye <tnorbye@google.com> | 2010-12-16 13:45:34 -0800 |
commit | a58666867fccd0dba3cad5d02f055e49a21f1901 (patch) | |
tree | 0bcbf77fdc02586fd17ed44a7336178691d04377 /eclipse/plugins/com.android.ide.eclipse.tests/unittests/com/android/ide/common/layout | |
parent | b629a5b1a40bde693613f74265ca4fd22f35e89a (diff) | |
download | sdk-a58666867fccd0dba3cad5d02f055e49a21f1901.zip sdk-a58666867fccd0dba3cad5d02f055e49a21f1901.tar.gz sdk-a58666867fccd0dba3cad5d02f055e49a21f1901.tar.bz2 |
Improve handling of custom width/height layout attributes
Remove the "Custom..." items from the menus (which were not hooked up
anyway).
If there is a custom value (e.g. not fill_parent, match_parent or
wrap_content), add it into the menu directly (such as "42dip"), and
show it as selected.
In addition, always add a "Other..." menu item at the end. Invoking
Other will pop up a dialog asking you to enter a new custom value,
which is then applied.
This addresses issue #2 in multi-issue bug
13134: Eclipse layout editor contains many bugs
Change-Id: Ic1a84a789c53dd3a15b807a29461b80dc1b49c9f
Diffstat (limited to 'eclipse/plugins/com.android.ide.eclipse.tests/unittests/com/android/ide/common/layout')
-rw-r--r-- | eclipse/plugins/com.android.ide.eclipse.tests/unittests/com/android/ide/common/layout/LinearLayoutRuleTest.java | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/eclipse/plugins/com.android.ide.eclipse.tests/unittests/com/android/ide/common/layout/LinearLayoutRuleTest.java b/eclipse/plugins/com.android.ide.eclipse.tests/unittests/com/android/ide/common/layout/LinearLayoutRuleTest.java index 4f29932..e3e805e 100644 --- a/eclipse/plugins/com.android.ide.eclipse.tests/unittests/com/android/ide/common/layout/LinearLayoutRuleTest.java +++ b/eclipse/plugins/com.android.ide.eclipse.tests/unittests/com/android/ide/common/layout/LinearLayoutRuleTest.java @@ -18,6 +18,8 @@ package com.android.ide.common.layout; import static com.android.ide.common.layout.LayoutConstants.ANDROID_URI; import static com.android.ide.common.layout.LayoutConstants.ATTR_ID; +import static com.android.ide.common.layout.LayoutConstants.ATTR_LAYOUT_HEIGHT; +import static com.android.ide.common.layout.LayoutConstants.ATTR_LAYOUT_WIDTH; import static com.android.ide.common.layout.LayoutConstants.ATTR_ORIENTATION; import static com.android.ide.common.layout.LayoutConstants.VALUE_HORIZONTAL; import static com.android.ide.common.layout.LayoutConstants.VALUE_VERTICAL; @@ -33,6 +35,7 @@ import com.android.ide.common.api.Rect; import com.android.ide.common.api.MenuAction.Choices; import java.util.List; +import java.util.Map; /** Test the {@link LinearLayoutRule} */ public class LinearLayoutRuleTest extends LayoutTestBase { @@ -134,6 +137,27 @@ public class LinearLayoutRuleTest extends LayoutTestBase { // TODO: Test Properties-list } + public void testContextMenuCustom() { + LinearLayoutRule rule = new LinearLayoutRule(); + initialize(rule, "android.widget.LinearLayout"); + INode node = TestNode.create("android.widget.Button").id("@+id/Button012") + .set(ANDROID_URI, ATTR_LAYOUT_WIDTH, "42dip") + .set(ANDROID_URI, ATTR_LAYOUT_HEIGHT, "50sp"); + + List<MenuAction> contextMenu = rule.getContextMenu(node); + assertEquals(4, contextMenu.size()); + assertEquals("Layout Width", contextMenu.get(0).getTitle()); + MenuAction menuAction = contextMenu.get(0); + assertTrue(menuAction instanceof MenuAction.Choices); + MenuAction.Choices choices = (Choices) menuAction; + Map<String, String> items = choices.getChoices(); + assertTrue(items.containsKey("42dip")); + assertTrue(items.containsValue("42dip")); + assertEquals("Other...", items.get("zcustom")); + assertEquals("Match Parent", items.get("match_parent")); + assertEquals("42dip", choices.getCurrent()); + } + // Check that the context menu manipulates the orientation attribute public void testOrientation() { LinearLayoutRule rule = new LinearLayoutRule(); |