aboutsummaryrefslogtreecommitdiff
path: root/eclipse/plugins/com.android.ide.eclipse.tests/unittests/com/android/ide/eclipse/adt/internal/editors/layout/gre
diff options
context:
space:
mode:
Diffstat (limited to 'eclipse/plugins/com.android.ide.eclipse.tests/unittests/com/android/ide/eclipse/adt/internal/editors/layout/gre')
-rwxr-xr-xeclipse/plugins/com.android.ide.eclipse.tests/unittests/com/android/ide/eclipse/adt/internal/editors/layout/gre/MockNodeProxy.java68
-rwxr-xr-xeclipse/plugins/com.android.ide.eclipse.tests/unittests/com/android/ide/eclipse/adt/internal/editors/layout/gre/NodeFactoryTest.java123
-rwxr-xr-xeclipse/plugins/com.android.ide.eclipse.tests/unittests/com/android/ide/eclipse/adt/internal/editors/layout/gre/RulesEngineTest.java37
-rw-r--r--eclipse/plugins/com.android.ide.eclipse.tests/unittests/com/android/ide/eclipse/adt/internal/editors/layout/gre/ViewMetadataRepositoryTest.java77
4 files changed, 0 insertions, 305 deletions
diff --git a/eclipse/plugins/com.android.ide.eclipse.tests/unittests/com/android/ide/eclipse/adt/internal/editors/layout/gre/MockNodeProxy.java b/eclipse/plugins/com.android.ide.eclipse.tests/unittests/com/android/ide/eclipse/adt/internal/editors/layout/gre/MockNodeProxy.java
deleted file mode 100755
index 433d3903d..000000000
--- a/eclipse/plugins/com.android.ide.eclipse.tests/unittests/com/android/ide/eclipse/adt/internal/editors/layout/gre/MockNodeProxy.java
+++ /dev/null
@@ -1,68 +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.gre;
-
-import com.android.ide.eclipse.adt.internal.editors.layout.descriptors.ViewElementDescriptor;
-import com.android.ide.eclipse.adt.internal.editors.layout.uimodel.UiViewElementNode;
-
-import org.eclipse.swt.graphics.Rectangle;
-import org.eclipse.ui.internal.registry.ViewDescriptor;
-
-/**
- * Mocks a {@link NodeProxy}, creating it using an XML local name and generating
- * a made-up {@link UiViewElementNode} and a {@link ViewDescriptor} on the fly.
- */
-public class MockNodeProxy extends NodeProxy {
-
- /**
- * Generates a {@link NodeProxy} using an FQCN (e.g. android.view.View)
- * and making the last segment of the FQCN the XML name of the view (e.g. "View")
- * and wraps it as a {@link NodeProxy}.
- *
- * @param fqcn The fully qualified name of the class to wrap, e.g. "android.view.Button".
- * @param bounds The bounds of a the view in the canvas. Must be either: <br/>
- * - a valid rect for a view that is actually in the canvas <br/>
- * - <b>*or*</b> null (or an invalid rect) for a view that has just been added dynamically
- * to the model. We never store a null bounds rectangle in the node, a null rectangle
- * will be converted to an invalid rectangle.
- * @param factory A {@link NodeFactory} to create unique children nodes.
- */
- public MockNodeProxy(String fqcn, Rectangle bounds, NodeFactory factory) {
- super(makeUiViewNode(fqcn), bounds, factory);
- }
-
- /**
- * Generates a {@link ViewElementDescriptor} using an FQCN (e.g. android.view.View)
- * and making the last segment of the FQCN the XML name of the view (e.g. "View").
- *
- * @param fqcn The fully qualified name of the class to wrap, e.g. "android.view.Button"
- * @return A new view element node with a new descriptor for the FQCN and an XML name
- * matching the last FQCN segment (e.g. "Button")
- */
- private static UiViewElementNode makeUiViewNode(String fqcn) {
- String xmlName = fqcn;
- int pos = xmlName.lastIndexOf('.');
- if (pos > 0) {
- xmlName = xmlName.substring(pos + 1);
- }
-
- ViewElementDescriptor desc = new ViewElementDescriptor(xmlName, fqcn);
- UiViewElementNode uiNode = new UiViewElementNode(desc);
- return uiNode;
- }
-
-}
diff --git a/eclipse/plugins/com.android.ide.eclipse.tests/unittests/com/android/ide/eclipse/adt/internal/editors/layout/gre/NodeFactoryTest.java b/eclipse/plugins/com.android.ide.eclipse.tests/unittests/com/android/ide/eclipse/adt/internal/editors/layout/gre/NodeFactoryTest.java
deleted file mode 100755
index 0e6d33db3..000000000
--- a/eclipse/plugins/com.android.ide.eclipse.tests/unittests/com/android/ide/eclipse/adt/internal/editors/layout/gre/NodeFactoryTest.java
+++ /dev/null
@@ -1,123 +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.gre;
-
-import com.android.ide.common.api.INode;
-import com.android.ide.common.api.Rect;
-import com.android.ide.common.rendering.api.ViewInfo;
-import com.android.ide.eclipse.adt.internal.editors.layout.descriptors.ViewElementDescriptor;
-import com.android.ide.eclipse.adt.internal.editors.layout.gle2.CanvasViewInfo;
-import com.android.ide.eclipse.adt.internal.editors.layout.uimodel.UiViewElementNode;
-
-import java.util.Arrays;
-
-import junit.framework.TestCase;
-
-public class NodeFactoryTest extends TestCase {
-
- private NodeFactory m;
-
- @Override
- protected void setUp() throws Exception {
- super.setUp();
- m = new NodeFactory(null);
-
- }
-
- @Override
- protected void tearDown() throws Exception {
- super.tearDown();
- m = null;
- }
-
- public final void testCreateCanvasViewInfo() {
- ViewElementDescriptor ved = new ViewElementDescriptor("xml", "com.example.MyJavaClass");
- UiViewElementNode uiv = new UiViewElementNode(ved);
- ViewInfo lvi = new ViewInfo("name", uiv, 10, 12, 110, 120);
- CanvasViewInfo cvi = CanvasViewInfo.create(lvi, true /* layoutlib5 */).getFirst();
-
- // Create a NodeProxy.
- NodeProxy proxy = m.create(cvi);
-
- // getNode() is our only internal implementation method.
- assertNotNull(proxy);
- assertSame(uiv, proxy.getNode());
-
- // Groovy scripts only see the INode interface so we want to primarily test that.
- INode inode = proxy;
- assertEquals(new Rect(10, 12, 110-10-1, 120-12-1), inode.getBounds());
- assertTrue(Arrays.equals(new INode[0], inode.getChildren()));
- assertEquals("com.example.MyJavaClass", inode.getFqcn());
- assertNull(inode.getParent());
- assertSame(inode, inode.getRoot());
-
- }
-
- public final void testCreateUiViewElementNode() {
- ViewElementDescriptor ved = new ViewElementDescriptor("xml", "com.example.MyJavaClass");
- UiViewElementNode uiv = new UiViewElementNode(ved);
-
- // Create a NodeProxy.
- NodeProxy proxy = m.create(uiv);
-
- // getNode() is our only internal implementation method.
- assertNotNull(proxy);
- assertSame(uiv, proxy.getNode());
-
- // Groovy scripts only see the INode interface so we want to primarily test that.
- INode inode = proxy;
- // Nodes constructed using this create() method do not have valid bounds.
- // There should be one invalid bound rectangle.
- assertNotNull(inode.getBounds());
- assertFalse(inode.getBounds().isValid());
- // All the other properties should be set correctly.
- assertTrue(Arrays.equals(new INode[0], inode.getChildren()));
- assertEquals("com.example.MyJavaClass", inode.getFqcn());
- assertNull(inode.getParent());
- assertSame(inode, inode.getRoot());
- }
-
- public final void testCreateDup() {
- ViewElementDescriptor ved = new ViewElementDescriptor("xml", "com.example.MyJavaClass");
- UiViewElementNode uiv = new UiViewElementNode(ved);
- ViewInfo lvi = new ViewInfo("name", uiv, 10, 12, 110, 120);
- CanvasViewInfo cvi = CanvasViewInfo.create(lvi, true /* layoutlib5 */).getFirst();
-
- // NodeProxies are cached. Creating the same one twice returns the same proxy.
- NodeProxy proxy1 = m.create(cvi);
- NodeProxy proxy2 = m.create(cvi);
- assertSame(proxy2, proxy1);
- }
-
- public final void testClear() {
- ViewElementDescriptor ved = new ViewElementDescriptor("xml", "com.example.MyJavaClass");
- UiViewElementNode uiv = new UiViewElementNode(ved);
- ViewInfo lvi = new ViewInfo("name", uiv, 10, 12, 110, 120);
- CanvasViewInfo cvi = CanvasViewInfo.create(lvi, true /* layoutlib5 */).getFirst();
-
- // NodeProxies are cached. Creating the same one twice returns the same proxy.
- NodeProxy proxy1 = m.create(cvi);
- NodeProxy proxy2 = m.create(cvi);
- assertSame(proxy2, proxy1);
-
- // Clearing the cache will force it create a new proxy.
- m.clear();
- NodeProxy proxy3 = m.create(cvi);
- assertNotSame(proxy1, proxy3);
- }
-
-}
diff --git a/eclipse/plugins/com.android.ide.eclipse.tests/unittests/com/android/ide/eclipse/adt/internal/editors/layout/gre/RulesEngineTest.java b/eclipse/plugins/com.android.ide.eclipse.tests/unittests/com/android/ide/eclipse/adt/internal/editors/layout/gre/RulesEngineTest.java
deleted file mode 100755
index d9a1a3dc1..000000000
--- a/eclipse/plugins/com.android.ide.eclipse.tests/unittests/com/android/ide/eclipse/adt/internal/editors/layout/gre/RulesEngineTest.java
+++ /dev/null
@@ -1,37 +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.gre;
-
-import junit.framework.TestCase;
-
-public class RulesEngineTest extends TestCase {
-
- @Override
- protected void setUp() throws Exception {
- super.setUp();
- }
-
- @Override
- protected void tearDown() throws Exception {
- super.tearDown();
- }
-
- public void testDummy() {
- // Here to avoid warning that RulesEngineTest is empty
- }
-
-}
diff --git a/eclipse/plugins/com.android.ide.eclipse.tests/unittests/com/android/ide/eclipse/adt/internal/editors/layout/gre/ViewMetadataRepositoryTest.java b/eclipse/plugins/com.android.ide.eclipse.tests/unittests/com/android/ide/eclipse/adt/internal/editors/layout/gre/ViewMetadataRepositoryTest.java
deleted file mode 100644
index 50d438cdb..000000000
--- a/eclipse/plugins/com.android.ide.eclipse.tests/unittests/com/android/ide/eclipse/adt/internal/editors/layout/gre/ViewMetadataRepositoryTest.java
+++ /dev/null
@@ -1,77 +0,0 @@
-/*
- * Copyright (C) 2011 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.gre;
-
-import com.android.ide.common.api.IViewMetadata.FillPreference;
-import com.android.ide.eclipse.adt.internal.editors.layout.gre.ViewMetadataRepository.RenderMode;
-
-import java.util.Arrays;
-
-import junit.framework.TestCase;
-
-public class ViewMetadataRepositoryTest extends TestCase {
- public void testSingleton() throws Exception {
- assertSame(ViewMetadataRepository.get(), ViewMetadataRepository.get());
- }
-
- public void testBasic() throws Exception {
- ViewMetadataRepository repository = ViewMetadataRepository.get();
-
- assertEquals(FillPreference.WIDTH_IN_VERTICAL,
- repository.getFillPreference("android.widget.Spinner"));
- assertEquals(FillPreference.NONE,
- repository.getFillPreference("foo.bar"));
- }
-
- // Ensure that all basenames referenced in the metadata refer to other views in the file
- // (e.g. no typos)
- public void testRelatedTo() throws Exception {
- // Make sure unit tests are run with assertions on
- boolean assertionsEnabled = false;
- assert assertionsEnabled = true; // Intentional assignment
- assertTrue("This unit test must be run with assertions enabled (-ea)", assertionsEnabled);
-
- ViewMetadataRepository repository = ViewMetadataRepository.get();
- for (String fqcn : repository.getAllFqcns()) {
- repository.getRelatedTo(fqcn);
- }
- }
-
- public void testSkip() throws Exception {
- ViewMetadataRepository repository = ViewMetadataRepository.get();
- assertTrue(repository.getSkip("merge"));
- assertFalse(repository.getSkip("android.widget.Button"));
- }
-
- public void testRenderMode() throws Exception {
- ViewMetadataRepository repository = ViewMetadataRepository.get();
- assertEquals(RenderMode.NORMAL, repository.getRenderMode("android.widget.Button"));
- assertEquals(RenderMode.SKIP, repository.getRenderMode("android.widget.LinearLayout"));
- assertEquals(RenderMode.ALONE, repository.getRenderMode("android.widget.TabHost"));
- }
-
- public void testGetTopAttributes() throws Exception {
- ViewMetadataRepository repository = ViewMetadataRepository.get();
- assertEquals(Arrays.asList("id", "text", "style"),
- repository.getTopAttributes("android.widget.RadioButton"));
- assertEquals(Arrays.asList("id", "gravity", "paddingLeft", "paddingRight", "checkMark",
- "textAppearance"),
- repository.getTopAttributes("android.widget.CheckedTextView"));
- assertEquals(Arrays.asList("id"),
- repository.getTopAttributes("android.widget.NonExistent"));
- }
-
-}