diff options
author | Tor Norbye <tnorbye@google.com> | 2010-12-09 14:49:13 -0800 |
---|---|---|
committer | Tor Norbye <tnorbye@google.com> | 2010-12-09 14:49:13 -0800 |
commit | fe3eebe57ba2925642cc1b257cb03ba617d298af (patch) | |
tree | 8a348ddd82b7b13754115a3a715fcc6e3990a8d4 /eclipse/plugins/com.android.ide.eclipse.tests/unittests/com/android/ide/common | |
parent | f7bb5e5fe9c3e6cda5f6d2c4a1db4673a2f8f02d (diff) | |
download | sdk-fe3eebe57ba2925642cc1b257cb03ba617d298af.zip sdk-fe3eebe57ba2925642cc1b257cb03ba617d298af.tar.gz sdk-fe3eebe57ba2925642cc1b257cb03ba617d298af.tar.bz2 |
Issue 13051: Use match_parent or fill_parent based on API level
Fixes issue 13051: New layout editor always insert "match_parent",
even on older platform.
View rules can now look up the API level of the current project, and
based on that choose to use match_parent or fill_parent when they need
to manipulate the layout attributes.
Change-Id: I861e1f7f7409c40c05b1472268f120806667025c
Diffstat (limited to 'eclipse/plugins/com.android.ide.eclipse.tests/unittests/com/android/ide/common')
2 files changed, 51 insertions, 1 deletions
diff --git a/eclipse/plugins/com.android.ide.eclipse.tests/unittests/com/android/ide/common/layout/LayoutTestBase.java b/eclipse/plugins/com.android.ide.eclipse.tests/unittests/com/android/ide/common/layout/LayoutTestBase.java index d6161b1..50d71fc 100644 --- a/eclipse/plugins/com.android.ide.eclipse.tests/unittests/com/android/ide/common/layout/LayoutTestBase.java +++ b/eclipse/plugins/com.android.ide.eclipse.tests/unittests/com/android/ide/common/layout/LayoutTestBase.java @@ -20,8 +20,11 @@ import static com.android.ide.common.layout.LayoutConstants.ANDROID_URI; import static com.android.ide.common.layout.LayoutConstants.ATTR_ID; import com.android.ide.common.api.DropFeedback; +import com.android.ide.common.api.IClientRulesEngine; import com.android.ide.common.api.IDragElement; import com.android.ide.common.api.INode; +import com.android.ide.common.api.IValidator; +import com.android.ide.common.api.IViewMetadata; import com.android.ide.common.api.IViewRule; import com.android.ide.common.api.Point; import com.android.ide.common.api.Rect; @@ -178,4 +181,48 @@ public abstract class LayoutTestBase extends TestCase { assertEquals("Collections differ; first difference:", expectedElement, actualElement); } } + + protected void initialize(IViewRule rule, String fqn) { + rule.onInitialize(fqn, new TestRulesEngine(fqn)); + } + + private static class TestRulesEngine implements IClientRulesEngine { + private final String mFqn; + + protected TestRulesEngine(String fqn) { + mFqn = fqn; + } + + public void debugPrintf(String msg, Object... params) { + fail("Not supported in tests yet"); + } + + public void displayAlert(String message) { + fail("Not supported in tests yet"); + } + + public String displayInput(String message, String value, IValidator filter) { + fail("Not supported in tests yet"); + return null; + } + + public String getFqcn() { + return mFqn; + } + + public IViewMetadata getMetadata(String fqcn) { + fail("Not supported in tests yet"); + return null; + } + + public int getMinApiLevel() { + return 8; + } + + public IViewRule loadRule(String fqcn) { + fail("Not supported in tests yet"); + return null; + } + + } } 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 520f984..4f29932 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 @@ -28,9 +28,9 @@ import com.android.ide.common.api.IMenuCallback; import com.android.ide.common.api.INode; import com.android.ide.common.api.IViewRule; import com.android.ide.common.api.MenuAction; -import com.android.ide.common.api.MenuAction.Choices; import com.android.ide.common.api.Point; import com.android.ide.common.api.Rect; +import com.android.ide.common.api.MenuAction.Choices; import java.util.List; @@ -41,6 +41,7 @@ public class LinearLayoutRuleTest extends LayoutTestBase { boolean haveBounds = dragBounds.isValid(); IViewRule rule = new LinearLayoutRule(); + INode targetNode = TestNode.create("android.widget.LinearLayout").id( "@+id/LinearLayout01").bounds(new Rect(0, 0, 240, 480)); Point dropPoint = new Point(10, 5); @@ -118,6 +119,7 @@ public class LinearLayoutRuleTest extends LayoutTestBase { // Check that the context menu registers the expected menu items public void testContextMenu() { LinearLayoutRule rule = new LinearLayoutRule(); + initialize(rule, "android.widget.LinearLayout"); INode node = TestNode.create("android.widget.Button").id("@+id/Button012"); List<MenuAction> contextMenu = rule.getContextMenu(node); @@ -135,6 +137,7 @@ public class LinearLayoutRuleTest extends LayoutTestBase { // Check that the context menu manipulates the orientation attribute public void testOrientation() { LinearLayoutRule rule = new LinearLayoutRule(); + initialize(rule, "android.widget.LinearLayout"); INode node = TestNode.create("android.widget.Button").id("@+id/Button012"); assertNull(node.getStringAttr(ANDROID_URI, ATTR_ORIENTATION)); |