diff options
author | Treehugger Robot <treehugger-gerrit@google.com> | 2020-05-08 18:46:56 +0000 |
---|---|---|
committer | Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com> | 2020-05-08 18:46:56 +0000 |
commit | 7532f1a99bc17a82ae8b6714025facb3095c08b1 (patch) | |
tree | c4efb96abd28c58f6dc220fdcc8ee8ab69f7ca38 /eclipse/plugins/com.android.ide.eclipse.tests/unittests/com/android/ide/eclipse/adt/internal/editors/layout/ExplodeRenderingHelperTest.java | |
parent | c6f9015f6bf1b59f46d6bb87f5e48cbab3cb94de (diff) | |
parent | 46a5c62c6763f054fce88ab6737983014de66226 (diff) | |
download | sdk-7532f1a99bc17a82ae8b6714025facb3095c08b1.tar.gz |
Merge "Remove all non-Apache2 licensed files from sdk" am: 106d12a4f8 am: 7cb6fc634a am: ccad5384d7 am: 18c1c14ad4 am: 46a5c62c67
Change-Id: Ib5a1e041abdbd5696d1b4467fa1581ae5d9c344c
Diffstat (limited to 'eclipse/plugins/com.android.ide.eclipse.tests/unittests/com/android/ide/eclipse/adt/internal/editors/layout/ExplodeRenderingHelperTest.java')
-rw-r--r-- | eclipse/plugins/com.android.ide.eclipse.tests/unittests/com/android/ide/eclipse/adt/internal/editors/layout/ExplodeRenderingHelperTest.java | 256 |
1 files changed, 0 insertions, 256 deletions
diff --git a/eclipse/plugins/com.android.ide.eclipse.tests/unittests/com/android/ide/eclipse/adt/internal/editors/layout/ExplodeRenderingHelperTest.java b/eclipse/plugins/com.android.ide.eclipse.tests/unittests/com/android/ide/eclipse/adt/internal/editors/layout/ExplodeRenderingHelperTest.java deleted file mode 100644 index 0e528674a..000000000 --- a/eclipse/plugins/com.android.ide.eclipse.tests/unittests/com/android/ide/eclipse/adt/internal/editors/layout/ExplodeRenderingHelperTest.java +++ /dev/null @@ -1,256 +0,0 @@ -/* - * Copyright (C) 2010 The Android Open Source Project - * - * Licensed under the Eclipse Public License, Version 1.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.eclipse.org/org/documents/epl-v10.php - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.android.ide.eclipse.adt.internal.editors.layout; - -import com.android.SdkConstants; -import com.android.ide.eclipse.adt.internal.editors.mock.MockXmlNode; - -import org.w3c.dom.Node; - -import java.util.HashSet; - -import junit.framework.TestCase; - -public class ExplodeRenderingHelperTest extends TestCase { - - private final HashSet<String> mLayoutNames = new HashSet<String>(); - - @Override - protected void setUp() throws Exception { - super.setUp(); - - mLayoutNames.add("LinearLayout"); - mLayoutNames.add("RelativeLayout"); - } - - public void testSingleHorizontalLinearLayout() { - // Single layout, horizontal, 2 buttons. - MockXmlNode layout = createLinearLayout(true /*horizontal*/, - new MockXmlNode[] { createButton(), createButton()} ); - - ExplodedRenderingHelper helper = new ExplodedRenderingHelper(layout, mLayoutNames); - assertEquals(1, helper.getHeightPadding()); - assertEquals(1, helper.getWidthPadding()); - } - - public void testSingleVerticalLinearLayout() { - // Single layout, horizontal, with 2 buttons. - // LinearLayout(H:[Button Button]) - MockXmlNode layout = createLinearLayout(false /*horizontal*/, - new MockXmlNode[] { createButton(), createButton()} ); - - ExplodedRenderingHelper helper = new ExplodedRenderingHelper(layout, mLayoutNames); - assertEquals(1, helper.getWidthPadding()); - assertEquals(1, helper.getHeightPadding()); - } - - public void testEmbeddedLinearLayouts() { - /* - * LinearLayout(vertical): - * LinearLayout(H:[Button Button]) - * LinearLayout(H:[Button Button Button]) - * - * Result should be 2 in x, 3 in y - */ - MockXmlNode layout = createLinearLayout(false /*horizontal*/, - new MockXmlNode[] { - createLinearLayout(true /*horizontal*/, - new MockXmlNode[] { createButton(), createButton()}), - createLinearLayout(true /*horizontal*/, - new MockXmlNode[] { createButton(), createButton(), createButton()}), - } ); - - ExplodedRenderingHelper helper = new ExplodedRenderingHelper(layout, mLayoutNames); - assertEquals(2, helper.getWidthPadding()); - assertEquals(3, helper.getHeightPadding()); - } - - public void testSimpleRelativeLayoutWithOneLinearLayouts() { - /* - * RelativeLayout: - * LinearLayout(H:[Button Button]) - * - * Result should be 2 in x, 2 in y - */ - MockXmlNode layout = createRelativeLayout( - new MockXmlNode[] { - createLinearLayout(true /*horizontal*/, - new MockXmlNode[] { createButton(), createButton()}), - } ); - - ExplodedRenderingHelper helper = new ExplodedRenderingHelper(layout, mLayoutNames); - assertEquals(2, helper.getWidthPadding()); - assertEquals(2, helper.getHeightPadding()); - } - - public void /*test*/RelativeLayoutWithVerticalLinearLayouts() { - //FIXME: Reenable once the relative layout are properly supported. - /* - * Children of the relative layouts, one below the other. - * Each with only buttons in them. - * RelativeLayout: - * LinearLayout(H:[Button Button]) - * ^ - * LinearLayout(H:[Button Button]) - * - * Result should be 2 in x, 3 in y - */ - - // create the linearlayouts. - MockXmlNode linear1 = createLinearLayout(true /*horizontal*/, - new MockXmlNode[] { createButton(), createButton()}); - linear1.addAttributes(SdkConstants.NS_RESOURCES, "id", "@+id/linear1"); - - MockXmlNode linear2 = createLinearLayout(true /*horizontal*/, - new MockXmlNode[] { createButton(), createButton()}); - linear2.addAttributes(SdkConstants.NS_RESOURCES, "id", "@+id/linear2"); - - // position linear2 below linear1 - linear2.addAttributes(SdkConstants.NS_RESOURCES, "layout_below", "@+id/linear1"); - - - MockXmlNode layout = createRelativeLayout(new MockXmlNode[] { linear1, linear2 } ); - - ExplodedRenderingHelper helper = new ExplodedRenderingHelper(layout, mLayoutNames); - assertEquals(2, helper.getWidthPadding()); - assertEquals(3, helper.getHeightPadding()); - } - - public void /*test*/RelativeLayoutWithVerticalLinearLayouts2() { - //FIXME: Reenable once the relative layout are properly supported. - /* - * Children of the relative layouts, one above the other. - * Each with only buttons in them. - * RelativeLayout: - * LinearLayout(H:[Button Button]) - * v - * LinearLayout(H:[Button Button]) - * - * Result should be 2 in x, 3 in y - */ - - // create the linearlayouts. - MockXmlNode linear1 = createLinearLayout(true /*horizontal*/, - new MockXmlNode[] { createButton(), createButton() } ); - linear1.addAttributes(SdkConstants.NS_RESOURCES, "id", "@+id/linear1"); - - MockXmlNode linear2 = createLinearLayout(true /*horizontal*/, - new MockXmlNode[] { createButton(), createButton() } ); - linear2.addAttributes(SdkConstants.NS_RESOURCES, "id", "@+id/linear2"); - - // position linear2 below linear1 - linear2.addAttributes(SdkConstants.NS_RESOURCES, "layout_above", "@+id/linear1"); - - - MockXmlNode layout = createRelativeLayout(new MockXmlNode[] { linear1, linear2 } ); - - ExplodedRenderingHelper helper = new ExplodedRenderingHelper(layout, mLayoutNames); - assertEquals(2, helper.getWidthPadding()); - assertEquals(3, helper.getHeightPadding()); - } - - public void /*test*/ComplexRelativeLayout() { - //FIXME: Reenable once the relative layout are properly supported. - /* - * RelativeLayout: - * - * < LinearLayout1(V: [button]) > LinearLayout2(V: [button]) - * v - * Button1 > LinearLayout3(V: [button]) < Button2 - * v - * < LinearLayout4(V: [button]) - * ^ - * <LinearLayout5(V: [button]) - * - * Result should be 4 in x, 5 in y - */ - - // create the elements - MockXmlNode button1 = createButton(); - button1.addAttributes(SdkConstants.NS_RESOURCES, "id", "@+id/button1"); - - MockXmlNode button2 = createButton(); - button2.addAttributes(SdkConstants.NS_RESOURCES, "id", "@+id/button2"); - - MockXmlNode linear1 = createLinearLayout(true /*horizontal*/, - new MockXmlNode[] { createButton() } ); - linear1.addAttributes(SdkConstants.NS_RESOURCES, "id", "@+id/linear1"); - - MockXmlNode linear2 = createLinearLayout(true /*horizontal*/, - new MockXmlNode[] { createButton() } ); - linear2.addAttributes(SdkConstants.NS_RESOURCES, "id", "@+id/linear2"); - - MockXmlNode linear3 = createLinearLayout(true /*horizontal*/, - new MockXmlNode[] { createButton() } ); - linear3.addAttributes(SdkConstants.NS_RESOURCES, "id", "@+id/linear3"); - - MockXmlNode linear4 = createLinearLayout(true /*horizontal*/, - new MockXmlNode[] { createButton() } ); - linear4.addAttributes(SdkConstants.NS_RESOURCES, "id", "@+id/linear4"); - - MockXmlNode linear5 = createLinearLayout(true /*horizontal*/, - new MockXmlNode[] { createButton() } ); - linear5.addAttributes(SdkConstants.NS_RESOURCES, "id", "@+id/linear5"); - - - // link them - button1.addAttributes(SdkConstants.NS_RESOURCES, "layout_toLeftOf", "@+id/linear3"); - - button2.addAttributes(SdkConstants.NS_RESOURCES, "layout_toRightOf", "@+id/linear3"); - - linear1.addAttributes(SdkConstants.NS_RESOURCES, "layout_toRightOf", "@+id/linear3"); - linear1.addAttributes(SdkConstants.NS_RESOURCES, "layout_toLeftOf", "@+id/linear2"); - linear1.addAttributes(SdkConstants.NS_RESOURCES, "layout_above", "@+id/button2"); - - linear3.addAttributes(SdkConstants.NS_RESOURCES, "layout_above", "@+id/linear4"); - - linear4.addAttributes(SdkConstants.NS_RESOURCES, "layout_toRightOf", "@+id/button1"); - - linear5.addAttributes(SdkConstants.NS_RESOURCES, "layout_toRightOf", "@+id/linear4"); - linear5.addAttributes(SdkConstants.NS_RESOURCES, "layout_below", "@+id/linear4"); - - MockXmlNode layout = createRelativeLayout( - new MockXmlNode[] { - button1, button2, linear1, linear2, linear3, linear4, linear5 } ); - - ExplodedRenderingHelper helper = new ExplodedRenderingHelper(layout, mLayoutNames); - assertEquals(4, helper.getWidthPadding()); - assertEquals(5, helper.getHeightPadding()); - } - - - // ----- helper to deal with mocks - - private MockXmlNode createButton() { - return new MockXmlNode(null, "Button", Node.ELEMENT_NODE, null); - } - - private MockXmlNode createLinearLayout(boolean horizontal, MockXmlNode[] children) { - MockXmlNode layout = new MockXmlNode(null, "LinearLayout", Node.ELEMENT_NODE, children); - - layout.addAttributes(SdkConstants.NS_RESOURCES, "orientation", - horizontal ? "horizontal" : "vertical"); - - return layout; - } - - private MockXmlNode createRelativeLayout(MockXmlNode[] children) { - MockXmlNode layout = new MockXmlNode(null, "RelativeLayout", Node.ELEMENT_NODE, children); - - return layout; - } -} |